pinctrl-msm.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2013, Sony Mobile Communications AB.
  4. * Copyright (c) 2021, The Linux Foundation. All rights reserved.
  5. * Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
  6. */
  7. #ifndef __PINCTRL_MSM_H__
  8. #define __PINCTRL_MSM_H__
  9. #include <linux/pinctrl/qcom-pinctrl.h>
  10. struct pinctrl_pin_desc;
  11. /**
  12. * struct msm_function - a pinmux function
  13. * @name: Name of the pinmux function.
  14. * @groups: List of pingroups for this function.
  15. * @ngroups: Number of entries in @groups.
  16. */
  17. struct msm_function {
  18. const char *name;
  19. const char * const *groups;
  20. unsigned ngroups;
  21. };
  22. /**
  23. * struct msm_pingroup - Qualcomm pingroup definition
  24. * @name: Name of the pingroup.
  25. * @pins: A list of pins assigned to this pingroup.
  26. * @npins: Number of entries in @pins.
  27. * @funcs: A list of pinmux functions that can be selected for
  28. * this group. The index of the selected function is used
  29. * for programming the function selector.
  30. * Entries should be indices into the groups list of the
  31. * struct msm_pinctrl_soc_data.
  32. * @ctl_reg: Offset of the register holding control bits for this group.
  33. * @io_reg: Offset of the register holding input/output bits for this group.
  34. * @intr_cfg_reg: Offset of the register holding interrupt configuration bits.
  35. * @intr_status_reg: Offset of the register holding the status bits for this group.
  36. * @intr_target_reg: Offset of the register specifying routing of the interrupts
  37. * from this group.
  38. * @dir_conn_reg: Offset of the register hmss setup in tile.
  39. * @reg_size_4k: Size of the group register space in 4k granularity.
  40. * @mux_bit: Offset in @ctl_reg for the pinmux function selection.
  41. * @pull_bit: Offset in @ctl_reg for the bias configuration.
  42. * @drv_bit: Offset in @ctl_reg for the drive strength configuration.
  43. * @od_bit: Offset in @ctl_reg for controlling open drain.
  44. * @oe_bit: Offset in @ctl_reg for controlling output enable.
  45. * @in_bit: Offset in @io_reg for the input bit value.
  46. * @out_bit: Offset in @io_reg for the output bit value.
  47. * @intr_enable_bit: Offset in @intr_cfg_reg for enabling the interrupt for this group.
  48. * @intr_status_bit: Offset in @intr_status_reg for reading and acking the interrupt
  49. * status.
  50. * @intr_target_bit: Offset in @intr_target_reg for configuring the interrupt routing.
  51. * @intr_target_width: Number of bits used for specifying interrupt routing target.
  52. * @intr_target_kpss_val: Value in @intr_target_bit for specifying that the interrupt from
  53. * this gpio should get routed to the KPSS processor.
  54. * @intr_raw_status_bit: Offset in @intr_cfg_reg for the raw status bit.
  55. * @intr_polarity_bit: Offset in @intr_cfg_reg for specifying polarity of the interrupt.
  56. * @intr_detection_bit: Offset in @intr_cfg_reg for specifying interrupt type.
  57. * @intr_detection_width: Number of bits used for specifying interrupt type,
  58. * Should be 2 for SoCs that can detect both edges in hardware,
  59. * otherwise 1.
  60. * @dir_conn_en_bit: Offset in @intr_cfg_reg for direct connect enable bit
  61. * @wake_reg: Offset of the WAKEUP_INT_EN register from base tile
  62. * @wake_bit: Bit number for the corresponding gpio
  63. */
  64. struct msm_pingroup {
  65. const char *name;
  66. const unsigned *pins;
  67. unsigned npins;
  68. unsigned *funcs;
  69. unsigned nfuncs;
  70. u32 ctl_reg;
  71. u32 io_reg;
  72. u32 intr_cfg_reg;
  73. u32 intr_status_reg;
  74. u32 intr_target_reg;
  75. u32 dir_conn_reg;
  76. unsigned int reg_size_4k:5;
  77. unsigned int tile:2;
  78. unsigned mux_bit:5;
  79. unsigned pull_bit:5;
  80. unsigned drv_bit:5;
  81. unsigned od_bit:5;
  82. unsigned egpio_enable:5;
  83. unsigned egpio_present:5;
  84. unsigned oe_bit:5;
  85. unsigned in_bit:5;
  86. unsigned out_bit:5;
  87. unsigned intr_enable_bit:5;
  88. unsigned intr_status_bit:5;
  89. unsigned intr_ack_high:1;
  90. unsigned intr_target_bit:5;
  91. unsigned intr_target_width:5;
  92. unsigned intr_wakeup_enable_bit:5;
  93. unsigned intr_wakeup_present_bit:5;
  94. unsigned intr_target_kpss_val:5;
  95. unsigned intr_raw_status_bit:5;
  96. unsigned intr_polarity_bit:5;
  97. unsigned intr_detection_bit:5;
  98. unsigned intr_detection_width:5;
  99. unsigned dir_conn_en_bit:8;
  100. u32 wake_reg;
  101. unsigned int wake_bit;
  102. };
  103. /**
  104. * struct msm_gpio_wakeirq_map - Map of GPIOs and their wakeup pins
  105. * @gpio: The GPIOs that are wakeup capable
  106. * @wakeirq: The interrupt at the always-on interrupt controller
  107. */
  108. struct msm_gpio_wakeirq_map {
  109. unsigned int gpio;
  110. unsigned int wakeirq;
  111. };
  112. /**
  113. * struct msm_dir_conn - TLMM Direct GPIO connect configuration
  114. * @gpio: GPIO pin number
  115. * @irq: The GIC interrupt that the pin is connected to
  116. */
  117. struct msm_dir_conn {
  118. int gpio;
  119. int irq;
  120. };
  121. /*
  122. * struct pinctrl_qup - Qup mode configuration
  123. * @mode: Qup i3c mode
  124. * @offset: Offset of the register
  125. */
  126. struct pinctrl_qup {
  127. u32 mode;
  128. u32 offset;
  129. };
  130. /*
  131. * struct msm_spare_tlmm - TLMM spare registers config
  132. * @spare_reg: spare register number
  133. * @offset: Offset of spare register
  134. */
  135. struct msm_spare_tlmm {
  136. int spare_reg;
  137. u32 offset;
  138. };
  139. /**
  140. * struct msm_pinctrl_soc_data - Qualcomm pin controller driver configuration
  141. * @pins: An array describing all pins the pin controller affects.
  142. * @npins: The number of entries in @pins.
  143. * @functions: An array describing all mux functions the SoC supports.
  144. * @nfunctions: The number of entries in @functions.
  145. * @groups: An array describing all pin groups the pin SoC supports.
  146. * @ngroups: The numbmer of entries in @groups.
  147. * @ngpio: The number of pingroups the driver should expose as GPIOs.
  148. * @pull_no_keeper: The SoC does not support keeper bias.
  149. * @wakeirq_map: The map of wakeup capable GPIOs and the pin at PDC/MPM
  150. * @nwakeirq_map: The number of entries in @wakeirq_map
  151. * @dir_conn: An array describing all the pins directly connected to GIC.
  152. * @wakeirq_dual_edge_errata: If true then GPIOs using the wakeirq_map need
  153. * to be aware that their parent can't handle dual
  154. * edge interrupts.
  155. * @gpio_func: Which function number is GPIO (usually 0).
  156. * @egpio_func: If non-zero then this SoC supports eGPIO. Even though in
  157. * hardware this is a mux 1-level above the TLMM, we'll treat
  158. * it as if this is just another mux state of the TLMM. Since
  159. * it doesn't really map to hardware, we'll allocate a virtual
  160. * function number for eGPIO and any time we see that function
  161. * number used we'll treat it as a request to mux away from
  162. * our TLMM towards another owner.
  163. */
  164. struct msm_pinctrl_soc_data {
  165. const struct pinctrl_pin_desc *pins;
  166. unsigned npins;
  167. const struct msm_function *functions;
  168. unsigned nfunctions;
  169. const struct msm_pingroup *groups;
  170. unsigned ngroups;
  171. unsigned ngpios;
  172. bool pull_no_keeper;
  173. const char *const *tiles;
  174. unsigned int ntiles;
  175. const int *reserved_gpios;
  176. const struct msm_gpio_wakeirq_map *wakeirq_map;
  177. unsigned int nwakeirq_map;
  178. bool wakeirq_dual_edge_errata;
  179. struct pinctrl_qup *qup_regs;
  180. unsigned int nqup_regs;
  181. unsigned int gpio_func;
  182. unsigned int egpio_func;
  183. u32 *dir_conn_addr;
  184. const struct msm_spare_tlmm *spare_regs;
  185. unsigned int nspare_regs;
  186. struct msm_dir_conn *dir_conn;
  187. };
  188. extern const struct dev_pm_ops msm_pinctrl_dev_pm_ops;
  189. extern const struct dev_pm_ops noirq_msm_pinctrl_dev_pm_ops;
  190. int msm_pinctrl_probe(struct platform_device *pdev,
  191. const struct msm_pinctrl_soc_data *soc_data);
  192. int msm_pinctrl_remove(struct platform_device *pdev);
  193. #endif