pinctrl-msm.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * Copyright (c) 2013, Sony Mobile Communications AB.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef __PINCTRL_MSM_H__
  14. #define __PINCTRL_MSM_H__
  15. struct pinctrl_pin_desc;
  16. /**
  17. * struct msm_function - a pinmux function
  18. * @name: Name of the pinmux function.
  19. * @groups: List of pingroups for this function.
  20. * @ngroups: Number of entries in @groups.
  21. */
  22. struct msm_function {
  23. const char *name;
  24. const char * const *groups;
  25. unsigned ngroups;
  26. };
  27. /**
  28. * struct msm_pingroup - Qualcomm pingroup definition
  29. * @name: Name of the pingroup.
  30. * @pins: A list of pins assigned to this pingroup.
  31. * @npins: Number of entries in @pins.
  32. * @funcs: A list of pinmux functions that can be selected for
  33. * this group. The index of the selected function is used
  34. * for programming the function selector.
  35. * Entries should be indices into the groups list of the
  36. * struct msm_pinctrl_soc_data.
  37. * @ctl_reg: Offset of the register holding control bits for this group.
  38. * @io_reg: Offset of the register holding input/output bits for this group.
  39. * @intr_cfg_reg: Offset of the register holding interrupt configuration bits.
  40. * @intr_status_reg: Offset of the register holding the status bits for this group.
  41. * @intr_target_reg: Offset of the register specifying routing of the interrupts
  42. * from this group.
  43. * @mux_bit: Offset in @ctl_reg for the pinmux function selection.
  44. * @pull_bit: Offset in @ctl_reg for the bias configuration.
  45. * @drv_bit: Offset in @ctl_reg for the drive strength configuration.
  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_target_bit: Offset in @intr_target_reg for configuring the interrupt routing.
  53. * @intr_target_kpss_val: Value in @intr_target_bit for specifying that the interrupt from
  54. * this gpio should get routed to the KPSS processor.
  55. * @intr_raw_status_bit: Offset in @intr_cfg_reg for the raw status bit.
  56. * @intr_polarity_bit: Offset in @intr_cfg_reg for specifying polarity of the interrupt.
  57. * @intr_detection_bit: Offset in @intr_cfg_reg for specifying interrupt type.
  58. * @intr_detection_width: Number of bits used for specifying interrupt type,
  59. * Should be 2 for SoCs that can detect both edges in hardware,
  60. * otherwise 1.
  61. */
  62. struct msm_pingroup {
  63. const char *name;
  64. const unsigned *pins;
  65. unsigned npins;
  66. unsigned *funcs;
  67. unsigned nfuncs;
  68. u32 ctl_reg;
  69. u32 io_reg;
  70. u32 intr_cfg_reg;
  71. u32 intr_status_reg;
  72. u32 intr_target_reg;
  73. unsigned mux_bit:5;
  74. unsigned pull_bit:5;
  75. unsigned drv_bit:5;
  76. unsigned oe_bit:5;
  77. unsigned in_bit:5;
  78. unsigned out_bit:5;
  79. unsigned intr_enable_bit:5;
  80. unsigned intr_status_bit:5;
  81. unsigned intr_ack_high:1;
  82. unsigned intr_target_bit:5;
  83. unsigned intr_target_kpss_val:5;
  84. unsigned intr_raw_status_bit:5;
  85. unsigned intr_polarity_bit:5;
  86. unsigned intr_detection_bit:5;
  87. unsigned intr_detection_width:5;
  88. };
  89. /**
  90. * struct msm_pinctrl_soc_data - Qualcomm pin controller driver configuration
  91. * @pins: An array describing all pins the pin controller affects.
  92. * @npins: The number of entries in @pins.
  93. * @functions: An array describing all mux functions the SoC supports.
  94. * @nfunctions: The number of entries in @functions.
  95. * @groups: An array describing all pin groups the pin SoC supports.
  96. * @ngroups: The numbmer of entries in @groups.
  97. * @ngpio: The number of pingroups the driver should expose as GPIOs.
  98. */
  99. struct msm_pinctrl_soc_data {
  100. const struct pinctrl_pin_desc *pins;
  101. unsigned npins;
  102. const struct msm_function *functions;
  103. unsigned nfunctions;
  104. const struct msm_pingroup *groups;
  105. unsigned ngroups;
  106. unsigned ngpios;
  107. };
  108. int msm_pinctrl_probe(struct platform_device *pdev,
  109. const struct msm_pinctrl_soc_data *soc_data);
  110. int msm_pinctrl_remove(struct platform_device *pdev);
  111. #endif