]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
AT91: fix related at91 driver files
authorReinhard Meyer <u-boot@emk-elektronik.de>
Wed, 3 Nov 2010 14:47:20 +0000 (15:47 +0100)
committerAlbert ARIBAUD <albert.u.boot@aribaud.net>
Wed, 18 May 2011 05:56:51 +0000 (07:56 +0200)
Signed-off-by: Reinhard Meyer <u-boot@emk-elektronik.de>
drivers/gpio/at91_gpio.c
drivers/rtc/at91sam9_rtt.c
drivers/usb/host/ohci-at91.c
drivers/watchdog/at91sam9_wdt.c

index c0a97bc5dad7722fd4fb4e36e8a7d1108f3e7966..1631687186b797fe171c7fbc05142a95f7013434 100644 (file)
  * MA 02111-1307 USA
  */
 
+/*
+ * WARNING:
+ *
+ * As the code is right now, it expects all PIO ports A,B,C,...
+ * to be evenly spaced in the memory map:
+ * ATMEL_BASE_PIOA + port * sizeof at91pio_t
+ * This might not necessaryly be true in future Atmel SoCs.
+ * This code should be fixed to use a pointer array to the ports.
+ */
+
 #include <config.h>
 #include <common.h>
 #include <asm/sizes.h>
 
 int at91_set_pio_pullup(unsigned port, unsigned pin, int use_pullup)
 {
-       at91_pio_t      *pio    = (at91_pio_t *) AT91_PIO_BASE;
+       at91_pio_t      *pio = (at91_pio_t *) ATMEL_BASE_PIOA;
        u32             mask;
 
-       if ((port < AT91_PIO_PORTS) && (pin < 32)) {
+       if ((port < ATMEL_PIO_PORTS) && (pin < 32)) {
                mask = 1 << pin;
                if (use_pullup)
                        writel(1 << pin, &pio->port[port].puer);
@@ -52,10 +62,10 @@ int at91_set_pio_pullup(unsigned port, unsigned pin, int use_pullup)
  */
 int at91_set_pio_periph(unsigned port, unsigned pin, int use_pullup)
 {
-       at91_pio_t      *pio    = (at91_pio_t *) AT91_PIO_BASE;
+       at91_pio_t      *pio = (at91_pio_t *) ATMEL_BASE_PIOA;
        u32             mask;
 
-       if ((port < AT91_PIO_PORTS) && (pin < 32)) {
+       if ((port < ATMEL_PIO_PORTS) && (pin < 32)) {
                mask = 1 << pin;
                writel(mask, &pio->port[port].idr);
                at91_set_pio_pullup(port, pin, use_pullup);
@@ -69,10 +79,10 @@ int at91_set_pio_periph(unsigned port, unsigned pin, int use_pullup)
  */
 int at91_set_a_periph(unsigned port, unsigned pin, int use_pullup)
 {
-       at91_pio_t      *pio    = (at91_pio_t *) AT91_PIO_BASE;
+       at91_pio_t      *pio = (at91_pio_t *) ATMEL_BASE_PIOA;
        u32             mask;
 
-       if ((port < AT91_PIO_PORTS) && (pin < 32)) {
+       if ((port < ATMEL_PIO_PORTS) && (pin < 32)) {
                mask = 1 << pin;
                writel(mask, &pio->port[port].idr);
                at91_set_pio_pullup(port, pin, use_pullup);
@@ -87,10 +97,10 @@ int at91_set_a_periph(unsigned port, unsigned pin, int use_pullup)
  */
 int at91_set_b_periph(unsigned port, unsigned pin, int use_pullup)
 {
-       at91_pio_t      *pio    = (at91_pio_t *) AT91_PIO_BASE;
+       at91_pio_t      *pio = (at91_pio_t *) ATMEL_BASE_PIOA;
        u32             mask;
 
-       if ((port < AT91_PIO_PORTS) && (pin < 32)) {
+       if ((port < ATMEL_PIO_PORTS) && (pin < 32)) {
                mask = 1 << pin;
                writel(mask, &pio->port[port].idr);
                at91_set_pio_pullup(port, pin, use_pullup);
@@ -106,10 +116,10 @@ int at91_set_b_periph(unsigned port, unsigned pin, int use_pullup)
  */
 int at91_set_pio_input(unsigned port, u32 pin, int use_pullup)
 {
-       at91_pio_t      *pio    = (at91_pio_t *) AT91_PIO_BASE;
+       at91_pio_t      *pio = (at91_pio_t *) ATMEL_BASE_PIOA;
        u32             mask;
 
-       if ((port < AT91_PIO_PORTS) && (pin < 32)) {
+       if ((port < ATMEL_PIO_PORTS) && (pin < 32)) {
                mask = 1 << pin;
                writel(mask, &pio->port[port].idr);
                at91_set_pio_pullup(port, pin, use_pullup);
@@ -125,10 +135,10 @@ int at91_set_pio_input(unsigned port, u32 pin, int use_pullup)
  */
 int at91_set_pio_output(unsigned port, u32 pin, int value)
 {
-       at91_pio_t      *pio    = (at91_pio_t *) AT91_PIO_BASE;
+       at91_pio_t      *pio = (at91_pio_t *) ATMEL_BASE_PIOA;
        u32             mask;
 
-       if ((port < AT91_PIO_PORTS) && (pin < 32)) {
+       if ((port < ATMEL_PIO_PORTS) && (pin < 32)) {
                mask = 1 << pin;
                writel(mask, &pio->port[port].idr);
                writel(mask, &pio->port[port].pudr);
@@ -147,10 +157,10 @@ int at91_set_pio_output(unsigned port, u32 pin, int value)
  */
 int at91_set_pio_deglitch(unsigned port, unsigned pin, int is_on)
 {
-       at91_pio_t      *pio    = (at91_pio_t *) AT91_PIO_BASE;
+       at91_pio_t      *pio = (at91_pio_t *) ATMEL_BASE_PIOA;
        u32             mask;
 
-       if ((port < AT91_PIO_PORTS) && (pin < 32)) {
+       if ((port < ATMEL_PIO_PORTS) && (pin < 32)) {
                mask = 1 << pin;
                if (is_on)
                        writel(mask, &pio->port[port].ifer);
@@ -166,10 +176,10 @@ int at91_set_pio_deglitch(unsigned port, unsigned pin, int is_on)
  */
 int at91_set_pio_multi_drive(unsigned port, unsigned pin, int is_on)
 {
-       at91_pio_t      *pio    = (at91_pio_t *) AT91_PIO_BASE;
+       at91_pio_t      *pio = (at91_pio_t *) ATMEL_BASE_PIOA;
        u32             mask;
 
-       if ((port < AT91_PIO_PORTS) && (pin < 32)) {
+       if ((port < ATMEL_PIO_PORTS) && (pin < 32)) {
                mask = 1 << pin;
                if (is_on)
                        writel(mask, &pio->port[port].mder);
@@ -184,10 +194,10 @@ int at91_set_pio_multi_drive(unsigned port, unsigned pin, int is_on)
  */
 int at91_set_pio_value(unsigned port, unsigned pin, int value)
 {
-       at91_pio_t      *pio    = (at91_pio_t *) AT91_PIO_BASE;
+       at91_pio_t      *pio = (at91_pio_t *) ATMEL_BASE_PIOA;
        u32             mask;
 
-       if ((port < AT91_PIO_PORTS) && (pin < 32)) {
+       if ((port < ATMEL_PIO_PORTS) && (pin < 32)) {
                mask = 1 << pin;
                if (value)
                        writel(mask, &pio->port[port].sodr);
@@ -202,11 +212,11 @@ int at91_set_pio_value(unsigned port, unsigned pin, int value)
  */
 int at91_get_pio_value(unsigned port, unsigned pin)
 {
-       u32             pdsr    = 0;
-       at91_pio_t      *pio    = (at91_pio_t *) AT91_PIO_BASE;
+       u32             pdsr = 0;
+       at91_pio_t      *pio = (at91_pio_t *) ATMEL_BASE_PIOA;
        u32             mask;
 
-       if ((port < AT91_PIO_PORTS) && (pin < 32)) {
+       if ((port < ATMEL_PIO_PORTS) && (pin < 32)) {
                mask = 1 << pin;
                pdsr = readl(&pio->port[port].pdsr) & mask;
        }
index de8e30d0d7ca6969fba033ea1cc0851a30effaec..ed44016078fc14115f40f254f3ea856d75508f66 100644 (file)
@@ -48,8 +48,8 @@
 
 int rtc_get (struct rtc_time *tmp)
 {
-       at91_rtt_t *rtt = (at91_rtt_t *) AT91_RTT_BASE;
-       at91_gpbr_t *gpbr = (at91_gpbr_t *) AT91_GPR_BASE;
+       at91_rtt_t *rtt = (at91_rtt_t *) ATMEL_BASE_RTT;
+       at91_gpbr_t *gpbr = (at91_gpbr_t *) ATMEL_BASE_GPBR;
        ulong tim;
        ulong tim2;
        ulong off;
@@ -66,8 +66,8 @@ int rtc_get (struct rtc_time *tmp)
 
 int rtc_set (struct rtc_time *tmp)
 {
-       at91_rtt_t *rtt = (at91_rtt_t *) AT91_RTT_BASE;
-       at91_gpbr_t *gpbr = (at91_gpbr_t *) AT91_GPR_BASE;
+       at91_rtt_t *rtt = (at91_rtt_t *) ATMEL_BASE_RTT;
+       at91_gpbr_t *gpbr = (at91_gpbr_t *) ATMEL_BASE_GPBR;
        ulong tim;
 
        tim = mktime (tmp->tm_year, tmp->tm_mon, tmp->tm_mday,
@@ -85,8 +85,8 @@ int rtc_set (struct rtc_time *tmp)
 
 void rtc_reset (void)
 {
-       at91_rtt_t *rtt = (at91_rtt_t *) AT91_RTT_BASE;
-       at91_gpbr_t *gpbr = (at91_gpbr_t *) AT91_GPR_BASE;
+       at91_rtt_t *rtt = (at91_rtt_t *) ATMEL_BASE_RTT;
+       at91_gpbr_t *gpbr = (at91_gpbr_t *) ATMEL_BASE_GPBR;
 
        /* clear alarm, set prescaler to 32768, clear counter */
        writel(32768+AT91_RTT_RTTRST, &rtt->mr);
index 64fde68ff59c077749084914a959d6000bfee723..6166899432b3a8506dd21ea1ded709eca7d0d457 100644 (file)
@@ -32,7 +32,7 @@
 
 int usb_cpu_init(void)
 {
-       at91_pmc_t *pmc = (at91_pmc_t *)AT91_PMC_BASE;
+       at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
 
 #if defined(CONFIG_AT91CAP9) || defined(CONFIG_AT91SAM9260) || \
     defined(CONFIG_AT91SAM9263) || defined(CONFIG_AT91SAM9G20) || \
@@ -53,11 +53,11 @@ int usb_cpu_init(void)
 #endif
 
        /* Enable USB host clock. */
-       writel(1 << AT91_ID_UHP, &pmc->pcer);
+       writel(1 << ATMEL_ID_UHP, &pmc->pcer);
 #ifdef CONFIG_AT91SAM9261
-       writel(AT91_PMC_UHP | AT91_PMC_HCK0, &pmc->scer);
+       writel(ATMEL_PMC_UHP | AT91_PMC_HCK0, &pmc->scer);
 #else
-       writel(AT91_PMC_UHP, &pmc->scer);
+       writel(ATMEL_PMC_UHP, &pmc->scer);
 #endif
 
        return 0;
@@ -65,14 +65,14 @@ int usb_cpu_init(void)
 
 int usb_cpu_stop(void)
 {
-       at91_pmc_t *pmc = (at91_pmc_t *)AT91_PMC_BASE;
+       at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
 
        /* Disable USB host clock. */
-       writel(1 << AT91_ID_UHP, &pmc->pcdr);
+       writel(1 << ATMEL_ID_UHP, &pmc->pcdr);
 #ifdef CONFIG_AT91SAM9261
-       writel(AT91_PMC_UHP | AT91_PMC_HCK0, &pmc->scdr);
+       writel(ATMEL_PMC_UHP | AT91_PMC_HCK0, &pmc->scdr);
 #else
-       writel(AT91_PMC_UHP, &pmc->scdr);
+       writel(ATMEL_PMC_UHP, &pmc->scdr);
 #endif
 
 #if defined(CONFIG_AT91CAP9) || defined(CONFIG_AT91SAM9260) || \
index 25afae748d611cdb47123899ed2d693b1de279ad..62547651a5f7b29d958d9bc9b617a5dec31496f0 100644 (file)
@@ -42,7 +42,7 @@
 static int at91_wdt_settimeout(unsigned int timeout)
 {
        unsigned int reg;
-       at91_wdt_t *wd  = (at91_wdt_t *) AT91_WDT_BASE;
+       at91_wdt_t *wd = (at91_wdt_t *) ATMEL_BASE_WDT;
 
        /* Check if disabled */
        if (readl(&wd->mr) & AT91_WDT_MR_WDDIS) {
@@ -69,7 +69,7 @@ static int at91_wdt_settimeout(unsigned int timeout)
 
 void hw_watchdog_reset(void)
 {
-       at91_wdt_t *wd  = (at91_wdt_t *) AT91_WDT_BASE;
+       at91_wdt_t *wd = (at91_wdt_t *) ATMEL_BASE_WDT;
        writel(AT91_WDT_CR_WDRSTT | AT91_WDT_CR_KEY, &wd->cr);
 }