]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - board/karo/tx53/tx53.c
karo: tx53/tx6: support either LCD or LVDS depending on module type
[karo-tx-uboot.git] / board / karo / tx53 / tx53.c
index 7e0c753e2cebbd1594456db920c5618f36d24a80..11e473f5af557352c20c32ae542071346300d6ca 100644 (file)
@@ -616,6 +616,7 @@ vidinfo_t panel_info = {
 };
 
 static struct fb_videomode tx53_fb_modes[] = {
+#ifndef CONFIG_SYS_LVDS_IF
        {
                /* Standard VGA timing */
                .name           = "VGA",
@@ -734,6 +735,25 @@ static struct fb_videomode tx53_fb_modes[] = {
                .lower_margin   = 525 - 480 - 35,
                .sync           = FB_SYNC_CLK_LAT_FALL,
        },
+#else
+       {
+               /* HannStar HSD100PXN1
+                * 202.7m mm x 152.06 mm display area.
+                */
+               .name           = "HSD100PXN1",
+               .refresh        = 60,
+               .xres           = 1024,
+               .yres           = 768,
+               .pixclock       = KHZ2PICOS(65000),
+               .left_margin    = 0,
+               .hsync_len      = 0,
+               .right_margin   = 320,
+               .upper_margin   = 0,
+               .vsync_len      = 0,
+               .lower_margin   = 38,
+               .sync           = FB_SYNC_CLK_LAT_FALL,
+       },
+#endif
        {
                /* unnamed entry for assigning parameters parsed from 'video_mode' string */
                .refresh        = 60,
@@ -766,7 +786,7 @@ void lcd_enable(void)
                udelay(100);
                gpio_set_value(TX53_LCD_RST_GPIO, 1);
                udelay(300000);
-               gpio_set_value(TX53_LCD_BACKLIGHT_GPIO, 0);
+               gpio_set_value(TX53_LCD_BACKLIGHT_GPIO, is_lvds());
        }
 }
 
@@ -782,7 +802,7 @@ void lcd_panel_disable(void)
 {
        if (lcd_enabled) {
                debug("Switching LCD off\n");
-               gpio_set_value(TX53_LCD_BACKLIGHT_GPIO, 1);
+               gpio_set_value(TX53_LCD_BACKLIGHT_GPIO, !is_lvds());
                gpio_set_value(TX53_LCD_RST_GPIO, 0);
                gpio_set_value(TX53_LCD_PWR_GPIO, 0);
        }
@@ -797,6 +817,8 @@ static const iomux_v3_cfg_t stk5_lcd_pads[] = {
        MX53_PAD_GPIO_1__GPIO1_1 | MX53_GPIO_PAD_CTRL,
 
        /* Display */
+#ifndef CONFIG_SYS_LVDS_IF
+       /* LCD option */
        MX53_PAD_DI0_DISP_CLK__IPU_DI0_DISP_CLK,
        MX53_PAD_DI0_PIN15__IPU_DI0_PIN15,
        MX53_PAD_DI0_PIN2__IPU_DI0_PIN2,
@@ -825,7 +847,7 @@ static const iomux_v3_cfg_t stk5_lcd_pads[] = {
        MX53_PAD_DISP0_DAT21__IPU_DISP0_DAT_21,
        MX53_PAD_DISP0_DAT22__IPU_DISP0_DAT_22,
        MX53_PAD_DISP0_DAT23__IPU_DISP0_DAT_23,
-
+#else
        /* LVDS option */
        MX53_PAD_LVDS1_TX3_P__LDB_LVDS1_TX3,
        MX53_PAD_LVDS1_TX2_P__LDB_LVDS1_TX2,
@@ -837,6 +859,7 @@ static const iomux_v3_cfg_t stk5_lcd_pads[] = {
        MX53_PAD_LVDS0_TX2_P__LDB_LVDS0_TX2,
        MX53_PAD_LVDS0_TX1_P__LDB_LVDS0_TX1,
        MX53_PAD_LVDS0_TX0_P__LDB_LVDS0_TX0,
+#endif
 };
 
 static const struct gpio stk5_lcd_gpios[] = {
@@ -848,15 +871,15 @@ static const struct gpio stk5_lcd_gpios[] = {
 void lcd_ctrl_init(void *lcdbase)
 {
        int color_depth = 24;
-       const char *video_mode = getenv("video_mode");
+       const char *video_mode = karo_get_vmode(getenv("video_mode"));
        const char *vm;
        unsigned long val;
        int refresh = 60;
        struct fb_videomode *p = &tx53_fb_modes[0];
        struct fb_videomode fb_mode;
        int xres_set = 0, yres_set = 0, bpp_set = 0, refresh_set = 0;
-       int pix_fmt = 0;
-       ipu_di_clk_parent_t di_clk_parent = DI_PCLK_PLL3;
+       int pix_fmt = is_lvds() ? IPU_PIX_FMT_LVDS666 : IPU_PIX_FMT_RGB24;
+       ipu_di_clk_parent_t di_clk_parent = is_lvds() ? DI_PCLK_LDB : DI_PCLK_PLL3;
        unsigned long di_clk_rate = 65000000;
 
        if (!lcd_enabled) {
@@ -873,14 +896,13 @@ void lcd_ctrl_init(void *lcdbase)
 
        karo_fdt_move_fdt();
 
-       vm = karo_fdt_set_display(video_mode, "/soc", "/soc/aips/ldb");
-       if (vm == NULL) {
+       if (video_mode == NULL) {
                debug("Disabling LCD\n");
                lcd_enabled = 0;
                return;
        }
-       video_mode = vm;
-       if (karo_fdt_get_fb_mode(working_fdt, vm, &fb_mode) == 0) {
+       vm = video_mode;
+       if (karo_fdt_get_fb_mode(working_fdt, video_mode, &fb_mode) == 0) {
                p = &fb_mode;
                debug("Using video mode from FDT\n");
                vm += strlen(vm);
@@ -927,7 +949,7 @@ void lcd_ctrl_init(void *lcdbase)
                                        switch (val) {
                                        case 32:
                                        case 24:
-                                               if (pix_fmt == IPU_PIX_FMT_LVDS666)
+                                               if (is_lvds())
                                                        pix_fmt = IPU_PIX_FMT_LVDS888;
                                                /* fallthru */
                                        case 16:
@@ -936,7 +958,7 @@ void lcd_ctrl_init(void *lcdbase)
                                                break;
 
                                        case 18:
-                                               if (pix_fmt == IPU_PIX_FMT_LVDS666) {
+                                               if (is_lvds()) {
                                                        color_depth = val;
                                                        break;
                                                }
@@ -970,15 +992,8 @@ void lcd_ctrl_init(void *lcdbase)
 
                default:
                        if (!pix_fmt) {
-                               char *tmp;
+                               char *tmp = strchr(vm, ':');
 
-                               if (strncmp(vm, "LVDS", 4) == 0) {
-                                       pix_fmt = IPU_PIX_FMT_LVDS666;
-                                       di_clk_parent = DI_PCLK_LDB;
-                               } else {
-                                       pix_fmt = IPU_PIX_FMT_RGB24;
-                               }
-                               tmp = strchr(vm, ':');
                                if (tmp)
                                        vm = tmp;
                        }
@@ -1040,20 +1055,19 @@ void lcd_ctrl_init(void *lcdbase)
                                        ARRAY_SIZE(stk5_lcd_pads));
 
        debug("Initializing FB driver\n");
-       if (!pix_fmt)
-               pix_fmt = IPU_PIX_FMT_RGB24;
-       else if (pix_fmt == IPU_PIX_FMT_LVDS666) {
+#ifdef CONFIG_SYS_LVDS_IF
+       if (pix_fmt == IPU_PIX_FMT_LVDS666) {
                writel(0x01, IOMUXC_BASE_ADDR + 8);
        } else if (pix_fmt == IPU_PIX_FMT_LVDS888) {
                writel(0x21, IOMUXC_BASE_ADDR + 8);
        }
-       if (pix_fmt != IPU_PIX_FMT_RGB24) {
+       {
                struct mxc_ccm_reg *ccm_regs = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
                /* enable LDB & DI0 clock */
                writel(readl(&ccm_regs->CCGR6) | (3 << 28) | (3 << 10),
                        &ccm_regs->CCGR6);
        }
-
+#endif
        if (karo_load_splashimage(0) == 0) {
                int ret;
 
@@ -1124,8 +1138,8 @@ static void tx53_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)
@@ -1168,8 +1182,8 @@ int checkboard(void)
 {
        tx53_print_cpuinfo();
 
-       printf("Board: Ka-Ro TX53-xx3%s\n",
-               TX53_MOD_SUFFIX);
+       printf("Board: Ka-Ro TX53-x%d3%s\n",
+               is_lvds(), TX53_MOD_SUFFIX);
 
        return 0;
 }
@@ -1198,6 +1212,17 @@ static inline void tx53_fixup_rtc(void *blob)
 }
 #endif /* CONFIG_SYS_TX53_HWREV_2 */
 
+#ifndef CONFIG_SYS_LVDS_IF
+static inline void tx53_fdt_fixup_sata(void *blob)
+{
+       karo_fdt_enable_node(blob, "/soc/sata", 0);
+}
+#else
+static inline void tx53_fdt_fixup_sata(void *blob)
+{
+}
+#endif
+
 static const char *tx53_touchpanels[] = {
        "ti,tsc2007",
        "edt,edt-ft5x06",
@@ -1207,7 +1232,7 @@ void ft_board_setup(void *blob, bd_t *bd)
 {
        const char *baseboard = getenv("baseboard");
        int stk5_v5 = baseboard != NULL && (strcmp(baseboard, "stk5-v5") == 0);
-       const char *video_mode = getenv("video_mode");
+       const char *video_mode = karo_get_vmode(getenv("video_mode"));
 
        fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
        fdt_fixup_ethernet(blob);
@@ -1217,7 +1242,6 @@ void ft_board_setup(void *blob, bd_t *bd)
        karo_fdt_fixup_usb_otg(blob, "fsl,imx-otg", "fsl,usbphy");
        karo_fdt_fixup_flexcan(blob, stk5_v5);
        tx53_fixup_rtc(blob);
-       video_mode = karo_fdt_set_display(video_mode, "/soc", "/soc/aips/ldb");
        karo_fdt_update_fb_mode(blob, video_mode);
 }
 #endif /* CONFIG_OF_BOARD_SETUP */