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)
53 #define UART_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE | \
54 PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \
55 PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST | PAD_CTL_HYS)
57 #define USDHC_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE | \
58 PAD_CTL_PUS_47K_UP | PAD_CTL_SPEED_LOW | \
59 PAD_CTL_DSE_80ohm | PAD_CTL_SRE_FAST | PAD_CTL_HYS)
61 #define ENET_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE | \
62 PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \
63 PAD_CTL_DSE_40ohm | PAD_CTL_HYS)
65 #define SPI_PAD_CTRL (PAD_CTL_HYS | \
66 PAD_CTL_PUS_100K_DOWN | PAD_CTL_SPEED_MED | \
67 PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST)
69 #define DIO_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE | \
70 PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \
71 PAD_CTL_DSE_34ohm | PAD_CTL_HYS | PAD_CTL_SRE_FAST)
73 #define I2C_PAD_CTRL (PAD_CTL_PUS_100K_UP | \
74 PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS | \
75 PAD_CTL_ODE | PAD_CTL_SRE_FAST)
77 #define IRQ_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE | \
78 PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \
79 PAD_CTL_DSE_34ohm | PAD_CTL_HYS | PAD_CTL_SRE_FAST)
81 #define DIO_PAD_CFG (MUX_PAD_CTRL(DIO_PAD_CTRL) | MUX_MODE_SION)
85 * EEPROM board info struct populated by read_eeprom so that we only have to
88 struct ventana_board_info ventana_info;
92 /* UART1: Function varies per baseboard */
93 iomux_v3_cfg_t const uart1_pads[] = {
94 IOMUX_PADS(PAD_SD3_DAT6__UART1_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)),
95 IOMUX_PADS(PAD_SD3_DAT7__UART1_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)),
98 /* UART2: Serial Console */
99 iomux_v3_cfg_t const uart2_pads[] = {
100 IOMUX_PADS(PAD_SD4_DAT7__UART2_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)),
101 IOMUX_PADS(PAD_SD4_DAT4__UART2_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)),
104 #define PC MUX_PAD_CTRL(I2C_PAD_CTRL)
107 struct i2c_pads_info mx6q_i2c_pad_info0 = {
109 .i2c_mode = MX6Q_PAD_EIM_D21__I2C1_SCL | PC,
110 .gpio_mode = MX6Q_PAD_EIM_D21__GPIO3_IO21 | PC,
111 .gp = IMX_GPIO_NR(3, 21)
114 .i2c_mode = MX6Q_PAD_EIM_D28__I2C1_SDA | PC,
115 .gpio_mode = MX6Q_PAD_EIM_D28__GPIO3_IO28 | PC,
116 .gp = IMX_GPIO_NR(3, 28)
119 struct i2c_pads_info mx6dl_i2c_pad_info0 = {
121 .i2c_mode = MX6DL_PAD_EIM_D21__I2C1_SCL | PC,
122 .gpio_mode = MX6DL_PAD_EIM_D21__GPIO3_IO21 | PC,
123 .gp = IMX_GPIO_NR(3, 21)
126 .i2c_mode = MX6DL_PAD_EIM_D28__I2C1_SDA | PC,
127 .gpio_mode = MX6DL_PAD_EIM_D28__GPIO3_IO28 | PC,
128 .gp = IMX_GPIO_NR(3, 28)
132 /* I2C2: PMIC/PCIe Switch/PCIe Clock/Mezz */
133 struct i2c_pads_info mx6q_i2c_pad_info1 = {
135 .i2c_mode = MX6Q_PAD_KEY_COL3__I2C2_SCL | PC,
136 .gpio_mode = MX6Q_PAD_KEY_COL3__GPIO4_IO12 | PC,
137 .gp = IMX_GPIO_NR(4, 12)
140 .i2c_mode = MX6Q_PAD_KEY_ROW3__I2C2_SDA | PC,
141 .gpio_mode = MX6Q_PAD_KEY_ROW3__GPIO4_IO13 | PC,
142 .gp = IMX_GPIO_NR(4, 13)
145 struct i2c_pads_info mx6dl_i2c_pad_info1 = {
147 .i2c_mode = MX6DL_PAD_KEY_COL3__I2C2_SCL | PC,
148 .gpio_mode = MX6DL_PAD_KEY_COL3__GPIO4_IO12 | PC,
149 .gp = IMX_GPIO_NR(4, 12)
152 .i2c_mode = MX6DL_PAD_KEY_ROW3__I2C2_SDA | PC,
153 .gpio_mode = MX6DL_PAD_KEY_ROW3__GPIO4_IO13 | PC,
154 .gp = IMX_GPIO_NR(4, 13)
158 /* I2C3: Misc/Expansion */
159 struct i2c_pads_info mx6q_i2c_pad_info2 = {
161 .i2c_mode = MX6Q_PAD_GPIO_3__I2C3_SCL | PC,
162 .gpio_mode = MX6Q_PAD_GPIO_3__GPIO1_IO03 | PC,
163 .gp = IMX_GPIO_NR(1, 3)
166 .i2c_mode = MX6Q_PAD_GPIO_6__I2C3_SDA | PC,
167 .gpio_mode = MX6Q_PAD_GPIO_6__GPIO1_IO06 | PC,
168 .gp = IMX_GPIO_NR(1, 6)
171 struct i2c_pads_info mx6dl_i2c_pad_info2 = {
173 .i2c_mode = MX6DL_PAD_GPIO_3__I2C3_SCL | PC,
174 .gpio_mode = MX6DL_PAD_GPIO_3__GPIO1_IO03 | PC,
175 .gp = IMX_GPIO_NR(1, 3)
178 .i2c_mode = MX6DL_PAD_GPIO_6__I2C3_SDA | PC,
179 .gpio_mode = MX6DL_PAD_GPIO_6__GPIO1_IO06 | PC,
180 .gp = IMX_GPIO_NR(1, 6)
185 iomux_v3_cfg_t const usdhc3_pads[] = {
186 IOMUX_PADS(PAD_SD3_CLK__SD3_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
187 IOMUX_PADS(PAD_SD3_CMD__SD3_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
188 IOMUX_PADS(PAD_SD3_DAT0__SD3_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
189 IOMUX_PADS(PAD_SD3_DAT1__SD3_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
190 IOMUX_PADS(PAD_SD3_DAT2__SD3_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
191 IOMUX_PADS(PAD_SD3_DAT3__SD3_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
193 IOMUX_PADS(PAD_SD3_DAT5__GPIO7_IO00 | MUX_PAD_CTRL(IRQ_PAD_CTRL)),
197 iomux_v3_cfg_t const enet_pads[] = {
198 IOMUX_PADS(PAD_ENET_MDIO__ENET_MDIO | MUX_PAD_CTRL(ENET_PAD_CTRL)),
199 IOMUX_PADS(PAD_ENET_MDC__ENET_MDC | MUX_PAD_CTRL(ENET_PAD_CTRL)),
200 IOMUX_PADS(PAD_RGMII_TXC__RGMII_TXC | MUX_PAD_CTRL(ENET_PAD_CTRL)),
201 IOMUX_PADS(PAD_RGMII_TD0__RGMII_TD0 | MUX_PAD_CTRL(ENET_PAD_CTRL)),
202 IOMUX_PADS(PAD_RGMII_TD1__RGMII_TD1 | MUX_PAD_CTRL(ENET_PAD_CTRL)),
203 IOMUX_PADS(PAD_RGMII_TD2__RGMII_TD2 | MUX_PAD_CTRL(ENET_PAD_CTRL)),
204 IOMUX_PADS(PAD_RGMII_TD3__RGMII_TD3 | MUX_PAD_CTRL(ENET_PAD_CTRL)),
205 IOMUX_PADS(PAD_RGMII_TX_CTL__RGMII_TX_CTL |
206 MUX_PAD_CTRL(ENET_PAD_CTRL)),
207 IOMUX_PADS(PAD_ENET_REF_CLK__ENET_TX_CLK |
208 MUX_PAD_CTRL(ENET_PAD_CTRL)),
209 IOMUX_PADS(PAD_RGMII_RXC__RGMII_RXC | MUX_PAD_CTRL(ENET_PAD_CTRL)),
210 IOMUX_PADS(PAD_RGMII_RD0__RGMII_RD0 | MUX_PAD_CTRL(ENET_PAD_CTRL)),
211 IOMUX_PADS(PAD_RGMII_RD1__RGMII_RD1 | MUX_PAD_CTRL(ENET_PAD_CTRL)),
212 IOMUX_PADS(PAD_RGMII_RD2__RGMII_RD2 | MUX_PAD_CTRL(ENET_PAD_CTRL)),
213 IOMUX_PADS(PAD_RGMII_RD3__RGMII_RD3 | MUX_PAD_CTRL(ENET_PAD_CTRL)),
214 IOMUX_PADS(PAD_RGMII_RX_CTL__RGMII_RX_CTL |
215 MUX_PAD_CTRL(ENET_PAD_CTRL)),
217 IOMUX_PADS(PAD_ENET_TXD0__GPIO1_IO30 | DIO_PAD_CFG),
221 iomux_v3_cfg_t const nfc_pads[] = {
222 IOMUX_PADS(PAD_NANDF_CLE__NAND_CLE | MUX_PAD_CTRL(NO_PAD_CTRL)),
223 IOMUX_PADS(PAD_NANDF_ALE__NAND_ALE | MUX_PAD_CTRL(NO_PAD_CTRL)),
224 IOMUX_PADS(PAD_NANDF_WP_B__NAND_WP_B | MUX_PAD_CTRL(NO_PAD_CTRL)),
225 IOMUX_PADS(PAD_NANDF_RB0__NAND_READY_B | MUX_PAD_CTRL(NO_PAD_CTRL)),
226 IOMUX_PADS(PAD_NANDF_CS0__NAND_CE0_B | MUX_PAD_CTRL(NO_PAD_CTRL)),
227 IOMUX_PADS(PAD_SD4_CMD__NAND_RE_B | MUX_PAD_CTRL(NO_PAD_CTRL)),
228 IOMUX_PADS(PAD_SD4_CLK__NAND_WE_B | MUX_PAD_CTRL(NO_PAD_CTRL)),
229 IOMUX_PADS(PAD_NANDF_D0__NAND_DATA00 | MUX_PAD_CTRL(NO_PAD_CTRL)),
230 IOMUX_PADS(PAD_NANDF_D1__NAND_DATA01 | MUX_PAD_CTRL(NO_PAD_CTRL)),
231 IOMUX_PADS(PAD_NANDF_D2__NAND_DATA02 | MUX_PAD_CTRL(NO_PAD_CTRL)),
232 IOMUX_PADS(PAD_NANDF_D3__NAND_DATA03 | MUX_PAD_CTRL(NO_PAD_CTRL)),
233 IOMUX_PADS(PAD_NANDF_D4__NAND_DATA04 | MUX_PAD_CTRL(NO_PAD_CTRL)),
234 IOMUX_PADS(PAD_NANDF_D5__NAND_DATA05 | MUX_PAD_CTRL(NO_PAD_CTRL)),
235 IOMUX_PADS(PAD_NANDF_D6__NAND_DATA06 | MUX_PAD_CTRL(NO_PAD_CTRL)),
236 IOMUX_PADS(PAD_NANDF_D7__NAND_DATA07 | MUX_PAD_CTRL(NO_PAD_CTRL)),
239 #ifdef CONFIG_CMD_NAND
240 static void setup_gpmi_nand(void)
242 struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
244 /* config gpmi nand iomux */
245 SETUP_IOMUX_PADS(nfc_pads);
247 /* config gpmi and bch clock to 100 MHz */
248 clrsetbits_le32(&mxc_ccm->cs2cdr,
249 MXC_CCM_CS2CDR_ENFC_CLK_PODF_MASK |
250 MXC_CCM_CS2CDR_ENFC_CLK_PRED_MASK |
251 MXC_CCM_CS2CDR_ENFC_CLK_SEL_MASK,
252 MXC_CCM_CS2CDR_ENFC_CLK_PODF(0) |
253 MXC_CCM_CS2CDR_ENFC_CLK_PRED(3) |
254 MXC_CCM_CS2CDR_ENFC_CLK_SEL(3));
256 /* enable gpmi and bch clock gating */
257 setbits_le32(&mxc_ccm->CCGR4,
258 MXC_CCM_CCGR4_RAWNAND_U_BCH_INPUT_APB_MASK |
259 MXC_CCM_CCGR4_RAWNAND_U_GPMI_BCH_INPUT_BCH_MASK |
260 MXC_CCM_CCGR4_RAWNAND_U_GPMI_BCH_INPUT_GPMI_IO_MASK |
261 MXC_CCM_CCGR4_RAWNAND_U_GPMI_INPUT_APB_MASK |
262 MXC_CCM_CCGR4_PL301_MX6QPER1_BCH_OFFSET);
264 /* enable apbh clock gating */
265 setbits_le32(&mxc_ccm->CCGR0, MXC_CCM_CCGR0_APBHDMA_MASK);
269 static void setup_iomux_enet(void)
271 SETUP_IOMUX_PADS(enet_pads);
273 /* toggle PHY_RST# */
274 gpio_direction_output(GP_PHY_RST, 0);
276 gpio_set_value(GP_PHY_RST, 1);
279 static void setup_iomux_uart(void)
281 SETUP_IOMUX_PADS(uart1_pads);
282 SETUP_IOMUX_PADS(uart2_pads);
285 #ifdef CONFIG_USB_EHCI_MX6
286 iomux_v3_cfg_t const usb_pads[] = {
287 IOMUX_PADS(PAD_GPIO_1__USB_OTG_ID | DIO_PAD_CFG),
288 IOMUX_PADS(PAD_KEY_COL4__USB_OTG_OC | DIO_PAD_CFG),
290 IOMUX_PADS(PAD_EIM_D22__GPIO3_IO22 | DIO_PAD_CFG),
293 int board_ehci_hcd_init(int port)
295 struct ventana_board_info *info = &ventana_info;
297 SETUP_IOMUX_PADS(usb_pads);
299 /* Reset USB HUB (present on GW54xx/GW53xx) */
300 switch (info->model[3]) {
301 case '3': /* GW53xx */
302 SETUP_IOMUX_PAD(PAD_GPIO_9__GPIO1_IO09 | DIO_PAD_CFG);
303 gpio_direction_output(IMX_GPIO_NR(1, 9), 0);
305 gpio_set_value(IMX_GPIO_NR(1, 9), 1);
307 case '4': /* GW54xx */
308 SETUP_IOMUX_PAD(PAD_SD1_DAT0__GPIO1_IO16 | DIO_PAD_CFG);
309 gpio_direction_output(IMX_GPIO_NR(1, 16), 0);
311 gpio_set_value(IMX_GPIO_NR(1, 16), 1);
318 int board_ehci_power(int port, int on)
322 gpio_set_value(GP_USB_OTG_PWR, on);
325 #endif /* CONFIG_USB_EHCI_MX6 */
327 #ifdef CONFIG_FSL_ESDHC
328 struct fsl_esdhc_cfg usdhc_cfg = { USDHC3_BASE_ADDR };
330 int board_mmc_getcd(struct mmc *mmc)
333 gpio_direction_input(GP_SD3_CD);
334 return !gpio_get_value(GP_SD3_CD);
337 int board_mmc_init(bd_t *bis)
339 /* Only one USDHC controller on Ventana */
340 SETUP_IOMUX_PADS(usdhc3_pads);
341 usdhc_cfg.sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
342 usdhc_cfg.max_bus_width = 4;
344 return fsl_esdhc_initialize(bis, &usdhc_cfg);
346 #endif /* CONFIG_FSL_ESDHC */
348 #ifdef CONFIG_MXC_SPI
349 iomux_v3_cfg_t const ecspi1_pads[] = {
351 IOMUX_PADS(PAD_EIM_D19__GPIO3_IO19 | MUX_PAD_CTRL(SPI_PAD_CTRL)),
352 IOMUX_PADS(PAD_EIM_D17__ECSPI1_MISO | MUX_PAD_CTRL(SPI_PAD_CTRL)),
353 IOMUX_PADS(PAD_EIM_D18__ECSPI1_MOSI | MUX_PAD_CTRL(SPI_PAD_CTRL)),
354 IOMUX_PADS(PAD_EIM_D16__ECSPI1_SCLK | MUX_PAD_CTRL(SPI_PAD_CTRL)),
357 static void setup_spi(void)
359 gpio_direction_output(CONFIG_SF_DEFAULT_CS, 1);
360 SETUP_IOMUX_PADS(ecspi1_pads);
364 /* configure eth0 PHY board-specific LED behavior */
365 int board_phy_config(struct phy_device *phydev)
370 if (phydev->phy_id == 0x1410dd1) {
372 * Page 3, Register 16: LED[2:0] Function Control Register
373 * LED[0] (SPD:Amber) R16_3.3:0 to 0111: on-GbE link
374 * LED[1] (LNK:Green) R16_3.7:4 to 0001: on-link, blink-activity
376 phy_write(phydev, MDIO_DEVAD_NONE, 22, 3);
377 val = phy_read(phydev, MDIO_DEVAD_NONE, 16);
380 phy_write(phydev, MDIO_DEVAD_NONE, 16, val);
381 phy_write(phydev, MDIO_DEVAD_NONE, 22, 0);
384 if (phydev->drv->config)
385 phydev->drv->config(phydev);
390 int board_eth_init(bd_t *bis)
394 #ifdef CONFIG_FEC_MXC
399 /* For otg ethernet*/
400 usb_eth_initialize(bis);
406 #if defined(CONFIG_VIDEO_IPUV3)
408 static void enable_hdmi(struct display_info_t const *dev)
410 imx_enable_hdmi_phy();
413 static int detect_i2c(struct display_info_t const *dev)
415 return i2c_set_bus_num(dev->bus) == 0 &&
416 i2c_probe(dev->addr) == 0;
419 static void enable_lvds(struct display_info_t const *dev)
421 struct iomuxc *iomux = (struct iomuxc *)
424 /* set CH0 data width to 24bit (IOMUXC_GPR2:5 0=18bit, 1=24bit) */
425 u32 reg = readl(&iomux->gpr[2]);
426 reg |= IOMUXC_GPR2_DATA_WIDTH_CH0_24BIT;
427 writel(reg, &iomux->gpr[2]);
429 /* Enable Backlight */
430 SETUP_IOMUX_PAD(PAD_SD1_CMD__GPIO1_IO18 | DIO_PAD_CFG);
431 gpio_direction_output(IMX_GPIO_NR(1, 18), 1);
434 struct display_info_t const displays[] = {{
438 .pixfmt = IPU_PIX_FMT_RGB24,
439 .detect = detect_hdmi,
440 .enable = enable_hdmi,
454 .vmode = FB_VMODE_NONINTERLACED
456 /* Freescale MXC-LVDS1: HannStar HSD100PXN1-A00 w/ egalx_ts cont */
459 .pixfmt = IPU_PIX_FMT_LVDS666,
460 .detect = detect_i2c,
461 .enable = enable_lvds,
463 .name = "Hannstar-XGA",
475 .vmode = FB_VMODE_NONINTERLACED
477 size_t display_count = ARRAY_SIZE(displays);
479 static void setup_display(void)
481 struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
482 struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR;
487 /* Turn on LDB0,IPU,IPU DI0 clocks */
488 reg = __raw_readl(&mxc_ccm->CCGR3);
489 reg |= MXC_CCM_CCGR3_LDB_DI0_MASK;
490 writel(reg, &mxc_ccm->CCGR3);
492 /* set LDB0, LDB1 clk select to 011/011 */
493 reg = readl(&mxc_ccm->cs2cdr);
494 reg &= ~(MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_MASK
495 |MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_MASK);
496 reg |= (3<<MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_OFFSET)
497 |(3<<MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_OFFSET);
498 writel(reg, &mxc_ccm->cs2cdr);
500 reg = readl(&mxc_ccm->cscmr2);
501 reg |= MXC_CCM_CSCMR2_LDB_DI0_IPU_DIV;
502 writel(reg, &mxc_ccm->cscmr2);
504 reg = readl(&mxc_ccm->chsccdr);
505 reg |= (CHSCCDR_CLK_SEL_LDB_DI0
506 <<MXC_CCM_CHSCCDR_IPU1_DI0_CLK_SEL_OFFSET);
507 writel(reg, &mxc_ccm->chsccdr);
509 reg = IOMUXC_GPR2_BGREF_RRMODE_EXTERNAL_RES
510 |IOMUXC_GPR2_DI1_VS_POLARITY_ACTIVE_HIGH
511 |IOMUXC_GPR2_DI0_VS_POLARITY_ACTIVE_LOW
512 |IOMUXC_GPR2_BIT_MAPPING_CH1_SPWG
513 |IOMUXC_GPR2_DATA_WIDTH_CH1_18BIT
514 |IOMUXC_GPR2_BIT_MAPPING_CH0_SPWG
515 |IOMUXC_GPR2_DATA_WIDTH_CH0_18BIT
516 |IOMUXC_GPR2_LVDS_CH1_MODE_DISABLED
517 |IOMUXC_GPR2_LVDS_CH0_MODE_ENABLED_DI0;
518 writel(reg, &iomux->gpr[2]);
520 reg = readl(&iomux->gpr[3]);
521 reg = (reg & ~IOMUXC_GPR3_LVDS0_MUX_CTL_MASK)
522 | (IOMUXC_GPR3_MUX_SRC_IPU1_DI0
523 <<IOMUXC_GPR3_LVDS0_MUX_CTL_OFFSET);
524 writel(reg, &iomux->gpr[3]);
526 /* Backlight CABEN on LVDS connector */
527 SETUP_IOMUX_PAD(PAD_SD2_CLK__GPIO1_IO10 | DIO_PAD_CFG);
528 gpio_direction_output(IMX_GPIO_NR(1, 10), 0);
530 #endif /* CONFIG_VIDEO_IPUV3 */
533 * Baseboard specific GPIO
536 /* common to add baseboards */
537 static iomux_v3_cfg_t const gw_gpio_pads[] = {
539 IOMUX_PADS(PAD_SD4_DAT0__GPIO2_IO08 | DIO_PAD_CFG),
541 IOMUX_PADS(PAD_SD4_DAT3__GPIO2_IO11 | DIO_PAD_CFG),
545 static iomux_v3_cfg_t const gwproto_gpio_pads[] = {
547 IOMUX_PADS(PAD_KEY_COL0__GPIO4_IO06 | DIO_PAD_CFG),
549 IOMUX_PADS(PAD_KEY_ROW0__GPIO4_IO07 | DIO_PAD_CFG),
551 IOMUX_PADS(PAD_KEY_ROW4__GPIO4_IO15 | DIO_PAD_CFG),
553 IOMUX_PADS(PAD_SD3_DAT4__GPIO7_IO01 | DIO_PAD_CFG),
555 IOMUX_PADS(PAD_EIM_A19__GPIO2_IO19 | DIO_PAD_CFG),
557 IOMUX_PADS(PAD_EIM_A20__GPIO2_IO18 | MUX_PAD_CTRL(IRQ_PAD_CTRL)),
559 IOMUX_PADS(PAD_EIM_D31__GPIO3_IO31 | DIO_PAD_CFG),
561 IOMUX_PADS(PAD_GPIO_19__GPIO4_IO05 | DIO_PAD_CFG),
563 IOMUX_PADS(PAD_SD1_CLK__GPIO1_IO20 | DIO_PAD_CFG),
565 IOMUX_PADS(PAD_ENET_TXD1__GPIO1_IO29 | DIO_PAD_CFG),
568 static iomux_v3_cfg_t const gw51xx_gpio_pads[] = {
570 IOMUX_PADS(PAD_KEY_COL0__GPIO4_IO06 | DIO_PAD_CFG),
572 IOMUX_PADS(PAD_KEY_ROW0__GPIO4_IO07 | DIO_PAD_CFG),
574 IOMUX_PADS(PAD_EIM_A19__GPIO2_IO19 | DIO_PAD_CFG),
576 IOMUX_PADS(PAD_EIM_A20__GPIO2_IO18 | MUX_PAD_CTRL(IRQ_PAD_CTRL)),
579 IOMUX_PADS(PAD_GPIO_2__GPIO1_IO02 | DIO_PAD_CFG),
581 IOMUX_PADS(PAD_CSI0_DATA_EN__GPIO5_IO20 | DIO_PAD_CFG),
583 IOMUX_PADS(PAD_GPIO_0__GPIO1_IO00 | DIO_PAD_CFG),
585 IOMUX_PADS(PAD_GPIO_17__GPIO7_IO12 | DIO_PAD_CFG),
588 static iomux_v3_cfg_t const gw52xx_gpio_pads[] = {
590 IOMUX_PADS(PAD_KEY_COL0__GPIO4_IO06 | DIO_PAD_CFG),
592 IOMUX_PADS(PAD_KEY_ROW0__GPIO4_IO07 | DIO_PAD_CFG),
594 IOMUX_PADS(PAD_EIM_A19__GPIO2_IO19 | DIO_PAD_CFG),
596 IOMUX_PADS(PAD_EIM_A20__GPIO2_IO18 | MUX_PAD_CTRL(IRQ_PAD_CTRL)),
599 IOMUX_PADS(PAD_KEY_ROW4__GPIO4_IO15 | DIO_PAD_CFG),
601 IOMUX_PADS(PAD_ENET_RXD0__GPIO1_IO27 | DIO_PAD_CFG),
603 IOMUX_PADS(PAD_GPIO_2__GPIO1_IO02 | DIO_PAD_CFG),
605 IOMUX_PADS(PAD_EIM_D31__GPIO3_IO31 | DIO_PAD_CFG),
607 IOMUX_PADS(PAD_ENET_TXD1__GPIO1_IO29 | DIO_PAD_CFG),
609 IOMUX_PADS(PAD_GPIO_17__GPIO7_IO12 | DIO_PAD_CFG),
612 static iomux_v3_cfg_t const gw53xx_gpio_pads[] = {
614 IOMUX_PADS(PAD_KEY_COL0__GPIO4_IO06 | DIO_PAD_CFG),
616 IOMUX_PADS(PAD_KEY_ROW0__GPIO4_IO07 | DIO_PAD_CFG),
618 IOMUX_PADS(PAD_EIM_A19__GPIO2_IO19 | DIO_PAD_CFG),
620 IOMUX_PADS(PAD_EIM_A20__GPIO2_IO18 | MUX_PAD_CTRL(IRQ_PAD_CTRL)),
622 IOMUX_PADS(PAD_GPIO_19__GPIO4_IO05 | DIO_PAD_CFG),
625 IOMUX_PADS(PAD_KEY_ROW4__GPIO4_IO15 | DIO_PAD_CFG),
627 IOMUX_PADS(PAD_ENET_RXD0__GPIO1_IO27 | DIO_PAD_CFG),
629 IOMUX_PADS(PAD_EIM_D31__GPIO3_IO31 | DIO_PAD_CFG),
631 IOMUX_PADS(PAD_ENET_TXD1__GPIO1_IO29 | DIO_PAD_CFG),
633 IOMUX_PADS(PAD_GPIO_17__GPIO7_IO12 | DIO_PAD_CFG),
636 static iomux_v3_cfg_t const gw54xx_gpio_pads[] = {
638 IOMUX_PADS(PAD_KEY_COL0__GPIO4_IO06 | DIO_PAD_CFG),
640 IOMUX_PADS(PAD_KEY_COL2__GPIO4_IO10 | DIO_PAD_CFG),
642 IOMUX_PADS(PAD_KEY_ROW4__GPIO4_IO15 | DIO_PAD_CFG),
644 IOMUX_PADS(PAD_SD1_DAT3__GPIO1_IO21 | DIO_PAD_CFG),
646 IOMUX_PADS(PAD_EIM_D24__GPIO3_IO24 | DIO_PAD_CFG),
648 IOMUX_PADS(PAD_KEY_ROW0__GPIO4_IO07 | DIO_PAD_CFG),
650 IOMUX_PADS(PAD_KEY_ROW1__GPIO4_IO09 | MUX_PAD_CTRL(IRQ_PAD_CTRL)),
652 IOMUX_PADS(PAD_GPIO_19__GPIO4_IO05 | DIO_PAD_CFG),
654 IOMUX_PADS(PAD_SD1_CLK__GPIO1_IO20 | DIO_PAD_CFG),
656 IOMUX_PADS(PAD_ENET_TXD1__GPIO1_IO29 | DIO_PAD_CFG),
658 IOMUX_PADS(PAD_EIM_D31__GPIO3_IO31 | DIO_PAD_CFG),
660 IOMUX_PADS(PAD_DISP0_DAT23__GPIO5_IO17 | DIO_PAD_CFG),
664 * each baseboard has 4 user configurable Digital IO lines which can
665 * be pinmuxed as a GPIO or in some cases a PWM
668 iomux_v3_cfg_t gpio_padmux[2];
670 iomux_v3_cfg_t pwm_padmux[2];
676 iomux_v3_cfg_t const *gpio_pads;
679 struct dio_cfg dio_cfg[4];
680 /* various gpios (0 if non-existent) */
694 struct ventana gpio_cfg[] = {
697 .gpio_pads = gw54xx_gpio_pads,
698 .num_pads = ARRAY_SIZE(gw54xx_gpio_pads)/2,
701 { IOMUX_PADS(PAD_GPIO_9__GPIO1_IO09) },
703 { IOMUX_PADS(PAD_GPIO_9__PWM1_OUT) },
707 { IOMUX_PADS(PAD_SD1_DAT2__GPIO1_IO19) },
709 { IOMUX_PADS(PAD_SD1_DAT2__PWM2_OUT) },
713 { IOMUX_PADS(PAD_SD4_DAT1__GPIO2_IO09) },
715 { IOMUX_PADS(PAD_SD4_DAT1__PWM3_OUT) },
719 { IOMUX_PADS(PAD_SD4_DAT2__GPIO2_IO10) },
721 { IOMUX_PADS(PAD_SD4_DAT2__PWM4_OUT) },
730 .pcie_rst = IMX_GPIO_NR(1, 29),
731 .mezz_pwren = IMX_GPIO_NR(4, 7),
732 .mezz_irq = IMX_GPIO_NR(4, 9),
733 .rs485en = IMX_GPIO_NR(3, 24),
734 .dioi2c_en = IMX_GPIO_NR(4, 5),
735 .pcie_sson = IMX_GPIO_NR(1, 20),
740 .gpio_pads = gw51xx_gpio_pads,
741 .num_pads = ARRAY_SIZE(gw51xx_gpio_pads)/2,
744 { IOMUX_PADS(PAD_SD1_DAT0__GPIO1_IO16) },
750 { IOMUX_PADS(PAD_SD1_DAT2__GPIO1_IO19) },
752 { IOMUX_PADS(PAD_SD1_DAT2__PWM2_OUT) },
756 { IOMUX_PADS(PAD_SD1_DAT1__GPIO1_IO17) },
758 { IOMUX_PADS(PAD_SD1_DAT1__PWM3_OUT) },
762 { IOMUX_PADS(PAD_SD1_CMD__GPIO1_IO18) },
764 { IOMUX_PADS(PAD_SD1_CMD__PWM4_OUT) },
772 .pcie_rst = IMX_GPIO_NR(1, 0),
773 .mezz_pwren = IMX_GPIO_NR(2, 19),
774 .mezz_irq = IMX_GPIO_NR(2, 18),
775 .gps_shdn = IMX_GPIO_NR(1, 2),
776 .vidin_en = IMX_GPIO_NR(5, 20),
777 .wdis = IMX_GPIO_NR(7, 12),
782 .gpio_pads = gw52xx_gpio_pads,
783 .num_pads = ARRAY_SIZE(gw52xx_gpio_pads)/2,
786 { IOMUX_PADS(PAD_SD1_DAT0__GPIO1_IO16) },
792 { IOMUX_PADS(PAD_SD1_DAT2__GPIO1_IO19) },
794 { IOMUX_PADS(PAD_SD1_DAT2__PWM2_OUT) },
798 { IOMUX_PADS(PAD_SD1_DAT1__GPIO1_IO17) },
800 { IOMUX_PADS(PAD_SD1_DAT1__PWM3_OUT) },
804 { IOMUX_PADS(PAD_SD1_CLK__GPIO1_IO20) },
815 .pcie_rst = IMX_GPIO_NR(1, 29),
816 .mezz_pwren = IMX_GPIO_NR(2, 19),
817 .mezz_irq = IMX_GPIO_NR(2, 18),
818 .gps_shdn = IMX_GPIO_NR(1, 27),
819 .vidin_en = IMX_GPIO_NR(3, 31),
820 .usb_sel = IMX_GPIO_NR(1, 2),
821 .wdis = IMX_GPIO_NR(7, 12),
826 .gpio_pads = gw53xx_gpio_pads,
827 .num_pads = ARRAY_SIZE(gw53xx_gpio_pads)/2,
830 { IOMUX_PADS(PAD_SD1_DAT0__GPIO1_IO16) },
836 { IOMUX_PADS(PAD_SD1_DAT2__GPIO1_IO19) },
838 { IOMUX_PADS(PAD_SD1_DAT2__PWM2_OUT) },
842 { IOMUX_PADS(PAD_SD1_DAT1__GPIO1_IO17) },
844 { IOMUX_PADS(PAD_SD1_DAT1__PWM3_OUT) },
848 {IOMUX_PADS(PAD_SD1_CLK__GPIO1_IO20) },
859 .pcie_rst = IMX_GPIO_NR(1, 29),
860 .mezz_pwren = IMX_GPIO_NR(2, 19),
861 .mezz_irq = IMX_GPIO_NR(2, 18),
862 .gps_shdn = IMX_GPIO_NR(1, 27),
863 .vidin_en = IMX_GPIO_NR(3, 31),
864 .wdis = IMX_GPIO_NR(7, 12),
869 .gpio_pads = gw54xx_gpio_pads,
870 .num_pads = ARRAY_SIZE(gw54xx_gpio_pads)/2,
873 { IOMUX_PADS(PAD_GPIO_9__GPIO1_IO09) },
875 { IOMUX_PADS(PAD_GPIO_9__PWM1_OUT) },
879 { IOMUX_PADS(PAD_SD1_DAT2__GPIO1_IO19) },
881 { IOMUX_PADS(PAD_SD1_DAT2__PWM2_OUT) },
885 { IOMUX_PADS(PAD_SD4_DAT1__GPIO2_IO09) },
887 { IOMUX_PADS(PAD_SD4_DAT1__PWM3_OUT) },
891 { IOMUX_PADS(PAD_SD4_DAT2__GPIO2_IO10) },
893 { IOMUX_PADS(PAD_SD4_DAT2__PWM4_OUT) },
902 .pcie_rst = IMX_GPIO_NR(1, 29),
903 .mezz_pwren = IMX_GPIO_NR(2, 19),
904 .mezz_irq = IMX_GPIO_NR(2, 18),
905 .rs485en = IMX_GPIO_NR(7, 1),
906 .vidin_en = IMX_GPIO_NR(3, 31),
907 .dioi2c_en = IMX_GPIO_NR(4, 5),
908 .pcie_sson = IMX_GPIO_NR(1, 20),
909 .wdis = IMX_GPIO_NR(5, 17),
913 /* setup board specific PMIC */
914 int power_init_board(void)
919 /* configure PFUZE100 PMIC */
920 if (board_type == GW54xx || board_type == GW54proto) {
921 power_pfuze100_init(CONFIG_I2C_PMIC);
922 p = pmic_get("PFUZE100");
923 if (p && !pmic_probe(p)) {
924 pmic_reg_read(p, PFUZE100_DEVICEID, ®);
925 printf("PMIC: PFUZE100 ID=0x%02x\n", reg);
927 /* Set VGEN1 to 1.5V and enable */
928 pmic_reg_read(p, PFUZE100_VGEN1VOL, ®);
929 reg &= ~(LDO_VOL_MASK);
930 reg |= (LDOA_1_50V | LDO_EN);
931 pmic_reg_write(p, PFUZE100_VGEN1VOL, reg);
933 /* Set SWBST to 5.0V and enable */
934 pmic_reg_read(p, PFUZE100_SWBSTCON1, ®);
935 reg &= ~(SWBST_MODE_MASK | SWBST_VOL_MASK);
936 reg |= (SWBST_5_00V | SWBST_MODE_AUTO);
937 pmic_reg_write(p, PFUZE100_SWBSTCON1, reg);
941 /* configure LTC3676 PMIC */
943 power_ltc3676_init(CONFIG_I2C_PMIC);
944 p = pmic_get("LTC3676_PMIC");
945 if (p && !pmic_probe(p)) {
946 puts("PMIC: LTC3676\n");
947 /* set board-specific scalar to 1225mV for IMX6Q@1GHz */
948 if (is_cpu_type(MXC_CPU_MX6Q)) {
949 /* mask PGOOD during SW1 transition */
950 reg = 0x1d | LTC3676_PGOOD_MASK;
951 pmic_reg_write(p, LTC3676_DVB1B, reg);
952 /* set SW1 (VDD_SOC) to 1259mV */
954 pmic_reg_write(p, LTC3676_DVB1A, reg);
956 /* mask PGOOD during SW3 transition */
957 reg = 0x1d | LTC3676_PGOOD_MASK;
958 pmic_reg_write(p, LTC3676_DVB3B, reg);
959 /*set SW3 (VDD_ARM) to 1259mV */
961 pmic_reg_write(p, LTC3676_DVB3A, reg);
969 /* setup GPIO pinmux and default configuration per baseboard */
970 static void setup_board_gpio(int board)
972 struct ventana_board_info *info = &ventana_info;
977 int quiet = simple_strtol(getenv("quiet"), NULL, 10);
979 if (board >= GW_UNKNOWN)
983 gpio_direction_output(GP_RS232_EN, (hwconfig("rs232")) ? 0 : 1);
986 if (is_cpu_type(MXC_CPU_MX6Q) &&
987 test_bit(EECONFIG_SATA, info->config)) {
988 gpio_direction_output(GP_MSATA_SEL,
989 (hwconfig("msata")) ? 1 : 0);
991 gpio_direction_output(GP_MSATA_SEL, 0);
994 #if !defined(CONFIG_CMD_PCI)
995 /* assert PCI_RST# (released by OS when clock is valid) */
996 gpio_direction_output(gpio_cfg[board].pcie_rst, 0);
999 /* turn off (active-high) user LED's */
1000 for (i = 0; i < 4; i++) {
1001 if (gpio_cfg[board].leds[i])
1002 gpio_direction_output(gpio_cfg[board].leds[i], 1);
1005 /* Expansion Mezzanine IO */
1006 gpio_direction_output(gpio_cfg[board].mezz_pwren, 0);
1007 gpio_direction_input(gpio_cfg[board].mezz_irq);
1009 /* RS485 Transmit Enable */
1010 if (gpio_cfg[board].rs485en)
1011 gpio_direction_output(gpio_cfg[board].rs485en, 0);
1014 if (gpio_cfg[board].gps_shdn)
1015 gpio_direction_output(gpio_cfg[board].gps_shdn, 1);
1017 /* Analog video codec power enable */
1018 if (gpio_cfg[board].vidin_en)
1019 gpio_direction_output(gpio_cfg[board].vidin_en, 1);
1022 if (gpio_cfg[board].dioi2c_en)
1023 gpio_direction_output(gpio_cfg[board].dioi2c_en, 0);
1025 /* PCICK_SSON: disable spread-spectrum clock */
1026 if (gpio_cfg[board].pcie_sson)
1027 gpio_direction_output(gpio_cfg[board].pcie_sson, 0);
1029 /* USBOTG Select (PCISKT or FrontPanel) */
1030 if (gpio_cfg[board].usb_sel)
1031 gpio_direction_output(gpio_cfg[board].usb_sel, 0);
1033 /* PCISKT_WDIS# (Wireless disable GPIO to miniPCIe sockets) */
1034 if (gpio_cfg[board].wdis)
1035 gpio_direction_output(gpio_cfg[board].wdis, 1);
1038 * Configure DIO pinmux/padctl registers
1039 * see IMX6DQRM/IMX6SDLRM IOMUXC_SW_PAD_CTL_PAD_* register definitions
1041 for (i = 0; i < 4; i++) {
1042 struct dio_cfg *cfg = &gpio_cfg[board].dio_cfg[i];
1043 iomux_v3_cfg_t ctrl = DIO_PAD_CFG;
1044 unsigned cputype = is_cpu_type(MXC_CPU_MX6Q) ? 0 : 1;
1046 sprintf(arg, "dio%d", i);
1049 s = hwconfig_subarg(arg, "padctrl", &len);
1051 ctrl = MUX_PAD_CTRL(simple_strtoul(s, NULL, 16)
1052 & 0x1ffff) | MUX_MODE_SION;
1054 if (hwconfig_subarg_cmp(arg, "mode", "gpio")) {
1056 printf("DIO%d: GPIO%d_IO%02d (gpio-%d)\n", i,
1057 (cfg->gpio_param/32)+1,
1061 imx_iomux_v3_setup_pad(cfg->gpio_padmux[cputype] |
1063 gpio_direction_input(cfg->gpio_param);
1064 } else if (hwconfig_subarg_cmp("dio2", "mode", "pwm") &&
1067 printf("DIO%d: pwm%d\n", i, cfg->pwm_param);
1068 imx_iomux_v3_setup_pad(cfg->pwm_padmux[cputype] |
1069 MUX_PAD_CTRL(ctrl));
1074 if (is_cpu_type(MXC_CPU_MX6Q) &&
1075 (test_bit(EECONFIG_SATA, info->config))) {
1076 printf("MSATA: %s\n", (hwconfig("msata") ?
1077 "enabled" : "disabled"));
1079 printf("RS232: %s\n", (hwconfig("rs232")) ?
1080 "enabled" : "disabled");
1084 #if defined(CONFIG_CMD_PCI)
1085 int imx6_pcie_toggle_reset(void)
1087 if (board_type < GW_UNKNOWN) {
1088 uint pin = gpio_cfg[board_type].pcie_rst;
1089 gpio_direction_output(pin, 0);
1091 gpio_direction_output(pin, 1);
1095 #endif /* CONFIG_CMD_PCI */
1097 #ifdef CONFIG_SERIAL_TAG
1099 * called when setting up ATAGS before booting kernel
1100 * populate serialnum from the following (in order of priority):
1104 void get_board_serial(struct tag_serialnr *serialnr)
1106 char *serial = getenv("serial#");
1110 serialnr->low = simple_strtoul(serial, NULL, 10);
1111 } else if (ventana_info.model[0]) {
1113 serialnr->low = ventana_info.serial;
1125 /* called from SPL board_init_f() */
1126 int board_early_init_f(void)
1129 gpio_direction_output(GP_USB_OTG_PWR, 0); /* OTG power off */
1131 #if defined(CONFIG_VIDEO_IPUV3)
1139 gd->ram_size = imx_ddr_size();
1143 int board_init(void)
1145 struct iomuxc *const iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR;
1147 clrsetbits_le32(&iomuxc_regs->gpr[1],
1148 IOMUXC_GPR1_OTG_ID_MASK,
1149 IOMUXC_GPR1_OTG_ID_GPIO1);
1151 /* address of linux boot parameters */
1152 gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
1154 #ifdef CONFIG_CMD_NAND
1157 #ifdef CONFIG_MXC_SPI
1160 if (is_cpu_type(MXC_CPU_MX6Q)) {
1161 setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, &mx6q_i2c_pad_info0);
1162 setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, &mx6q_i2c_pad_info1);
1163 setup_i2c(2, CONFIG_SYS_I2C_SPEED, 0x7f, &mx6q_i2c_pad_info2);
1165 setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, &mx6dl_i2c_pad_info0);
1166 setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, &mx6dl_i2c_pad_info1);
1167 setup_i2c(2, CONFIG_SYS_I2C_SPEED, 0x7f, &mx6dl_i2c_pad_info2);
1170 #ifdef CONFIG_CMD_SATA
1173 /* read Gateworks EEPROM into global struct (used later) */
1174 board_type = read_eeprom(CONFIG_I2C_GSC, &ventana_info);
1176 /* board-specifc GPIO iomux */
1177 SETUP_IOMUX_PADS(gw_gpio_pads);
1178 if (board_type < GW_UNKNOWN) {
1179 iomux_v3_cfg_t const *p = gpio_cfg[board_type].gpio_pads;
1180 int count = gpio_cfg[board_type].num_pads;
1182 imx_iomux_v3_setup_multiple_pads(p, count);
1188 #if defined(CONFIG_DISPLAY_BOARDINFO_LATE)
1190 * called during late init (after relocation and after board_init())
1191 * by virtue of CONFIG_DISPLAY_BOARDINFO_LATE as we needed i2c initialized and
1194 int checkboard(void)
1196 struct ventana_board_info *info = &ventana_info;
1197 unsigned char buf[4];
1199 int quiet; /* Quiet or minimal output mode */
1202 p = getenv("quiet");
1204 quiet = simple_strtol(p, NULL, 10);
1206 setenv("quiet", "0");
1208 puts("\nGateworks Corporation Copyright 2014\n");
1209 if (info->model[0]) {
1210 printf("Model: %s\n", info->model);
1211 printf("MFGDate: %02x-%02x-%02x%02x\n",
1212 info->mfgdate[0], info->mfgdate[1],
1213 info->mfgdate[2], info->mfgdate[3]);
1214 printf("Serial:%d\n", info->serial);
1216 puts("Invalid EEPROM - board will not function fully\n");
1221 /* Display GSC firmware revision/CRC/status */
1222 i2c_set_bus_num(CONFIG_I2C_GSC);
1223 if (!gsc_i2c_read(GSC_SC_ADDR, GSC_SC_FWVER, 1, buf, 1)) {
1224 printf("GSC: v%d", buf[0]);
1225 if (!gsc_i2c_read(GSC_SC_ADDR, GSC_SC_STATUS, 1, buf, 4)) {
1226 printf(" 0x%04x", buf[2] | buf[3]<<8); /* CRC */
1227 printf(" 0x%02x", buf[0]); /* irq status */
1232 if (!gsc_i2c_read(GSC_RTC_ADDR, 0x00, 1, buf, 4)) {
1234 buf[0] | buf[1]<<8 | buf[2]<<16 | buf[3]<<24);
1241 #ifdef CONFIG_CMD_BMODE
1243 * BOOT_CFG1, BOOT_CFG2, BOOT_CFG3, BOOT_CFG4
1244 * see Table 8-11 and Table 5-9
1245 * BOOT_CFG1[7] = 1 (boot from NAND)
1246 * BOOT_CFG1[5] = 0 - raw NAND
1247 * BOOT_CFG1[4] = 0 - default pad settings
1248 * BOOT_CFG1[3:2] = 00 - devices = 1
1249 * BOOT_CFG1[1:0] = 00 - Row Address Cycles = 3
1250 * BOOT_CFG2[4:3] = 00 - Boot Search Count = 2
1251 * BOOT_CFG2[2:1] = 01 - Pages In Block = 64
1252 * BOOT_CFG2[0] = 0 - Reset time 12ms
1254 static const struct boot_mode board_boot_modes[] = {
1255 /* NAND: 64pages per block, 3 row addr cycles, 2 copies of FCB/DBBT */
1256 { "nand", MAKE_CFGVAL(0x80, 0x02, 0x00, 0x00) },
1262 int misc_init_r(void)
1264 struct ventana_board_info *info = &ventana_info;
1267 /* set env vars based on EEPROM data */
1268 if (ventana_info.model[0]) {
1269 char str[16], fdt[36];
1271 const char *cputype = "";
1275 * FDT name will be prefixed with CPU type. Three versions
1276 * will be created each increasingly generic and bootloader
1277 * env scripts will try loading each from most specific to
1280 if (is_cpu_type(MXC_CPU_MX6Q) ||
1281 is_cpu_type(MXC_CPU_MX6D))
1283 else if (is_cpu_type(MXC_CPU_MX6DL) ||
1284 is_cpu_type(MXC_CPU_MX6SOLO))
1286 if (8 << (ventana_info.nand_flash_size-1) >= 2048)
1287 setenv("flash_layout", "large");
1289 setenv("flash_layout", "normal");
1290 memset(str, 0, sizeof(str));
1291 for (i = 0; i < (sizeof(str)-1) && info->model[i]; i++)
1292 str[i] = tolower(info->model[i]);
1293 if (!getenv("model"))
1294 setenv("model", str);
1295 if (!getenv("fdt_file")) {
1296 sprintf(fdt, "%s-%s.dtb", cputype, str);
1297 setenv("fdt_file", fdt);
1299 p = strchr(str, '-');
1303 setenv("model_base", str);
1304 if (!getenv("fdt_file1")) {
1305 sprintf(fdt, "%s-%s.dtb", cputype, str);
1306 setenv("fdt_file1", fdt);
1311 if (!getenv("fdt_file2")) {
1312 sprintf(fdt, "%s-%s.dtb", cputype, str);
1313 setenv("fdt_file2", fdt);
1317 /* initialize env from EEPROM */
1318 if (test_bit(EECONFIG_ETH0, info->config) &&
1319 !getenv("ethaddr")) {
1320 eth_setenv_enetaddr("ethaddr", info->mac0);
1322 if (test_bit(EECONFIG_ETH1, info->config) &&
1323 !getenv("eth1addr")) {
1324 eth_setenv_enetaddr("eth1addr", info->mac1);
1327 /* board serial-number */
1328 sprintf(str, "%6d", info->serial);
1329 setenv("serial#", str);
1333 /* setup baseboard specific GPIO pinmux and config */
1334 setup_board_gpio(board_type);
1336 #ifdef CONFIG_CMD_BMODE
1337 add_board_boot_modes(board_boot_modes);
1341 * The Gateworks System Controller implements a boot
1342 * watchdog (always enabled) as a workaround for IMX6 boot related
1344 * ERR005768 - no fix
1345 * ERR006282 - fixed in silicon r1.3
1346 * ERR007117 - fixed in silicon r1.3
1347 * ERR007220 - fixed in silicon r1.3
1348 * see http://cache.freescale.com/files/32bit/doc/errata/IMX6DQCE.pdf
1350 * Disable the boot watchdog and display/clear the timeout flag if set
1352 i2c_set_bus_num(CONFIG_I2C_GSC);
1353 if (!gsc_i2c_read(GSC_SC_ADDR, GSC_SC_CTRL1, 1, ®, 1)) {
1354 reg |= (1 << GSC_SC_CTRL1_WDDIS);
1355 if (gsc_i2c_write(GSC_SC_ADDR, GSC_SC_CTRL1, 1, ®, 1))
1356 puts("Error: could not disable GSC Watchdog\n");
1358 puts("Error: could not disable GSC Watchdog\n");
1360 if (!gsc_i2c_read(GSC_SC_ADDR, GSC_SC_STATUS, 1, ®, 1)) {
1361 if (reg & (1 << GSC_SC_IRQ_WATCHDOG)) { /* watchdog timeout */
1362 puts("GSC boot watchdog timeout detected\n");
1363 reg &= ~(1 << GSC_SC_IRQ_WATCHDOG); /* clear flag */
1364 gsc_i2c_write(GSC_SC_ADDR, GSC_SC_STATUS, 1, ®, 1);
1371 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
1374 * called prior to booting kernel or by 'fdt boardsetup' command
1376 * unless 'fdt_noauto' env var is set we will update the following in the DTB:
1377 * - mtd partitions based on mtdparts/mtdids env
1378 * - system-serial (board serial num from EEPROM)
1379 * - board (full model from EEPROM)
1380 * - peripherals removed from DTB if not loaded on board (per EEPROM config)
1382 void ft_board_setup(void *blob, bd_t *bd)
1384 struct ventana_board_info *info = &ventana_info;
1385 struct ventana_eeprom_config *cfg;
1386 struct node_info nodes[] = {
1387 { "sst,w25q256", MTD_DEV_TYPE_NOR, }, /* SPI flash */
1388 { "fsl,imx6q-gpmi-nand", MTD_DEV_TYPE_NAND, }, /* NAND flash */
1390 const char *model = getenv("model");
1392 if (getenv("fdt_noauto")) {
1393 puts(" Skiping ft_board_setup (fdt_noauto defined)\n");
1397 /* Update partition nodes using info from mtdparts env var */
1398 puts(" Updating MTD partitions...\n");
1399 fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
1402 puts("invalid board info: Leaving FDT fully enabled\n");
1405 printf(" Adjusting FDT per EEPROM for %s...\n", model);
1407 /* board serial number */
1408 fdt_setprop(blob, 0, "system-serial", getenv("serial#"),
1409 strlen(getenv("serial#")) + 1);
1411 /* board (model contains model from device-tree) */
1412 fdt_setprop(blob, 0, "board", info->model,
1413 strlen((const char *)info->model) + 1);
1416 * Peripheral Config:
1417 * remove nodes by alias path if EEPROM config tells us the
1418 * peripheral is not loaded on the board.
1420 if (getenv("fdt_noconfig")) {
1421 puts(" Skiping periperhal config (fdt_noconfig defined)\n");
1426 if (!test_bit(cfg->bit, info->config)) {
1427 fdt_del_node_and_alias(blob, cfg->dtalias ?
1428 cfg->dtalias : cfg->name);
1433 #endif /* defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP) */