summaryrefslogtreecommitdiff
path: root/drivers/serial/atmel_usart.c
diff options
context:
space:
mode:
authorReinhard Meyer <u-boot@emk-elektronik.de>2010-11-03 16:32:56 +0100
committerAlbert ARIBAUD <albert.u.boot@aribaud.net>2011-05-18 07:56:51 +0200
commit329f0f52fa9fa572b0edbc8dfc34698dbe8efb6a (patch)
treeff13bc9ee5b1061823e33a57539a5214a43229a5 /drivers/serial/atmel_usart.c
parent372f2783a7b111f567ca541194bc7a75a3d5d64a (diff)
downloadu-boot-imx-329f0f52fa9fa572b0edbc8dfc34698dbe8efb6a.zip
u-boot-imx-329f0f52fa9fa572b0edbc8dfc34698dbe8efb6a.tar.gz
u-boot-imx-329f0f52fa9fa572b0edbc8dfc34698dbe8efb6a.tar.bz2
ATMEL: fix related common atmel driver files
Signed-off-by: Reinhard Meyer <u-boot@emk-elektronik.de>
Diffstat (limited to 'drivers/serial/atmel_usart.c')
-rw-r--r--drivers/serial/atmel_usart.c28
1 files changed, 7 insertions, 21 deletions
diff --git a/drivers/serial/atmel_usart.c b/drivers/serial/atmel_usart.c
index bfa1f3a..e326b2b 100644
--- a/drivers/serial/atmel_usart.c
+++ b/drivers/serial/atmel_usart.c
@@ -23,21 +23,7 @@
#include <asm/io.h>
#include <asm/arch/clk.h>
-#include <asm/arch/memory-map.h>
-
-#if defined(CONFIG_USART0)
-# define USART_ID 0
-# define USART_BASE USART0_BASE
-#elif defined(CONFIG_USART1)
-# define USART_ID 1
-# define USART_BASE USART1_BASE
-#elif defined(CONFIG_USART2)
-# define USART_ID 2
-# define USART_BASE USART2_BASE
-#elif defined(CONFIG_USART3)
-# define USART_ID 3
-# define USART_BASE USART3_BASE
-#endif
+#include <asm/arch/hardware.h>
#include "atmel_usart.h"
@@ -45,7 +31,7 @@ DECLARE_GLOBAL_DATA_PTR;
void serial_setbrg(void)
{
- atmel_usart3_t *usart = (atmel_usart3_t*)USART_BASE;
+ atmel_usart3_t *usart = (atmel_usart3_t *)CONFIG_USART_BASE;
unsigned long divisor;
unsigned long usart_hz;
@@ -54,14 +40,14 @@ void serial_setbrg(void)
* Baud Rate = --------------
* 16 * CD
*/
- usart_hz = get_usart_clk_rate(USART_ID);
+ usart_hz = get_usart_clk_rate(CONFIG_USART_ID);
divisor = (usart_hz / 16 + gd->baudrate / 2) / gd->baudrate;
writel(USART3_BF(CD, divisor), &usart->brgr);
}
int serial_init(void)
{
- atmel_usart3_t *usart = (atmel_usart3_t*)USART_BASE;
+ atmel_usart3_t *usart = (atmel_usart3_t *)CONFIG_USART_BASE;
writel(USART3_BIT(RSTRX) | USART3_BIT(RSTTX), &usart->cr);
@@ -80,7 +66,7 @@ int serial_init(void)
void serial_putc(char c)
{
- atmel_usart3_t *usart = (atmel_usart3_t*)USART_BASE;
+ atmel_usart3_t *usart = (atmel_usart3_t *)CONFIG_USART_BASE;
if (c == '\n')
serial_putc('\r');
@@ -97,7 +83,7 @@ void serial_puts(const char *s)
int serial_getc(void)
{
- atmel_usart3_t *usart = (atmel_usart3_t*)USART_BASE;
+ atmel_usart3_t *usart = (atmel_usart3_t *)CONFIG_USART_BASE;
while (!(readl(&usart->csr) & USART3_BIT(RXRDY)))
WATCHDOG_RESET();
@@ -106,6 +92,6 @@ int serial_getc(void)
int serial_tstc(void)
{
- atmel_usart3_t *usart = (atmel_usart3_t*)USART_BASE;
+ atmel_usart3_t *usart = (atmel_usart3_t *)CONFIG_USART_BASE;
return (readl(&usart->csr) & USART3_BIT(RXRDY)) != 0;
}