Merge branch 'master' of git://www.denx.de/git/u-boot-socfpga
[oweals/u-boot.git] / board / gateworks / gw_ventana / gw_ventana.c
index 068c7264bb2c8302652ee6a273525938b8d154e9..1e54912a0180961194cbbb921dbbacad9a659bf4 100644 (file)
@@ -495,6 +495,48 @@ struct display_info_t const displays[] = {{
                .vsync_len      = 10,
                .sync           = FB_SYNC_EXT,
                .vmode          = FB_VMODE_NONINTERLACED
+} }, {
+       /* DLC700JMG-T-4 */
+       .bus    = 0,
+       .addr   = 0,
+       .detect = NULL,
+       .enable = enable_lvds,
+       .pixfmt = IPU_PIX_FMT_LVDS666,
+       .mode   = {
+               .name           = "DLC700JMGT4",
+               .refresh        = 60,
+               .xres           = 1024,         /* 1024x600active pixels */
+               .yres           = 600,
+               .pixclock       = 15385,        /* 64MHz */
+               .left_margin    = 220,
+               .right_margin   = 40,
+               .upper_margin   = 21,
+               .lower_margin   = 7,
+               .hsync_len      = 60,
+               .vsync_len      = 10,
+               .sync           = FB_SYNC_EXT,
+               .vmode          = FB_VMODE_NONINTERLACED
+} }, {
+       /* DLC800FIG-T-3 */
+       .bus    = 0,
+       .addr   = 0,
+       .detect = NULL,
+       .enable = enable_lvds,
+       .pixfmt = IPU_PIX_FMT_LVDS666,
+       .mode   = {
+               .name           = "DLC800FIGT3",
+               .refresh        = 60,
+               .xres           = 1024,         /* 1024x768 active pixels */
+               .yres           = 768,
+               .pixclock       = 15385,        /* 64MHz */
+               .left_margin    = 220,
+               .right_margin   = 40,
+               .upper_margin   = 21,
+               .lower_margin   = 7,
+               .hsync_len      = 60,
+               .vsync_len      = 10,
+               .sync           = FB_SYNC_EXT,
+               .vmode          = FB_VMODE_NONINTERLACED
 } } };
 size_t display_count = ARRAY_SIZE(displays);
 
@@ -627,6 +669,8 @@ static iomux_v3_cfg_t const gw52xx_gpio_pads[] = {
        IOMUX_PADS(PAD_EIM_D31__GPIO3_IO31 | DIO_PAD_CFG),
        /* PCI_RST# */
        IOMUX_PADS(PAD_ENET_TXD1__GPIO1_IO29 | DIO_PAD_CFG),
+       /* PCI_RST# (GW522x) */
+       IOMUX_PADS(PAD_EIM_D23__GPIO3_IO23 | DIO_PAD_CFG),
        /* PCIESKT_WDIS# */
        IOMUX_PADS(PAD_GPIO_17__GPIO7_IO12 | DIO_PAD_CFG),
 };
@@ -1126,6 +1170,10 @@ static void setup_board_gpio(int board)
        }
 
 #if !defined(CONFIG_CMD_PCI)
+       /* GW522x Uses GPIO3_IO23 for PCIE_RST# */
+       if (board_type == GW52xx && info->model[4] == '2')
+               gpio_cfg[board].pcie_rst = IMX_GPIO_NR(3, 23);
+
        /* assert PCI_RST# (released by OS when clock is valid) */
        gpio_direction_output(gpio_cfg[board].pcie_rst, 0);
 #endif
@@ -1388,15 +1436,8 @@ int checkboard(void)
                return 0;
 
        /* Display GSC firmware revision/CRC/status */
-       i2c_set_bus_num(CONFIG_I2C_GSC);
-       if (!gsc_i2c_read(GSC_SC_ADDR, GSC_SC_FWVER, 1, buf, 1)) {
-               printf("GSC:   v%d", buf[0]);
-               if (!gsc_i2c_read(GSC_SC_ADDR, GSC_SC_STATUS, 1, buf, 4)) {
-                       printf(" 0x%04x", buf[2] | buf[3]<<8); /* CRC */
-                       printf(" 0x%02x", buf[0]); /* irq status */
-               }
-               puts("\n");
-       }
+       gsc_info(0);
+
        /* Display RTC */
        if (!gsc_i2c_read(GSC_RTC_ADDR, 0x00, 1, buf, 4)) {
                printf("RTC:   %d\n",
@@ -1533,19 +1574,48 @@ int misc_init_r(void)
        } else {
                puts("Error: could not disable GSC Watchdog\n");
        }
-       if (!gsc_i2c_read(GSC_SC_ADDR, GSC_SC_STATUS, 1, &reg, 1)) {
-               if (reg & (1 << GSC_SC_IRQ_WATCHDOG)) { /* watchdog timeout */
-                       puts("GSC boot watchdog timeout detected\n");
-                       reg &= ~(1 << GSC_SC_IRQ_WATCHDOG); /* clear flag */
-                       gsc_i2c_write(GSC_SC_ADDR, GSC_SC_STATUS, 1, &reg, 1);
-               }
-       }
 
        return 0;
 }
 
 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
 
+static int ft_sethdmiinfmt(void *blob, char *mode)
+{
+       int off;
+
+       if (!mode)
+               return -EINVAL;
+
+       off = fdt_node_offset_by_compatible(blob, -1, "nxp,tda1997x");
+       if (off < 0)
+               return off;
+
+       if (0 == strcasecmp(mode, "yuv422bt656")) {
+               u8 cfg[] = { 0x00, 0x00, 0x00, 0x82, 0x81, 0x00,
+                            0x00, 0x00, 0x00 };
+               mode = "422_ccir";
+               fdt_setprop(blob, off, "vidout_fmt", mode, strlen(mode) + 1);
+               fdt_setprop_u32(blob, off, "vidout_trc", 1);
+               fdt_setprop_u32(blob, off, "vidout_blc", 1);
+               fdt_setprop(blob, off, "vidout_portcfg", cfg, sizeof(cfg));
+               printf("   set HDMI input mode to %s\n", mode);
+       } else if (0 == strcasecmp(mode, "yuv422smp")) {
+               u8 cfg[] = { 0x00, 0x00, 0x00, 0x88, 0x87, 0x00,
+                            0x82, 0x81, 0x00 };
+               mode = "422_smp";
+               fdt_setprop(blob, off, "vidout_fmt", mode, strlen(mode) + 1);
+               fdt_setprop_u32(blob, off, "vidout_trc", 0);
+               fdt_setprop_u32(blob, off, "vidout_blc", 0);
+               fdt_setprop(blob, off, "vidout_portcfg", cfg, sizeof(cfg));
+               printf("   set HDMI input mode to %s\n", mode);
+       } else {
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
 /*
  * called prior to booting kernel or by 'fdt boardsetup' command
  *
@@ -1564,6 +1634,7 @@ int ft_board_setup(void *blob, bd_t *bd)
                { "fsl,imx6q-gpmi-nand",  MTD_DEV_TYPE_NAND, }, /* NAND flash */
        };
        const char *model = getenv("model");
+       const char *display = getenv("display");
        int i;
        char rev = 0;
 
@@ -1584,6 +1655,13 @@ int ft_board_setup(void *blob, bd_t *bd)
        puts("   Updating MTD partitions...\n");
        fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
 
+       /* Update display timings from display env var */
+       if (display) {
+               if (fdt_fixup_display(blob, fdt_get_alias(blob, "lvds0"),
+                                     display) >= 0)
+                       printf("   Set display timings for %s...\n", display);
+       }
+
        if (!model) {
                puts("invalid board info: Leaving FDT fully enabled\n");
                return 0;
@@ -1598,6 +1676,20 @@ int ft_board_setup(void *blob, bd_t *bd)
        fdt_setprop(blob, 0, "board", info->model,
                    strlen((const char *)info->model) + 1);
 
+       /* set desired digital video capture format */
+       ft_sethdmiinfmt(blob, getenv("hdmiinfmt"));
+
+       /*
+        * disable serial2 node for GW54xx for compatibility with older
+        * 3.10.x kernel that improperly had this node enabled in the DT
+        */
+       if (board_type == GW54xx) {
+               i = fdt_path_offset(blob,
+                                   "/soc/aips-bus@02100000/serial@021ec000");
+               if (i)
+                       fdt_del_node(blob, i);
+       }
+
        /*
         * disable wdog1/wdog2 nodes for GW51xx below revC to work around
         * errata causing wdog timer to be unreliable.
@@ -1609,6 +1701,28 @@ int ft_board_setup(void *blob, bd_t *bd)
                        fdt_status_disabled(blob, i);
        }
 
+       /* GW522x Uses GPIO3_IO23 instead of GPIO1_IO29 */
+       else if (board_type == GW52xx && info->model[4] == '2') {
+               u32 handle = 0;
+               u32 *range = NULL;
+
+               i = fdt_node_offset_by_compatible(blob, -1, "fsl,imx6q-pcie");
+               if (i)
+                       range = (u32 *)fdt_getprop(blob, i, "reset-gpio",
+                                                  NULL);
+
+               if (range) {
+                       i = fdt_path_offset(blob,
+                                           "/soc/aips-bus@02000000/gpio@020a4000");
+                       if (i)
+                               handle = fdt_get_phandle(blob, i);
+                       if (handle) {
+                               range[0] = cpu_to_fdt32(handle);
+                               range[1] = cpu_to_fdt32(23);
+                       }
+               }
+       }
+
        /*
         * isolate CSI0_DATA_EN for GW551x below revB to work around
         * errata causing non functional digital video in (it is not hooked up)
@@ -1642,6 +1756,9 @@ int ft_board_setup(void *blob, bd_t *bd)
                        }
                        fdt_setprop_inplace(blob, i, "fsl,pins", range, len);
                }
+
+               /* set BT656 video format */
+               ft_sethdmiinfmt(blob, "yuv422bt656");
        }
 
        /*