Prepare v2023.10
[platform/kernel/u-boot.git] / board / gateworks / gw_ventana / gw_ventana.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2013 Gateworks Corporation
4  *
5  * Author: Tim Harvey <tharvey@gateworks.com>
6  */
7
8 #include <command.h>
9 #include <common.h>
10 #include <fdt_support.h>
11 #include <gsc.h>
12 #include <hwconfig.h>
13 #include <i2c.h>
14 #include <miiphy.h>
15 #include <mtd_node.h>
16 #include <asm/arch/clock.h>
17 #include <asm/arch/crm_regs.h>
18 #include <asm/arch/mx6-pins.h>
19 #include <asm/arch/mxc_hdmi.h>
20 #include <asm/arch/sys_proto.h>
21 #include <asm/mach-imx/boot_mode.h>
22 #include <asm/mach-imx/video.h>
23 #include <jffs2/load_kernel.h>
24 #include <linux/ctype.h>
25 #include <linux/delay.h>
26
27 #include "common.h"
28
29 DECLARE_GLOBAL_DATA_PTR;
30
31 /* configure eth0 PHY board-specific LED behavior */
32 int board_phy_config(struct phy_device *phydev)
33 {
34         unsigned short val;
35         ofnode node;
36
37         switch (phydev->phy_id) {
38         case 0x1410dd1:
39                 puts("MV88E1510");
40                 /*
41                  * Page 3, Register 16: LED[2:0] Function Control Register
42                  * LED[0] (SPD:Amber) R16_3.3:0 to 0111: on-GbE link
43                  * LED[1] (LNK:Green) R16_3.7:4 to 0001: on-link, blink-activity
44                  */
45                 phy_write(phydev, MDIO_DEVAD_NONE, 22, 3);
46                 val = phy_read(phydev, MDIO_DEVAD_NONE, 16);
47                 val &= 0xff00;
48                 val |= 0x0017;
49                 phy_write(phydev, MDIO_DEVAD_NONE, 16, val);
50                 phy_write(phydev, MDIO_DEVAD_NONE, 22, 0);
51                 break;
52         case 0x2000a231:
53                 puts("TIDP83867 ");
54                 /* LED configuration */
55                 val = 0;
56                 val |= 0x5 << 4; /* LED1(Amber;Speed)   : 1000BT link */
57                 val |= 0xb << 8; /* LED2(Green;Link/Act): blink for TX/RX act */
58                 phy_write(phydev, MDIO_DEVAD_NONE, 24, val);
59
60                 /* configure register 0x170 for ref CLKOUT */
61                 phy_write(phydev, MDIO_DEVAD_NONE, 13, 0x001f);
62                 phy_write(phydev, MDIO_DEVAD_NONE, 14, 0x0170);
63                 phy_write(phydev, MDIO_DEVAD_NONE, 13, 0x401f);
64                 val = phy_read(phydev, MDIO_DEVAD_NONE, 14);
65                 val &= ~0x1f00;
66                 val |= 0x0b00; /* chD tx clock*/
67                 phy_write(phydev, MDIO_DEVAD_NONE, 14, val);
68                 break;
69         case 0xd565a401:
70                 puts("GPY111 ");
71                 node = phy_get_ofnode(phydev);
72                 if (ofnode_valid(node)) {
73                         u32 rx_delay, tx_delay;
74
75                         rx_delay = ofnode_read_u32_default(node, "rx-internal-delay-ps", 2000);
76                         tx_delay = ofnode_read_u32_default(node, "tx-internal-delay-ps", 2000);
77                         val = phy_read(phydev, MDIO_DEVAD_NONE, 0x17);
78                         val &= ~((0x7 << 12) | (0x7 << 8));
79                         val |= (rx_delay / 500) << 12;
80                         val |= (tx_delay / 500) << 8;
81                         phy_write(phydev, MDIO_DEVAD_NONE, 0x17, val);
82                 }
83                 break;
84         }
85
86         /* Fixed PHY: for GW5904/GW5909 this is Marvell 88E6176 GbE Switch */
87         if (phydev->phy_id == PHY_FIXED_ID &&
88             (board_type == GW5904 || board_type == GW5909)) {
89                 struct mii_dev *bus = miiphy_get_dev_by_name("mdio");
90
91                 puts("MV88E61XX ");
92                 /* GPIO[0] output CLK125 for RGMII_REFCLK */
93                 bus->write(bus, 0x1c, 0, 0x1a, (1 << 15) | (0x62 << 8) | 0xfe);
94                 bus->write(bus, 0x1c, 0, 0x1a, (1 << 15) | (0x68 << 8) | 7);
95
96                 /* Port 0-3 LED configuration: Table 80/82 */
97                 /* LED configuration: 7:4-green (8=Activity)  3:0 amber (8=Link) */
98                 bus->write(bus, 0x10, 0, 0x16, 0x8088);
99                 bus->write(bus, 0x11, 0, 0x16, 0x8088);
100                 bus->write(bus, 0x12, 0, 0x16, 0x8088);
101                 bus->write(bus, 0x13, 0, 0x16, 0x8088);
102         }
103
104         if (phydev->drv->config)
105                 phydev->drv->config(phydev);
106
107         return 0;
108 }
109
110 #if defined(CONFIG_VIDEO_IPUV3)
111 static void enable_hdmi(struct display_info_t const *dev)
112 {
113         imx_enable_hdmi_phy();
114 }
115
116 static int detect_lvds(struct display_info_t const *dev)
117 {
118         /* only the following boards support LVDS connectors */
119         switch (board_type) {
120         case GW52xx:
121         case GW53xx:
122         case GW54xx:
123         case GW560x:
124         case GW5905:
125         case GW5909:
126                 break;
127         default:
128                 return 0;
129         }
130
131         return (i2c_get_dev(dev->bus, dev->addr) ? 1 : 0);
132 }
133
134 static void enable_lvds(struct display_info_t const *dev)
135 {
136         struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR;
137
138         /* set CH0 data width to 24bit (IOMUXC_GPR2:5 0=18bit, 1=24bit) */
139         u32 reg = readl(&iomux->gpr[2]);
140         reg |= IOMUXC_GPR2_DATA_WIDTH_CH0_24BIT;
141         writel(reg, &iomux->gpr[2]);
142
143         /* Configure GPIO */
144         switch (board_type) {
145         case GW52xx:
146         case GW53xx:
147         case GW54xx:
148                 if (!strncmp(dev->mode.name, "Hannstar", 8)) {
149                         SETUP_IOMUX_PAD(PAD_SD2_CLK__GPIO1_IO10 | DIO_PAD_CFG);
150                         gpio_request(IMX_GPIO_NR(1, 10), "cabc");
151                         gpio_direction_output(IMX_GPIO_NR(1, 10), 0);
152                 } else if (!strncmp(dev->mode.name, "DLC", 3)) {
153                         SETUP_IOMUX_PAD(PAD_SD2_CLK__GPIO1_IO10 | DIO_PAD_CFG);
154                         gpio_request(IMX_GPIO_NR(1, 10), "touch_rst#");
155                         gpio_direction_output(IMX_GPIO_NR(1, 10), 1);
156                 }
157                 break;
158         default:
159                 break;
160         }
161
162         /* Configure backlight */
163         gpio_request(IMX_GPIO_NR(1, 18), "bklt_en");
164         SETUP_IOMUX_PAD(PAD_SD1_CMD__GPIO1_IO18 | DIO_PAD_CFG);
165         gpio_direction_output(IMX_GPIO_NR(1, 18), 1);
166 }
167
168 struct display_info_t const displays[] = {{
169         /* HDMI Output */
170         .bus    = -1,
171         .addr   = 0,
172         .pixfmt = IPU_PIX_FMT_RGB24,
173         .detect = detect_hdmi,
174         .enable = enable_hdmi,
175         .mode   = {
176                 .name           = "HDMI",
177                 .refresh        = 60,
178                 .xres           = 1024,
179                 .yres           = 768,
180                 .pixclock       = 15385,
181                 .left_margin    = 220,
182                 .right_margin   = 40,
183                 .upper_margin   = 21,
184                 .lower_margin   = 7,
185                 .hsync_len      = 60,
186                 .vsync_len      = 10,
187                 .sync           = FB_SYNC_EXT,
188                 .vmode          = FB_VMODE_NONINTERLACED
189 } }, {
190         /* Freescale MXC-LVDS1: HannStar HSD100PXN1-A00 w/ egalx_ts cont */
191         .bus    = 2,
192         .addr   = 0x4,
193         .pixfmt = IPU_PIX_FMT_LVDS666,
194         .detect = detect_lvds,
195         .enable = enable_lvds,
196         .mode   = {
197                 .name           = "Hannstar-XGA",
198                 .refresh        = 60,
199                 .xres           = 1024,
200                 .yres           = 768,
201                 .pixclock       = 15385,
202                 .left_margin    = 220,
203                 .right_margin   = 40,
204                 .upper_margin   = 21,
205                 .lower_margin   = 7,
206                 .hsync_len      = 60,
207                 .vsync_len      = 10,
208                 .sync           = FB_SYNC_EXT,
209                 .vmode          = FB_VMODE_NONINTERLACED
210 } }, {
211         /* DLC700JMG-T-4 */
212         .bus    = 2,
213         .addr   = 0x38,
214         .detect = detect_lvds,
215         .enable = enable_lvds,
216         .pixfmt = IPU_PIX_FMT_LVDS666,
217         .mode   = {
218                 .name           = "DLC700JMGT4",
219                 .refresh        = 60,
220                 .xres           = 1024,         /* 1024x600active pixels */
221                 .yres           = 600,
222                 .pixclock       = 15385,        /* 64MHz */
223                 .left_margin    = 220,
224                 .right_margin   = 40,
225                 .upper_margin   = 21,
226                 .lower_margin   = 7,
227                 .hsync_len      = 60,
228                 .vsync_len      = 10,
229                 .sync           = FB_SYNC_EXT,
230                 .vmode          = FB_VMODE_NONINTERLACED
231 } }, {
232         /* DLC0700XDP21LF-C-1 */
233         .bus    = 2,
234         .addr   = 0x38,
235         .detect = detect_lvds,
236         .enable = enable_lvds,
237         .pixfmt = IPU_PIX_FMT_LVDS666,
238         .mode   = {
239                 .name           = "DLC0700XDP21LF",
240                 .refresh        = 60,
241                 .xres           = 1024,         /* 1024x600active pixels */
242                 .yres           = 600,
243                 .pixclock       = 15385,        /* 64MHz */
244                 .left_margin    = 220,
245                 .right_margin   = 40,
246                 .upper_margin   = 21,
247                 .lower_margin   = 7,
248                 .hsync_len      = 60,
249                 .vsync_len      = 10,
250                 .sync           = FB_SYNC_EXT,
251                 .vmode          = FB_VMODE_NONINTERLACED
252 } }, {
253         /* DLC800FIG-T-3 */
254         .bus    = 2,
255         .addr   = 0x14,
256         .detect = detect_lvds,
257         .enable = enable_lvds,
258         .pixfmt = IPU_PIX_FMT_LVDS666,
259         .mode   = {
260                 .name           = "DLC800FIGT3",
261                 .refresh        = 60,
262                 .xres           = 1024,         /* 1024x768 active pixels */
263                 .yres           = 768,
264                 .pixclock       = 15385,        /* 64MHz */
265                 .left_margin    = 220,
266                 .right_margin   = 40,
267                 .upper_margin   = 21,
268                 .lower_margin   = 7,
269                 .hsync_len      = 60,
270                 .vsync_len      = 10,
271                 .sync           = FB_SYNC_EXT,
272                 .vmode          = FB_VMODE_NONINTERLACED
273 } }, {
274         .bus    = 2,
275         .addr   = 0x5d,
276         .detect = detect_lvds,
277         .enable = enable_lvds,
278         .pixfmt = IPU_PIX_FMT_LVDS666,
279         .mode   = {
280                 .name           = "Z101WX01",
281                 .refresh        = 60,
282                 .xres           = 1280,
283                 .yres           = 800,
284                 .pixclock       = 15385,        /* 64MHz */
285                 .left_margin    = 220,
286                 .right_margin   = 40,
287                 .upper_margin   = 21,
288                 .lower_margin   = 7,
289                 .hsync_len      = 60,
290                 .vsync_len      = 10,
291                 .sync           = FB_SYNC_EXT,
292                 .vmode          = FB_VMODE_NONINTERLACED
293         }
294 },
295 };
296 size_t display_count = ARRAY_SIZE(displays);
297
298 static void setup_display(void)
299 {
300         struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
301         struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR;
302         int reg;
303
304         enable_ipu_clock();
305         imx_setup_hdmi();
306         /* Turn on LDB0,IPU,IPU DI0 clocks */
307         reg = __raw_readl(&mxc_ccm->CCGR3);
308         reg |= MXC_CCM_CCGR3_LDB_DI0_MASK;
309         writel(reg, &mxc_ccm->CCGR3);
310
311         /* set LDB0, LDB1 clk select to 011/011 */
312         reg = readl(&mxc_ccm->cs2cdr);
313         reg &= ~(MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_MASK
314                  |MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_MASK);
315         reg |= (3<<MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_OFFSET)
316               |(3<<MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_OFFSET);
317         writel(reg, &mxc_ccm->cs2cdr);
318
319         reg = readl(&mxc_ccm->cscmr2);
320         reg |= MXC_CCM_CSCMR2_LDB_DI0_IPU_DIV;
321         writel(reg, &mxc_ccm->cscmr2);
322
323         reg = readl(&mxc_ccm->chsccdr);
324         reg |= (CHSCCDR_CLK_SEL_LDB_DI0
325                 <<MXC_CCM_CHSCCDR_IPU1_DI0_CLK_SEL_OFFSET);
326         writel(reg, &mxc_ccm->chsccdr);
327
328         reg = IOMUXC_GPR2_BGREF_RRMODE_EXTERNAL_RES
329              |IOMUXC_GPR2_DI1_VS_POLARITY_ACTIVE_HIGH
330              |IOMUXC_GPR2_DI0_VS_POLARITY_ACTIVE_LOW
331              |IOMUXC_GPR2_BIT_MAPPING_CH1_SPWG
332              |IOMUXC_GPR2_DATA_WIDTH_CH1_18BIT
333              |IOMUXC_GPR2_BIT_MAPPING_CH0_SPWG
334              |IOMUXC_GPR2_DATA_WIDTH_CH0_18BIT
335              |IOMUXC_GPR2_LVDS_CH1_MODE_DISABLED
336              |IOMUXC_GPR2_LVDS_CH0_MODE_ENABLED_DI0;
337         writel(reg, &iomux->gpr[2]);
338
339         reg = readl(&iomux->gpr[3]);
340         reg = (reg & ~IOMUXC_GPR3_LVDS0_MUX_CTL_MASK)
341             | (IOMUXC_GPR3_MUX_SRC_IPU1_DI0
342                <<IOMUXC_GPR3_LVDS0_MUX_CTL_OFFSET);
343         writel(reg, &iomux->gpr[3]);
344 }
345 #endif /* CONFIG_VIDEO_IPUV3 */
346
347 /*
348  * Most Ventana boards have a PLX PEX860x PCIe switch onboard and use its
349  * GPIO's as PERST# signals for its downstream ports - configure the GPIO's
350  * properly and assert reset for 100ms.
351  */
352 #define MAX_PCI_DEVS    32
353 struct pci_dev {
354         pci_dev_t devfn;
355         struct udevice *dev;
356         unsigned short vendor;
357         unsigned short device;
358         unsigned short class;
359         unsigned short busno; /* subbordinate busno */
360         struct pci_dev *ppar;
361 };
362 struct pci_dev pci_devs[MAX_PCI_DEVS];
363 int pci_devno;
364 int pci_bridgeno;
365
366 void board_pci_fixup_dev(struct udevice *bus, struct udevice *udev)
367 {
368         struct pci_child_plat *pdata = dev_get_parent_plat(udev);
369         struct pci_dev *pdev = &pci_devs[pci_devno++];
370         unsigned short vendor = pdata->vendor;
371         unsigned short device = pdata->device;
372         unsigned int class = pdata->class;
373         pci_dev_t dev = dm_pci_get_bdf(udev);
374         int i;
375
376         debug("%s: %02d:%02d.%02d: %04x:%04x\n", __func__,
377               PCI_BUS(dev), PCI_DEV(dev), PCI_FUNC(dev), vendor, device);
378
379         /* store array of devs for later use in device-tree fixup */
380         pdev->dev = udev;
381         pdev->devfn = dev;
382         pdev->vendor = vendor;
383         pdev->device = device;
384         pdev->class = class;
385         pdev->ppar = NULL;
386         if (class == PCI_CLASS_BRIDGE_PCI)
387                 pdev->busno = ++pci_bridgeno;
388         else
389                 pdev->busno = 0;
390
391         /* fixup RC - it should be 00:00.0 not 00:01.0 */
392         if (PCI_BUS(dev) == 0)
393                 pdev->devfn = 0;
394
395         /* find dev's parent */
396         for (i = 0; i < pci_devno; i++) {
397                 if (pci_devs[i].busno == PCI_BUS(pdev->devfn)) {
398                         pdev->ppar = &pci_devs[i];
399                         break;
400                 }
401         }
402
403         /* assert downstream PERST# */
404         if (vendor == PCI_VENDOR_ID_PLX &&
405             (device & 0xfff0) == 0x8600 &&
406             PCI_DEV(dev) == 0 && PCI_FUNC(dev) == 0) {
407                 ulong val;
408                 debug("configuring PLX 860X downstream PERST#\n");
409                 pci_bus_read_config(bus, dev, 0x62c, &val, PCI_SIZE_32);
410                 val |= 0xaaa8; /* GPIO1-7 outputs */
411                 pci_bus_write_config(bus, dev, 0x62c, val, PCI_SIZE_32);
412
413                 pci_bus_read_config(bus, dev, 0x644, &val, PCI_SIZE_32);
414                 val |= 0xfe;   /* GPIO1-7 output high */
415                 pci_bus_write_config(bus, dev, 0x644, val, PCI_SIZE_32);
416
417                 mdelay(100);
418         }
419 }
420
421 #ifdef CONFIG_SERIAL_TAG
422 /*
423  * called when setting up ATAGS before booting kernel
424  * populate serialnum from the following (in order of priority):
425  *   serial# env var
426  *   eeprom
427  */
428 void get_board_serial(struct tag_serialnr *serialnr)
429 {
430         char *serial = env_get("serial#");
431
432         if (serial) {
433                 serialnr->high = 0;
434                 serialnr->low = dectoul(serial, NULL);
435         } else if (ventana_info.model[0]) {
436                 serialnr->high = 0;
437                 serialnr->low = ventana_info.serial;
438         } else {
439                 serialnr->high = 0;
440                 serialnr->low = 0;
441         }
442 }
443 #endif
444
445 /*
446  * Board Support
447  */
448
449 int board_early_init_f(void)
450 {
451 #if defined(CONFIG_VIDEO_IPUV3)
452         setup_display();
453 #endif
454         return 0;
455 }
456
457 int dram_init(void)
458 {
459         gd->ram_size = imx_ddr_size();
460         return 0;
461 }
462
463 int board_init(void)
464 {
465         struct iomuxc *const iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR;
466
467         clrsetbits_le32(&iomuxc_regs->gpr[1],
468                         IOMUXC_GPR1_OTG_ID_MASK,
469                         IOMUXC_GPR1_OTG_ID_GPIO1);
470
471         /* address of linux boot parameters */
472         gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
473
474         /* read Gateworks EEPROM into global struct (used later) */
475         board_type = read_eeprom(&ventana_info);
476
477         setup_iomux_gpio(board_type);
478
479         /* show GSC details */
480         run_command("gsc", 0);
481
482         return 0;
483 }
484
485 int board_fit_config_name_match(const char *name)
486 {
487         static char init;
488         const char *dtb;
489         char buf[32];
490         int i = 0;
491
492         do {
493                 dtb = gsc_get_dtb_name(i++, buf, sizeof(buf));
494                 if (dtb && !strcmp(dtb, name)) {
495                         if (!init++)
496                                 printf("DTB:   %s\n", name);
497                         return 0;
498                 }
499         } while (dtb);
500
501         return -1;
502 }
503
504 #if defined(CONFIG_DISPLAY_BOARDINFO_LATE)
505 /*
506  * called during late init (after relocation and after board_init())
507  * by virtue of CONFIG_DISPLAY_BOARDINFO_LATE as we needed i2c initialized and
508  * EEPROM read.
509  */
510 int checkboard(void)
511 {
512         struct ventana_board_info *info = &ventana_info;
513         const char *p;
514         int quiet; /* Quiet or minimal output mode */
515
516         quiet = 0;
517         p = env_get("quiet");
518         if (p)
519                 quiet = simple_strtol(p, NULL, 10);
520         else
521                 env_set("quiet", "0");
522
523         puts("\nGateworks Corporation Copyright 2014\n");
524         if (info->model[0]) {
525                 printf("Model: %s\n", info->model);
526                 printf("MFGDate: %02x-%02x-%02x%02x\n",
527                        info->mfgdate[0], info->mfgdate[1],
528                        info->mfgdate[2], info->mfgdate[3]);
529                 printf("Serial:%d\n", info->serial);
530         } else {
531                 puts("Invalid EEPROM - board will not function fully\n");
532         }
533         if (quiet)
534                 return 0;
535
536         return 0;
537 }
538 #endif
539
540 #ifdef CONFIG_CMD_BMODE
541 /*
542  * BOOT_CFG1, BOOT_CFG2, BOOT_CFG3, BOOT_CFG4
543  * see Table 8-11 and Table 5-9
544  *  BOOT_CFG1[7] = 1 (boot from NAND)
545  *  BOOT_CFG1[5] = 0 - raw NAND
546  *  BOOT_CFG1[4] = 0 - default pad settings
547  *  BOOT_CFG1[3:2] = 00 - devices = 1
548  *  BOOT_CFG1[1:0] = 00 - Row Address Cycles = 3
549  *  BOOT_CFG2[4:3] = 00 - Boot Search Count = 2
550  *  BOOT_CFG2[2:1] = 01 - Pages In Block = 64
551  *  BOOT_CFG2[0] = 0 - Reset time 12ms
552  */
553 static const struct boot_mode board_boot_modes[] = {
554         /* NAND: 64pages per block, 3 row addr cycles, 2 copies of FCB/DBBT */
555         { "nand", MAKE_CFGVAL(0x80, 0x02, 0x00, 0x00) },
556         { "emmc2", MAKE_CFGVAL(0x60, 0x48, 0x00, 0x00) }, /* GW5600 */
557         { "emmc3", MAKE_CFGVAL(0x60, 0x50, 0x00, 0x00) }, /* GW5903/4/5 */
558         { NULL, 0 },
559 };
560 #endif
561
562 /* setup GPIO pinmux and default configuration per baseboard and env */
563 void setup_board_gpio(int board, struct ventana_board_info *info)
564 {
565         const char *s;
566         char arg[10];
567         size_t len;
568         int i;
569         int quiet = simple_strtol(env_get("quiet"), NULL, 10);
570
571         if (board >= GW_UNKNOWN)
572                 return;
573
574         /* RS232_EN# */
575         if (gpio_cfg[board].rs232_en) {
576                 gpio_direction_output(gpio_cfg[board].rs232_en,
577                                       (hwconfig("rs232")) ? 0 : 1);
578         }
579
580         /* MSATA Enable */
581         if (gpio_cfg[board].msata_en && is_cpu_type(MXC_CPU_MX6Q)) {
582                 gpio_direction_output(GP_MSATA_SEL,
583                                       (hwconfig("msata")) ? 1 : 0);
584         }
585
586         /* USBOTG Select (PCISKT or FrontPanel) */
587         if (gpio_cfg[board].usb_sel) {
588                 gpio_direction_output(gpio_cfg[board].usb_sel,
589                                       (hwconfig("usb_pcisel")) ? 1 : 0);
590         }
591
592         /*
593          * Configure DIO pinmux/padctl registers
594          * see IMX6DQRM/IMX6SDLRM IOMUXC_SW_PAD_CTL_PAD_* register definitions
595          */
596         for (i = 0; i < gpio_cfg[board].dio_num; i++) {
597                 struct dio_cfg *cfg = &gpio_cfg[board].dio_cfg[i];
598                 iomux_v3_cfg_t ctrl = DIO_PAD_CFG;
599                 unsigned int cputype = is_cpu_type(MXC_CPU_MX6Q) ? 0 : 1;
600
601                 if (!cfg->gpio_padmux[0] && !cfg->gpio_padmux[1])
602                         continue;
603                 sprintf(arg, "dio%d", i);
604                 if (!hwconfig(arg))
605                         continue;
606                 s = hwconfig_subarg(arg, "padctrl", &len);
607                 if (s) {
608                         ctrl = MUX_PAD_CTRL(hextoul(s, NULL)
609                                             & 0x1ffff) | MUX_MODE_SION;
610                 }
611                 if (hwconfig_subarg_cmp(arg, "mode", "gpio")) {
612                         if (!quiet) {
613                                 printf("DIO%d:  GPIO%d_IO%02d (gpio-%d)\n", i,
614                                        (cfg->gpio_param / 32) + 1,
615                                        cfg->gpio_param % 32,
616                                        cfg->gpio_param);
617                         }
618                         imx_iomux_v3_setup_pad(cfg->gpio_padmux[cputype] |
619                                                ctrl);
620                         gpio_requestf(cfg->gpio_param, "dio%d", i);
621                         gpio_direction_input(cfg->gpio_param);
622                 } else if (hwconfig_subarg_cmp(arg, "mode", "pwm")) {
623                         if (!cfg->pwm_param) {
624                                 printf("DIO%d:  Error: pwm config invalid\n",
625                                        i);
626                                 continue;
627                         }
628                         if (!quiet)
629                                 printf("DIO%d:  pwm%d\n", i, cfg->pwm_param);
630                         imx_iomux_v3_setup_pad(cfg->pwm_padmux[cputype] |
631                                                MUX_PAD_CTRL(ctrl));
632                 }
633         }
634
635         if (!quiet) {
636                 if (gpio_cfg[board].msata_en && is_cpu_type(MXC_CPU_MX6Q)) {
637                         printf("MSATA: %s\n", (hwconfig("msata") ?
638                                "enabled" : "disabled"));
639                 }
640                 if (gpio_cfg[board].rs232_en) {
641                         printf("RS232: %s\n", (hwconfig("rs232")) ?
642                                "enabled" : "disabled");
643                 }
644         }
645 }
646 /* late init */
647 int misc_init_r(void)
648 {
649         struct ventana_board_info *info = &ventana_info;
650         char buf[256];
651         int i;
652
653         /* set env vars based on EEPROM data */
654         if (ventana_info.model[0]) {
655                 char str[16], fdt[36];
656                 char *p;
657                 const char *cputype = "";
658
659                 /*
660                  * FDT name will be prefixed with CPU type.  Three versions
661                  * will be created each increasingly generic and bootloader
662                  * env scripts will try loading each from most specific to
663                  * least.
664                  */
665                 if (is_cpu_type(MXC_CPU_MX6Q) ||
666                     is_cpu_type(MXC_CPU_MX6D))
667                         cputype = "imx6q";
668                 else if (is_cpu_type(MXC_CPU_MX6DL) ||
669                          is_cpu_type(MXC_CPU_MX6SOLO))
670                         cputype = "imx6dl";
671                 env_set("soctype", cputype);
672                 if (8 << (ventana_info.nand_flash_size-1) >= 2048)
673                         env_set("flash_layout", "large");
674                 else
675                         env_set("flash_layout", "normal");
676                 memset(str, 0, sizeof(str));
677                 for (i = 0; i < (sizeof(str)-1) && info->model[i]; i++)
678                         str[i] = tolower(info->model[i]);
679                 env_set("model", str);
680                 if (!env_get("fdt_file")) {
681                         sprintf(fdt, "%s-%s.dtb", cputype, str);
682                         env_set("fdt_file", fdt);
683                 }
684                 p = strchr(str, '-');
685                 if (p) {
686                         *p++ = 0;
687
688                         env_set("model_base", str);
689                         sprintf(fdt, "%s-%s.dtb", cputype, str);
690                         env_set("fdt_file1", fdt);
691                         if (board_type != GW551x &&
692                             board_type != GW552x &&
693                             board_type != GW553x &&
694                             board_type != GW560x)
695                                 str[4] = 'x';
696                         str[5] = 'x';
697                         str[6] = 0;
698                         sprintf(fdt, "%s-%s.dtb", cputype, str);
699                         env_set("fdt_file2", fdt);
700                 }
701
702                 /* initialize env from EEPROM */
703                 if (test_bit(EECONFIG_ETH0, info->config) &&
704                     !env_get("ethaddr")) {
705                         eth_env_set_enetaddr("ethaddr", info->mac0);
706                 }
707                 if (test_bit(EECONFIG_ETH1, info->config) &&
708                     !env_get("eth1addr")) {
709                         eth_env_set_enetaddr("eth1addr", info->mac1);
710                 }
711
712                 /* board serial-number */
713                 sprintf(str, "%6d", info->serial);
714                 env_set("serial#", str);
715
716                 /* memory MB */
717                 sprintf(str, "%d", (int) (gd->ram_size >> 20));
718                 env_set("mem_mb", str);
719         }
720
721         /* Set a non-initialized hwconfig based on board configuration */
722         if (!strcmp(env_get("hwconfig"), "_UNKNOWN_")) {
723                 buf[0] = 0;
724                 if (gpio_cfg[board_type].rs232_en)
725                         strcat(buf, "rs232;");
726                 for (i = 0; i < gpio_cfg[board_type].dio_num; i++) {
727                         char buf1[32];
728                         sprintf(buf1, "dio%d:mode=gpio;", i);
729                         if (strlen(buf) + strlen(buf1) < sizeof(buf))
730                                 strcat(buf, buf1);
731                 }
732                 env_set("hwconfig", buf);
733         }
734
735         /* setup baseboard specific GPIO based on board and env */
736         setup_board_gpio(board_type, info);
737
738 #ifdef CONFIG_CMD_BMODE
739         add_board_boot_modes(board_boot_modes);
740 #endif
741
742         /* disable boot watchdog */
743         gsc_boot_wd_disable();
744
745         return 0;
746 }
747
748 #ifdef CONFIG_OF_BOARD_SETUP
749
750 static int ft_sethdmiinfmt(void *blob, char *mode)
751 {
752         int off;
753
754         if (!mode)
755                 return -EINVAL;
756
757         off = fdt_node_offset_by_compatible(blob, -1, "nxp,tda1997x");
758         if (off < 0)
759                 return off;
760
761         if (0 == strcasecmp(mode, "yuv422bt656")) {
762                 u8 cfg[] = { 0x00, 0x00, 0x00, 0x82, 0x81, 0x00,
763                              0x00, 0x00, 0x00 };
764                 mode = "422_ccir";
765                 fdt_setprop(blob, off, "vidout_fmt", mode, strlen(mode) + 1);
766                 fdt_setprop_u32(blob, off, "vidout_trc", 1);
767                 fdt_setprop_u32(blob, off, "vidout_blc", 1);
768                 fdt_setprop(blob, off, "vidout_portcfg", cfg, sizeof(cfg));
769                 printf("   set HDMI input mode to %s\n", mode);
770         } else if (0 == strcasecmp(mode, "yuv422smp")) {
771                 u8 cfg[] = { 0x00, 0x00, 0x00, 0x88, 0x87, 0x00,
772                              0x82, 0x81, 0x00 };
773                 mode = "422_smp";
774                 fdt_setprop(blob, off, "vidout_fmt", mode, strlen(mode) + 1);
775                 fdt_setprop_u32(blob, off, "vidout_trc", 0);
776                 fdt_setprop_u32(blob, off, "vidout_blc", 0);
777                 fdt_setprop(blob, off, "vidout_portcfg", cfg, sizeof(cfg));
778                 printf("   set HDMI input mode to %s\n", mode);
779         } else {
780                 return -EINVAL;
781         }
782
783         return 0;
784 }
785
786 #if defined(CONFIG_CMD_PCI)
787 #define PCI_ID(x) ( \
788         (PCI_BUS(x->devfn)<<16)| \
789         (PCI_DEV(x->devfn)<<11)| \
790         (PCI_FUNC(x->devfn)<<8) \
791         )
792 int fdt_add_pci_node(void *blob, int par, struct pci_dev *dev)
793 {
794         uint32_t reg[5];
795         char node[32];
796         int np;
797
798         sprintf(node, "pcie@%d,%d,%d", PCI_BUS(dev->devfn),
799                 PCI_DEV(dev->devfn), PCI_FUNC(dev->devfn));
800
801         np = fdt_subnode_offset(blob, par, node);
802         if (np >= 0)
803                 return np;
804         np = fdt_add_subnode(blob, par, node);
805         if (np < 0) {
806                 printf("   %s failed: no space\n", __func__);
807                 return np;
808         }
809
810         memset(reg, 0, sizeof(reg));
811         reg[0] = cpu_to_fdt32(PCI_ID(dev));
812         fdt_setprop(blob, np, "reg", reg, sizeof(reg));
813
814         return np;
815 }
816
817 /* build a path of nested PCI devs for all bridges passed through */
818 int fdt_add_pci_path(void *blob, struct pci_dev *dev)
819 {
820         struct pci_dev *bridges[MAX_PCI_DEVS];
821         int k, np;
822
823         /* build list of parents */
824         np = fdt_node_offset_by_compatible(blob, -1, "fsl,imx6q-pcie");
825         if (np < 0)
826                 return np;
827
828         k = 0;
829         while (dev) {
830                 bridges[k++] = dev;
831                 dev = dev->ppar;
832         };
833
834         /* now add them the to DT in reverse order */
835         while (k--) {
836                 np = fdt_add_pci_node(blob, np, bridges[k]);
837                 if (np < 0)
838                         break;
839         }
840
841         return np;
842 }
843
844 /*
845  * The GW16082 has a hardware errata errata such that it's
846  * INTA/B/C/D are mis-mapped to its four slots (slot12-15). Because
847  * of this normal PCI interrupt swizzling will not work so we will
848  * provide an irq-map via device-tree.
849  */
850 int fdt_fixup_gw16082(void *blob, int np, struct pci_dev *dev)
851 {
852         int len;
853         int host;
854         uint32_t imap_new[8*4*4];
855         const uint32_t *imap;
856         uint32_t irq[4];
857         uint32_t reg[4];
858         int i;
859
860         /* build irq-map based on host controllers map */
861         host = fdt_node_offset_by_compatible(blob, -1, "fsl,imx6q-pcie");
862         if (host < 0) {
863                 printf("   %s failed: missing host\n", __func__);
864                 return host;
865         }
866
867         /* use interrupt data from root complex's node */
868         imap = fdt_getprop(blob, host, "interrupt-map", &len);
869         if (!imap || len != 128) {
870                 printf("   %s failed: invalid interrupt-map\n",
871                        __func__);
872                 return -FDT_ERR_NOTFOUND;
873         }
874
875         /* obtain irq's of host controller in pin order */
876         for (i = 0; i < 4; i++)
877                 irq[(fdt32_to_cpu(imap[(i*8)+3])-1)%4] = imap[(i*8)+6];
878
879         /*
880          * determine number of swizzles necessary:
881          *   For each bridge we pass through we need to swizzle
882          *   the number of the slot we are on.
883          */
884         struct pci_dev *d;
885         int b;
886         b = 0;
887         d = dev->ppar;
888         while(d && d->ppar) {
889                 b += PCI_DEV(d->devfn);
890                 d = d->ppar;
891         }
892
893         /* create new irq mappings for slots12-15
894          * <skt> <idsel> <slot> <skt-inta> <skt-intb>
895          * J3    AD28    12     INTD      INTA
896          * J4    AD29    13     INTC      INTD
897          * J5    AD30    14     INTB      INTC
898          * J2    AD31    15     INTA      INTB
899          */
900         for (i = 0; i < 4; i++) {
901                 /* addr matches bus:dev:func */
902                 u32 addr = dev->busno << 16 | (12+i) << 11;
903
904                 /* default cells from root complex */
905                 memcpy(&imap_new[i*32], imap, 128);
906                 /* first cell is PCI device address (BDF) */
907                 imap_new[(i*32)+(0*8)+0] = cpu_to_fdt32(addr);
908                 imap_new[(i*32)+(1*8)+0] = cpu_to_fdt32(addr);
909                 imap_new[(i*32)+(2*8)+0] = cpu_to_fdt32(addr);
910                 imap_new[(i*32)+(3*8)+0] = cpu_to_fdt32(addr);
911                 /* third cell is pin */
912                 imap_new[(i*32)+(0*8)+3] = cpu_to_fdt32(1);
913                 imap_new[(i*32)+(1*8)+3] = cpu_to_fdt32(2);
914                 imap_new[(i*32)+(2*8)+3] = cpu_to_fdt32(3);
915                 imap_new[(i*32)+(3*8)+3] = cpu_to_fdt32(4);
916                 /* sixth cell is relative interrupt */
917                 imap_new[(i*32)+(0*8)+6] = irq[(15-(12+i)+b+0)%4];
918                 imap_new[(i*32)+(1*8)+6] = irq[(15-(12+i)+b+1)%4];
919                 imap_new[(i*32)+(2*8)+6] = irq[(15-(12+i)+b+2)%4];
920                 imap_new[(i*32)+(3*8)+6] = irq[(15-(12+i)+b+3)%4];
921         }
922         fdt_setprop(blob, np, "interrupt-map", imap_new,
923                     sizeof(imap_new));
924         reg[0] = cpu_to_fdt32(0xfff00);
925         reg[1] = 0;
926         reg[2] = 0;
927         reg[3] = cpu_to_fdt32(0x7);
928         fdt_setprop(blob, np, "interrupt-map-mask", reg, sizeof(reg));
929         fdt_setprop_cell(blob, np, "#interrupt-cells", 1);
930         fdt_setprop_string(blob, np, "device_type", "pci");
931         fdt_setprop_cell(blob, np, "#address-cells", 3);
932         fdt_setprop_cell(blob, np, "#size-cells", 2);
933         printf("   Added custom interrupt-map for GW16082\n");
934
935         return 0;
936 }
937
938 /* The sky2 GigE MAC obtains it's MAC addr from device-tree by default */
939 int fdt_fixup_sky2(void *blob, int np, struct pci_dev *dev)
940 {
941         char *tmp, *end;
942         char mac[16];
943         unsigned char mac_addr[6];
944         int j;
945
946         sprintf(mac, "eth1addr");
947         tmp = env_get(mac);
948         if (tmp) {
949                 for (j = 0; j < 6; j++) {
950                         mac_addr[j] = tmp ?
951                                       hextoul(tmp, &end) : 0;
952                         if (tmp)
953                                 tmp = (*end) ? end+1 : end;
954                 }
955                 fdt_setprop(blob, np, "local-mac-address", mac_addr,
956                             sizeof(mac_addr));
957                 printf("   Added mac addr for eth1\n");
958                 return 0;
959         }
960
961         return -1;
962 }
963
964 /*
965  * PCI DT nodes must be nested therefore if we need to apply a DT fixup
966  * we will walk the PCI bus and add bridge nodes up to the device receiving
967  * the fixup.
968  */
969 void ft_board_pci_fixup(void *blob, struct bd_info *bd)
970 {
971         int i, np;
972         struct pci_dev *dev;
973
974         for (i = 0; i < pci_devno; i++) {
975                 dev = &pci_devs[i];
976
977                 /*
978                  * The GW16082 consists of a TI XIO2001 PCIe-to-PCI bridge and
979                  * an EEPROM at i2c1-0x50.
980                  */
981                 if ((dev->vendor == PCI_VENDOR_ID_TI) &&
982                     (dev->device == 0x8240) &&
983                     i2c_get_dev(1, 0x50))
984                 {
985                         np = fdt_add_pci_path(blob, dev);
986                         if (np > 0)
987                                 fdt_fixup_gw16082(blob, np, dev);
988                 }
989
990                 /* ethernet1 mac address */
991                 else if ((dev->vendor == PCI_VENDOR_ID_MARVELL) &&
992                          (dev->device == 0x4380))
993                 {
994                         np = fdt_add_pci_path(blob, dev);
995                         if (np > 0)
996                                 fdt_fixup_sky2(blob, np, dev);
997                 }
998         }
999 }
1000 #endif /* if defined(CONFIG_CMD_PCI) */
1001
1002 #define WDOG1_ADDR      0x20bc000
1003 #define WDOG2_ADDR      0x20c0000
1004 #define GPIO3_ADDR      0x20a4000
1005 #define USDHC3_ADDR     0x2198000
1006 static void ft_board_wdog_fixup(void *blob, phys_addr_t addr)
1007 {
1008         int off = fdt_node_offset_by_compat_reg(blob, "fsl,imx6q-wdt", addr);
1009
1010         if (off) {
1011                 fdt_delprop(blob, off, "ext-reset-output");
1012                 fdt_delprop(blob, off, "fsl,ext-reset-output");
1013         }
1014 }
1015
1016 void ft_early_fixup(void *blob, int board_type)
1017 {
1018         struct ventana_board_info *info = &ventana_info;
1019         char rev = 0;
1020         int i;
1021
1022         /* determine board revision */
1023         for (i = sizeof(ventana_info.model) - 1; i > 0; i--) {
1024                 if (ventana_info.model[i] >= 'A') {
1025                         rev = ventana_info.model[i];
1026                         break;
1027                 }
1028         }
1029
1030         /*
1031          * Board model specific fixups
1032          */
1033         switch (board_type) {
1034         case GW51xx:
1035                 /*
1036                  * disable wdog node for GW51xx-A/B to work around
1037                  * errata causing wdog timer to be unreliable.
1038                  */
1039                 if (rev >= 'A' && rev < 'C') {
1040                         i = fdt_node_offset_by_compat_reg(blob, "fsl,imx6q-wdt",
1041                                                           WDOG1_ADDR);
1042                         if (i)
1043                                 fdt_status_disabled(blob, i);
1044                 }
1045
1046                 /* GW51xx-E adds WDOG1_B external reset */
1047                 if (rev < 'E')
1048                         ft_board_wdog_fixup(blob, WDOG1_ADDR);
1049                 break;
1050
1051         case GW52xx:
1052                 /* GW522x Uses GPIO3_IO23 instead of GPIO1_IO29 */
1053                 if (info->model[4] == '2') {
1054                         u32 handle = 0;
1055                         u32 *range = NULL;
1056
1057                         i = fdt_node_offset_by_compatible(blob, -1,
1058                                                           "fsl,imx6q-pcie");
1059                         if (i)
1060                                 range = (u32 *)fdt_getprop(blob, i,
1061                                                            "reset-gpio", NULL);
1062
1063                         if (range) {
1064                                 i = fdt_node_offset_by_compat_reg(blob,
1065                                                                   "fsl,imx6q-gpio", GPIO3_ADDR);
1066                                 if (i)
1067                                         handle = fdt_get_phandle(blob, i);
1068                                 if (handle) {
1069                                         range[0] = cpu_to_fdt32(handle);
1070                                         range[1] = cpu_to_fdt32(23);
1071                                 }
1072                         }
1073
1074                         /* these have broken usd_vsel */
1075                         if (strstr((const char *)info->model, "SP318-B") ||
1076                             strstr((const char *)info->model, "SP331-B"))
1077                                 gpio_cfg[board_type].usd_vsel = 0;
1078
1079                         /* GW522x-B adds WDOG1_B external reset */
1080                         if (rev < 'B')
1081                                 ft_board_wdog_fixup(blob, WDOG1_ADDR);
1082                 }
1083
1084                 /* GW520x-E adds WDOG1_B external reset */
1085                 else if (info->model[4] == '0' && rev < 'E')
1086                         ft_board_wdog_fixup(blob, WDOG1_ADDR);
1087                 break;
1088
1089         case GW53xx:
1090                 /* GW53xx-E adds WDOG1_B external reset */
1091                 if (rev < 'E')
1092                         ft_board_wdog_fixup(blob, WDOG1_ADDR);
1093
1094                 /* GW53xx-G has an adv7280 instead of an adv7180 */
1095                 else if (rev > 'F') {
1096                         i = fdt_node_offset_by_compatible(blob, -1, "adi,adv7180");
1097                         if (i) {
1098                                 fdt_setprop_string(blob, i, "compatible", "adi,adv7280");
1099                                 fdt_setprop_empty(blob, i, "adv,force-bt656-4");
1100                         }
1101                 }
1102                 break;
1103
1104         case GW54xx:
1105                 /*
1106                  * disable serial2 node for GW54xx for compatibility with older
1107                  * 3.10.x kernel that improperly had this node enabled in the DT
1108                  */
1109                 fdt_set_status_by_alias(blob, "serial2", FDT_STATUS_DISABLED);
1110
1111                 /* GW54xx-E adds WDOG2_B external reset */
1112                 if (rev < 'E')
1113                         ft_board_wdog_fixup(blob, WDOG2_ADDR);
1114
1115                 /* GW54xx-G has an adv7280 instead of an adv7180 */
1116                 else if (rev > 'F') {
1117                         i = fdt_node_offset_by_compatible(blob, -1, "adi,adv7180");
1118                         if (i) {
1119                                 fdt_setprop_string(blob, i, "compatible", "adi,adv7280");
1120                                 fdt_setprop_empty(blob, i, "adv,force-bt656-4");
1121                         }
1122                 }
1123                 break;
1124
1125         case GW551x:
1126                 /* GW551x-C adds WDOG1_B external reset */
1127                 if (rev < 'C')
1128                         ft_board_wdog_fixup(blob, WDOG1_ADDR);
1129                 break;
1130         case GW5901:
1131         case GW5902:
1132                 /* GW5901/GW5901 revB adds WDOG1_B as an external reset */
1133                 if (rev < 'B')
1134                         ft_board_wdog_fixup(blob, WDOG1_ADDR);
1135                 break;
1136         }
1137
1138         /* remove no-1-8-v if UHS-I support is present */
1139         if (gpio_cfg[board_type].usd_vsel) {
1140                 debug("Enabling UHS-I support\n");
1141                 i = fdt_node_offset_by_compat_reg(blob, "fsl,imx6q-usdhc",
1142                                                   USDHC3_ADDR);
1143                 if (i)
1144                         fdt_delprop(blob, i, "no-1-8-v");
1145         }
1146 }
1147
1148 /*
1149  * called prior to booting kernel or by 'fdt boardsetup' command
1150  *
1151  * unless 'fdt_noauto' env var is set we will update the following in the DTB:
1152  *  - mtd partitions based on mtdparts/mtdids env
1153  *  - system-serial (board serial num from EEPROM)
1154  *  - board (full model from EEPROM)
1155  *  - peripherals removed from DTB if not loaded on board (per EEPROM config)
1156  */
1157 #define PWM0_ADDR       0x2080000
1158 int ft_board_setup(void *blob, struct bd_info *bd)
1159 {
1160         struct ventana_board_info *info = &ventana_info;
1161         struct ventana_eeprom_config *cfg;
1162         static const struct node_info nand_nodes[] = {
1163                 { "sst,w25q256",          MTD_DEV_TYPE_NOR, },  /* SPI flash */
1164                 { "fsl,imx6q-gpmi-nand",  MTD_DEV_TYPE_NAND, }, /* NAND flash */
1165         };
1166         const char *model = env_get("model");
1167         const char *display = env_get("display");
1168         int i;
1169         char rev = 0;
1170
1171         /* determine board revision */
1172         for (i = sizeof(ventana_info.model) - 1; i > 0; i--) {
1173                 if (ventana_info.model[i] >= 'A') {
1174                         rev = ventana_info.model[i];
1175                         break;
1176                 }
1177         }
1178
1179         if (env_get("fdt_noauto")) {
1180                 puts("   Skiping ft_board_setup (fdt_noauto defined)\n");
1181                 return 0;
1182         }
1183
1184         /* Update MTD partition nodes using info from mtdparts env var */
1185         puts("   Updating MTD partitions...\n");
1186         fdt_fixup_mtdparts(blob, nand_nodes, ARRAY_SIZE(nand_nodes));
1187
1188         /* Update display timings from display env var */
1189         if (display) {
1190                 if (fdt_fixup_display(blob, fdt_get_alias(blob, "lvds0"),
1191                                       display) >= 0)
1192                         printf("   Set display timings for %s...\n", display);
1193         }
1194
1195         printf("   Adjusting FDT per EEPROM for %s...\n", model);
1196
1197         /* board serial number */
1198         fdt_setprop(blob, 0, "system-serial", env_get("serial#"),
1199                     strlen(env_get("serial#")) + 1);
1200
1201         /* board (model contains model from device-tree) */
1202         fdt_setprop(blob, 0, "board", info->model,
1203                     strlen((const char *)info->model) + 1);
1204
1205         /* set desired digital video capture format */
1206         ft_sethdmiinfmt(blob, env_get("hdmiinfmt"));
1207
1208         /* early board/revision ft fixups */
1209         ft_early_fixup(blob, board_type);
1210
1211         /* Configure DIO */
1212         for (i = 0; i < gpio_cfg[board_type].dio_num; i++) {
1213                 struct dio_cfg *cfg = &gpio_cfg[board_type].dio_cfg[i];
1214                 char arg[10];
1215
1216                 sprintf(arg, "dio%d", i);
1217                 if (!hwconfig(arg))
1218                         continue;
1219                 if (hwconfig_subarg_cmp(arg, "mode", "pwm") && cfg->pwm_param)
1220                 {
1221                         phys_addr_t addr;
1222                         int off;
1223
1224                         printf("   Enabling pwm%d for DIO%d\n",
1225                                cfg->pwm_param, i);
1226                         addr = PWM0_ADDR + (0x4000 * (cfg->pwm_param - 1));
1227                         off = fdt_node_offset_by_compat_reg(blob,
1228                                                             "fsl,imx6q-pwm",
1229                                                             addr);
1230                         if (off)
1231                                 fdt_status_okay(blob, off);
1232                 }
1233         }
1234
1235 #if defined(CONFIG_CMD_PCI)
1236         if (!env_get("nopcifixup"))
1237                 ft_board_pci_fixup(blob, bd);
1238 #endif
1239
1240         /*
1241          * remove reset gpio control as we configure the PHY registers
1242          * for internal delay, LED config, and clock config in the bootloader
1243          */
1244         i = fdt_node_offset_by_compatible(blob, -1, "fsl,imx6q-fec");
1245         if (i)
1246                 fdt_delprop(blob, i, "phy-reset-gpios");
1247
1248         /*
1249          * Peripheral Config:
1250          *  remove nodes by alias path if EEPROM config tells us the
1251          *  peripheral is not loaded on the board.
1252          */
1253         if (env_get("fdt_noconfig")) {
1254                 puts("   Skiping periperhal config (fdt_noconfig defined)\n");
1255                 return 0;
1256         }
1257         cfg = econfig;
1258         while (cfg->name) {
1259                 if (!test_bit(cfg->bit, info->config)) {
1260                         fdt_del_node_and_alias(blob, cfg->dtalias ?
1261                                                cfg->dtalias : cfg->name);
1262                 }
1263                 cfg++;
1264         }
1265
1266         return 0;
1267 }
1268 #endif /* CONFIG_OF_BOARD_SETUP */
1269
1270 int board_mmc_get_env_dev(int devno)
1271 {
1272         return devno;
1273 }