]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
karo: tx53/tx6: support either LCD or LVDS depending on module type
authorLothar Waßmann <LW@KARO-electronics.de>
Fri, 6 Dec 2013 09:35:50 +0000 (10:35 +0100)
committerLothar Waßmann <LW@KARO-electronics.de>
Fri, 6 Dec 2013 09:35:50 +0000 (10:35 +0100)
board/karo/common/fdt.c
board/karo/common/karo.h
board/karo/tx28/tx28.c
board/karo/tx48/tx48.c
board/karo/tx53/tx53.c
board/karo/tx6/tx6qdl.c
boards.cfg
include/configs/tx53.h
include/configs/tx6.h

index f735d369dd68e5a2d04244611e3ecf5d4b38563f..8acdb85ebc7f45a8daff19b09530194c94fdd6cc 100644 (file)
@@ -312,7 +312,7 @@ out:
        karo_set_fdtsize(blob);
 }
 
-static int karo_fdt_flexcan_enabled(void *blob)
+static inline int karo_fdt_flexcan_enabled(void *blob)
 {
        const char *can_ifs[] = {
                "can0",
@@ -338,7 +338,7 @@ static int karo_fdt_flexcan_enabled(void *blob)
        return 0;
 }
 
-static void karo_fdt_set_lcd_pins(void *blob, const char *name)
+static inline void karo_fdt_set_lcd_pins(void *blob, const char *name)
 {
        int off = fdt_path_offset(blob, name);
        u32 ph;
@@ -368,6 +368,7 @@ void karo_fdt_fixup_flexcan(void *blob, int xcvr_present)
 {
        const char *xcvr_status = "disabled";
 
+#ifndef CONFIG_SYS_LVDS_IF
        if (xcvr_present) {
                if (karo_fdt_flexcan_enabled(blob)) {
                        karo_fdt_set_lcd_pins(blob, "lcdif_23bit_pins_a");
@@ -383,6 +384,7 @@ void karo_fdt_fixup_flexcan(void *blob, int xcvr_present)
 
                karo_fdt_set_lcd_pins(blob, "lcdif_24bit_pins_a");
        }
+#endif
        fdt_find_and_setprop(blob, "reg_can_xcvr", "status",
                        xcvr_status, strlen(xcvr_status) + 1, 1);
 }
@@ -679,96 +681,6 @@ out:
        return ret;
 }
 
-static int karo_fdt_set_display_alias(void *blob, const char *path,
-                               const char *name)
-{
-       int ret;
-       int off;
-       size_t size = strlen(path) + strlen(name) + 2;
-       char *display;
-
-       display = malloc(size);
-       if (display == NULL) {
-               printf("%s: Failed to allocate buffer\n", __func__);
-               return -ENOMEM;
-       }
-       sprintf(display, "%s/%s", path, name);
-       if (strlen(display) != size - 1)
-               hang();
-       off = fdt_path_offset(blob, "/aliases");
-       if (off == FDT_ERR_BADMAGIC)
-               return -EINVAL;
-       ret = fdt_resize(blob);
-       if (ret < 0) {
-               printf("%s: Failed to resize FDT: %s\n",
-                       __func__, fdt_strerror(ret));
-       }
-       if (off < 0) {
-               off = fdt_add_subnode(blob, 0, "aliases");
-               if (off < 0) {
-                       printf("%s: Failed to create 'aliases' node: %s\n",
-                               __func__, fdt_strerror(off));
-                       return off;
-               }
-       }
-       ret = fdt_setprop_string(blob, off, "display", display);
-       debug("setprop_string(display='%s') returned %d (%s)\n", display, ret,
-               ret < 0 ? fdt_strerror(ret) : "OK");
-       return ret;
-}
-
-const char *karo_fdt_set_display(const char *video_mode, const char *lcd_path,
-                               const char *lvds_path)
-{
-       const char *vmode = NULL;
-       int ret;
-       void *blob = working_fdt;
-
-       if (video_mode == NULL || strlen(video_mode) == 0)
-               return NULL;
-
-       vmode = strchr(video_mode, ':');
-
-       if (lvds_path == NULL)
-               return vmode ? vmode + 1 : video_mode;
-
-       if (lvds_path != NULL && vmode != NULL) {
-               if (strncmp(video_mode, "LVDS:", 5) == 0 ||
-                       strncmp(video_mode, "LVDS0:", 6) == 0) {
-                       ret = karo_fdt_set_display_alias(blob, lvds_path,
-                                                       "lvds-channel@0");
-               } else if (strncmp(video_mode, "LVDS1:", 6) == 0) {
-                       ret = karo_fdt_set_display_alias(blob, lvds_path,
-                                                       "lvds-channel@1");
-               } else {
-                       debug("%s: Syntax error in video_mode\n", __func__);
-                       return vmode + 1;
-               }
-               video_mode = vmode + 1;
-       } else {
-               int off;
-
-               ret = karo_fdt_set_display_alias(blob, lcd_path,
-                                               "display@di0");
-
-               off = fdt_path_offset(blob, "lvds0");
-               if (off >= 0) {
-                       ret = fdt_set_node_status(blob, off,
-                                               FDT_STATUS_DISABLED, 0);
-               }
-               off = fdt_path_offset(blob, "lvds1");
-               if (off >= 0) {
-                       ret = fdt_set_node_status(blob, off,
-                                               FDT_STATUS_DISABLED, 0);
-               }
-       }
-       if (ret) {
-               printf("%s: failed to set 'display' alias: %s\n",
-                       __func__, fdt_strerror(ret));
-       }
-       return video_mode;
-}
-
 int karo_fdt_update_fb_mode(void *blob, const char *name)
 {
        int off = fdt_path_offset(blob, "display");
index 6ef52933468149368d584b8a8ea488e28dc6edcc..894b2126c80adae6bea2466086af75aed8f58cce 100644 (file)
@@ -31,8 +31,6 @@ int karo_fdt_get_fb_mode(void *blob, const char *name,
 int karo_fdt_update_fb_mode(void *blob, const char *name);
 int karo_fdt_create_fb_mode(void *blob, const char *name,
                        struct fb_videomode *mode);
-const char *karo_fdt_set_display(const char *video_mode, const char *lcd_path,
-                               const char *lvds_path);
 #else
 static inline void karo_fdt_remove_node(void *blob, const char *node)
 {
@@ -74,11 +72,17 @@ static inline int karo_fdt_create_fb_mode(void *blob,
 {
        return 0;
 }
-static inline const char *karo_fdt_set_display(const char *video_mode, const char *lcd_path,
-                                       const char *lvds_path)
+#endif
+
+static inline const char *karo_get_vmode(const char *video_mode)
 {
-       return video_mode;
+       const char *vmode = NULL;
+
+       if (video_mode == NULL || strlen(video_mode) == 0)
+               return NULL;
+
+       vmode = strchr(video_mode, ':');
+       return vmode ? vmode + 1 : video_mode;
 }
-#endif
 
 int karo_load_splashimage(int mode);
index c3e261690ff58bef8b4b6889607d1a1b9c03f8b9..b902fa0c7c0256106728b6351baa99c0fdd336c3 100644 (file)
@@ -23,6 +23,7 @@
 #include <lcd.h>
 #include <netdev.h>
 #include <mmc.h>
+#include <mxcfb.h>
 #include <linux/list.h>
 #include <linux/fb.h>
 #include <asm/io.h>
@@ -231,8 +232,11 @@ static int fec_get_mac_addr(int index)
                        val = readl(&cust[index * 8 + i]);
                mac[i] = val >> shift;
        }
-       if (!is_valid_ether_addr(mac))
+       if (!is_valid_ether_addr(mac)) {
+               if (index == 0)
+                       printf("No valid MAC address programmed\n");
                return 0;
+       }
 
        if (index == 0) {
                printf("MAC addr from fuse: %pM\n", mac);
@@ -421,6 +425,7 @@ static struct fb_videomode tx28_fb_modes[] = {
                .upper_margin   = 2,
                .vsync_len      = 10,
                .lower_margin   = 2,
+               .sync           = FB_SYNC_CLK_LAT_FALL,
                .vmode          = FB_VMODE_NONINTERLACED,
        },
        {
@@ -569,7 +574,8 @@ extern void video_hw_init(void *lcdbase);
 void lcd_ctrl_init(void *lcdbase)
 {
        int color_depth = 24;
-       char *vm;
+       const char *video_mode = karo_get_vmode(getenv("video_mode"));
+       const char *vm;
        unsigned long val;
        int refresh = 60;
        struct fb_videomode *p = tx28_fb_modes;
@@ -581,24 +587,33 @@ void lcd_ctrl_init(void *lcdbase)
                return;
        }
 
-       if (tstc()) {
+       if (had_ctrlc()) {
                debug("Disabling LCD\n");
                lcd_enabled = 0;
+               setenv("splashimage", NULL);
                return;
        }
 
        karo_fdt_move_fdt();
 
-       vm = getenv("video_mode");
-       if (vm == NULL) {
+       if (video_mode == NULL) {
                debug("Disabling LCD\n");
                lcd_enabled = 0;
                return;
        }
-       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);
+               if (fb_mode.xres > panel_info.vl_col ||
+                       fb_mode.yres > panel_info.vl_row) {
+                       printf("video resolution from DT: %dx%d exceeds hardware limits: %dx%d\n",
+                               fb_mode.xres, fb_mode.yres,
+                               panel_info.vl_col, panel_info.vl_row);
+                       lcd_enabled = 0;
+                       return;
+               }
        }
        if (p->name != NULL)
                debug("Trying compiled-in video modes\n");
@@ -622,11 +637,13 @@ void lcd_ctrl_init(void *lcdbase)
                                        if (val > panel_info.vl_col)
                                                val = panel_info.vl_col;
                                        p->xres = val;
+                                       panel_info.vl_col = val;
                                        xres_set = 1;
                                } else if (!yres_set) {
                                        if (val > panel_info.vl_row)
                                                val = panel_info.vl_row;
                                        p->yres = val;
+                                       panel_info.vl_row = val;
                                        yres_set = 1;
                                } else if (!bpp_set) {
                                        switch (val) {
@@ -679,6 +696,12 @@ void lcd_ctrl_init(void *lcdbase)
                printf("\n");
                return;
        }
+       if (p->xres > panel_info.vl_col || p->yres > panel_info.vl_row) {
+               printf("video resolution: %dx%d exceeds hardware limits: %dx%d\n",
+                       p->xres, p->yres, panel_info.vl_col, panel_info.vl_row);
+               lcd_enabled = 0;
+               return;
+       }
        panel_info.vl_col = p->xres;
        panel_info.vl_row = p->yres;
 
@@ -700,6 +723,17 @@ void lcd_ctrl_init(void *lcdbase)
        debug("Pixel clock set to %lu.%03lu MHz\n",
                PICOS2KHZ(p->pixclock) / 1000, PICOS2KHZ(p->pixclock) % 1000);
 
+       if (p != &fb_mode) {
+               int ret;
+
+               debug("Creating new display-timing node from '%s'\n",
+                       video_mode);
+               ret = karo_fdt_create_fb_mode(working_fdt, video_mode, p);
+               if (ret)
+                       printf("Failed to create new display-timing node from '%s': %d\n",
+                               video_mode, ret);
+       }
+
        gpio_request_array(stk5_lcd_gpios, ARRAY_SIZE(stk5_lcd_gpios));
        mxs_iomux_setup_multiple_pads(stk5_lcd_pads,
                                ARRAY_SIZE(stk5_lcd_pads));
@@ -708,11 +742,14 @@ void lcd_ctrl_init(void *lcdbase)
                color_depth, refresh);
 
        if (karo_load_splashimage(0) == 0) {
-               char vmode[32];
+               char vmode[128];
 
                /* setup env variable for mxsfb display driver */
-               snprintf(vmode, sizeof(vmode), "%dx%dMR-%d@%d",
-                       p->xres, p->yres, color_depth, refresh);
+               snprintf(vmode, sizeof(vmode),
+                       "x:%d,y:%d,le:%d,ri:%d,up:%d,lo:%d,hs:%d,vs:%d,sync:%d,pclk:%d,depth:%d",
+                       p->xres, p->yres, p->left_margin, p->right_margin,
+                       p->upper_margin, p->lower_margin, p->hsync_len,
+                       p->vsync_len, p->sync, p->pixclock, color_depth);
                setenv("videomode", vmode);
 
                debug("Initializing LCD controller\n");
@@ -763,19 +800,40 @@ int tx28_fec1_enabled(void)
        return status && (strcmp(status, "okay") == 0);
 }
 
-int board_late_init(void)
+static void tx28_init_mac(void)
 {
        int ret;
+
+       ret = fec_get_mac_addr(0);
+       if (ret < 0) {
+               printf("Failed to read FEC0 MAC address from OCOTP\n");
+               return;
+       }
+#ifdef CONFIG_FEC_MXC_MULTI
+       if (tx28_fec1_enabled()) {
+               ret = fec_get_mac_addr(1);
+               if (ret < 0) {
+                       printf("Failed to read FEC1 MAC address from OCOTP\n");
+                       return;
+               }
+       }
+#endif
+}
+
+int board_late_init(void)
+{
+       int ret = 0;
        const char *baseboard;
 
        karo_fdt_move_fdt();
 
        baseboard = getenv("baseboard");
        if (!baseboard)
-               return 0;
+               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();
@@ -795,24 +853,13 @@ int board_late_init(void)
        } else {
                printf("WARNING: Unsupported baseboard: '%s'\n",
                        baseboard);
-               return -EINVAL;
+               ret = -EINVAL;
        }
 
-       ret = fec_get_mac_addr(0);
-       if (ret < 0) {
-               printf("Failed to read FEC0 MAC address from OCOTP\n");
-               return ret;
-       }
-#ifdef CONFIG_FEC_MXC_MULTI
-       if (tx28_fec1_enabled()) {
-               ret = fec_get_mac_addr(1);
-               if (ret < 0) {
-                       printf("Failed to read FEC1 MAC address from OCOTP\n");
-                       return ret;
-               }
-       }
-#endif
-       return 0;
+exit:
+       tx28_init_mac();
+       clear_ctrlc();
+       return ret;
 }
 
 #define BOOT_CAUSE_MASK                (RTC_PERSISTENT0_EXTERNAL_RESET |       \
@@ -901,7 +948,7 @@ int checkboard(void)
 #ifdef CONFIG_FDT_FIXUP_PARTITIONS
 #include <jffs2/jffs2.h>
 #include <mtd_node.h>
-struct node_info tx28_nand_nodes[] = {
+static struct node_info tx28_nand_nodes[] = {
        { "fsl,imx28-gpmi-nand", MTD_DEV_TYPE_NAND, },
 };
 #else
@@ -918,6 +965,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 = karo_get_vmode(getenv("video_mode"));
 
 #ifdef CONFIG_TX28_S
        /* TX28-41xx (aka TX28S) has no external RTC
@@ -926,9 +974,8 @@ void ft_board_setup(void *blob, bd_t *bd)
        karo_fdt_remove_node(blob, "ds1339");
        karo_fdt_remove_node(blob, "gpio5");
 #endif
-       if (stk5_v5) {
-               karo_fdt_remove_node(blob, "stk5led");
-       }
+       if (stk5_v5)
+               karo_fdt_enable_node(blob, "stk5led", 0);
 
        fdt_fixup_mtdparts(blob, tx28_nand_nodes, ARRAY_SIZE(tx28_nand_nodes));
        fdt_fixup_ethernet(blob);
@@ -937,6 +984,6 @@ void ft_board_setup(void *blob, bd_t *bd)
                                ARRAY_SIZE(tx28_touchpanels));
        karo_fdt_fixup_usb_otg(blob, "usbotg", "fsl,usbphy");
        karo_fdt_fixup_flexcan(blob, stk5_v5);
-       karo_fdt_update_fb_mode(blob, getenv("video_mode"));
+       karo_fdt_update_fb_mode(blob, video_mode);
 }
 #endif /* CONFIG_OF_BOARD_SETUP */
index c3e428e13049f79b9b18d389442c4541f648af8b..5fcfbd1e18387b17aaf6f65a1fd5d6cd2b67a6d9 100644 (file)
@@ -604,7 +604,7 @@ void lcd_panel_disable(void)
 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;
@@ -626,14 +626,13 @@ void lcd_ctrl_init(void *lcdbase)
 
        karo_fdt_move_fdt();
 
-       vm = karo_fdt_set_display(video_mode, "/panel", NULL);
-       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);
@@ -936,6 +935,7 @@ int board_late_init(void)
                        baseboard);
                ret = -EINVAL;
        }
+
 exit:
        tx48_init_mac();
        clear_ctrlc();
@@ -1069,7 +1069,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);
@@ -1079,7 +1079,6 @@ void ft_board_setup(void *blob, bd_t *bd)
        karo_fdt_fixup_usb_otg(blob, "usb0", "phys");
        karo_fdt_fixup_flexcan(blob, stk5_v5);
 
-       video_mode = karo_fdt_set_display(video_mode, "/panel", NULL);
        karo_fdt_update_fb_mode(blob, video_mode);
 
        tx48_disable_watchdog();
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 */
index a3772ec1e48737b0ea662ca3464b5c3f5f6ce14f..733dec27d95f3de14d660f3b3f8d4c5bcb261a4c 100644 (file)
@@ -712,6 +712,7 @@ vidinfo_t panel_info = {
 };
 
 static struct fb_videomode tx6_fb_modes[] = {
+#ifndef CONFIG_SYS_LVDS_IF
        {
                /* Standard VGA timing */
                .name           = "VGA",
@@ -830,6 +831,25 @@ static struct fb_videomode tx6_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,
@@ -862,7 +882,7 @@ void lcd_enable(void)
                udelay(100);
                gpio_set_value(TX6_LCD_RST_GPIO, 1);
                udelay(300000);
-               gpio_set_value(TX6_LCD_BACKLIGHT_GPIO, 0);
+               gpio_set_value(TX6_LCD_BACKLIGHT_GPIO, is_lvds());
        }
 }
 
@@ -878,7 +898,7 @@ void lcd_panel_disable(void)
 {
        if (lcd_enabled) {
                debug("Switching LCD off\n");
-               gpio_set_value(TX6_LCD_BACKLIGHT_GPIO, 1);
+               gpio_set_value(TX6_LCD_BACKLIGHT_GPIO, !is_lvds());
                gpio_set_value(TX6_LCD_RST_GPIO, 0);
                gpio_set_value(TX6_LCD_PWR_GPIO, 0);
        }
@@ -932,15 +952,14 @@ 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 = &tx6_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;
        unsigned long di_clk_rate = 65000000;
 
        if (!lcd_enabled) {
@@ -957,14 +976,13 @@ void lcd_ctrl_init(void *lcdbase)
 
        karo_fdt_move_fdt();
 
-       vm = karo_fdt_set_display(video_mode, "", "/soc/aips-bus/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);
@@ -1053,19 +1071,6 @@ void lcd_ctrl_init(void *lcdbase)
                        break;
 
                default:
-                       if (!pix_fmt) {
-                               char *tmp;
-
-                               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;
-                       }
                        if (*vm != '\0')
                                vm++;
                }
@@ -1102,11 +1107,10 @@ void lcd_ctrl_init(void *lcdbase)
 
        p->pixclock = KHZ2PICOS(refresh *
                (p->xres + p->left_margin + p->right_margin + p->hsync_len) *
-               (p->yres + p->upper_margin + p->lower_margin + p->vsync_len)
-               / 1000);
+               (p->yres + p->upper_margin + p->lower_margin + p->vsync_len) /
+                               1000);
        debug("Pixel clock set to %lu.%03lu MHz\n",
-               PICOS2KHZ(p->pixclock) / 1000,
-               PICOS2KHZ(p->pixclock) % 1000);
+               PICOS2KHZ(p->pixclock) / 1000, PICOS2KHZ(p->pixclock) % 1000);
 
        if (p != &fb_mode) {
                int ret;
@@ -1124,24 +1128,23 @@ 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->CCGR3) | MXC_CCM_CCGR3_LDB_DI0_MASK |
                        MXC_CCM_CCGR3_IPU1_IPU_DI0_MASK,
                        &ccm_regs->CCGR3);
        }
-
+#endif
        if (karo_load_splashimage(0) == 0) {
                debug("Initializing LCD controller\n");
-               ipuv3_fb_init(p, 0, pix_fmt, di_clk_parent, di_clk_rate, -1);
+               ipuv3_fb_init(p, 0, pix_fmt, DI_PCLK_PLL3, di_clk_rate, -1);
        } else {
                debug("Skipping initialization of LCD controller\n");
        }
@@ -1255,10 +1258,10 @@ int checkboard(void)
 
        tx6qdl_print_cpuinfo();
 
-       printf("Board: Ka-Ro TX6%c-%dx1%d\n",
+       printf("Board: Ka-Ro TX6%c-%d%d1%d\n",
                cpu_variant == MXC_CPU_MX6Q ? 'Q' : 'U',
                cpu_variant == MXC_CPU_MX6Q ? 1 : 8,
-               1 - PHYS_SDRAM_1_WIDTH / 64);
+               is_lvds(), 1 - PHYS_SDRAM_1_WIDTH / 64);
 
        return 0;
 }
@@ -1281,7 +1284,6 @@ void get_board_serial(struct tag_serialnr *serialnr)
 static struct node_info nodes[] = {
        { "fsl,imx6q-gpmi-nand", MTD_DEV_TYPE_NAND, },
 };
-
 #else
 #define fdt_fixup_mtdparts(b,n,c) do { } while (0)
 #endif
@@ -1291,13 +1293,25 @@ static const char *tx6_touchpanels[] = {
        "edt,edt-ft5x06",
 };
 
+#ifndef CONFIG_SYS_LVDS_IF
+static inline void tx6_fdt_fixup_sata(void *blob)
+{
+       karo_fdt_enable_node(blob, "/soc/sata", 0);
+}
+#else
+static inline void tx6_fdt_fixup_sata(void *blob)
+{
+}
+#endif
+
 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"));
 
-       karo_fdt_enable_node(blob, "stk5led", !stk5_v5);
+       if (stk5_v5)
+               karo_fdt_enable_node(blob, "stk5led", 0);
 
        fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
        fdt_fixup_ethernet(blob);
@@ -1306,8 +1320,8 @@ void ft_board_setup(void *blob, bd_t *bd)
                                ARRAY_SIZE(tx6_touchpanels));
        karo_fdt_fixup_usb_otg(blob, "usbotg", "fsl,usbphy");
        karo_fdt_fixup_flexcan(blob, stk5_v5);
+       tx6_fdt_fixup_sata(blob);
 
-       video_mode = karo_fdt_set_display(video_mode, "", "/soc/aips-bus/ldb");
        karo_fdt_update_fb_mode(blob, video_mode);
 }
 #endif /* CONFIG_OF_BOARD_SETUP */
index 8a1a7fc8d0e2911a1953e0f2778a637fc25fe2bb..01a230e8953f9baa35331fed0c14daa9c10d720d 100644 (file)
@@ -272,17 +272,28 @@ vision2                      arm         armv7       vision2             ttcontr
 cgtqmx6qeval                 arm         armv7       cgtqmx6eval         congatec      mx6             cgtqmx6eval:IMX_CONFIG=board/freescale/imx/ddr/mx6q_4x_mt41j128.cfg,MX6Q
 tx51-8xx0                    arm         armv7       tx51                karo          mx5             tx51:SYS_CPU_CLK=800,NR_DRAM_BANKS=1
 tx51-8xx1_2                  arm         armv7       tx51                karo          mx5             tx51:SYS_CPU_CLK=800,NR_DRAM_BANKS=2
-tx53-xx30                    arm         armv7       tx53                karo          mx5             tx53:NR_DRAM_BANKS=1
-tx53-xx31                    arm         armv7       tx53                karo          mx5             tx53:NR_DRAM_BANKS=2
-tx6u-8x10                    arm         armv7       tx6                 karo          mx6             tx6:MX6DL
-tx6u-8x10_mfg                arm         armv7       tx6                 karo          mx6             tx6:MX6DL,MFG
-tx6u-8x10_noenv              arm         armv7       tx6                 karo          mx6             tx6:MX6DL,ENV_IS_NOWHERE
-tx6u-8x11                    arm         armv7       tx6                 karo          mx6             tx6:MX6DL,SYS_SDRAM_BUS_WIDTH=32
-tx6u-8x11_mfg                arm         armv7       tx6                 karo          mx6             tx6:MX6DL,SYS_SDRAM_BUS_WIDTH=32,MFG
-tx6u-8x11_noenv              arm         armv7       tx6                 karo          mx6             tx6:MX6DL,SYS_SDRAM_BUS_WIDTH=32,ENV_IS_NOWHERE
-tx6q-1x10                    arm         armv7       tx6                 karo          mx6             tx6:MX6Q
-tx6q-1x10_mfg                arm         armv7       tx6                 karo          mx6             tx6:MX6Q,MFG
-tx6q-1x10_noenv              arm         armv7       tx6                 karo          mx6             tx6:MX6Q,ENV_IS_NOWHERE
+tx53-x030                    arm         armv7       tx53                karo          mx5             tx53:NR_DRAM_BANKS=1
+tx53-x031                    arm         armv7       tx53                karo          mx5             tx53:NR_DRAM_BANKS=2
+tx53-x130                    arm         armv7       tx53                karo          mx5             tx53:NR_DRAM_BANKS=1,SYS_LVDS_IF
+tx53-x131                    arm         armv7       tx53                karo          mx5             tx53:NR_DRAM_BANKS=2,SYS_LVDS_IF
+tx6u-8010                    arm         armv7       tx6                 karo          mx6             tx6:MX6DL
+tx6u-8010_mfg                arm         armv7       tx6                 karo          mx6             tx6:MX6DL,MFG
+tx6u-8010_noenv              arm         armv7       tx6                 karo          mx6             tx6:MX6DL,ENV_IS_NOWHERE
+tx6u-8011                    arm         armv7       tx6                 karo          mx6             tx6:MX6DL,SYS_SDRAM_BUS_WIDTH=32
+tx6u-8011_mfg                arm         armv7       tx6                 karo          mx6             tx6:MX6DL,SYS_SDRAM_BUS_WIDTH=32,MFG
+tx6u-8011_noenv              arm         armv7       tx6                 karo          mx6             tx6:MX6DL,SYS_SDRAM_BUS_WIDTH=32,ENV_IS_NOWHERE
+tx6q-1010                    arm         armv7       tx6                 karo          mx6             tx6:MX6Q
+tx6q-1010_mfg                arm         armv7       tx6                 karo          mx6             tx6:MX6Q,MFG
+tx6q-1010_noenv              arm         armv7       tx6                 karo          mx6             tx6:MX6Q,ENV_IS_NOWHERE
+tx6u-8110                    arm         armv7       tx6                 karo          mx6             tx6:MX6DL,SYS_LVDS_IF
+tx6u-8110_mfg                arm         armv7       tx6                 karo          mx6             tx6:MX6DL,MFG,SYS_LVDS_IF
+tx6u-8110_noenv              arm         armv7       tx6                 karo          mx6             tx6:MX6DL,ENV_IS_NOWHERE,SYS_LVDS_IF
+tx6u-8111                    arm         armv7       tx6                 karo          mx6             tx6:MX6DL,SYS_SDRAM_BUS_WIDTH=32,SYS_LVDS_IF
+tx6u-8111_mfg                arm         armv7       tx6                 karo          mx6             tx6:MX6DL,SYS_SDRAM_BUS_WIDTH=32,MFG,SYS_LVDS_IF
+tx6u-8111_noenv              arm         armv7       tx6                 karo          mx6             tx6:MX6DL,SYS_SDRAM_BUS_WIDTH=32,ENV_IS_NOWHERE,SYS_LVDS_IF
+tx6q-1110                    arm         armv7       tx6                 karo          mx6             tx6:MX6Q,SYS_LVDS_IF
+tx6q-1110_mfg                arm         armv7       tx6                 karo          mx6             tx6:MX6Q,MFG,SYS_LVDS_IF
+tx6q-1110_noenv              arm         armv7       tx6                 karo          mx6             tx6:MX6Q,ENV_IS_NOWHERE,SYS_LVDS_IF
 mx6qarm2                     arm         armv7       mx6qarm2            freescale      mx6            mx6qarm2:IMX_CONFIG=board/freescale/mx6qarm2/imximage.cfg
 mx6qsabreauto                arm         armv7       mx6qsabreauto       freescale      mx6            mx6qsabreauto:IMX_CONFIG=board/freescale/mx6qsabreauto/imximage.cfg,MX6Q
 mx6qsabrelite                arm         armv7       mx6qsabrelite       freescale      mx6            mx6qsabrelite:IMX_CONFIG=board/freescale/imx/ddr/mx6q_4x_mt41j128.cfg
index 717b053866cbf1a1a6332bcebf39d45dc93168dc..c8d4ef7a13508f8e06c1224a36391e4adcc763f3 100644 (file)
 #define CONFIG_VIDEO_BMP_RLE8
 #endif /* CONFIG_LCD */
 
+#ifdef CONFIG_SYS_LVDS_IF
+#define is_lvds()                      1
+#else
+#define is_lvds()                      0
+#endif
+
 /*
  * Memory configurations
  */
index fe6aa640a6e5e80b2e81fd33a131897a6283e24b..7bd3bacbcdcb6f8913d2da2d786b85720c0d0573 100644 (file)
 #endif /* CONFIG_LCD */
 #endif /* CONFIG_MFG */
 
+#ifdef CONFIG_SYS_LVDS_IF
+#define is_lvds()                      1
+#else
+#define is_lvds()                      0
+#endif
+
 /*
  * Memory configuration options
  */