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