spi_gpio.h 2.5 KB

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