1<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>struct spi_device</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Linux Device Drivers"><link rel="up" href="spi.html" title="Chapter 10. Serial Peripheral Interface (SPI)"><link rel="prev" href="API-struct-spi-statistics.html" title="struct spi_statistics"><link rel="next" href="API-struct-spi-driver.html" title="struct spi_driver"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span class="phrase">struct spi_device</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-struct-spi-statistics.html">Prev</a> </td><th width="60%" align="center">Chapter 10. Serial Peripheral Interface (SPI)</th><td width="20%" align="right"> <a accesskey="n" href="API-struct-spi-driver.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-struct-spi-device"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>struct spi_device — 
2     Master side proxy for an SPI slave device
3 </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="programlisting">
4struct spi_device {
5  struct device dev;
6  struct spi_master * master;
7  u32 max_speed_hz;
8  u8 chip_select;
9  u8 bits_per_word;
10  u16 mode;
11#define SPI_CPHA	0x01
12#define SPI_CPOL	0x02
13#define SPI_MODE_0	(0|0)
14#define SPI_MODE_1	(0|SPI_CPHA)
15#define SPI_MODE_2	(SPI_CPOL|0)
16#define SPI_MODE_3	(SPI_CPOL|SPI_CPHA)
17#define SPI_CS_HIGH	0x04
18#define SPI_LSB_FIRST	0x08
19#define SPI_3WIRE	0x10
20#define SPI_LOOP	0x20
21#define SPI_NO_CS	0x40
22#define SPI_READY	0x80
23#define SPI_TX_DUAL	0x100
24#define SPI_TX_QUAD	0x200
25#define SPI_RX_DUAL	0x400
26#define SPI_RX_QUAD	0x800
27  int irq;
28  void * controller_state;
29  void * controller_data;
30  char modalias[SPI_NAME_SIZE];
31  int cs_gpio;
32  struct spi_statistics statistics;
33};  </pre></div><div class="refsect1"><a name="id-1.12.7.5"></a><h2>Members</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term">dev</span></dt><dd><p>
34   Driver model representation of the device.
35      </p></dd><dt><span class="term">master</span></dt><dd><p>
36   SPI controller used with the device.
37      </p></dd><dt><span class="term">max_speed_hz</span></dt><dd><p>
38   Maximum clock rate to be used with this chip
39   (on this board); may be changed by the device's driver.
40   The spi_transfer.speed_hz can override this for each transfer.
41      </p></dd><dt><span class="term">chip_select</span></dt><dd><p>
42   Chipselect, distinguishing chips handled by <em class="parameter"><code>master</code></em>.
43      </p></dd><dt><span class="term">bits_per_word</span></dt><dd><p>
44   Data transfers involve one or more words; word sizes
45   like eight or 12 bits are common.  In-memory wordsizes are
46   powers of two bytes (e.g. 20 bit samples use 32 bits).
47   This may be changed by the device's driver, or left at the
48   default (0) indicating protocol words are eight bit bytes.
49   The spi_transfer.bits_per_word can override this for each transfer.
50      </p></dd><dt><span class="term">mode</span></dt><dd><p>
51   The spi mode defines how data is clocked out and in.
52   This may be changed by the device's driver.
53   The <span class="quote">“<span class="quote">active low</span>”</span> default for chipselect mode can be overridden
54   (by specifying SPI_CS_HIGH) as can the <span class="quote">“<span class="quote">MSB first</span>”</span> default for
55   each word in a transfer (by specifying SPI_LSB_FIRST).
56      </p></dd><dt><span class="term">irq</span></dt><dd><p>
57   Negative, or the number passed to <code class="function">request_irq</code> to receive
58   interrupts from this device.
59      </p></dd><dt><span class="term">controller_state</span></dt><dd><p>
60   Controller's runtime state
61      </p></dd><dt><span class="term">controller_data</span></dt><dd><p>
62   Board-specific definitions for controller, such as
63   FIFO initialization parameters; from board_info.controller_data
64      </p></dd><dt><span class="term">modalias[SPI_NAME_SIZE]</span></dt><dd><p>
65   Name of the driver to use with this device, or an alias
66   for that name.  This appears in the sysfs <span class="quote">“<span class="quote">modalias</span>”</span> attribute
67   for driver coldplugging, and in uevents used for hotplugging
68      </p></dd><dt><span class="term">cs_gpio</span></dt><dd><p>
69   gpio number of the chipselect line (optional, -ENOENT when
70   when not using a GPIO line)
71      </p></dd><dt><span class="term">statistics</span></dt><dd><p>
72   statistics for the spi_device
73      </p></dd></dl></div></div><div class="refsect1"><a name="id-1.12.7.6"></a><h2>Description</h2><p>
74   A <em class="parameter"><code>spi_device</code></em> is used to interchange data between an SPI slave
75   (usually a discrete chip) and CPU memory.
76   </p><p>
77
78   In <em class="parameter"><code>dev</code></em>, the platform_data is used to hold information about this
79   device that's meaningful to the device's protocol driver, but not
80   to its controller.  One example might be an identifier for a chip
81   variant with slightly different functionality; another might be
82   information about how this particular board wires the chip's pins.
83</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-struct-spi-statistics.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="spi.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="API-struct-spi-driver.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">struct spi_statistics</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> <span class="phrase">struct spi_driver</span></td></tr></table></div></body></html>
84