Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2015 Freescale Semiconductor, Inc. |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 4 | */ |
| 5 | |
Simon Glass | a7b5130 | 2019-11-14 12:57:46 -0700 | [diff] [blame^] | 6 | #include <init.h> |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 7 | #include <asm/arch/clock.h> |
| 8 | #include <asm/arch/imx-regs.h> |
| 9 | #include <asm/arch/mx7-pins.h> |
| 10 | #include <asm/arch/sys_proto.h> |
| 11 | #include <asm/gpio.h> |
Stefano Babic | 33731bc | 2017-06-29 10:16:06 +0200 | [diff] [blame] | 12 | #include <asm/mach-imx/iomux-v3.h> |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 13 | #include <asm/io.h> |
| 14 | #include <linux/sizes.h> |
| 15 | #include <common.h> |
Yangbo Lu | 7334038 | 2019-06-21 11:42:28 +0800 | [diff] [blame] | 16 | #include <fsl_esdhc_imx.h> |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 17 | #include <mmc.h> |
| 18 | #include <miiphy.h> |
| 19 | #include <netdev.h> |
| 20 | #include <power/pmic.h> |
| 21 | #include <power/pfuze3000_pmic.h> |
| 22 | #include "../common/pfuze.h" |
| 23 | #include <i2c.h> |
Stefano Babic | 33731bc | 2017-06-29 10:16:06 +0200 | [diff] [blame] | 24 | #include <asm/mach-imx/mxc_i2c.h> |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 25 | #include <asm/arch/crm_regs.h> |
| 26 | |
| 27 | DECLARE_GLOBAL_DATA_PTR; |
| 28 | |
| 29 | #define UART_PAD_CTRL (PAD_CTL_DSE_3P3V_49OHM | \ |
| 30 | PAD_CTL_PUS_PU100KOHM | PAD_CTL_HYS) |
| 31 | |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 32 | #define ENET_PAD_CTRL (PAD_CTL_PUS_PU100KOHM | PAD_CTL_DSE_3P3V_49OHM) |
| 33 | #define ENET_PAD_CTRL_MII (PAD_CTL_DSE_3P3V_32OHM) |
| 34 | |
| 35 | #define ENET_RX_PAD_CTRL (PAD_CTL_PUS_PU100KOHM | PAD_CTL_DSE_3P3V_49OHM) |
| 36 | |
Peng Fan | 55be1ed | 2015-10-29 15:54:53 +0800 | [diff] [blame] | 37 | #define LCD_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_PUS_PU100KOHM | \ |
| 38 | PAD_CTL_DSE_3P3V_49OHM) |
| 39 | |
Peng Fan | 62f9260 | 2015-12-22 17:04:24 +0800 | [diff] [blame] | 40 | #define NAND_PAD_CTRL (PAD_CTL_DSE_3P3V_49OHM | PAD_CTL_SRE_SLOW | PAD_CTL_HYS) |
| 41 | |
Angus Ainslie | aa7ea8c | 2016-11-11 11:31:39 -0700 | [diff] [blame] | 42 | #define SPI_PAD_CTRL \ |
| 43 | (PAD_CTL_HYS | PAD_CTL_DSE_3P3V_49OHM | PAD_CTL_SRE_FAST) |
| 44 | |
Peng Fan | 62f9260 | 2015-12-22 17:04:24 +0800 | [diff] [blame] | 45 | #define NAND_PAD_READY0_CTRL (PAD_CTL_DSE_3P3V_49OHM | PAD_CTL_PUS_PU5KOHM) |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 46 | |
Peng Fan | 9aa9c41 | 2017-04-13 14:09:57 +0800 | [diff] [blame] | 47 | #ifdef CONFIG_MXC_SPI |
Angus Ainslie | aa7ea8c | 2016-11-11 11:31:39 -0700 | [diff] [blame] | 48 | static iomux_v3_cfg_t const ecspi3_pads[] = { |
| 49 | MX7D_PAD_SAI2_RX_DATA__ECSPI3_SCLK | MUX_PAD_CTRL(SPI_PAD_CTRL), |
| 50 | MX7D_PAD_SAI2_TX_SYNC__ECSPI3_MISO | MUX_PAD_CTRL(SPI_PAD_CTRL), |
| 51 | MX7D_PAD_SAI2_TX_BCLK__ECSPI3_MOSI | MUX_PAD_CTRL(SPI_PAD_CTRL), |
| 52 | MX7D_PAD_SAI2_TX_DATA__GPIO6_IO22 | MUX_PAD_CTRL(NO_PAD_CTRL), |
| 53 | }; |
| 54 | |
| 55 | int board_spi_cs_gpio(unsigned bus, unsigned cs) |
| 56 | { |
| 57 | return (bus == 2 && cs == 0) ? (IMX_GPIO_NR(6, 22)) : -1; |
| 58 | } |
| 59 | |
| 60 | static void setup_spi(void) |
| 61 | { |
| 62 | imx_iomux_v3_setup_multiple_pads(ecspi3_pads, ARRAY_SIZE(ecspi3_pads)); |
| 63 | } |
Peng Fan | 9aa9c41 | 2017-04-13 14:09:57 +0800 | [diff] [blame] | 64 | #endif |
Angus Ainslie | aa7ea8c | 2016-11-11 11:31:39 -0700 | [diff] [blame] | 65 | |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 66 | int dram_init(void) |
| 67 | { |
| 68 | gd->ram_size = PHYS_SDRAM_SIZE; |
| 69 | |
| 70 | return 0; |
| 71 | } |
| 72 | |
| 73 | static iomux_v3_cfg_t const wdog_pads[] = { |
| 74 | MX7D_PAD_GPIO1_IO00__WDOG1_WDOG_B | MUX_PAD_CTRL(NO_PAD_CTRL), |
| 75 | }; |
| 76 | |
| 77 | static iomux_v3_cfg_t const uart1_pads[] = { |
| 78 | MX7D_PAD_UART1_TX_DATA__UART1_DCE_TX | MUX_PAD_CTRL(UART_PAD_CTRL), |
| 79 | MX7D_PAD_UART1_RX_DATA__UART1_DCE_RX | MUX_PAD_CTRL(UART_PAD_CTRL), |
| 80 | }; |
| 81 | |
Peng Fan | 62f9260 | 2015-12-22 17:04:24 +0800 | [diff] [blame] | 82 | #ifdef CONFIG_NAND_MXS |
| 83 | static iomux_v3_cfg_t const gpmi_pads[] = { |
| 84 | MX7D_PAD_SD3_DATA0__NAND_DATA00 | MUX_PAD_CTRL(NAND_PAD_CTRL), |
| 85 | MX7D_PAD_SD3_DATA1__NAND_DATA01 | MUX_PAD_CTRL(NAND_PAD_CTRL), |
| 86 | MX7D_PAD_SD3_DATA2__NAND_DATA02 | MUX_PAD_CTRL(NAND_PAD_CTRL), |
| 87 | MX7D_PAD_SD3_DATA3__NAND_DATA03 | MUX_PAD_CTRL(NAND_PAD_CTRL), |
| 88 | MX7D_PAD_SD3_DATA4__NAND_DATA04 | MUX_PAD_CTRL(NAND_PAD_CTRL), |
| 89 | MX7D_PAD_SD3_DATA5__NAND_DATA05 | MUX_PAD_CTRL(NAND_PAD_CTRL), |
| 90 | MX7D_PAD_SD3_DATA6__NAND_DATA06 | MUX_PAD_CTRL(NAND_PAD_CTRL), |
| 91 | MX7D_PAD_SD3_DATA7__NAND_DATA07 | MUX_PAD_CTRL(NAND_PAD_CTRL), |
| 92 | MX7D_PAD_SD3_CLK__NAND_CLE | MUX_PAD_CTRL(NAND_PAD_CTRL), |
| 93 | MX7D_PAD_SD3_CMD__NAND_ALE | MUX_PAD_CTRL(NAND_PAD_CTRL), |
| 94 | MX7D_PAD_SD3_STROBE__NAND_RE_B | MUX_PAD_CTRL(NAND_PAD_CTRL), |
| 95 | MX7D_PAD_SD3_RESET_B__NAND_WE_B | MUX_PAD_CTRL(NAND_PAD_CTRL), |
| 96 | MX7D_PAD_SAI1_MCLK__NAND_WP_B | MUX_PAD_CTRL(NAND_PAD_CTRL), |
| 97 | MX7D_PAD_SAI1_RX_BCLK__NAND_CE3_B | MUX_PAD_CTRL(NAND_PAD_CTRL), |
| 98 | MX7D_PAD_SAI1_RX_SYNC__NAND_CE2_B | MUX_PAD_CTRL(NAND_PAD_CTRL), |
| 99 | MX7D_PAD_SAI1_RX_DATA__NAND_CE1_B | MUX_PAD_CTRL(NAND_PAD_CTRL), |
| 100 | MX7D_PAD_SAI1_TX_BCLK__NAND_CE0_B | MUX_PAD_CTRL(NAND_PAD_CTRL), |
| 101 | MX7D_PAD_SAI1_TX_SYNC__NAND_DQS | MUX_PAD_CTRL(NAND_PAD_CTRL), |
| 102 | MX7D_PAD_SAI1_TX_DATA__NAND_READY_B | MUX_PAD_CTRL(NAND_PAD_READY0_CTRL), |
| 103 | }; |
| 104 | |
| 105 | static void setup_gpmi_nand(void) |
| 106 | { |
| 107 | imx_iomux_v3_setup_multiple_pads(gpmi_pads, ARRAY_SIZE(gpmi_pads)); |
| 108 | |
| 109 | /* NAND_USDHC_BUS_CLK is set in rom */ |
| 110 | set_clk_nand(); |
| 111 | } |
| 112 | #endif |
| 113 | |
Peng Fan | 55be1ed | 2015-10-29 15:54:53 +0800 | [diff] [blame] | 114 | #ifdef CONFIG_VIDEO_MXS |
| 115 | static iomux_v3_cfg_t const lcd_pads[] = { |
| 116 | MX7D_PAD_LCD_CLK__LCD_CLK | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 117 | MX7D_PAD_LCD_ENABLE__LCD_ENABLE | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 118 | MX7D_PAD_LCD_HSYNC__LCD_HSYNC | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 119 | MX7D_PAD_LCD_VSYNC__LCD_VSYNC | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 120 | MX7D_PAD_LCD_DATA00__LCD_DATA0 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 121 | MX7D_PAD_LCD_DATA01__LCD_DATA1 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 122 | MX7D_PAD_LCD_DATA02__LCD_DATA2 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 123 | MX7D_PAD_LCD_DATA03__LCD_DATA3 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 124 | MX7D_PAD_LCD_DATA04__LCD_DATA4 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 125 | MX7D_PAD_LCD_DATA05__LCD_DATA5 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 126 | MX7D_PAD_LCD_DATA06__LCD_DATA6 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 127 | MX7D_PAD_LCD_DATA07__LCD_DATA7 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 128 | MX7D_PAD_LCD_DATA08__LCD_DATA8 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 129 | MX7D_PAD_LCD_DATA09__LCD_DATA9 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 130 | MX7D_PAD_LCD_DATA10__LCD_DATA10 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 131 | MX7D_PAD_LCD_DATA11__LCD_DATA11 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 132 | MX7D_PAD_LCD_DATA12__LCD_DATA12 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 133 | MX7D_PAD_LCD_DATA13__LCD_DATA13 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 134 | MX7D_PAD_LCD_DATA14__LCD_DATA14 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 135 | MX7D_PAD_LCD_DATA15__LCD_DATA15 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 136 | MX7D_PAD_LCD_DATA16__LCD_DATA16 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 137 | MX7D_PAD_LCD_DATA17__LCD_DATA17 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 138 | MX7D_PAD_LCD_DATA18__LCD_DATA18 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 139 | MX7D_PAD_LCD_DATA19__LCD_DATA19 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 140 | MX7D_PAD_LCD_DATA20__LCD_DATA20 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 141 | MX7D_PAD_LCD_DATA21__LCD_DATA21 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 142 | MX7D_PAD_LCD_DATA22__LCD_DATA22 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 143 | MX7D_PAD_LCD_DATA23__LCD_DATA23 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 144 | |
| 145 | MX7D_PAD_LCD_RESET__GPIO3_IO4 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 146 | }; |
| 147 | |
| 148 | static iomux_v3_cfg_t const pwm_pads[] = { |
| 149 | /* Use GPIO for Brightness adjustment, duty cycle = period */ |
| 150 | MX7D_PAD_GPIO1_IO01__GPIO1_IO1 | MUX_PAD_CTRL(NO_PAD_CTRL), |
| 151 | }; |
| 152 | |
| 153 | static int setup_lcd(void) |
| 154 | { |
| 155 | imx_iomux_v3_setup_multiple_pads(lcd_pads, ARRAY_SIZE(lcd_pads)); |
| 156 | |
| 157 | imx_iomux_v3_setup_multiple_pads(pwm_pads, ARRAY_SIZE(pwm_pads)); |
| 158 | |
| 159 | /* Reset LCD */ |
Peng Fan | 9aa9c41 | 2017-04-13 14:09:57 +0800 | [diff] [blame] | 160 | gpio_request(IMX_GPIO_NR(3, 4), "lcd reset"); |
Peng Fan | 55be1ed | 2015-10-29 15:54:53 +0800 | [diff] [blame] | 161 | gpio_direction_output(IMX_GPIO_NR(3, 4) , 0); |
| 162 | udelay(500); |
| 163 | gpio_direction_output(IMX_GPIO_NR(3, 4) , 1); |
| 164 | |
| 165 | /* Set Brightness to high */ |
Peng Fan | 9aa9c41 | 2017-04-13 14:09:57 +0800 | [diff] [blame] | 166 | gpio_request(IMX_GPIO_NR(1, 1), "lcd backlight"); |
Peng Fan | 55be1ed | 2015-10-29 15:54:53 +0800 | [diff] [blame] | 167 | gpio_direction_output(IMX_GPIO_NR(1, 1) , 1); |
| 168 | |
| 169 | return 0; |
| 170 | } |
| 171 | #endif |
| 172 | |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 173 | #ifdef CONFIG_FEC_MXC |
| 174 | static iomux_v3_cfg_t const fec1_pads[] = { |
| 175 | MX7D_PAD_ENET1_RGMII_RX_CTL__ENET1_RGMII_RX_CTL | MUX_PAD_CTRL(ENET_RX_PAD_CTRL), |
| 176 | MX7D_PAD_ENET1_RGMII_RD0__ENET1_RGMII_RD0 | MUX_PAD_CTRL(ENET_RX_PAD_CTRL), |
| 177 | MX7D_PAD_ENET1_RGMII_RD1__ENET1_RGMII_RD1 | MUX_PAD_CTRL(ENET_RX_PAD_CTRL), |
| 178 | MX7D_PAD_ENET1_RGMII_RD2__ENET1_RGMII_RD2 | MUX_PAD_CTRL(ENET_RX_PAD_CTRL), |
| 179 | MX7D_PAD_ENET1_RGMII_RD3__ENET1_RGMII_RD3 | MUX_PAD_CTRL(ENET_RX_PAD_CTRL), |
| 180 | MX7D_PAD_ENET1_RGMII_RXC__ENET1_RGMII_RXC | MUX_PAD_CTRL(ENET_RX_PAD_CTRL), |
| 181 | MX7D_PAD_ENET1_RGMII_TX_CTL__ENET1_RGMII_TX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 182 | MX7D_PAD_ENET1_RGMII_TD0__ENET1_RGMII_TD0 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 183 | MX7D_PAD_ENET1_RGMII_TD1__ENET1_RGMII_TD1 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 184 | MX7D_PAD_ENET1_RGMII_TD2__ENET1_RGMII_TD2 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 185 | MX7D_PAD_ENET1_RGMII_TD3__ENET1_RGMII_TD3 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 186 | MX7D_PAD_ENET1_RGMII_TXC__ENET1_RGMII_TXC | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 187 | MX7D_PAD_GPIO1_IO10__ENET1_MDIO | MUX_PAD_CTRL(ENET_PAD_CTRL_MII), |
| 188 | MX7D_PAD_GPIO1_IO11__ENET1_MDC | MUX_PAD_CTRL(ENET_PAD_CTRL_MII), |
| 189 | }; |
| 190 | |
| 191 | static void setup_iomux_fec(void) |
| 192 | { |
| 193 | imx_iomux_v3_setup_multiple_pads(fec1_pads, ARRAY_SIZE(fec1_pads)); |
| 194 | } |
| 195 | #endif |
| 196 | |
| 197 | static void setup_iomux_uart(void) |
| 198 | { |
| 199 | imx_iomux_v3_setup_multiple_pads(uart1_pads, ARRAY_SIZE(uart1_pads)); |
| 200 | } |
| 201 | |
Peng Fan | 6c9d8fb | 2016-01-28 16:51:25 +0800 | [diff] [blame] | 202 | int board_mmc_get_env_dev(int devno) |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 203 | { |
Peng Fan | 6c9d8fb | 2016-01-28 16:51:25 +0800 | [diff] [blame] | 204 | if (devno == 2) |
| 205 | devno--; |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 206 | |
Peng Fan | 6c9d8fb | 2016-01-28 16:51:25 +0800 | [diff] [blame] | 207 | return devno; |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 208 | } |
| 209 | |
Peng Fan | 9aa9c41 | 2017-04-13 14:09:57 +0800 | [diff] [blame] | 210 | int mmc_map_to_kernel_blk(int dev_no) |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 211 | { |
| 212 | if (dev_no == 1) |
| 213 | dev_no++; |
| 214 | |
| 215 | return dev_no; |
| 216 | } |
| 217 | |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 218 | #ifdef CONFIG_FEC_MXC |
| 219 | int board_eth_init(bd_t *bis) |
| 220 | { |
| 221 | int ret; |
Peng Fan | 12f4611 | 2017-04-13 14:09:58 +0800 | [diff] [blame] | 222 | unsigned int gpio; |
| 223 | |
| 224 | ret = gpio_lookup_name("gpio_spi@0_5", NULL, NULL, &gpio); |
| 225 | if (ret) { |
| 226 | printf("GPIO: 'gpio_spi@0_5' not found\n"); |
| 227 | return -ENODEV; |
| 228 | } |
| 229 | |
| 230 | ret = gpio_request(gpio, "fec_rst"); |
| 231 | if (ret && ret != -EBUSY) { |
| 232 | printf("gpio: requesting pin %u failed\n", gpio); |
| 233 | return ret; |
| 234 | } |
| 235 | |
| 236 | gpio_direction_output(gpio, 0); |
| 237 | udelay(500); |
| 238 | gpio_direction_output(gpio, 1); |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 239 | |
| 240 | setup_iomux_fec(); |
| 241 | |
| 242 | ret = fecmxc_initialize_multi(bis, 0, |
| 243 | CONFIG_FEC_MXC_PHYADDR, IMX_FEC_BASE); |
| 244 | if (ret) |
| 245 | printf("FEC1 MXC: %s:failed\n", __func__); |
| 246 | |
| 247 | return ret; |
| 248 | } |
| 249 | |
| 250 | static int setup_fec(void) |
| 251 | { |
| 252 | struct iomuxc_gpr_base_regs *const iomuxc_gpr_regs |
| 253 | = (struct iomuxc_gpr_base_regs *) IOMUXC_GPR_BASE_ADDR; |
| 254 | |
| 255 | /* Use 125M anatop REF_CLK1 for ENET1, clear gpr1[13], gpr1[17]*/ |
| 256 | clrsetbits_le32(&iomuxc_gpr_regs->gpr[1], |
| 257 | (IOMUXC_GPR_GPR1_GPR_ENET1_TX_CLK_SEL_MASK | |
| 258 | IOMUXC_GPR_GPR1_GPR_ENET1_CLK_DIR_MASK), 0); |
| 259 | |
Eric Nelson | eadd732 | 2017-08-31 08:34:23 -0700 | [diff] [blame] | 260 | return set_clk_enet(ENET_125MHZ); |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | |
| 264 | int board_phy_config(struct phy_device *phydev) |
| 265 | { |
| 266 | /* enable rgmii rxc skew and phy mode select to RGMII copper */ |
| 267 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x21); |
| 268 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1f, 0x7ea8); |
| 269 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x2f); |
| 270 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1f, 0x71b7); |
| 271 | |
| 272 | if (phydev->drv->config) |
| 273 | phydev->drv->config(phydev); |
| 274 | return 0; |
| 275 | } |
| 276 | #endif |
| 277 | |
Peng Fan | 7431e70 | 2015-11-30 17:45:02 +0800 | [diff] [blame] | 278 | #ifdef CONFIG_FSL_QSPI |
Peng Fan | 7431e70 | 2015-11-30 17:45:02 +0800 | [diff] [blame] | 279 | int board_qspi_init(void) |
| 280 | { |
Peng Fan | 7431e70 | 2015-11-30 17:45:02 +0800 | [diff] [blame] | 281 | /* Set the clock */ |
| 282 | set_clk_qspi(); |
| 283 | |
| 284 | return 0; |
| 285 | } |
| 286 | #endif |
| 287 | |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 288 | int board_early_init_f(void) |
| 289 | { |
| 290 | setup_iomux_uart(); |
| 291 | |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 292 | return 0; |
| 293 | } |
| 294 | |
| 295 | int board_init(void) |
| 296 | { |
| 297 | /* address of boot parameters */ |
| 298 | gd->bd->bi_boot_params = PHYS_SDRAM + 0x100; |
| 299 | |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 300 | #ifdef CONFIG_FEC_MXC |
| 301 | setup_fec(); |
| 302 | #endif |
| 303 | |
Peng Fan | 62f9260 | 2015-12-22 17:04:24 +0800 | [diff] [blame] | 304 | #ifdef CONFIG_NAND_MXS |
| 305 | setup_gpmi_nand(); |
| 306 | #endif |
| 307 | |
Peng Fan | 55be1ed | 2015-10-29 15:54:53 +0800 | [diff] [blame] | 308 | #ifdef CONFIG_VIDEO_MXS |
| 309 | setup_lcd(); |
| 310 | #endif |
| 311 | |
Peng Fan | 7431e70 | 2015-11-30 17:45:02 +0800 | [diff] [blame] | 312 | #ifdef CONFIG_FSL_QSPI |
| 313 | board_qspi_init(); |
| 314 | #endif |
| 315 | |
Angus Ainslie | aa7ea8c | 2016-11-11 11:31:39 -0700 | [diff] [blame] | 316 | #ifdef CONFIG_MXC_SPI |
| 317 | setup_spi(); |
| 318 | #endif |
| 319 | |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 320 | return 0; |
| 321 | } |
| 322 | |
Peng Fan | 9aa9c41 | 2017-04-13 14:09:57 +0800 | [diff] [blame] | 323 | #ifdef CONFIG_DM_PMIC |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 324 | int power_init_board(void) |
| 325 | { |
Peng Fan | 9aa9c41 | 2017-04-13 14:09:57 +0800 | [diff] [blame] | 326 | struct udevice *dev; |
| 327 | int ret, dev_id, rev_id; |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 328 | |
Peng Fan | 9aa9c41 | 2017-04-13 14:09:57 +0800 | [diff] [blame] | 329 | ret = pmic_get("pfuze3000", &dev); |
| 330 | if (ret == -ENODEV) |
| 331 | return 0; |
| 332 | if (ret != 0) |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 333 | return ret; |
| 334 | |
Peng Fan | 9aa9c41 | 2017-04-13 14:09:57 +0800 | [diff] [blame] | 335 | dev_id = pmic_reg_read(dev, PFUZE3000_DEVICEID); |
| 336 | rev_id = pmic_reg_read(dev, PFUZE3000_REVID); |
| 337 | printf("PMIC: PFUZE3000 DEV_ID=0x%x REV_ID=0x%x\n", dev_id, rev_id); |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 338 | |
Peng Fan | 9aa9c41 | 2017-04-13 14:09:57 +0800 | [diff] [blame] | 339 | pmic_clrsetbits(dev, PFUZE3000_LDOGCTL, 0, 1); |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 340 | |
Gautam Bhat | 0782281 | 2017-07-03 00:50:32 +0530 | [diff] [blame] | 341 | /* |
| 342 | * Set the voltage of VLDO4 output to 2.8V which feeds |
| 343 | * the MIPI DSI and MIPI CSI inputs. |
| 344 | */ |
| 345 | pmic_clrsetbits(dev, PFUZE3000_VLD4CTL, 0xF, 0xA); |
| 346 | |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 347 | return 0; |
| 348 | } |
| 349 | #endif |
| 350 | |
| 351 | int board_late_init(void) |
| 352 | { |
Peng Fan | 6b7c3dc | 2015-09-14 13:34:45 +0800 | [diff] [blame] | 353 | struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR; |
| 354 | |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 355 | imx_iomux_v3_setup_multiple_pads(wdog_pads, ARRAY_SIZE(wdog_pads)); |
| 356 | |
Peng Fan | 6b7c3dc | 2015-09-14 13:34:45 +0800 | [diff] [blame] | 357 | set_wdog_reset(wdog); |
| 358 | |
| 359 | /* |
| 360 | * Do not assert internal WDOG_RESET_B_DEB(controlled by bit 4), |
| 361 | * since we use PMIC_PWRON to reset the board. |
| 362 | */ |
| 363 | clrsetbits_le16(&wdog->wcr, 0, 0x10); |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 364 | |
| 365 | return 0; |
| 366 | } |
| 367 | |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 368 | int checkboard(void) |
| 369 | { |
Fabio Estevam | ea696c7 | 2016-07-28 20:49:46 -0300 | [diff] [blame] | 370 | char *mode; |
| 371 | |
| 372 | if (IS_ENABLED(CONFIG_ARMV7_BOOT_SEC_DEFAULT)) |
| 373 | mode = "secure"; |
| 374 | else |
| 375 | mode = "non-secure"; |
| 376 | |
| 377 | printf("Board: i.MX7D SABRESD in %s mode\n", mode); |
Adrian Alonso | 9881077 | 2015-09-03 11:49:28 -0500 | [diff] [blame] | 378 | |
| 379 | return 0; |
| 380 | } |