pinctrl-msm.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2013, Sony Mobile Communications AB.
  4. */
  5. #ifndef __PINCTRL_MSM_H__
  6. #define __PINCTRL_MSM_H__
  7. #include <linux/pm.h>
  8. #include <linux/types.h>
  9. #include <linux/pinctrl/pinctrl.h>
  10. struct platform_device;
  11. struct pinctrl_pin_desc;
  12. #define APQ_PIN_FUNCTION(fname) \
  13. [APQ_MUX_##fname] = PINCTRL_PINFUNCTION(#fname, \
  14. fname##_groups, \
  15. ARRAY_SIZE(fname##_groups))
  16. #define IPQ_PIN_FUNCTION(fname) \
  17. [IPQ_MUX_##fname] = PINCTRL_PINFUNCTION(#fname, \
  18. fname##_groups, \
  19. ARRAY_SIZE(fname##_groups))
  20. #define MSM_PIN_FUNCTION(fname) \
  21. [msm_mux_##fname] = PINCTRL_PINFUNCTION(#fname, \
  22. fname##_groups, \
  23. ARRAY_SIZE(fname##_groups))
  24. #define QCA_PIN_FUNCTION(fname) \
  25. [qca_mux_##fname] = PINCTRL_PINFUNCTION(#fname, \
  26. fname##_groups, \
  27. ARRAY_SIZE(fname##_groups))
  28. /**
  29. * struct msm_pingroup - Qualcomm pingroup definition
  30. * @grp: Generic data of the pin group (name and pins)
  31. * @funcs: A list of pinmux functions that can be selected for
  32. * this group. The index of the selected function is used
  33. * for programming the function selector.
  34. * Entries should be indices into the groups list of the
  35. * struct msm_pinctrl_soc_data.
  36. * @ctl_reg: Offset of the register holding control bits for this group.
  37. * @io_reg: Offset of the register holding input/output bits for this group.
  38. * @intr_cfg_reg: Offset of the register holding interrupt configuration bits.
  39. * @intr_status_reg: Offset of the register holding the status bits for this group.
  40. * @intr_target_reg: Offset of the register specifying routing of the interrupts
  41. * from this group.
  42. * @mux_bit: Offset in @ctl_reg for the pinmux function selection.
  43. * @pull_bit: Offset in @ctl_reg for the bias configuration.
  44. * @drv_bit: Offset in @ctl_reg for the drive strength configuration.
  45. * @od_bit: Offset in @ctl_reg for controlling open drain.
  46. * @oe_bit: Offset in @ctl_reg for controlling output enable.
  47. * @in_bit: Offset in @io_reg for the input bit value.
  48. * @out_bit: Offset in @io_reg for the output bit value.
  49. * @intr_enable_bit: Offset in @intr_cfg_reg for enabling the interrupt for this group.
  50. * @intr_status_bit: Offset in @intr_status_reg for reading and acking the interrupt
  51. * status.
  52. * @intr_wakeup_present_bit: Offset in @intr_target_reg specifying the GPIO can generate
  53. * wakeup events.
  54. * @intr_wakeup_enable_bit: Offset in @intr_target_reg to enable wakeup events for the GPIO.
  55. * @intr_target_bit: Offset in @intr_target_reg for configuring the interrupt routing.
  56. * @intr_target_width: Number of bits used for specifying interrupt routing target.
  57. * @intr_target_kpss_val: Value in @intr_target_bit for specifying that the interrupt from
  58. * this gpio should get routed to the KPSS processor.
  59. * @intr_raw_status_bit: Offset in @intr_cfg_reg for the raw status bit.
  60. * @intr_polarity_bit: Offset in @intr_cfg_reg for specifying polarity of the interrupt.
  61. * @intr_detection_bit: Offset in @intr_cfg_reg for specifying interrupt type.
  62. * @intr_detection_width: Number of bits used for specifying interrupt type,
  63. * Should be 2 for SoCs that can detect both edges in hardware,
  64. * otherwise 1.
  65. */
  66. struct msm_pingroup {
  67. struct pingroup grp;
  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. unsigned int tile:2;
  76. unsigned mux_bit:5;
  77. unsigned pull_bit:5;
  78. unsigned drv_bit:5;
  79. unsigned i2c_pull_bit:5;
  80. unsigned od_bit:5;
  81. unsigned egpio_enable:5;
  82. unsigned egpio_present:5;
  83. unsigned oe_bit:5;
  84. unsigned in_bit:5;
  85. unsigned out_bit:5;
  86. unsigned intr_enable_bit:5;
  87. unsigned intr_status_bit:5;
  88. unsigned intr_ack_high:1;
  89. unsigned intr_wakeup_present_bit:5;
  90. unsigned intr_wakeup_enable_bit:5;
  91. unsigned intr_target_bit:5;
  92. unsigned intr_target_width:5;
  93. unsigned intr_target_kpss_val:5;
  94. unsigned intr_raw_status_bit:5;
  95. unsigned intr_polarity_bit:5;
  96. unsigned intr_detection_bit:5;
  97. unsigned intr_detection_width:5;
  98. };
  99. /**
  100. * struct msm_gpio_wakeirq_map - Map of GPIOs and their wakeup pins
  101. * @gpio: The GPIOs that are wakeup capable
  102. * @wakeirq: The interrupt at the always-on interrupt controller
  103. */
  104. struct msm_gpio_wakeirq_map {
  105. unsigned int gpio;
  106. unsigned int wakeirq;
  107. };
  108. /**
  109. * struct msm_pinctrl_soc_data - Qualcomm pin controller driver configuration
  110. * @pins: An array describing all pins the pin controller affects.
  111. * @npins: The number of entries in @pins.
  112. * @functions: An array describing all mux functions the SoC supports.
  113. * @nfunctions: The number of entries in @functions.
  114. * @groups: An array describing all pin groups the pin SoC supports.
  115. * @ngroups: The numbmer of entries in @groups.
  116. * @ngpio: The number of pingroups the driver should expose as GPIOs.
  117. * @pull_no_keeper: The SoC does not support keeper bias.
  118. * @wakeirq_map: The map of wakeup capable GPIOs and the pin at PDC/MPM
  119. * @nwakeirq_map: The number of entries in @wakeirq_map
  120. * @wakeirq_dual_edge_errata: If true then GPIOs using the wakeirq_map need
  121. * to be aware that their parent can't handle dual
  122. * edge interrupts.
  123. * @gpio_func: Which function number is GPIO (usually 0).
  124. * @egpio_func: If non-zero then this SoC supports eGPIO. Even though in
  125. * hardware this is a mux 1-level above the TLMM, we'll treat
  126. * it as if this is just another mux state of the TLMM. Since
  127. * it doesn't really map to hardware, we'll allocate a virtual
  128. * function number for eGPIO and any time we see that function
  129. * number used we'll treat it as a request to mux away from
  130. * our TLMM towards another owner.
  131. */
  132. struct msm_pinctrl_soc_data {
  133. const struct pinctrl_pin_desc *pins;
  134. unsigned npins;
  135. const struct pinfunction *functions;
  136. unsigned nfunctions;
  137. const struct msm_pingroup *groups;
  138. unsigned ngroups;
  139. unsigned ngpios;
  140. bool pull_no_keeper;
  141. const char *const *tiles;
  142. unsigned int ntiles;
  143. const int *reserved_gpios;
  144. const struct msm_gpio_wakeirq_map *wakeirq_map;
  145. unsigned int nwakeirq_map;
  146. bool wakeirq_dual_edge_errata;
  147. unsigned int gpio_func;
  148. unsigned int egpio_func;
  149. };
  150. extern const struct dev_pm_ops msm_pinctrl_dev_pm_ops;
  151. int msm_pinctrl_probe(struct platform_device *pdev,
  152. const struct msm_pinctrl_soc_data *soc_data);
  153. void msm_pinctrl_remove(struct platform_device *pdev);
  154. #endif