]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - board/gateworks/gw_ventana/gw_ventana.c
Merge branch 'master' of git://www.denx.de/git/u-boot-imx
[karo-tx-uboot.git] / board / gateworks / gw_ventana / gw_ventana.c
index 452a9053f51c0e9915d05078a73effb58ee18a8b..bb08cd272ef28b439326c3c63499f87a58788e8e 100644 (file)
@@ -20,6 +20,7 @@
 #include <asm/imx-common/mxc_i2c.h>
 #include <asm/imx-common/boot_mode.h>
 #include <asm/imx-common/sata.h>
+#include <asm/imx-common/spi.h>
 #include <asm/imx-common/video.h>
 #include <jffs2/load_kernel.h>
 #include <hwconfig.h>
@@ -31,6 +32,7 @@
 #include <mmc.h>
 #include <mtd_node.h>
 #include <netdev.h>
+#include <pci.h>
 #include <power/pmic.h>
 #include <power/ltc3676_pmic.h>
 #include <power/pfuze100_pmic.h>
@@ -355,9 +357,14 @@ iomux_v3_cfg_t const ecspi1_pads[] = {
        IOMUX_PADS(PAD_EIM_D16__ECSPI1_SCLK | MUX_PAD_CTRL(SPI_PAD_CTRL)),
 };
 
+int board_spi_cs_gpio(unsigned bus, unsigned cs)
+{
+       return (bus == 0 && cs == 0) ? (IMX_GPIO_NR(3, 19)) : -1;
+}
+
 static void setup_spi(void)
 {
-       gpio_direction_output(CONFIG_SF_DEFAULT_CS, 1);
+       gpio_direction_output(IMX_GPIO_NR(3, 19), 1);
        SETUP_IOMUX_PADS(ecspi1_pads);
 }
 #endif
@@ -1060,7 +1067,7 @@ static void setup_board_gpio(int board)
 #endif
 
        /* turn off (active-high) user LED's */
-       for (i = 0; i < 4; i++) {
+       for (i = 0; i < ARRAY_SIZE(gpio_cfg[board].leds); i++) {
                if (gpio_cfg[board].leds[i])
                        gpio_direction_output(gpio_cfg[board].leds[i], 1);
        }
@@ -1157,6 +1164,35 @@ int imx6_pcie_toggle_reset(void)
        }
        return 0;
 }
+
+/*
+ * Most Ventana boards have a PLX PEX860x PCIe switch onboard and use its
+ * GPIO's as PERST# signals for its downstream ports - configure the GPIO's
+ * properly and assert reset for 100ms.
+ */
+void board_pci_fixup_dev(struct pci_controller *hose, pci_dev_t dev,
+                        unsigned short vendor, unsigned short device,
+                        unsigned short class)
+{
+       u32 dw;
+
+       debug("%s: %02d:%02d.%02d: %04x:%04x\n", __func__,
+             PCI_BUS(dev), PCI_DEV(dev), PCI_FUNC(dev), vendor, device);
+       if (vendor == PCI_VENDOR_ID_PLX &&
+           (device & 0xfff0) == 0x8600 &&
+           PCI_DEV(dev) == 0 && PCI_FUNC(dev) == 0) {
+               debug("configuring PLX 860X downstream PERST#\n");
+               pci_hose_read_config_dword(hose, dev, 0x62c, &dw);
+               dw |= 0xaaa8; /* GPIO1-7 outputs */
+               pci_hose_write_config_dword(hose, dev, 0x62c, dw);
+
+               pci_hose_read_config_dword(hose, dev, 0x644, &dw);
+               dw |= 0xfe;   /* GPIO1-7 output high */
+               pci_hose_write_config_dword(hose, dev, 0x644, dw);
+
+               mdelay(100);
+       }
+}
 #endif /* CONFIG_CMD_PCI */
 
 #ifdef CONFIG_SERIAL_TAG
@@ -1447,7 +1483,7 @@ int misc_init_r(void)
  *  - board (full model from EEPROM)
  *  - peripherals removed from DTB if not loaded on board (per EEPROM config)
  */
-void ft_board_setup(void *blob, bd_t *bd)
+int ft_board_setup(void *blob, bd_t *bd)
 {
        struct ventana_board_info *info = &ventana_info;
        struct ventana_eeprom_config *cfg;
@@ -1459,7 +1495,7 @@ void ft_board_setup(void *blob, bd_t *bd)
 
        if (getenv("fdt_noauto")) {
                puts("   Skiping ft_board_setup (fdt_noauto defined)\n");
-               return;
+               return 0;
        }
 
        /* Update partition nodes using info from mtdparts env var */
@@ -1468,7 +1504,7 @@ void ft_board_setup(void *blob, bd_t *bd)
 
        if (!model) {
                puts("invalid board info: Leaving FDT fully enabled\n");
-               return;
+               return 0;
        }
        printf("   Adjusting FDT per EEPROM for %s...\n", model);
 
@@ -1487,7 +1523,7 @@ void ft_board_setup(void *blob, bd_t *bd)
         */
        if (getenv("fdt_noconfig")) {
                puts("   Skiping periperhal config (fdt_noconfig defined)\n");
-               return;
+               return 0;
        }
        cfg = econfig;
        while (cfg->name) {
@@ -1497,6 +1533,8 @@ void ft_board_setup(void *blob, bd_t *bd)
                }
                cfg++;
        }
+
+       return 0;
 }
 #endif /* defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP) */