blob: d0d65e58c14b04f010723752d858619806a8eb24 [file] [log] [blame]
Jonathan Corbetdcec3c82016-08-20 13:17:32 -06001Serial Peripheral Interface (SPI)
2=================================
3
4SPI is the "Serial Peripheral Interface", widely used with embedded
5systems because it is a simple and efficient interface: basically a
6multiplexed shift register. Its three signal wires hold a clock (SCK,
7often in the range of 1-20 MHz), a "Master Out, Slave In" (MOSI) data
8line, and a "Master In, Slave Out" (MISO) data line. SPI is a full
9duplex protocol; for each bit shifted out the MOSI line (one per clock)
10another is shifted in on the MISO line. Those bits are assembled into
11words of various sizes on the way to and from system memory. An
12additional chipselect line is usually active-low (nCS); four signals are
13normally used for each peripheral, plus sometimes an interrupt.
14
15The SPI bus facilities listed here provide a generalized interface to
16declare SPI busses and devices, manage them according to the standard
17Linux driver model, and perform input/output operations. At this time,
18only "master" side interfaces are supported, where Linux talks to SPI
19peripherals and does not implement such a peripheral itself. (Interfaces
20to support implementing SPI slaves would necessarily look different.)
21
22The programming interface is structured around two kinds of driver, and
23two kinds of device. A "Controller Driver" abstracts the controller
24hardware, which may be as simple as a set of GPIO pins or as complex as
25a pair of FIFOs connected to dual DMA engines on the other side of the
26SPI shift register (maximizing throughput). Such drivers bridge between
27whatever bus they sit on (often the platform bus) and SPI, and expose
28the SPI side of their device as a :c:type:`struct spi_master
29<spi_master>`. SPI devices are children of that master,
30represented as a :c:type:`struct spi_device <spi_device>` and
31manufactured from :c:type:`struct spi_board_info
32<spi_board_info>` descriptors which are usually provided by
33board-specific initialization code. A :c:type:`struct spi_driver
34<spi_driver>` is called a "Protocol Driver", and is bound to a
35spi_device using normal driver model calls.
36
37The I/O model is a set of queued messages. Protocol drivers submit one
38or more :c:type:`struct spi_message <spi_message>` objects,
39which are processed and completed asynchronously. (There are synchronous
40wrappers, however.) Messages are built from one or more
41:c:type:`struct spi_transfer <spi_transfer>` objects, each of
42which wraps a full duplex SPI transfer. A variety of protocol tweaking
43options are needed, because different chips adopt very different
44policies for how they use the bits transferred with SPI.
45
46.. kernel-doc:: include/linux/spi/spi.h
47 :internal:
48
49.. kernel-doc:: drivers/spi/spi.c
50 :functions: spi_register_board_info
51
52.. kernel-doc:: drivers/spi/spi.c
53 :export:
54
55I\ :sup:`2`\ C and SMBus Subsystem
56==================================
57
58I\ :sup:`2`\ C (or without fancy typography, "I2C") is an acronym for
59the "Inter-IC" bus, a simple bus protocol which is widely used where low
60data rate communications suffice. Since it's also a licensed trademark,
61some vendors use another name (such as "Two-Wire Interface", TWI) for
62the same bus. I2C only needs two signals (SCL for clock, SDA for data),
63conserving board real estate and minimizing signal quality issues. Most
64I2C devices use seven bit addresses, and bus speeds of up to 400 kHz;
65there's a high speed extension (3.4 MHz) that's not yet found wide use.
66I2C is a multi-master bus; open drain signaling is used to arbitrate
67between masters, as well as to handshake and to synchronize clocks from
68slower clients.
69
70The Linux I2C programming interfaces support only the master side of bus
71interactions, not the slave side. The programming interface is
72structured around two kinds of driver, and two kinds of device. An I2C
73"Adapter Driver" abstracts the controller hardware; it binds to a
74physical device (perhaps a PCI device or platform_device) and exposes a
75:c:type:`struct i2c_adapter <i2c_adapter>` representing each
76I2C bus segment it manages. On each I2C bus segment will be I2C devices
77represented by a :c:type:`struct i2c_client <i2c_client>`.
78Those devices will be bound to a :c:type:`struct i2c_driver
79<i2c_driver>`, which should follow the standard Linux driver
80model. (At this writing, a legacy model is more widely used.) There are
81functions to perform various I2C protocol operations; at this writing
82all such functions are usable only from task context.
83
84The System Management Bus (SMBus) is a sibling protocol. Most SMBus
85systems are also I2C conformant. The electrical constraints are tighter
86for SMBus, and it standardizes particular protocol messages and idioms.
87Controllers that support I2C can also support most SMBus operations, but
88SMBus controllers don't support all the protocol options that an I2C
89controller will. There are functions to perform various SMBus protocol
90operations, either using I2C primitives or by issuing SMBus commands to
91i2c_adapter devices which don't support those I2C operations.
92
93.. kernel-doc:: include/linux/i2c.h
94 :internal:
95
96.. kernel-doc:: drivers/i2c/i2c-boardinfo.c
97 :functions: i2c_register_board_info
98
99.. kernel-doc:: drivers/i2c/i2c-core.c
100 :export:
101
102High Speed Synchronous Serial Interface (HSI)
103=============================================
104
105High Speed Synchronous Serial Interface (HSI) is a serial interface
106mainly used for connecting application engines (APE) with cellular modem
107engines (CMT) in cellular handsets. HSI provides multiplexing for up to
10816 logical channels, low-latency and full duplex communication.
109
110.. kernel-doc:: include/linux/hsi/hsi.h
111 :internal:
112
113.. kernel-doc:: drivers/hsi/hsi_core.c
114 :export:
115