brintos

brintos / linux-shallow public Read only

0
0
Text · 2.7 KiB · f288870 Raw
54 lines · plain
1Serial Peripheral Interface (SPI)2=================================3 4SPI is the "Serial Peripheral Interface", widely used with embedded5systems because it is a simple and efficient interface: basically a6multiplexed shift register. Its three signal wires hold a clock (SCK,7often in the range of 1-20 MHz), a "Master Out, Slave In" (MOSI) data8line, and a "Master In, Slave Out" (MISO) data line. SPI is a full9duplex protocol; for each bit shifted out the MOSI line (one per clock)10another is shifted in on the MISO line. Those bits are assembled into11words of various sizes on the way to and from system memory. An12additional chipselect line is usually active-low (nCS); four signals are13normally used for each peripheral, plus sometimes an interrupt.14 15The SPI bus facilities listed here provide a generalized interface to16declare SPI busses and devices, manage them according to the standard17Linux driver model, and perform input/output operations. At this time,18only "master" side interfaces are supported, where Linux talks to SPI19peripherals and does not implement such a peripheral itself. (Interfaces20to support implementing SPI slaves would necessarily look different.)21 22The programming interface is structured around two kinds of driver, and23two kinds of device. A "Controller Driver" abstracts the controller24hardware, which may be as simple as a set of GPIO pins or as complex as25a pair of FIFOs connected to dual DMA engines on the other side of the26SPI shift register (maximizing throughput). Such drivers bridge between27whatever bus they sit on (often the platform bus) and SPI, and expose28the SPI side of their device as a :c:type:`struct spi_controller29<spi_controller>`. SPI devices are children of that master,30represented as a :c:type:`struct spi_device <spi_device>` and31manufactured from :c:type:`struct spi_board_info32<spi_board_info>` descriptors which are usually provided by33board-specific initialization code. A :c:type:`struct spi_driver34<spi_driver>` is called a "Protocol Driver", and is bound to a35spi_device using normal driver model calls.36 37The I/O model is a set of queued messages. Protocol drivers submit one38or more :c:type:`struct spi_message <spi_message>` objects,39which are processed and completed asynchronously. (There are synchronous40wrappers, however.) Messages are built from one or more41:c:type:`struct spi_transfer <spi_transfer>` objects, each of42which wraps a full duplex SPI transfer. A variety of protocol tweaking43options are needed, because different chips adopt very different44policies for how they use the bits transferred with SPI.45 46.. kernel-doc:: include/linux/spi/spi.h47   :internal:48 49.. kernel-doc:: drivers/spi/spi.c50   :functions: spi_register_board_info51 52.. kernel-doc:: drivers/spi/spi.c53   :export:54