Merge branch 'master' of git://www.denx.de/git/u-boot-socfpga
[oweals/u-boot.git] / board / gateworks / gw_ventana / gw_ventana.c
index 871af09d418840539c046d54940c16dbb290013b..1e54912a0180961194cbbb921dbbacad9a659bf4 100644 (file)
@@ -669,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),
 };
@@ -1168,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
@@ -1430,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",
@@ -1575,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
  *
@@ -1648,6 +1676,9 @@ 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
@@ -1670,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)
@@ -1703,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");
        }
 
        /*