]> git.sur5r.net Git - u-boot/blobdiff - board/atmel/at91rm9200ek/led.c
at91rm9200ek: convert to at91
[u-boot] / board / atmel / at91rm9200ek / led.c
index 9464952211baf5128b5dd21e3863cea3b86a0d7b..8d512e0329ce05ef7b6460fad4d3245ebab9b2da 100644 (file)
@@ -3,6 +3,9 @@
  * Atmel Nordic AB <www.atmel.com>
  * Ulf Samuelsson <ulf@atmel.com>
  *
+ * (C) Copyright 2010
+ * Andreas Bießmann <andreas.devel@gmail.com>
+ *
  * See file CREDITS for list of people who contributed to this
  * project.
  *
  */
 
 #include <common.h>
-#include <asm/arch/AT91RM9200.h>
-#include <asm/io.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/at91_pmc.h>
 
-#define        GREEN_LED       AT91C_PIO_PB0
-#define        YELLOW_LED      AT91C_PIO_PB1
-#define        RED_LED         AT91C_PIO_PB2
+/* bit mask in PIO port B */
+#define        GREEN_LED       (1<<0)
+#define        YELLOW_LED      (1<<1)
+#define        RED_LED         (1<<2)
 
 void   green_LED_on(void)
 {
-       AT91PS_PIO      PIOB    = AT91C_BASE_PIOB;
-
-       writel(GREEN_LED, PIOB->PIO_CODR);
+       at91_pio_t *pio = (at91_pio_t *)AT91_PIO_BASE;
+       writel(GREEN_LED, &pio->piob.codr);
 }
 
 void    yellow_LED_on(void)
 {
-       AT91PS_PIO      PIOB    = AT91C_BASE_PIOB;
-
-       writel(YELLOW_LED, PIOB->PIO_CODR);
+       at91_pio_t *pio = (at91_pio_t *)AT91_PIO_BASE;
+       writel(YELLOW_LED, &pio->piob.codr);
 }
 
 void    red_LED_on(void)
 {
-       AT91PS_PIO      PIOB    = AT91C_BASE_PIOB;
-
-       writel(RED_LED, PIOB->PIO_CODR);
+       at91_pio_t *pio = (at91_pio_t *)AT91_PIO_BASE;
+       writel(RED_LED, &pio->piob.codr);
 }
 
 void   green_LED_off(void)
 {
-       AT91PS_PIO      PIOB    = AT91C_BASE_PIOB;
-
-       writel(GREEN_LED, PIOB->PIO_SODR);
+       at91_pio_t *pio = (at91_pio_t *)AT91_PIO_BASE;
+       writel(GREEN_LED, &pio->piob.sodr);
 }
 
 void   yellow_LED_off(void)
 {
-       AT91PS_PIO      PIOB    = AT91C_BASE_PIOB;
-
-       writel(YELLOW_LED, PIOB->PIO_SODR);
+       at91_pio_t *pio = (at91_pio_t *)AT91_PIO_BASE;
+       writel(YELLOW_LED, &pio->piob.sodr);
 }
 
 void   red_LED_off(void)
 {
-       AT91PS_PIO      PIOB    = AT91C_BASE_PIOB;
-
-       writel(RED_LED, PIOB->PIO_SODR);
+       at91_pio_t *pio = (at91_pio_t *)AT91_PIO_BASE;
+       writel(RED_LED, &pio->piob.sodr);
 }
 
-
 void coloured_LED_init (void)
 {
-       AT91PS_PIO      PIOB    = AT91C_BASE_PIOB;
-       AT91PS_PMC      PMC     = AT91C_BASE_PMC;
+       at91_pmc_t *pmc = (at91_pmc_t *)AT91_PMC_BASE;
+       at91_pio_t *pio = (at91_pio_t *)AT91_PIO_BASE;
 
        /* Enable PIOB clock */
-       writel((1 << AT91C_ID_PIOB), PMC->PMC_PCER);
+       writel(1 << AT91_ID_PIOB, &pmc->pcer);
+
        /* Disable peripherals on LEDs */
-       writel(AT91C_PIO_PB2 | AT91C_PIO_PB1 | AT91C_PIO_PB0, PIOB->PIO_PER);
+       writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.per);
        /* Enable pins as outputs */
-       writel(AT91C_PIO_PB2 | AT91C_PIO_PB1 | AT91C_PIO_PB0, PIOB->PIO_OER);
+       writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.oer);
        /* Turn all LEDs OFF */
-       writel(AT91C_PIO_PB2 | AT91C_PIO_PB1 | AT91C_PIO_PB0, PIOB->PIO_SODR);
+       writel(GREEN_LED | YELLOW_LED | RED_LED, &pio->piob.sodr);
 }