diff mbox series

[U-Boot,v2] gpio: at91_gpio: Add bank names

Message ID 0102016e84617b12-968fc4b1-c4e4-4382-87b0-30897473ef4b-000000@eu-west-1.amazonses.com
State Changes Requested
Delegated to: Eugen Hristev
Headers show
Series [U-Boot,v2] gpio: at91_gpio: Add bank names | expand

Commit Message

James Byrne Nov. 19, 2019, 3:56 p.m. UTC
Make the at91_gpio driver set sensible GPIO bank names in the platform
data. This makes the 'gpio status' command a lot more useful.

Signed-off-by: James Byrne <james.byrne@origamienergy.com>

---

Changes in v2:
- Use "undefined" for an unknown bank name.

 drivers/gpio/at91_gpio.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

Comments

Eugen Hristev Nov. 20, 2019, 7:21 a.m. UTC | #1
On 19.11.2019 17:56, James Byrne wrote:
> Make the at91_gpio driver set sensible GPIO bank names in the platform
> data. This makes the 'gpio status' command a lot more useful.
> 
> Signed-off-by: James Byrne <james.byrne@origamienergy.com>
> 
> ---

Reviewed-by: Eugen Hristev <eugen.hristev@microchip.com>
Eugen Hristev Nov. 22, 2019, 7:07 a.m. UTC | #2
On 20.11.2019 09:21, Eugen Hristev wrote:
> 
> 
> On 19.11.2019 17:56, James Byrne wrote:
>> Make the at91_gpio driver set sensible GPIO bank names in the platform
>> data. This makes the 'gpio status' command a lot more useful.
>>
>> Signed-off-by: James Byrne <james.byrne@origamienergy.com>
>>
>> ---
> 
> Reviewed-by: Eugen Hristev <eugen.hristev@microchip.com>

Hi James,

Unfortunately this patch breaks a number of platforms:

  smartweb

+drivers/gpio/at91_gpio.c:22:20: error: 'at91_get_bank_name' defined but 
not used [-Werror=unused-function]

at91rm9200ek at91rm9200ek_ram wb45n picosam9g45 corvus smartweb

+drivers/gpio/at91_gpio.c:22:20: error: 'at91_get_bank_name' defined but 
not used [-Werror=unused-function]

Can you please fix this ? Otherwise I cannot take this patch.

Thanks !
Eugen
diff mbox series

Patch

diff --git a/drivers/gpio/at91_gpio.c b/drivers/gpio/at91_gpio.c
index 965becf77a..2c5a2098fe 100644
--- a/drivers/gpio/at91_gpio.c
+++ b/drivers/gpio/at91_gpio.c
@@ -19,6 +19,28 @@ 
 
 #define GPIO_PER_BANK	32
 
+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 struct at91_port *at91_pio_get_port(unsigned port)
 {
 	switch (port) {
@@ -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;
 }