1 From 532b81ac600b6a70a1421f86503cb6d8543edf1b Mon Sep 17 00:00:00 2001
2 From: Samuel Holland <samuel@sholland.org>
3 Date: Tue, 17 Aug 2021 20:01:55 -0500
4 Subject: [PATCH 49/90] gpio: axp: Use DM_PMIC functions for register access
6 Now that the PMIC driver implements the DM_PMIC uclass, those functions
7 can be used instead of the platform-specific "pmic_bus" functions.
9 Since the driver still uses the single set of register definitions from
10 axpXXX.h (as selected by AXPxxx_POWER), it still depends on one of those
11 choices, and therefore also AXP_PMIC_BUS.
13 Signed-off-by: Samuel Holland <samuel@sholland.org>
15 drivers/gpio/axp_gpio.c | 27 ++++++++++++---------------
16 1 file changed, 12 insertions(+), 15 deletions(-)
18 --- a/drivers/gpio/axp_gpio.c
19 +++ b/drivers/gpio/axp_gpio.c
24 -#include <asm/arch/pmic_bus.h>
29 +#include <power/pmic.h>
31 #define AXP_GPIO_PREFIX "AXP0-"
32 #define AXP_GPIO_COUNT 4
33 @@ -40,7 +40,7 @@ static int axp_gpio_direction_input(stru
37 - return pmic_bus_write(reg, AXP_GPIO_CTRL_INPUT);
38 + return pmic_reg_write(dev->parent, reg, AXP_GPIO_CTRL_INPUT);
41 static int axp_gpio_direction_output(struct udevice *dev, unsigned pin,
42 @@ -52,26 +52,27 @@ static int axp_gpio_direction_output(str
46 - return pmic_bus_write(reg, val ? AXP_GPIO_CTRL_OUTPUT_HIGH :
47 - AXP_GPIO_CTRL_OUTPUT_LOW);
48 + return pmic_reg_write(dev->parent, reg,
49 + val ? AXP_GPIO_CTRL_OUTPUT_HIGH :
50 + AXP_GPIO_CTRL_OUTPUT_LOW);
53 static int axp_gpio_get_value(struct udevice *dev, unsigned pin)
59 reg = axp_get_gpio_ctrl_reg(pin);
63 - ret = pmic_bus_read(AXP_GPIO_STATE, &val);
65 + ret = pmic_reg_read(dev->parent, AXP_GPIO_STATE);
69 mask = 1 << (pin + AXP_GPIO_STATE_OFFSET);
71 - return (val & mask) ? 1 : 0;
72 + return (ret & mask) ? 1 : 0;
75 static int axp_gpio_set_value(struct udevice *dev, unsigned pin, int val)
76 @@ -82,8 +83,9 @@ static int axp_gpio_set_value(struct ude
80 - return pmic_bus_write(reg, val ? AXP_GPIO_CTRL_OUTPUT_HIGH :
81 - AXP_GPIO_CTRL_OUTPUT_LOW);
82 + return pmic_reg_write(dev->parent, reg,
83 + val ? AXP_GPIO_CTRL_OUTPUT_HIGH :
84 + AXP_GPIO_CTRL_OUTPUT_LOW);
87 static const struct dm_gpio_ops axp_gpio_ops = {
88 @@ -96,11 +98,6 @@ static const struct dm_gpio_ops axp_gpio
89 static int axp_gpio_probe(struct udevice *dev)
91 struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
94 - ret = pmic_bus_init();
98 /* Tell the uclass how many GPIOs we have */
99 uc_priv->bank_name = AXP_GPIO_PREFIX;