0048-gpio-axp-Bind-via-device-tree.patch 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. From a39b1bd1ad0babb355a5cb6f6a3bd8e378433b54 Mon Sep 17 00:00:00 2001
  2. From: Samuel Holland <[email protected]>
  3. Date: Fri, 27 Aug 2021 21:43:19 -0500
  4. Subject: [PATCH 48/90] gpio: axp: Bind via device tree
  5. Now that the PMIC has a DM driver and binds device tree subnodes, the
  6. GPIO device can be bound that way, instead of from inside board code.
  7. Since the driver still uses the single set of register definitions from
  8. axpXXX.h (as selected by AXPxxx_POWER), it does not differentiate among
  9. the supported compatibles.
  10. Signed-off-by: Samuel Holland <[email protected]>
  11. ---
  12. arch/arm/include/asm/arch-sunxi/gpio.h | 6 -----
  13. arch/arm/mach-sunxi/Kconfig | 6 -----
  14. board/sunxi/board.c | 4 ---
  15. drivers/gpio/Kconfig | 8 ++++++
  16. drivers/gpio/axp_gpio.c | 34 +++++++++++---------------
  17. 5 files changed, 22 insertions(+), 36 deletions(-)
  18. --- a/arch/arm/include/asm/arch-sunxi/gpio.h
  19. +++ b/arch/arm/include/asm/arch-sunxi/gpio.h
  20. @@ -219,10 +219,4 @@ void sunxi_gpio_set_pull(u32 pin, u32 va
  21. void sunxi_gpio_set_pull_bank(struct sunxi_gpio *pio, int bank_offset, u32 val);
  22. int sunxi_name_to_gpio(const char *name);
  23. -#if !defined CONFIG_SPL_BUILD && defined CONFIG_AXP_GPIO
  24. -int axp_gpio_init(void);
  25. -#else
  26. -static inline int axp_gpio_init(void) { return 0; }
  27. -#endif
  28. -
  29. #endif /* _SUNXI_GPIO_H */
  30. --- a/arch/arm/mach-sunxi/Kconfig
  31. +++ b/arch/arm/mach-sunxi/Kconfig
  32. @@ -682,12 +682,6 @@ config R_I2C_ENABLE
  33. Set this to y to enable the I2C controller which is part of the PRCM.
  34. endif
  35. -config AXP_GPIO
  36. - bool "Enable support for gpio-s on axp PMICs"
  37. - depends on AXP_PMIC_BUS
  38. - ---help---
  39. - Say Y here to enable support for the gpio pins of the axp PMIC ICs.
  40. -
  41. config AXP_DISABLE_BOOT_ON_POWERON
  42. bool "Disable device boot on power plug-in"
  43. depends on AXP209_POWER || AXP221_POWER || AXP809_POWER || AXP818_POWER
  44. --- a/board/sunxi/board.c
  45. +++ b/board/sunxi/board.c
  46. @@ -221,10 +221,6 @@ int board_init(void)
  47. }
  48. #endif /* !CONFIG_ARM64 && !CONFIG_MACH_SUNIV */
  49. - ret = axp_gpio_init();
  50. - if (ret)
  51. - return ret;
  52. -
  53. /* strcmp() would look better, but doesn't get optimised away. */
  54. if (CONFIG_SATAPWR[0]) {
  55. satapwr_pin = sunxi_name_to_gpio(CONFIG_SATAPWR);
  56. --- a/drivers/gpio/Kconfig
  57. +++ b/drivers/gpio/Kconfig
  58. @@ -104,6 +104,14 @@ config ALTERA_PIO
  59. Select this to enable PIO for Altera devices. Please find
  60. details on the "Embedded Peripherals IP User Guide" of Altera.
  61. +config AXP_GPIO
  62. + bool "X-Powers AXP PMICs GPIO driver"
  63. + depends on DM_GPIO && PMIC_AXP
  64. + depends on AXP_PMIC_BUS
  65. + help
  66. + This driver supports the GPIO pins on
  67. + X-Powers AXP152, AXP2xx, and AXP8xx PMICs.
  68. +
  69. config BCM2835_GPIO
  70. bool "BCM2835 GPIO driver"
  71. depends on DM_GPIO
  72. --- a/drivers/gpio/axp_gpio.c
  73. +++ b/drivers/gpio/axp_gpio.c
  74. @@ -10,9 +10,6 @@
  75. #include <asm/gpio.h>
  76. #include <axp_pmic.h>
  77. #include <dm.h>
  78. -#include <dm/device-internal.h>
  79. -#include <dm/lists.h>
  80. -#include <dm/root.h>
  81. #include <errno.h>
  82. #define AXP_GPIO_PREFIX "AXP0-"
  83. @@ -99,6 +96,11 @@ static const struct dm_gpio_ops axp_gpio
  84. static int axp_gpio_probe(struct udevice *dev)
  85. {
  86. struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
  87. + int ret;
  88. +
  89. + ret = pmic_bus_init();
  90. + if (ret)
  91. + return ret;
  92. /* Tell the uclass how many GPIOs we have */
  93. uc_priv->bank_name = AXP_GPIO_PREFIX;
  94. @@ -107,26 +109,18 @@ static int axp_gpio_probe(struct udevice
  95. return 0;
  96. }
  97. +static const struct udevice_id axp_gpio_ids[] = {
  98. + { .compatible = "x-powers,axp152-gpio" },
  99. + { .compatible = "x-powers,axp209-gpio" },
  100. + { .compatible = "x-powers,axp221-gpio" },
  101. + { .compatible = "x-powers,axp813-gpio" },
  102. + { }
  103. +};
  104. +
  105. U_BOOT_DRIVER(axp_gpio) = {
  106. .name = "axp_gpio",
  107. .id = UCLASS_GPIO,
  108. + .of_match = axp_gpio_ids,
  109. .probe = axp_gpio_probe,
  110. .ops = &axp_gpio_ops,
  111. };
  112. -
  113. -int axp_gpio_init(void)
  114. -{
  115. - struct udevice *dev;
  116. - int ret;
  117. -
  118. - ret = pmic_bus_init();
  119. - if (ret)
  120. - return ret;
  121. -
  122. - /* There is no devicetree support for the axp yet, so bind directly */
  123. - ret = device_bind_driver(dm_root(), "axp_gpio", "AXP-gpio", &dev);
  124. - if (ret)
  125. - return ret;
  126. -
  127. - return 0;
  128. -}