summaryrefslogtreecommitdiff
path: root/post/uart.c
diff options
context:
space:
mode:
authorwdenk <wdenk>2004-08-01 22:48:16 +0000
committerwdenk <wdenk>2004-08-01 22:48:16 +0000
commit281e00a3be453a169d854f824a460359d10f92bb (patch)
tree43dab398f1d6f601bb44df108427f7e0c611d68d /post/uart.c
parentcfca5e604d5692f081cc1a9185ca5dc6dc77599d (diff)
downloadu-boot-imx-281e00a3be453a169d854f824a460359d10f92bb.zip
u-boot-imx-281e00a3be453a169d854f824a460359d10f92bb.tar.gz
u-boot-imx-281e00a3be453a169d854f824a460359d10f92bb.tar.bz2
* Code cleanup
* Patch by Sascha Hauer, 28 Jun: - add generic support for Motorola i.MX architecture - add support for mx1ads, mx1fs2 and scb9328 boards * Patches by Marc Leeman, 23 Jul 2004: - Add define for the PCI/Memory Buffer Configuration Register - corrected comments in cpu/mpc824x/cpu_init.c * Add support for multiple serial interfaces (for example to allow modem dial-in / dial-out)
Diffstat (limited to 'post/uart.c')
-rw-r--r--post/uart.c53
1 files changed, 23 insertions, 30 deletions
diff --git a/post/uart.c b/post/uart.c
index f6936ca..23bf036 100644
--- a/post/uart.c
+++ b/post/uart.c
@@ -48,7 +48,7 @@
#error "Apparently a bad configuration, please fix."
#endif
#include <command.h>
-#include <net.h>
+#include <serial.h>
#define CTLR_SMC 0
#define CTLR_SCC 1
@@ -65,14 +65,13 @@ static int ctlr_list[][2] = { };
static struct {
void (*init) (int index);
+ void (*halt) (int index);
void (*putc) (int index, const char c);
int (*getc) (int index);
} ctlr_proc[2];
static char *ctlr_name[2] = { "SMC", "SCC" };
-static int used_by_uart[2] = { -1, -1 };
-
static int proff_smc[] = { PROFF_SMC1, PROFF_SMC2 };
static int proff_scc[] =
{ PROFF_SCC1, PROFF_SCC2, PROFF_SCC3, PROFF_SCC4 };
@@ -212,6 +211,10 @@ static void smc_init (int smc_index)
sp->smc_smcmr |= SMCMR_REN | SMCMR_TEN;
}
+static void smc_halt(int smc_index)
+{
+}
+
static void smc_putc (int smc_index, const char c)
{
volatile cbd_t *tbdf;
@@ -419,6 +422,15 @@ static void scc_init (int scc_index)
sp->scc_gsmrl |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT);
}
+static void scc_halt(int scc_index)
+{
+ volatile immap_t *im = (immap_t *) CFG_IMMR;
+ volatile cpm8xx_t *cp = &(im->im_cpm);
+ volatile scc_t *sp = (scc_t *) & (cp->cp_scc[scc_index]);
+
+ sp->scc_gsmrl &= ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT | SCC_GSMRL_DIAG_LE);
+}
+
static void scc_putc (int scc_index, const char c)
{
volatile cbd_t *tbdf;
@@ -496,12 +508,6 @@ static int test_ctlr (int ctlr, int index)
char test_str[] = "*** UART Test String ***\r\n";
int i;
-#if !defined(CONFIG_8xx_CONS_NONE)
- if (used_by_uart[ctlr] == index) {
- while (ctlr_proc[ctlr].getc (index) != -1);
- }
-#endif
-
ctlr_proc[ctlr].init (index);
for (i = 0; i < sizeof (test_str) - 1; i++) {
@@ -512,13 +518,8 @@ static int test_ctlr (int ctlr, int index)
res = 0;
- Done:
-
-#if !defined(CONFIG_8xx_CONS_NONE)
- if (used_by_uart[ctlr] == index) {
- serial_init ();
- }
-#endif
+Done:
+ ctlr_proc[ctlr].halt (index);
if (res != 0) {
post_log ("uart %s%d test failed\n",
@@ -533,25 +534,13 @@ int uart_post_test (int flags)
int res = 0;
int i;
-#if defined(CONFIG_8xx_CONS_SMC1)
- used_by_uart[CTLR_SMC] = 0;
-#elif defined(CONFIG_8xx_CONS_SMC2)
- used_by_uart[CTLR_SMC] = 1;
-#elif defined(CONFIG_8xx_CONS_SCC1)
- used_by_uart[CTLR_SCC] = 0;
-#elif defined(CONFIG_8xx_CONS_SCC2)
- used_by_uart[CTLR_SCC] = 1;
-#elif defined(CONFIG_8xx_CONS_SCC3)
- used_by_uart[CTLR_SCC] = 2;
-#elif defined(CONFIG_8xx_CONS_SCC4)
- used_by_uart[CTLR_SCC] = 3;
-#endif
-
ctlr_proc[CTLR_SMC].init = smc_init;
+ ctlr_proc[CTLR_SMC].halt = smc_halt;
ctlr_proc[CTLR_SMC].putc = smc_putc;
ctlr_proc[CTLR_SMC].getc = smc_getc;
ctlr_proc[CTLR_SCC].init = scc_init;
+ ctlr_proc[CTLR_SCC].halt = scc_halt;
ctlr_proc[CTLR_SCC].putc = scc_putc;
ctlr_proc[CTLR_SCC].getc = scc_getc;
@@ -561,6 +550,10 @@ int uart_post_test (int flags)
}
}
+#if !defined(CONFIG_8xx_CONS_NONE)
+ serial_reinit_all ();
+#endif
+
return res;
}