pinctrl-meson.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * (C) Copyright 2016 - Beniamino Galvani <b.galvani@gmail.com>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #ifndef __PINCTRL_MESON_H__
  7. #define __PINCTRL_MESON_H__
  8. #include <linux/types.h>
  9. struct meson_pmx_group {
  10. const char *name;
  11. const unsigned int *pins;
  12. unsigned int num_pins;
  13. bool is_gpio;
  14. unsigned int reg;
  15. unsigned int bit;
  16. };
  17. struct meson_pmx_func {
  18. const char *name;
  19. const char * const *groups;
  20. unsigned int num_groups;
  21. };
  22. struct meson_pinctrl_data {
  23. const char *name;
  24. struct meson_pmx_group *groups;
  25. struct meson_pmx_func *funcs;
  26. unsigned int pin_base;
  27. unsigned int num_pins;
  28. unsigned int num_groups;
  29. unsigned int num_funcs;
  30. };
  31. struct meson_pinctrl {
  32. struct meson_pinctrl_data *data;
  33. void __iomem *reg_mux;
  34. };
  35. #define PIN(x, b) (b + x)
  36. #define GROUP(grp, r, b) \
  37. { \
  38. .name = #grp, \
  39. .pins = grp ## _pins, \
  40. .num_pins = ARRAY_SIZE(grp ## _pins), \
  41. .reg = r, \
  42. .bit = b, \
  43. }
  44. #define GPIO_GROUP(gpio, b) \
  45. { \
  46. .name = #gpio, \
  47. .pins = (const unsigned int[]){ PIN(gpio, b) }, \
  48. .num_pins = 1, \
  49. .is_gpio = true, \
  50. }
  51. #define FUNCTION(fn) \
  52. { \
  53. .name = #fn, \
  54. .groups = fn ## _groups, \
  55. .num_groups = ARRAY_SIZE(fn ## _groups), \
  56. }
  57. #define MESON_PIN(x, b) PINCTRL_PIN(PIN(x, b), #x)
  58. extern const struct pinctrl_ops meson_pinctrl_ops;
  59. int meson_pinctrl_probe(struct udevice *dev);
  60. #endif /* __PINCTRL_MESON_H__ */