blob: ca6782ee4b9fce4f9208020e552129db6f0fbd5a [file] [log] [blame]
David Brownelld29389d2009-01-06 14:41:41 -08001#ifndef __LINUX_SPI_GPIO_H
2#define __LINUX_SPI_GPIO_H
3
4/*
5 * For each bitbanged SPI bus, set up a platform_device node with:
6 * - name "spi_gpio"
7 * - id the same as the SPI bus number it implements
8 * - dev.platform data pointing to a struct spi_gpio_platform_data
9 *
10 * Or, see the driver code for information about speedups that are
11 * possible on platforms that support inlined access for GPIOs (no
12 * spi_gpio_platform_data is used).
13 *
14 * Use spi_board_info with these busses in the usual way, being sure
15 * that the controller_data being the GPIO used for each device's
16 * chipselect:
17 *
18 * static struct spi_board_info ... [] = {
19 * ...
20 * // this slave uses GPIO 42 for its chipselect
21 * .controller_data = (void *) 42,
22 * ...
23 * // this one uses GPIO 86 for its chipselect
24 * .controller_data = (void *) 86,
25 * ...
26 * };
27 *
Michael Bueschbfb9bcd2009-04-02 16:57:07 -070028 * If chipselect is not used (there's only one device on the bus), assign
29 * SPI_GPIO_NO_CHIPSELECT to the controller_data:
30 * .controller_data = (void *) SPI_GPIO_NO_CHIPSELECT;
31 *
David Brownelld29389d2009-01-06 14:41:41 -080032 * If the bitbanged bus is later switched to a "native" controller,
33 * that platform_device and controller_data should be removed.
34 */
35
Michael Bueschbfb9bcd2009-04-02 16:57:07 -070036#define SPI_GPIO_NO_CHIPSELECT ((unsigned long)-1l)
37
David Brownelld29389d2009-01-06 14:41:41 -080038/**
39 * struct spi_gpio_platform_data - parameter for bitbanged SPI master
40 * @sck: number of the GPIO used for clock output
41 * @mosi: number of the GPIO used for Master Output, Slave In (MOSI) data
42 * @miso: number of the GPIO used for Master Input, Slave Output (MISO) data
43 * @num_chipselect: how many slaves to allow
44 *
45 * All GPIO signals used with the SPI bus managed through this driver
46 * (chipselects, MOSI, MISO, SCK) must be configured as GPIOs, instead
47 * of some alternate function.
48 *
49 * It can be convenient to use this driver with pins that have alternate
50 * functions associated with a "native" SPI controller if a driver for that
51 * controller is not available, or is missing important functionality.
52 *
53 * On platforms which can do so, configure MISO with a weak pullup unless
54 * there's an external pullup on that signal. That saves power by avoiding
55 * floating signals. (A weak pulldown would save power too, but many
56 * drivers expect to see all-ones data as the no slave "response".)
57 */
58struct spi_gpio_platform_data {
59 unsigned sck;
60 unsigned mosi;
61 unsigned miso;
62
63 u16 num_chipselect;
64};
65
66#endif /* __LINUX_SPI_GPIO_H */