gpio: axp: Bind via device tree

Now that the PMIC has a DM driver and binds device tree subnodes, the
GPIO device can be bound that way, instead of from inside board code.

Since the driver still uses the single set of register definitions from
axpXXX.h (as selected by AXPxxx_POWER), it does not differentiate among
the supported compatibles.

Signed-off-by: Samuel Holland <samuel@sholland.org>
This commit is contained in:
Samuel Holland 2021-08-27 21:43:19 -05:00
parent eedbe58ecd
commit 3fe7ba6039
5 changed files with 22 additions and 36 deletions

View File

@ -219,10 +219,4 @@ void sunxi_gpio_set_pull(u32 pin, u32 val);
void sunxi_gpio_set_pull_bank(struct sunxi_gpio *pio, int bank_offset, u32 val);
int sunxi_name_to_gpio(const char *name);
#if !defined CONFIG_SPL_BUILD && defined CONFIG_AXP_GPIO
int axp_gpio_init(void);
#else
static inline int axp_gpio_init(void) { return 0; }
#endif
#endif /* _SUNXI_GPIO_H */

View File

@ -720,12 +720,6 @@ config R_I2C_ENABLE
Set this to y to enable the I2C controller which is part of the PRCM.
endif
config AXP_GPIO
bool "Enable support for gpio-s on axp PMICs"
depends on AXP_PMIC_BUS
---help---
Say Y here to enable support for the gpio pins of the axp PMIC ICs.
config AXP_DISABLE_BOOT_ON_POWERON
bool "Disable device boot on power plug-in"
depends on AXP209_POWER || AXP221_POWER || AXP809_POWER || AXP818_POWER

View File

@ -224,10 +224,6 @@ int board_init(void)
}
#endif /* !CONFIG_ARM64 && !CONFIG_MACH_SUNIV */
ret = axp_gpio_init();
if (ret)
return ret;
/* strcmp() would look better, but doesn't get optimised away. */
if (CONFIG_SATAPWR[0]) {
satapwr_pin = sunxi_name_to_gpio(CONFIG_SATAPWR);

View File

@ -104,6 +104,14 @@ config ALTERA_PIO
Select this to enable PIO for Altera devices. Please find
details on the "Embedded Peripherals IP User Guide" of Altera.
config AXP_GPIO
bool "X-Powers AXP PMICs GPIO driver"
depends on DM_GPIO && PMIC_AXP
depends on AXP_PMIC_BUS
help
This driver supports the GPIO pins on
X-Powers AXP152, AXP2xx, and AXP8xx PMICs.
config BCM2835_GPIO
bool "BCM2835 GPIO driver"
depends on DM_GPIO

View File

@ -10,9 +10,6 @@
#include <asm/gpio.h>
#include <axp_pmic.h>
#include <dm.h>
#include <dm/device-internal.h>
#include <dm/lists.h>
#include <dm/root.h>
#include <errno.h>
#define AXP_GPIO_PREFIX "AXP0-"
@ -99,6 +96,11 @@ static const struct dm_gpio_ops axp_gpio_ops = {
static int axp_gpio_probe(struct udevice *dev)
{
struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
int ret;
ret = pmic_bus_init();
if (ret)
return ret;
/* Tell the uclass how many GPIOs we have */
uc_priv->bank_name = AXP_GPIO_PREFIX;
@ -107,26 +109,18 @@ static int axp_gpio_probe(struct udevice *dev)
return 0;
}
static const struct udevice_id axp_gpio_ids[] = {
{ .compatible = "x-powers,axp152-gpio" },
{ .compatible = "x-powers,axp209-gpio" },
{ .compatible = "x-powers,axp221-gpio" },
{ .compatible = "x-powers,axp813-gpio" },
{ }
};
U_BOOT_DRIVER(axp_gpio) = {
.name = "axp_gpio",
.id = UCLASS_GPIO,
.of_match = axp_gpio_ids,
.probe = axp_gpio_probe,
.ops = &axp_gpio_ops,
};
int axp_gpio_init(void)
{
struct udevice *dev;
int ret;
ret = pmic_bus_init();
if (ret)
return ret;
/* There is no devicetree support for the axp yet, so bind directly */
ret = device_bind_driver(dm_root(), "axp_gpio", "AXP-gpio", &dev);
if (ret)
return ret;
return 0;
}