Skip to contentSkip to conversation

at91: remove legacy gpio API

RFC PATCH New Andreas Bießmann 6 participants 21 messages Oct 29, 2013 – Dec 9, 2013

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover at91: remove legacy gpio API

This RFC is to remove the need for legacy at91 gpio API in favor of switching to generic gpio API.

Please comment, especially on new gpio macros.

Andreas Bie?mann (3):
at91: add new gpio pin macros
at91sam9263ek: remove ATMEL_LEGACY
at91: use generic gpio API for AT91_LED

 arch/arm/cpu/arm926ejs/at91/led.c     |   43 +++++++++++++++++++++++++++++++++
 arch/arm/include/asm/arch-at91/gpio.h |   34 ++++++++++++++++++++++----
 board/atmel/at91sam9263ek/led.c       |   12 +++------
 include/configs/at91sam9263ek.h       |   13 +++++-----
 4 files changed, 82 insertions(+), 20 deletions(-)
Signature · 1 line
1.7.10.4
#1 lore raw

RFC PATCH 1/3 at91: add new gpio pin macros

---
 arch/arm/include/asm/arch-at91/gpio.h |   34 ++++++++++++++++++++++++++++-----
 1 file changed, 29 insertions(+), 5 deletions(-)
arch/arm/include/asm/arch-at91/gpio.h +29 -5
index 0700427..f9ca11e 100644
@@ -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 */
Signature · 1 line
1.7.10.4
#2 lore raw

RFC PATCH 1/3 at91: add new gpio pin macros

Hi Andreas,

Quoted 23 lines · Andreas Bie?mann
---
  arch/arm/include/asm/arch-at91/gpio.h |   34 ++++++++++++++++++++++++++++-----
  1 file changed, 29 insertions(+), 5 deletions(-)
arch/arm/include/asm/arch-at91/gpio.h +5 -5
index 0700427..f9ca11e 100644
@@ -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)

arch/arm/include/asm/arch-at91/gpio.h static inline unsigned pin_to_mask(unsigned pin) · line 244

Quoted 10 lines
arch/arm/include/asm/arch-at91/gpio.h +10 -0
+#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)

This is an exception for at91sam9x5 and at91sam9n12 SoCs, which PIOB and PIOD are not 32 pins. PIOB only has 19 pins, while PIOD only has 22 pins.

Quoted 4 lines
arch/arm/include/asm/arch-at91/gpio.h +3 -0
+/* 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)

arch/arm/include/asm/arch-at91/gpio.h static inline unsigned pin_to_mask(unsigned pin) · line 258

Quoted 10 lines
arch/arm/include/asm/arch-at91/gpio.h +10 -0
+#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 */

Best Regards,
Bo Shen

#3 lore raw

RFC PATCH 1/3 at91: add new gpio pin macros

Hi Bo,

+Jens, he did the rewrite of the at91 gpio driver.

Quoted 31 lines · Bo Shen
Quoted 30 lines · Andreas Bie?mann
---
  arch/arm/include/asm/arch-at91/gpio.h |   34
++++++++++++++++++++++++++++-----
  1 file changed, 29 insertions(+), 5 deletions(-)
arch/arm/include/asm/arch-at91/gpio.h +10 -5
index 0700427..f9ca11e 100644
@@ -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))
Quoted 8 lines

arch/arm/include/asm/arch-at91/gpio.h static inline unsigned pin_to_mask(unsigned pin) · line 244

Quoted 5 lines
arch/arm/include/asm/arch-at91/gpio.h +5 -0
+#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)

This is an exception for at91sam9x5 and at91sam9n12 SoCs, which PIOB and PIOD are not 32 pins. PIOB only has 19 pins, while PIOD only has 22 pins.

I think this is a job for gpio_is_valid() then. How is this case handled in kernel?

Here are a few things to discuss. First of all I'd like to get some insights why the at91 gpio API was changed back in 2010. It was a plain number before and was changed to PORT + PIN as two separate parameters. Jens, could you please shed some light on this?

The second thing is this specific RFC implementation. It contains again different points.

a) it defines another way to get a plain number for a GPIO

    (GPIO_PIN_Px())

I know that the kernel uses AT91_PIN_Pxy notation for defining a GPIO number. The above approach is copied from AVR32 which I think is a bit better cause of smaller include file. This change however should be discussed here.

b) the fact that we shift back to a plain number for defining a GPIO

I'd like to have a plain number defining a GPIO (which doesn't need to correlate to a number in SoC spec's). It is just a plain number for feeding generic gpio API. Which I'd like to use in the drivers to be able to share with AVR32 or other generic stuff like status led API. Currently some drivers do not define the CONFIG_ATMEL_LEGACY (to hide the old defines) but use the PORT + PIN pair for example in pm9g45:

#define CONFIG_RED_LED AT91_PIO_PORTD, 31

and this is ugly!

Just to mention, I'd like to hide the current API of PORT + PIN as separate parameters but not delete it. It is Ok in at91 specific surrounding but where we share code with others we need to use that single number that represents a GPIO. Especially is it misleading approach in board headers to define the PORT + PIN tuple as an single parameter to be placed in by preprocessor.

Any comments?

Best regards

Andreas Bie?mann

#4 lore raw

RFC PATCH 1/3 at91: add new gpio pin macros

Am 30.10.2013 11:39, schrieb Andreas Bie?mann:

Quoted 6 lines

Hi Bo,

+Jens, he did the rewrite of the at91 gpio driver.

Quoted 8 lines

I think this is a job for gpio_is_valid() then. How is this case handled in kernel?

Here are a few things to discuss. First of all I'd like to get some insights why the at91 gpio API was changed back in 2010. It was a plain number before and was changed to PORT + PIN as two separate parameters. Jens, could you please shed some light on this?

Sorry, but I don't remember me why we do this. I think, it was a compromise between number of changes and code size.

Regards

Jens

#5 lore raw

RFC PATCH 1/3 at91: add new gpio pin macros

Hi Jens,

Quoted 10 lines · Jens Scharsig

Am 30.10.2013 11:39, schrieb Andreas Bie?mann:

Quoted 9 lines

Hi Bo,

+Jens, he did the rewrite of the at91 gpio driver.

I think this is a job for gpio_is_valid() then. How is this case handled in kernel?

Quoted 8 lines
Quoted 5 lines

Here are a few things to discuss. First of all I'd like to get some insights why the at91 gpio API was changed back in 2010. It was a plain number before and was changed to PORT + PIN as two separate parameters. Jens, could you please shed some light on this?

Sorry, but I don't remember me why we do this. I think, it was a compromise between number of changes and code size.

found it:
http://article.gmane.org/gmane.comp.boot-loaders.u-boot/74579

---8<---

Review

Quoted 10 lines · Jens Scharsig
(quoted diff) +10 -0
+#endif
+
+#define AT91_PIN_TO_MASK(x)	(1<<x)
+#define AT91_PORTPIN(PORT, PIN)	((0x0##PORT - 9) * 32 + ((PIN) & 0x1F))
+#define	AT91_PIO_PORTA		0x0
+#define	AT91_PIO_PORTB		0x1
+#define	AT91_PIO_PORTC		0x2
+#define	AT91_PIO_PORTD		0x3
+#define	AT91_PIO_PORTE		0x4
+

Tom.Rix at windriver.com:
Is this necessary?
You are packing arguments that you are passing to the gpio functions. It would be better if there were seperate port, pin parameters than combining and then uncombining.
Please change this.
--->8---

I think we should shift toward the linux kernel at91_pio API which uses a single number for identifying the GPIO. Any complaints?

I think it would make sense to retain some PORT + MASK functions to easily switch multiple I/O in one go. What do you think about?

Best regards

Andreas Bie?mann

#6 lore raw

RFC PATCH 1/3 at91: add new gpio pin macros

Hello Andreas,

Am 30.10.2013 19:59, schrieb Andreas Bie?mann:

Quoted 46 lines

Hi Jens,

Quoted 10 lines · Jens Scharsig

Am 30.10.2013 11:39, schrieb Andreas Bie?mann:

Quoted 9 lines

Hi Bo,

+Jens, he did the rewrite of the at91 gpio driver.

I think this is a job for gpio_is_valid() then. How is this case handled in kernel?

Quoted 8 lines
Quoted 5 lines

Here are a few things to discuss. First of all I'd like to get some insights why the at91 gpio API was changed back in 2010. It was a plain number before and was changed to PORT + PIN as two separate parameters. Jens, could you please shed some light on this?

Sorry, but I don't remember me why we do this. I think, it was a compromise between number of changes and code size.

found it:
http://article.gmane.org/gmane.comp.boot-loaders.u-boot/74579

---8<---

Review

Quoted 10 lines · Jens Scharsig
(quoted diff) +10 -0
+#endif
+
+#define AT91_PIN_TO_MASK(x)	(1<<x)
+#define AT91_PORTPIN(PORT, PIN)	((0x0##PORT - 9) * 32 + ((PIN)&  0x1F))
+#define	AT91_PIO_PORTA		0x0
+#define	AT91_PIO_PORTB		0x1
+#define	AT91_PIO_PORTC		0x2
+#define	AT91_PIO_PORTD		0x3
+#define	AT91_PIO_PORTE		0x4
+

Tom.Rix at windriver.com:
Is this necessary?
You are packing arguments that you are passing to the gpio functions. It would be better if there were seperate port, pin parameters than combining and then uncombining.
Please change this.
--->8---

Quoted 2 lines

I think we should shift toward the linux kernel at91_pio API which uses a single number for identifying the GPIO. Any complaints?

Full Ack.

Quoted 2 lines

I think it would make sense to retain some PORT + MASK functions to easily switch multiple I/O in one go. What do you think about?

That would be good.

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#7 lore raw

RFC PATCH 2/3 at91sam9263ek: remove ATMEL_LEGACY

In reply to Andreas Bießmann
---
 board/atmel/at91sam9263ek/led.c |   12 ++++--------
 include/configs/at91sam9263ek.h |   13 ++++++-------
 2 files changed, 10 insertions(+), 15 deletions(-)
board/atmel/at91sam9263ek/led.c +4 -8
index e317d99..8ed8de2 100644
@@ -8,7 +8,7 @@
 
 #include <common.h>
 #include <asm/io.h>
-#include <asm/arch/gpio.h>
+#include <asm/gpio.h>
 #include <asm/arch/at91_pmc.h>
 #include <asm/arch/at91sam9263.h>
 
@@ -20,11 +20,7 @@ void coloured_LED_init(void)
 	writel(1 << ATMEL_ID_PIOB | 1 << ATMEL_ID_PIOCDE,
 		&pmc->pcer);
 
-	at91_set_gpio_output(CONFIG_RED_LED, 1);
-	at91_set_gpio_output(CONFIG_GREEN_LED, 1);
-	at91_set_gpio_output(CONFIG_YELLOW_LED, 1);
-
-	at91_set_gpio_value(CONFIG_RED_LED, 0);
-	at91_set_gpio_value(CONFIG_GREEN_LED, 1);
-	at91_set_gpio_value(CONFIG_YELLOW_LED, 1);
+	gpio_direction_output(CONFIG_RED_LED, 0);
+	gpio_direction_output(CONFIG_GREEN_LED, 1);
+	gpio_direction_output(CONFIG_YELLOW_LED, 1);
 }
include/configs/at91sam9263ek.h +6 -7
index 40e167c..3a80e7d 100644
@@ -52,8 +52,7 @@
 /*
  * Hardware drivers
  */
-#define CONFIG_ATMEL_LEGACY
-#define CONFIG_AT91_GPIO		1
+#define CONFIG_AT91_GPIO
 #define CONFIG_AT91_GPIO_PULLUP		1
 
 /* serial console */
@@ -76,9 +75,9 @@
 
 /* LED */
 #define CONFIG_AT91_LED
-#define	CONFIG_RED_LED		AT91_PIN_PB7	/* the power led */
-#define	CONFIG_GREEN_LED	AT91_PIN_PB8	/* the user1 led */
-#define	CONFIG_YELLOW_LED	AT91_PIN_PC29	/* the user2 led */
+#define	CONFIG_RED_LED		GPIO_PIN_PA(7)  /* the power led */
+#define	CONFIG_GREEN_LED	GPIO_PIN_PB(8)  /* the user1 led */
+#define	CONFIG_YELLOW_LED	GPIO_PIN_PC(29) /* the user2 led */
 
 #define CONFIG_BOOTDELAY	3
 
@@ -267,8 +266,8 @@
 #define CONFIG_SYS_NAND_MASK_ALE		(1 << 21)
 /* our CLE is AD22 */
 #define CONFIG_SYS_NAND_MASK_CLE		(1 << 22)
-#define CONFIG_SYS_NAND_ENABLE_PIN		AT91_PIN_PD15
-#define CONFIG_SYS_NAND_READY_PIN		AT91_PIN_PA22
+#define CONFIG_SYS_NAND_ENABLE_PIN		GPIO_PIN_PD(15)
+#define CONFIG_SYS_NAND_READY_PIN		GPIO_PIN_PA(22)
 #endif
 
 /* Ethernet */
Signature · 1 line
1.7.10.4
#8 lore raw

RFC PATCH 3/3 at91: use generic gpio API for AT91_LED

In reply to Andreas Bießmann
---
 arch/arm/cpu/arm926ejs/at91/led.c |   43 +++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
arch/arm/cpu/arm926ejs/at91/led.c +43 -0
index 5dd9048..9dcba7a 100644
@@ -7,6 +7,9 @@
  */
 
 #include <common.h>
+
+#ifdef CONFIG_ATMEL_LEGACY
+
 #include <asm/io.h>
 #include <asm/arch/at91_pmc.h>
 #include <asm/arch/at91_pio.h>
@@ -47,3 +50,43 @@ void yellow_led_off(void)
 	at91_set_gpio_value(CONFIG_YELLOW_LED, 1);
 }
 #endif
+#else /* CONFIG_ATMEL_LEGACY */
+
+#include <asm/gpio.h>
+
+#ifdef CONFIG_RED_LED
+void red_led_on(void)
+{
+	gpio_set_value(CONFIG_RED_LED, 1);
+}
+
+void red_led_off(void)
+{
+	gpio_set_value(CONFIG_RED_LED, 0);
+}
+#endif
+
+#ifdef CONFIG_GREEN_LED
+void green_led_on(void)
+{
+	gpio_set_value(CONFIG_GREEN_LED, 0);
+}
+
+void green_led_off(void)
+{
+	gpio_set_value(CONFIG_GREEN_LED, 1);
+}
+#endif
+
+#ifdef CONFIG_YELLOW_LED
+void yellow_led_on(void)
+{
+	gpio_set_value(CONFIG_YELLOW_LED, 0);
+}
+
+void yellow_led_off(void)
+{
+	gpio_set_value(CONFIG_YELLOW_LED, 1);
+}
+#endif
+#endif /* CONFIG_ATMEL_LEGACY */
Signature · 1 line
1.7.10.4
#9 lore raw

cover at91: remove legacy GPIO API (part 1)

In reply to Andreas Bießmann

This series adds new macros to name a GPIO, it uses again a single number (as the legacy at91_pio api does).
It converts the at91-nand and the at91-led stuff to use these new GPIO numbers. But it is not the whole thing at once, I have another RFC to add new portmux API which is more close to the hardware, it will work with a port number plus mask. This will be sent soon, but too late for 2014.01.

This series however had an RFC in the MW and will therefore end up in the 2014.01 release.

For all waiting on this change, I hopefully merge it next week and send another PR to Albert.

Andreas Bie?mann (4):
at91: add new gpio pin definitions
at91: redefine legacy GPIO PIN_BASE
at91: nand: switch atmel_nand to generic GPIO API
at91: switch coloured LED to gpio API

 arch/arm/cpu/arm926ejs/at91/led.c     |   16 +++++++---------
 arch/arm/include/asm/arch-at91/gpio.h |   26 ++++++++++++++++++++++++--
 board/BuS/vl_ma2sc/vl_ma2sc.c         |    5 +++--
 board/egnite/ethernut5/ethernut5.c    |    3 ++-
 board/esd/meesc/meesc.c               |    5 +++--
 board/esd/otc570/otc570.c             |    5 +++--
 board/eukrea/cpu9260/cpu9260.c        |    5 +++--
 board/ronetix/pm9261/led.c            |   14 +++++++-------
 board/ronetix/pm9261/pm9261.c         |    5 +++--
 board/ronetix/pm9263/led.c            |   10 +++++-----
 board/ronetix/pm9263/pm9263.c         |    5 +++--
 board/ronetix/pm9g45/pm9g45.c         |    5 +++--
 drivers/gpio/at91_gpio.c              |    4 +---
 drivers/mtd/nand/atmel_nand.c         |    8 +++-----
 include/configs/at91sam9n12ek.h       |    4 ++--
 include/configs/cpu9260.h             |    4 ++--
 include/configs/ethernut5.h           |    2 +-
 include/configs/meesc.h               |    4 ++--
 include/configs/otc570.h              |    4 ++--
 include/configs/pm9261.h              |   10 +++++-----
 include/configs/pm9263.h              |    8 ++++----
 include/configs/pm9g45.h              |    8 ++++----
 include/configs/vl_ma2sc.h            |    4 ++--
 23 files changed, 94 insertions(+), 70 deletions(-)
Signature · 1 line
1.7.10.4
#10 lore raw

PATCH 1/4 at91: add new gpio pin definitions

This patch define new names for GPIO pins on at91 devices. Follow up patches will convert the whole infrastructure to use these new definitions.

---
 arch/arm/include/asm/arch-at91/gpio.h |   24 +++++++++++++++++++++++-
 drivers/gpio/at91_gpio.c              |    4 +---
 2 files changed, 24 insertions(+), 4 deletions(-)
arch/arm/include/asm/arch-at91/gpio.h +23 -1
index 0700427..b340afe 100644
@@ -231,4 +231,26 @@ static inline unsigned pin_to_mask(unsigned pin)
 #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
+
+#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;
+}
+
+#endif /* __ASM_ARCH_AT91_GPIO_H */
drivers/gpio/at91_gpio.c +1 -3
index af09786..8b76666 100644
@@ -14,6 +14,7 @@
 #include <asm/sizes.h>
 #include <asm/arch/hardware.h>
 #include <asm/arch/at91_pio.h>
+#include <asm/arch/gpio.h>
 
 static struct at91_port *at91_pio_get_port(unsigned port)
 {
@@ -356,9 +357,6 @@ int at91_get_pio_value(unsigned port, unsigned pin)
 
 /* Common GPIO API */
 
-#define at91_gpio_to_port(gpio)		(gpio / 32)
-#define at91_gpio_to_pin(gpio)		(gpio % 32)
-
 int gpio_request(unsigned gpio, const char *label)
 {
 	return 0;
Signature · 1 line
1.7.10.4
#11 lore raw

PATCH 1/4 at91: add new gpio pin definitions

Hi Andreas,

Quoted 8 lines · Andreas Bie?mann

This patch define new names for GPIO pins on at91 devices. Follow up patches will convert the whole infrastructure to use these new definitions.

---
  arch/arm/include/asm/arch-at91/gpio.h |   24 +++++++++++++++++++++++-
  drivers/gpio/at91_gpio.c              |    4 +---
  2 files changed, 24 insertions(+), 4 deletions(-)

For this series, tested OK on at91sam9n12ek and at91sam9x5ek board. Thanks.

Best Regards,
Bo Shen

#12 lore raw

PATCH 1/4 at91: add new gpio pin definitions

In reply to Andreas Bießmann

Dear Andreas Devel,

Quoted 10 lines · Andreas Devel

This patch define new names for GPIO pins on at91 devices. Follow up patches will convert the whole infrastructure to use these new definitions.

---
arch/arm/include/asm/arch-at91/gpio.h | 24 +++++++++++++++++++++++-
drivers/gpio/at91_gpio.c | 4 +---

2 files changed, 24 insertions(+), 4 deletions(-)

applied to u-boot-atmel/master, thanks!

Best regards,
Andreas Bie?mann

#13 lore raw

PATCH 2/4 at91: redefine legacy GPIO PIN_BASE

In reply to Andreas Bießmann

In order to get the very same value for legacy pin definitions and new gpio definitions set the legacy PIN_BASE to 0.

---
 arch/arm/include/asm/arch-at91/gpio.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/arch-at91/gpio.h +1 -1
index b340afe..ff6142b 100644
@@ -16,7 +16,7 @@
 
 #ifdef CONFIG_ATMEL_LEGACY
 
-#define PIN_BASE		32
+#define PIN_BASE		0
 
 #define MAX_GPIO_BANKS		5
 
Signature · 1 line
1.7.10.4
#14 lore raw

PATCH 2/4 at91: redefine legacy GPIO PIN_BASE

Dear Andreas Devel,

Quoted 8 lines · Andreas Devel

In order to get the very same value for legacy pin definitions and new gpio definitions set the legacy PIN_BASE to 0.

---
arch/arm/include/asm/arch-at91/gpio.h | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)

applied to u-boot-atmel/master, thanks!

Best regards,
Andreas Bie?mann

#15 lore raw

PATCH 3/4 at91: nand: switch atmel_nand to generic GPIO API

In reply to Andreas Bießmann
---
 board/BuS/vl_ma2sc/vl_ma2sc.c      |    5 +++--
 board/egnite/ethernut5/ethernut5.c |    3 ++-
 board/esd/meesc/meesc.c            |    5 +++--
 board/esd/otc570/otc570.c          |    5 +++--
 board/eukrea/cpu9260/cpu9260.c     |    5 +++--
 board/ronetix/pm9261/pm9261.c      |    5 +++--
 board/ronetix/pm9263/pm9263.c      |    5 +++--
 board/ronetix/pm9g45/pm9g45.c      |    5 +++--
 drivers/mtd/nand/atmel_nand.c      |    8 +++-----
 include/configs/at91sam9n12ek.h    |    4 ++--
 include/configs/cpu9260.h          |    4 ++--
 include/configs/ethernut5.h        |    2 +-
 include/configs/meesc.h            |    4 ++--
 include/configs/otc570.h           |    4 ++--
 include/configs/pm9261.h           |    4 ++--
 include/configs/pm9263.h           |    4 ++--
 include/configs/pm9g45.h           |    4 ++--
 include/configs/vl_ma2sc.h         |    4 ++--
 18 files changed, 43 insertions(+), 37 deletions(-)
board/BuS/vl_ma2sc/vl_ma2sc.c +3 -2
index e2ae6fd..ccfb6da 100644
@@ -10,6 +10,7 @@
 #include <common.h>
 #include <asm/sizes.h>
 #include <asm/io.h>
+#include <asm/gpio.h>
 #include <asm/arch/hardware.h>
 #include <asm/arch/clk.h>
 #include <asm/arch/at91_matrix.h>
@@ -66,10 +67,10 @@ static void vl_ma2sc_nand_hw_init(void)
 
 	/* Configure RDY/BSY */
 #ifdef CONFIG_SYS_NAND_READY_PIN
-	at91_set_pio_input(CONFIG_SYS_NAND_READY_PIN, 1);
+	gpio_direction_input(CONFIG_SYS_NAND_READY_PIN);
 #endif
 	/* Enable NandFlash */
-	at91_set_pio_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
+	gpio_direction_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
 }
 #endif
 
board/egnite/ethernut5/ethernut5.c +2 -1
index 1f5eea5..b45213c 100644
@@ -71,6 +71,7 @@
 #include <asm/arch/at91_spi.h>
 #include <asm/arch/gpio.h>
 #include <asm/io.h>
+#include <asm/gpio.h>
 
 #include "ethernut5_pwrman.h"
 
@@ -141,7 +142,7 @@ static void ethernut5_nand_hw_init(void)
 	/* Ready pin is optional. */
 	at91_set_pio_input(CONFIG_SYS_NAND_READY_PIN, 1);
 #endif
-	at91_set_pio_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
+	gpio_direction_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
 }
 #endif
 
board/esd/meesc/meesc.c +3 -2
index 9bf6739..c5994e0 100644
@@ -12,6 +12,7 @@
 
 #include <common.h>
 #include <asm/io.h>
+#include <asm/gpio.h>
 #include <asm/arch/at91sam9_smc.h>
 #include <asm/arch/at91_common.h>
 #include <asm/arch/at91_pmc.h>
@@ -74,10 +75,10 @@ static void meesc_nand_hw_init(void)
 		&smc->cs[3].mode);
 
 	/* Configure RDY/BSY */
-	at91_set_pio_input(CONFIG_SYS_NAND_READY_PIN, 1);
+	gpio_direction_input(CONFIG_SYS_NAND_READY_PIN);
 
 	/* Enable NandFlash */
-	at91_set_pio_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
+	gpio_direction_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
 }
 #endif /* CONFIG_CMD_NAND */
 
board/esd/otc570/otc570.c +3 -2
index acc1b31..4751d0a 100644
@@ -12,6 +12,7 @@
 
 #include <common.h>
 #include <asm/io.h>
+#include <asm/gpio.h>
 #include <asm/arch/at91sam9_smc.h>
 #include <asm/arch/at91_common.h>
 #include <asm/arch/at91_pmc.h>
@@ -82,10 +83,10 @@ static void otc570_nand_hw_init(void)
 		&smc->cs[3].mode);
 
 	/* Configure RDY/BSY */
-	at91_set_pio_input(CONFIG_SYS_NAND_READY_PIN, 1);
+	gpio_direction_input(CONFIG_SYS_NAND_READY_PIN);
 
 	/* Enable NandFlash */
-	at91_set_pio_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
+	gpio_direction_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
 }
 #endif /* CONFIG_CMD_NAND */
 
board/eukrea/cpu9260/cpu9260.c +3 -2
index 5e1524e..9dc6dcc 100644
@@ -12,6 +12,7 @@
 
 #include <common.h>
 #include <asm/io.h>
+#include <asm/gpio.h>
 #include <asm/arch/at91sam9260.h>
 #include <asm/arch/at91sam9_smc.h>
 #include <asm/arch/at91_common.h>
@@ -79,10 +80,10 @@ static void cpu9260_nand_hw_init(void)
 	writel(1 << ATMEL_ID_PIOC, &pmc->pcer);
 
 	/* Configure RDY/BSY */
-	at91_set_pio_input(CONFIG_SYS_NAND_READY_PIN, 1);
+	gpio_direction_input(CONFIG_SYS_NAND_READY_PIN);
 
 	/* Enable NandFlash */
-	at91_set_pio_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
+	gpio_direction_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
 }
 #endif
 
board/ronetix/pm9261/pm9261.c +3 -2
index a2a569b..a634383 100644
@@ -11,6 +11,7 @@
 #include <common.h>
 #include <asm/sizes.h>
 #include <asm/io.h>
+#include <asm/gpio.h>
 #include <asm/arch/at91sam9_smc.h>
 #include <asm/arch/at91_common.h>
 #include <asm/arch/at91_pmc.h>
@@ -73,10 +74,10 @@ static void pm9261_nand_hw_init(void)
 		&pmc->pcer);
 
 	/* Configure RDY/BSY */
-	at91_set_pio_input(CONFIG_SYS_NAND_READY_PIN, 1);
+	gpio_direction_input(CONFIG_SYS_NAND_READY_PIN);
 
 	/* Enable NandFlash */
-	at91_set_pio_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
+	gpio_direction_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
 
 	at91_set_a_periph(AT91_PIO_PORTC, 0, 0);	/* NANDOE */
 	at91_set_a_periph(AT91_PIO_PORTC, 1, 0);	/* NANDWE */
board/ronetix/pm9263/pm9263.c +3 -2
index 48eba99..3cedeef 100644
@@ -11,6 +11,7 @@
 #include <common.h>
 #include <asm/sizes.h>
 #include <asm/io.h>
+#include <asm/gpio.h>
 #include <asm/arch/at91sam9_smc.h>
 #include <asm/arch/at91_common.h>
 #include <asm/arch/at91_pmc.h>
@@ -67,10 +68,10 @@ static void pm9263_nand_hw_init(void)
 		&smc->cs[3].mode);
 
 	/* Configure RDY/BSY */
-	at91_set_pio_input(CONFIG_SYS_NAND_READY_PIN, 1);
+	gpio_direction_input(CONFIG_SYS_NAND_READY_PIN);
 
 	/* Enable NandFlash */
-	at91_set_pio_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
+	gpio_direction_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
 }
 #endif
 
board/ronetix/pm9g45/pm9g45.c +3 -2
index 5bb5a3c..c9f2747 100644
@@ -14,6 +14,7 @@
 #include <common.h>
 #include <asm/sizes.h>
 #include <asm/io.h>
+#include <asm/gpio.h>
 #include <asm/arch/at91sam9_smc.h>
 #include <asm/arch/at91_common.h>
 #include <asm/arch/at91_pmc.h>
@@ -66,11 +67,11 @@ static void pm9g45_nand_hw_init(void)
 
 #ifdef CONFIG_SYS_NAND_READY_PIN
 	/* Configure RDY/BSY */
-	at91_set_pio_input(CONFIG_SYS_NAND_READY_PIN, 1);
+	gpio_direction_input(CONFIG_SYS_NAND_READY_PIN);
 #endif
 
 	/* Enable NandFlash */
-	at91_set_pio_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
+	gpio_direction_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
 }
 #endif
 
drivers/mtd/nand/atmel_nand.c +3 -5
index da83f06..99fc86c 100644
@@ -12,9 +12,8 @@
  */
 
 #include <common.h>
-#include <asm/arch/hardware.h>
+#include <asm/gpio.h>
 #include <asm/arch/gpio.h>
-#include <asm/arch/at91_pio.h>
 
 #include <malloc.h>
 #include <nand.h>
@@ -1146,8 +1145,7 @@ static void at91_nand_hwcontrol(struct mtd_info *mtd,
 			IO_ADDR_W |= CONFIG_SYS_NAND_MASK_ALE;
 
 #ifdef CONFIG_SYS_NAND_ENABLE_PIN
-		at91_set_gpio_value(CONFIG_SYS_NAND_ENABLE_PIN,
-				    !(ctrl & NAND_NCE));
+		gpio_set_value(CONFIG_SYS_NAND_ENABLE_PIN, !(ctrl & NAND_NCE));
 #endif
 		this->IO_ADDR_W = (void *) IO_ADDR_W;
 	}
@@ -1159,7 +1157,7 @@ static void at91_nand_hwcontrol(struct mtd_info *mtd,
 #ifdef CONFIG_SYS_NAND_READY_PIN
 static int at91_nand_ready(struct mtd_info *mtd)
 {
-	return at91_get_gpio_value(CONFIG_SYS_NAND_READY_PIN);
+	return gpio_get_value(CONFIG_SYS_NAND_READY_PIN);
 }
 #endif
 
include/configs/at91sam9n12ek.h +2 -2
index 4ec1799..e23549d 100644
@@ -113,8 +113,8 @@
 #define CONFIG_SYS_NAND_BASE		0x40000000
 #define CONFIG_SYS_NAND_MASK_ALE	(1 << 21)
 #define CONFIG_SYS_NAND_MASK_CLE	(1 << 22)
-#define CONFIG_SYS_NAND_ENABLE_PIN	AT91_PIO_PORTD, 4
-#define CONFIG_SYS_NAND_READY_PIN	AT91_PIO_PORTD, 5
+#define CONFIG_SYS_NAND_ENABLE_PIN	GPIO_PIN_PD(4)
+#define CONFIG_SYS_NAND_READY_PIN	GPIO_PIN_PD(5)
 
 /* PMECC & PMERRLOC */
 #define CONFIG_ATMEL_NAND_HWECC
include/configs/cpu9260.h +2 -2
index ccf36a5..f189b15 100644
@@ -280,8 +280,8 @@
 #define CONFIG_SYS_MAX_NAND_DEVICE		1
 #define CONFIG_SYS_NAND_BASE			0x40000000
 #define CONFIG_SYS_NAND_DBW_8			1
-#define CONFIG_SYS_NAND_READY_PIN		AT91_PIO_PORTC, 13
-#define CONFIG_SYS_NAND_ENABLE_PIN		AT91_PIO_PORTC, 14
+#define CONFIG_SYS_NAND_READY_PIN		GPIO_PIN_PC(13)
+#define CONFIG_SYS_NAND_ENABLE_PIN		GPIO_PIN_PC(14)
 #define CONFIG_SYS_NAND_MASK_ALE		(1 << 21)
 #define CONFIG_SYS_NAND_MASK_CLE		(1 << 22)
 
include/configs/ethernut5.h +1 -1
index 252df54..480d867 100644
@@ -149,7 +149,7 @@
 #define CONFIG_SYS_NAND_MASK_ALE	(1 << 21)
 /* our CLE is AD22 */
 #define CONFIG_SYS_NAND_MASK_CLE	(1 << 22)
-#define CONFIG_SYS_NAND_ENABLE_PIN	AT91_PIO_PORTC, 14
+#define CONFIG_SYS_NAND_ENABLE_PIN	GPIO_PIN_PC(14)
 #endif
 
 /* JFFS2 */
include/configs/meesc.h +2 -2
index 91f6e2f..86ce5f2 100644
@@ -143,8 +143,8 @@
 # define CONFIG_SYS_NAND_DBW_8
 # define CONFIG_SYS_NAND_MASK_ALE		(1 << 21)
 # define CONFIG_SYS_NAND_MASK_CLE		(1 << 22)
-# define CONFIG_SYS_NAND_ENABLE_PIN		AT91_PIO_PORTD, 15
-# define CONFIG_SYS_NAND_READY_PIN		AT91_PIO_PORTA, 22
+# define CONFIG_SYS_NAND_ENABLE_PIN		GPIO_PIN_PD(15)
+# define CONFIG_SYS_NAND_READY_PIN		GPIO_PIN_PA(22)
 #endif
 
 /* Ethernet */
include/configs/otc570.h +2 -2
index 3f4e073..629967d 100644
@@ -193,8 +193,8 @@
 # define CONFIG_SYS_NAND_DBW_8
 # define CONFIG_SYS_NAND_MASK_ALE		(1 << 21)
 # define CONFIG_SYS_NAND_MASK_CLE		(1 << 22)
-# define CONFIG_SYS_NAND_ENABLE_PIN		AT91_PIO_PORTD, 15
-# define CONFIG_SYS_NAND_READY_PIN		AT91_PIO_PORTA, 22
+# define CONFIG_SYS_NAND_ENABLE_PIN		GPIO_PIN_PD(15)
+# define CONFIG_SYS_NAND_READY_PIN		GPIO_PIN_PA(22)
 #endif
 
 /* Ethernet */
include/configs/pm9261.h +2 -2
index fc95cf0..9442d8f 100644
@@ -221,8 +221,8 @@
 #define CONFIG_SYS_NAND_MASK_ALE		(1 << 22)
 /* our CLE is AD21 */
 #define CONFIG_SYS_NAND_MASK_CLE		(1 << 21)
-#define CONFIG_SYS_NAND_ENABLE_PIN		AT91_PIO_PORTC, 14
-#define CONFIG_SYS_NAND_READY_PIN		AT91_PIO_PORTA, 16
+#define CONFIG_SYS_NAND_ENABLE_PIN		GPIO_PIN_PC(14)
+#define CONFIG_SYS_NAND_READY_PIN		GPIO_PIN_PA(16)
 
 /* NOR flash */
 #define CONFIG_SYS_FLASH_CFI			1
include/configs/pm9263.h +2 -2
index 533e249..dffc336 100644
@@ -241,8 +241,8 @@
 #define CONFIG_SYS_NAND_MASK_ALE	(1 << 21)
 /* our CLE is AD22 */
 #define CONFIG_SYS_NAND_MASK_CLE	(1 << 22)
-#define CONFIG_SYS_NAND_ENABLE_PIN	AT91_PIO_PORTD, 15
-#define CONFIG_SYS_NAND_READY_PIN	AT91_PIO_PORTB, 30
+#define CONFIG_SYS_NAND_ENABLE_PIN	GPIO_PIN_PD(15)
+#define CONFIG_SYS_NAND_READY_PIN	GPIO_PIN_PB(30)
 
 #endif
 
include/configs/pm9g45.h +2 -2
index e0c388e..03a25c8 100644
@@ -106,8 +106,8 @@
 #define CONFIG_SYS_NAND_MASK_ALE	(1 << 21)
 /* our CLE is AD22 */
 #define CONFIG_SYS_NAND_MASK_CLE	(1 << 22)
-#define CONFIG_SYS_NAND_ENABLE_PIN	AT91_PIO_PORTC, 14
-#define CONFIG_SYS_NAND_READY_PIN	AT91_PIO_PORTD, 3
+#define CONFIG_SYS_NAND_ENABLE_PIN	GPIO_PIN_PC(14)
+#define CONFIG_SYS_NAND_READY_PIN	GPIO_PIN_PD(3)
 
 #endif
 
include/configs/vl_ma2sc.h +2 -2
index 1489080..98cb9d7 100644
@@ -320,8 +320,8 @@
 #define CONFIG_SYS_NAND_DBW_8		1
 #define CONFIG_SYS_NAND_MASK_ALE	(1 << 21)	/* our ALE is AD21 */
 #define CONFIG_SYS_NAND_MASK_CLE	(1 << 22)	/* our CLE is AD22 */
-#define CONFIG_SYS_NAND_ENABLE_PIN	AT91_PIO_PORTD, 15
-#define CONFIG_SYS_NAND_READY_PIN	AT91_PIO_PORTB, 0
+#define CONFIG_SYS_NAND_ENABLE_PIN	GPIO_PIN_PD(15)
+#define CONFIG_SYS_NAND_READY_PIN	GPIO_PIN_PB(0)
 #define CONFIG_SYS_64BIT_VSPRINTF	/* needed for nand_util.c */
 #endif
 
Signature · 1 line
1.7.10.4
#16 lore raw

PATCH 3/4 at91: nand: switch atmel_nand to generic GPIO API

Am 2013-11-29 12:13, schrieb Andreas Bie?mann:

Quoted 13 lines
---
 board/BuS/vl_ma2sc/vl_ma2sc.c      |    5 +++--
 board/egnite/ethernut5/ethernut5.c |    3 ++-
 board/esd/meesc/meesc.c            |    5 +++--
 board/esd/otc570/otc570.c          |    5 +++--
 board/eukrea/cpu9260/cpu9260.c     |    5 +++--
 board/ronetix/pm9261/pm9261.c      |    5 +++--
 board/ronetix/pm9263/pm9263.c      |    5 +++--
 board/ronetix/pm9g45/pm9g45.c      |    5 +++--
 drivers/mtd/nand/atmel_nand.c      |    8 +++-----
 include/configs/at91sam9n12ek.h    |    4 ++--
 include/configs/cpu9260.h          |    4 ++--
Quoted 9 lines
 include/configs/ethernut5.h        |    2 +-
 include/configs/meesc.h            |    4 ++--
 include/configs/otc570.h           |    4 ++--
 include/configs/pm9261.h           |    4 ++--
 include/configs/pm9263.h           |    4 ++--
 include/configs/pm9g45.h           |    4 ++--
 include/configs/vl_ma2sc.h         |    4 ++--
 18 files changed, 43 insertions(+), 37 deletions(-)

I have successfully tested this patch for vl_ma2sc board

#17 lore raw

PATCH 3/4 at91: nand: switch atmel_nand to generic GPIO API

In reply to Andreas Bießmann
Quoted 13 lines · Andreas Bie?mann
---
 board/BuS/vl_ma2sc/vl_ma2sc.c      |    5 +++--
 board/egnite/ethernut5/ethernut5.c |    3 ++-
 board/esd/meesc/meesc.c            |    5 +++--
 board/esd/otc570/otc570.c          |    5 +++--
 board/eukrea/cpu9260/cpu9260.c     |    5 +++--
 board/ronetix/pm9261/pm9261.c      |    5 +++--
 board/ronetix/pm9263/pm9263.c      |    5 +++--
 board/ronetix/pm9g45/pm9g45.c      |    5 +++--
 drivers/mtd/nand/atmel_nand.c      |    8 +++-----
 include/configs/at91sam9n12ek.h    |    4 ++--
 include/configs/cpu9260.h          |    4 ++--
Quoted 8 lines
 include/configs/ethernut5.h        |    2 +-
 include/configs/meesc.h            |    4 ++--
 include/configs/otc570.h           |    4 ++--
 include/configs/pm9261.h           |    4 ++--
 include/configs/pm9263.h           |    4 ++--
 include/configs/pm9g45.h           |    4 ++--
 include/configs/vl_ma2sc.h         |    4 ++--
 18 files changed, 43 insertions(+), 37 deletions(-)

-Scott

#18 lore raw

PATCH 3/4 at91: nand: switch atmel_nand to generic GPIO API

In reply to Andreas Bießmann

Dear Andreas Devel,

Quoted 17 lines · Andreas Devel

---

board/BuS/vl_ma2sc/vl_ma2sc.c      |    5 +++--
board/egnite/ethernut5/ethernut5.c |    3 ++-
board/esd/meesc/meesc.c            |    5 +++--
board/esd/otc570/otc570.c          |    5 +++--
board/eukrea/cpu9260/cpu9260.c     |    5 +++--
board/ronetix/pm9261/pm9261.c      |    5 +++--
board/ronetix/pm9263/pm9263.c      |    5 +++--
board/ronetix/pm9g45/pm9g45.c      |    5 +++--
drivers/mtd/nand/atmel_nand.c      |    8 +++-----
include/configs/at91sam9n12ek.h    |    4 ++--
include/configs/cpu9260.h          |    4 ++--
Quoted 8 lines
include/configs/ethernut5.h        |    2 +-
include/configs/meesc.h            |    4 ++--
include/configs/otc570.h           |    4 ++--
include/configs/pm9261.h           |    4 ++--
include/configs/pm9263.h           |    4 ++--
include/configs/pm9g45.h           |    4 ++--
include/configs/vl_ma2sc.h         |    4 ++--
18 files changed, 43 insertions(+), 37 deletions(-)

applied to u-boot-atmel/master, thanks!

Best regards,
Andreas Bie?mann

#19 lore raw

PATCH 4/4 at91: switch coloured LED to gpio API

In reply to Andreas Bießmann
---
 arch/arm/cpu/arm926ejs/at91/led.c |   16 +++++++---------
 board/ronetix/pm9261/led.c        |   14 +++++++-------
 board/ronetix/pm9263/led.c        |   10 +++++-----
 include/configs/pm9261.h          |    6 +++---
 include/configs/pm9263.h          |    4 ++--
 include/configs/pm9g45.h          |    4 ++--
 6 files changed, 26 insertions(+), 28 deletions(-)
arch/arm/cpu/arm926ejs/at91/led.c +7 -9
index 5dd9048..46ed055 100644
@@ -7,43 +7,41 @@
  */
 
 #include <common.h>
-#include <asm/io.h>
-#include <asm/arch/at91_pmc.h>
-#include <asm/arch/at91_pio.h>
+#include <asm/gpio.h>
 #include <asm/arch/gpio.h>
 
 #ifdef CONFIG_RED_LED
 void red_led_on(void)
 {
-	at91_set_gpio_value(CONFIG_RED_LED, 1);
+	gpio_set_value(CONFIG_RED_LED, 1);
 }
 
 void red_led_off(void)
 {
-	at91_set_gpio_value(CONFIG_RED_LED, 0);
+	gpio_set_value(CONFIG_RED_LED, 0);
 }
 #endif
 
 #ifdef CONFIG_GREEN_LED
 void green_led_on(void)
 {
-	at91_set_gpio_value(CONFIG_GREEN_LED, 0);
+	gpio_set_value(CONFIG_GREEN_LED, 0);
 }
 
 void green_led_off(void)
 {
-	at91_set_gpio_value(CONFIG_GREEN_LED, 1);
+	gpio_set_value(CONFIG_GREEN_LED, 1);
 }
 #endif
 
 #ifdef CONFIG_YELLOW_LED
 void yellow_led_on(void)
 {
-	at91_set_gpio_value(CONFIG_YELLOW_LED, 0);
+	gpio_set_value(CONFIG_YELLOW_LED, 0);
 }
 
 void yellow_led_off(void)
 {
-	at91_set_gpio_value(CONFIG_YELLOW_LED, 1);
+	gpio_set_value(CONFIG_YELLOW_LED, 1);
 }
 #endif
board/ronetix/pm9261/led.c +7 -7
index 223a516..cc4c2a0 100644
@@ -8,9 +8,9 @@
  */
 
 #include <common.h>
+#include <asm/gpio.h>
 #include <asm/arch/at91_pmc.h>
 #include <asm/arch/gpio.h>
-#include <asm/io.h>
 
 void coloured_LED_init(void)
 {
@@ -19,11 +19,11 @@ void coloured_LED_init(void)
 	/* Enable clock */
 	writel(1 << ATMEL_ID_PIOC, &pmc->pcer);
 
-	at91_set_pio_output(CONFIG_RED_LED, 1);
-	at91_set_pio_output(CONFIG_GREEN_LED, 1);
-	at91_set_pio_output(CONFIG_YELLOW_LED, 1);
+	gpio_direction_output(CONFIG_RED_LED, 1);
+	gpio_direction_output(CONFIG_GREEN_LED, 1);
+	gpio_direction_output(CONFIG_YELLOW_LED, 1);
 
-	at91_set_pio_value(CONFIG_RED_LED, 0);
-	at91_set_pio_value(CONFIG_GREEN_LED, 1);
-	at91_set_pio_value(CONFIG_YELLOW_LED, 1);
+	gpio_set_value(CONFIG_RED_LED, 0);
+	gpio_set_value(CONFIG_GREEN_LED, 1);
+	gpio_set_value(CONFIG_YELLOW_LED, 1);
 }
board/ronetix/pm9263/led.c +5 -5
index 44e3430..bfc2310 100644
@@ -8,9 +8,9 @@
  */
 
 #include <common.h>
+#include <asm/gpio.h>
 #include <asm/arch/at91_pmc.h>
 #include <asm/arch/gpio.h>
-#include <asm/io.h>
 
 void coloured_LED_init(void)
 {
@@ -19,9 +19,9 @@ void coloured_LED_init(void)
 	/* Enable clock */
 	writel(1 << ATMEL_ID_PIOB, &pmc->pcer);
 
-	at91_set_pio_output(CONFIG_RED_LED, 1);
-	at91_set_pio_output(CONFIG_GREEN_LED, 1);
+	gpio_direction_output(CONFIG_RED_LED, 1);
+	gpio_direction_output(CONFIG_GREEN_LED, 1);
 
-	at91_set_pio_value(CONFIG_RED_LED, 0);
-	at91_set_pio_value(CONFIG_GREEN_LED, 1);
+	gpio_set_value(CONFIG_RED_LED, 0);
+	gpio_set_value(CONFIG_GREEN_LED, 1);
 }
include/configs/pm9261.h +3 -3
index 9442d8f..0f3cfba 100644
@@ -166,9 +166,9 @@
 
 /* LED */
 #define CONFIG_AT91_LED
-#define	CONFIG_RED_LED		AT91_PIO_PORTC, 12
-#define	CONFIG_GREEN_LED	AT91_PIO_PORTC, 13
-#define	CONFIG_YELLOW_LED	AT91_PIO_PORTC, 15
+#define CONFIG_RED_LED		GPIO_PIN_PC(12)
+#define CONFIG_GREEN_LED	GPIO_PIN_PC(13)
+#define CONFIG_YELLOW_LED	GPIO_PIN_PC(15)
 
 #define CONFIG_BOOTDELAY	3
 
include/configs/pm9263.h +2 -2
index dffc336..d9c04d1 100644
@@ -179,8 +179,8 @@
 
 /* LED */
 #define CONFIG_AT91_LED
-#define	CONFIG_RED_LED		AT91_PIO_PORTB, 7	/* this is the power led */
-#define	CONFIG_GREEN_LED	AT91_PIO_PORTB, 8	/* this is the user1 led */
+#define CONFIG_RED_LED		GPIO_PIN_PB(7) /* this is the power led */
+#define CONFIG_GREEN_LED	GPIO_PIN_PB(8) /* this is the user1 led */
 
 #define CONFIG_BOOTDELAY	3
 
include/configs/pm9g45.h +2 -2
index 03a25c8..f78e0ec 100644
@@ -54,8 +54,8 @@
 
 /* LED */
 #define CONFIG_AT91_LED
-#define	CONFIG_RED_LED		AT91_PIO_PORTD, 31 /* this is the user1 led */
-#define	CONFIG_GREEN_LED	AT91_PIO_PORTD, 0 /* this is the user2 led */
+#define CONFIG_RED_LED		GPIO_PIN_PD(31) /* this is the user1 led */
+#define CONFIG_GREEN_LED	GPIO_PIN_PD(0)  /* this is the user2 led */
 
 #define CONFIG_BOOTDELAY	3
 
Signature · 1 line
1.7.10.4
#20 lore raw

PATCH 4/4 at91: switch coloured LED to gpio API

Dear Andreas Devel,

Quoted 10 lines · Andreas Devel

---

arch/arm/cpu/arm926ejs/at91/led.c |   16 +++++++---------
board/ronetix/pm9261/led.c        |   14 +++++++-------
board/ronetix/pm9263/led.c        |   10 +++++-----
include/configs/pm9261.h          |    6 +++---
include/configs/pm9263.h          |    4 ++--
include/configs/pm9g45.h          |    4 ++--
6 files changed, 26 insertions(+), 28 deletions(-)

applied to u-boot-atmel/master, thanks!

Best regards,
Andreas Bie?mann