1*83d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+
21a8150d4SAdrian Alonso /*
31a8150d4SAdrian Alonso * Copyright (C) 2015 Freescale Semiconductor, Inc.
41a8150d4SAdrian Alonso */
51a8150d4SAdrian Alonso
61a8150d4SAdrian Alonso #include <asm/arch/clock.h>
71a8150d4SAdrian Alonso #include <asm/arch/imx-regs.h>
81a8150d4SAdrian Alonso #include <asm/arch/mx7-pins.h>
91a8150d4SAdrian Alonso #include <asm/arch/sys_proto.h>
101a8150d4SAdrian Alonso #include <asm/gpio.h>
11552a848eSStefano Babic #include <asm/mach-imx/iomux-v3.h>
121a8150d4SAdrian Alonso #include <asm/io.h>
131a8150d4SAdrian Alonso #include <linux/sizes.h>
141a8150d4SAdrian Alonso #include <common.h>
151a8150d4SAdrian Alonso #include <fsl_esdhc.h>
161a8150d4SAdrian Alonso #include <mmc.h>
171a8150d4SAdrian Alonso #include <miiphy.h>
181a8150d4SAdrian Alonso #include <netdev.h>
191a8150d4SAdrian Alonso #include <power/pmic.h>
201a8150d4SAdrian Alonso #include <power/pfuze3000_pmic.h>
211a8150d4SAdrian Alonso #include "../common/pfuze.h"
221a8150d4SAdrian Alonso #include <i2c.h>
23552a848eSStefano Babic #include <asm/mach-imx/mxc_i2c.h>
241a8150d4SAdrian Alonso #include <asm/arch/crm_regs.h>
251a8150d4SAdrian Alonso
261a8150d4SAdrian Alonso DECLARE_GLOBAL_DATA_PTR;
271a8150d4SAdrian Alonso
281a8150d4SAdrian Alonso #define UART_PAD_CTRL (PAD_CTL_DSE_3P3V_49OHM | \
291a8150d4SAdrian Alonso PAD_CTL_PUS_PU100KOHM | PAD_CTL_HYS)
301a8150d4SAdrian Alonso
311a8150d4SAdrian Alonso #define ENET_PAD_CTRL (PAD_CTL_PUS_PU100KOHM | PAD_CTL_DSE_3P3V_49OHM)
321a8150d4SAdrian Alonso #define ENET_PAD_CTRL_MII (PAD_CTL_DSE_3P3V_32OHM)
331a8150d4SAdrian Alonso
341a8150d4SAdrian Alonso #define ENET_RX_PAD_CTRL (PAD_CTL_PUS_PU100KOHM | PAD_CTL_DSE_3P3V_49OHM)
351a8150d4SAdrian Alonso
36ebe517b6SPeng Fan #define LCD_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_PUS_PU100KOHM | \
37ebe517b6SPeng Fan PAD_CTL_DSE_3P3V_49OHM)
38ebe517b6SPeng Fan
396e1a41cdSPeng Fan #define NAND_PAD_CTRL (PAD_CTL_DSE_3P3V_49OHM | PAD_CTL_SRE_SLOW | PAD_CTL_HYS)
406e1a41cdSPeng Fan
419cd37b02SAngus Ainslie #define SPI_PAD_CTRL \
429cd37b02SAngus Ainslie (PAD_CTL_HYS | PAD_CTL_DSE_3P3V_49OHM | PAD_CTL_SRE_FAST)
439cd37b02SAngus Ainslie
446e1a41cdSPeng Fan #define NAND_PAD_READY0_CTRL (PAD_CTL_DSE_3P3V_49OHM | PAD_CTL_PUS_PU5KOHM)
451a8150d4SAdrian Alonso
466fbbcfdfSPeng Fan #ifdef CONFIG_MXC_SPI
479cd37b02SAngus Ainslie static iomux_v3_cfg_t const ecspi3_pads[] = {
489cd37b02SAngus Ainslie MX7D_PAD_SAI2_RX_DATA__ECSPI3_SCLK | MUX_PAD_CTRL(SPI_PAD_CTRL),
499cd37b02SAngus Ainslie MX7D_PAD_SAI2_TX_SYNC__ECSPI3_MISO | MUX_PAD_CTRL(SPI_PAD_CTRL),
509cd37b02SAngus Ainslie MX7D_PAD_SAI2_TX_BCLK__ECSPI3_MOSI | MUX_PAD_CTRL(SPI_PAD_CTRL),
519cd37b02SAngus Ainslie MX7D_PAD_SAI2_TX_DATA__GPIO6_IO22 | MUX_PAD_CTRL(NO_PAD_CTRL),
529cd37b02SAngus Ainslie };
539cd37b02SAngus Ainslie
board_spi_cs_gpio(unsigned bus,unsigned cs)549cd37b02SAngus Ainslie int board_spi_cs_gpio(unsigned bus, unsigned cs)
559cd37b02SAngus Ainslie {
569cd37b02SAngus Ainslie return (bus == 2 && cs == 0) ? (IMX_GPIO_NR(6, 22)) : -1;
579cd37b02SAngus Ainslie }
589cd37b02SAngus Ainslie
setup_spi(void)599cd37b02SAngus Ainslie static void setup_spi(void)
609cd37b02SAngus Ainslie {
619cd37b02SAngus Ainslie imx_iomux_v3_setup_multiple_pads(ecspi3_pads, ARRAY_SIZE(ecspi3_pads));
629cd37b02SAngus Ainslie }
636fbbcfdfSPeng Fan #endif
649cd37b02SAngus Ainslie
dram_init(void)651a8150d4SAdrian Alonso int dram_init(void)
661a8150d4SAdrian Alonso {
671a8150d4SAdrian Alonso gd->ram_size = PHYS_SDRAM_SIZE;
681a8150d4SAdrian Alonso
691a8150d4SAdrian Alonso return 0;
701a8150d4SAdrian Alonso }
711a8150d4SAdrian Alonso
721a8150d4SAdrian Alonso static iomux_v3_cfg_t const wdog_pads[] = {
731a8150d4SAdrian Alonso MX7D_PAD_GPIO1_IO00__WDOG1_WDOG_B | MUX_PAD_CTRL(NO_PAD_CTRL),
741a8150d4SAdrian Alonso };
751a8150d4SAdrian Alonso
761a8150d4SAdrian Alonso static iomux_v3_cfg_t const uart1_pads[] = {
771a8150d4SAdrian Alonso MX7D_PAD_UART1_TX_DATA__UART1_DCE_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
781a8150d4SAdrian Alonso MX7D_PAD_UART1_RX_DATA__UART1_DCE_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
791a8150d4SAdrian Alonso };
801a8150d4SAdrian Alonso
816e1a41cdSPeng Fan #ifdef CONFIG_NAND_MXS
826e1a41cdSPeng Fan static iomux_v3_cfg_t const gpmi_pads[] = {
836e1a41cdSPeng Fan MX7D_PAD_SD3_DATA0__NAND_DATA00 | MUX_PAD_CTRL(NAND_PAD_CTRL),
846e1a41cdSPeng Fan MX7D_PAD_SD3_DATA1__NAND_DATA01 | MUX_PAD_CTRL(NAND_PAD_CTRL),
856e1a41cdSPeng Fan MX7D_PAD_SD3_DATA2__NAND_DATA02 | MUX_PAD_CTRL(NAND_PAD_CTRL),
866e1a41cdSPeng Fan MX7D_PAD_SD3_DATA3__NAND_DATA03 | MUX_PAD_CTRL(NAND_PAD_CTRL),
876e1a41cdSPeng Fan MX7D_PAD_SD3_DATA4__NAND_DATA04 | MUX_PAD_CTRL(NAND_PAD_CTRL),
886e1a41cdSPeng Fan MX7D_PAD_SD3_DATA5__NAND_DATA05 | MUX_PAD_CTRL(NAND_PAD_CTRL),
896e1a41cdSPeng Fan MX7D_PAD_SD3_DATA6__NAND_DATA06 | MUX_PAD_CTRL(NAND_PAD_CTRL),
906e1a41cdSPeng Fan MX7D_PAD_SD3_DATA7__NAND_DATA07 | MUX_PAD_CTRL(NAND_PAD_CTRL),
916e1a41cdSPeng Fan MX7D_PAD_SD3_CLK__NAND_CLE | MUX_PAD_CTRL(NAND_PAD_CTRL),
926e1a41cdSPeng Fan MX7D_PAD_SD3_CMD__NAND_ALE | MUX_PAD_CTRL(NAND_PAD_CTRL),
936e1a41cdSPeng Fan MX7D_PAD_SD3_STROBE__NAND_RE_B | MUX_PAD_CTRL(NAND_PAD_CTRL),
946e1a41cdSPeng Fan MX7D_PAD_SD3_RESET_B__NAND_WE_B | MUX_PAD_CTRL(NAND_PAD_CTRL),
956e1a41cdSPeng Fan MX7D_PAD_SAI1_MCLK__NAND_WP_B | MUX_PAD_CTRL(NAND_PAD_CTRL),
966e1a41cdSPeng Fan MX7D_PAD_SAI1_RX_BCLK__NAND_CE3_B | MUX_PAD_CTRL(NAND_PAD_CTRL),
976e1a41cdSPeng Fan MX7D_PAD_SAI1_RX_SYNC__NAND_CE2_B | MUX_PAD_CTRL(NAND_PAD_CTRL),
986e1a41cdSPeng Fan MX7D_PAD_SAI1_RX_DATA__NAND_CE1_B | MUX_PAD_CTRL(NAND_PAD_CTRL),
996e1a41cdSPeng Fan MX7D_PAD_SAI1_TX_BCLK__NAND_CE0_B | MUX_PAD_CTRL(NAND_PAD_CTRL),
1006e1a41cdSPeng Fan MX7D_PAD_SAI1_TX_SYNC__NAND_DQS | MUX_PAD_CTRL(NAND_PAD_CTRL),
1016e1a41cdSPeng Fan MX7D_PAD_SAI1_TX_DATA__NAND_READY_B | MUX_PAD_CTRL(NAND_PAD_READY0_CTRL),
1026e1a41cdSPeng Fan };
1036e1a41cdSPeng Fan
setup_gpmi_nand(void)1046e1a41cdSPeng Fan static void setup_gpmi_nand(void)
1056e1a41cdSPeng Fan {
1066e1a41cdSPeng Fan imx_iomux_v3_setup_multiple_pads(gpmi_pads, ARRAY_SIZE(gpmi_pads));
1076e1a41cdSPeng Fan
1086e1a41cdSPeng Fan /* NAND_USDHC_BUS_CLK is set in rom */
1096e1a41cdSPeng Fan set_clk_nand();
1106e1a41cdSPeng Fan }
1116e1a41cdSPeng Fan #endif
1126e1a41cdSPeng Fan
113ebe517b6SPeng Fan #ifdef CONFIG_VIDEO_MXS
114ebe517b6SPeng Fan static iomux_v3_cfg_t const lcd_pads[] = {
115ebe517b6SPeng Fan MX7D_PAD_LCD_CLK__LCD_CLK | MUX_PAD_CTRL(LCD_PAD_CTRL),
116ebe517b6SPeng Fan MX7D_PAD_LCD_ENABLE__LCD_ENABLE | MUX_PAD_CTRL(LCD_PAD_CTRL),
117ebe517b6SPeng Fan MX7D_PAD_LCD_HSYNC__LCD_HSYNC | MUX_PAD_CTRL(LCD_PAD_CTRL),
118ebe517b6SPeng Fan MX7D_PAD_LCD_VSYNC__LCD_VSYNC | MUX_PAD_CTRL(LCD_PAD_CTRL),
119ebe517b6SPeng Fan MX7D_PAD_LCD_DATA00__LCD_DATA0 | MUX_PAD_CTRL(LCD_PAD_CTRL),
120ebe517b6SPeng Fan MX7D_PAD_LCD_DATA01__LCD_DATA1 | MUX_PAD_CTRL(LCD_PAD_CTRL),
121ebe517b6SPeng Fan MX7D_PAD_LCD_DATA02__LCD_DATA2 | MUX_PAD_CTRL(LCD_PAD_CTRL),
122ebe517b6SPeng Fan MX7D_PAD_LCD_DATA03__LCD_DATA3 | MUX_PAD_CTRL(LCD_PAD_CTRL),
123ebe517b6SPeng Fan MX7D_PAD_LCD_DATA04__LCD_DATA4 | MUX_PAD_CTRL(LCD_PAD_CTRL),
124ebe517b6SPeng Fan MX7D_PAD_LCD_DATA05__LCD_DATA5 | MUX_PAD_CTRL(LCD_PAD_CTRL),
125ebe517b6SPeng Fan MX7D_PAD_LCD_DATA06__LCD_DATA6 | MUX_PAD_CTRL(LCD_PAD_CTRL),
126ebe517b6SPeng Fan MX7D_PAD_LCD_DATA07__LCD_DATA7 | MUX_PAD_CTRL(LCD_PAD_CTRL),
127ebe517b6SPeng Fan MX7D_PAD_LCD_DATA08__LCD_DATA8 | MUX_PAD_CTRL(LCD_PAD_CTRL),
128ebe517b6SPeng Fan MX7D_PAD_LCD_DATA09__LCD_DATA9 | MUX_PAD_CTRL(LCD_PAD_CTRL),
129ebe517b6SPeng Fan MX7D_PAD_LCD_DATA10__LCD_DATA10 | MUX_PAD_CTRL(LCD_PAD_CTRL),
130ebe517b6SPeng Fan MX7D_PAD_LCD_DATA11__LCD_DATA11 | MUX_PAD_CTRL(LCD_PAD_CTRL),
131ebe517b6SPeng Fan MX7D_PAD_LCD_DATA12__LCD_DATA12 | MUX_PAD_CTRL(LCD_PAD_CTRL),
132ebe517b6SPeng Fan MX7D_PAD_LCD_DATA13__LCD_DATA13 | MUX_PAD_CTRL(LCD_PAD_CTRL),
133ebe517b6SPeng Fan MX7D_PAD_LCD_DATA14__LCD_DATA14 | MUX_PAD_CTRL(LCD_PAD_CTRL),
134ebe517b6SPeng Fan MX7D_PAD_LCD_DATA15__LCD_DATA15 | MUX_PAD_CTRL(LCD_PAD_CTRL),
135ebe517b6SPeng Fan MX7D_PAD_LCD_DATA16__LCD_DATA16 | MUX_PAD_CTRL(LCD_PAD_CTRL),
136ebe517b6SPeng Fan MX7D_PAD_LCD_DATA17__LCD_DATA17 | MUX_PAD_CTRL(LCD_PAD_CTRL),
137ebe517b6SPeng Fan MX7D_PAD_LCD_DATA18__LCD_DATA18 | MUX_PAD_CTRL(LCD_PAD_CTRL),
138ebe517b6SPeng Fan MX7D_PAD_LCD_DATA19__LCD_DATA19 | MUX_PAD_CTRL(LCD_PAD_CTRL),
139ebe517b6SPeng Fan MX7D_PAD_LCD_DATA20__LCD_DATA20 | MUX_PAD_CTRL(LCD_PAD_CTRL),
140ebe517b6SPeng Fan MX7D_PAD_LCD_DATA21__LCD_DATA21 | MUX_PAD_CTRL(LCD_PAD_CTRL),
141ebe517b6SPeng Fan MX7D_PAD_LCD_DATA22__LCD_DATA22 | MUX_PAD_CTRL(LCD_PAD_CTRL),
142ebe517b6SPeng Fan MX7D_PAD_LCD_DATA23__LCD_DATA23 | MUX_PAD_CTRL(LCD_PAD_CTRL),
143ebe517b6SPeng Fan
144ebe517b6SPeng Fan MX7D_PAD_LCD_RESET__GPIO3_IO4 | MUX_PAD_CTRL(LCD_PAD_CTRL),
145ebe517b6SPeng Fan };
146ebe517b6SPeng Fan
147ebe517b6SPeng Fan static iomux_v3_cfg_t const pwm_pads[] = {
148ebe517b6SPeng Fan /* Use GPIO for Brightness adjustment, duty cycle = period */
149ebe517b6SPeng Fan MX7D_PAD_GPIO1_IO01__GPIO1_IO1 | MUX_PAD_CTRL(NO_PAD_CTRL),
150ebe517b6SPeng Fan };
151ebe517b6SPeng Fan
setup_lcd(void)152ebe517b6SPeng Fan static int setup_lcd(void)
153ebe517b6SPeng Fan {
154ebe517b6SPeng Fan imx_iomux_v3_setup_multiple_pads(lcd_pads, ARRAY_SIZE(lcd_pads));
155ebe517b6SPeng Fan
156ebe517b6SPeng Fan imx_iomux_v3_setup_multiple_pads(pwm_pads, ARRAY_SIZE(pwm_pads));
157ebe517b6SPeng Fan
158ebe517b6SPeng Fan /* Reset LCD */
1596fbbcfdfSPeng Fan gpio_request(IMX_GPIO_NR(3, 4), "lcd reset");
160ebe517b6SPeng Fan gpio_direction_output(IMX_GPIO_NR(3, 4) , 0);
161ebe517b6SPeng Fan udelay(500);
162ebe517b6SPeng Fan gpio_direction_output(IMX_GPIO_NR(3, 4) , 1);
163ebe517b6SPeng Fan
164ebe517b6SPeng Fan /* Set Brightness to high */
1656fbbcfdfSPeng Fan gpio_request(IMX_GPIO_NR(1, 1), "lcd backlight");
166ebe517b6SPeng Fan gpio_direction_output(IMX_GPIO_NR(1, 1) , 1);
167ebe517b6SPeng Fan
168ebe517b6SPeng Fan return 0;
169ebe517b6SPeng Fan }
170ebe517b6SPeng Fan #endif
171ebe517b6SPeng Fan
1721a8150d4SAdrian Alonso #ifdef CONFIG_FEC_MXC
1731a8150d4SAdrian Alonso static iomux_v3_cfg_t const fec1_pads[] = {
1741a8150d4SAdrian Alonso MX7D_PAD_ENET1_RGMII_RX_CTL__ENET1_RGMII_RX_CTL | MUX_PAD_CTRL(ENET_RX_PAD_CTRL),
1751a8150d4SAdrian Alonso MX7D_PAD_ENET1_RGMII_RD0__ENET1_RGMII_RD0 | MUX_PAD_CTRL(ENET_RX_PAD_CTRL),
1761a8150d4SAdrian Alonso MX7D_PAD_ENET1_RGMII_RD1__ENET1_RGMII_RD1 | MUX_PAD_CTRL(ENET_RX_PAD_CTRL),
1771a8150d4SAdrian Alonso MX7D_PAD_ENET1_RGMII_RD2__ENET1_RGMII_RD2 | MUX_PAD_CTRL(ENET_RX_PAD_CTRL),
1781a8150d4SAdrian Alonso MX7D_PAD_ENET1_RGMII_RD3__ENET1_RGMII_RD3 | MUX_PAD_CTRL(ENET_RX_PAD_CTRL),
1791a8150d4SAdrian Alonso MX7D_PAD_ENET1_RGMII_RXC__ENET1_RGMII_RXC | MUX_PAD_CTRL(ENET_RX_PAD_CTRL),
1801a8150d4SAdrian Alonso MX7D_PAD_ENET1_RGMII_TX_CTL__ENET1_RGMII_TX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL),
1811a8150d4SAdrian Alonso MX7D_PAD_ENET1_RGMII_TD0__ENET1_RGMII_TD0 | MUX_PAD_CTRL(ENET_PAD_CTRL),
1821a8150d4SAdrian Alonso MX7D_PAD_ENET1_RGMII_TD1__ENET1_RGMII_TD1 | MUX_PAD_CTRL(ENET_PAD_CTRL),
1831a8150d4SAdrian Alonso MX7D_PAD_ENET1_RGMII_TD2__ENET1_RGMII_TD2 | MUX_PAD_CTRL(ENET_PAD_CTRL),
1841a8150d4SAdrian Alonso MX7D_PAD_ENET1_RGMII_TD3__ENET1_RGMII_TD3 | MUX_PAD_CTRL(ENET_PAD_CTRL),
1851a8150d4SAdrian Alonso MX7D_PAD_ENET1_RGMII_TXC__ENET1_RGMII_TXC | MUX_PAD_CTRL(ENET_PAD_CTRL),
1861a8150d4SAdrian Alonso MX7D_PAD_GPIO1_IO10__ENET1_MDIO | MUX_PAD_CTRL(ENET_PAD_CTRL_MII),
1871a8150d4SAdrian Alonso MX7D_PAD_GPIO1_IO11__ENET1_MDC | MUX_PAD_CTRL(ENET_PAD_CTRL_MII),
1881a8150d4SAdrian Alonso };
1891a8150d4SAdrian Alonso
setup_iomux_fec(void)1901a8150d4SAdrian Alonso static void setup_iomux_fec(void)
1911a8150d4SAdrian Alonso {
1921a8150d4SAdrian Alonso imx_iomux_v3_setup_multiple_pads(fec1_pads, ARRAY_SIZE(fec1_pads));
1931a8150d4SAdrian Alonso }
1941a8150d4SAdrian Alonso #endif
1951a8150d4SAdrian Alonso
setup_iomux_uart(void)1961a8150d4SAdrian Alonso static void setup_iomux_uart(void)
1971a8150d4SAdrian Alonso {
1981a8150d4SAdrian Alonso imx_iomux_v3_setup_multiple_pads(uart1_pads, ARRAY_SIZE(uart1_pads));
1991a8150d4SAdrian Alonso }
2001a8150d4SAdrian Alonso
board_mmc_get_env_dev(int devno)20162d8cce9SPeng Fan int board_mmc_get_env_dev(int devno)
2021a8150d4SAdrian Alonso {
20362d8cce9SPeng Fan if (devno == 2)
20462d8cce9SPeng Fan devno--;
2051a8150d4SAdrian Alonso
20662d8cce9SPeng Fan return devno;
2071a8150d4SAdrian Alonso }
2081a8150d4SAdrian Alonso
mmc_map_to_kernel_blk(int dev_no)2096fbbcfdfSPeng Fan int mmc_map_to_kernel_blk(int dev_no)
2101a8150d4SAdrian Alonso {
2111a8150d4SAdrian Alonso if (dev_no == 1)
2121a8150d4SAdrian Alonso dev_no++;
2131a8150d4SAdrian Alonso
2141a8150d4SAdrian Alonso return dev_no;
2151a8150d4SAdrian Alonso }
2161a8150d4SAdrian Alonso
2171a8150d4SAdrian Alonso #ifdef CONFIG_FEC_MXC
board_eth_init(bd_t * bis)2181a8150d4SAdrian Alonso int board_eth_init(bd_t *bis)
2191a8150d4SAdrian Alonso {
2201a8150d4SAdrian Alonso int ret;
221709fef51SPeng Fan unsigned int gpio;
222709fef51SPeng Fan
223709fef51SPeng Fan ret = gpio_lookup_name("gpio_spi@0_5", NULL, NULL, &gpio);
224709fef51SPeng Fan if (ret) {
225709fef51SPeng Fan printf("GPIO: 'gpio_spi@0_5' not found\n");
226709fef51SPeng Fan return -ENODEV;
227709fef51SPeng Fan }
228709fef51SPeng Fan
229709fef51SPeng Fan ret = gpio_request(gpio, "fec_rst");
230709fef51SPeng Fan if (ret && ret != -EBUSY) {
231709fef51SPeng Fan printf("gpio: requesting pin %u failed\n", gpio);
232709fef51SPeng Fan return ret;
233709fef51SPeng Fan }
234709fef51SPeng Fan
235709fef51SPeng Fan gpio_direction_output(gpio, 0);
236709fef51SPeng Fan udelay(500);
237709fef51SPeng Fan gpio_direction_output(gpio, 1);
2381a8150d4SAdrian Alonso
2391a8150d4SAdrian Alonso setup_iomux_fec();
2401a8150d4SAdrian Alonso
2411a8150d4SAdrian Alonso ret = fecmxc_initialize_multi(bis, 0,
2421a8150d4SAdrian Alonso CONFIG_FEC_MXC_PHYADDR, IMX_FEC_BASE);
2431a8150d4SAdrian Alonso if (ret)
2441a8150d4SAdrian Alonso printf("FEC1 MXC: %s:failed\n", __func__);
2451a8150d4SAdrian Alonso
2461a8150d4SAdrian Alonso return ret;
2471a8150d4SAdrian Alonso }
2481a8150d4SAdrian Alonso
setup_fec(void)2491a8150d4SAdrian Alonso static int setup_fec(void)
2501a8150d4SAdrian Alonso {
2511a8150d4SAdrian Alonso struct iomuxc_gpr_base_regs *const iomuxc_gpr_regs
2521a8150d4SAdrian Alonso = (struct iomuxc_gpr_base_regs *) IOMUXC_GPR_BASE_ADDR;
2531a8150d4SAdrian Alonso
2541a8150d4SAdrian Alonso /* Use 125M anatop REF_CLK1 for ENET1, clear gpr1[13], gpr1[17]*/
2551a8150d4SAdrian Alonso clrsetbits_le32(&iomuxc_gpr_regs->gpr[1],
2561a8150d4SAdrian Alonso (IOMUXC_GPR_GPR1_GPR_ENET1_TX_CLK_SEL_MASK |
2571a8150d4SAdrian Alonso IOMUXC_GPR_GPR1_GPR_ENET1_CLK_DIR_MASK), 0);
2581a8150d4SAdrian Alonso
2598590786aSEric Nelson return set_clk_enet(ENET_125MHZ);
2601a8150d4SAdrian Alonso }
2611a8150d4SAdrian Alonso
2621a8150d4SAdrian Alonso
board_phy_config(struct phy_device * phydev)2631a8150d4SAdrian Alonso int board_phy_config(struct phy_device *phydev)
2641a8150d4SAdrian Alonso {
2651a8150d4SAdrian Alonso /* enable rgmii rxc skew and phy mode select to RGMII copper */
2661a8150d4SAdrian Alonso phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x21);
2671a8150d4SAdrian Alonso phy_write(phydev, MDIO_DEVAD_NONE, 0x1f, 0x7ea8);
2681a8150d4SAdrian Alonso phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x2f);
2691a8150d4SAdrian Alonso phy_write(phydev, MDIO_DEVAD_NONE, 0x1f, 0x71b7);
2701a8150d4SAdrian Alonso
2711a8150d4SAdrian Alonso if (phydev->drv->config)
2721a8150d4SAdrian Alonso phydev->drv->config(phydev);
2731a8150d4SAdrian Alonso return 0;
2741a8150d4SAdrian Alonso }
2751a8150d4SAdrian Alonso #endif
2761a8150d4SAdrian Alonso
27753cc647dSPeng Fan #ifdef CONFIG_FSL_QSPI
board_qspi_init(void)27853cc647dSPeng Fan int board_qspi_init(void)
27953cc647dSPeng Fan {
28053cc647dSPeng Fan /* Set the clock */
28153cc647dSPeng Fan set_clk_qspi();
28253cc647dSPeng Fan
28353cc647dSPeng Fan return 0;
28453cc647dSPeng Fan }
28553cc647dSPeng Fan #endif
28653cc647dSPeng Fan
board_early_init_f(void)2871a8150d4SAdrian Alonso int board_early_init_f(void)
2881a8150d4SAdrian Alonso {
2891a8150d4SAdrian Alonso setup_iomux_uart();
2901a8150d4SAdrian Alonso
2911a8150d4SAdrian Alonso return 0;
2921a8150d4SAdrian Alonso }
2931a8150d4SAdrian Alonso
board_init(void)2941a8150d4SAdrian Alonso int board_init(void)
2951a8150d4SAdrian Alonso {
2961a8150d4SAdrian Alonso /* address of boot parameters */
2971a8150d4SAdrian Alonso gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
2981a8150d4SAdrian Alonso
2991a8150d4SAdrian Alonso #ifdef CONFIG_FEC_MXC
3001a8150d4SAdrian Alonso setup_fec();
3011a8150d4SAdrian Alonso #endif
3021a8150d4SAdrian Alonso
3036e1a41cdSPeng Fan #ifdef CONFIG_NAND_MXS
3046e1a41cdSPeng Fan setup_gpmi_nand();
3056e1a41cdSPeng Fan #endif
3066e1a41cdSPeng Fan
307ebe517b6SPeng Fan #ifdef CONFIG_VIDEO_MXS
308ebe517b6SPeng Fan setup_lcd();
309ebe517b6SPeng Fan #endif
310ebe517b6SPeng Fan
31153cc647dSPeng Fan #ifdef CONFIG_FSL_QSPI
31253cc647dSPeng Fan board_qspi_init();
31353cc647dSPeng Fan #endif
31453cc647dSPeng Fan
3159cd37b02SAngus Ainslie #ifdef CONFIG_MXC_SPI
3169cd37b02SAngus Ainslie setup_spi();
3179cd37b02SAngus Ainslie #endif
3189cd37b02SAngus Ainslie
3191a8150d4SAdrian Alonso return 0;
3201a8150d4SAdrian Alonso }
3211a8150d4SAdrian Alonso
3226fbbcfdfSPeng Fan #ifdef CONFIG_DM_PMIC
power_init_board(void)3231a8150d4SAdrian Alonso int power_init_board(void)
3241a8150d4SAdrian Alonso {
3256fbbcfdfSPeng Fan struct udevice *dev;
3266fbbcfdfSPeng Fan int ret, dev_id, rev_id;
3271a8150d4SAdrian Alonso
3286fbbcfdfSPeng Fan ret = pmic_get("pfuze3000", &dev);
3296fbbcfdfSPeng Fan if (ret == -ENODEV)
3306fbbcfdfSPeng Fan return 0;
3316fbbcfdfSPeng Fan if (ret != 0)
3321a8150d4SAdrian Alonso return ret;
3331a8150d4SAdrian Alonso
3346fbbcfdfSPeng Fan dev_id = pmic_reg_read(dev, PFUZE3000_DEVICEID);
3356fbbcfdfSPeng Fan rev_id = pmic_reg_read(dev, PFUZE3000_REVID);
3366fbbcfdfSPeng Fan printf("PMIC: PFUZE3000 DEV_ID=0x%x REV_ID=0x%x\n", dev_id, rev_id);
3371a8150d4SAdrian Alonso
3386fbbcfdfSPeng Fan pmic_clrsetbits(dev, PFUZE3000_LDOGCTL, 0, 1);
3391a8150d4SAdrian Alonso
340d8fab10cSGautam Bhat /*
341d8fab10cSGautam Bhat * Set the voltage of VLDO4 output to 2.8V which feeds
342d8fab10cSGautam Bhat * the MIPI DSI and MIPI CSI inputs.
343d8fab10cSGautam Bhat */
344d8fab10cSGautam Bhat pmic_clrsetbits(dev, PFUZE3000_VLD4CTL, 0xF, 0xA);
345d8fab10cSGautam Bhat
3461a8150d4SAdrian Alonso return 0;
3471a8150d4SAdrian Alonso }
3481a8150d4SAdrian Alonso #endif
3491a8150d4SAdrian Alonso
board_late_init(void)3501a8150d4SAdrian Alonso int board_late_init(void)
3511a8150d4SAdrian Alonso {
3524fae48e8SPeng Fan struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR;
3534fae48e8SPeng Fan
3541a8150d4SAdrian Alonso imx_iomux_v3_setup_multiple_pads(wdog_pads, ARRAY_SIZE(wdog_pads));
3551a8150d4SAdrian Alonso
3564fae48e8SPeng Fan set_wdog_reset(wdog);
3574fae48e8SPeng Fan
3584fae48e8SPeng Fan /*
3594fae48e8SPeng Fan * Do not assert internal WDOG_RESET_B_DEB(controlled by bit 4),
3604fae48e8SPeng Fan * since we use PMIC_PWRON to reset the board.
3614fae48e8SPeng Fan */
3624fae48e8SPeng Fan clrsetbits_le16(&wdog->wcr, 0, 0x10);
3631a8150d4SAdrian Alonso
3641a8150d4SAdrian Alonso return 0;
3651a8150d4SAdrian Alonso }
3661a8150d4SAdrian Alonso
checkboard(void)3671a8150d4SAdrian Alonso int checkboard(void)
3681a8150d4SAdrian Alonso {
36976b21efdSFabio Estevam char *mode;
37076b21efdSFabio Estevam
37176b21efdSFabio Estevam if (IS_ENABLED(CONFIG_ARMV7_BOOT_SEC_DEFAULT))
37276b21efdSFabio Estevam mode = "secure";
37376b21efdSFabio Estevam else
37476b21efdSFabio Estevam mode = "non-secure";
37576b21efdSFabio Estevam
37676b21efdSFabio Estevam printf("Board: i.MX7D SABRESD in %s mode\n", mode);
3771a8150d4SAdrian Alonso
3781a8150d4SAdrian Alonso return 0;
3791a8150d4SAdrian Alonso }
380