0012-gpio-axp-Remove-virtual-VBUS-enable-GPIO.patch 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. From cbb281e0ec847b9de41970e470348b3534bb9a9f Mon Sep 17 00:00:00 2001
  2. From: Samuel Holland <[email protected]>
  3. Date: Thu, 26 Aug 2021 18:02:54 -0500
  4. Subject: [PATCH 12/90] gpio: axp: Remove virtual VBUS enable GPIO
  5. Now that this functionality is modeled using the device tree and
  6. regulator uclass, the named GPIO is not referenced anywhere. Remove
  7. it, along with the rest of the support for AXP virtual GPIOs.
  8. Signed-off-by: Samuel Holland <[email protected]>
  9. ---
  10. arch/arm/include/asm/arch-sunxi/gpio.h | 8 ---
  11. drivers/gpio/axp_gpio.c | 75 ++++++++------------------
  12. drivers/gpio/sunxi_gpio.c | 8 ---
  13. include/axp221.h | 4 --
  14. include/axp809.h | 4 --
  15. include/axp818.h | 4 --
  16. 6 files changed, 21 insertions(+), 82 deletions(-)
  17. --- a/arch/arm/include/asm/arch-sunxi/gpio.h
  18. +++ b/arch/arm/include/asm/arch-sunxi/gpio.h
  19. @@ -111,7 +111,6 @@ enum sunxi_gpio_number {
  20. SUNXI_GPIO_L_START = 352,
  21. SUNXI_GPIO_M_START = SUNXI_GPIO_NEXT(SUNXI_GPIO_L),
  22. SUNXI_GPIO_N_START = SUNXI_GPIO_NEXT(SUNXI_GPIO_M),
  23. - SUNXI_GPIO_AXP0_START = 1024,
  24. };
  25. /* SUNXI GPIO number definitions */
  26. @@ -128,8 +127,6 @@ enum sunxi_gpio_number {
  27. #define SUNXI_GPM(_nr) (SUNXI_GPIO_M_START + (_nr))
  28. #define SUNXI_GPN(_nr) (SUNXI_GPIO_N_START + (_nr))
  29. -#define SUNXI_GPAXP0(_nr) (SUNXI_GPIO_AXP0_START + (_nr))
  30. -
  31. /* GPIO pin function config */
  32. #define SUNXI_GPIO_INPUT 0
  33. #define SUNXI_GPIO_OUTPUT 1
  34. @@ -207,11 +204,6 @@ enum sunxi_gpio_number {
  35. #define SUNXI_GPIO_PULL_UP 1
  36. #define SUNXI_GPIO_PULL_DOWN 2
  37. -/* Virtual AXP0 GPIOs */
  38. -#define SUNXI_GPIO_AXP0_PREFIX "AXP0-"
  39. -#define SUNXI_GPIO_AXP0_VBUS_ENABLE 5
  40. -#define SUNXI_GPIO_AXP0_GPIO_COUNT 6
  41. -
  42. struct sunxi_gpio_plat {
  43. struct sunxi_gpio *regs;
  44. char bank_name[3];
  45. --- a/drivers/gpio/axp_gpio.c
  46. +++ b/drivers/gpio/axp_gpio.c
  47. @@ -15,6 +15,9 @@
  48. #include <dm/root.h>
  49. #include <errno.h>
  50. +#define AXP_GPIO_PREFIX "AXP0-"
  51. +#define AXP_GPIO_COUNT 4
  52. +
  53. static int axp_gpio_set_value(struct udevice *dev, unsigned pin, int val);
  54. static u8 axp_get_gpio_ctrl_reg(unsigned pin)
  55. @@ -46,28 +49,14 @@ static int axp_gpio_direction_input(stru
  56. static int axp_gpio_direction_output(struct udevice *dev, unsigned pin,
  57. int val)
  58. {
  59. - __maybe_unused int ret;
  60. u8 reg;
  61. - switch (pin) {
  62. -#ifdef AXP_MISC_CTRL_N_VBUSEN_FUNC
  63. - /* Only available on later PMICs */
  64. - case SUNXI_GPIO_AXP0_VBUS_ENABLE:
  65. - ret = pmic_bus_clrbits(AXP_MISC_CTRL,
  66. - AXP_MISC_CTRL_N_VBUSEN_FUNC);
  67. - if (ret)
  68. - return ret;
  69. -
  70. - return axp_gpio_set_value(dev, pin, val);
  71. -#endif
  72. - default:
  73. - reg = axp_get_gpio_ctrl_reg(pin);
  74. - if (reg == 0)
  75. - return -EINVAL;
  76. + reg = axp_get_gpio_ctrl_reg(pin);
  77. + if (reg == 0)
  78. + return -EINVAL;
  79. - return pmic_bus_write(reg, val ? AXP_GPIO_CTRL_OUTPUT_HIGH :
  80. - AXP_GPIO_CTRL_OUTPUT_LOW);
  81. - }
  82. + return pmic_bus_write(reg, val ? AXP_GPIO_CTRL_OUTPUT_HIGH :
  83. + AXP_GPIO_CTRL_OUTPUT_LOW);
  84. }
  85. static int axp_gpio_get_value(struct udevice *dev, unsigned pin)
  86. @@ -75,25 +64,16 @@ static int axp_gpio_get_value(struct ude
  87. u8 reg, val, mask;
  88. int ret;
  89. - switch (pin) {
  90. -#ifdef AXP_MISC_CTRL_N_VBUSEN_FUNC
  91. - /* Only available on later PMICs */
  92. - case SUNXI_GPIO_AXP0_VBUS_ENABLE:
  93. - ret = pmic_bus_read(AXP_VBUS_IPSOUT, &val);
  94. - mask = AXP_VBUS_IPSOUT_DRIVEBUS;
  95. - break;
  96. -#endif
  97. - default:
  98. - reg = axp_get_gpio_ctrl_reg(pin);
  99. - if (reg == 0)
  100. - return -EINVAL;
  101. + reg = axp_get_gpio_ctrl_reg(pin);
  102. + if (reg == 0)
  103. + return -EINVAL;
  104. - ret = pmic_bus_read(AXP_GPIO_STATE, &val);
  105. - mask = 1 << (pin + AXP_GPIO_STATE_OFFSET);
  106. - }
  107. + ret = pmic_bus_read(AXP_GPIO_STATE, &val);
  108. if (ret)
  109. return ret;
  110. + mask = 1 << (pin + AXP_GPIO_STATE_OFFSET);
  111. +
  112. return (val & mask) ? 1 : 0;
  113. }
  114. @@ -101,25 +81,12 @@ static int axp_gpio_set_value(struct ude
  115. {
  116. u8 reg;
  117. - switch (pin) {
  118. -#ifdef AXP_MISC_CTRL_N_VBUSEN_FUNC
  119. - /* Only available on later PMICs */
  120. - case SUNXI_GPIO_AXP0_VBUS_ENABLE:
  121. - if (val)
  122. - return pmic_bus_setbits(AXP_VBUS_IPSOUT,
  123. - AXP_VBUS_IPSOUT_DRIVEBUS);
  124. - else
  125. - return pmic_bus_clrbits(AXP_VBUS_IPSOUT,
  126. - AXP_VBUS_IPSOUT_DRIVEBUS);
  127. -#endif
  128. - default:
  129. - reg = axp_get_gpio_ctrl_reg(pin);
  130. - if (reg == 0)
  131. - return -EINVAL;
  132. + reg = axp_get_gpio_ctrl_reg(pin);
  133. + if (reg == 0)
  134. + return -EINVAL;
  135. - return pmic_bus_write(reg, val ? AXP_GPIO_CTRL_OUTPUT_HIGH :
  136. - AXP_GPIO_CTRL_OUTPUT_LOW);
  137. - }
  138. + return pmic_bus_write(reg, val ? AXP_GPIO_CTRL_OUTPUT_HIGH :
  139. + AXP_GPIO_CTRL_OUTPUT_LOW);
  140. }
  141. static const struct dm_gpio_ops gpio_axp_ops = {
  142. @@ -134,8 +101,8 @@ static int gpio_axp_probe(struct udevice
  143. struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
  144. /* Tell the uclass how many GPIOs we have */
  145. - uc_priv->bank_name = strdup(SUNXI_GPIO_AXP0_PREFIX);
  146. - uc_priv->gpio_count = SUNXI_GPIO_AXP0_GPIO_COUNT;
  147. + uc_priv->bank_name = AXP_GPIO_PREFIX;
  148. + uc_priv->gpio_count = AXP_GPIO_COUNT;
  149. return 0;
  150. }
  151. --- a/drivers/gpio/sunxi_gpio.c
  152. +++ b/drivers/gpio/sunxi_gpio.c
  153. @@ -114,15 +114,7 @@ int sunxi_name_to_gpio(const char *name)
  154. {
  155. unsigned int gpio;
  156. int ret;
  157. -#if !defined CONFIG_SPL_BUILD && defined CONFIG_AXP_GPIO
  158. - char lookup[8];
  159. - if (strcasecmp(name, "AXP0-VBUS-ENABLE") == 0) {
  160. - sprintf(lookup, SUNXI_GPIO_AXP0_PREFIX "%d",
  161. - SUNXI_GPIO_AXP0_VBUS_ENABLE);
  162. - name = lookup;
  163. - }
  164. -#endif
  165. ret = gpio_lookup_name(name, NULL, NULL, &gpio);
  166. return ret ? ret : gpio;
  167. --- a/include/axp221.h
  168. +++ b/include/axp221.h
  169. @@ -53,10 +53,6 @@
  170. #ifdef CONFIG_AXP221_POWER
  171. #define AXP_POWER_STATUS 0x00
  172. #define AXP_POWER_STATUS_ALDO_IN BIT(0)
  173. -#define AXP_VBUS_IPSOUT 0x30
  174. -#define AXP_VBUS_IPSOUT_DRIVEBUS (1 << 2)
  175. -#define AXP_MISC_CTRL 0x8f
  176. -#define AXP_MISC_CTRL_N_VBUSEN_FUNC (1 << 4)
  177. #define AXP_GPIO0_CTRL 0x90
  178. #define AXP_GPIO1_CTRL 0x92
  179. #define AXP_GPIO_CTRL_OUTPUT_LOW 0x00 /* Drive pin low */
  180. --- a/include/axp809.h
  181. +++ b/include/axp809.h
  182. @@ -47,10 +47,6 @@
  183. #ifdef CONFIG_AXP809_POWER
  184. #define AXP_POWER_STATUS 0x00
  185. #define AXP_POWER_STATUS_ALDO_IN BIT(0)
  186. -#define AXP_VBUS_IPSOUT 0x30
  187. -#define AXP_VBUS_IPSOUT_DRIVEBUS (1 << 2)
  188. -#define AXP_MISC_CTRL 0x8f
  189. -#define AXP_MISC_CTRL_N_VBUSEN_FUNC (1 << 4)
  190. #define AXP_GPIO0_CTRL 0x90
  191. #define AXP_GPIO1_CTRL 0x92
  192. #define AXP_GPIO_CTRL_OUTPUT_LOW 0x00 /* Drive pin low */
  193. --- a/include/axp818.h
  194. +++ b/include/axp818.h
  195. @@ -61,10 +61,6 @@
  196. #ifdef CONFIG_AXP818_POWER
  197. #define AXP_POWER_STATUS 0x00
  198. #define AXP_POWER_STATUS_ALDO_IN BIT(0)
  199. -#define AXP_VBUS_IPSOUT 0x30
  200. -#define AXP_VBUS_IPSOUT_DRIVEBUS (1 << 2)
  201. -#define AXP_MISC_CTRL 0x8f
  202. -#define AXP_MISC_CTRL_N_VBUSEN_FUNC (1 << 4)
  203. #define AXP_GPIO0_CTRL 0x90
  204. #define AXP_GPIO1_CTRL 0x92
  205. #define AXP_GPIO_CTRL_OUTPUT_LOW 0x00 /* Drive pin low */