]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
am33xx: tx48: general cleanup
authorLothar Waßmann <LW@KARO-electronics.de>
Mon, 24 Jun 2013 09:13:29 +0000 (11:13 +0200)
committerLothar Waßmann <LW@KARO-electronics.de>
Mon, 24 Jun 2013 09:13:29 +0000 (11:13 +0200)
- add timeout to polling loop for UART_RESETDONE
- setup gd for SPL
- stub out tx48_wdog_disable() if CONFIG_HW_WATCHDOG is not set
- make enable_*_pin_mux() static

board/karo/tx48/config.mk
board/karo/tx48/spl.c
board/karo/tx48/tx48.c

index c68318af32a179f6fac8bdcca5dbdb35d90749cb..51490f0d3b4267e8a6c50efbd8b03ba0e1d5d9e5 100644 (file)
@@ -3,6 +3,5 @@ ifneq ($(CONFIG_SPL_BUILD),)
        CONFIG_SPL_TEXT_BASE = 0x402F0400
 endif
 PLATFORM_CPPFLAGS += -Werror
-PLATFORM_CPPFLAGS += -DDEBUG
 
 LOGO_BMP = logos/karo.bmp
index 9c3cf6f0c901016e1246a3979ff75987edcf4a99..4737cd3b3df9e1a0829b3332b3024adc82e1a594 100644 (file)
@@ -50,8 +50,9 @@
 #define UART_SYSSTS_OFFSET     0x58
 
 #define UART_RESET             (0x1 << 1)
-#define UART_CLK_RUNNING_MASK  0x1
-#define UART_SMART_IDLE_EN     (0x1 << 0x3)
+#define UART_RESETDONE         (1 << 0)
+#define UART_IDLE_MODE(m)      (((m) << 3) & UART_IDLE_MODE_MASK)
+#define UART_IDLE_MODE_MASK    (0x3 << 3)
 
 /* Timer Defines */
 #define TSICR_REG              0x54
@@ -78,6 +79,8 @@
 #define PULLUDDIS      (0x1 << 3) /* Pull up disabled */
 #define MODE(val)      (val)
 
+DECLARE_GLOBAL_DATA_PTR;
+
 /*
  * PAD CONTROL OFFSETS
  * Field names corresponds to the pad signal name
@@ -396,12 +399,12 @@ static struct pin_mux tx48_uart0_pins[] = {
 /*
  * early system init of muxing and clocks.
  */
-void enable_uart0_pin_mux(void)
+static void enable_uart0_pin_mux(void)
 {
        tx48_set_pin_mux(tx48_uart0_pins, ARRAY_SIZE(tx48_uart0_pins));
 }
 
-void enable_mmc0_pin_mux(void)
+static void enable_mmc0_pin_mux(void)
 {
        tx48_set_pin_mux(tx48_mmc_pins, ARRAY_SIZE(tx48_mmc_pins));
 }
@@ -438,9 +441,13 @@ static struct emif_regs tx48_ddr3_emif_reg_data = {
        .emif_ddr_phy_ctlr_1 = MT41J128MJT125_EMIF_READ_LATENCY,
 };
 
-void s_init(void)
+#ifdef CONFIG_HW_WATCHDOG
+static inline void tx48_wdog_disable(void)
+{
+}
+#else
+static inline void tx48_wdog_disable(void)
 {
-#ifndef CONFIG_HW_WATCHDOG
        struct wd_timer *wdtimer = (struct wd_timer *)WDT_BASE;
 
        /* WDT1 is already running when the bootloader gets control
@@ -452,33 +459,44 @@ void s_init(void)
        writel(0x5555, &wdtimer->wdtwspr);
        while (readl(&wdtimer->wdtwwps) != 0x0)
                ;
+}
 #endif
+
+void s_init(void)
+{
+       struct uart_sys *uart_base = (struct uart_sys *)DEFAULT_UART_BASE;
+       int timeout = 1000;
+
        /* Setup the PLLs and the clocks for the peripherals */
        pll_init();
 
-       /* UART softreset */
-       u32 regVal;
-       struct uart_sys *uart_base = (struct uart_sys *)DEFAULT_UART_BASE;
+       tx48_wdog_disable();
 
        enable_uart0_pin_mux();
 
-       regVal = readl(&uart_base->uartsyscfg);
-       regVal |= UART_RESET;
-       writel(regVal, &uart_base->uartsyscfg);
-       while ((readl(&uart_base->uartsyssts) &
-               UART_CLK_RUNNING_MASK) != UART_CLK_RUNNING_MASK)
-               ;
+       /* UART softreset */
+       writel(readl(&uart_base->uartsyscfg) | UART_RESET,
+               &uart_base->uartsyscfg);
+       while (!(readl(&uart_base->uartsyssts) & UART_RESETDONE)) {
+               udelay(1);
+               if (timeout-- <= 0)
+                       break;
+       }
 
        /* Disable smart idle */
-       regVal = readl(&uart_base->uartsyscfg);
-       regVal |= UART_SMART_IDLE_EN;
-       writel(regVal, &uart_base->uartsyscfg);
+       writel((readl(&uart_base->uartsyscfg) & ~UART_IDLE_MODE_MASK) |
+               UART_IDLE_MODE(1), &uart_base->uartsyscfg);
 
-       /* Initialize the Timer */
-       timer_init();
+       gd = &gdata;
 
        preloader_console_init();
 
+       if (timeout <= 0)
+               printf("Timeout waiting for UART RESET\n");
+
+
+       timer_init();
+
        config_ddr(303, MT41J128MJT125_IOCTRL_VALUE, &tx48_ddr3_data,
                &tx48_ddr3_cmd_ctrl_data, &tx48_ddr3_emif_reg_data);
 
index 9f692d8b1c7e271e0d56bee913bd80d3db8248fb..5ed220bf287e3aa9c70ec984cd35534f7b2e14be 100644 (file)
@@ -324,13 +324,6 @@ static inline void tx48_set_pin_mux(const struct pin_mux *pin_mux,
 #define PRM_RSTST_EXTERNAL_WARM_RST    (1 << 5)
 #define PRM_RSTST_ICEPICK_RST          (1 << 9)
 
-struct prm_device {
-       unsigned int prmrstctrl;        /* offset 0x00 */
-       unsigned int prmrsttime;        /* offset 0x04 */
-       unsigned int prmrstst;          /* offset 0x08 */
-       /* ... */
-};
-
 static u32 prm_rstst __attribute__((section(".data")));
 
 /*
@@ -636,9 +629,7 @@ static void show_reset_cause(u32 prm_rstst)
 /* called with default environment! */
 int checkboard(void)
 {
-       struct prm_device *prmdev = (struct prm_device *)PRM_DEVICE;
-
-       prm_rstst = readl(&prmdev->prmrstst);
+       prm_rstst = readl(PRM_RSTST);
        show_reset_cause(prm_rstst);
 
 #ifdef CONFIG_OF_LIBFDT
@@ -732,6 +723,7 @@ static struct cpsw_slave_data cpsw_slaves[] = {
 
 void s_init(void)
 {
+       /* Nothing to be done here */
 }
 
 static struct cpsw_platform_data cpsw_data = {