]> git.sur5r.net Git - u-boot/blobdiff - post/uart.c
Merge branch 'i2c'
[u-boot] / post / uart.c
index 354c6c7a3d868fe1510dfc0448b810aaaf7d2a6c..fd97e3899e9e1187aaff700cec7c97d06c89d4ee 100644 (file)
@@ -39,6 +39,7 @@
 #ifdef CONFIG_POST
 
 #include <post.h>
+#if CONFIG_POST & CFG_POST_UART
 #if defined(CONFIG_8xx)
 #include <commproc.h>
 #elif defined(CONFIG_MPC8260)
@@ -47,9 +48,9 @@
 #error "Apparently a bad configuration, please fix."
 #endif
 #include <command.h>
-#include <net.h>
+#include <serial.h>
 
-#if CONFIG_POST & CFG_POST_UART
+DECLARE_GLOBAL_DATA_PTR;
 
 #define CTLR_SMC 0
 #define CTLR_SCC 1
@@ -66,27 +67,23 @@ 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 used_by_ether[2] = { -1, -1 };
-
 static int proff_smc[] = { PROFF_SMC1, PROFF_SMC2 };
 static int proff_scc[] =
                { PROFF_SCC1, PROFF_SCC2, PROFF_SCC3, PROFF_SCC4 };
 
-  /*
  * SMC callbacks
  */
+/*
+ * SMC callbacks
+ */
 
 static void smc_init (int smc_index)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
        static int cpm_cr_ch[] = { CPM_CR_CH_SMC1, CPM_CR_CH_SMC2 };
 
        volatile immap_t *im = (immap_t *) CFG_IMMR;
@@ -214,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;
@@ -287,8 +288,6 @@ static int smc_getc (int smc_index)
 
 static void scc_init (int scc_index)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
        static int cpm_cr_ch[] = {
                CPM_CR_CH_SCC1,
                CPM_CR_CH_SCC2,
@@ -421,6 +420,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;
@@ -498,12 +506,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++) {
@@ -514,21 +516,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
-
-#if defined(SCC_ENET)
-       if (used_by_ether[ctlr] == index) {
-               DECLARE_GLOBAL_DATA_PTR;
-
-               eth_init (gd->bd);
-       }
-#endif
+Done:
+       ctlr_proc[ctlr].halt (index);
 
        if (res != 0) {
                post_log ("uart %s%d test failed\n",
@@ -543,29 +532,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
-
-#if defined(SCC_ENET)
-       used_by_ether[CTLR_SCC] = SCC_ENET;
-#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;
 
@@ -575,6 +548,10 @@ int uart_post_test (int flags)
                }
        }
 
+#if !defined(CONFIG_8xx_CONS_NONE)
+       serial_reinit_all ();
+#endif
+
        return res;
 }