Linux SPI 驱动框架分为两部分:
SPI总线控制器驱动:SOC的 SPI 控制器外设驱动SPI设备驱动:基于SPI总线控制器驱动编写,针对具体的SPI从机设备
一、SPI总线控制器驱动
基于platform平台驱动框架,Linux内核将SOC的SPI外设主机功能抽象为 spi_master 结构体。
spi_master 结构体定义在include/linux/spi/spi.h
文件中,如下:
/*** struct spi_master - interface to SPI master controller* @dev: device interface to this driver* @list: link with the global spi_master list* @bus_num: board-specific (and often SOC-specific) identifier for a*given SPI controller.* @num_chipselect: chipselects are used to distinguish individual*SPI slaves, and are numbered from zero to num_chipselects.*each slave has a chipselect signal, but its common that not*every chipselect is connected to a slave.* @dma_alignment: SPI controller constraint on DMA buffers alignment.* @mode_