1STRUCT SPI_DEVICE(9)    Serial Peripheral Interface (S    STRUCT SPI_DEVICE(9)
2
3
4

NAME

6       struct_spi_device - Master side proxy for an SPI slave device
7

SYNOPSIS

9       struct spi_device {
10         struct device dev;
11         struct spi_master * master;
12         u32 max_speed_hz;
13         u8 chip_select;
14         u8 mode;
15       #define SPI_CPHA    0x01
16       #define SPI_CPOL    0x02
17       #define SPI_MODE_0  (0|0)
18       #define SPI_MODE_1  (0|SPI_CPHA)
19       #define SPI_MODE_2  (SPI_CPOL|0)
20       #define SPI_MODE_3  (SPI_CPOL|SPI_CPHA)
21       #define SPI_CS_HIGH 0x04
22       #define SPI_LSB_FIRST    0x08
23       #define SPI_3WIRE   0x10
24       #define SPI_LOOP    0x20
25       #define SPI_NO_CS   0x40
26       #define SPI_READY   0x80
27         u8 bits_per_word;
28         int irq;
29         void * controller_state;
30         void * controller_data;
31         char modalias[SPI_NAME_SIZE];
32         int cs_gpio;
33       };
34

MEMBERS

36       dev
37           Driver model representation of the device.
38
39       master
40           SPI controller used with the device.
41
42       max_speed_hz
43           Maximum clock rate to be used with this chip (on this board); may
44           be changed by the device's driver. The spi_transfer.speed_hz can
45           override this for each transfer.
46
47       chip_select
48           Chipselect, distinguishing chips handled by master.
49
50       mode
51           The spi mode defines how data is clocked out and in. This may be
52           changed by the device's driver. The “active low” default for
53           chipselect mode can be overridden (by specifying SPI_CS_HIGH) as
54           can the “MSB first” default for each word in a transfer (by
55           specifying SPI_LSB_FIRST).
56
57       bits_per_word
58           Data transfers involve one or more words; word sizes like eight or
59           12 bits are common. In-memory wordsizes are powers of two bytes
60           (e.g. 20 bit samples use 32 bits). This may be changed by the
61           device's driver, or left at the default (0) indicating protocol
62           words are eight bit bytes. The spi_transfer.bits_per_word can
63           override this for each transfer.
64
65       irq
66           Negative, or the number passed to request_irq to receive interrupts
67           from this device.
68
69       controller_state
70           Controller's runtime state
71
72       controller_data
73           Board-specific definitions for controller, such as FIFO
74           initialization parameters; from board_info.controller_data
75
76       modalias[SPI_NAME_SIZE]
77           Name of the driver to use with this device, or an alias for that
78           name. This appears in the sysfs “modalias” attribute for driver
79           coldplugging, and in uevents used for hotplugging
80
81       cs_gpio
82           gpio number of the chipselect line (optional, -ENOENT when when not
83           using a GPIO line)
84

DESCRIPTION

86       A spi_device is used to interchange data between an SPI slave (usually
87       a discrete chip) and CPU memory.
88
89       In dev, the platform_data is used to hold information about this device
90       that's meaningful to the device's protocol driver, but not to its
91       controller. One example might be an identifier for a chip variant with
92       slightly different functionality; another might be information about
93       how this particular board wires the chip's pins.
94
96Kernel Hackers Manual 3.10         June 2019              STRUCT SPI_DEVICE(9)
Impressum