]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - arch/arm/include/asm/arch-at91/gpio.h
gpio: at91: add missing () around macro arguments and remove redundant type cast...
[karo-tx-uboot.git] / arch / arm / include / asm / arch-at91 / gpio.h
index 293d0bf56b3b7d4b2d5beb340694b352a5b962e8..fd3743f6ac99fa694c36e6f0ca115f4221790346 100644 (file)
@@ -3,11 +3,7 @@
  *
  *  Copyright (C) 2005 HP Labs
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #ifndef __ASM_ARCH_AT91_GPIO_H
@@ -20,7 +16,7 @@
 
 #ifdef CONFIG_ATMEL_LEGACY
 
-#define PIN_BASE               32
+#define PIN_BASE               0
 
 #define MAX_GPIO_BANKS         5
 
@@ -207,7 +203,7 @@ static inline void *pin_to_controller(unsigned pin)
 {
        pin -= PIN_BASE;
        pin /= 32;
-       return (void *)(at91_pios[pin]);
+       return at91_pios[pin];
 }
 
 static inline unsigned pin_to_mask(unsigned pin)
@@ -218,21 +214,51 @@ static inline unsigned pin_to_mask(unsigned pin)
 
 /* The following macros are need for backward compatibility */
 #define at91_set_GPIO_periph(x, y) \
-       at91_set_gpio_periph((x - PIN_BASE) / 32,(x % 32), y)
+       at91_set_pio_periph(((x) - PIN_BASE) / 32, (x) % 32, y)
 #define at91_set_A_periph(x, y) \
-       at91_set_a_periph((x - PIN_BASE) / 32,(x % 32), y)
+       at91_set_a_periph(((x) - PIN_BASE) / 32, (x) % 32, y)
 #define at91_set_B_periph(x, y) \
-       at91_set_b_periph((x - PIN_BASE) / 32,(x % 32), y)
+       at91_set_b_periph(((x) - PIN_BASE) / 32, (x) % 32, y)
 #define at91_set_gpio_output(x, y) \
-       at91_set_pio_output((x - PIN_BASE) / 32,(x % 32), y)
+       at91_set_pio_output(((x) - PIN_BASE) / 32, (x) % 32, y)
 #define at91_set_gpio_input(x, y) \
-       at91_set_pio_input((x - PIN_BASE) / 32,(x % 32), y)
+       at91_set_pio_input(((x) - PIN_BASE) / 32, (x) % 32, y)
 #define at91_set_gpio_value(x, y) \
-       at91_set_pio_value((x - PIN_BASE) / 32,(x % 32), y)
+       at91_set_pio_value(((x) - PIN_BASE) / 32, (x) % 32, y)
 #define at91_get_gpio_value(x) \
-       at91_get_pio_value((x - PIN_BASE) / 32,(x % 32))
+       at91_get_pio_value(((x) - PIN_BASE) / 32, (x) % 32)
 #else
-#define at91_set_gpio_value(x, y)      at91_set_pio_value(x, y)
-#define at91_get_gpio_value(x)         at91_get_pio_value(x)
-#endif
+#define at91_set_gpio_value(x, y)      at91_set_pio_value(at91_gpio_to_port(x), \
+                                                       at91_gpio_to_pin(x), y)
+#define at91_get_gpio_value(x)         at91_get_pio_value(at91_gpio_to_port(x), \
+                                                       at91_gpio_to_pin(x))
 #endif
+
+#define GPIO_PIOA_BASE  0
+#define GPIO_PIOB_BASE  (GPIO_PIOA_BASE + 32)
+#define GPIO_PIOC_BASE  (GPIO_PIOB_BASE + 32)
+#define GPIO_PIOD_BASE  (GPIO_PIOC_BASE + 32)
+#define GPIO_PIOE_BASE  (GPIO_PIOD_BASE + 32)
+#define GPIO_PIN_PA(x)  (GPIO_PIOA_BASE + (x))
+#define GPIO_PIN_PB(x)  (GPIO_PIOB_BASE + (x))
+#define GPIO_PIN_PC(x)  (GPIO_PIOC_BASE + (x))
+#define GPIO_PIN_PD(x)  (GPIO_PIOD_BASE + (x))
+#define GPIO_PIN_PE(x)  (GPIO_PIOE_BASE + (x))
+
+static inline unsigned at91_gpio_to_port(unsigned gpio)
+{
+       return gpio / 32;
+}
+
+static inline unsigned at91_gpio_to_pin(unsigned gpio)
+{
+       return gpio % 32;
+}
+
+/* Platform data for each GPIO port */
+struct at91_port_platdata {
+       uint32_t base_addr;
+       const char *bank_name;
+};
+
+#endif /* __ASM_ARCH_AT91_GPIO_H */