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