summaryrefslogtreecommitdiff
path: root/cpu/mcf52x2/serial.c
diff options
context:
space:
mode:
authorMarian Balakowicz <m8@semihalf.com>2006-05-09 11:37:13 +0200
committerMarian Balakowicz <m8@semihalf.com>2006-05-09 11:37:13 +0200
commit0c056f0e274b83fb98b6a562b124709f8fe26c11 (patch)
tree84a002a372f396649cf26a3d79685dae25eff323 /cpu/mcf52x2/serial.c
parent483a0cf804dfc2b320fc32c7de77d23502dadfd5 (diff)
downloadu-boot-imx-0c056f0e274b83fb98b6a562b124709f8fe26c11.zip
u-boot-imx-0c056f0e274b83fb98b6a562b124709f8fe26c11.tar.gz
u-boot-imx-0c056f0e274b83fb98b6a562b124709f8fe26c11.tar.bz2
Fix serial console support for MCF5271.
Diffstat (limited to 'cpu/mcf52x2/serial.c')
-rw-r--r--cpu/mcf52x2/serial.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/cpu/mcf52x2/serial.c b/cpu/mcf52x2/serial.c
index 8fbfad4..1cde1b6 100644
--- a/cpu/mcf52x2/serial.c
+++ b/cpu/mcf52x2/serial.c
@@ -44,7 +44,7 @@
DECLARE_GLOBAL_DATA_PTR;
-#ifdef CONFIG_M5249
+#if defined(CONFIG_M5249) || defined(CONFIG_M5271)
#define DoubleClock(a) ((double)(CFG_CLK/2) / 32.0 / (double)(a))
#else
#define DoubleClock(a) ((double)(CFG_CLK) / 32.0 / (double)(a))
@@ -54,7 +54,10 @@ void rs_serial_setbaudrate(int port,int baudrate)
{
#if defined(CONFIG_M5272) || defined(CONFIG_M5249) || defined(CONFIG_M5271)
volatile unsigned char *uartp;
- double clock, fraction;
+#ifndef CONFIG_M5271
+ double fraction;
+#endif
+ double clock;
if (port == 0)
uartp = (volatile unsigned char *) (CFG_MBAR + MCFUART_BASE1);
@@ -63,11 +66,11 @@ void rs_serial_setbaudrate(int port,int baudrate)
clock = DoubleClock(baudrate); /* Set baud above */
- fraction = ((clock - (int)clock) * 16.0) + 0.5;
-
uartp[MCFUART_UBG1] = (((int)clock >> 8) & 0xff); /* set msb baud */
uartp[MCFUART_UBG2] = ((int)clock & 0xff); /* set lsb baud */
+
#ifndef CONFIG_M5271
+ fraction = ((clock - (int)clock) * 16.0) + 0.5;
uartp[MCFUART_UFPD] = ((int)fraction & 0xf); /* set baud fraction adjust */
#endif
#endif
@@ -85,8 +88,9 @@ void rs_serial_init(int port,int baudrate)
else
uartp = (volatile unsigned char *) (CFG_MBAR + MCFUART_BASE2);
- uartp[MCFUART_UCR] = MCFUART_UCR_CMDRESETRX; /* reset RX */
uartp[MCFUART_UCR] = MCFUART_UCR_CMDRESETTX; /* reset TX */
+ uartp[MCFUART_UCR] = MCFUART_UCR_CMDRESETRX; /* reset RX */
+
uartp[MCFUART_UCR] = MCFUART_UCR_CMDRESETMRPTR; /* reset MR pointer */
uartp[MCFUART_UCR] = MCFUART_UCR_CMDRESETERR; /* reset Error pointer */
@@ -96,9 +100,15 @@ void rs_serial_init(int port,int baudrate)
uartp[MCFUART_UMR] = MCFUART_MR1_PARITYNONE | MCFUART_MR1_CS8;
uartp[MCFUART_UMR] = MCFUART_MR2_STOP1;
- rs_serial_setbaudrate(port,baudrate);
+ /* Mask UART interrupts */
+ uartp[MCFUART_UIMR] = 0;
+ /* Set clock Select Register: Tx/Rx clock is timer */
uartp[MCFUART_UCSR] = MCFUART_UCSR_RXCLKTIMER | MCFUART_UCSR_TXCLKTIMER;
+
+ rs_serial_setbaudrate(port,baudrate);
+
+ /* Enable Tx/Rx */
uartp[MCFUART_UCR] = MCFUART_UCR_RXENABLE | MCFUART_UCR_TXENABLE;
return;