Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Fabio Estevam | 14a1613 | 2014-06-24 17:41:01 -0300 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2014 Freescale Semiconductor, Inc. |
| 4 | * |
| 5 | * Author: Fabio Estevam <fabio.estevam@freescale.com> |
Fabio Estevam | 14a1613 | 2014-06-24 17:41:01 -0300 | [diff] [blame] | 6 | */ |
| 7 | |
Simon Glass | 5255932 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 8 | #include <init.h> |
Fabio Estevam | 14a1613 | 2014-06-24 17:41:01 -0300 | [diff] [blame] | 9 | #include <asm/arch/clock.h> |
Fabio Estevam | d145878 | 2014-08-15 00:24:29 -0300 | [diff] [blame] | 10 | #include <asm/arch/crm_regs.h> |
Fabio Estevam | 14a1613 | 2014-06-24 17:41:01 -0300 | [diff] [blame] | 11 | #include <asm/arch/iomux.h> |
| 12 | #include <asm/arch/imx-regs.h> |
| 13 | #include <asm/arch/mx6-pins.h> |
| 14 | #include <asm/arch/sys_proto.h> |
| 15 | #include <asm/gpio.h> |
Stefano Babic | 552a848 | 2017-06-29 10:16:06 +0200 | [diff] [blame] | 16 | #include <asm/mach-imx/iomux-v3.h> |
Fabio Estevam | 14a1613 | 2014-06-24 17:41:01 -0300 | [diff] [blame] | 17 | #include <asm/io.h> |
Stefano Babic | 552a848 | 2017-06-29 10:16:06 +0200 | [diff] [blame] | 18 | #include <asm/mach-imx/mxc_i2c.h> |
Simon Glass | 9fb625c | 2019-08-01 09:46:51 -0600 | [diff] [blame] | 19 | #include <env.h> |
Fabio Estevam | 14a1613 | 2014-06-24 17:41:01 -0300 | [diff] [blame] | 20 | #include <linux/sizes.h> |
| 21 | #include <common.h> |
Yangbo Lu | e37ac71 | 2019-06-21 11:42:28 +0800 | [diff] [blame] | 22 | #include <fsl_esdhc_imx.h> |
Fabio Estevam | 14a1613 | 2014-06-24 17:41:01 -0300 | [diff] [blame] | 23 | #include <mmc.h> |
Fabio Estevam | fa8cf31 | 2014-07-09 16:13:30 -0300 | [diff] [blame] | 24 | #include <i2c.h> |
Fabio Estevam | d145878 | 2014-08-15 00:24:29 -0300 | [diff] [blame] | 25 | #include <miiphy.h> |
| 26 | #include <netdev.h> |
Fabio Estevam | fa8cf31 | 2014-07-09 16:13:30 -0300 | [diff] [blame] | 27 | #include <power/pmic.h> |
| 28 | #include <power/pfuze100_pmic.h> |
Ye.Li | 1f98e31 | 2014-11-06 16:29:01 +0800 | [diff] [blame] | 29 | #include "../common/pfuze.h" |
Fabio Estevam | 14a1613 | 2014-06-24 17:41:01 -0300 | [diff] [blame] | 30 | |
| 31 | DECLARE_GLOBAL_DATA_PTR; |
| 32 | |
| 33 | #define UART_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE | \ |
| 34 | PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \ |
| 35 | PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST | PAD_CTL_HYS) |
| 36 | |
| 37 | #define USDHC_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE | \ |
| 38 | PAD_CTL_PUS_22K_UP | PAD_CTL_SPEED_LOW | \ |
| 39 | PAD_CTL_DSE_80ohm | PAD_CTL_SRE_FAST | PAD_CTL_HYS) |
| 40 | |
Fabio Estevam | d145878 | 2014-08-15 00:24:29 -0300 | [diff] [blame] | 41 | #define ENET_PAD_CTRL (PAD_CTL_PUS_100K_UP | PAD_CTL_PUE | \ |
| 42 | PAD_CTL_SPEED_HIGH | \ |
| 43 | PAD_CTL_DSE_48ohm | PAD_CTL_SRE_FAST) |
| 44 | |
| 45 | #define ENET_CLK_PAD_CTRL (PAD_CTL_SPEED_MED | \ |
| 46 | PAD_CTL_DSE_120ohm | PAD_CTL_SRE_FAST) |
| 47 | |
| 48 | #define ENET_RX_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE | \ |
| 49 | PAD_CTL_SPEED_HIGH | PAD_CTL_SRE_FAST) |
| 50 | |
Ye Li | 85eb095 | 2016-01-26 22:09:40 +0800 | [diff] [blame] | 51 | #define LCD_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_PUS_100K_UP | PAD_CTL_PUE | \ |
| 52 | PAD_CTL_PKE | PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm) |
| 53 | |
Peng Fan | e80f9e1 | 2018-01-02 09:32:09 +0800 | [diff] [blame] | 54 | #define WDOG_PAD_CTRL (PAD_CTL_PUE | PAD_CTL_PKE | PAD_CTL_SPEED_MED | \ |
| 55 | PAD_CTL_DSE_40ohm) |
| 56 | |
Fabio Estevam | 14a1613 | 2014-06-24 17:41:01 -0300 | [diff] [blame] | 57 | int dram_init(void) |
| 58 | { |
Vanessa Maegima | d6b0c46 | 2016-06-09 15:28:33 -0300 | [diff] [blame] | 59 | gd->ram_size = imx_ddr_size(); |
Fabio Estevam | 14a1613 | 2014-06-24 17:41:01 -0300 | [diff] [blame] | 60 | |
| 61 | return 0; |
| 62 | } |
| 63 | |
| 64 | static iomux_v3_cfg_t const uart1_pads[] = { |
| 65 | MX6_PAD_GPIO1_IO04__UART1_TX | MUX_PAD_CTRL(UART_PAD_CTRL), |
| 66 | MX6_PAD_GPIO1_IO05__UART1_RX | MUX_PAD_CTRL(UART_PAD_CTRL), |
| 67 | }; |
| 68 | |
Peng Fan | e80f9e1 | 2018-01-02 09:32:09 +0800 | [diff] [blame] | 69 | static iomux_v3_cfg_t const wdog_b_pad = { |
| 70 | MX6_PAD_GPIO1_IO13__GPIO1_IO_13 | MUX_PAD_CTRL(WDOG_PAD_CTRL), |
| 71 | }; |
Fabio Estevam | d145878 | 2014-08-15 00:24:29 -0300 | [diff] [blame] | 72 | static iomux_v3_cfg_t const fec1_pads[] = { |
| 73 | MX6_PAD_ENET1_MDC__ENET1_MDC | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 74 | MX6_PAD_ENET1_MDIO__ENET1_MDIO | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 75 | MX6_PAD_RGMII1_RX_CTL__ENET1_RX_EN | MUX_PAD_CTRL(ENET_RX_PAD_CTRL), |
| 76 | MX6_PAD_RGMII1_RD0__ENET1_RX_DATA_0 | MUX_PAD_CTRL(ENET_RX_PAD_CTRL), |
| 77 | MX6_PAD_RGMII1_RD1__ENET1_RX_DATA_1 | MUX_PAD_CTRL(ENET_RX_PAD_CTRL), |
| 78 | MX6_PAD_RGMII1_RD2__ENET1_RX_DATA_2 | MUX_PAD_CTRL(ENET_RX_PAD_CTRL), |
| 79 | MX6_PAD_RGMII1_RD3__ENET1_RX_DATA_3 | MUX_PAD_CTRL(ENET_RX_PAD_CTRL), |
| 80 | MX6_PAD_RGMII1_RXC__ENET1_RX_CLK | MUX_PAD_CTRL(ENET_RX_PAD_CTRL), |
| 81 | MX6_PAD_RGMII1_TX_CTL__ENET1_TX_EN | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 82 | MX6_PAD_RGMII1_TD0__ENET1_TX_DATA_0 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 83 | MX6_PAD_RGMII1_TD1__ENET1_TX_DATA_1 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 84 | MX6_PAD_RGMII1_TD2__ENET1_TX_DATA_2 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 85 | MX6_PAD_RGMII1_TD3__ENET1_TX_DATA_3 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 86 | MX6_PAD_RGMII1_TXC__ENET1_RGMII_TXC | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 87 | }; |
| 88 | |
| 89 | static iomux_v3_cfg_t const peri_3v3_pads[] = { |
| 90 | MX6_PAD_QSPI1A_DATA0__GPIO4_IO_16 | MUX_PAD_CTRL(NO_PAD_CTRL), |
| 91 | }; |
| 92 | |
| 93 | static iomux_v3_cfg_t const phy_control_pads[] = { |
| 94 | /* 25MHz Ethernet PHY Clock */ |
| 95 | MX6_PAD_ENET2_RX_CLK__ENET2_REF_CLK_25M | MUX_PAD_CTRL(ENET_CLK_PAD_CTRL), |
| 96 | |
| 97 | /* ENET PHY Power */ |
| 98 | MX6_PAD_ENET2_COL__GPIO2_IO_6 | MUX_PAD_CTRL(NO_PAD_CTRL), |
| 99 | |
| 100 | /* AR8031 PHY Reset */ |
| 101 | MX6_PAD_ENET2_CRS__GPIO2_IO_7 | MUX_PAD_CTRL(NO_PAD_CTRL), |
| 102 | }; |
| 103 | |
Fabio Estevam | 14a1613 | 2014-06-24 17:41:01 -0300 | [diff] [blame] | 104 | static void setup_iomux_uart(void) |
| 105 | { |
| 106 | imx_iomux_v3_setup_multiple_pads(uart1_pads, ARRAY_SIZE(uart1_pads)); |
| 107 | } |
| 108 | |
Fabio Estevam | d145878 | 2014-08-15 00:24:29 -0300 | [diff] [blame] | 109 | static int setup_fec(void) |
| 110 | { |
| 111 | struct iomuxc *iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR; |
| 112 | struct anatop_regs *anatop = (struct anatop_regs *)ANATOP_BASE_ADDR; |
Fabio Estevam | 29bc24e | 2015-11-23 16:18:02 -0200 | [diff] [blame] | 113 | int reg, ret; |
Fabio Estevam | d145878 | 2014-08-15 00:24:29 -0300 | [diff] [blame] | 114 | |
| 115 | /* Use 125MHz anatop loopback REF_CLK1 for ENET1 */ |
| 116 | clrsetbits_le32(&iomuxc_regs->gpr[1], IOMUX_GPR1_FEC1_MASK, 0); |
| 117 | |
Fabio Estevam | 29bc24e | 2015-11-23 16:18:02 -0200 | [diff] [blame] | 118 | ret = enable_fec_anatop_clock(0, ENET_125MHZ); |
| 119 | if (ret) |
| 120 | return ret; |
| 121 | |
Fabio Estevam | d145878 | 2014-08-15 00:24:29 -0300 | [diff] [blame] | 122 | imx_iomux_v3_setup_multiple_pads(phy_control_pads, |
| 123 | ARRAY_SIZE(phy_control_pads)); |
| 124 | |
| 125 | /* Enable the ENET power, active low */ |
Peng Fan | 5dfc9d3 | 2018-01-02 09:32:08 +0800 | [diff] [blame] | 126 | gpio_request(IMX_GPIO_NR(2, 6), "enet_rst"); |
Fabio Estevam | d145878 | 2014-08-15 00:24:29 -0300 | [diff] [blame] | 127 | gpio_direction_output(IMX_GPIO_NR(2, 6) , 0); |
| 128 | |
| 129 | /* Reset AR8031 PHY */ |
Peng Fan | 5dfc9d3 | 2018-01-02 09:32:08 +0800 | [diff] [blame] | 130 | gpio_request(IMX_GPIO_NR(2, 7), "phy_rst"); |
Fabio Estevam | d145878 | 2014-08-15 00:24:29 -0300 | [diff] [blame] | 131 | gpio_direction_output(IMX_GPIO_NR(2, 7) , 0); |
Fabio Estevam | 29bc24e | 2015-11-23 16:18:02 -0200 | [diff] [blame] | 132 | mdelay(10); |
Fabio Estevam | d145878 | 2014-08-15 00:24:29 -0300 | [diff] [blame] | 133 | gpio_set_value(IMX_GPIO_NR(2, 7), 1); |
| 134 | |
| 135 | reg = readl(&anatop->pll_enet); |
| 136 | reg |= BM_ANADIG_PLL_ENET_REF_25M_ENABLE; |
| 137 | writel(reg, &anatop->pll_enet); |
| 138 | |
Fabio Estevam | 29bc24e | 2015-11-23 16:18:02 -0200 | [diff] [blame] | 139 | return 0; |
Fabio Estevam | d145878 | 2014-08-15 00:24:29 -0300 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | int board_eth_init(bd_t *bis) |
| 143 | { |
| 144 | imx_iomux_v3_setup_multiple_pads(fec1_pads, ARRAY_SIZE(fec1_pads)); |
| 145 | setup_fec(); |
| 146 | |
| 147 | return cpu_eth_init(bis); |
| 148 | } |
| 149 | |
Ye.Li | 1f98e31 | 2014-11-06 16:29:01 +0800 | [diff] [blame] | 150 | int power_init_board(void) |
Fabio Estevam | fa8cf31 | 2014-07-09 16:13:30 -0300 | [diff] [blame] | 151 | { |
Peng Fan | 5dfc9d3 | 2018-01-02 09:32:08 +0800 | [diff] [blame] | 152 | struct udevice *dev; |
Fabio Estevam | 42acd18 | 2015-07-21 20:37:22 -0300 | [diff] [blame] | 153 | unsigned int reg; |
| 154 | int ret; |
Fabio Estevam | fa8cf31 | 2014-07-09 16:13:30 -0300 | [diff] [blame] | 155 | |
Peng Fan | 5dfc9d3 | 2018-01-02 09:32:08 +0800 | [diff] [blame] | 156 | dev = pfuze_common_init(); |
| 157 | if (!dev) |
Ye.Li | 1f98e31 | 2014-11-06 16:29:01 +0800 | [diff] [blame] | 158 | return -ENODEV; |
Fabio Estevam | fa8cf31 | 2014-07-09 16:13:30 -0300 | [diff] [blame] | 159 | |
Peng Fan | 5dfc9d3 | 2018-01-02 09:32:08 +0800 | [diff] [blame] | 160 | ret = pfuze_mode_init(dev, APS_PFM); |
Peng Fan | 258c98f | 2015-01-27 10:14:04 +0800 | [diff] [blame] | 161 | if (ret < 0) |
| 162 | return ret; |
| 163 | |
Fabio Estevam | fa8cf31 | 2014-07-09 16:13:30 -0300 | [diff] [blame] | 164 | /* Enable power of VGEN5 3V3, needed for SD3 */ |
Peng Fan | 5dfc9d3 | 2018-01-02 09:32:08 +0800 | [diff] [blame] | 165 | reg = pmic_reg_read(dev, PFUZE100_VGEN5VOL); |
Ye.Li | 1f98e31 | 2014-11-06 16:29:01 +0800 | [diff] [blame] | 166 | reg &= ~LDO_VOL_MASK; |
| 167 | reg |= (LDOB_3_30V | (1 << LDO_EN)); |
Peng Fan | 5dfc9d3 | 2018-01-02 09:32:08 +0800 | [diff] [blame] | 168 | pmic_reg_write(dev, PFUZE100_VGEN5VOL, reg); |
Fabio Estevam | fa8cf31 | 2014-07-09 16:13:30 -0300 | [diff] [blame] | 169 | |
| 170 | return 0; |
| 171 | } |
| 172 | |
Fabio Estevam | d145878 | 2014-08-15 00:24:29 -0300 | [diff] [blame] | 173 | int board_phy_config(struct phy_device *phydev) |
| 174 | { |
| 175 | /* |
| 176 | * Enable 1.8V(SEL_1P5_1P8_POS_REG) on |
| 177 | * Phy control debug reg 0 |
| 178 | */ |
| 179 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x1f); |
| 180 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x8); |
| 181 | |
| 182 | /* rgmii tx clock delay enable */ |
| 183 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x05); |
| 184 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x100); |
| 185 | |
| 186 | if (phydev->drv->config) |
| 187 | phydev->drv->config(phydev); |
| 188 | |
| 189 | return 0; |
| 190 | } |
| 191 | |
Fabio Estevam | 14a1613 | 2014-06-24 17:41:01 -0300 | [diff] [blame] | 192 | int board_early_init_f(void) |
| 193 | { |
| 194 | setup_iomux_uart(); |
Fabio Estevam | fa8cf31 | 2014-07-09 16:13:30 -0300 | [diff] [blame] | 195 | |
Fabio Estevam | d145878 | 2014-08-15 00:24:29 -0300 | [diff] [blame] | 196 | /* Enable PERI_3V3, which is used by SD2, ENET, LVDS, BT */ |
| 197 | imx_iomux_v3_setup_multiple_pads(peri_3v3_pads, |
| 198 | ARRAY_SIZE(peri_3v3_pads)); |
| 199 | |
Fabio Estevam | 14a1613 | 2014-06-24 17:41:01 -0300 | [diff] [blame] | 200 | return 0; |
| 201 | } |
| 202 | |
Peng Fan | fb0d042 | 2016-01-28 16:51:27 +0800 | [diff] [blame] | 203 | int board_mmc_get_env_dev(int devno) |
| 204 | { |
Peng Fan | 5dfc9d3 | 2018-01-02 09:32:08 +0800 | [diff] [blame] | 205 | return devno; |
Fabio Estevam | 14a1613 | 2014-06-24 17:41:01 -0300 | [diff] [blame] | 206 | } |
| 207 | |
Peng Fan | fad7d73 | 2014-12-31 11:01:40 +0800 | [diff] [blame] | 208 | #ifdef CONFIG_FSL_QSPI |
| 209 | |
Peng Fan | fad7d73 | 2014-12-31 11:01:40 +0800 | [diff] [blame] | 210 | int board_qspi_init(void) |
| 211 | { |
Peng Fan | fad7d73 | 2014-12-31 11:01:40 +0800 | [diff] [blame] | 212 | /* Set the clock */ |
| 213 | enable_qspi_clk(1); |
| 214 | |
| 215 | return 0; |
| 216 | } |
| 217 | #endif |
| 218 | |
Ye Li | 85eb095 | 2016-01-26 22:09:40 +0800 | [diff] [blame] | 219 | #ifdef CONFIG_VIDEO_MXS |
| 220 | static iomux_v3_cfg_t const lcd_pads[] = { |
| 221 | MX6_PAD_LCD1_CLK__LCDIF1_CLK | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 222 | MX6_PAD_LCD1_ENABLE__LCDIF1_ENABLE | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 223 | MX6_PAD_LCD1_HSYNC__LCDIF1_HSYNC | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 224 | MX6_PAD_LCD1_VSYNC__LCDIF1_VSYNC | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 225 | MX6_PAD_LCD1_DATA00__LCDIF1_DATA_0 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 226 | MX6_PAD_LCD1_DATA01__LCDIF1_DATA_1 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 227 | MX6_PAD_LCD1_DATA02__LCDIF1_DATA_2 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 228 | MX6_PAD_LCD1_DATA03__LCDIF1_DATA_3 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 229 | MX6_PAD_LCD1_DATA04__LCDIF1_DATA_4 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 230 | MX6_PAD_LCD1_DATA05__LCDIF1_DATA_5 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 231 | MX6_PAD_LCD1_DATA06__LCDIF1_DATA_6 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 232 | MX6_PAD_LCD1_DATA07__LCDIF1_DATA_7 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 233 | MX6_PAD_LCD1_DATA08__LCDIF1_DATA_8 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 234 | MX6_PAD_LCD1_DATA09__LCDIF1_DATA_9 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 235 | MX6_PAD_LCD1_DATA10__LCDIF1_DATA_10 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 236 | MX6_PAD_LCD1_DATA11__LCDIF1_DATA_11 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 237 | MX6_PAD_LCD1_DATA12__LCDIF1_DATA_12 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 238 | MX6_PAD_LCD1_DATA13__LCDIF1_DATA_13 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 239 | MX6_PAD_LCD1_DATA14__LCDIF1_DATA_14 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 240 | MX6_PAD_LCD1_DATA15__LCDIF1_DATA_15 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 241 | MX6_PAD_LCD1_DATA16__LCDIF1_DATA_16 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 242 | MX6_PAD_LCD1_DATA17__LCDIF1_DATA_17 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 243 | MX6_PAD_LCD1_DATA18__LCDIF1_DATA_18 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 244 | MX6_PAD_LCD1_DATA19__LCDIF1_DATA_19 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 245 | MX6_PAD_LCD1_DATA20__LCDIF1_DATA_20 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 246 | MX6_PAD_LCD1_DATA21__LCDIF1_DATA_21 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 247 | MX6_PAD_LCD1_DATA22__LCDIF1_DATA_22 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 248 | MX6_PAD_LCD1_DATA23__LCDIF1_DATA_23 | MUX_PAD_CTRL(LCD_PAD_CTRL), |
| 249 | MX6_PAD_LCD1_RESET__GPIO3_IO_27 | MUX_PAD_CTRL(NO_PAD_CTRL), |
| 250 | |
| 251 | /* Use GPIO for Brightness adjustment, duty cycle = period */ |
| 252 | MX6_PAD_SD1_DATA2__GPIO6_IO_4 | MUX_PAD_CTRL(NO_PAD_CTRL), |
| 253 | }; |
| 254 | |
| 255 | static int setup_lcd(void) |
| 256 | { |
Peng Fan | 708f692 | 2016-12-11 19:24:28 +0800 | [diff] [blame] | 257 | enable_lcdif_clock(LCDIF1_BASE_ADDR, 1); |
Ye Li | 85eb095 | 2016-01-26 22:09:40 +0800 | [diff] [blame] | 258 | |
| 259 | imx_iomux_v3_setup_multiple_pads(lcd_pads, ARRAY_SIZE(lcd_pads)); |
| 260 | |
| 261 | /* Reset the LCD */ |
Peng Fan | 5dfc9d3 | 2018-01-02 09:32:08 +0800 | [diff] [blame] | 262 | gpio_request(IMX_GPIO_NR(3, 27), "lcd_rst"); |
Ye Li | 85eb095 | 2016-01-26 22:09:40 +0800 | [diff] [blame] | 263 | gpio_direction_output(IMX_GPIO_NR(3, 27) , 0); |
| 264 | udelay(500); |
| 265 | gpio_direction_output(IMX_GPIO_NR(3, 27) , 1); |
| 266 | |
| 267 | /* Set Brightness to high */ |
Peng Fan | 5dfc9d3 | 2018-01-02 09:32:08 +0800 | [diff] [blame] | 268 | gpio_request(IMX_GPIO_NR(6, 4), "lcd_bright"); |
Ye Li | 85eb095 | 2016-01-26 22:09:40 +0800 | [diff] [blame] | 269 | gpio_direction_output(IMX_GPIO_NR(6, 4) , 1); |
| 270 | |
| 271 | return 0; |
| 272 | } |
| 273 | #endif |
| 274 | |
Fabio Estevam | 14a1613 | 2014-06-24 17:41:01 -0300 | [diff] [blame] | 275 | int board_init(void) |
| 276 | { |
| 277 | /* Address of boot parameters */ |
| 278 | gd->bd->bi_boot_params = PHYS_SDRAM + 0x100; |
| 279 | |
Peng Fan | e80f9e1 | 2018-01-02 09:32:09 +0800 | [diff] [blame] | 280 | /* |
| 281 | * Because kernel set WDOG_B mux before pad with the common pinctrl |
| 282 | * framwork now and wdog reset will be triggered once set WDOG_B mux |
| 283 | * with default pad setting, we set pad setting here to workaround this. |
| 284 | * Since imx_iomux_v3_setup_pad also set mux before pad setting, we set |
| 285 | * as GPIO mux firstly here to workaround it. |
| 286 | */ |
| 287 | imx_iomux_v3_setup_pad(wdog_b_pad); |
| 288 | |
Peng Fan | 5dfc9d3 | 2018-01-02 09:32:08 +0800 | [diff] [blame] | 289 | /* Active high for ncp692 */ |
| 290 | gpio_request(IMX_GPIO_NR(4, 16), "ncp692_en"); |
| 291 | gpio_direction_output(IMX_GPIO_NR(4, 16), 1); |
Peng Fan | 0509553 | 2014-10-31 11:08:06 +0800 | [diff] [blame] | 292 | |
Peng Fan | fad7d73 | 2014-12-31 11:01:40 +0800 | [diff] [blame] | 293 | #ifdef CONFIG_FSL_QSPI |
| 294 | board_qspi_init(); |
| 295 | #endif |
| 296 | |
Ye Li | 85eb095 | 2016-01-26 22:09:40 +0800 | [diff] [blame] | 297 | #ifdef CONFIG_VIDEO_MXS |
| 298 | setup_lcd(); |
| 299 | #endif |
| 300 | |
Fabio Estevam | 14a1613 | 2014-06-24 17:41:01 -0300 | [diff] [blame] | 301 | return 0; |
| 302 | } |
| 303 | |
Fabio Estevam | 6ca03f0 | 2017-11-27 10:25:10 -0200 | [diff] [blame] | 304 | static bool is_reva(void) |
| 305 | { |
| 306 | return (nxp_board_rev() == 1); |
| 307 | } |
| 308 | |
| 309 | int board_late_init(void) |
| 310 | { |
| 311 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
| 312 | if (is_reva()) |
| 313 | env_set("board_rev", "REVA"); |
| 314 | #endif |
| 315 | return 0; |
| 316 | } |
| 317 | |
Fabio Estevam | 14a1613 | 2014-06-24 17:41:01 -0300 | [diff] [blame] | 318 | int checkboard(void) |
| 319 | { |
Fabio Estevam | 6ca03f0 | 2017-11-27 10:25:10 -0200 | [diff] [blame] | 320 | printf("Board: MX6SX SABRE SDB rev%c\n", nxp_board_rev_string()); |
Fabio Estevam | 14a1613 | 2014-06-24 17:41:01 -0300 | [diff] [blame] | 321 | |
| 322 | return 0; |
| 323 | } |