Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2015 Timesys Corporation |
| 4 | * Copyright 2015 General Electric Company |
| 5 | * Copyright 2012 Freescale Semiconductor, Inc. |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 6 | */ |
| 7 | |
Simon Glass | a7b5130 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 8 | #include <init.h> |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 9 | #include <asm/arch/clock.h> |
| 10 | #include <asm/arch/imx-regs.h> |
| 11 | #include <asm/arch/iomux.h> |
| 12 | #include <asm/arch/mx6-pins.h> |
Simon Glass | 5e6201b | 2019-08-01 09:46:51 -0600 | [diff] [blame] | 13 | #include <env.h> |
Masahiro Yamada | 56a931c | 2016-09-21 11:28:55 +0900 | [diff] [blame] | 14 | #include <linux/errno.h> |
Ian Ray | 6445094 | 2019-01-31 16:21:18 +0200 | [diff] [blame] | 15 | #include <linux/libfdt.h> |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 16 | #include <asm/gpio.h> |
Stefano Babic | 33731bc | 2017-06-29 10:16:06 +0200 | [diff] [blame] | 17 | #include <asm/mach-imx/mxc_i2c.h> |
| 18 | #include <asm/mach-imx/iomux-v3.h> |
| 19 | #include <asm/mach-imx/boot_mode.h> |
| 20 | #include <asm/mach-imx/video.h> |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 21 | #include <mmc.h> |
Yangbo Lu | 7334038 | 2019-06-21 11:42:28 +0800 | [diff] [blame] | 22 | #include <fsl_esdhc_imx.h> |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 23 | #include <miiphy.h> |
Martyn Welch | 18c31ea | 2018-01-10 20:31:30 +0100 | [diff] [blame] | 24 | #include <net.h> |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 25 | #include <netdev.h> |
| 26 | #include <asm/arch/mxc_hdmi.h> |
| 27 | #include <asm/arch/crm_regs.h> |
| 28 | #include <asm/io.h> |
| 29 | #include <asm/arch/sys_proto.h> |
| 30 | #include <i2c.h> |
Diego Dorta | 2661c9c | 2017-09-22 12:12:18 -0300 | [diff] [blame] | 31 | #include <input.h> |
Akshay Bhat | 5d64362 | 2016-04-12 18:13:59 -0400 | [diff] [blame] | 32 | #include <pwm.h> |
Ian Ray | 6445094 | 2019-01-31 16:21:18 +0200 | [diff] [blame] | 33 | #include <version.h> |
Ian Ray | c0293da | 2017-08-22 09:03:54 +0300 | [diff] [blame] | 34 | #include <stdlib.h> |
Robert Beckett | f746ab6 | 2019-11-12 19:15:11 +0000 | [diff] [blame] | 35 | #include <dm/root.h> |
Nandor Han | ae3c6d2 | 2018-01-10 20:31:38 +0100 | [diff] [blame] | 36 | #include "../common/ge_common.h" |
Martyn Welch | 66697ce | 2017-11-08 15:35:15 +0000 | [diff] [blame] | 37 | #include "../common/vpd_reader.h" |
Hannu Lounento | 3787968 | 2018-01-10 20:31:31 +0100 | [diff] [blame] | 38 | #include "../../../drivers/net/e1000.h" |
Denis Zalevskiy | 0d97471 | 2019-11-12 19:15:17 +0000 | [diff] [blame] | 39 | #include <pci.h> |
| 40 | |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 41 | DECLARE_GLOBAL_DATA_PTR; |
| 42 | |
Robert Beckett | f746ab6 | 2019-11-12 19:15:11 +0000 | [diff] [blame] | 43 | static int confidx; /* Default to generic. */ |
Nandor Han | 7a9bb30 | 2018-04-25 16:57:01 +0200 | [diff] [blame] | 44 | static struct vpd_cache vpd; |
| 45 | |
Justin Waters | ef93fc2 | 2016-04-13 17:03:18 -0400 | [diff] [blame] | 46 | #define NC_PAD_CTRL (PAD_CTL_PUS_100K_UP | \ |
| 47 | PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | \ |
| 48 | PAD_CTL_HYS) |
| 49 | |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 50 | #define UART_PAD_CTRL (PAD_CTL_PUS_100K_UP | \ |
| 51 | PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | \ |
| 52 | PAD_CTL_SRE_FAST | PAD_CTL_HYS) |
| 53 | |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 54 | #define ENET_PAD_CTRL (PAD_CTL_PUS_100K_UP | PAD_CTL_PUE | \ |
| 55 | PAD_CTL_SPEED_HIGH | PAD_CTL_DSE_48ohm | PAD_CTL_SRE_FAST) |
| 56 | |
| 57 | #define ENET_CLK_PAD_CTRL (PAD_CTL_SPEED_MED | \ |
| 58 | PAD_CTL_DSE_120ohm | PAD_CTL_SRE_FAST) |
| 59 | |
| 60 | #define ENET_RX_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE | \ |
| 61 | PAD_CTL_SPEED_HIGH | PAD_CTL_SRE_FAST) |
| 62 | |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 63 | #define I2C_PAD_CTRL (PAD_CTL_PUS_100K_UP | \ |
| 64 | PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS | \ |
| 65 | PAD_CTL_ODE | PAD_CTL_SRE_FAST) |
| 66 | |
| 67 | #define I2C_PAD MUX_PAD_CTRL(I2C_PAD_CTRL) |
| 68 | |
| 69 | int dram_init(void) |
| 70 | { |
Fabio Estevam | dd5d4e4 | 2016-07-23 13:23:40 -0300 | [diff] [blame] | 71 | gd->ram_size = imx_ddr_size(); |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 72 | |
| 73 | return 0; |
| 74 | } |
| 75 | |
| 76 | static iomux_v3_cfg_t const uart3_pads[] = { |
| 77 | MX6_PAD_EIM_D31__UART3_RTS_B | MUX_PAD_CTRL(UART_PAD_CTRL), |
| 78 | MX6_PAD_EIM_D23__UART3_CTS_B | MUX_PAD_CTRL(UART_PAD_CTRL), |
| 79 | MX6_PAD_EIM_D24__UART3_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL), |
| 80 | MX6_PAD_EIM_D25__UART3_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL), |
| 81 | }; |
| 82 | |
| 83 | static iomux_v3_cfg_t const uart4_pads[] = { |
| 84 | MX6_PAD_KEY_COL0__UART4_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL), |
| 85 | MX6_PAD_KEY_ROW0__UART4_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL), |
| 86 | }; |
| 87 | |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 88 | static struct i2c_pads_info i2c_pad_info1 = { |
| 89 | .scl = { |
| 90 | .i2c_mode = MX6_PAD_CSI0_DAT9__I2C1_SCL | I2C_PAD, |
| 91 | .gpio_mode = MX6_PAD_CSI0_DAT9__GPIO5_IO27 | I2C_PAD, |
| 92 | .gp = IMX_GPIO_NR(5, 27) |
| 93 | }, |
| 94 | .sda = { |
| 95 | .i2c_mode = MX6_PAD_CSI0_DAT8__I2C1_SDA | I2C_PAD, |
| 96 | .gpio_mode = MX6_PAD_CSI0_DAT8__GPIO5_IO26 | I2C_PAD, |
| 97 | .gp = IMX_GPIO_NR(5, 26) |
| 98 | } |
| 99 | }; |
| 100 | |
| 101 | static struct i2c_pads_info i2c_pad_info2 = { |
| 102 | .scl = { |
| 103 | .i2c_mode = MX6_PAD_KEY_COL3__I2C2_SCL | I2C_PAD, |
| 104 | .gpio_mode = MX6_PAD_KEY_COL3__GPIO4_IO12 | I2C_PAD, |
| 105 | .gp = IMX_GPIO_NR(4, 12) |
| 106 | }, |
| 107 | .sda = { |
| 108 | .i2c_mode = MX6_PAD_KEY_ROW3__I2C2_SDA | I2C_PAD, |
| 109 | .gpio_mode = MX6_PAD_KEY_ROW3__GPIO4_IO13 | I2C_PAD, |
| 110 | .gp = IMX_GPIO_NR(4, 13) |
| 111 | } |
| 112 | }; |
| 113 | |
| 114 | static struct i2c_pads_info i2c_pad_info3 = { |
| 115 | .scl = { |
| 116 | .i2c_mode = MX6_PAD_GPIO_3__I2C3_SCL | I2C_PAD, |
| 117 | .gpio_mode = MX6_PAD_GPIO_3__GPIO1_IO03 | I2C_PAD, |
| 118 | .gp = IMX_GPIO_NR(1, 3) |
| 119 | }, |
| 120 | .sda = { |
| 121 | .i2c_mode = MX6_PAD_GPIO_6__I2C3_SDA | I2C_PAD, |
| 122 | .gpio_mode = MX6_PAD_GPIO_6__GPIO1_IO06 | I2C_PAD, |
| 123 | .gp = IMX_GPIO_NR(1, 6) |
| 124 | } |
| 125 | }; |
| 126 | |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 127 | static void setup_iomux_uart(void) |
| 128 | { |
| 129 | imx_iomux_v3_setup_multiple_pads(uart3_pads, ARRAY_SIZE(uart3_pads)); |
| 130 | imx_iomux_v3_setup_multiple_pads(uart4_pads, ARRAY_SIZE(uart4_pads)); |
| 131 | } |
| 132 | |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 133 | static int mx6_rgmii_rework(struct phy_device *phydev) |
| 134 | { |
| 135 | /* Configure AR8033 to ouput a 125MHz clk from CLK_25M */ |
| 136 | /* set device address 0x7 */ |
| 137 | phy_write(phydev, MDIO_DEVAD_NONE, 0xd, 0x7); |
| 138 | /* offset 0x8016: CLK_25M Clock Select */ |
| 139 | phy_write(phydev, MDIO_DEVAD_NONE, 0xe, 0x8016); |
| 140 | /* enable register write, no post increment, address 0x7 */ |
| 141 | phy_write(phydev, MDIO_DEVAD_NONE, 0xd, 0x4007); |
| 142 | /* set to 125 MHz from local PLL source */ |
| 143 | phy_write(phydev, MDIO_DEVAD_NONE, 0xe, 0x18); |
| 144 | |
| 145 | /* rgmii tx clock delay enable */ |
| 146 | /* set debug port address: SerDes Test and System Mode Control */ |
| 147 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x05); |
| 148 | /* enable rgmii tx clock delay */ |
Yung-Ching LIN | 48652c8 | 2017-02-21 09:56:56 +0800 | [diff] [blame] | 149 | /* set the reserved bits to avoid board specific voltage peak issue*/ |
| 150 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x3D47); |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 151 | |
| 152 | return 0; |
| 153 | } |
| 154 | |
| 155 | int board_phy_config(struct phy_device *phydev) |
| 156 | { |
| 157 | mx6_rgmii_rework(phydev); |
| 158 | |
| 159 | if (phydev->drv->config) |
| 160 | phydev->drv->config(phydev); |
| 161 | |
| 162 | return 0; |
| 163 | } |
| 164 | |
| 165 | #if defined(CONFIG_VIDEO_IPUV3) |
| 166 | static iomux_v3_cfg_t const backlight_pads[] = { |
| 167 | /* Power for LVDS Display */ |
| 168 | MX6_PAD_EIM_D22__GPIO3_IO22 | MUX_PAD_CTRL(NO_PAD_CTRL), |
| 169 | #define LVDS_POWER_GP IMX_GPIO_NR(3, 22) |
| 170 | /* Backlight enable for LVDS display */ |
| 171 | MX6_PAD_GPIO_0__GPIO1_IO00 | MUX_PAD_CTRL(NO_PAD_CTRL), |
| 172 | #define LVDS_BACKLIGHT_GP IMX_GPIO_NR(1, 0) |
Akshay Bhat | 5d64362 | 2016-04-12 18:13:59 -0400 | [diff] [blame] | 173 | /* backlight PWM brightness control */ |
| 174 | MX6_PAD_SD1_DAT3__PWM1_OUT | MUX_PAD_CTRL(NO_PAD_CTRL), |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 175 | }; |
| 176 | |
| 177 | static void do_enable_hdmi(struct display_info_t const *dev) |
| 178 | { |
| 179 | imx_enable_hdmi_phy(); |
| 180 | } |
| 181 | |
Ian Ray | 6eac23f | 2018-04-25 16:57:02 +0200 | [diff] [blame] | 182 | static int is_b850v3(void) |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 183 | { |
Ian Ray | 6eac23f | 2018-04-25 16:57:02 +0200 | [diff] [blame] | 184 | return confidx == 3; |
| 185 | } |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 186 | |
Ian Ray | 6eac23f | 2018-04-25 16:57:02 +0200 | [diff] [blame] | 187 | static int detect_lcd(struct display_info_t const *dev) |
| 188 | { |
| 189 | return !is_b850v3(); |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | struct display_info_t const displays[] = {{ |
| 193 | .bus = -1, |
| 194 | .addr = -1, |
| 195 | .pixfmt = IPU_PIX_FMT_RGB24, |
Ian Ray | f8e4fab | 2018-04-25 16:56:58 +0200 | [diff] [blame] | 196 | .detect = detect_lcd, |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 197 | .enable = NULL, |
| 198 | .mode = { |
| 199 | .name = "G121X1-L03", |
| 200 | .refresh = 60, |
| 201 | .xres = 1024, |
| 202 | .yres = 768, |
| 203 | .pixclock = 15385, |
| 204 | .left_margin = 20, |
| 205 | .right_margin = 300, |
| 206 | .upper_margin = 30, |
| 207 | .lower_margin = 8, |
| 208 | .hsync_len = 1, |
| 209 | .vsync_len = 1, |
| 210 | .sync = FB_SYNC_EXT, |
| 211 | .vmode = FB_VMODE_NONINTERLACED |
| 212 | } }, { |
| 213 | .bus = -1, |
| 214 | .addr = 3, |
| 215 | .pixfmt = IPU_PIX_FMT_RGB24, |
| 216 | .detect = detect_hdmi, |
| 217 | .enable = do_enable_hdmi, |
| 218 | .mode = { |
| 219 | .name = "HDMI", |
| 220 | .refresh = 60, |
| 221 | .xres = 1024, |
| 222 | .yres = 768, |
| 223 | .pixclock = 15385, |
| 224 | .left_margin = 220, |
| 225 | .right_margin = 40, |
| 226 | .upper_margin = 21, |
| 227 | .lower_margin = 7, |
| 228 | .hsync_len = 60, |
| 229 | .vsync_len = 10, |
| 230 | .sync = FB_SYNC_EXT, |
| 231 | .vmode = FB_VMODE_NONINTERLACED |
| 232 | } } }; |
| 233 | size_t display_count = ARRAY_SIZE(displays); |
| 234 | |
Akshay Bhat | 3a5b15a | 2016-04-12 18:13:58 -0400 | [diff] [blame] | 235 | static void enable_videopll(void) |
| 236 | { |
| 237 | struct mxc_ccm_reg *ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR; |
| 238 | s32 timeout = 100000; |
| 239 | |
| 240 | setbits_le32(&ccm->analog_pll_video, BM_ANADIG_PLL_VIDEO_POWERDOWN); |
| 241 | |
Ian Ray | 28540c5 | 2018-10-15 09:59:44 +0200 | [diff] [blame] | 242 | /* PLL_VIDEO 455MHz (24MHz * (37+11/12) / 2) |
| 243 | * | |
| 244 | * PLL5 |
| 245 | * | |
| 246 | * CS2CDR[LDB_DI0_CLK_SEL] |
| 247 | * | |
| 248 | * +----> LDB_DI0_SERIAL_CLK_ROOT |
| 249 | * | |
| 250 | * +--> CSCMR2[LDB_DI0_IPU_DIV] --> LDB_DI0_IPU 455 / 7 = 65 MHz |
| 251 | */ |
| 252 | |
Akshay Bhat | 3a5b15a | 2016-04-12 18:13:58 -0400 | [diff] [blame] | 253 | clrsetbits_le32(&ccm->analog_pll_video, |
| 254 | BM_ANADIG_PLL_VIDEO_DIV_SELECT | |
| 255 | BM_ANADIG_PLL_VIDEO_POST_DIV_SELECT, |
| 256 | BF_ANADIG_PLL_VIDEO_DIV_SELECT(37) | |
Ian Ray | 28540c5 | 2018-10-15 09:59:44 +0200 | [diff] [blame] | 257 | BF_ANADIG_PLL_VIDEO_POST_DIV_SELECT(1)); |
Akshay Bhat | 3a5b15a | 2016-04-12 18:13:58 -0400 | [diff] [blame] | 258 | |
| 259 | writel(BF_ANADIG_PLL_VIDEO_NUM_A(11), &ccm->analog_pll_video_num); |
| 260 | writel(BF_ANADIG_PLL_VIDEO_DENOM_B(12), &ccm->analog_pll_video_denom); |
| 261 | |
| 262 | clrbits_le32(&ccm->analog_pll_video, BM_ANADIG_PLL_VIDEO_POWERDOWN); |
| 263 | |
| 264 | while (timeout--) |
| 265 | if (readl(&ccm->analog_pll_video) & BM_ANADIG_PLL_VIDEO_LOCK) |
| 266 | break; |
| 267 | |
| 268 | if (timeout < 0) |
| 269 | printf("Warning: video pll lock timeout!\n"); |
| 270 | |
| 271 | clrsetbits_le32(&ccm->analog_pll_video, |
| 272 | BM_ANADIG_PLL_VIDEO_BYPASS, |
| 273 | BM_ANADIG_PLL_VIDEO_ENABLE); |
| 274 | } |
| 275 | |
Akshay Bhat | cc4e4b6 | 2016-04-12 18:13:57 -0400 | [diff] [blame] | 276 | static void setup_display_b850v3(void) |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 277 | { |
| 278 | struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR; |
| 279 | struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR; |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 280 | |
Akshay Bhat | 3a5b15a | 2016-04-12 18:13:58 -0400 | [diff] [blame] | 281 | enable_videopll(); |
| 282 | |
Ian Ray | 28540c5 | 2018-10-15 09:59:44 +0200 | [diff] [blame] | 283 | /* IPU1 DI0 clock is 455MHz / 7 = 65MHz */ |
| 284 | setbits_le32(&mxc_ccm->cscmr2, MXC_CCM_CSCMR2_LDB_DI0_IPU_DIV); |
Akshay Bhat | cc4e4b6 | 2016-04-12 18:13:57 -0400 | [diff] [blame] | 285 | |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 286 | imx_setup_hdmi(); |
| 287 | |
Akshay Bhat | cc4e4b6 | 2016-04-12 18:13:57 -0400 | [diff] [blame] | 288 | /* Set LDB_DI0 as clock source for IPU_DI0 */ |
| 289 | clrsetbits_le32(&mxc_ccm->chsccdr, |
| 290 | MXC_CCM_CHSCCDR_IPU1_DI0_CLK_SEL_MASK, |
| 291 | (CHSCCDR_CLK_SEL_LDB_DI0 << |
| 292 | MXC_CCM_CHSCCDR_IPU1_DI0_CLK_SEL_OFFSET)); |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 293 | |
Akshay Bhat | cc4e4b6 | 2016-04-12 18:13:57 -0400 | [diff] [blame] | 294 | /* Turn on IPU LDB DI0 clocks */ |
| 295 | setbits_le32(&mxc_ccm->CCGR3, MXC_CCM_CCGR3_LDB_DI0_MASK); |
| 296 | |
| 297 | enable_ipu_clock(); |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 298 | |
Akshay Bhat | cc4e4b6 | 2016-04-12 18:13:57 -0400 | [diff] [blame] | 299 | writel(IOMUXC_GPR2_BGREF_RRMODE_EXTERNAL_RES | |
| 300 | IOMUXC_GPR2_DI1_VS_POLARITY_ACTIVE_LOW | |
| 301 | IOMUXC_GPR2_DI0_VS_POLARITY_ACTIVE_LOW | |
| 302 | IOMUXC_GPR2_BIT_MAPPING_CH1_SPWG | |
| 303 | IOMUXC_GPR2_DATA_WIDTH_CH1_24BIT | |
| 304 | IOMUXC_GPR2_BIT_MAPPING_CH0_SPWG | |
| 305 | IOMUXC_GPR2_DATA_WIDTH_CH0_24BIT | |
| 306 | IOMUXC_GPR2_SPLIT_MODE_EN_MASK | |
| 307 | IOMUXC_GPR2_LVDS_CH0_MODE_ENABLED_DI0 | |
| 308 | IOMUXC_GPR2_LVDS_CH1_MODE_ENABLED_DI0, |
| 309 | &iomux->gpr[2]); |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 310 | |
Akshay Bhat | cc4e4b6 | 2016-04-12 18:13:57 -0400 | [diff] [blame] | 311 | clrbits_le32(&iomux->gpr[3], |
| 312 | IOMUXC_GPR3_LVDS0_MUX_CTL_MASK | |
| 313 | IOMUXC_GPR3_LVDS1_MUX_CTL_MASK | |
| 314 | IOMUXC_GPR3_HDMI_MUX_CTL_MASK); |
| 315 | } |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 316 | |
Akshay Bhat | cc4e4b6 | 2016-04-12 18:13:57 -0400 | [diff] [blame] | 317 | static void setup_display_bx50v3(void) |
| 318 | { |
| 319 | struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR; |
| 320 | struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR; |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 321 | |
Ian Ray | 66395e8 | 2018-04-25 16:57:00 +0200 | [diff] [blame] | 322 | enable_videopll(); |
| 323 | |
Akshay Bhat | 66027fe | 2016-04-12 18:14:00 -0400 | [diff] [blame] | 324 | /* When a reset/reboot is performed the display power needs to be turned |
| 325 | * off for atleast 500ms. The boot time is ~300ms, we need to wait for |
| 326 | * an additional 200ms here. Unfortunately we use external PMIC for |
| 327 | * doing the reset, so can not differentiate between POR vs soft reset |
| 328 | */ |
| 329 | mdelay(200); |
| 330 | |
Ian Ray | 28540c5 | 2018-10-15 09:59:44 +0200 | [diff] [blame] | 331 | /* IPU1 DI0 clock is 455MHz / 7 = 65MHz */ |
Akshay Bhat | cc4e4b6 | 2016-04-12 18:13:57 -0400 | [diff] [blame] | 332 | setbits_le32(&mxc_ccm->cscmr2, MXC_CCM_CSCMR2_LDB_DI0_IPU_DIV); |
| 333 | |
| 334 | /* Set LDB_DI0 as clock source for IPU_DI0 */ |
| 335 | clrsetbits_le32(&mxc_ccm->chsccdr, |
| 336 | MXC_CCM_CHSCCDR_IPU1_DI0_CLK_SEL_MASK, |
| 337 | (CHSCCDR_CLK_SEL_LDB_DI0 << |
| 338 | MXC_CCM_CHSCCDR_IPU1_DI0_CLK_SEL_OFFSET)); |
| 339 | |
| 340 | /* Turn on IPU LDB DI0 clocks */ |
| 341 | setbits_le32(&mxc_ccm->CCGR3, MXC_CCM_CCGR3_LDB_DI0_MASK); |
| 342 | |
| 343 | enable_ipu_clock(); |
| 344 | |
| 345 | writel(IOMUXC_GPR2_BGREF_RRMODE_EXTERNAL_RES | |
| 346 | IOMUXC_GPR2_DI0_VS_POLARITY_ACTIVE_LOW | |
| 347 | IOMUXC_GPR2_BIT_MAPPING_CH0_SPWG | |
| 348 | IOMUXC_GPR2_DATA_WIDTH_CH0_24BIT | |
| 349 | IOMUXC_GPR2_LVDS_CH0_MODE_ENABLED_DI0, |
| 350 | &iomux->gpr[2]); |
| 351 | |
| 352 | clrsetbits_le32(&iomux->gpr[3], |
| 353 | IOMUXC_GPR3_LVDS0_MUX_CTL_MASK, |
| 354 | (IOMUXC_GPR3_MUX_SRC_IPU1_DI0 << |
| 355 | IOMUXC_GPR3_LVDS0_MUX_CTL_OFFSET)); |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 356 | |
| 357 | /* backlights off until needed */ |
| 358 | imx_iomux_v3_setup_multiple_pads(backlight_pads, |
| 359 | ARRAY_SIZE(backlight_pads)); |
Ian Ray | 5f1e344 | 2019-01-31 16:21:13 +0200 | [diff] [blame] | 360 | gpio_request(LVDS_POWER_GP, "lvds_power"); |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 361 | gpio_direction_input(LVDS_POWER_GP); |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 362 | } |
| 363 | #endif /* CONFIG_VIDEO_IPUV3 */ |
| 364 | |
| 365 | /* |
| 366 | * Do not overwrite the console |
| 367 | * Use always serial for U-Boot console |
| 368 | */ |
| 369 | int overwrite_console(void) |
| 370 | { |
| 371 | return 1; |
| 372 | } |
| 373 | |
Ian Ray | c0293da | 2017-08-22 09:03:54 +0300 | [diff] [blame] | 374 | #define VPD_TYPE_INVALID 0x00 |
| 375 | #define VPD_BLOCK_NETWORK 0x20 |
| 376 | #define VPD_BLOCK_HWID 0x44 |
| 377 | #define VPD_PRODUCT_B850 1 |
| 378 | #define VPD_PRODUCT_B650 2 |
| 379 | #define VPD_PRODUCT_B450 3 |
Martyn Welch | 18c31ea | 2018-01-10 20:31:30 +0100 | [diff] [blame] | 380 | #define VPD_HAS_MAC1 0x1 |
Hannu Lounento | 3787968 | 2018-01-10 20:31:31 +0100 | [diff] [blame] | 381 | #define VPD_HAS_MAC2 0x2 |
Martyn Welch | 18c31ea | 2018-01-10 20:31:30 +0100 | [diff] [blame] | 382 | #define VPD_MAC_ADDRESS_LENGTH 6 |
Ian Ray | c0293da | 2017-08-22 09:03:54 +0300 | [diff] [blame] | 383 | |
| 384 | struct vpd_cache { |
Denis Zalevskiy | 22a347d | 2018-10-17 10:33:30 +0200 | [diff] [blame] | 385 | bool is_read; |
Martyn Welch | 18c31ea | 2018-01-10 20:31:30 +0100 | [diff] [blame] | 386 | u8 product_id; |
| 387 | u8 has; |
| 388 | unsigned char mac1[VPD_MAC_ADDRESS_LENGTH]; |
Hannu Lounento | 3787968 | 2018-01-10 20:31:31 +0100 | [diff] [blame] | 389 | unsigned char mac2[VPD_MAC_ADDRESS_LENGTH]; |
Ian Ray | c0293da | 2017-08-22 09:03:54 +0300 | [diff] [blame] | 390 | }; |
| 391 | |
| 392 | /* |
| 393 | * Extracts MAC and product information from the VPD. |
| 394 | */ |
Denis Zalevskiy | 22a347d | 2018-10-17 10:33:30 +0200 | [diff] [blame] | 395 | static int vpd_callback(struct vpd_cache *vpd, u8 id, u8 version, u8 type, |
Martyn Welch | 18c31ea | 2018-01-10 20:31:30 +0100 | [diff] [blame] | 396 | size_t size, u8 const *data) |
Ian Ray | c0293da | 2017-08-22 09:03:54 +0300 | [diff] [blame] | 397 | { |
Martyn Welch | 18c31ea | 2018-01-10 20:31:30 +0100 | [diff] [blame] | 398 | if (id == VPD_BLOCK_HWID && version == 1 && type != VPD_TYPE_INVALID && |
| 399 | size >= 1) { |
Ian Ray | c0293da | 2017-08-22 09:03:54 +0300 | [diff] [blame] | 400 | vpd->product_id = data[0]; |
Martyn Welch | 18c31ea | 2018-01-10 20:31:30 +0100 | [diff] [blame] | 401 | } else if (id == VPD_BLOCK_NETWORK && version == 1 && |
| 402 | type != VPD_TYPE_INVALID) { |
| 403 | if (size >= 6) { |
| 404 | vpd->has |= VPD_HAS_MAC1; |
| 405 | memcpy(vpd->mac1, data, VPD_MAC_ADDRESS_LENGTH); |
| 406 | } |
Hannu Lounento | 3787968 | 2018-01-10 20:31:31 +0100 | [diff] [blame] | 407 | if (size >= 12) { |
| 408 | vpd->has |= VPD_HAS_MAC2; |
| 409 | memcpy(vpd->mac2, data + 6, VPD_MAC_ADDRESS_LENGTH); |
| 410 | } |
Ian Ray | c0293da | 2017-08-22 09:03:54 +0300 | [diff] [blame] | 411 | } |
| 412 | |
| 413 | return 0; |
| 414 | } |
| 415 | |
Ian Ray | c0293da | 2017-08-22 09:03:54 +0300 | [diff] [blame] | 416 | static void process_vpd(struct vpd_cache *vpd) |
| 417 | { |
Denis Zalevskiy | 0d97471 | 2019-11-12 19:15:17 +0000 | [diff] [blame] | 418 | int fec_index = 0; |
Hannu Lounento | 3787968 | 2018-01-10 20:31:31 +0100 | [diff] [blame] | 419 | int i210_index = -1; |
Martyn Welch | 18c31ea | 2018-01-10 20:31:30 +0100 | [diff] [blame] | 420 | |
Denis Zalevskiy | 22a347d | 2018-10-17 10:33:30 +0200 | [diff] [blame] | 421 | if (!vpd->is_read) { |
| 422 | printf("VPD wasn't read"); |
| 423 | return; |
| 424 | } |
| 425 | |
Denis Zalevskiy | 0d97471 | 2019-11-12 19:15:17 +0000 | [diff] [blame] | 426 | if (vpd->has & VPD_HAS_MAC1) |
| 427 | eth_env_set_enetaddr_by_index("eth", fec_index, vpd->mac1); |
| 428 | |
| 429 | env_set("ethact", "eth0"); |
| 430 | |
Martyn Welch | 18c31ea | 2018-01-10 20:31:30 +0100 | [diff] [blame] | 431 | switch (vpd->product_id) { |
| 432 | case VPD_PRODUCT_B450: |
Ian Ray | b52e252 | 2018-01-10 20:31:33 +0100 | [diff] [blame] | 433 | env_set("confidx", "1"); |
Denis Zalevskiy | 0d97471 | 2019-11-12 19:15:17 +0000 | [diff] [blame] | 434 | i210_index = 1; |
Ian Ray | b52e252 | 2018-01-10 20:31:33 +0100 | [diff] [blame] | 435 | break; |
| 436 | case VPD_PRODUCT_B650: |
| 437 | env_set("confidx", "2"); |
Denis Zalevskiy | 0d97471 | 2019-11-12 19:15:17 +0000 | [diff] [blame] | 438 | i210_index = 1; |
Martyn Welch | 18c31ea | 2018-01-10 20:31:30 +0100 | [diff] [blame] | 439 | break; |
| 440 | case VPD_PRODUCT_B850: |
Nandor Han | f335ae9 | 2018-04-25 16:56:59 +0200 | [diff] [blame] | 441 | env_set("confidx", "3"); |
Denis Zalevskiy | 0d97471 | 2019-11-12 19:15:17 +0000 | [diff] [blame] | 442 | i210_index = 2; |
Martyn Welch | 18c31ea | 2018-01-10 20:31:30 +0100 | [diff] [blame] | 443 | break; |
Ian Ray | c0293da | 2017-08-22 09:03:54 +0300 | [diff] [blame] | 444 | } |
Martyn Welch | 18c31ea | 2018-01-10 20:31:30 +0100 | [diff] [blame] | 445 | |
Hannu Lounento | 3787968 | 2018-01-10 20:31:31 +0100 | [diff] [blame] | 446 | if (i210_index >= 0 && (vpd->has & VPD_HAS_MAC2)) |
| 447 | eth_env_set_enetaddr_by_index("eth", i210_index, vpd->mac2); |
Ian Ray | c0293da | 2017-08-22 09:03:54 +0300 | [diff] [blame] | 448 | } |
| 449 | |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 450 | static iomux_v3_cfg_t const misc_pads[] = { |
| 451 | MX6_PAD_KEY_ROW2__GPIO4_IO11 | MUX_PAD_CTRL(NO_PAD_CTRL), |
Justin Waters | ef93fc2 | 2016-04-13 17:03:18 -0400 | [diff] [blame] | 452 | MX6_PAD_EIM_A25__GPIO5_IO02 | MUX_PAD_CTRL(NC_PAD_CTRL), |
| 453 | MX6_PAD_EIM_CS0__GPIO2_IO23 | MUX_PAD_CTRL(NC_PAD_CTRL), |
| 454 | MX6_PAD_EIM_CS1__GPIO2_IO24 | MUX_PAD_CTRL(NC_PAD_CTRL), |
| 455 | MX6_PAD_EIM_OE__GPIO2_IO25 | MUX_PAD_CTRL(NC_PAD_CTRL), |
| 456 | MX6_PAD_EIM_BCLK__GPIO6_IO31 | MUX_PAD_CTRL(NC_PAD_CTRL), |
| 457 | MX6_PAD_GPIO_1__GPIO1_IO01 | MUX_PAD_CTRL(NC_PAD_CTRL), |
Martyn Welch | 110f5d9 | 2018-01-10 20:31:32 +0100 | [diff] [blame] | 458 | MX6_PAD_GPIO_9__WDOG1_B | MUX_PAD_CTRL(NC_PAD_CTRL), |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 459 | }; |
| 460 | #define SUS_S3_OUT IMX_GPIO_NR(4, 11) |
| 461 | #define WIFI_EN IMX_GPIO_NR(6, 14) |
| 462 | |
| 463 | int board_early_init_f(void) |
| 464 | { |
| 465 | imx_iomux_v3_setup_multiple_pads(misc_pads, |
| 466 | ARRAY_SIZE(misc_pads)); |
| 467 | |
| 468 | setup_iomux_uart(); |
| 469 | |
Akshay Bhat | 3a5b15a | 2016-04-12 18:13:58 -0400 | [diff] [blame] | 470 | #if defined(CONFIG_VIDEO_IPUV3) |
Ian Ray | 28540c5 | 2018-10-15 09:59:44 +0200 | [diff] [blame] | 471 | /* Set LDB clock to Video PLL */ |
| 472 | select_ldb_di_clock_source(MXC_PLL5_CLK); |
Akshay Bhat | 3a5b15a | 2016-04-12 18:13:58 -0400 | [diff] [blame] | 473 | #endif |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 474 | return 0; |
| 475 | } |
| 476 | |
Nandor Han | 7a9bb30 | 2018-04-25 16:57:01 +0200 | [diff] [blame] | 477 | static void set_confidx(const struct vpd_cache* vpd) |
| 478 | { |
| 479 | switch (vpd->product_id) { |
| 480 | case VPD_PRODUCT_B450: |
| 481 | confidx = 1; |
| 482 | break; |
| 483 | case VPD_PRODUCT_B650: |
| 484 | confidx = 2; |
| 485 | break; |
| 486 | case VPD_PRODUCT_B850: |
| 487 | confidx = 3; |
| 488 | break; |
| 489 | } |
| 490 | } |
| 491 | |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 492 | int board_init(void) |
| 493 | { |
Dan Cimpoca | 42e8d8f | 2018-10-15 12:09:56 +0200 | [diff] [blame] | 494 | setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info1); |
| 495 | setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info2); |
| 496 | setup_i2c(2, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info3); |
Nandor Han | 7a9bb30 | 2018-04-25 16:57:01 +0200 | [diff] [blame] | 497 | |
Denis Zalevskiy | 22a347d | 2018-10-17 10:33:30 +0200 | [diff] [blame] | 498 | if (!read_vpd(&vpd, vpd_callback)) { |
Robert Beckett | f746ab6 | 2019-11-12 19:15:11 +0000 | [diff] [blame] | 499 | int ret, rescan; |
| 500 | |
Denis Zalevskiy | 22a347d | 2018-10-17 10:33:30 +0200 | [diff] [blame] | 501 | vpd.is_read = true; |
| 502 | set_confidx(&vpd); |
Robert Beckett | f746ab6 | 2019-11-12 19:15:11 +0000 | [diff] [blame] | 503 | |
| 504 | ret = fdtdec_resetup(&rescan); |
| 505 | if (!ret && rescan) { |
| 506 | dm_uninit(); |
| 507 | dm_init_and_scan(false); |
| 508 | } |
Denis Zalevskiy | 22a347d | 2018-10-17 10:33:30 +0200 | [diff] [blame] | 509 | } |
Nandor Han | 7a9bb30 | 2018-04-25 16:57:01 +0200 | [diff] [blame] | 510 | |
Ian Ray | 5f1e344 | 2019-01-31 16:21:13 +0200 | [diff] [blame] | 511 | gpio_request(SUS_S3_OUT, "sus_s3_out"); |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 512 | gpio_direction_output(SUS_S3_OUT, 1); |
Ian Ray | 5f1e344 | 2019-01-31 16:21:13 +0200 | [diff] [blame] | 513 | |
| 514 | gpio_request(WIFI_EN, "wifi_en"); |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 515 | gpio_direction_output(WIFI_EN, 1); |
Ian Ray | 5f1e344 | 2019-01-31 16:21:13 +0200 | [diff] [blame] | 516 | |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 517 | #if defined(CONFIG_VIDEO_IPUV3) |
Ian Ray | 6eac23f | 2018-04-25 16:57:02 +0200 | [diff] [blame] | 518 | if (is_b850v3()) |
Akshay Bhat | cc4e4b6 | 2016-04-12 18:13:57 -0400 | [diff] [blame] | 519 | setup_display_b850v3(); |
| 520 | else |
| 521 | setup_display_bx50v3(); |
Ian Ray | 5f1e344 | 2019-01-31 16:21:13 +0200 | [diff] [blame] | 522 | |
| 523 | gpio_request(LVDS_BACKLIGHT_GP, "lvds_backlight"); |
| 524 | gpio_direction_input(LVDS_BACKLIGHT_GP); |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 525 | #endif |
Ian Ray | 5f1e344 | 2019-01-31 16:21:13 +0200 | [diff] [blame] | 526 | |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 527 | /* address of boot parameters */ |
| 528 | gd->bd->bi_boot_params = PHYS_SDRAM + 0x100; |
| 529 | |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 530 | return 0; |
| 531 | } |
| 532 | |
| 533 | #ifdef CONFIG_CMD_BMODE |
| 534 | static const struct boot_mode board_boot_modes[] = { |
| 535 | /* 4 bit bus width */ |
| 536 | {"sd2", MAKE_CFGVAL(0x40, 0x28, 0x00, 0x00)}, |
| 537 | {"sd3", MAKE_CFGVAL(0x40, 0x30, 0x00, 0x00)}, |
| 538 | {NULL, 0}, |
| 539 | }; |
| 540 | #endif |
| 541 | |
Ken Lin | c7219fc | 2016-11-18 12:20:54 -0500 | [diff] [blame] | 542 | void pmic_init(void) |
| 543 | { |
| 544 | #define I2C_PMIC 0x2 |
| 545 | #define DA9063_I2C_ADDR 0x58 |
| 546 | #define DA9063_REG_BCORE2_CFG 0x9D |
| 547 | #define DA9063_REG_BCORE1_CFG 0x9E |
| 548 | #define DA9063_REG_BPRO_CFG 0x9F |
| 549 | #define DA9063_REG_BIO_CFG 0xA0 |
| 550 | #define DA9063_REG_BMEM_CFG 0xA1 |
| 551 | #define DA9063_REG_BPERI_CFG 0xA2 |
| 552 | #define DA9063_BUCK_MODE_MASK 0xC0 |
| 553 | #define DA9063_BUCK_MODE_MANUAL 0x00 |
| 554 | #define DA9063_BUCK_MODE_SLEEP 0x40 |
| 555 | #define DA9063_BUCK_MODE_SYNC 0x80 |
| 556 | #define DA9063_BUCK_MODE_AUTO 0xC0 |
| 557 | |
| 558 | uchar val; |
| 559 | |
| 560 | i2c_set_bus_num(I2C_PMIC); |
| 561 | |
| 562 | i2c_read(DA9063_I2C_ADDR, DA9063_REG_BCORE2_CFG, 1, &val, 1); |
| 563 | val &= ~DA9063_BUCK_MODE_MASK; |
| 564 | val |= DA9063_BUCK_MODE_SYNC; |
| 565 | i2c_write(DA9063_I2C_ADDR, DA9063_REG_BCORE2_CFG, 1, &val, 1); |
| 566 | |
| 567 | i2c_read(DA9063_I2C_ADDR, DA9063_REG_BCORE1_CFG, 1, &val, 1); |
| 568 | val &= ~DA9063_BUCK_MODE_MASK; |
| 569 | val |= DA9063_BUCK_MODE_SYNC; |
| 570 | i2c_write(DA9063_I2C_ADDR, DA9063_REG_BCORE1_CFG, 1, &val, 1); |
| 571 | |
| 572 | i2c_read(DA9063_I2C_ADDR, DA9063_REG_BPRO_CFG, 1, &val, 1); |
| 573 | val &= ~DA9063_BUCK_MODE_MASK; |
| 574 | val |= DA9063_BUCK_MODE_SYNC; |
| 575 | i2c_write(DA9063_I2C_ADDR, DA9063_REG_BPRO_CFG, 1, &val, 1); |
| 576 | |
| 577 | i2c_read(DA9063_I2C_ADDR, DA9063_REG_BIO_CFG, 1, &val, 1); |
| 578 | val &= ~DA9063_BUCK_MODE_MASK; |
| 579 | val |= DA9063_BUCK_MODE_SYNC; |
| 580 | i2c_write(DA9063_I2C_ADDR, DA9063_REG_BIO_CFG, 1, &val, 1); |
| 581 | |
| 582 | i2c_read(DA9063_I2C_ADDR, DA9063_REG_BMEM_CFG, 1, &val, 1); |
| 583 | val &= ~DA9063_BUCK_MODE_MASK; |
| 584 | val |= DA9063_BUCK_MODE_SYNC; |
| 585 | i2c_write(DA9063_I2C_ADDR, DA9063_REG_BMEM_CFG, 1, &val, 1); |
| 586 | |
| 587 | i2c_read(DA9063_I2C_ADDR, DA9063_REG_BPERI_CFG, 1, &val, 1); |
| 588 | val &= ~DA9063_BUCK_MODE_MASK; |
| 589 | val |= DA9063_BUCK_MODE_SYNC; |
| 590 | i2c_write(DA9063_I2C_ADDR, DA9063_REG_BPERI_CFG, 1, &val, 1); |
| 591 | } |
| 592 | |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 593 | int board_late_init(void) |
| 594 | { |
Nandor Han | 7a9bb30 | 2018-04-25 16:57:01 +0200 | [diff] [blame] | 595 | process_vpd(&vpd); |
Martyn Welch | 18c31ea | 2018-01-10 20:31:30 +0100 | [diff] [blame] | 596 | |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 597 | #ifdef CONFIG_CMD_BMODE |
| 598 | add_board_boot_modes(board_boot_modes); |
| 599 | #endif |
Andrew Shadura | c26583d | 2016-05-24 15:56:17 +0200 | [diff] [blame] | 600 | |
Ian Ray | d8c6099 | 2018-04-25 16:57:03 +0200 | [diff] [blame] | 601 | if (is_b850v3()) |
| 602 | env_set("videoargs", "video=DP-1:1024x768@60 video=HDMI-A-1:1024x768@60"); |
Ian Ray | 476e4e6 | 2018-10-15 09:59:45 +0200 | [diff] [blame] | 603 | else |
| 604 | env_set("videoargs", "video=LVDS-1:1024x768@65"); |
Ian Ray | d8c6099 | 2018-04-25 16:57:03 +0200 | [diff] [blame] | 605 | |
Ken Lin | c7219fc | 2016-11-18 12:20:54 -0500 | [diff] [blame] | 606 | /* board specific pmic init */ |
| 607 | pmic_init(); |
| 608 | |
Nandor Han | ae3c6d2 | 2018-01-10 20:31:38 +0100 | [diff] [blame] | 609 | check_time(); |
| 610 | |
Denis Zalevskiy | 0d97471 | 2019-11-12 19:15:17 +0000 | [diff] [blame] | 611 | pci_init(); |
| 612 | |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 613 | return 0; |
| 614 | } |
| 615 | |
Hannu Lounento | 3787968 | 2018-01-10 20:31:31 +0100 | [diff] [blame] | 616 | /* |
| 617 | * Removes the 'eth[0-9]*addr' environment variable with the given index |
| 618 | * |
| 619 | * @param index [in] the index of the eth_device whose variable is to be removed |
| 620 | */ |
| 621 | static void remove_ethaddr_env_var(int index) |
| 622 | { |
| 623 | char env_var_name[9]; |
| 624 | |
| 625 | sprintf(env_var_name, index == 0 ? "ethaddr" : "eth%daddr", index); |
| 626 | env_set(env_var_name, NULL); |
| 627 | } |
| 628 | |
Martyn Welch | 18c31ea | 2018-01-10 20:31:30 +0100 | [diff] [blame] | 629 | int last_stage_init(void) |
| 630 | { |
Hannu Lounento | 3787968 | 2018-01-10 20:31:31 +0100 | [diff] [blame] | 631 | int i; |
| 632 | |
| 633 | /* |
| 634 | * Remove first three ethaddr which may have been created by |
| 635 | * function process_vpd(). |
| 636 | */ |
| 637 | for (i = 0; i < 3; ++i) |
| 638 | remove_ethaddr_env_var(i); |
Martyn Welch | 18c31ea | 2018-01-10 20:31:30 +0100 | [diff] [blame] | 639 | |
| 640 | return 0; |
| 641 | } |
| 642 | |
Akshay Bhat | 197f987 | 2016-01-29 15:16:40 -0500 | [diff] [blame] | 643 | int checkboard(void) |
| 644 | { |
| 645 | printf("BOARD: %s\n", CONFIG_BOARD_NAME); |
| 646 | return 0; |
| 647 | } |
Ian Ray | 4013368 | 2018-04-04 10:50:17 +0200 | [diff] [blame] | 648 | |
Ian Ray | 6445094 | 2019-01-31 16:21:18 +0200 | [diff] [blame] | 649 | #ifdef CONFIG_OF_BOARD_SETUP |
| 650 | int ft_board_setup(void *blob, bd_t *bd) |
| 651 | { |
Ian Ray | c69217c | 2019-11-12 19:15:18 +0000 | [diff] [blame^] | 652 | char *rtc_status = env_get("rtc_status"); |
| 653 | |
Ian Ray | 6445094 | 2019-01-31 16:21:18 +0200 | [diff] [blame] | 654 | fdt_setprop(blob, 0, "ge,boot-ver", version_string, |
Ian Ray | c69217c | 2019-11-12 19:15:18 +0000 | [diff] [blame^] | 655 | strlen(version_string) + 1); |
| 656 | |
| 657 | fdt_setprop(blob, 0, "ge,rtc-status", rtc_status, |
| 658 | strlen(rtc_status) + 1); |
Ian Ray | 6445094 | 2019-01-31 16:21:18 +0200 | [diff] [blame] | 659 | return 0; |
| 660 | } |
| 661 | #endif |
| 662 | |
Ian Ray | 4013368 | 2018-04-04 10:50:17 +0200 | [diff] [blame] | 663 | static int do_backlight_enable(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
| 664 | { |
Ian Ray | b7f9625 | 2019-11-12 19:15:15 +0000 | [diff] [blame] | 665 | #if CONFIG_IS_ENABLED(DM_VIDEO) |
| 666 | int ret; |
| 667 | struct udevice *dev; |
| 668 | |
Ian Ray | 4013368 | 2018-04-04 10:50:17 +0200 | [diff] [blame] | 669 | #ifdef CONFIG_VIDEO_IPUV3 |
Ian Ray | 8f198da | 2019-11-12 19:15:14 +0000 | [diff] [blame] | 670 | if (!is_b850v3()) { |
Ian Ray | b7f9625 | 2019-11-12 19:15:15 +0000 | [diff] [blame] | 671 | gpio_direction_output(LVDS_POWER_GP, 1); |
| 672 | |
Ian Ray | 8f198da | 2019-11-12 19:15:14 +0000 | [diff] [blame] | 673 | /* We need at least 200ms between power on and backlight on |
| 674 | * as per specifications from CHI MEI |
| 675 | */ |
| 676 | mdelay(250); |
Ian Ray | 4013368 | 2018-04-04 10:50:17 +0200 | [diff] [blame] | 677 | |
Ian Ray | 8f198da | 2019-11-12 19:15:14 +0000 | [diff] [blame] | 678 | /* enable backlight PWM 1 */ |
| 679 | pwm_init(0, 0, 0); |
Ian Ray | 4013368 | 2018-04-04 10:50:17 +0200 | [diff] [blame] | 680 | |
Ian Ray | 8f198da | 2019-11-12 19:15:14 +0000 | [diff] [blame] | 681 | /* duty cycle 5000000ns, period: 5000000ns */ |
| 682 | pwm_config(0, 5000000, 5000000); |
Ian Ray | 4013368 | 2018-04-04 10:50:17 +0200 | [diff] [blame] | 683 | |
Ian Ray | 8f198da | 2019-11-12 19:15:14 +0000 | [diff] [blame] | 684 | /* Backlight Power */ |
| 685 | gpio_direction_output(LVDS_BACKLIGHT_GP, 1); |
Ian Ray | 4013368 | 2018-04-04 10:50:17 +0200 | [diff] [blame] | 686 | |
Ian Ray | 8f198da | 2019-11-12 19:15:14 +0000 | [diff] [blame] | 687 | pwm_enable(0); |
| 688 | } |
Ian Ray | 4013368 | 2018-04-04 10:50:17 +0200 | [diff] [blame] | 689 | #endif |
| 690 | |
Ian Ray | b7f9625 | 2019-11-12 19:15:15 +0000 | [diff] [blame] | 691 | /* Probe, to find a video device to be used to show a message on |
| 692 | * the vidconsole. |
| 693 | */ |
| 694 | ret = uclass_get_device(UCLASS_VIDEO, 0, &dev); |
| 695 | if (ret) |
| 696 | return ret; |
| 697 | #endif |
| 698 | |
Ian Ray | 4013368 | 2018-04-04 10:50:17 +0200 | [diff] [blame] | 699 | return 0; |
| 700 | } |
| 701 | |
| 702 | U_BOOT_CMD( |
| 703 | bx50_backlight_enable, 1, 1, do_backlight_enable, |
| 704 | "enable Bx50 backlight", |
| 705 | "" |
| 706 | ); |
Robert Beckett | f746ab6 | 2019-11-12 19:15:11 +0000 | [diff] [blame] | 707 | |
| 708 | int board_fit_config_name_match(const char *name) |
| 709 | { |
| 710 | if (!vpd.is_read) |
| 711 | return strcmp(name, "imx6q-bx50v3"); |
| 712 | |
| 713 | switch (vpd.product_id) { |
| 714 | case VPD_PRODUCT_B450: |
| 715 | return strcmp(name, "imx6q-b450v3"); |
| 716 | case VPD_PRODUCT_B650: |
| 717 | return strcmp(name, "imx6q-b650v3"); |
| 718 | case VPD_PRODUCT_B850: |
| 719 | return strcmp(name, "imx6q-b850v3"); |
| 720 | default: |
| 721 | return -1; |
| 722 | } |
| 723 | } |
| 724 | |
| 725 | int embedded_dtb_select(void) |
| 726 | { |
| 727 | vpd.is_read = false; |
| 728 | return fdtdec_setup(); |
| 729 | } |