summaryrefslogtreecommitdiff
path: root/drivers/gpio/at91_gpio.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2019-12-11 08:16:16 -0500
committerTom Rini <trini@konsulko.com>2019-12-11 08:16:16 -0500
commitaddb1d9f5d63f4586fa4a0ad24a9eaae35331783 (patch)
treec82d3d5454934c5f403ed78ca1f35dd8788c78bf /drivers/gpio/at91_gpio.c
parentfd4b8f813f11879bb38a0d3a5839279e85325476 (diff)
parente50d238a1ce856d3e16bbc279a6e92a0c2b5fb4f (diff)
Merge tag 'u-boot-atmel-fixes-2020.01-a' of https://gitlab.denx.de/u-boot/custodians/u-boot-atmel
- First set of u-boot-atmel fixes for 2020.01 cycle: This set includes a small fix for gpio bank names, one for removing unused headers (also touches some other boards), and a fix for the QSPI env read on one of the boards.
Diffstat (limited to 'drivers/gpio/at91_gpio.c')
-rw-r--r--drivers/gpio/at91_gpio.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/drivers/gpio/at91_gpio.c b/drivers/gpio/at91_gpio.c
index 965becf77a..dbfed72c61 100644
--- a/drivers/gpio/at91_gpio.c
+++ b/drivers/gpio/at91_gpio.c
@@ -556,6 +556,28 @@ static int at91_gpio_get_function(struct udevice *dev, unsigned offset)
return GPIOF_INPUT;
}
+static const char *at91_get_bank_name(uint32_t base_addr)
+{
+ switch (base_addr) {
+ case ATMEL_BASE_PIOA:
+ return "PIOA";
+ case ATMEL_BASE_PIOB:
+ return "PIOB";
+ case ATMEL_BASE_PIOC:
+ return "PIOC";
+#if (ATMEL_PIO_PORTS > 3)
+ case ATMEL_BASE_PIOD:
+ return "PIOD";
+#if (ATMEL_PIO_PORTS > 4)
+ case ATMEL_BASE_PIOE:
+ return "PIOE";
+#endif
+#endif
+ }
+
+ return "undefined";
+}
+
static const struct dm_gpio_ops gpio_at91_ops = {
.direction_input = at91_gpio_direction_input,
.direction_output = at91_gpio_direction_output,
@@ -582,14 +604,15 @@ static int at91_gpio_probe(struct udevice *dev)
clk_free(&clk);
- uc_priv->bank_name = plat->bank_name;
- uc_priv->gpio_count = GPIO_PER_BANK;
-
#if CONFIG_IS_ENABLED(OF_CONTROL)
plat->base_addr = (uint32_t)devfdt_get_addr_ptr(dev);
#endif
+ plat->bank_name = at91_get_bank_name(plat->base_addr);
port->regs = (struct at91_port *)plat->base_addr;
+ uc_priv->bank_name = plat->bank_name;
+ uc_priv->gpio_count = GPIO_PER_BANK;
+
return 0;
}