]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - board/karo/tx51/tx51.c
karo: tx51: justify and adjust the delay required before releasing the ETN PHY strap...
[karo-tx-uboot.git] / board / karo / tx51 / tx51.c
index 502487523bffc4c1d299c50b2bd56aa36d22be55..f8b8c3ffd506a54c7e75e99907984e0089726ab2 100644 (file)
@@ -248,7 +248,7 @@ int board_early_init_f(void)
        writel(0x00000000, AIPS2_BASE_ADDR + 0x4c);
        writel(0x00000000, AIPS2_BASE_ADDR + 0x50);
 
-       writel(0xffcffffc, &ccm_regs->CCGR0);
+       writel(0xffcfffff, &ccm_regs->CCGR0);
        writel(0x003fffff, &ccm_regs->CCGR1);
        writel(0x030c003c, &ccm_regs->CCGR2);
        writel(0x000000ff, &ccm_regs->CCGR3);
@@ -271,7 +271,10 @@ int board_init(void)
        gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x1000;
 
        if (ctrlc() || (wrsr & WRSR_TOUT)) {
-               printf("CTRL-C detected; Skipping boot critical setup\n");
+               if (wrsr & WRSR_TOUT)
+                       printf("WDOG RESET detected\n");
+               else
+                       printf("<CTRL-C> detected; safeboot enabled\n");
                return 1;
        }
        return 0;
@@ -386,9 +389,6 @@ int board_mmc_init(bd_t *bis)
                struct tx51_esdhc_cfg *cfg = &tx51_esdhc_cfg[i];
                int ret;
 
-               if (i >= CONFIG_SYS_FSL_ESDHC_NUM)
-                       break;
-
                imx_iomux_v3_setup_multiple_pads(cfg->pads,
                                                cfg->num_pads);
                cfg->cfg.sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK);
@@ -476,16 +476,19 @@ int board_eth_init(bd_t *bis)
        /* Deassert RESET to the external phy */
        gpio_set_value(TX51_FEC_RST_GPIO, 1);
 
-       /* Without this delay the PHY won't work, though nothing in
-        * the datasheets suggests that it should be necessary!
+       /*
+        * Due to an RC-filter in the PHY RESET line, a minimum
+        * delay of 535us is required to let the RESET line rise
+        * above the logic high threshold of the PHY input pin.
         */
-       udelay(400);
+       udelay(550);
        imx_iomux_v3_setup_multiple_pads(tx51_fec_pads,
                                        ARRAY_SIZE(tx51_fec_pads));
 
        ret = cpu_eth_init(bis);
        if (ret)
                printf("cpu_eth_init() failed: %d\n", ret);
+
        return ret;
 }
 #endif /* CONFIG_FEC_MXC */
@@ -688,6 +691,12 @@ static struct fb_videomode tx51_fb_modes[] = {
 };
 
 static int lcd_enabled = 1;
+static int lcd_bl_polarity;
+
+static int lcd_backlight_polarity(void)
+{
+       return lcd_bl_polarity;
+}
 
 void lcd_enable(void)
 {
@@ -706,7 +715,8 @@ void lcd_enable(void)
                udelay(100);
                gpio_set_value(TX51_LCD_RST_GPIO, 1);
                udelay(300000);
-               gpio_set_value(TX51_LCD_BACKLIGHT_GPIO, 0);
+               gpio_set_value(TX51_LCD_BACKLIGHT_GPIO,
+                       lcd_backlight_polarity());
        }
 }
 
@@ -722,7 +732,8 @@ void lcd_panel_disable(void)
 {
        if (lcd_enabled) {
                debug("Switching LCD off\n");
-               gpio_set_value(TX51_LCD_BACKLIGHT_GPIO, 1);
+               gpio_set_value(TX51_LCD_BACKLIGHT_GPIO,
+                       !lcd_backlight_polarity());
                gpio_set_value(TX51_LCD_RST_GPIO, 0);
                gpio_set_value(TX51_LCD_PWR_GPIO, 0);
        }
@@ -799,6 +810,7 @@ void lcd_ctrl_init(void *lcdbase)
        }
 
        karo_fdt_move_fdt();
+       lcd_bl_polarity = karo_fdt_get_backlight_polarity(working_fdt);
 
        if (video_mode == NULL) {
                debug("Disabling LCD\n");
@@ -1001,7 +1013,6 @@ static void stk5v3_board_init(void)
 static void tx51_set_cpu_clock(void)
 {
        unsigned long cpu_clk = getenv_ulong("cpu_clk", 10, 0);
-       int ret;
 
        if (had_ctrlc() || (wrsr & WRSR_TOUT))
                return;
@@ -1009,14 +1020,13 @@ static void tx51_set_cpu_clock(void)
        if (cpu_clk == 0 || cpu_clk == mxc_get_clock(MXC_ARM_CLK) / 1000000)
                return;
 
-       ret = mxc_set_clock(CONFIG_SYS_MX5_HCLK, cpu_clk, MXC_ARM_CLK);
-       if (ret != 0) {
+       if (mxc_set_clock(CONFIG_SYS_MX5_HCLK, cpu_clk, MXC_ARM_CLK) == 0) {
+               cpu_clk = mxc_get_clock(MXC_ARM_CLK);
+               printf("CPU clock set to %lu.%03lu MHz\n",
+                       cpu_clk / 1000000, cpu_clk / 1000 % 1000);
+       } else {
                printf("Error: Failed to set CPU clock to %lu MHz\n", cpu_clk);
-               return;
        }
-       printf("CPU clock set to %u.%03u MHz\n",
-               mxc_get_clock(MXC_ARM_CLK) / 1000000,
-               mxc_get_clock(MXC_ARM_CLK) / 1000 % 1000);
 }
 
 static void tx51_init_mac(void)
@@ -1029,8 +1039,8 @@ static void tx51_init_mac(void)
                return;
        }
 
-       eth_setenv_enetaddr("ethaddr", mac);
        printf("MAC addr from fuse: %pM\n", mac);
+       eth_setenv_enetaddr("ethaddr", mac);
 }
 
 int board_late_init(void)
@@ -1038,15 +1048,24 @@ int board_late_init(void)
        int ret = 0;
        const char *baseboard;
 
+       env_cleanup();
+
        tx51_set_cpu_clock();
-       karo_fdt_move_fdt();
+
+       if (had_ctrlc())
+               setenv_ulong("safeboot", 1);
+       else if (wrsr & WRSR_TOUT)
+               setenv_ulong("wdreset", 1);
+       else
+               karo_fdt_move_fdt();
 
        baseboard = getenv("baseboard");
        if (!baseboard)
                goto exit;
 
+       printf("Baseboard: %s\n", baseboard);
+
        if (strncmp(baseboard, "stk5", 4) == 0) {
-               printf("Baseboard: %s\n", baseboard);
                if ((strlen(baseboard) == 4) ||
                        strcmp(baseboard, "stk5-v3") == 0) {
                        stk5v3_board_init();
@@ -1087,10 +1106,9 @@ int checkboard(void)
 #ifdef CONFIG_FDT_FIXUP_PARTITIONS
 #include <jffs2/jffs2.h>
 #include <mtd_node.h>
-struct node_info nodes[] = {
+static struct node_info nodes[] = {
        { "fsl,imx51-nand", MTD_DEV_TYPE_NAND, },
 };
-
 #else
 #define fdt_fixup_mtdparts(b,n,c) do { } while (0)
 #endif
@@ -1103,13 +1121,18 @@ static const char *tx51_touchpanels[] = {
 void ft_board_setup(void *blob, bd_t *bd)
 {
        const char *video_mode = karo_get_vmode(getenv("video_mode"));
+       int ret;
+
+       ret = fdt_increase_size(blob, 4096);
+       if (ret)
+               printf("Failed to increase FDT size: %s\n", fdt_strerror(ret));
 
        fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
        fdt_fixup_ethernet(blob);
 
        karo_fdt_fixup_touchpanel(blob, tx51_touchpanels,
                                ARRAY_SIZE(tx51_touchpanels));
-       karo_fdt_fixup_usb_otg(blob, "fsl,imx-otg", "fsl,usbphy");
+       karo_fdt_fixup_usb_otg(blob, "usbotg", "fsl,usbphy", "vbus-supply");
        karo_fdt_update_fb_mode(blob, video_mode);
 }
 #endif /* CONFIG_OF_BOARD_SETUP */