<?xml version="1.0" encoding="ANSI_X3.4-1968" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968" /><title>struct spi_master</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><link rel="home" href="index.html" title="Linux Device Drivers" /><link rel="up" href="ch09.html" title="Chapter 9. Serial Peripheral Interface (SPI)" /><link rel="prev" href="re732.html" title="spi_unregister_driver" /><link rel="next" href="re734.html" title="struct spi_transfer" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span>struct spi_master</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="re732.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="re734.html">Next</a></td></tr></table><hr /></div><div class="refentry" title="struct spi_master"><a id="API-struct-spi-master"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>struct spi_master — interface to SPI master controller </p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><pre class="programlisting"> struct spi_master { struct device dev; s16 bus_num; u16 num_chipselect; u16 dma_alignment; u16 mode_bits; u16 flags; #define SPI_MASTER_HALF_DUPLEX BIT(0) #define SPI_MASTER_NO_RX BIT(1) #define SPI_MASTER_NO_TX BIT(2) int (* setup) (struct spi_device *spi); int (* transfer) (struct spi_device *spi,struct spi_message *mesg); void (* cleanup) (struct spi_device *spi); }; </pre></div><div class="refsect1" title="Members"><a id="id2704529"></a><h2>Members</h2><div class="variablelist"><dl><dt><span class="term">dev</span></dt><dd><p> device interface to this driver </p></dd><dt><span class="term">bus_num</span></dt><dd><p> board-specific (and often SOC-specific) identifier for a given SPI controller. </p></dd><dt><span class="term">num_chipselect</span></dt><dd><p> chipselects are used to distinguish individual SPI slaves, and are numbered from zero to num_chipselects. each slave has a chipselect signal, but it's common that not every chipselect is connected to a slave. </p></dd><dt><span class="term">dma_alignment</span></dt><dd><p> SPI controller constraint on DMA buffers alignment. </p></dd><dt><span class="term">mode_bits</span></dt><dd><p> flags understood by this controller driver </p></dd><dt><span class="term">flags</span></dt><dd><p> other constraints relevant to this driver </p></dd><dt><span class="term">setup</span></dt><dd><p> updates the device mode and clocking records used by a device's SPI controller; protocol code may call this. This must fail if an unrecognized or unsupported mode is requested. It's always safe to call this unless transfers are pending on the device whose settings are being modified. </p></dd><dt><span class="term">transfer</span></dt><dd><p> adds a message to the controller's transfer queue. </p></dd><dt><span class="term">cleanup</span></dt><dd><p> frees controller-specific state </p></dd></dl></div></div><div class="refsect1" title="Description"><a id="id2704652"></a><h2>Description</h2><p> Each SPI master controller can communicate with one or more <em class="parameter"><code>spi_device</code></em> children. These make a small bus, sharing MOSI, MISO and SCK signals but not chip select signals. Each device may be configured to use a different clock rate, since those shared signals are ignored unless the chip is selected. </p><p> The driver for an SPI controller manages access to those devices through a queue of spi_message transactions, copying data between CPU memory and an SPI slave device. For each such message it queues, it calls the message's completion function when the transaction completes. </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="re732.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch09.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="re734.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span>spi_unregister_driver</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> <span>struct spi_transfer</span></td></tr></table></div></body></html>