xref: /openbmc/u-boot/board/technexion/pico-imx7d/pico-imx7d.c (revision 748ad078eefea2ee5a3c8e53ca46e9e93c2fc7f1)
183d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+
21541d7a6SVanessa Maegima /*
31541d7a6SVanessa Maegima  * Copyright (C) 2017 NXP Semiconductors
41541d7a6SVanessa Maegima  */
51541d7a6SVanessa Maegima 
61541d7a6SVanessa Maegima #include <asm/arch/clock.h>
71541d7a6SVanessa Maegima #include <asm/arch/crm_regs.h>
81541d7a6SVanessa Maegima #include <asm/arch/imx-regs.h>
91541d7a6SVanessa Maegima #include <asm/arch/mx7-pins.h>
101541d7a6SVanessa Maegima #include <asm/arch/sys_proto.h>
111541d7a6SVanessa Maegima #include <asm/gpio.h>
12552a848eSStefano Babic #include <asm/mach-imx/iomux-v3.h>
13552a848eSStefano Babic #include <asm/mach-imx/mxc_i2c.h>
141541d7a6SVanessa Maegima #include <asm/io.h>
151541d7a6SVanessa Maegima #include <common.h>
161541d7a6SVanessa Maegima #include <fsl_esdhc.h>
171541d7a6SVanessa Maegima #include <i2c.h>
181541d7a6SVanessa Maegima #include <miiphy.h>
191541d7a6SVanessa Maegima #include <mmc.h>
201541d7a6SVanessa Maegima #include <netdev.h>
211541d7a6SVanessa Maegima #include <usb.h>
221541d7a6SVanessa Maegima #include <power/pmic.h>
231541d7a6SVanessa Maegima #include <power/pfuze3000_pmic.h>
241541d7a6SVanessa Maegima #include "../../freescale/common/pfuze.h"
251541d7a6SVanessa Maegima 
261541d7a6SVanessa Maegima DECLARE_GLOBAL_DATA_PTR;
271541d7a6SVanessa Maegima 
281541d7a6SVanessa Maegima #define UART_PAD_CTRL  (PAD_CTL_DSE_3P3V_49OHM | \
291541d7a6SVanessa Maegima 	PAD_CTL_PUS_PU100KOHM | PAD_CTL_HYS)
301541d7a6SVanessa Maegima 
311541d7a6SVanessa Maegima #define USDHC_PAD_CTRL (PAD_CTL_DSE_3P3V_32OHM | PAD_CTL_SRE_SLOW | \
321541d7a6SVanessa Maegima 	PAD_CTL_HYS | PAD_CTL_PUE | PAD_CTL_PUS_PU47KOHM)
331541d7a6SVanessa Maegima 
341541d7a6SVanessa Maegima #define ENET_PAD_CTRL  (PAD_CTL_PUS_PU100KOHM | PAD_CTL_DSE_3P3V_49OHM)
351541d7a6SVanessa Maegima #define ENET_PAD_CTRL_MII  (PAD_CTL_DSE_3P3V_32OHM)
361541d7a6SVanessa Maegima 
371541d7a6SVanessa Maegima #define ENET_RX_PAD_CTRL  (PAD_CTL_PUS_PU100KOHM | PAD_CTL_DSE_3P3V_49OHM)
381541d7a6SVanessa Maegima 
391541d7a6SVanessa Maegima #define I2C_PAD_CTRL    (PAD_CTL_DSE_3P3V_32OHM | PAD_CTL_SRE_SLOW | \
401541d7a6SVanessa Maegima 	PAD_CTL_HYS | PAD_CTL_PUE | PAD_CTL_PUS_PU100KOHM)
411541d7a6SVanessa Maegima 
42*9e3c0174SFabio Estevam 
43*9e3c0174SFabio Estevam #define LCD_PAD_CTRL    (PAD_CTL_HYS | PAD_CTL_PUS_PU100KOHM | \
44*9e3c0174SFabio Estevam 			 PAD_CTL_DSE_3P3V_49OHM)
45*9e3c0174SFabio Estevam 
46*9e3c0174SFabio Estevam #define LCD_SYNC_PAD_CTRL    (PAD_CTL_HYS | PAD_CTL_PUS_PU100KOHM | \
47*9e3c0174SFabio Estevam 			      PAD_CTL_DSE_3P3V_196OHM)
48*9e3c0174SFabio Estevam 
491541d7a6SVanessa Maegima #ifdef CONFIG_SYS_I2C_MXC
501541d7a6SVanessa Maegima #define PC MUX_PAD_CTRL(I2C_PAD_CTRL)
51*9e3c0174SFabio Estevam 
521541d7a6SVanessa Maegima /* I2C4 for PMIC */
531541d7a6SVanessa Maegima static struct i2c_pads_info i2c_pad_info4 = {
541541d7a6SVanessa Maegima 	.scl = {
551541d7a6SVanessa Maegima 		.i2c_mode = MX7D_PAD_SAI1_RX_SYNC__I2C4_SCL | PC,
561541d7a6SVanessa Maegima 		.gpio_mode = MX7D_PAD_SAI1_RX_SYNC__GPIO6_IO16 | PC,
571541d7a6SVanessa Maegima 		.gp = IMX_GPIO_NR(6, 16),
581541d7a6SVanessa Maegima 	},
591541d7a6SVanessa Maegima 	.sda = {
601541d7a6SVanessa Maegima 		.i2c_mode = MX7D_PAD_SAI1_RX_BCLK__I2C4_SDA | PC,
611541d7a6SVanessa Maegima 		.gpio_mode = MX7D_PAD_SAI1_RX_BCLK__GPIO6_IO17 | PC,
621541d7a6SVanessa Maegima 		.gp = IMX_GPIO_NR(6, 17),
631541d7a6SVanessa Maegima 	},
641541d7a6SVanessa Maegima };
651541d7a6SVanessa Maegima #endif
661541d7a6SVanessa Maegima 
dram_init(void)671541d7a6SVanessa Maegima int dram_init(void)
681541d7a6SVanessa Maegima {
69d5b7177fSFabio Estevam 	gd->ram_size = imx_ddr_size();
701541d7a6SVanessa Maegima 
711541d7a6SVanessa Maegima 	return 0;
721541d7a6SVanessa Maegima }
731541d7a6SVanessa Maegima 
741541d7a6SVanessa Maegima #ifdef CONFIG_POWER
751541d7a6SVanessa Maegima #define I2C_PMIC	3
power_init_board(void)761541d7a6SVanessa Maegima int power_init_board(void)
771541d7a6SVanessa Maegima {
781541d7a6SVanessa Maegima 	struct pmic *p;
791541d7a6SVanessa Maegima 	int ret;
801541d7a6SVanessa Maegima 	unsigned int reg, rev_id;
811541d7a6SVanessa Maegima 
821541d7a6SVanessa Maegima 	ret = power_pfuze3000_init(I2C_PMIC);
831541d7a6SVanessa Maegima 	if (ret)
841541d7a6SVanessa Maegima 		return ret;
851541d7a6SVanessa Maegima 
861541d7a6SVanessa Maegima 	p = pmic_get("PFUZE3000");
871541d7a6SVanessa Maegima 	ret = pmic_probe(p);
881541d7a6SVanessa Maegima 	if (ret)
891541d7a6SVanessa Maegima 		return ret;
901541d7a6SVanessa Maegima 
911541d7a6SVanessa Maegima 	pmic_reg_read(p, PFUZE3000_DEVICEID, &reg);
921541d7a6SVanessa Maegima 	pmic_reg_read(p, PFUZE3000_REVID, &rev_id);
931541d7a6SVanessa Maegima 	printf("PMIC:  PFUZE3000 DEV_ID=0x%x REV_ID=0x%x\n", reg, rev_id);
941541d7a6SVanessa Maegima 
951541d7a6SVanessa Maegima 	/* disable Low Power Mode during standby mode */
961541d7a6SVanessa Maegima 	pmic_reg_read(p, PFUZE3000_LDOGCTL, &reg);
971541d7a6SVanessa Maegima 	reg |= 0x1;
981541d7a6SVanessa Maegima 	pmic_reg_write(p, PFUZE3000_LDOGCTL, reg);
991541d7a6SVanessa Maegima 
1001541d7a6SVanessa Maegima 	/* SW1A/1B mode set to APS/APS */
1011541d7a6SVanessa Maegima 	reg = 0x8;
1021541d7a6SVanessa Maegima 	pmic_reg_write(p, PFUZE3000_SW1AMODE, reg);
1031541d7a6SVanessa Maegima 	pmic_reg_write(p, PFUZE3000_SW1BMODE, reg);
1041541d7a6SVanessa Maegima 
1051541d7a6SVanessa Maegima 	/* SW1A/1B standby voltage set to 1.025V */
1061541d7a6SVanessa Maegima 	reg = 0xd;
1071541d7a6SVanessa Maegima 	pmic_reg_write(p, PFUZE3000_SW1ASTBY, reg);
1081541d7a6SVanessa Maegima 	pmic_reg_write(p, PFUZE3000_SW1BSTBY, reg);
1091541d7a6SVanessa Maegima 
1101541d7a6SVanessa Maegima 	/* decrease SW1B normal voltage to 0.975V */
1111541d7a6SVanessa Maegima 	pmic_reg_read(p, PFUZE3000_SW1BVOLT, &reg);
1121541d7a6SVanessa Maegima 	reg &= ~0x1f;
1131541d7a6SVanessa Maegima 	reg |= PFUZE3000_SW1AB_SETP(975);
1141541d7a6SVanessa Maegima 	pmic_reg_write(p, PFUZE3000_SW1BVOLT, reg);
1151541d7a6SVanessa Maegima 
1161541d7a6SVanessa Maegima 	return 0;
1171541d7a6SVanessa Maegima }
1181541d7a6SVanessa Maegima #endif
1191541d7a6SVanessa Maegima 
1201541d7a6SVanessa Maegima static iomux_v3_cfg_t const wdog_pads[] = {
1211541d7a6SVanessa Maegima 	MX7D_PAD_GPIO1_IO00__WDOG1_WDOG_B | MUX_PAD_CTRL(NO_PAD_CTRL),
1221541d7a6SVanessa Maegima };
1231541d7a6SVanessa Maegima 
1241541d7a6SVanessa Maegima static iomux_v3_cfg_t const uart5_pads[] = {
1251541d7a6SVanessa Maegima 	MX7D_PAD_I2C4_SCL__UART5_DCE_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
1261541d7a6SVanessa Maegima 	MX7D_PAD_I2C4_SDA__UART5_DCE_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
1271541d7a6SVanessa Maegima };
1281541d7a6SVanessa Maegima 
1291541d7a6SVanessa Maegima static iomux_v3_cfg_t const usdhc3_emmc_pads[] = {
1301541d7a6SVanessa Maegima 	MX7D_PAD_SD3_CLK__SD3_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL),
1311541d7a6SVanessa Maegima 	MX7D_PAD_SD3_CMD__SD3_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL),
1321541d7a6SVanessa Maegima 	MX7D_PAD_SD3_DATA0__SD3_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
1331541d7a6SVanessa Maegima 	MX7D_PAD_SD3_DATA1__SD3_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
1341541d7a6SVanessa Maegima 	MX7D_PAD_SD3_DATA2__SD3_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
1351541d7a6SVanessa Maegima 	MX7D_PAD_SD3_DATA3__SD3_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
1361541d7a6SVanessa Maegima 	MX7D_PAD_SD3_DATA4__SD3_DATA4 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
1371541d7a6SVanessa Maegima 	MX7D_PAD_SD3_DATA5__SD3_DATA5 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
1381541d7a6SVanessa Maegima 	MX7D_PAD_SD3_DATA6__SD3_DATA6 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
1391541d7a6SVanessa Maegima 	MX7D_PAD_SD3_DATA7__SD3_DATA7 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
1401541d7a6SVanessa Maegima 	MX7D_PAD_GPIO1_IO14__GPIO1_IO14 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
1411541d7a6SVanessa Maegima };
1421541d7a6SVanessa Maegima 
1431541d7a6SVanessa Maegima #ifdef CONFIG_FEC_MXC
1441541d7a6SVanessa Maegima static iomux_v3_cfg_t const fec1_pads[] = {
1451541d7a6SVanessa Maegima 	MX7D_PAD_SD2_CD_B__ENET1_MDIO | MUX_PAD_CTRL(ENET_PAD_CTRL_MII),
1461541d7a6SVanessa Maegima 	MX7D_PAD_SD2_WP__ENET1_MDC | MUX_PAD_CTRL(ENET_PAD_CTRL_MII),
1471541d7a6SVanessa Maegima 	MX7D_PAD_ENET1_RGMII_TXC__ENET1_RGMII_TXC | MUX_PAD_CTRL(ENET_PAD_CTRL),
1481541d7a6SVanessa Maegima 	MX7D_PAD_ENET1_RGMII_TD0__ENET1_RGMII_TD0 | MUX_PAD_CTRL(ENET_PAD_CTRL),
1491541d7a6SVanessa Maegima 	MX7D_PAD_ENET1_RGMII_TD1__ENET1_RGMII_TD1 | MUX_PAD_CTRL(ENET_PAD_CTRL),
1501541d7a6SVanessa Maegima 	MX7D_PAD_ENET1_RGMII_TD2__ENET1_RGMII_TD2 | MUX_PAD_CTRL(ENET_PAD_CTRL),
1511541d7a6SVanessa Maegima 	MX7D_PAD_ENET1_RGMII_TD3__ENET1_RGMII_TD3 | MUX_PAD_CTRL(ENET_PAD_CTRL),
1521541d7a6SVanessa Maegima 	MX7D_PAD_ENET1_RGMII_TX_CTL__ENET1_RGMII_TX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL),
1531541d7a6SVanessa Maegima 	MX7D_PAD_ENET1_RGMII_RXC__ENET1_RGMII_RXC | MUX_PAD_CTRL(ENET_RX_PAD_CTRL),
1541541d7a6SVanessa Maegima 	MX7D_PAD_ENET1_RGMII_RD0__ENET1_RGMII_RD0 | MUX_PAD_CTRL(ENET_RX_PAD_CTRL),
1551541d7a6SVanessa Maegima 	MX7D_PAD_ENET1_RGMII_RD1__ENET1_RGMII_RD1 | MUX_PAD_CTRL(ENET_RX_PAD_CTRL),
1561541d7a6SVanessa Maegima 	MX7D_PAD_ENET1_RGMII_RD2__ENET1_RGMII_RD2 | MUX_PAD_CTRL(ENET_RX_PAD_CTRL),
1571541d7a6SVanessa Maegima 	MX7D_PAD_ENET1_RGMII_RD3__ENET1_RGMII_RD3 | MUX_PAD_CTRL(ENET_RX_PAD_CTRL),
1581541d7a6SVanessa Maegima 	MX7D_PAD_ENET1_RGMII_RX_CTL__ENET1_RGMII_RX_CTL | MUX_PAD_CTRL(ENET_RX_PAD_CTRL),
1591541d7a6SVanessa Maegima 	MX7D_PAD_SD3_STROBE__GPIO6_IO10 | MUX_PAD_CTRL(NO_PAD_CTRL),
1601541d7a6SVanessa Maegima 	MX7D_PAD_SD3_RESET_B__GPIO6_IO11 | MUX_PAD_CTRL(NO_PAD_CTRL),
1611541d7a6SVanessa Maegima };
1621541d7a6SVanessa Maegima 
1631541d7a6SVanessa Maegima #define FEC1_RST_GPIO	IMX_GPIO_NR(6, 11)
1641541d7a6SVanessa Maegima 
setup_iomux_fec(void)1651541d7a6SVanessa Maegima static void setup_iomux_fec(void)
1661541d7a6SVanessa Maegima {
1671541d7a6SVanessa Maegima 	imx_iomux_v3_setup_multiple_pads(fec1_pads, ARRAY_SIZE(fec1_pads));
1681541d7a6SVanessa Maegima 
1691541d7a6SVanessa Maegima 	gpio_direction_output(FEC1_RST_GPIO, 0);
1701541d7a6SVanessa Maegima 	udelay(500);
1711541d7a6SVanessa Maegima 	gpio_set_value(FEC1_RST_GPIO, 1);
1721541d7a6SVanessa Maegima }
1731541d7a6SVanessa Maegima 
board_eth_init(bd_t * bis)1741541d7a6SVanessa Maegima int board_eth_init(bd_t *bis)
1751541d7a6SVanessa Maegima {
1761541d7a6SVanessa Maegima 	setup_iomux_fec();
1771541d7a6SVanessa Maegima 
1781541d7a6SVanessa Maegima 	return fecmxc_initialize_multi(bis, 0,
1791541d7a6SVanessa Maegima 		CONFIG_FEC_MXC_PHYADDR, IMX_FEC_BASE);
1801541d7a6SVanessa Maegima }
1811541d7a6SVanessa Maegima 
setup_fec(void)1821541d7a6SVanessa Maegima static int setup_fec(void)
1831541d7a6SVanessa Maegima {
1841541d7a6SVanessa Maegima 	struct iomuxc_gpr_base_regs *const iomuxc_gpr_regs
1851541d7a6SVanessa Maegima 		= (struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR;
1861541d7a6SVanessa Maegima 
1871541d7a6SVanessa Maegima 	/* Use 125M anatop REF_CLK1 for ENET1, clear gpr1[13], gpr1[17] */
1881541d7a6SVanessa Maegima 	clrsetbits_le32(&iomuxc_gpr_regs->gpr[1],
1891541d7a6SVanessa Maegima 			(IOMUXC_GPR_GPR1_GPR_ENET1_TX_CLK_SEL_MASK |
1901541d7a6SVanessa Maegima 			IOMUXC_GPR_GPR1_GPR_ENET1_CLK_DIR_MASK), 0);
1911541d7a6SVanessa Maegima 
1928590786aSEric Nelson 	return set_clk_enet(ENET_125MHZ);
1931541d7a6SVanessa Maegima }
1941541d7a6SVanessa Maegima 
board_phy_config(struct phy_device * phydev)1951541d7a6SVanessa Maegima int board_phy_config(struct phy_device *phydev)
1961541d7a6SVanessa Maegima {
1971541d7a6SVanessa Maegima 	unsigned short val;
1981541d7a6SVanessa Maegima 
1991541d7a6SVanessa Maegima 	/* To enable AR8035 ouput a 125MHz clk from CLK_25M */
2001541d7a6SVanessa Maegima 	phy_write(phydev, MDIO_DEVAD_NONE, 0xd, 0x7);
2011541d7a6SVanessa Maegima 	phy_write(phydev, MDIO_DEVAD_NONE, 0xe, 0x8016);
2021541d7a6SVanessa Maegima 	phy_write(phydev, MDIO_DEVAD_NONE, 0xd, 0x4007);
2031541d7a6SVanessa Maegima 
2041541d7a6SVanessa Maegima 	val = phy_read(phydev, MDIO_DEVAD_NONE, 0xe);
2051541d7a6SVanessa Maegima 	val &= 0xffe7;
2061541d7a6SVanessa Maegima 	val |= 0x18;
2071541d7a6SVanessa Maegima 	phy_write(phydev, MDIO_DEVAD_NONE, 0xe, val);
2081541d7a6SVanessa Maegima 
2091541d7a6SVanessa Maegima 	/* introduce tx clock delay */
2101541d7a6SVanessa Maegima 	phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x5);
2111541d7a6SVanessa Maegima 	val = phy_read(phydev, MDIO_DEVAD_NONE, 0x1e);
2121541d7a6SVanessa Maegima 	val |= 0x0100;
2131541d7a6SVanessa Maegima 	phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, val);
2141541d7a6SVanessa Maegima 
2151541d7a6SVanessa Maegima 	if (phydev->drv->config)
2161541d7a6SVanessa Maegima 		phydev->drv->config(phydev);
2171541d7a6SVanessa Maegima 
2181541d7a6SVanessa Maegima 	return 0;
2191541d7a6SVanessa Maegima }
2201541d7a6SVanessa Maegima #endif
2211541d7a6SVanessa Maegima 
setup_iomux_uart(void)2221541d7a6SVanessa Maegima static void setup_iomux_uart(void)
2231541d7a6SVanessa Maegima {
2241541d7a6SVanessa Maegima 	imx_iomux_v3_setup_multiple_pads(uart5_pads, ARRAY_SIZE(uart5_pads));
2251541d7a6SVanessa Maegima }
2261541d7a6SVanessa Maegima 
2271541d7a6SVanessa Maegima static struct fsl_esdhc_cfg usdhc_cfg[1] = {
2281541d7a6SVanessa Maegima 	{USDHC3_BASE_ADDR},
2291541d7a6SVanessa Maegima };
2301541d7a6SVanessa Maegima 
board_mmc_getcd(struct mmc * mmc)2311541d7a6SVanessa Maegima int board_mmc_getcd(struct mmc *mmc)
2321541d7a6SVanessa Maegima {
2331541d7a6SVanessa Maegima 	/* Assume uSDHC3 emmc is always present */
2341541d7a6SVanessa Maegima 	return 1;
2351541d7a6SVanessa Maegima }
2361541d7a6SVanessa Maegima 
board_mmc_init(bd_t * bis)2371541d7a6SVanessa Maegima int board_mmc_init(bd_t *bis)
2381541d7a6SVanessa Maegima {
2391541d7a6SVanessa Maegima 	imx_iomux_v3_setup_multiple_pads(
2401541d7a6SVanessa Maegima 			usdhc3_emmc_pads, ARRAY_SIZE(usdhc3_emmc_pads));
2411541d7a6SVanessa Maegima 	usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
2421541d7a6SVanessa Maegima 
2431541d7a6SVanessa Maegima 	return fsl_esdhc_initialize(bis, &usdhc_cfg[0]);
2441541d7a6SVanessa Maegima }
2451541d7a6SVanessa Maegima 
board_early_init_f(void)2461541d7a6SVanessa Maegima int board_early_init_f(void)
2471541d7a6SVanessa Maegima {
2481541d7a6SVanessa Maegima 	setup_iomux_uart();
2491541d7a6SVanessa Maegima 
2501541d7a6SVanessa Maegima #ifdef CONFIG_SYS_I2C_MXC
2511541d7a6SVanessa Maegima 	setup_i2c(3, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info4);
2521541d7a6SVanessa Maegima #endif
2531541d7a6SVanessa Maegima 
2541541d7a6SVanessa Maegima 	return 0;
2551541d7a6SVanessa Maegima }
2561541d7a6SVanessa Maegima 
257*9e3c0174SFabio Estevam #ifdef CONFIG_VIDEO_MXS
258*9e3c0174SFabio Estevam static iomux_v3_cfg_t const lcd_pads[] = {
259*9e3c0174SFabio Estevam 	MX7D_PAD_LCD_CLK__LCD_CLK | MUX_PAD_CTRL(LCD_PAD_CTRL),
260*9e3c0174SFabio Estevam 	MX7D_PAD_LCD_ENABLE__LCD_ENABLE | MUX_PAD_CTRL(LCD_SYNC_PAD_CTRL),
261*9e3c0174SFabio Estevam 	MX7D_PAD_LCD_HSYNC__LCD_HSYNC | MUX_PAD_CTRL(LCD_SYNC_PAD_CTRL),
262*9e3c0174SFabio Estevam 	MX7D_PAD_LCD_VSYNC__LCD_VSYNC | MUX_PAD_CTRL(LCD_SYNC_PAD_CTRL),
263*9e3c0174SFabio Estevam 	MX7D_PAD_LCD_DATA00__LCD_DATA0 | MUX_PAD_CTRL(LCD_PAD_CTRL),
264*9e3c0174SFabio Estevam 	MX7D_PAD_LCD_DATA01__LCD_DATA1 | MUX_PAD_CTRL(LCD_PAD_CTRL),
265*9e3c0174SFabio Estevam 	MX7D_PAD_LCD_DATA02__LCD_DATA2 | MUX_PAD_CTRL(LCD_PAD_CTRL),
266*9e3c0174SFabio Estevam 	MX7D_PAD_LCD_DATA03__LCD_DATA3 | MUX_PAD_CTRL(LCD_PAD_CTRL),
267*9e3c0174SFabio Estevam 	MX7D_PAD_LCD_DATA04__LCD_DATA4 | MUX_PAD_CTRL(LCD_PAD_CTRL),
268*9e3c0174SFabio Estevam 	MX7D_PAD_LCD_DATA05__LCD_DATA5 | MUX_PAD_CTRL(LCD_PAD_CTRL),
269*9e3c0174SFabio Estevam 	MX7D_PAD_LCD_DATA06__LCD_DATA6 | MUX_PAD_CTRL(LCD_PAD_CTRL),
270*9e3c0174SFabio Estevam 	MX7D_PAD_LCD_DATA07__LCD_DATA7 | MUX_PAD_CTRL(LCD_PAD_CTRL),
271*9e3c0174SFabio Estevam 	MX7D_PAD_LCD_DATA08__LCD_DATA8 | MUX_PAD_CTRL(LCD_PAD_CTRL),
272*9e3c0174SFabio Estevam 	MX7D_PAD_LCD_DATA09__LCD_DATA9 | MUX_PAD_CTRL(LCD_PAD_CTRL),
273*9e3c0174SFabio Estevam 	MX7D_PAD_LCD_DATA10__LCD_DATA10 | MUX_PAD_CTRL(LCD_PAD_CTRL),
274*9e3c0174SFabio Estevam 	MX7D_PAD_LCD_DATA11__LCD_DATA11 | MUX_PAD_CTRL(LCD_PAD_CTRL),
275*9e3c0174SFabio Estevam 	MX7D_PAD_LCD_DATA12__LCD_DATA12 | MUX_PAD_CTRL(LCD_PAD_CTRL),
276*9e3c0174SFabio Estevam 	MX7D_PAD_LCD_DATA13__LCD_DATA13 | MUX_PAD_CTRL(LCD_PAD_CTRL),
277*9e3c0174SFabio Estevam 	MX7D_PAD_LCD_DATA14__LCD_DATA14 | MUX_PAD_CTRL(LCD_PAD_CTRL),
278*9e3c0174SFabio Estevam 	MX7D_PAD_LCD_DATA15__LCD_DATA15 | MUX_PAD_CTRL(LCD_PAD_CTRL),
279*9e3c0174SFabio Estevam 	MX7D_PAD_LCD_DATA16__LCD_DATA16 | MUX_PAD_CTRL(LCD_PAD_CTRL),
280*9e3c0174SFabio Estevam 	MX7D_PAD_LCD_DATA17__LCD_DATA17 | MUX_PAD_CTRL(LCD_PAD_CTRL),
281*9e3c0174SFabio Estevam 	MX7D_PAD_LCD_DATA18__LCD_DATA18 | MUX_PAD_CTRL(LCD_PAD_CTRL),
282*9e3c0174SFabio Estevam 	MX7D_PAD_LCD_DATA19__LCD_DATA19 | MUX_PAD_CTRL(LCD_PAD_CTRL),
283*9e3c0174SFabio Estevam 	MX7D_PAD_LCD_DATA20__LCD_DATA20 | MUX_PAD_CTRL(LCD_PAD_CTRL),
284*9e3c0174SFabio Estevam 	MX7D_PAD_LCD_DATA21__LCD_DATA21 | MUX_PAD_CTRL(LCD_PAD_CTRL),
285*9e3c0174SFabio Estevam 	MX7D_PAD_LCD_DATA22__LCD_DATA22 | MUX_PAD_CTRL(LCD_PAD_CTRL),
286*9e3c0174SFabio Estevam 	MX7D_PAD_LCD_DATA23__LCD_DATA23 | MUX_PAD_CTRL(LCD_PAD_CTRL),
287*9e3c0174SFabio Estevam 	MX7D_PAD_GPIO1_IO06__GPIO1_IO6	| MUX_PAD_CTRL(LCD_PAD_CTRL),
288*9e3c0174SFabio Estevam 	MX7D_PAD_GPIO1_IO11__GPIO1_IO11 | MUX_PAD_CTRL(NO_PAD_CTRL),
289*9e3c0174SFabio Estevam };
290*9e3c0174SFabio Estevam 
setup_lcd(void)291*9e3c0174SFabio Estevam void setup_lcd(void)
292*9e3c0174SFabio Estevam {
293*9e3c0174SFabio Estevam 	imx_iomux_v3_setup_multiple_pads(lcd_pads, ARRAY_SIZE(lcd_pads));
294*9e3c0174SFabio Estevam 	/* Set Brightness to high */
295*9e3c0174SFabio Estevam 	gpio_direction_output(IMX_GPIO_NR(1, 11) , 1);
296*9e3c0174SFabio Estevam 	/* Set LCD enable to high */
297*9e3c0174SFabio Estevam 	gpio_direction_output(IMX_GPIO_NR(1, 6) , 1);
298*9e3c0174SFabio Estevam }
299*9e3c0174SFabio Estevam #endif
300*9e3c0174SFabio Estevam 
board_init(void)3011541d7a6SVanessa Maegima int board_init(void)
3021541d7a6SVanessa Maegima {
3031541d7a6SVanessa Maegima 	/* address of boot parameters */
3041541d7a6SVanessa Maegima 	gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
3051541d7a6SVanessa Maegima 
306*9e3c0174SFabio Estevam #ifdef CONFIG_VIDEO_MXS
307*9e3c0174SFabio Estevam 	setup_lcd();
308*9e3c0174SFabio Estevam #endif
3091541d7a6SVanessa Maegima #ifdef CONFIG_FEC_MXC
3101541d7a6SVanessa Maegima 	setup_fec();
3111541d7a6SVanessa Maegima #endif
3121541d7a6SVanessa Maegima 
3131541d7a6SVanessa Maegima 	return 0;
3141541d7a6SVanessa Maegima }
3151541d7a6SVanessa Maegima 
board_late_init(void)3161541d7a6SVanessa Maegima int board_late_init(void)
3171541d7a6SVanessa Maegima {
3181541d7a6SVanessa Maegima 	struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR;
3191541d7a6SVanessa Maegima 
3201541d7a6SVanessa Maegima 	imx_iomux_v3_setup_multiple_pads(wdog_pads, ARRAY_SIZE(wdog_pads));
3211541d7a6SVanessa Maegima 
3221541d7a6SVanessa Maegima 	set_wdog_reset(wdog);
3231541d7a6SVanessa Maegima 
3241541d7a6SVanessa Maegima 	/*
3251541d7a6SVanessa Maegima 	 * Do not assert internal WDOG_RESET_B_DEB(controlled by bit 4),
3261541d7a6SVanessa Maegima 	 * since we use PMIC_PWRON to reset the board.
3271541d7a6SVanessa Maegima 	 */
3281541d7a6SVanessa Maegima 	clrsetbits_le16(&wdog->wcr, 0, 0x10);
3291541d7a6SVanessa Maegima 
3301541d7a6SVanessa Maegima 	return 0;
3311541d7a6SVanessa Maegima }
3321541d7a6SVanessa Maegima 
checkboard(void)3331541d7a6SVanessa Maegima int checkboard(void)
3341541d7a6SVanessa Maegima {
3351541d7a6SVanessa Maegima 	puts("Board: i.MX7D PICOSOM\n");
3361541d7a6SVanessa Maegima 
3371541d7a6SVanessa Maegima 	return 0;
3381541d7a6SVanessa Maegima }
3391541d7a6SVanessa Maegima 
340780e31e9SFabio Estevam static iomux_v3_cfg_t const usb_otg2_pads[] = {
341780e31e9SFabio Estevam 	MX7D_PAD_UART3_CTS_B__USB_OTG2_PWR | MUX_PAD_CTRL(NO_PAD_CTRL),
342780e31e9SFabio Estevam };
343780e31e9SFabio Estevam 
board_ehci_hcd_init(int port)344780e31e9SFabio Estevam int board_ehci_hcd_init(int port)
345780e31e9SFabio Estevam {
346780e31e9SFabio Estevam 	switch (port) {
347780e31e9SFabio Estevam 	case 0:
348780e31e9SFabio Estevam 		break;
349780e31e9SFabio Estevam 	case 1:
350780e31e9SFabio Estevam 		imx_iomux_v3_setup_multiple_pads(usb_otg2_pads,
351780e31e9SFabio Estevam 						 ARRAY_SIZE(usb_otg2_pads));
352780e31e9SFabio Estevam 		break;
353780e31e9SFabio Estevam 	default:
354780e31e9SFabio Estevam 		return -EINVAL;
355780e31e9SFabio Estevam 	}
356780e31e9SFabio Estevam 	return 0;
357780e31e9SFabio Estevam }
358780e31e9SFabio Estevam 
board_usb_phy_mode(int port)3591541d7a6SVanessa Maegima int board_usb_phy_mode(int port)
3601541d7a6SVanessa Maegima {
361780e31e9SFabio Estevam 	switch (port) {
362780e31e9SFabio Estevam 	case 0:
3631541d7a6SVanessa Maegima 		return USB_INIT_DEVICE;
364780e31e9SFabio Estevam 	case 1:
365780e31e9SFabio Estevam 		return USB_INIT_HOST;
366780e31e9SFabio Estevam 	default:
367780e31e9SFabio Estevam 		return -EINVAL;
368780e31e9SFabio Estevam 	}
369780e31e9SFabio Estevam 	return 0;
3701541d7a6SVanessa Maegima }
371