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