一方面对SPI子系统进行初始化工作,注册spi bus,注册spi_masterclass,同时提供spi设备驱动对spi总线进行操作的API。 另一方面SPI子系统对spi控制器层,提供注册控制器的api和回调操作函数。spi.h包含了spi核心层的一些重要数据结构,structspi_master;structspi_transfer;structspi_message,以及一些实现比较简单的函数等。spi...
1.1 spi设备的添加spi_new_device structspi_device*spi_new_device(structspi_master*master,structspi_board_info*chip){structspi_device*proxy;intstatus;/* NOTE: caller did any chip->bus_num checks necessary.** Also, unless we change the return value convention to use* error-or-pointer (not N...
SPI设备是主设备的子设备,由struct spi_device表示,并由struct spi_board_info描述符进行描述,这些描述符通常由特定板卡的初始化代码提供。 struct spi_driver称为协议驱动程序,并通过正常的驱动程序模型绑定到spi_device。 SPI的I/O模型是一组排队的消息,在协议驱动程序中可提交一个或多个struct spi_message对象,...
第434 行,transfer_one_message 函数,也用于 SPI 数据发送,用于发送一个 spi_message,SPI 的数据会打包成 spi_message,然后以队列方式发送出去。 也就是 SPI 主机端最终会通过 transfer 函数与 SPI 设备进行通信,因此对于 SPI 主机控制器的驱动编写者而言 transfer 函数是需要实现的,因为不同的 SOC 其 SPI 控制...
SPI,是英语Serial Peripheral interface的缩写,顾名思义就是串行外围设备接口。是Motorola首先在其MC68HCXX系列处理器上定义的。SPI接口主要应用在 EEPROM,FLASH,实时时钟,AD转换器,还有数字信号处理器和数字信号解码器之间。
从Makefile可知,内核提供的SPI框架主要实现在spi.c、spidev.c文件中。 spi.c文件实现了spi核心的初始化,以及实现spi框架的相关API接口。(如果想让系统支持spi,此文件必须被编译) spidev.c文件用于实现SPI设备同步用户空间接口。(该文件为可选特性) 存在/drivers/spi路径下其他洋洋洒洒的文件则是不同厂家提供的SPI...
最后关键是调用了s3c24xx_spi_initialsetup函数,该函数内部最后调用了spi_register_master方法来注册SPI控制器。类比I2C在probe函数中调用的i2c_add_numbered_adapter函数,其内部会扫描SPI的板卡信息,然后利用板卡信息生成SPI设备,并将控制器spi_master挂接到spi_device上,随后在SPI设备驱动层中注册设备驱动后调用probe...
int (*setup)(struct spi_device *spi); int (*transfer)(struct spi_device *spi, struct spi_message *mesg); void (*cleanup)(struct spi_device *spi); struct kthread_worker kworker; struct task_struct *kworker_task; struct kthread_work pump_messages; struct list_head queue; struct spi_mes...
int(*setup)(struct spi_device *spi);更新SPI采样时钟 int(*transfer)(struct spi_device *spi,struct spi_message *mesg);添加消息到SPI控制器的队列 void(*cleanup)(struct spi_device *spi); boolqueued; struct kthread_workerkworker; ...
setup函数是设置SPI总线的模式,时钟等的初始化函数, 针对设备设置SPI的工作时钟及数据传输模式等。在spi_add_device函数中调用。 transfer函数是实现SPI总线读写方法的函数。实现数据的双向传输,可能会睡眠 cleanup 注销的时候调用 3.2 SPI设备驱动层 SPI设备驱动层为用户接口层,其为用户提供了通过SPI总线访问具体设备...