machine.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef __LINUX_GPIO_MACHINE_H
  2. #define __LINUX_GPIO_MACHINE_H
  3. #include <linux/types.h>
  4. #include <linux/list.h>
  5. enum gpio_lookup_flags {
  6. GPIO_ACTIVE_HIGH = (0 << 0),
  7. GPIO_ACTIVE_LOW = (1 << 0),
  8. GPIO_OPEN_DRAIN = (1 << 1),
  9. GPIO_OPEN_SOURCE = (1 << 2),
  10. };
  11. /**
  12. * struct gpiod_lookup - lookup table
  13. * @chip_label: name of the chip the GPIO belongs to
  14. * @chip_hwnum: hardware number (i.e. relative to the chip) of the GPIO
  15. * @con_id: name of the GPIO from the device's point of view
  16. * @idx: index of the GPIO in case several GPIOs share the same name
  17. * @flags: mask of GPIO_* values
  18. *
  19. * gpiod_lookup is a lookup table for associating GPIOs to specific devices and
  20. * functions using platform data.
  21. */
  22. struct gpiod_lookup {
  23. const char *chip_label;
  24. u16 chip_hwnum;
  25. const char *con_id;
  26. unsigned int idx;
  27. enum gpio_lookup_flags flags;
  28. };
  29. struct gpiod_lookup_table {
  30. struct list_head list;
  31. const char *dev_id;
  32. struct gpiod_lookup table[];
  33. };
  34. /*
  35. * Simple definition of a single GPIO under a con_id
  36. */
  37. #define GPIO_LOOKUP(_chip_label, _chip_hwnum, _con_id, _flags) \
  38. GPIO_LOOKUP_IDX(_chip_label, _chip_hwnum, _con_id, 0, _flags)
  39. /*
  40. * Use this macro if you need to have several GPIOs under the same con_id.
  41. * Each GPIO needs to use a different index and can be accessed using
  42. * gpiod_get_index()
  43. */
  44. #define GPIO_LOOKUP_IDX(_chip_label, _chip_hwnum, _con_id, _idx, _flags) \
  45. { \
  46. .chip_label = _chip_label, \
  47. .chip_hwnum = _chip_hwnum, \
  48. .con_id = _con_id, \
  49. .idx = _idx, \
  50. .flags = _flags, \
  51. }
  52. void gpiod_add_lookup_table(struct gpiod_lookup_table *table);
  53. void gpiod_remove_lookup_table(struct gpiod_lookup_table *table);
  54. #endif /* __LINUX_GPIO_MACHINE_H */