1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><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 9. Serial Peripheral Interface (SPI)"><link rel="prev" href="spi.html" title="Chapter 9. Serial Peripheral Interface (SPI)"><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="spi.html">Prev</a> </td><th width="60%" align="center">Chapter 9. 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}; </pre></div><div class="refsect1"><a name="idp1114817460"></a><h2>Members</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term">dev</span></dt><dd><p> 33Driver model representation of the device. 34 </p></dd><dt><span class="term">master</span></dt><dd><p> 35SPI controller used with the device. 36 </p></dd><dt><span class="term">max_speed_hz</span></dt><dd><p> 37Maximum clock rate to be used with this chip 38(on this board); may be changed by the device's driver. 39The spi_transfer.speed_hz can override this for each transfer. 40 </p></dd><dt><span class="term">chip_select</span></dt><dd><p> 41Chipselect, distinguishing chips handled by <em class="parameter"><code>master</code></em>. 42 </p></dd><dt><span class="term">bits_per_word</span></dt><dd><p> 43Data transfers involve one or more words; word sizes 44like eight or 12 bits are common. In-memory wordsizes are 45powers of two bytes (e.g. 20 bit samples use 32 bits). 46This may be changed by the device's driver, or left at the 47default (0) indicating protocol words are eight bit bytes. 48The spi_transfer.bits_per_word can override this for each transfer. 49 </p></dd><dt><span class="term">mode</span></dt><dd><p> 50The spi mode defines how data is clocked out and in. 51This may be changed by the device's driver. 52The <span class="quote">“<span class="quote">active low</span>”</span> default for chipselect mode can be overridden 53(by specifying SPI_CS_HIGH) as can the <span class="quote">“<span class="quote">MSB first</span>”</span> default for 54each word in a transfer (by specifying SPI_LSB_FIRST). 55 </p></dd><dt><span class="term">irq</span></dt><dd><p> 56Negative, or the number passed to <code class="function">request_irq</code> to receive 57interrupts from this device. 58 </p></dd><dt><span class="term">controller_state</span></dt><dd><p> 59Controller's runtime state 60 </p></dd><dt><span class="term">controller_data</span></dt><dd><p> 61Board-specific definitions for controller, such as 62FIFO initialization parameters; from board_info.controller_data 63 </p></dd><dt><span class="term">modalias[SPI_NAME_SIZE]</span></dt><dd><p> 64Name of the driver to use with this device, or an alias 65for that name. This appears in the sysfs <span class="quote">“<span class="quote">modalias</span>”</span> attribute 66for driver coldplugging, and in uevents used for hotplugging 67 </p></dd><dt><span class="term">cs_gpio</span></dt><dd><p> 68gpio number of the chipselect line (optional, -ENOENT when 69when not using a GPIO line) 70 </p></dd></dl></div></div><div class="refsect1"><a name="idp1114828172"></a><h2>Description</h2><p> 71 A <em class="parameter"><code>spi_device</code></em> is used to interchange data between an SPI slave 72 (usually a discrete chip) and CPU memory. 73 </p><p> 74 75 In <em class="parameter"><code>dev</code></em>, the platform_data is used to hold information about this 76 device that's meaningful to the device's protocol driver, but not 77 to its controller. One example might be an identifier for a chip 78 variant with slightly different functionality; another might be 79 information about how this particular board wires the chip's pins. 80</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="spi.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">Chapter 9. Serial Peripheral Interface (SPI) </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> 81