[U-Boot] [RFC PATCH 1/3] at91: add new gpio pin macros
Andreas Bießmann
andreas.devel at googlemail.com
Tue Oct 29 13:53:09 CET 2013
Signed-off-by: Andreas Bießmann <andreas.devel at googlemail.com>
---
arch/arm/include/asm/arch-at91/gpio.h | 34 ++++++++++++++++++++++++++++-----
1 file changed, 29 insertions(+), 5 deletions(-)
diff --git a/arch/arm/include/asm/arch-at91/gpio.h b/arch/arm/include/asm/arch-at91/gpio.h
index 0700427..f9ca11e 100644
--- a/arch/arm/include/asm/arch-at91/gpio.h
+++ b/arch/arm/include/asm/arch-at91/gpio.h
@@ -227,8 +227,32 @@ static inline unsigned pin_to_mask(unsigned pin)
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))
-#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
-#endif
+#else /* CONFIG_ATMEL_LEGACY */
+
+#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))
+
+#define at91_gpio_to_port(gpio) (gpio / 32)
+#define at91_gpio_to_pin(gpio) (gpio % 32)
+
+/* remove after transition to generic gpio API of all users */
+#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))
+
+#define at91_set_gpio_input(x, y) \
+ at91_set_pio_input(at91_gpio_to_port(x), at91_gpio_to_pin(x), y)
+#define at91_set_gpio_output(x, y) \
+ at91_set_pio_output(at91_gpio_to_port(x), at91_gpio_to_pin(x), y)
+
+#endif /* CONFIG_ATMEL_LEGACY */
+#endif /* __ASM_ARCH_AT91_GPIO_H */
--
1.7.10.4
More information about the U-Boot
mailing list