2 * Copyright (C) 2013 Gateworks Corporation
4 * Author: Tim Harvey <tharvey@gateworks.com>
6 * SPDX-License-Identifier: GPL-2.0+
11 #include <asm/arch/clock.h>
12 #include <asm/arch/imx-regs.h>
13 #include <asm/arch/iomux.h>
14 #include <asm/arch/mx6-pins.h>
15 #include <asm/arch/mxc_hdmi.h>
16 #include <asm/arch/crm_regs.h>
17 #include <asm/arch/sys_proto.h>
19 #include <asm/imx-common/iomux-v3.h>
20 #include <asm/imx-common/mxc_i2c.h>
21 #include <asm/imx-common/boot_mode.h>
22 #include <asm/imx-common/sata.h>
23 #include <asm/imx-common/video.h>
24 #include <jffs2/load_kernel.h>
27 #include <linux/ctype.h>
28 #include <fdt_support.h>
29 #include <fsl_esdhc.h>
34 #include <power/pmic.h>
35 #include <power/ltc3676_pmic.h>
36 #include <power/pfuze100_pmic.h>
37 #include <fdt_support.h>
38 #include <jffs2/load_kernel.h>
39 #include <spi_flash.h>
42 #include "ventana_eeprom.h"
44 DECLARE_GLOBAL_DATA_PTR;
46 /* GPIO's common to all baseboards */
47 #define GP_PHY_RST IMX_GPIO_NR(1, 30)
48 #define GP_USB_OTG_PWR IMX_GPIO_NR(3, 22)
49 #define GP_SD3_CD IMX_GPIO_NR(7, 0)
50 #define GP_RS232_EN IMX_GPIO_NR(2, 11)
51 #define GP_MSATA_SEL IMX_GPIO_NR(2, 8)
57 #define UART_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE | \
58 PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \
59 PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST | PAD_CTL_HYS)
61 #define USDHC_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE | \
62 PAD_CTL_PUS_47K_UP | PAD_CTL_SPEED_LOW | \
63 PAD_CTL_DSE_80ohm | PAD_CTL_SRE_FAST | PAD_CTL_HYS)
65 #define ENET_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE | \
66 PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \
67 PAD_CTL_DSE_40ohm | PAD_CTL_HYS)
69 #define SPI_PAD_CTRL (PAD_CTL_HYS | \
70 PAD_CTL_PUS_100K_DOWN | PAD_CTL_SPEED_MED | \
71 PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST)
73 #define DIO_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE | \
74 PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \
75 PAD_CTL_DSE_34ohm | PAD_CTL_HYS | PAD_CTL_SRE_FAST)
77 #define I2C_PAD_CTRL (PAD_CTL_PUS_100K_UP | \
78 PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS | \
79 PAD_CTL_ODE | PAD_CTL_SRE_FAST)
82 * EEPROM board info struct populated by read_eeprom so that we only have to
85 static struct ventana_board_info ventana_info;
88 GW54proto, /* original GW5400-A prototype */
98 /* UART1: Function varies per baseboard */
99 iomux_v3_cfg_t const uart1_pads[] = {
100 MX6_PAD_SD3_DAT6__UART1_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL),
101 MX6_PAD_SD3_DAT7__UART1_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL),
104 /* UART2: Serial Console */
105 iomux_v3_cfg_t const uart2_pads[] = {
106 MX6_PAD_SD4_DAT7__UART2_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL),
107 MX6_PAD_SD4_DAT4__UART2_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL),
110 #define PC MUX_PAD_CTRL(I2C_PAD_CTRL)
113 struct i2c_pads_info i2c_pad_info0 = {
115 .i2c_mode = MX6_PAD_EIM_D21__I2C1_SCL | PC,
116 .gpio_mode = MX6_PAD_EIM_D21__GPIO3_IO21 | PC,
117 .gp = IMX_GPIO_NR(3, 21)
120 .i2c_mode = MX6_PAD_EIM_D28__I2C1_SDA | PC,
121 .gpio_mode = MX6_PAD_EIM_D28__GPIO3_IO28 | PC,
122 .gp = IMX_GPIO_NR(3, 28)
126 /* I2C2: PMIC/PCIe Switch/PCIe Clock/Mezz */
127 struct i2c_pads_info i2c_pad_info1 = {
129 .i2c_mode = MX6_PAD_KEY_COL3__I2C2_SCL | PC,
130 .gpio_mode = MX6_PAD_KEY_COL3__GPIO4_IO12 | PC,
131 .gp = IMX_GPIO_NR(4, 12)
134 .i2c_mode = MX6_PAD_KEY_ROW3__I2C2_SDA | PC,
135 .gpio_mode = MX6_PAD_KEY_ROW3__GPIO4_IO13 | PC,
136 .gp = IMX_GPIO_NR(4, 13)
140 /* I2C3: Misc/Expansion */
141 struct i2c_pads_info i2c_pad_info2 = {
143 .i2c_mode = MX6_PAD_GPIO_3__I2C3_SCL | PC,
144 .gpio_mode = MX6_PAD_GPIO_3__GPIO1_IO03 | PC,
145 .gp = IMX_GPIO_NR(1, 3)
148 .i2c_mode = MX6_PAD_GPIO_6__I2C3_SDA | PC,
149 .gpio_mode = MX6_PAD_GPIO_6__GPIO1_IO06 | PC,
150 .gp = IMX_GPIO_NR(1, 6)
155 iomux_v3_cfg_t const usdhc3_pads[] = {
156 MX6_PAD_SD3_CLK__SD3_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL),
157 MX6_PAD_SD3_CMD__SD3_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL),
158 MX6_PAD_SD3_DAT0__SD3_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
159 MX6_PAD_SD3_DAT1__SD3_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
160 MX6_PAD_SD3_DAT2__SD3_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
161 MX6_PAD_SD3_DAT3__SD3_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
162 MX6_PAD_SD3_DAT5__GPIO7_IO00 | MUX_PAD_CTRL(NO_PAD_CTRL), /* CD */
166 iomux_v3_cfg_t const enet_pads[] = {
167 MX6_PAD_ENET_MDIO__ENET_MDIO | MUX_PAD_CTRL(ENET_PAD_CTRL),
168 MX6_PAD_ENET_MDC__ENET_MDC | MUX_PAD_CTRL(ENET_PAD_CTRL),
169 MX6_PAD_RGMII_TXC__RGMII_TXC | MUX_PAD_CTRL(ENET_PAD_CTRL),
170 MX6_PAD_RGMII_TD0__RGMII_TD0 | MUX_PAD_CTRL(ENET_PAD_CTRL),
171 MX6_PAD_RGMII_TD1__RGMII_TD1 | MUX_PAD_CTRL(ENET_PAD_CTRL),
172 MX6_PAD_RGMII_TD2__RGMII_TD2 | MUX_PAD_CTRL(ENET_PAD_CTRL),
173 MX6_PAD_RGMII_TD3__RGMII_TD3 | MUX_PAD_CTRL(ENET_PAD_CTRL),
174 MX6_PAD_RGMII_TX_CTL__RGMII_TX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL),
175 MX6_PAD_ENET_REF_CLK__ENET_TX_CLK | MUX_PAD_CTRL(ENET_PAD_CTRL),
176 MX6_PAD_RGMII_RXC__RGMII_RXC | MUX_PAD_CTRL(ENET_PAD_CTRL),
177 MX6_PAD_RGMII_RD0__RGMII_RD0 | MUX_PAD_CTRL(ENET_PAD_CTRL),
178 MX6_PAD_RGMII_RD1__RGMII_RD1 | MUX_PAD_CTRL(ENET_PAD_CTRL),
179 MX6_PAD_RGMII_RD2__RGMII_RD2 | MUX_PAD_CTRL(ENET_PAD_CTRL),
180 MX6_PAD_RGMII_RD3__RGMII_RD3 | MUX_PAD_CTRL(ENET_PAD_CTRL),
181 MX6_PAD_RGMII_RX_CTL__RGMII_RX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL),
183 MX6_PAD_ENET_TXD0__GPIO1_IO30 | MUX_PAD_CTRL(NO_PAD_CTRL),
187 iomux_v3_cfg_t const nfc_pads[] = {
188 MX6_PAD_NANDF_CLE__NAND_CLE | MUX_PAD_CTRL(NO_PAD_CTRL),
189 MX6_PAD_NANDF_ALE__NAND_ALE | MUX_PAD_CTRL(NO_PAD_CTRL),
190 MX6_PAD_NANDF_WP_B__NAND_WP_B | MUX_PAD_CTRL(NO_PAD_CTRL),
191 MX6_PAD_NANDF_RB0__NAND_READY_B | MUX_PAD_CTRL(NO_PAD_CTRL),
192 MX6_PAD_NANDF_CS0__NAND_CE0_B | MUX_PAD_CTRL(NO_PAD_CTRL),
193 MX6_PAD_SD4_CMD__NAND_RE_B | MUX_PAD_CTRL(NO_PAD_CTRL),
194 MX6_PAD_SD4_CLK__NAND_WE_B | MUX_PAD_CTRL(NO_PAD_CTRL),
195 MX6_PAD_NANDF_D0__NAND_DATA00 | MUX_PAD_CTRL(NO_PAD_CTRL),
196 MX6_PAD_NANDF_D1__NAND_DATA01 | MUX_PAD_CTRL(NO_PAD_CTRL),
197 MX6_PAD_NANDF_D2__NAND_DATA02 | MUX_PAD_CTRL(NO_PAD_CTRL),
198 MX6_PAD_NANDF_D3__NAND_DATA03 | MUX_PAD_CTRL(NO_PAD_CTRL),
199 MX6_PAD_NANDF_D4__NAND_DATA04 | MUX_PAD_CTRL(NO_PAD_CTRL),
200 MX6_PAD_NANDF_D5__NAND_DATA05 | MUX_PAD_CTRL(NO_PAD_CTRL),
201 MX6_PAD_NANDF_D6__NAND_DATA06 | MUX_PAD_CTRL(NO_PAD_CTRL),
202 MX6_PAD_NANDF_D7__NAND_DATA07 | MUX_PAD_CTRL(NO_PAD_CTRL),
205 #ifdef CONFIG_CMD_NAND
206 static void setup_gpmi_nand(void)
208 struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
210 /* config gpmi nand iomux */
211 imx_iomux_v3_setup_multiple_pads(nfc_pads, ARRAY_SIZE(nfc_pads));
213 /* config gpmi and bch clock to 100 MHz */
214 clrsetbits_le32(&mxc_ccm->cs2cdr,
215 MXC_CCM_CS2CDR_ENFC_CLK_PODF_MASK |
216 MXC_CCM_CS2CDR_ENFC_CLK_PRED_MASK |
217 MXC_CCM_CS2CDR_ENFC_CLK_SEL_MASK,
218 MXC_CCM_CS2CDR_ENFC_CLK_PODF(0) |
219 MXC_CCM_CS2CDR_ENFC_CLK_PRED(3) |
220 MXC_CCM_CS2CDR_ENFC_CLK_SEL(3));
222 /* enable gpmi and bch clock gating */
223 setbits_le32(&mxc_ccm->CCGR4,
224 MXC_CCM_CCGR4_RAWNAND_U_BCH_INPUT_APB_MASK |
225 MXC_CCM_CCGR4_RAWNAND_U_GPMI_BCH_INPUT_BCH_MASK |
226 MXC_CCM_CCGR4_RAWNAND_U_GPMI_BCH_INPUT_GPMI_IO_MASK |
227 MXC_CCM_CCGR4_RAWNAND_U_GPMI_INPUT_APB_MASK |
228 MXC_CCM_CCGR4_PL301_MX6QPER1_BCH_OFFSET);
230 /* enable apbh clock gating */
231 setbits_le32(&mxc_ccm->CCGR0, MXC_CCM_CCGR0_APBHDMA_MASK);
235 static void setup_iomux_enet(void)
237 imx_iomux_v3_setup_multiple_pads(enet_pads, ARRAY_SIZE(enet_pads));
239 /* toggle PHY_RST# */
240 gpio_direction_output(GP_PHY_RST, 0);
242 gpio_set_value(GP_PHY_RST, 1);
245 static void setup_iomux_uart(void)
247 imx_iomux_v3_setup_multiple_pads(uart1_pads, ARRAY_SIZE(uart1_pads));
248 imx_iomux_v3_setup_multiple_pads(uart2_pads, ARRAY_SIZE(uart2_pads));
251 #ifdef CONFIG_USB_EHCI_MX6
252 iomux_v3_cfg_t const usb_pads[] = {
253 MX6_PAD_GPIO_1__USB_OTG_ID | MUX_PAD_CTRL(DIO_PAD_CTRL),
254 MX6_PAD_KEY_COL4__USB_OTG_OC | MUX_PAD_CTRL(DIO_PAD_CTRL),
255 MX6_PAD_EIM_D22__GPIO3_IO22 | MUX_PAD_CTRL(DIO_PAD_CTRL), /* OTG PWR */
258 int board_ehci_hcd_init(int port)
260 struct ventana_board_info *info = &ventana_info;
262 imx_iomux_v3_setup_multiple_pads(usb_pads, ARRAY_SIZE(usb_pads));
264 /* Reset USB HUB (present on GW54xx/GW53xx) */
265 switch (info->model[3]) {
266 case '3': /* GW53xx */
267 imx_iomux_v3_setup_pad(MX6_PAD_GPIO_9__GPIO1_IO09|
268 MUX_PAD_CTRL(NO_PAD_CTRL));
269 gpio_direction_output(IMX_GPIO_NR(1, 9), 0);
271 gpio_set_value(IMX_GPIO_NR(1, 9), 1);
273 case '4': /* GW54xx */
274 imx_iomux_v3_setup_pad(MX6_PAD_SD1_DAT0__GPIO1_IO16 |
275 MUX_PAD_CTRL(NO_PAD_CTRL));
276 gpio_direction_output(IMX_GPIO_NR(1, 16), 0);
278 gpio_set_value(IMX_GPIO_NR(1, 16), 1);
285 int board_ehci_power(int port, int on)
289 gpio_set_value(GP_USB_OTG_PWR, on);
292 #endif /* CONFIG_USB_EHCI_MX6 */
294 #ifdef CONFIG_FSL_ESDHC
295 struct fsl_esdhc_cfg usdhc_cfg = { USDHC3_BASE_ADDR };
297 int board_mmc_getcd(struct mmc *mmc)
300 gpio_direction_input(GP_SD3_CD);
301 return !gpio_get_value(GP_SD3_CD);
304 int board_mmc_init(bd_t *bis)
306 /* Only one USDHC controller on Ventana */
307 imx_iomux_v3_setup_multiple_pads(usdhc3_pads, ARRAY_SIZE(usdhc3_pads));
308 usdhc_cfg.sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
309 usdhc_cfg.max_bus_width = 4;
311 return fsl_esdhc_initialize(bis, &usdhc_cfg);
313 #endif /* CONFIG_FSL_ESDHC */
315 #ifdef CONFIG_MXC_SPI
316 iomux_v3_cfg_t const ecspi1_pads[] = {
318 MX6_PAD_EIM_D19__GPIO3_IO19 | MUX_PAD_CTRL(SPI_PAD_CTRL),
319 MX6_PAD_EIM_D17__ECSPI1_MISO | MUX_PAD_CTRL(SPI_PAD_CTRL),
320 MX6_PAD_EIM_D18__ECSPI1_MOSI | MUX_PAD_CTRL(SPI_PAD_CTRL),
321 MX6_PAD_EIM_D16__ECSPI1_SCLK | MUX_PAD_CTRL(SPI_PAD_CTRL),
324 static void setup_spi(void)
326 gpio_direction_output(CONFIG_SF_DEFAULT_CS, 1);
327 imx_iomux_v3_setup_multiple_pads(ecspi1_pads,
328 ARRAY_SIZE(ecspi1_pads));
332 /* configure eth0 PHY board-specific LED behavior */
333 int board_phy_config(struct phy_device *phydev)
338 if (phydev->phy_id == 0x1410dd1) {
340 * Page 3, Register 16: LED[2:0] Function Control Register
341 * LED[0] (SPD:Amber) R16_3.3:0 to 0111: on-GbE link
342 * LED[1] (LNK:Green) R16_3.7:4 to 0001: on-link, blink-activity
344 phy_write(phydev, MDIO_DEVAD_NONE, 22, 3);
345 val = phy_read(phydev, MDIO_DEVAD_NONE, 16);
348 phy_write(phydev, MDIO_DEVAD_NONE, 16, val);
349 phy_write(phydev, MDIO_DEVAD_NONE, 22, 0);
352 if (phydev->drv->config)
353 phydev->drv->config(phydev);
358 int board_eth_init(bd_t *bis)
362 #ifdef CONFIG_FEC_MXC
367 /* For otg ethernet*/
368 usb_eth_initialize(bis);
374 #if defined(CONFIG_VIDEO_IPUV3)
376 static void enable_hdmi(struct display_info_t const *dev)
378 imx_enable_hdmi_phy();
381 static int detect_i2c(struct display_info_t const *dev)
383 return i2c_set_bus_num(dev->bus) == 0 &&
384 i2c_probe(dev->addr) == 0;
387 static void enable_lvds(struct display_info_t const *dev)
389 struct iomuxc *iomux = (struct iomuxc *)
392 /* set CH0 data width to 24bit (IOMUXC_GPR2:5 0=18bit, 1=24bit) */
393 u32 reg = readl(&iomux->gpr[2]);
394 reg |= IOMUXC_GPR2_DATA_WIDTH_CH0_24BIT;
395 writel(reg, &iomux->gpr[2]);
397 /* Enable Backlight */
398 imx_iomux_v3_setup_pad(MX6_PAD_SD1_CMD__GPIO1_IO18 |
399 MUX_PAD_CTRL(NO_PAD_CTRL));
400 gpio_direction_output(IMX_GPIO_NR(1, 18), 1);
403 struct display_info_t const displays[] = {{
407 .pixfmt = IPU_PIX_FMT_RGB24,
408 .detect = detect_hdmi,
409 .enable = enable_hdmi,
423 .vmode = FB_VMODE_NONINTERLACED
425 /* Freescale MXC-LVDS1: HannStar HSD100PXN1-A00 w/ egalx_ts cont */
428 .pixfmt = IPU_PIX_FMT_LVDS666,
429 .detect = detect_i2c,
430 .enable = enable_lvds,
432 .name = "Hannstar-XGA",
444 .vmode = FB_VMODE_NONINTERLACED
446 size_t display_count = ARRAY_SIZE(displays);
448 static void setup_display(void)
450 struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
451 struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR;
456 /* Turn on LDB0,IPU,IPU DI0 clocks */
457 reg = __raw_readl(&mxc_ccm->CCGR3);
458 reg |= MXC_CCM_CCGR3_LDB_DI0_MASK;
459 writel(reg, &mxc_ccm->CCGR3);
461 /* set LDB0, LDB1 clk select to 011/011 */
462 reg = readl(&mxc_ccm->cs2cdr);
463 reg &= ~(MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_MASK
464 |MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_MASK);
465 reg |= (3<<MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_OFFSET)
466 |(3<<MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_OFFSET);
467 writel(reg, &mxc_ccm->cs2cdr);
469 reg = readl(&mxc_ccm->cscmr2);
470 reg |= MXC_CCM_CSCMR2_LDB_DI0_IPU_DIV;
471 writel(reg, &mxc_ccm->cscmr2);
473 reg = readl(&mxc_ccm->chsccdr);
474 reg |= (CHSCCDR_CLK_SEL_LDB_DI0
475 <<MXC_CCM_CHSCCDR_IPU1_DI0_CLK_SEL_OFFSET);
476 writel(reg, &mxc_ccm->chsccdr);
478 reg = IOMUXC_GPR2_BGREF_RRMODE_EXTERNAL_RES
479 |IOMUXC_GPR2_DI1_VS_POLARITY_ACTIVE_HIGH
480 |IOMUXC_GPR2_DI0_VS_POLARITY_ACTIVE_LOW
481 |IOMUXC_GPR2_BIT_MAPPING_CH1_SPWG
482 |IOMUXC_GPR2_DATA_WIDTH_CH1_18BIT
483 |IOMUXC_GPR2_BIT_MAPPING_CH0_SPWG
484 |IOMUXC_GPR2_DATA_WIDTH_CH0_18BIT
485 |IOMUXC_GPR2_LVDS_CH1_MODE_DISABLED
486 |IOMUXC_GPR2_LVDS_CH0_MODE_ENABLED_DI0;
487 writel(reg, &iomux->gpr[2]);
489 reg = readl(&iomux->gpr[3]);
490 reg = (reg & ~IOMUXC_GPR3_LVDS0_MUX_CTL_MASK)
491 | (IOMUXC_GPR3_MUX_SRC_IPU1_DI0
492 <<IOMUXC_GPR3_LVDS0_MUX_CTL_OFFSET);
493 writel(reg, &iomux->gpr[3]);
495 /* Backlight CABEN on LVDS connector */
496 imx_iomux_v3_setup_pad(MX6_PAD_SD2_CLK__GPIO1_IO10 |
497 MUX_PAD_CTRL(NO_PAD_CTRL));
498 gpio_direction_output(IMX_GPIO_NR(1, 10), 0);
500 #endif /* CONFIG_VIDEO_IPUV3 */
502 /* read ventana EEPROM, check for validity, and return baseboard type */
510 struct ventana_board_info *info = &ventana_info;
511 unsigned char *buf = (unsigned char *)&ventana_info;
513 memset(info, 0, sizeof(ventana_info));
516 * On a board with a missing/depleted backup battery for GSC, the
517 * board may be ready to probe the GSC before its firmware is
518 * running. We will wait here indefinately for the GSC/EEPROM.
521 if (0 == i2c_set_bus_num(I2C_GSC) &&
522 0 == i2c_probe(GSC_EEPROM_ADDR))
527 /* read eeprom config section */
528 if (gsc_i2c_read(GSC_EEPROM_ADDR, 0x00, 1, buf, sizeof(ventana_info))) {
529 puts("EEPROM: Failed to read EEPROM\n");
535 if (info->model[0] != 'G' || info->model[1] != 'W') {
536 puts("EEPROM: Invalid Model in EEPROM\n");
541 /* validate checksum */
542 for (chksum = 0, i = 0; i < sizeof(*info)-2; i++)
544 if ((info->chksum[0] != chksum>>8) ||
545 (info->chksum[1] != (chksum&0xff))) {
546 puts("EEPROM: Failed EEPROM checksum\n");
551 /* original GW5400-A prototype */
552 baseboard = info->model[3];
553 if (strncasecmp((const char *)info->model, "GW5400-A", 8) == 0)
557 case '0': /* original GW5400-A prototype */
573 printf("EEPROM: Unknown model in EEPROM: %s\n", info->model);
581 * Baseboard specific GPIO
584 /* common to add baseboards */
585 static iomux_v3_cfg_t const gw_gpio_pads[] = {
587 MX6_PAD_SD4_DAT0__GPIO2_IO08 | MUX_PAD_CTRL(NO_PAD_CTRL),
589 MX6_PAD_SD4_DAT3__GPIO2_IO11 | MUX_PAD_CTRL(NO_PAD_CTRL),
593 static iomux_v3_cfg_t const gwproto_gpio_pads[] = {
595 MX6_PAD_KEY_COL0__GPIO4_IO06 | MUX_PAD_CTRL(NO_PAD_CTRL),
597 MX6_PAD_KEY_ROW0__GPIO4_IO07 | MUX_PAD_CTRL(NO_PAD_CTRL),
599 MX6_PAD_KEY_ROW4__GPIO4_IO15 | MUX_PAD_CTRL(NO_PAD_CTRL),
601 MX6_PAD_SD3_DAT4__GPIO7_IO01 | MUX_PAD_CTRL(NO_PAD_CTRL),
603 MX6_PAD_EIM_A19__GPIO2_IO19 | MUX_PAD_CTRL(NO_PAD_CTRL),
605 MX6_PAD_EIM_A20__GPIO2_IO18 | MUX_PAD_CTRL(NO_PAD_CTRL),
607 MX6_PAD_EIM_D31__GPIO3_IO31 | MUX_PAD_CTRL(NO_PAD_CTRL),
609 MX6_PAD_GPIO_19__GPIO4_IO05 | MUX_PAD_CTRL(NO_PAD_CTRL),
611 MX6_PAD_SD1_CLK__GPIO1_IO20 | MUX_PAD_CTRL(NO_PAD_CTRL),
613 MX6_PAD_ENET_TXD1__GPIO1_IO29 | MUX_PAD_CTRL(NO_PAD_CTRL),
616 static iomux_v3_cfg_t const gw51xx_gpio_pads[] = {
618 MX6_PAD_KEY_COL0__GPIO4_IO06 | MUX_PAD_CTRL(NO_PAD_CTRL),
620 MX6_PAD_KEY_ROW0__GPIO4_IO07 | MUX_PAD_CTRL(NO_PAD_CTRL),
622 MX6_PAD_EIM_A19__GPIO2_IO19 | MUX_PAD_CTRL(NO_PAD_CTRL),
624 MX6_PAD_EIM_A20__GPIO2_IO18 | MUX_PAD_CTRL(NO_PAD_CTRL),
627 MX6_PAD_GPIO_2__GPIO1_IO02 | MUX_PAD_CTRL(NO_PAD_CTRL),
629 MX6_PAD_CSI0_DATA_EN__GPIO5_IO20 | MUX_PAD_CTRL(NO_PAD_CTRL),
631 MX6_PAD_GPIO_0__GPIO1_IO00 | MUX_PAD_CTRL(NO_PAD_CTRL),
634 static iomux_v3_cfg_t const gw52xx_gpio_pads[] = {
636 MX6_PAD_KEY_COL0__GPIO4_IO06 | MUX_PAD_CTRL(NO_PAD_CTRL),
638 MX6_PAD_KEY_ROW0__GPIO4_IO07 | MUX_PAD_CTRL(NO_PAD_CTRL),
640 MX6_PAD_EIM_A19__GPIO2_IO19 | MUX_PAD_CTRL(NO_PAD_CTRL),
642 MX6_PAD_EIM_A20__GPIO2_IO18 | MUX_PAD_CTRL(NO_PAD_CTRL),
645 MX6_PAD_KEY_ROW4__GPIO4_IO15 | MUX_PAD_CTRL(NO_PAD_CTRL),
647 MX6_PAD_ENET_RXD0__GPIO1_IO27 | MUX_PAD_CTRL(NO_PAD_CTRL),
649 MX6_PAD_GPIO_2__GPIO1_IO02 | MUX_PAD_CTRL(NO_PAD_CTRL),
651 MX6_PAD_EIM_D31__GPIO3_IO31 | MUX_PAD_CTRL(NO_PAD_CTRL),
653 MX6_PAD_ENET_TXD1__GPIO1_IO29 | MUX_PAD_CTRL(NO_PAD_CTRL),
656 static iomux_v3_cfg_t const gw53xx_gpio_pads[] = {
658 MX6_PAD_KEY_COL0__GPIO4_IO06 | MUX_PAD_CTRL(NO_PAD_CTRL),
660 MX6_PAD_KEY_ROW0__GPIO4_IO07 | MUX_PAD_CTRL(NO_PAD_CTRL),
662 MX6_PAD_EIM_A19__GPIO2_IO19 | MUX_PAD_CTRL(NO_PAD_CTRL),
664 MX6_PAD_EIM_A20__GPIO2_IO18 | MUX_PAD_CTRL(NO_PAD_CTRL),
667 MX6_PAD_KEY_ROW4__GPIO4_IO15 | MUX_PAD_CTRL(NO_PAD_CTRL),
669 MX6_PAD_ENET_RXD0__GPIO1_IO27 | MUX_PAD_CTRL(NO_PAD_CTRL),
671 MX6_PAD_EIM_D31__GPIO3_IO31 | MUX_PAD_CTRL(NO_PAD_CTRL),
673 MX6_PAD_ENET_TXD1__GPIO1_IO29 | MUX_PAD_CTRL(NO_PAD_CTRL),
676 static iomux_v3_cfg_t const gw54xx_gpio_pads[] = {
678 MX6_PAD_KEY_COL0__GPIO4_IO06 | MUX_PAD_CTRL(NO_PAD_CTRL),
680 MX6_PAD_KEY_COL2__GPIO4_IO10 | MUX_PAD_CTRL(NO_PAD_CTRL),
682 MX6_PAD_KEY_ROW4__GPIO4_IO15 | MUX_PAD_CTRL(NO_PAD_CTRL),
684 MX6_PAD_SD1_DAT3__GPIO1_IO21 | MUX_PAD_CTRL(NO_PAD_CTRL),
686 MX6_PAD_EIM_D24__GPIO3_IO24 | MUX_PAD_CTRL(NO_PAD_CTRL),
688 MX6_PAD_KEY_ROW0__GPIO4_IO07 | MUX_PAD_CTRL(NO_PAD_CTRL),
690 MX6_PAD_KEY_ROW1__GPIO4_IO09 | MUX_PAD_CTRL(NO_PAD_CTRL),
692 MX6_PAD_GPIO_19__GPIO4_IO05 | MUX_PAD_CTRL(NO_PAD_CTRL),
694 MX6_PAD_GPIO_19__GPIO4_IO05 | MUX_PAD_CTRL(NO_PAD_CTRL),
696 MX6_PAD_SD1_CLK__GPIO1_IO20 | MUX_PAD_CTRL(NO_PAD_CTRL),
698 MX6_PAD_ENET_TXD1__GPIO1_IO29 | MUX_PAD_CTRL(NO_PAD_CTRL),
702 * each baseboard has 4 user configurable Digital IO lines which can
703 * be pinmuxed as a GPIO or in some cases a PWM
706 iomux_v3_cfg_t gpio_padmux;
708 iomux_v3_cfg_t pwm_padmux;
714 iomux_v3_cfg_t const *gpio_pads;
717 struct dio_cfg dio_cfg[4];
718 /* various gpios (0 if non-existent) */
731 struct ventana gpio_cfg[] = {
734 .gpio_pads = gw54xx_gpio_pads,
735 .num_pads = ARRAY_SIZE(gw54xx_gpio_pads),
737 { MX6_PAD_GPIO_9__GPIO1_IO09, IMX_GPIO_NR(1, 9),
738 MX6_PAD_GPIO_9__PWM1_OUT, 1 },
739 { MX6_PAD_SD1_DAT2__GPIO1_IO19, IMX_GPIO_NR(1, 19),
740 MX6_PAD_SD1_DAT2__PWM2_OUT, 2 },
741 { MX6_PAD_SD4_DAT1__GPIO2_IO09, IMX_GPIO_NR(2, 9),
742 MX6_PAD_SD4_DAT1__PWM3_OUT, 3 },
743 { MX6_PAD_SD4_DAT2__GPIO2_IO10, IMX_GPIO_NR(2, 10),
744 MX6_PAD_SD4_DAT2__PWM4_OUT, 4 },
751 .pcie_rst = IMX_GPIO_NR(1, 29),
752 .mezz_pwren = IMX_GPIO_NR(4, 7),
753 .mezz_irq = IMX_GPIO_NR(4, 9),
754 .rs485en = IMX_GPIO_NR(3, 24),
755 .dioi2c_en = IMX_GPIO_NR(4, 5),
756 .pcie_sson = IMX_GPIO_NR(1, 20),
761 .gpio_pads = gw51xx_gpio_pads,
762 .num_pads = ARRAY_SIZE(gw51xx_gpio_pads),
764 { MX6_PAD_SD1_DAT0__GPIO1_IO16, IMX_GPIO_NR(1, 16),
766 { MX6_PAD_SD1_DAT2__GPIO1_IO19, IMX_GPIO_NR(1, 19),
767 MX6_PAD_SD1_DAT2__PWM2_OUT, 2 },
768 { MX6_PAD_SD1_DAT1__GPIO1_IO17, IMX_GPIO_NR(1, 17),
769 MX6_PAD_SD1_DAT1__PWM3_OUT, 3 },
770 { MX6_PAD_SD1_CMD__GPIO1_IO18, IMX_GPIO_NR(1, 18),
771 MX6_PAD_SD1_CMD__PWM4_OUT, 4 },
777 .pcie_rst = IMX_GPIO_NR(1, 0),
778 .mezz_pwren = IMX_GPIO_NR(2, 19),
779 .mezz_irq = IMX_GPIO_NR(2, 18),
780 .gps_shdn = IMX_GPIO_NR(1, 2),
781 .vidin_en = IMX_GPIO_NR(5, 20),
786 .gpio_pads = gw52xx_gpio_pads,
787 .num_pads = ARRAY_SIZE(gw52xx_gpio_pads),
789 { MX6_PAD_SD1_DAT0__GPIO1_IO16, IMX_GPIO_NR(1, 16),
791 { MX6_PAD_SD1_DAT2__GPIO1_IO19, IMX_GPIO_NR(1, 19),
792 MX6_PAD_SD1_DAT2__PWM2_OUT, 2 },
793 { MX6_PAD_SD1_DAT1__GPIO1_IO17, IMX_GPIO_NR(1, 17),
794 MX6_PAD_SD1_DAT1__PWM3_OUT, 3 },
795 { MX6_PAD_SD1_CLK__GPIO1_IO20, IMX_GPIO_NR(1, 20),
803 .pcie_rst = IMX_GPIO_NR(1, 29),
804 .mezz_pwren = IMX_GPIO_NR(2, 19),
805 .mezz_irq = IMX_GPIO_NR(2, 18),
806 .gps_shdn = IMX_GPIO_NR(1, 27),
807 .vidin_en = IMX_GPIO_NR(3, 31),
808 .usb_sel = IMX_GPIO_NR(1, 2),
813 .gpio_pads = gw53xx_gpio_pads,
814 .num_pads = ARRAY_SIZE(gw53xx_gpio_pads),
816 { MX6_PAD_SD1_DAT0__GPIO1_IO16, IMX_GPIO_NR(1, 16),
818 { MX6_PAD_SD1_DAT2__GPIO1_IO19, IMX_GPIO_NR(1, 19),
819 MX6_PAD_SD1_DAT2__PWM2_OUT, 2 },
820 { MX6_PAD_SD1_DAT1__GPIO1_IO17, IMX_GPIO_NR(1, 17),
821 MX6_PAD_SD1_DAT1__PWM3_OUT, 3 },
822 { MX6_PAD_SD1_CLK__GPIO1_IO20, IMX_GPIO_NR(1, 20),
830 .pcie_rst = IMX_GPIO_NR(1, 29),
831 .mezz_pwren = IMX_GPIO_NR(2, 19),
832 .mezz_irq = IMX_GPIO_NR(2, 18),
833 .gps_shdn = IMX_GPIO_NR(1, 27),
834 .vidin_en = IMX_GPIO_NR(3, 31),
839 .gpio_pads = gw54xx_gpio_pads,
840 .num_pads = ARRAY_SIZE(gw54xx_gpio_pads),
842 { MX6_PAD_GPIO_9__GPIO1_IO09, IMX_GPIO_NR(1, 9),
843 MX6_PAD_GPIO_9__PWM1_OUT, 1 },
844 { MX6_PAD_SD1_DAT2__GPIO1_IO19, IMX_GPIO_NR(1, 19),
845 MX6_PAD_SD1_DAT2__PWM2_OUT, 2 },
846 { MX6_PAD_SD4_DAT1__GPIO2_IO09, IMX_GPIO_NR(2, 9),
847 MX6_PAD_SD4_DAT1__PWM3_OUT, 3 },
848 { MX6_PAD_SD4_DAT2__GPIO2_IO10, IMX_GPIO_NR(2, 10),
849 MX6_PAD_SD4_DAT2__PWM4_OUT, 4 },
856 .pcie_rst = IMX_GPIO_NR(1, 29),
857 .mezz_pwren = IMX_GPIO_NR(2, 19),
858 .mezz_irq = IMX_GPIO_NR(2, 18),
859 .rs485en = IMX_GPIO_NR(7, 1),
860 .vidin_en = IMX_GPIO_NR(3, 31),
861 .dioi2c_en = IMX_GPIO_NR(4, 5),
862 .pcie_sson = IMX_GPIO_NR(1, 20),
866 /* setup board specific PMIC */
867 int power_init_board(void)
872 /* configure PFUZE100 PMIC */
873 if (board_type == GW54xx || board_type == GW54proto) {
874 power_pfuze100_init(I2C_PMIC);
875 p = pmic_get("PFUZE100_PMIC");
876 if (p && !pmic_probe(p)) {
877 pmic_reg_read(p, PFUZE100_DEVICEID, ®);
878 printf("PMIC: PFUZE100 ID=0x%02x\n", reg);
880 /* Set VGEN1 to 1.5V and enable */
881 pmic_reg_read(p, PFUZE100_VGEN1VOL, ®);
882 reg &= ~(LDO_VOL_MASK);
883 reg |= (LDOA_1_50V | LDO_EN);
884 pmic_reg_write(p, PFUZE100_VGEN1VOL, reg);
886 /* Set SWBST to 5.0V and enable */
887 pmic_reg_read(p, PFUZE100_SWBSTCON1, ®);
888 reg &= ~(SWBST_MODE_MASK | SWBST_VOL_MASK);
889 reg |= (SWBST_5_00V | SWBST_MODE_AUTO);
890 pmic_reg_write(p, PFUZE100_SWBSTCON1, reg);
894 /* configure LTC3676 PMIC */
896 power_ltc3676_init(I2C_PMIC);
897 p = pmic_get("LTC3676_PMIC");
898 if (p && !pmic_probe(p)) {
899 puts("PMIC: LTC3676\n");
900 /* set board-specific scalar to 1225mV for IMX6Q@1GHz */
901 if (is_cpu_type(MXC_CPU_MX6Q)) {
902 /* mask PGOOD during SW1 transition */
903 reg = 0x1d | LTC3676_PGOOD_MASK;
904 pmic_reg_write(p, LTC3676_DVB1B, reg);
905 /* set SW1 (VDD_SOC) to 1259mV */
907 pmic_reg_write(p, LTC3676_DVB1A, reg);
909 /* mask PGOOD during SW3 transition */
910 reg = 0x1d | LTC3676_PGOOD_MASK;
911 pmic_reg_write(p, LTC3676_DVB3B, reg);
912 /*set SW3 (VDD_ARM) to 1259mV */
914 pmic_reg_write(p, LTC3676_DVB3A, reg);
922 /* setup GPIO pinmux and default configuration per baseboard */
923 static void setup_board_gpio(int board)
925 struct ventana_board_info *info = &ventana_info;
930 int quiet = simple_strtol(getenv("quiet"), NULL, 10);
932 if (board >= GW_UNKNOWN)
936 gpio_direction_output(GP_RS232_EN, (hwconfig("rs232")) ? 0 : 1);
939 if (is_cpu_type(MXC_CPU_MX6Q) &&
940 test_bit(EECONFIG_SATA, info->config)) {
941 gpio_direction_output(GP_MSATA_SEL,
942 (hwconfig("msata")) ? 1 : 0);
944 gpio_direction_output(GP_MSATA_SEL, 0);
948 * assert PCI_RST# (released by OS when clock is valid)
949 * TODO: figure out why leaving this de-asserted from PCI scan on boot
950 * causes linux pcie driver to hang during enumeration
952 gpio_direction_output(gpio_cfg[board].pcie_rst, 0);
954 /* turn off (active-high) user LED's */
955 for (i = 0; i < 4; i++) {
956 if (gpio_cfg[board].leds[i])
957 gpio_direction_output(gpio_cfg[board].leds[i], 1);
960 /* Expansion Mezzanine IO */
961 gpio_direction_output(gpio_cfg[board].mezz_pwren, 0);
962 gpio_direction_input(gpio_cfg[board].mezz_irq);
964 /* RS485 Transmit Enable */
965 if (gpio_cfg[board].rs485en)
966 gpio_direction_output(gpio_cfg[board].rs485en, 0);
969 if (gpio_cfg[board].gps_shdn)
970 gpio_direction_output(gpio_cfg[board].gps_shdn, 1);
972 /* Analog video codec power enable */
973 if (gpio_cfg[board].vidin_en)
974 gpio_direction_output(gpio_cfg[board].vidin_en, 1);
977 if (gpio_cfg[board].dioi2c_en)
978 gpio_direction_output(gpio_cfg[board].dioi2c_en, 0);
980 /* PCICK_SSON: disable spread-spectrum clock */
981 if (gpio_cfg[board].pcie_sson)
982 gpio_direction_output(gpio_cfg[board].pcie_sson, 0);
984 /* USBOTG Select (PCISKT or FrontPanel) */
985 if (gpio_cfg[board].usb_sel)
986 gpio_direction_output(gpio_cfg[board].usb_sel, 0);
989 * Configure DIO pinmux/padctl registers
990 * see IMX6DQRM/IMX6SDLRM IOMUXC_SW_PAD_CTL_PAD_* register definitions
992 for (i = 0; i < 4; i++) {
993 struct dio_cfg *cfg = &gpio_cfg[board].dio_cfg[i];
994 unsigned ctrl = DIO_PAD_CTRL;
996 sprintf(arg, "dio%d", i);
999 s = hwconfig_subarg(arg, "padctrl", &len);
1001 ctrl = simple_strtoul(s, NULL, 16) & 0x3ffff;
1002 if (hwconfig_subarg_cmp(arg, "mode", "gpio")) {
1004 printf("DIO%d: GPIO%d_IO%02d (gpio-%d)\n", i,
1005 (cfg->gpio_param/32)+1,
1009 imx_iomux_v3_setup_pad(cfg->gpio_padmux |
1010 MUX_PAD_CTRL(ctrl));
1011 gpio_direction_input(cfg->gpio_param);
1012 } else if (hwconfig_subarg_cmp("dio2", "mode", "pwm") &&
1015 printf("DIO%d: pwm%d\n", i, cfg->pwm_param);
1016 imx_iomux_v3_setup_pad(cfg->pwm_padmux |
1017 MUX_PAD_CTRL(ctrl));
1022 if (is_cpu_type(MXC_CPU_MX6Q) &&
1023 (test_bit(EECONFIG_SATA, info->config))) {
1024 printf("MSATA: %s\n", (hwconfig("msata") ?
1025 "enabled" : "disabled"));
1027 printf("RS232: %s\n", (hwconfig("rs232")) ?
1028 "enabled" : "disabled");
1032 #if defined(CONFIG_CMD_PCI)
1033 int imx6_pcie_toggle_reset(void)
1035 if (board_type < GW_UNKNOWN) {
1036 gpio_direction_output(gpio_cfg[board_type].pcie_rst, 0);
1038 gpio_direction_output(gpio_cfg[board_type].pcie_rst, 1);
1042 #endif /* CONFIG_CMD_PCI */
1044 #ifdef CONFIG_SERIAL_TAG
1046 * called when setting up ATAGS before booting kernel
1047 * populate serialnum from the following (in order of priority):
1051 void get_board_serial(struct tag_serialnr *serialnr)
1053 char *serial = getenv("serial#");
1057 serialnr->low = simple_strtoul(serial, NULL, 10);
1058 } else if (ventana_info.model[0]) {
1060 serialnr->low = ventana_info.serial;
1072 int board_early_init_f(void)
1075 gpio_direction_output(GP_USB_OTG_PWR, 0); /* OTG power off */
1077 #if defined(CONFIG_VIDEO_IPUV3)
1085 gd->ram_size = get_ram_size((void *)PHYS_SDRAM,
1086 CONFIG_DDR_MB*1024*1024);
1091 int board_init(void)
1093 struct iomuxc_base_regs *const iomuxc_regs
1094 = (struct iomuxc_base_regs *)IOMUXC_BASE_ADDR;
1096 clrsetbits_le32(&iomuxc_regs->gpr[1],
1097 IOMUXC_GPR1_OTG_ID_MASK,
1098 IOMUXC_GPR1_OTG_ID_GPIO1);
1100 /* address of linux boot parameters */
1101 gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
1103 #ifdef CONFIG_CMD_NAND
1106 #ifdef CONFIG_MXC_SPI
1109 setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info0);
1110 setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info1);
1111 setup_i2c(2, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info2);
1113 #ifdef CONFIG_CMD_SATA
1116 /* read Gateworks EEPROM into global struct (used later) */
1117 board_type = read_eeprom();
1119 /* board-specifc GPIO iomux */
1120 if (board_type < GW_UNKNOWN) {
1121 imx_iomux_v3_setup_multiple_pads(gw_gpio_pads,
1122 ARRAY_SIZE(gw_gpio_pads));
1123 imx_iomux_v3_setup_multiple_pads(gpio_cfg[board_type].gpio_pads,
1124 gpio_cfg[board_type].num_pads);
1130 #if defined(CONFIG_DISPLAY_BOARDINFO_LATE)
1132 * called during late init (after relocation and after board_init())
1133 * by virtue of CONFIG_DISPLAY_BOARDINFO_LATE as we needed i2c initialized and
1136 int checkboard(void)
1138 struct ventana_board_info *info = &ventana_info;
1139 unsigned char buf[4];
1141 int quiet; /* Quiet or minimal output mode */
1144 p = getenv("quiet");
1146 quiet = simple_strtol(p, NULL, 10);
1148 setenv("quiet", "0");
1150 puts("\nGateworks Corporation Copyright 2014\n");
1151 if (info->model[0]) {
1152 printf("Model: %s\n", info->model);
1153 printf("MFGDate: %02x-%02x-%02x%02x\n",
1154 info->mfgdate[0], info->mfgdate[1],
1155 info->mfgdate[2], info->mfgdate[3]);
1156 printf("Serial:%d\n", info->serial);
1158 puts("Invalid EEPROM - board will not function fully\n");
1163 /* Display GSC firmware revision/CRC/status */
1164 i2c_set_bus_num(I2C_GSC);
1165 if (!gsc_i2c_read(GSC_SC_ADDR, GSC_SC_FWVER, 1, buf, 1)) {
1166 printf("GSC: v%d", buf[0]);
1167 if (!gsc_i2c_read(GSC_SC_ADDR, GSC_SC_STATUS, 1, buf, 4)) {
1168 printf(" 0x%04x", buf[2] | buf[3]<<8); /* CRC */
1169 printf(" 0x%02x", buf[0]); /* irq status */
1174 if (!gsc_i2c_read(GSC_RTC_ADDR, 0x00, 1, buf, 4)) {
1176 buf[0] | buf[1]<<8 | buf[2]<<16 | buf[3]<<24);
1183 #ifdef CONFIG_CMD_BMODE
1185 * BOOT_CFG1, BOOT_CFG2, BOOT_CFG3, BOOT_CFG4
1186 * see Table 8-11 and Table 5-9
1187 * BOOT_CFG1[7] = 1 (boot from NAND)
1188 * BOOT_CFG1[5] = 0 - raw NAND
1189 * BOOT_CFG1[4] = 0 - default pad settings
1190 * BOOT_CFG1[3:2] = 00 - devices = 1
1191 * BOOT_CFG1[1:0] = 00 - Row Address Cycles = 3
1192 * BOOT_CFG2[4:3] = 00 - Boot Search Count = 2
1193 * BOOT_CFG2[2:1] = 01 - Pages In Block = 64
1194 * BOOT_CFG2[0] = 0 - Reset time 12ms
1196 static const struct boot_mode board_boot_modes[] = {
1197 /* NAND: 64pages per block, 3 row addr cycles, 2 copies of FCB/DBBT */
1198 { "nand", MAKE_CFGVAL(0x80, 0x02, 0x00, 0x00) },
1204 int misc_init_r(void)
1206 struct ventana_board_info *info = &ventana_info;
1209 /* set env vars based on EEPROM data */
1210 if (ventana_info.model[0]) {
1211 char str[16], fdt[36];
1213 const char *cputype = "";
1217 * FDT name will be prefixed with CPU type. Three versions
1218 * will be created each increasingly generic and bootloader
1219 * env scripts will try loading each from most specific to
1222 if (is_cpu_type(MXC_CPU_MX6Q))
1224 else if (is_cpu_type(MXC_CPU_MX6DL))
1226 memset(str, 0, sizeof(str));
1227 for (i = 0; i < (sizeof(str)-1) && info->model[i]; i++)
1228 str[i] = tolower(info->model[i]);
1229 if (!getenv("model"))
1230 setenv("model", str);
1231 if (!getenv("fdt_file")) {
1232 sprintf(fdt, "%s-%s.dtb", cputype, str);
1233 setenv("fdt_file", fdt);
1235 p = strchr(str, '-');
1239 setenv("model_base", str);
1240 if (!getenv("fdt_file1")) {
1241 sprintf(fdt, "%s-%s.dtb", cputype, str);
1242 setenv("fdt_file1", fdt);
1247 if (!getenv("fdt_file2")) {
1248 sprintf(fdt, "%s-%s.dtb", cputype, str);
1249 setenv("fdt_file2", fdt);
1253 /* initialize env from EEPROM */
1254 if (test_bit(EECONFIG_ETH0, info->config) &&
1255 !getenv("ethaddr")) {
1256 eth_setenv_enetaddr("ethaddr", info->mac0);
1258 if (test_bit(EECONFIG_ETH1, info->config) &&
1259 !getenv("eth1addr")) {
1260 eth_setenv_enetaddr("eth1addr", info->mac1);
1263 /* board serial-number */
1264 sprintf(str, "%6d", info->serial);
1265 setenv("serial#", str);
1269 /* setup baseboard specific GPIO pinmux and config */
1270 setup_board_gpio(board_type);
1272 #ifdef CONFIG_CMD_BMODE
1273 add_board_boot_modes(board_boot_modes);
1277 * The Gateworks System Controller implements a boot
1278 * watchdog (always enabled) as a workaround for IMX6 boot related
1280 * ERR005768 - no fix
1281 * ERR006282 - fixed in silicon r1.3
1282 * ERR007117 - fixed in silicon r1.3
1283 * ERR007220 - fixed in silicon r1.3
1284 * see http://cache.freescale.com/files/32bit/doc/errata/IMX6DQCE.pdf
1286 * Disable the boot watchdog and display/clear the timeout flag if set
1288 i2c_set_bus_num(I2C_GSC);
1289 if (!gsc_i2c_read(GSC_SC_ADDR, GSC_SC_CTRL1, 1, ®, 1)) {
1290 reg |= (1 << GSC_SC_CTRL1_WDDIS);
1291 if (gsc_i2c_write(GSC_SC_ADDR, GSC_SC_CTRL1, 1, ®, 1))
1292 puts("Error: could not disable GSC Watchdog\n");
1294 puts("Error: could not disable GSC Watchdog\n");
1296 if (!gsc_i2c_read(GSC_SC_ADDR, GSC_SC_STATUS, 1, ®, 1)) {
1297 if (reg & (1 << GSC_SC_IRQ_WATCHDOG)) { /* watchdog timeout */
1298 puts("GSC boot watchdog timeout detected");
1299 reg &= ~(1 << GSC_SC_IRQ_WATCHDOG); /* clear flag */
1300 gsc_i2c_write(GSC_SC_ADDR, GSC_SC_STATUS, 1, ®, 1);
1307 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
1309 /* FDT aliases associated with EEPROM config bits */
1310 const char *fdt_aliases[] = {
1378 * called prior to booting kernel or by 'fdt boardsetup' command
1380 * unless 'fdt_noauto' env var is set we will update the following in the DTB:
1381 * - mtd partitions based on mtdparts/mtdids env
1382 * - system-serial (board serial num from EEPROM)
1383 * - board (full model from EEPROM)
1384 * - peripherals removed from DTB if not loaded on board (per EEPROM config)
1386 void ft_board_setup(void *blob, bd_t *bd)
1389 struct ventana_board_info *info = &ventana_info;
1390 struct node_info nodes[] = {
1391 { "sst,w25q256", MTD_DEV_TYPE_NOR, }, /* SPI flash */
1392 { "fsl,imx6q-gpmi-nand", MTD_DEV_TYPE_NAND, }, /* NAND flash */
1394 const char *model = getenv("model");
1396 if (getenv("fdt_noauto")) {
1397 puts(" Skiping ft_board_setup (fdt_noauto defined)\n");
1401 /* Update partition nodes using info from mtdparts env var */
1402 puts(" Updating MTD partitions...\n");
1403 fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
1406 puts("invalid board info: Leaving FDT fully enabled\n");
1409 printf(" Adjusting FDT per EEPROM for %s...\n", model);
1411 /* board serial number */
1412 fdt_setprop(blob, 0, "system-serial", getenv("serial#"),
1413 strlen(getenv("serial#")) + 1);
1415 /* board (model contains model from device-tree) */
1416 fdt_setprop(blob, 0, "board", info->model,
1417 strlen((const char *)info->model) + 1);
1420 * Peripheral Config:
1421 * remove nodes by alias path if EEPROM config tells us the
1422 * peripheral is not loaded on the board.
1424 for (bit = 0; bit < 64; bit++) {
1425 if (!test_bit(bit, info->config))
1426 fdt_del_node_and_alias(blob, fdt_aliases[bit]);
1429 #endif /* defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP) */