diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpio/at91_gpio.c | 52 | ||||
-rw-r--r-- | drivers/rtc/at91sam9_rtt.c | 12 | ||||
-rw-r--r-- | drivers/usb/host/ohci-at91.c | 16 | ||||
-rw-r--r-- | drivers/watchdog/at91sam9_wdt.c | 4 |
4 files changed, 47 insertions, 37 deletions
diff --git a/drivers/gpio/at91_gpio.c b/drivers/gpio/at91_gpio.c index c0a97bc..1631687 100644 --- a/drivers/gpio/at91_gpio.c +++ b/drivers/gpio/at91_gpio.c @@ -24,6 +24,16 @@ * 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> @@ -33,10 +43,10 @@ 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; } diff --git a/drivers/rtc/at91sam9_rtt.c b/drivers/rtc/at91sam9_rtt.c index de8e30d..ed44016 100644 --- a/drivers/rtc/at91sam9_rtt.c +++ b/drivers/rtc/at91sam9_rtt.c @@ -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); diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c index 64fde68..6166899 100644 --- a/drivers/usb/host/ohci-at91.c +++ b/drivers/usb/host/ohci-at91.c @@ -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) || \ diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c index 25afae7..6254765 100644 --- a/drivers/watchdog/at91sam9_wdt.c +++ b/drivers/watchdog/at91sam9_wdt.c @@ -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); } |