2016年6月22日 星期三

spi on 4412 exunos


The kernel SPI subsystem is divided into Controller Driver and Protocol Drivers.


Controller Driver
A controller driver is represented by the structure spi_master. The driver for an SPI controller manages access to spi slave devices through a queue of spi_message transactions, copying data between CPU memory and an SPI slave device. For each such message it queues, it calls the message’s completion function when the transaction completes.


软件平台:Android ICS & kernel version 3.0.15

打开方式:make menuconfigàDevice DriversàSPI supportàSamsung S3C64XX series type SPI.

编译后生成zImage,烧录进开发板

Protocol Driver
A Protocol driver is represented by the structure spi_driver, they pass messages through the controller driver to communicate with a Slave or Master device on the other side of an SPI link. For example one protocol driver might talk to the MTD layer to export data to file systems stored on SPI flash like Data Flash; and others might control audio interfaces, present touchscreen sensors as input interfaces, or monitor temperature and voltage levels during industrial processing. And those might all be sharing the same controller driver.


drivers/spi/spidev.c,生成spidev.ko,便是通用的设备端SPI驱动程序


Initializing and probing of SPI Controller Driver

For embedded System-on-Chip (SOC) based boards, SPI master controllers connect to their drivers using some non SPI bus, such as the platform bus. Initializing and probing SPI controller driver is performed using the platform bus. During the initial stage of platform driver registration stage of probe() in that code includes calling spi_alloc_master which allocated the structure spi_master in the kernel and during final stage calling spi_register_master() to hook up to this SPI bus glue.
SPI controller’s will usually be platform devices, and the controller may need some platform_data in order to operate properly. The “struct platform_device” will include resources like the physical address of the controller’s first register and its IRQ.
Platforms will often abstract the “register SPI controller” operation,maybe coupling it with code to initialize pin configurations in the board initialization files. This is because most SOCs have several SPI-capable controllers, and only the ones actually usable on a given board should normally be set up and registered.

/* spi bus : spi0 */
 static struct platform_device mysoc_spi_dev0 = {
 .name = “mysoc_spi”,
 .id = 0,
 . resource = &mysoc_spi_resources [0] ,
 . num_resources = 2,
 . dev = {
 . platform_data = &mysoc_spi_dev0_data ,
 },
 };

 static int __init mysoc_spi_init ( void )
 {
 …
 platform_device_register (&mysoc_spi_dev0 );
 …
 }



Ref : http://www.bkjia.com/Androidjc/760248.html

Ref : http://invo-tronics.com/spi-driver-for-linux-based-embedded-system/

沒有留言:

張貼留言