Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
d29389de DB |
2 | #ifndef __LINUX_SPI_GPIO_H |
3 | #define __LINUX_SPI_GPIO_H | |
4 | ||
5 | /* | |
6 | * For each bitbanged SPI bus, set up a platform_device node with: | |
7 | * - name "spi_gpio" | |
8 | * - id the same as the SPI bus number it implements | |
9 | * - dev.platform data pointing to a struct spi_gpio_platform_data | |
10 | * | |
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). | |
14 | * | |
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 | |
17 | * chipselect: | |
18 | * | |
19 | * static struct spi_board_info ... [] = { | |
20 | * ... | |
21 | * // this slave uses GPIO 42 for its chipselect | |
22 | * .controller_data = (void *) 42, | |
23 | * ... | |
24 | * // this one uses GPIO 86 for its chipselect | |
25 | * .controller_data = (void *) 86, | |
26 | * ... | |
27 | * }; | |
28 | * | |
bfb9bcdb MB |
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; | |
32 | * | |
3c8e1a84 MS |
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. | |
35 | * | |
d29389de DB |
36 | * If the bitbanged bus is later switched to a "native" controller, |
37 | * that platform_device and controller_data should be removed. | |
38 | */ | |
39 | ||
bfb9bcdb | 40 | #define SPI_GPIO_NO_CHIPSELECT ((unsigned long)-1l) |
3c8e1a84 MS |
41 | #define SPI_GPIO_NO_MISO ((unsigned long)-1l) |
42 | #define SPI_GPIO_NO_MOSI ((unsigned long)-1l) | |
bfb9bcdb | 43 | |
d29389de DB |
44 | /** |
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 | |
50 | * | |
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. | |
54 | * | |
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. | |
58 | * | |
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".) | |
63 | */ | |
64 | struct spi_gpio_platform_data { | |
65 | unsigned sck; | |
d560040f MR |
66 | unsigned long mosi; |
67 | unsigned long miso; | |
d29389de DB |
68 | |
69 | u16 num_chipselect; | |
70 | }; | |
71 | ||
72 | #endif /* __LINUX_SPI_GPIO_H */ |