gpio.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. * Copyright (c) 2011, The Linux Foundation. All rights reserved.
  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. /*
  14. * Qualcomm PMIC8XXX gpio driver header file
  15. *
  16. */
  17. #ifndef __PM8XXX_GPIO_H
  18. #define __PM8XXX_GPIO_H
  19. #include <linux/errno.h>
  20. #define PM8XXX_GPIO_DEV_NAME "pm8xxx-gpio"
  21. struct pm8xxx_gpio_core_data {
  22. int ngpios;
  23. };
  24. struct pm8xxx_gpio_platform_data {
  25. struct pm8xxx_gpio_core_data gpio_cdata;
  26. int gpio_base;
  27. };
  28. /* GPIO parameters */
  29. /* direction */
  30. #define PM_GPIO_DIR_OUT 0x01
  31. #define PM_GPIO_DIR_IN 0x02
  32. #define PM_GPIO_DIR_BOTH (PM_GPIO_DIR_OUT | PM_GPIO_DIR_IN)
  33. /* output_buffer */
  34. #define PM_GPIO_OUT_BUF_OPEN_DRAIN 1
  35. #define PM_GPIO_OUT_BUF_CMOS 0
  36. /* pull */
  37. #define PM_GPIO_PULL_UP_30 0
  38. #define PM_GPIO_PULL_UP_1P5 1
  39. #define PM_GPIO_PULL_UP_31P5 2
  40. #define PM_GPIO_PULL_UP_1P5_30 3
  41. #define PM_GPIO_PULL_DN 4
  42. #define PM_GPIO_PULL_NO 5
  43. /* vin_sel: Voltage Input Select */
  44. #define PM_GPIO_VIN_VPH 0 /* 3v ~ 4.4v */
  45. #define PM_GPIO_VIN_BB 1 /* ~3.3v */
  46. #define PM_GPIO_VIN_S4 2 /* 1.8v */
  47. #define PM_GPIO_VIN_L15 3
  48. #define PM_GPIO_VIN_L4 4
  49. #define PM_GPIO_VIN_L3 5
  50. #define PM_GPIO_VIN_L17 6
  51. /* vin_sel: Voltage Input select on PM8058 */
  52. #define PM8058_GPIO_VIN_VPH 0
  53. #define PM8058_GPIO_VIN_BB 1
  54. #define PM8058_GPIO_VIN_S3 2
  55. #define PM8058_GPIO_VIN_L3 3
  56. #define PM8058_GPIO_VIN_L7 4
  57. #define PM8058_GPIO_VIN_L6 5
  58. #define PM8058_GPIO_VIN_L5 6
  59. #define PM8058_GPIO_VIN_L2 7
  60. /* vin_sel: Voltage Input Select on PM8038*/
  61. #define PM8038_GPIO_VIN_VPH 0
  62. #define PM8038_GPIO_VIN_BB 1
  63. #define PM8038_GPIO_VIN_L11 2
  64. #define PM8038_GPIO_VIN_L15 3
  65. #define PM8038_GPIO_VIN_L4 4
  66. #define PM8038_GPIO_VIN_L3 5
  67. #define PM8038_GPIO_VIN_L17 6
  68. /* vin_sel: Voltage Input Select on PM8018*/
  69. #define PM8018_GPIO_VIN_L4 0
  70. #define PM8018_GPIO_VIN_L14 1
  71. #define PM8018_GPIO_VIN_S3 2
  72. #define PM8018_GPIO_VIN_L6 3
  73. #define PM8018_GPIO_VIN_L2 4
  74. #define PM8018_GPIO_VIN_L5 5
  75. #define PM8018_GPIO_VIN_L8 6
  76. #define PM8018_GPIO_VIN_VPH 7
  77. /* out_strength */
  78. #define PM_GPIO_STRENGTH_NO 0
  79. #define PM_GPIO_STRENGTH_HIGH 1
  80. #define PM_GPIO_STRENGTH_MED 2
  81. #define PM_GPIO_STRENGTH_LOW 3
  82. /* function */
  83. #define PM_GPIO_FUNC_NORMAL 0
  84. #define PM_GPIO_FUNC_PAIRED 1
  85. #define PM_GPIO_FUNC_1 2
  86. #define PM_GPIO_FUNC_2 3
  87. #define PM_GPIO_DTEST1 4
  88. #define PM_GPIO_DTEST2 5
  89. #define PM_GPIO_DTEST3 6
  90. #define PM_GPIO_DTEST4 7
  91. /**
  92. * struct pm_gpio - structure to specify gpio configurtion values
  93. * @direction: indicates whether the gpio should be input, output, or
  94. * both. Should be of the type PM_GPIO_DIR_*
  95. * @output_buffer: indicates gpio should be configured as CMOS or open
  96. * drain. Should be of the type PM_GPIO_OUT_BUF_*
  97. * @output_value: The gpio output value of the gpio line - 0 or 1
  98. * @pull: Indicates whether a pull up or pull down should be
  99. * applied. If a pullup is required the current strength
  100. * needs to be specified. Current values of 30uA, 1.5uA,
  101. * 31.5uA, 1.5uA with 30uA boost are supported. This value
  102. * should be one of the PM_GPIO_PULL_*
  103. * @vin_sel: specifies the voltage level when the output is set to 1.
  104. * For an input gpio specifies the voltage level at which
  105. * the input is interpreted as a logical 1.
  106. * @out_strength: the amount of current supplied for an output gpio,
  107. * should be of the type PM_GPIO_STRENGTH_*
  108. * @function: choose alternate function for the gpio. Certain gpios
  109. * can be paired (shorted) with each other. Some gpio pin
  110. * can act as alternate functions. This parameter should
  111. * be of type PM_GPIO_FUNC_*
  112. * @inv_int_pol: Invert polarity before feeding the line to the interrupt
  113. * module in pmic. This feature will almost be never used
  114. * since the pm8xxx interrupt block can detect both edges
  115. * and both levels.
  116. * @disable_pin: Disable the gpio by configuring it as high impedance.
  117. */
  118. struct pm_gpio {
  119. int direction;
  120. int output_buffer;
  121. int output_value;
  122. int pull;
  123. int vin_sel;
  124. int out_strength;
  125. int function;
  126. int inv_int_pol;
  127. int disable_pin;
  128. };
  129. #if defined(CONFIG_GPIO_PM8XXX) || defined(CONFIG_GPIO_PM8XXX_MODULE)
  130. /**
  131. * pm8xxx_gpio_config - configure a gpio controlled by a pm8xxx chip
  132. * @gpio: gpio number to configure
  133. * @param: configuration values
  134. *
  135. * RETURNS: an appropriate -ERRNO error value on error, or zero for success.
  136. */
  137. int pm8xxx_gpio_config(int gpio, struct pm_gpio *param);
  138. #else
  139. static inline int pm8xxx_gpio_config(int gpio, struct pm_gpio *param)
  140. {
  141. return -ENXIO;
  142. }
  143. #endif
  144. #endif