pinctrl-owl.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * OWL SoC's Pinctrl definitions
  4. *
  5. * Copyright (c) 2014 Actions Semi Inc.
  6. * Author: David Liu <liuwei@actions-semi.com>
  7. *
  8. * Copyright (c) 2018 Linaro Ltd.
  9. * Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
  10. */
  11. #ifndef __PINCTRL_OWL_H__
  12. #define __PINCTRL_OWL_H__
  13. #define OWL_PINCONF_SLEW_SLOW 0
  14. #define OWL_PINCONF_SLEW_FAST 1
  15. enum owl_pinconf_pull {
  16. OWL_PINCONF_PULL_HIZ,
  17. OWL_PINCONF_PULL_DOWN,
  18. OWL_PINCONF_PULL_UP,
  19. OWL_PINCONF_PULL_HOLD,
  20. };
  21. enum owl_pinconf_drv {
  22. OWL_PINCONF_DRV_2MA,
  23. OWL_PINCONF_DRV_4MA,
  24. OWL_PINCONF_DRV_8MA,
  25. OWL_PINCONF_DRV_12MA,
  26. };
  27. /* GPIO CTRL Bit Definition */
  28. #define OWL_GPIO_CTLR_PENDING 0
  29. #define OWL_GPIO_CTLR_ENABLE 1
  30. #define OWL_GPIO_CTLR_SAMPLE_CLK_24M 2
  31. /* GPIO TYPE Bit Definition */
  32. #define OWL_GPIO_INT_LEVEL_HIGH 0
  33. #define OWL_GPIO_INT_LEVEL_LOW 1
  34. #define OWL_GPIO_INT_EDGE_RISING 2
  35. #define OWL_GPIO_INT_EDGE_FALLING 3
  36. #define OWL_GPIO_INT_MASK 3
  37. /**
  38. * struct owl_pullctl - Actions pad pull control register
  39. * @reg: offset to the pull control register
  40. * @shift: shift value of the register
  41. * @width: width of the register
  42. */
  43. struct owl_pullctl {
  44. int reg;
  45. unsigned int shift;
  46. unsigned int width;
  47. };
  48. /**
  49. * struct owl_st - Actions pad schmitt trigger enable register
  50. * @reg: offset to the schmitt trigger enable register
  51. * @shift: shift value of the register
  52. * @width: width of the register
  53. */
  54. struct owl_st {
  55. int reg;
  56. unsigned int shift;
  57. unsigned int width;
  58. };
  59. /**
  60. * struct owl_pingroup - Actions pingroup definition
  61. * @name: name of the pin group
  62. * @pads: list of pins assigned to this pingroup
  63. * @npads: size of @pads array
  64. * @funcs: list of pinmux functions for this pingroup
  65. * @nfuncs: size of @funcs array
  66. * @mfpctl_reg: multiplexing control register offset
  67. * @mfpctl_shift: multiplexing control register bit mask
  68. * @mfpctl_width: multiplexing control register width
  69. * @drv_reg: drive control register offset
  70. * @drv_shift: drive control register bit mask
  71. * @drv_width: driver control register width
  72. * @sr_reg: slew rate control register offset
  73. * @sr_shift: slew rate control register bit mask
  74. * @sr_width: slew rate control register width
  75. */
  76. struct owl_pingroup {
  77. const char *name;
  78. unsigned int *pads;
  79. unsigned int npads;
  80. unsigned int *funcs;
  81. unsigned int nfuncs;
  82. int mfpctl_reg;
  83. unsigned int mfpctl_shift;
  84. unsigned int mfpctl_width;
  85. int drv_reg;
  86. unsigned int drv_shift;
  87. unsigned int drv_width;
  88. int sr_reg;
  89. unsigned int sr_shift;
  90. unsigned int sr_width;
  91. };
  92. /**
  93. * struct owl_padinfo - Actions pinctrl pad info
  94. * @pad: pad name of the SoC
  95. * @pullctl: pull control register info
  96. * @st: schmitt trigger register info
  97. */
  98. struct owl_padinfo {
  99. int pad;
  100. struct owl_pullctl *pullctl;
  101. struct owl_st *st;
  102. };
  103. /**
  104. * struct owl_pinmux_func - Actions pinctrl mux functions
  105. * @name: name of the pinmux function.
  106. * @groups: array of pin groups that may select this function.
  107. * @ngroups: number of entries in @groups.
  108. */
  109. struct owl_pinmux_func {
  110. const char *name;
  111. const char * const *groups;
  112. unsigned int ngroups;
  113. };
  114. /**
  115. * struct owl_gpio_port - Actions GPIO port info
  116. * @offset: offset of the GPIO port.
  117. * @pins: number of pins belongs to the GPIO port.
  118. * @outen: offset of the output enable register.
  119. * @inen: offset of the input enable register.
  120. * @dat: offset of the data register.
  121. * @intc_ctl: offset of the interrupt control register.
  122. * @intc_pd: offset of the interrupt pending register.
  123. * @intc_msk: offset of the interrupt mask register.
  124. * @intc_type: offset of the interrupt type register.
  125. */
  126. struct owl_gpio_port {
  127. unsigned int offset;
  128. unsigned int pins;
  129. unsigned int outen;
  130. unsigned int inen;
  131. unsigned int dat;
  132. unsigned int intc_ctl;
  133. unsigned int intc_pd;
  134. unsigned int intc_msk;
  135. unsigned int intc_type;
  136. };
  137. /**
  138. * struct owl_pinctrl_soc_data - Actions pin controller driver configuration
  139. * @pins: array describing all pins of the pin controller.
  140. * @npins: number of entries in @pins.
  141. * @functions: array describing all mux functions of this SoC.
  142. * @nfunction: number of entries in @functions.
  143. * @groups: array describing all pin groups of this SoC.
  144. * @ngroups: number of entries in @groups.
  145. * @padinfo: array describing the pad info of this SoC.
  146. * @ngpios: number of pingroups the driver should expose as GPIOs.
  147. * @ports: array describing all GPIO ports of this SoC.
  148. * @nports: number of GPIO ports in this SoC.
  149. */
  150. struct owl_pinctrl_soc_data {
  151. const struct pinctrl_pin_desc *pins;
  152. unsigned int npins;
  153. const struct owl_pinmux_func *functions;
  154. unsigned int nfunctions;
  155. const struct owl_pingroup *groups;
  156. unsigned int ngroups;
  157. const struct owl_padinfo *padinfo;
  158. unsigned int ngpios;
  159. const struct owl_gpio_port *ports;
  160. unsigned int nports;
  161. };
  162. int owl_pinctrl_probe(struct platform_device *pdev,
  163. struct owl_pinctrl_soc_data *soc_data);
  164. #endif /* __PINCTRL_OWL_H__ */