pinctrl-pxa2xx.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Marvell PXA2xx family pin control
  3. *
  4. * Copyright (C) 2015 Robert Jarzmik
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; version 2 of the License.
  9. *
  10. */
  11. #ifndef __PINCTRL_PXA_H
  12. #define __PINCTRL_PXA_H
  13. #define PXA_FUNCTION(_dir, _af, _name) \
  14. { \
  15. .name = _name, \
  16. .muxval = (_dir | (_af << 1)), \
  17. }
  18. #define PXA_PIN(_pin, funcs...) \
  19. { \
  20. .pin = _pin, \
  21. .functions = (struct pxa_desc_function[]){ \
  22. funcs, { } }, \
  23. }
  24. #define PXA_GPIO_PIN(_pin, funcs...) \
  25. { \
  26. .pin = _pin, \
  27. .functions = (struct pxa_desc_function[]){ \
  28. PXA_FUNCTION(0, 0, "gpio_in"), \
  29. PXA_FUNCTION(1, 0, "gpio_out"), \
  30. funcs, { } }, \
  31. }
  32. #define PXA_GPIO_ONLY_PIN(_pin) \
  33. { \
  34. .pin = _pin, \
  35. .functions = (struct pxa_desc_function[]){ \
  36. PXA_FUNCTION(0, 0, "gpio_in"), \
  37. PXA_FUNCTION(1, 0, "gpio_out"), \
  38. { } }, \
  39. }
  40. #define PXA_PINCTRL_PIN(pin) \
  41. PINCTRL_PIN(pin, "P" #pin)
  42. struct pxa_desc_function {
  43. const char *name;
  44. u8 muxval;
  45. };
  46. struct pxa_desc_pin {
  47. struct pinctrl_pin_desc pin;
  48. struct pxa_desc_function *functions;
  49. };
  50. struct pxa_pinctrl_group {
  51. const char *name;
  52. unsigned pin;
  53. };
  54. struct pxa_pinctrl_function {
  55. const char *name;
  56. const char **groups;
  57. unsigned ngroups;
  58. };
  59. struct pxa_pinctrl {
  60. spinlock_t lock;
  61. void __iomem **base_gafr;
  62. void __iomem **base_gpdr;
  63. void __iomem **base_pgsr;
  64. struct device *dev;
  65. struct pinctrl_desc desc;
  66. struct pinctrl_dev *pctl_dev;
  67. unsigned npins;
  68. const struct pxa_desc_pin *ppins;
  69. unsigned ngroups;
  70. struct pxa_pinctrl_group *groups;
  71. unsigned nfuncs;
  72. struct pxa_pinctrl_function *functions;
  73. char *name;
  74. };
  75. int pxa2xx_pinctrl_init(struct platform_device *pdev,
  76. const struct pxa_desc_pin *ppins, int npins,
  77. void __iomem *base_gafr[], void __iomem *base_gpdr[],
  78. void __iomem *base_gpsr[]);
  79. #endif /* __PINCTRL_PXA_H */