Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2013 Gateworks Corporation |
| 4 | * |
| 5 | * Author: Tim Harvey <tharvey@gateworks.com> |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 9 | #include <asm/arch/clock.h> |
Tim Harvey | 0cee224 | 2015-05-08 18:28:35 -0700 | [diff] [blame] | 10 | #include <asm/arch/crm_regs.h> |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 11 | #include <asm/arch/mx6-pins.h> |
Tim Harvey | fb64cc7 | 2014-04-25 15:39:07 -0700 | [diff] [blame] | 12 | #include <asm/arch/mxc_hdmi.h> |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 13 | #include <asm/arch/sys_proto.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 14 | #include <asm/global_data.h> |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 15 | #include <asm/gpio.h> |
Stefano Babic | 33731bc | 2017-06-29 10:16:06 +0200 | [diff] [blame] | 16 | #include <asm/mach-imx/boot_mode.h> |
Stefano Babic | 33731bc | 2017-06-29 10:16:06 +0200 | [diff] [blame] | 17 | #include <asm/mach-imx/video.h> |
Simon Glass | d9a766f | 2017-05-17 08:23:00 -0600 | [diff] [blame] | 18 | #include <asm/setup.h> |
Simon Glass | 5e6201b | 2019-08-01 09:46:51 -0600 | [diff] [blame] | 19 | #include <env.h> |
Tim Harvey | 8d2d8df | 2016-05-24 11:03:55 -0700 | [diff] [blame] | 20 | #include <hwconfig.h> |
Tim Harvey | 0cee224 | 2015-05-08 18:28:35 -0700 | [diff] [blame] | 21 | #include <linux/ctype.h> |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 22 | #include <miiphy.h> |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 23 | #include <mtd_node.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 24 | #include <linux/delay.h> |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 25 | #include <power/pmic.h> |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 26 | #include <fdt_support.h> |
| 27 | #include <jffs2/load_kernel.h> |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 28 | |
| 29 | #include "gsc.h" |
Tim Harvey | 0cee224 | 2015-05-08 18:28:35 -0700 | [diff] [blame] | 30 | #include "common.h" |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 31 | |
| 32 | DECLARE_GLOBAL_DATA_PTR; |
| 33 | |
Tim Harvey | 2699336 | 2014-08-07 22:35:49 -0700 | [diff] [blame] | 34 | |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 35 | /* |
| 36 | * EEPROM board info struct populated by read_eeprom so that we only have to |
| 37 | * read it once. |
| 38 | */ |
Tim Harvey | 0da2c52 | 2014-08-07 22:35:45 -0700 | [diff] [blame] | 39 | struct ventana_board_info ventana_info; |
Tim Harvey | 8b92bdf | 2015-04-08 12:54:43 -0700 | [diff] [blame] | 40 | static int board_type; |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 41 | |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 42 | #ifdef CONFIG_USB_EHCI_MX6 |
Tim Harvey | 1112b4e | 2021-03-01 14:33:34 -0800 | [diff] [blame] | 43 | /* toggle USB_HUB_RST# for boards that have it; it is not defined in dt */ |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 44 | int board_ehci_hcd_init(int port) |
| 45 | { |
Tim Harvey | f1f41db | 2015-05-08 18:28:28 -0700 | [diff] [blame] | 46 | int gpio; |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 47 | |
Tim Harvey | 1112b4e | 2021-03-01 14:33:34 -0800 | [diff] [blame] | 48 | /* USB HUB is always on P1 */ |
| 49 | if (port == 0) |
| 50 | return 0; |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 51 | |
Tim Harvey | db7edfa | 2015-05-26 11:04:54 -0700 | [diff] [blame] | 52 | /* Reset USB HUB */ |
| 53 | switch (board_type) { |
| 54 | case GW53xx: |
| 55 | case GW552x: |
Tim Harvey | b7c48a9 | 2019-02-04 13:10:54 -0800 | [diff] [blame] | 56 | case GW5906: |
Tim Harvey | f1f41db | 2015-05-08 18:28:28 -0700 | [diff] [blame] | 57 | gpio = (IMX_GPIO_NR(1, 9)); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 58 | break; |
Tim Harvey | db7edfa | 2015-05-26 11:04:54 -0700 | [diff] [blame] | 59 | case GW54proto: |
| 60 | case GW54xx: |
Tim Harvey | f1f41db | 2015-05-08 18:28:28 -0700 | [diff] [blame] | 61 | gpio = (IMX_GPIO_NR(1, 16)); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 62 | break; |
Tim Harvey | f1f41db | 2015-05-08 18:28:28 -0700 | [diff] [blame] | 63 | default: |
| 64 | return 0; |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 65 | } |
| 66 | |
Tim Harvey | f1f41db | 2015-05-08 18:28:28 -0700 | [diff] [blame] | 67 | /* request and toggle hub rst */ |
| 68 | gpio_request(gpio, "usb_hub_rst#"); |
| 69 | gpio_direction_output(gpio, 0); |
| 70 | mdelay(2); |
| 71 | gpio_set_value(gpio, 1); |
| 72 | |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 73 | return 0; |
| 74 | } |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 75 | #endif /* CONFIG_USB_EHCI_MX6 */ |
| 76 | |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 77 | /* configure eth0 PHY board-specific LED behavior */ |
| 78 | int board_phy_config(struct phy_device *phydev) |
| 79 | { |
| 80 | unsigned short val; |
| 81 | |
| 82 | /* Marvel 88E1510 */ |
| 83 | if (phydev->phy_id == 0x1410dd1) { |
| 84 | /* |
| 85 | * Page 3, Register 16: LED[2:0] Function Control Register |
| 86 | * LED[0] (SPD:Amber) R16_3.3:0 to 0111: on-GbE link |
| 87 | * LED[1] (LNK:Green) R16_3.7:4 to 0001: on-link, blink-activity |
| 88 | */ |
| 89 | phy_write(phydev, MDIO_DEVAD_NONE, 22, 3); |
| 90 | val = phy_read(phydev, MDIO_DEVAD_NONE, 16); |
| 91 | val &= 0xff00; |
| 92 | val |= 0x0017; |
| 93 | phy_write(phydev, MDIO_DEVAD_NONE, 16, val); |
| 94 | phy_write(phydev, MDIO_DEVAD_NONE, 22, 0); |
| 95 | } |
| 96 | |
Tim Harvey | 4533c90 | 2017-03-17 07:32:21 -0700 | [diff] [blame] | 97 | /* TI DP83867 */ |
| 98 | else if (phydev->phy_id == 0x2000a231) { |
| 99 | /* configure register 0x170 for ref CLKOUT */ |
| 100 | phy_write(phydev, MDIO_DEVAD_NONE, 13, 0x001f); |
| 101 | phy_write(phydev, MDIO_DEVAD_NONE, 14, 0x0170); |
| 102 | phy_write(phydev, MDIO_DEVAD_NONE, 13, 0x401f); |
| 103 | val = phy_read(phydev, MDIO_DEVAD_NONE, 14); |
| 104 | val &= ~0x1f00; |
| 105 | val |= 0x0b00; /* chD tx clock*/ |
| 106 | phy_write(phydev, MDIO_DEVAD_NONE, 14, val); |
| 107 | } |
| 108 | |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 109 | if (phydev->drv->config) |
| 110 | phydev->drv->config(phydev); |
| 111 | |
| 112 | return 0; |
| 113 | } |
Tim Harvey | 6353779 | 2017-03-17 07:30:38 -0700 | [diff] [blame] | 114 | |
| 115 | #ifdef CONFIG_MV88E61XX_SWITCH |
| 116 | int mv88e61xx_hw_reset(struct phy_device *phydev) |
| 117 | { |
| 118 | struct mii_dev *bus = phydev->bus; |
| 119 | |
| 120 | /* GPIO[0] output, CLK125 */ |
| 121 | debug("enabling RGMII_REFCLK\n"); |
| 122 | bus->write(bus, 0x1c /*MV_GLOBAL2*/, 0, |
| 123 | 0x1a /*MV_SCRATCH_MISC*/, |
| 124 | (1 << 15) | (0x62 /*MV_GPIO_DIR*/ << 8) | 0xfe); |
| 125 | bus->write(bus, 0x1c /*MV_GLOBAL2*/, 0, |
| 126 | 0x1a /*MV_SCRATCH_MISC*/, |
| 127 | (1 << 15) | (0x68 /*MV_GPIO01_CNTL*/ << 8) | 7); |
| 128 | |
| 129 | /* RGMII delay - Physical Control register bit[15:14] */ |
| 130 | debug("setting port%d RGMII rx/tx delay\n", CONFIG_MV88E61XX_CPU_PORT); |
| 131 | /* forced 1000mbps full-duplex link */ |
| 132 | bus->write(bus, 0x10 + CONFIG_MV88E61XX_CPU_PORT, 0, 1, 0xc0fe); |
| 133 | phydev->autoneg = AUTONEG_DISABLE; |
| 134 | phydev->speed = SPEED_1000; |
| 135 | phydev->duplex = DUPLEX_FULL; |
| 136 | |
Tim Harvey | 8c9d393 | 2019-02-04 13:10:47 -0800 | [diff] [blame] | 137 | /* LED configuration: 7:4-green (8=Activity) 3:0 amber (8=Link) */ |
| 138 | bus->write(bus, 0x10, 0, 0x16, 0x8088); |
| 139 | bus->write(bus, 0x11, 0, 0x16, 0x8088); |
| 140 | bus->write(bus, 0x12, 0, 0x16, 0x8088); |
| 141 | bus->write(bus, 0x13, 0, 0x16, 0x8088); |
Tim Harvey | 6353779 | 2017-03-17 07:30:38 -0700 | [diff] [blame] | 142 | |
| 143 | return 0; |
| 144 | } |
| 145 | #endif // CONFIG_MV88E61XX_SWITCH |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 146 | |
Tim Harvey | fb64cc7 | 2014-04-25 15:39:07 -0700 | [diff] [blame] | 147 | #if defined(CONFIG_VIDEO_IPUV3) |
Tim Harvey | fb64cc7 | 2014-04-25 15:39:07 -0700 | [diff] [blame] | 148 | static void enable_hdmi(struct display_info_t const *dev) |
| 149 | { |
| 150 | imx_enable_hdmi_phy(); |
| 151 | } |
| 152 | |
| 153 | static int detect_i2c(struct display_info_t const *dev) |
| 154 | { |
| 155 | return i2c_set_bus_num(dev->bus) == 0 && |
| 156 | i2c_probe(dev->addr) == 0; |
| 157 | } |
| 158 | |
| 159 | static void enable_lvds(struct display_info_t const *dev) |
| 160 | { |
| 161 | struct iomuxc *iomux = (struct iomuxc *) |
| 162 | IOMUXC_BASE_ADDR; |
| 163 | |
| 164 | /* set CH0 data width to 24bit (IOMUXC_GPR2:5 0=18bit, 1=24bit) */ |
| 165 | u32 reg = readl(&iomux->gpr[2]); |
| 166 | reg |= IOMUXC_GPR2_DATA_WIDTH_CH0_24BIT; |
| 167 | writel(reg, &iomux->gpr[2]); |
| 168 | |
| 169 | /* Enable Backlight */ |
Tim Harvey | a67e07f | 2016-05-24 11:03:53 -0700 | [diff] [blame] | 170 | gpio_request(IMX_GPIO_NR(1, 10), "bklt_gpio"); |
| 171 | gpio_direction_output(IMX_GPIO_NR(1, 10), 0); |
Tim Harvey | f1f41db | 2015-05-08 18:28:28 -0700 | [diff] [blame] | 172 | gpio_request(IMX_GPIO_NR(1, 18), "bklt_en"); |
Tim Harvey | 2699336 | 2014-08-07 22:35:49 -0700 | [diff] [blame] | 173 | SETUP_IOMUX_PAD(PAD_SD1_CMD__GPIO1_IO18 | DIO_PAD_CFG); |
Tim Harvey | fb64cc7 | 2014-04-25 15:39:07 -0700 | [diff] [blame] | 174 | gpio_direction_output(IMX_GPIO_NR(1, 18), 1); |
| 175 | } |
| 176 | |
| 177 | struct display_info_t const displays[] = {{ |
| 178 | /* HDMI Output */ |
| 179 | .bus = -1, |
| 180 | .addr = 0, |
| 181 | .pixfmt = IPU_PIX_FMT_RGB24, |
| 182 | .detect = detect_hdmi, |
| 183 | .enable = enable_hdmi, |
| 184 | .mode = { |
| 185 | .name = "HDMI", |
| 186 | .refresh = 60, |
| 187 | .xres = 1024, |
| 188 | .yres = 768, |
| 189 | .pixclock = 15385, |
| 190 | .left_margin = 220, |
| 191 | .right_margin = 40, |
| 192 | .upper_margin = 21, |
| 193 | .lower_margin = 7, |
| 194 | .hsync_len = 60, |
| 195 | .vsync_len = 10, |
| 196 | .sync = FB_SYNC_EXT, |
| 197 | .vmode = FB_VMODE_NONINTERLACED |
| 198 | } }, { |
| 199 | /* Freescale MXC-LVDS1: HannStar HSD100PXN1-A00 w/ egalx_ts cont */ |
| 200 | .bus = 2, |
| 201 | .addr = 0x4, |
| 202 | .pixfmt = IPU_PIX_FMT_LVDS666, |
| 203 | .detect = detect_i2c, |
| 204 | .enable = enable_lvds, |
| 205 | .mode = { |
| 206 | .name = "Hannstar-XGA", |
| 207 | .refresh = 60, |
| 208 | .xres = 1024, |
| 209 | .yres = 768, |
| 210 | .pixclock = 15385, |
| 211 | .left_margin = 220, |
| 212 | .right_margin = 40, |
| 213 | .upper_margin = 21, |
| 214 | .lower_margin = 7, |
| 215 | .hsync_len = 60, |
| 216 | .vsync_len = 10, |
| 217 | .sync = FB_SYNC_EXT, |
| 218 | .vmode = FB_VMODE_NONINTERLACED |
Tim Harvey | a20bd63 | 2015-04-08 12:54:57 -0700 | [diff] [blame] | 219 | } }, { |
| 220 | /* DLC700JMG-T-4 */ |
Tim Harvey | be786e7 | 2019-02-04 13:10:53 -0800 | [diff] [blame] | 221 | .bus = 2, |
| 222 | .addr = 0x38, |
Tim Harvey | a20bd63 | 2015-04-08 12:54:57 -0700 | [diff] [blame] | 223 | .detect = NULL, |
| 224 | .enable = enable_lvds, |
| 225 | .pixfmt = IPU_PIX_FMT_LVDS666, |
| 226 | .mode = { |
| 227 | .name = "DLC700JMGT4", |
| 228 | .refresh = 60, |
| 229 | .xres = 1024, /* 1024x600active pixels */ |
| 230 | .yres = 600, |
| 231 | .pixclock = 15385, /* 64MHz */ |
| 232 | .left_margin = 220, |
| 233 | .right_margin = 40, |
| 234 | .upper_margin = 21, |
| 235 | .lower_margin = 7, |
| 236 | .hsync_len = 60, |
| 237 | .vsync_len = 10, |
| 238 | .sync = FB_SYNC_EXT, |
| 239 | .vmode = FB_VMODE_NONINTERLACED |
| 240 | } }, { |
| 241 | /* DLC800FIG-T-3 */ |
Tim Harvey | be786e7 | 2019-02-04 13:10:53 -0800 | [diff] [blame] | 242 | .bus = 2, |
| 243 | .addr = 0x14, |
Tim Harvey | a20bd63 | 2015-04-08 12:54:57 -0700 | [diff] [blame] | 244 | .detect = NULL, |
| 245 | .enable = enable_lvds, |
| 246 | .pixfmt = IPU_PIX_FMT_LVDS666, |
| 247 | .mode = { |
| 248 | .name = "DLC800FIGT3", |
| 249 | .refresh = 60, |
| 250 | .xres = 1024, /* 1024x768 active pixels */ |
| 251 | .yres = 768, |
| 252 | .pixclock = 15385, /* 64MHz */ |
| 253 | .left_margin = 220, |
| 254 | .right_margin = 40, |
| 255 | .upper_margin = 21, |
| 256 | .lower_margin = 7, |
| 257 | .hsync_len = 60, |
| 258 | .vsync_len = 10, |
| 259 | .sync = FB_SYNC_EXT, |
| 260 | .vmode = FB_VMODE_NONINTERLACED |
Tim Harvey | c34e59e | 2019-02-04 13:10:51 -0800 | [diff] [blame] | 261 | } }, { |
| 262 | .bus = 2, |
| 263 | .addr = 0x5d, |
| 264 | .detect = detect_i2c, |
| 265 | .enable = enable_lvds, |
| 266 | .pixfmt = IPU_PIX_FMT_LVDS666, |
| 267 | .mode = { |
| 268 | .name = "Z101WX01", |
| 269 | .refresh = 60, |
| 270 | .xres = 1280, |
| 271 | .yres = 800, |
| 272 | .pixclock = 15385, /* 64MHz */ |
| 273 | .left_margin = 220, |
| 274 | .right_margin = 40, |
| 275 | .upper_margin = 21, |
| 276 | .lower_margin = 7, |
| 277 | .hsync_len = 60, |
| 278 | .vsync_len = 10, |
| 279 | .sync = FB_SYNC_EXT, |
| 280 | .vmode = FB_VMODE_NONINTERLACED |
| 281 | } |
| 282 | }, |
| 283 | }; |
Tim Harvey | fb64cc7 | 2014-04-25 15:39:07 -0700 | [diff] [blame] | 284 | size_t display_count = ARRAY_SIZE(displays); |
| 285 | |
| 286 | static void setup_display(void) |
| 287 | { |
| 288 | struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR; |
| 289 | struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR; |
| 290 | int reg; |
| 291 | |
| 292 | enable_ipu_clock(); |
| 293 | imx_setup_hdmi(); |
| 294 | /* Turn on LDB0,IPU,IPU DI0 clocks */ |
| 295 | reg = __raw_readl(&mxc_ccm->CCGR3); |
| 296 | reg |= MXC_CCM_CCGR3_LDB_DI0_MASK; |
| 297 | writel(reg, &mxc_ccm->CCGR3); |
| 298 | |
| 299 | /* set LDB0, LDB1 clk select to 011/011 */ |
| 300 | reg = readl(&mxc_ccm->cs2cdr); |
| 301 | reg &= ~(MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_MASK |
| 302 | |MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_MASK); |
| 303 | reg |= (3<<MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_OFFSET) |
| 304 | |(3<<MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_OFFSET); |
| 305 | writel(reg, &mxc_ccm->cs2cdr); |
| 306 | |
| 307 | reg = readl(&mxc_ccm->cscmr2); |
| 308 | reg |= MXC_CCM_CSCMR2_LDB_DI0_IPU_DIV; |
| 309 | writel(reg, &mxc_ccm->cscmr2); |
| 310 | |
| 311 | reg = readl(&mxc_ccm->chsccdr); |
| 312 | reg |= (CHSCCDR_CLK_SEL_LDB_DI0 |
| 313 | <<MXC_CCM_CHSCCDR_IPU1_DI0_CLK_SEL_OFFSET); |
| 314 | writel(reg, &mxc_ccm->chsccdr); |
| 315 | |
| 316 | reg = IOMUXC_GPR2_BGREF_RRMODE_EXTERNAL_RES |
| 317 | |IOMUXC_GPR2_DI1_VS_POLARITY_ACTIVE_HIGH |
| 318 | |IOMUXC_GPR2_DI0_VS_POLARITY_ACTIVE_LOW |
| 319 | |IOMUXC_GPR2_BIT_MAPPING_CH1_SPWG |
| 320 | |IOMUXC_GPR2_DATA_WIDTH_CH1_18BIT |
| 321 | |IOMUXC_GPR2_BIT_MAPPING_CH0_SPWG |
| 322 | |IOMUXC_GPR2_DATA_WIDTH_CH0_18BIT |
| 323 | |IOMUXC_GPR2_LVDS_CH1_MODE_DISABLED |
| 324 | |IOMUXC_GPR2_LVDS_CH0_MODE_ENABLED_DI0; |
| 325 | writel(reg, &iomux->gpr[2]); |
| 326 | |
| 327 | reg = readl(&iomux->gpr[3]); |
| 328 | reg = (reg & ~IOMUXC_GPR3_LVDS0_MUX_CTL_MASK) |
| 329 | | (IOMUXC_GPR3_MUX_SRC_IPU1_DI0 |
| 330 | <<IOMUXC_GPR3_LVDS0_MUX_CTL_OFFSET); |
| 331 | writel(reg, &iomux->gpr[3]); |
| 332 | |
Tim Harvey | a67e07f | 2016-05-24 11:03:53 -0700 | [diff] [blame] | 333 | /* LVDS Backlight GPIO on LVDS connector - output low */ |
Tim Harvey | 2699336 | 2014-08-07 22:35:49 -0700 | [diff] [blame] | 334 | SETUP_IOMUX_PAD(PAD_SD2_CLK__GPIO1_IO10 | DIO_PAD_CFG); |
Tim Harvey | fb64cc7 | 2014-04-25 15:39:07 -0700 | [diff] [blame] | 335 | gpio_direction_output(IMX_GPIO_NR(1, 10), 0); |
| 336 | } |
| 337 | #endif /* CONFIG_VIDEO_IPUV3 */ |
| 338 | |
Tim Harvey | 0dff16f | 2014-05-05 08:22:25 -0700 | [diff] [blame] | 339 | /* setup board specific PMIC */ |
| 340 | int power_init_board(void) |
| 341 | { |
Tim Harvey | 195bc97 | 2015-05-08 18:28:37 -0700 | [diff] [blame] | 342 | setup_pmic(); |
Tim Harvey | 0dff16f | 2014-05-05 08:22:25 -0700 | [diff] [blame] | 343 | return 0; |
| 344 | } |
| 345 | |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 346 | int imx6_pcie_toggle_reset(void) |
| 347 | { |
| 348 | if (board_type < GW_UNKNOWN) { |
Tim Harvey | 02fb592 | 2014-06-02 16:13:26 -0700 | [diff] [blame] | 349 | uint pin = gpio_cfg[board_type].pcie_rst; |
Tim Harvey | f1f41db | 2015-05-08 18:28:28 -0700 | [diff] [blame] | 350 | gpio_request(pin, "pci_rst#"); |
Tim Harvey | 02fb592 | 2014-06-02 16:13:26 -0700 | [diff] [blame] | 351 | gpio_direction_output(pin, 0); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 352 | mdelay(50); |
Tim Harvey | 02fb592 | 2014-06-02 16:13:26 -0700 | [diff] [blame] | 353 | gpio_direction_output(pin, 1); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 354 | } |
| 355 | return 0; |
| 356 | } |
Tim Harvey | 33791d5 | 2014-08-07 22:49:57 -0700 | [diff] [blame] | 357 | |
| 358 | /* |
| 359 | * Most Ventana boards have a PLX PEX860x PCIe switch onboard and use its |
| 360 | * GPIO's as PERST# signals for its downstream ports - configure the GPIO's |
| 361 | * properly and assert reset for 100ms. |
| 362 | */ |
Tim Harvey | bfb240a | 2016-06-17 06:10:41 -0700 | [diff] [blame] | 363 | #define MAX_PCI_DEVS 32 |
| 364 | struct pci_dev { |
| 365 | pci_dev_t devfn; |
Tim Harvey | 6ce10d5 | 2021-05-03 11:21:27 -0700 | [diff] [blame] | 366 | struct udevice *dev; |
Tim Harvey | bfb240a | 2016-06-17 06:10:41 -0700 | [diff] [blame] | 367 | unsigned short vendor; |
| 368 | unsigned short device; |
| 369 | unsigned short class; |
| 370 | unsigned short busno; /* subbordinate busno */ |
| 371 | struct pci_dev *ppar; |
| 372 | }; |
| 373 | struct pci_dev pci_devs[MAX_PCI_DEVS]; |
| 374 | int pci_devno; |
| 375 | int pci_bridgeno; |
| 376 | |
Tim Harvey | 6ce10d5 | 2021-05-03 11:21:27 -0700 | [diff] [blame] | 377 | void board_pci_fixup_dev(struct udevice *bus, struct udevice *udev) |
Tim Harvey | 33791d5 | 2014-08-07 22:49:57 -0700 | [diff] [blame] | 378 | { |
Tim Harvey | 6ce10d5 | 2021-05-03 11:21:27 -0700 | [diff] [blame] | 379 | struct pci_child_plat *pdata = dev_get_parent_plat(udev); |
Tim Harvey | bfb240a | 2016-06-17 06:10:41 -0700 | [diff] [blame] | 380 | struct pci_dev *pdev = &pci_devs[pci_devno++]; |
Tim Harvey | 6ce10d5 | 2021-05-03 11:21:27 -0700 | [diff] [blame] | 381 | unsigned short vendor = pdata->vendor; |
| 382 | unsigned short device = pdata->device; |
| 383 | unsigned int class = pdata->class; |
| 384 | pci_dev_t dev = dm_pci_get_bdf(udev); |
| 385 | int i; |
Tim Harvey | 33791d5 | 2014-08-07 22:49:57 -0700 | [diff] [blame] | 386 | |
| 387 | debug("%s: %02d:%02d.%02d: %04x:%04x\n", __func__, |
| 388 | PCI_BUS(dev), PCI_DEV(dev), PCI_FUNC(dev), vendor, device); |
Tim Harvey | bfb240a | 2016-06-17 06:10:41 -0700 | [diff] [blame] | 389 | |
| 390 | /* store array of devs for later use in device-tree fixup */ |
Tim Harvey | 6ce10d5 | 2021-05-03 11:21:27 -0700 | [diff] [blame] | 391 | pdev->dev = udev; |
Tim Harvey | bfb240a | 2016-06-17 06:10:41 -0700 | [diff] [blame] | 392 | pdev->devfn = dev; |
| 393 | pdev->vendor = vendor; |
| 394 | pdev->device = device; |
| 395 | pdev->class = class; |
| 396 | pdev->ppar = NULL; |
| 397 | if (class == PCI_CLASS_BRIDGE_PCI) |
| 398 | pdev->busno = ++pci_bridgeno; |
| 399 | else |
| 400 | pdev->busno = 0; |
| 401 | |
| 402 | /* fixup RC - it should be 00:00.0 not 00:01.0 */ |
| 403 | if (PCI_BUS(dev) == 0) |
| 404 | pdev->devfn = 0; |
| 405 | |
| 406 | /* find dev's parent */ |
| 407 | for (i = 0; i < pci_devno; i++) { |
| 408 | if (pci_devs[i].busno == PCI_BUS(pdev->devfn)) { |
| 409 | pdev->ppar = &pci_devs[i]; |
| 410 | break; |
| 411 | } |
| 412 | } |
| 413 | |
| 414 | /* assert downstream PERST# */ |
Tim Harvey | 33791d5 | 2014-08-07 22:49:57 -0700 | [diff] [blame] | 415 | if (vendor == PCI_VENDOR_ID_PLX && |
| 416 | (device & 0xfff0) == 0x8600 && |
| 417 | PCI_DEV(dev) == 0 && PCI_FUNC(dev) == 0) { |
Tim Harvey | 6ce10d5 | 2021-05-03 11:21:27 -0700 | [diff] [blame] | 418 | ulong val; |
Tim Harvey | 33791d5 | 2014-08-07 22:49:57 -0700 | [diff] [blame] | 419 | debug("configuring PLX 860X downstream PERST#\n"); |
Tim Harvey | 6ce10d5 | 2021-05-03 11:21:27 -0700 | [diff] [blame] | 420 | pci_bus_read_config(bus, dev, 0x62c, &val, PCI_SIZE_32); |
| 421 | val |= 0xaaa8; /* GPIO1-7 outputs */ |
| 422 | pci_bus_write_config(bus, dev, 0x62c, val, PCI_SIZE_32); |
Tim Harvey | 33791d5 | 2014-08-07 22:49:57 -0700 | [diff] [blame] | 423 | |
Tim Harvey | 6ce10d5 | 2021-05-03 11:21:27 -0700 | [diff] [blame] | 424 | pci_bus_read_config(bus, dev, 0x644, &val, PCI_SIZE_32); |
| 425 | val |= 0xfe; /* GPIO1-7 output high */ |
| 426 | pci_bus_write_config(bus, dev, 0x644, val, PCI_SIZE_32); |
Tim Harvey | 33791d5 | 2014-08-07 22:49:57 -0700 | [diff] [blame] | 427 | |
| 428 | mdelay(100); |
| 429 | } |
| 430 | } |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 431 | |
| 432 | #ifdef CONFIG_SERIAL_TAG |
| 433 | /* |
| 434 | * called when setting up ATAGS before booting kernel |
| 435 | * populate serialnum from the following (in order of priority): |
| 436 | * serial# env var |
| 437 | * eeprom |
| 438 | */ |
| 439 | void get_board_serial(struct tag_serialnr *serialnr) |
| 440 | { |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 441 | char *serial = env_get("serial#"); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 442 | |
| 443 | if (serial) { |
| 444 | serialnr->high = 0; |
| 445 | serialnr->low = simple_strtoul(serial, NULL, 10); |
| 446 | } else if (ventana_info.model[0]) { |
| 447 | serialnr->high = 0; |
| 448 | serialnr->low = ventana_info.serial; |
| 449 | } else { |
| 450 | serialnr->high = 0; |
| 451 | serialnr->low = 0; |
| 452 | } |
| 453 | } |
| 454 | #endif |
| 455 | |
| 456 | /* |
| 457 | * Board Support |
| 458 | */ |
| 459 | |
| 460 | int board_early_init_f(void) |
| 461 | { |
Tim Harvey | fb64cc7 | 2014-04-25 15:39:07 -0700 | [diff] [blame] | 462 | #if defined(CONFIG_VIDEO_IPUV3) |
| 463 | setup_display(); |
| 464 | #endif |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 465 | return 0; |
| 466 | } |
| 467 | |
| 468 | int dram_init(void) |
| 469 | { |
Tim Harvey | bfa2dae | 2014-06-02 16:13:27 -0700 | [diff] [blame] | 470 | gd->ram_size = imx_ddr_size(); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 471 | return 0; |
| 472 | } |
| 473 | |
| 474 | int board_init(void) |
| 475 | { |
Fabio Estevam | ceb74c4 | 2014-07-09 17:59:54 -0300 | [diff] [blame] | 476 | struct iomuxc *const iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR; |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 477 | |
| 478 | clrsetbits_le32(&iomuxc_regs->gpr[1], |
| 479 | IOMUXC_GPR1_OTG_ID_MASK, |
| 480 | IOMUXC_GPR1_OTG_ID_GPIO1); |
| 481 | |
| 482 | /* address of linux boot parameters */ |
| 483 | gd->bd->bi_boot_params = PHYS_SDRAM + 0x100; |
| 484 | |
Tim Harvey | ba9f234 | 2019-02-04 13:10:52 -0800 | [diff] [blame] | 485 | /* read Gateworks EEPROM into global struct (used later) */ |
| 486 | setup_ventana_i2c(0); |
| 487 | board_type = read_eeprom(CONFIG_I2C_GSC, &ventana_info); |
| 488 | |
Tim Harvey | d04dc81 | 2019-02-04 13:10:49 -0800 | [diff] [blame] | 489 | setup_ventana_i2c(1); |
| 490 | setup_ventana_i2c(2); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 491 | |
Tim Harvey | 0cee224 | 2015-05-08 18:28:35 -0700 | [diff] [blame] | 492 | setup_iomux_gpio(board_type, &ventana_info); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 493 | |
| 494 | return 0; |
| 495 | } |
| 496 | |
Tim Harvey | 948202c | 2021-03-01 14:33:32 -0800 | [diff] [blame] | 497 | int board_fit_config_name_match(const char *name) |
| 498 | { |
| 499 | static char init; |
| 500 | const char *dtb; |
| 501 | char buf[32]; |
| 502 | int i = 0; |
| 503 | |
| 504 | do { |
| 505 | dtb = gsc_get_dtb_name(i++, buf, sizeof(buf)); |
| 506 | if (dtb && !strcmp(dtb, name)) { |
| 507 | if (!init++) |
| 508 | printf("DTB: %s\n", name); |
| 509 | return 0; |
| 510 | } |
| 511 | } while (dtb); |
| 512 | |
| 513 | return -1; |
| 514 | } |
| 515 | |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 516 | #if defined(CONFIG_DISPLAY_BOARDINFO_LATE) |
| 517 | /* |
| 518 | * called during late init (after relocation and after board_init()) |
| 519 | * by virtue of CONFIG_DISPLAY_BOARDINFO_LATE as we needed i2c initialized and |
| 520 | * EEPROM read. |
| 521 | */ |
| 522 | int checkboard(void) |
| 523 | { |
| 524 | struct ventana_board_info *info = &ventana_info; |
| 525 | unsigned char buf[4]; |
| 526 | const char *p; |
| 527 | int quiet; /* Quiet or minimal output mode */ |
| 528 | |
| 529 | quiet = 0; |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 530 | p = env_get("quiet"); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 531 | if (p) |
| 532 | quiet = simple_strtol(p, NULL, 10); |
| 533 | else |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 534 | env_set("quiet", "0"); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 535 | |
| 536 | puts("\nGateworks Corporation Copyright 2014\n"); |
| 537 | if (info->model[0]) { |
| 538 | printf("Model: %s\n", info->model); |
| 539 | printf("MFGDate: %02x-%02x-%02x%02x\n", |
| 540 | info->mfgdate[0], info->mfgdate[1], |
| 541 | info->mfgdate[2], info->mfgdate[3]); |
| 542 | printf("Serial:%d\n", info->serial); |
| 543 | } else { |
| 544 | puts("Invalid EEPROM - board will not function fully\n"); |
| 545 | } |
| 546 | if (quiet) |
| 547 | return 0; |
| 548 | |
| 549 | /* Display GSC firmware revision/CRC/status */ |
Tim Harvey | 92e3d84 | 2015-04-08 12:54:59 -0700 | [diff] [blame] | 550 | gsc_info(0); |
| 551 | |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 552 | /* Display RTC */ |
| 553 | if (!gsc_i2c_read(GSC_RTC_ADDR, 0x00, 1, buf, 4)) { |
| 554 | printf("RTC: %d\n", |
| 555 | buf[0] | buf[1]<<8 | buf[2]<<16 | buf[3]<<24); |
| 556 | } |
| 557 | |
| 558 | return 0; |
| 559 | } |
| 560 | #endif |
| 561 | |
| 562 | #ifdef CONFIG_CMD_BMODE |
| 563 | /* |
| 564 | * BOOT_CFG1, BOOT_CFG2, BOOT_CFG3, BOOT_CFG4 |
| 565 | * see Table 8-11 and Table 5-9 |
| 566 | * BOOT_CFG1[7] = 1 (boot from NAND) |
| 567 | * BOOT_CFG1[5] = 0 - raw NAND |
| 568 | * BOOT_CFG1[4] = 0 - default pad settings |
| 569 | * BOOT_CFG1[3:2] = 00 - devices = 1 |
| 570 | * BOOT_CFG1[1:0] = 00 - Row Address Cycles = 3 |
| 571 | * BOOT_CFG2[4:3] = 00 - Boot Search Count = 2 |
| 572 | * BOOT_CFG2[2:1] = 01 - Pages In Block = 64 |
| 573 | * BOOT_CFG2[0] = 0 - Reset time 12ms |
| 574 | */ |
| 575 | static const struct boot_mode board_boot_modes[] = { |
| 576 | /* NAND: 64pages per block, 3 row addr cycles, 2 copies of FCB/DBBT */ |
| 577 | { "nand", MAKE_CFGVAL(0x80, 0x02, 0x00, 0x00) }, |
Tim Harvey | 659441b | 2017-03-17 07:31:02 -0700 | [diff] [blame] | 578 | { "emmc2", MAKE_CFGVAL(0x60, 0x48, 0x00, 0x00) }, /* GW5600 */ |
Tim Harvey | a2d24c9 | 2019-02-04 13:10:50 -0800 | [diff] [blame] | 579 | { "emmc3", MAKE_CFGVAL(0x60, 0x50, 0x00, 0x00) }, /* GW5903/4/5 */ |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 580 | { NULL, 0 }, |
| 581 | }; |
| 582 | #endif |
| 583 | |
| 584 | /* late init */ |
| 585 | int misc_init_r(void) |
| 586 | { |
| 587 | struct ventana_board_info *info = &ventana_info; |
Tim Harvey | 71dbb2c | 2016-07-15 07:14:25 -0700 | [diff] [blame] | 588 | char buf[256]; |
| 589 | int i; |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 590 | |
| 591 | /* set env vars based on EEPROM data */ |
| 592 | if (ventana_info.model[0]) { |
| 593 | char str[16], fdt[36]; |
| 594 | char *p; |
| 595 | const char *cputype = ""; |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 596 | |
| 597 | /* |
| 598 | * FDT name will be prefixed with CPU type. Three versions |
| 599 | * will be created each increasingly generic and bootloader |
| 600 | * env scripts will try loading each from most specific to |
| 601 | * least. |
| 602 | */ |
Tim Harvey | bfa2dae | 2014-06-02 16:13:27 -0700 | [diff] [blame] | 603 | if (is_cpu_type(MXC_CPU_MX6Q) || |
| 604 | is_cpu_type(MXC_CPU_MX6D)) |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 605 | cputype = "imx6q"; |
Tim Harvey | bfa2dae | 2014-06-02 16:13:27 -0700 | [diff] [blame] | 606 | else if (is_cpu_type(MXC_CPU_MX6DL) || |
| 607 | is_cpu_type(MXC_CPU_MX6SOLO)) |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 608 | cputype = "imx6dl"; |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 609 | env_set("soctype", cputype); |
Tim Harvey | 06d8743 | 2014-08-07 22:35:41 -0700 | [diff] [blame] | 610 | if (8 << (ventana_info.nand_flash_size-1) >= 2048) |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 611 | env_set("flash_layout", "large"); |
Tim Harvey | 06d8743 | 2014-08-07 22:35:41 -0700 | [diff] [blame] | 612 | else |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 613 | env_set("flash_layout", "normal"); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 614 | memset(str, 0, sizeof(str)); |
| 615 | for (i = 0; i < (sizeof(str)-1) && info->model[i]; i++) |
| 616 | str[i] = tolower(info->model[i]); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 617 | env_set("model", str); |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 618 | if (!env_get("fdt_file")) { |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 619 | sprintf(fdt, "%s-%s.dtb", cputype, str); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 620 | env_set("fdt_file", fdt); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 621 | } |
| 622 | p = strchr(str, '-'); |
| 623 | if (p) { |
| 624 | *p++ = 0; |
| 625 | |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 626 | env_set("model_base", str); |
Tim Harvey | f6db79a | 2015-05-26 11:04:56 -0700 | [diff] [blame] | 627 | sprintf(fdt, "%s-%s.dtb", cputype, str); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 628 | env_set("fdt_file1", fdt); |
Tim Harvey | 892068c | 2016-05-24 11:03:58 -0700 | [diff] [blame] | 629 | if (board_type != GW551x && |
| 630 | board_type != GW552x && |
Tim Harvey | 659441b | 2017-03-17 07:31:02 -0700 | [diff] [blame] | 631 | board_type != GW553x && |
| 632 | board_type != GW560x) |
Tim Harvey | 5058183 | 2014-08-20 23:35:14 -0700 | [diff] [blame] | 633 | str[4] = 'x'; |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 634 | str[5] = 'x'; |
| 635 | str[6] = 0; |
Tim Harvey | f6db79a | 2015-05-26 11:04:56 -0700 | [diff] [blame] | 636 | sprintf(fdt, "%s-%s.dtb", cputype, str); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 637 | env_set("fdt_file2", fdt); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 638 | } |
| 639 | |
| 640 | /* initialize env from EEPROM */ |
| 641 | if (test_bit(EECONFIG_ETH0, info->config) && |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 642 | !env_get("ethaddr")) { |
Simon Glass | 8551d55 | 2017-08-03 12:22:11 -0600 | [diff] [blame] | 643 | eth_env_set_enetaddr("ethaddr", info->mac0); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 644 | } |
| 645 | if (test_bit(EECONFIG_ETH1, info->config) && |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 646 | !env_get("eth1addr")) { |
Simon Glass | 8551d55 | 2017-08-03 12:22:11 -0600 | [diff] [blame] | 647 | eth_env_set_enetaddr("eth1addr", info->mac1); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 648 | } |
| 649 | |
| 650 | /* board serial-number */ |
| 651 | sprintf(str, "%6d", info->serial); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 652 | env_set("serial#", str); |
Tim Harvey | 2777082 | 2015-04-08 12:54:51 -0700 | [diff] [blame] | 653 | |
| 654 | /* memory MB */ |
| 655 | sprintf(str, "%d", (int) (gd->ram_size >> 20)); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 656 | env_set("mem_mb", str); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 657 | } |
| 658 | |
Tim Harvey | 71dbb2c | 2016-07-15 07:14:25 -0700 | [diff] [blame] | 659 | /* Set a non-initialized hwconfig based on board configuration */ |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 660 | if (!strcmp(env_get("hwconfig"), "_UNKNOWN_")) { |
Tim Harvey | fd6f239 | 2017-03-13 08:51:06 -0700 | [diff] [blame] | 661 | buf[0] = 0; |
Tim Harvey | 71dbb2c | 2016-07-15 07:14:25 -0700 | [diff] [blame] | 662 | if (gpio_cfg[board_type].rs232_en) |
| 663 | strcat(buf, "rs232;"); |
| 664 | for (i = 0; i < gpio_cfg[board_type].dio_num; i++) { |
| 665 | char buf1[32]; |
| 666 | sprintf(buf1, "dio%d:mode=gpio;", i); |
| 667 | if (strlen(buf) + strlen(buf1) < sizeof(buf)) |
| 668 | strcat(buf, buf1); |
| 669 | } |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 670 | env_set("hwconfig", buf); |
Tim Harvey | 71dbb2c | 2016-07-15 07:14:25 -0700 | [diff] [blame] | 671 | } |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 672 | |
Tim Harvey | 0cee224 | 2015-05-08 18:28:35 -0700 | [diff] [blame] | 673 | /* setup baseboard specific GPIO based on board and env */ |
| 674 | setup_board_gpio(board_type, info); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 675 | |
| 676 | #ifdef CONFIG_CMD_BMODE |
| 677 | add_board_boot_modes(board_boot_modes); |
| 678 | #endif |
| 679 | |
Tim Harvey | 40feabb | 2015-05-08 18:28:36 -0700 | [diff] [blame] | 680 | /* disable boot watchdog */ |
| 681 | gsc_boot_wd_disable(); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 682 | |
| 683 | return 0; |
| 684 | } |
| 685 | |
Robert P. J. Day | 3c75700 | 2016-05-19 15:23:12 -0400 | [diff] [blame] | 686 | #ifdef CONFIG_OF_BOARD_SETUP |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 687 | |
Tim Harvey | cf20e55 | 2015-04-08 12:55:01 -0700 | [diff] [blame] | 688 | static int ft_sethdmiinfmt(void *blob, char *mode) |
| 689 | { |
| 690 | int off; |
| 691 | |
| 692 | if (!mode) |
| 693 | return -EINVAL; |
| 694 | |
| 695 | off = fdt_node_offset_by_compatible(blob, -1, "nxp,tda1997x"); |
| 696 | if (off < 0) |
| 697 | return off; |
| 698 | |
| 699 | if (0 == strcasecmp(mode, "yuv422bt656")) { |
| 700 | u8 cfg[] = { 0x00, 0x00, 0x00, 0x82, 0x81, 0x00, |
| 701 | 0x00, 0x00, 0x00 }; |
| 702 | mode = "422_ccir"; |
| 703 | fdt_setprop(blob, off, "vidout_fmt", mode, strlen(mode) + 1); |
| 704 | fdt_setprop_u32(blob, off, "vidout_trc", 1); |
| 705 | fdt_setprop_u32(blob, off, "vidout_blc", 1); |
| 706 | fdt_setprop(blob, off, "vidout_portcfg", cfg, sizeof(cfg)); |
| 707 | printf(" set HDMI input mode to %s\n", mode); |
| 708 | } else if (0 == strcasecmp(mode, "yuv422smp")) { |
| 709 | u8 cfg[] = { 0x00, 0x00, 0x00, 0x88, 0x87, 0x00, |
| 710 | 0x82, 0x81, 0x00 }; |
| 711 | mode = "422_smp"; |
| 712 | fdt_setprop(blob, off, "vidout_fmt", mode, strlen(mode) + 1); |
| 713 | fdt_setprop_u32(blob, off, "vidout_trc", 0); |
| 714 | fdt_setprop_u32(blob, off, "vidout_blc", 0); |
| 715 | fdt_setprop(blob, off, "vidout_portcfg", cfg, sizeof(cfg)); |
| 716 | printf(" set HDMI input mode to %s\n", mode); |
| 717 | } else { |
| 718 | return -EINVAL; |
| 719 | } |
| 720 | |
| 721 | return 0; |
| 722 | } |
| 723 | |
Tim Harvey | bfb240a | 2016-06-17 06:10:41 -0700 | [diff] [blame] | 724 | #if defined(CONFIG_CMD_PCI) |
| 725 | #define PCI_ID(x) ( \ |
| 726 | (PCI_BUS(x->devfn)<<16)| \ |
| 727 | (PCI_DEV(x->devfn)<<11)| \ |
| 728 | (PCI_FUNC(x->devfn)<<8) \ |
| 729 | ) |
Tim Harvey | bfb240a | 2016-06-17 06:10:41 -0700 | [diff] [blame] | 730 | int fdt_add_pci_node(void *blob, int par, struct pci_dev *dev) |
| 731 | { |
| 732 | uint32_t reg[5]; |
| 733 | char node[32]; |
| 734 | int np; |
| 735 | |
| 736 | sprintf(node, "pcie@%d,%d,%d", PCI_BUS(dev->devfn), |
| 737 | PCI_DEV(dev->devfn), PCI_FUNC(dev->devfn)); |
| 738 | |
| 739 | np = fdt_subnode_offset(blob, par, node); |
| 740 | if (np >= 0) |
| 741 | return np; |
| 742 | np = fdt_add_subnode(blob, par, node); |
| 743 | if (np < 0) { |
| 744 | printf(" %s failed: no space\n", __func__); |
| 745 | return np; |
| 746 | } |
| 747 | |
| 748 | memset(reg, 0, sizeof(reg)); |
| 749 | reg[0] = cpu_to_fdt32(PCI_ID(dev)); |
| 750 | fdt_setprop(blob, np, "reg", reg, sizeof(reg)); |
| 751 | |
| 752 | return np; |
| 753 | } |
| 754 | |
| 755 | /* build a path of nested PCI devs for all bridges passed through */ |
| 756 | int fdt_add_pci_path(void *blob, struct pci_dev *dev) |
| 757 | { |
| 758 | struct pci_dev *bridges[MAX_PCI_DEVS]; |
| 759 | int k, np; |
| 760 | |
| 761 | /* build list of parents */ |
Tim Harvey | 984aa0d | 2019-02-04 13:11:00 -0800 | [diff] [blame] | 762 | np = fdt_node_offset_by_compatible(blob, -1, "fsl,imx6q-pcie"); |
Tim Harvey | bfb240a | 2016-06-17 06:10:41 -0700 | [diff] [blame] | 763 | if (np < 0) |
| 764 | return np; |
| 765 | |
| 766 | k = 0; |
| 767 | while (dev) { |
| 768 | bridges[k++] = dev; |
| 769 | dev = dev->ppar; |
| 770 | }; |
| 771 | |
| 772 | /* now add them the to DT in reverse order */ |
| 773 | while (k--) { |
| 774 | np = fdt_add_pci_node(blob, np, bridges[k]); |
| 775 | if (np < 0) |
| 776 | break; |
| 777 | } |
| 778 | |
| 779 | return np; |
| 780 | } |
| 781 | |
| 782 | /* |
| 783 | * The GW16082 has a hardware errata errata such that it's |
| 784 | * INTA/B/C/D are mis-mapped to its four slots (slot12-15). Because |
| 785 | * of this normal PCI interrupt swizzling will not work so we will |
| 786 | * provide an irq-map via device-tree. |
| 787 | */ |
| 788 | int fdt_fixup_gw16082(void *blob, int np, struct pci_dev *dev) |
| 789 | { |
| 790 | int len; |
| 791 | int host; |
| 792 | uint32_t imap_new[8*4*4]; |
| 793 | const uint32_t *imap; |
| 794 | uint32_t irq[4]; |
| 795 | uint32_t reg[4]; |
| 796 | int i; |
| 797 | |
| 798 | /* build irq-map based on host controllers map */ |
Tim Harvey | 984aa0d | 2019-02-04 13:11:00 -0800 | [diff] [blame] | 799 | host = fdt_node_offset_by_compatible(blob, -1, "fsl,imx6q-pcie"); |
Tim Harvey | bfb240a | 2016-06-17 06:10:41 -0700 | [diff] [blame] | 800 | if (host < 0) { |
| 801 | printf(" %s failed: missing host\n", __func__); |
| 802 | return host; |
| 803 | } |
| 804 | |
| 805 | /* use interrupt data from root complex's node */ |
| 806 | imap = fdt_getprop(blob, host, "interrupt-map", &len); |
| 807 | if (!imap || len != 128) { |
| 808 | printf(" %s failed: invalid interrupt-map\n", |
| 809 | __func__); |
| 810 | return -FDT_ERR_NOTFOUND; |
| 811 | } |
| 812 | |
| 813 | /* obtain irq's of host controller in pin order */ |
| 814 | for (i = 0; i < 4; i++) |
| 815 | irq[(fdt32_to_cpu(imap[(i*8)+3])-1)%4] = imap[(i*8)+6]; |
| 816 | |
| 817 | /* |
| 818 | * determine number of swizzles necessary: |
| 819 | * For each bridge we pass through we need to swizzle |
| 820 | * the number of the slot we are on. |
| 821 | */ |
| 822 | struct pci_dev *d; |
| 823 | int b; |
| 824 | b = 0; |
| 825 | d = dev->ppar; |
| 826 | while(d && d->ppar) { |
| 827 | b += PCI_DEV(d->devfn); |
| 828 | d = d->ppar; |
| 829 | } |
| 830 | |
| 831 | /* create new irq mappings for slots12-15 |
| 832 | * <skt> <idsel> <slot> <skt-inta> <skt-intb> |
| 833 | * J3 AD28 12 INTD INTA |
| 834 | * J4 AD29 13 INTC INTD |
| 835 | * J5 AD30 14 INTB INTC |
| 836 | * J2 AD31 15 INTA INTB |
| 837 | */ |
| 838 | for (i = 0; i < 4; i++) { |
| 839 | /* addr matches bus:dev:func */ |
| 840 | u32 addr = dev->busno << 16 | (12+i) << 11; |
| 841 | |
| 842 | /* default cells from root complex */ |
| 843 | memcpy(&imap_new[i*32], imap, 128); |
| 844 | /* first cell is PCI device address (BDF) */ |
| 845 | imap_new[(i*32)+(0*8)+0] = cpu_to_fdt32(addr); |
| 846 | imap_new[(i*32)+(1*8)+0] = cpu_to_fdt32(addr); |
| 847 | imap_new[(i*32)+(2*8)+0] = cpu_to_fdt32(addr); |
| 848 | imap_new[(i*32)+(3*8)+0] = cpu_to_fdt32(addr); |
| 849 | /* third cell is pin */ |
| 850 | imap_new[(i*32)+(0*8)+3] = cpu_to_fdt32(1); |
| 851 | imap_new[(i*32)+(1*8)+3] = cpu_to_fdt32(2); |
| 852 | imap_new[(i*32)+(2*8)+3] = cpu_to_fdt32(3); |
| 853 | imap_new[(i*32)+(3*8)+3] = cpu_to_fdt32(4); |
| 854 | /* sixth cell is relative interrupt */ |
| 855 | imap_new[(i*32)+(0*8)+6] = irq[(15-(12+i)+b+0)%4]; |
| 856 | imap_new[(i*32)+(1*8)+6] = irq[(15-(12+i)+b+1)%4]; |
| 857 | imap_new[(i*32)+(2*8)+6] = irq[(15-(12+i)+b+2)%4]; |
| 858 | imap_new[(i*32)+(3*8)+6] = irq[(15-(12+i)+b+3)%4]; |
| 859 | } |
| 860 | fdt_setprop(blob, np, "interrupt-map", imap_new, |
| 861 | sizeof(imap_new)); |
| 862 | reg[0] = cpu_to_fdt32(0xfff00); |
| 863 | reg[1] = 0; |
| 864 | reg[2] = 0; |
| 865 | reg[3] = cpu_to_fdt32(0x7); |
| 866 | fdt_setprop(blob, np, "interrupt-map-mask", reg, sizeof(reg)); |
| 867 | fdt_setprop_cell(blob, np, "#interrupt-cells", 1); |
| 868 | fdt_setprop_string(blob, np, "device_type", "pci"); |
| 869 | fdt_setprop_cell(blob, np, "#address-cells", 3); |
| 870 | fdt_setprop_cell(blob, np, "#size-cells", 2); |
| 871 | printf(" Added custom interrupt-map for GW16082\n"); |
| 872 | |
| 873 | return 0; |
| 874 | } |
| 875 | |
Tim Harvey | 77b82a1 | 2016-06-17 06:10:42 -0700 | [diff] [blame] | 876 | /* The sky2 GigE MAC obtains it's MAC addr from device-tree by default */ |
| 877 | int fdt_fixup_sky2(void *blob, int np, struct pci_dev *dev) |
| 878 | { |
| 879 | char *tmp, *end; |
| 880 | char mac[16]; |
| 881 | unsigned char mac_addr[6]; |
| 882 | int j; |
| 883 | |
| 884 | sprintf(mac, "eth1addr"); |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 885 | tmp = env_get(mac); |
Tim Harvey | 77b82a1 | 2016-06-17 06:10:42 -0700 | [diff] [blame] | 886 | if (tmp) { |
| 887 | for (j = 0; j < 6; j++) { |
| 888 | mac_addr[j] = tmp ? |
| 889 | simple_strtoul(tmp, &end,16) : 0; |
| 890 | if (tmp) |
| 891 | tmp = (*end) ? end+1 : end; |
| 892 | } |
| 893 | fdt_setprop(blob, np, "local-mac-address", mac_addr, |
| 894 | sizeof(mac_addr)); |
| 895 | printf(" Added mac addr for eth1\n"); |
| 896 | return 0; |
| 897 | } |
| 898 | |
| 899 | return -1; |
| 900 | } |
| 901 | |
Tim Harvey | bfb240a | 2016-06-17 06:10:41 -0700 | [diff] [blame] | 902 | /* |
| 903 | * PCI DT nodes must be nested therefore if we need to apply a DT fixup |
| 904 | * we will walk the PCI bus and add bridge nodes up to the device receiving |
| 905 | * the fixup. |
| 906 | */ |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 907 | void ft_board_pci_fixup(void *blob, struct bd_info *bd) |
Tim Harvey | bfb240a | 2016-06-17 06:10:41 -0700 | [diff] [blame] | 908 | { |
| 909 | int i, np; |
| 910 | struct pci_dev *dev; |
| 911 | |
| 912 | for (i = 0; i < pci_devno; i++) { |
| 913 | dev = &pci_devs[i]; |
| 914 | |
| 915 | /* |
| 916 | * The GW16082 consists of a TI XIO2001 PCIe-to-PCI bridge and |
| 917 | * an EEPROM at i2c1-0x50. |
| 918 | */ |
| 919 | if ((dev->vendor == PCI_VENDOR_ID_TI) && |
| 920 | (dev->device == 0x8240) && |
| 921 | (i2c_set_bus_num(1) == 0) && |
| 922 | (i2c_probe(0x50) == 0)) |
| 923 | { |
| 924 | np = fdt_add_pci_path(blob, dev); |
| 925 | if (np > 0) |
| 926 | fdt_fixup_gw16082(blob, np, dev); |
| 927 | } |
Tim Harvey | 77b82a1 | 2016-06-17 06:10:42 -0700 | [diff] [blame] | 928 | |
| 929 | /* ethernet1 mac address */ |
| 930 | else if ((dev->vendor == PCI_VENDOR_ID_MARVELL) && |
| 931 | (dev->device == 0x4380)) |
| 932 | { |
| 933 | np = fdt_add_pci_path(blob, dev); |
| 934 | if (np > 0) |
| 935 | fdt_fixup_sky2(blob, np, dev); |
| 936 | } |
Tim Harvey | bfb240a | 2016-06-17 06:10:41 -0700 | [diff] [blame] | 937 | } |
| 938 | } |
| 939 | #endif /* if defined(CONFIG_CMD_PCI) */ |
Tim Harvey | 147b576 | 2016-05-24 11:03:59 -0700 | [diff] [blame] | 940 | |
Tim Harvey | 984aa0d | 2019-02-04 13:11:00 -0800 | [diff] [blame] | 941 | void ft_board_wdog_fixup(void *blob, phys_addr_t addr) |
Tim Harvey | fcabb0b | 2017-05-15 10:05:07 -0700 | [diff] [blame] | 942 | { |
Tim Harvey | 984aa0d | 2019-02-04 13:11:00 -0800 | [diff] [blame] | 943 | int off = fdt_node_offset_by_compat_reg(blob, "fsl,imx6q-wdt", addr); |
| 944 | |
| 945 | if (off) { |
| 946 | fdt_delprop(blob, off, "ext-reset-output"); |
| 947 | fdt_delprop(blob, off, "fsl,ext-reset-output"); |
| 948 | } |
Tim Harvey | fcabb0b | 2017-05-15 10:05:07 -0700 | [diff] [blame] | 949 | } |
| 950 | |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 951 | /* |
| 952 | * called prior to booting kernel or by 'fdt boardsetup' command |
| 953 | * |
| 954 | * unless 'fdt_noauto' env var is set we will update the following in the DTB: |
| 955 | * - mtd partitions based on mtdparts/mtdids env |
| 956 | * - system-serial (board serial num from EEPROM) |
| 957 | * - board (full model from EEPROM) |
| 958 | * - peripherals removed from DTB if not loaded on board (per EEPROM config) |
| 959 | */ |
Tim Harvey | 984aa0d | 2019-02-04 13:11:00 -0800 | [diff] [blame] | 960 | #define WDOG1_ADDR 0x20bc000 |
| 961 | #define WDOG2_ADDR 0x20c0000 |
| 962 | #define GPIO3_ADDR 0x20a4000 |
| 963 | #define USDHC3_ADDR 0x2198000 |
| 964 | #define PWM0_ADDR 0x2080000 |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 965 | int ft_board_setup(void *blob, struct bd_info *bd) |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 966 | { |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 967 | struct ventana_board_info *info = &ventana_info; |
Tim Harvey | 0da2c52 | 2014-08-07 22:35:45 -0700 | [diff] [blame] | 968 | struct ventana_eeprom_config *cfg; |
Masahiro Yamada | 20ead6f | 2018-07-19 16:28:23 +0900 | [diff] [blame] | 969 | static const struct node_info nodes[] = { |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 970 | { "sst,w25q256", MTD_DEV_TYPE_NOR, }, /* SPI flash */ |
| 971 | { "fsl,imx6q-gpmi-nand", MTD_DEV_TYPE_NAND, }, /* NAND flash */ |
| 972 | }; |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 973 | const char *model = env_get("model"); |
| 974 | const char *display = env_get("display"); |
Tim Harvey | 16e0eae | 2015-04-08 12:54:44 -0700 | [diff] [blame] | 975 | int i; |
| 976 | char rev = 0; |
| 977 | |
| 978 | /* determine board revision */ |
| 979 | for (i = sizeof(ventana_info.model) - 1; i > 0; i--) { |
| 980 | if (ventana_info.model[i] >= 'A') { |
| 981 | rev = ventana_info.model[i]; |
| 982 | break; |
| 983 | } |
| 984 | } |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 985 | |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 986 | if (env_get("fdt_noauto")) { |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 987 | puts(" Skiping ft_board_setup (fdt_noauto defined)\n"); |
Simon Glass | 2aec3cc | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 988 | return 0; |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 989 | } |
| 990 | |
Tim Harvey | c9e43e0 | 2015-05-26 11:04:58 -0700 | [diff] [blame] | 991 | if (test_bit(EECONFIG_NAND, info->config)) { |
| 992 | /* Update partition nodes using info from mtdparts env var */ |
| 993 | puts(" Updating MTD partitions...\n"); |
| 994 | fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes)); |
| 995 | } |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 996 | |
Tim Harvey | e4af5d3 | 2015-04-08 12:54:58 -0700 | [diff] [blame] | 997 | /* Update display timings from display env var */ |
| 998 | if (display) { |
| 999 | if (fdt_fixup_display(blob, fdt_get_alias(blob, "lvds0"), |
| 1000 | display) >= 0) |
| 1001 | printf(" Set display timings for %s...\n", display); |
| 1002 | } |
| 1003 | |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 1004 | printf(" Adjusting FDT per EEPROM for %s...\n", model); |
| 1005 | |
| 1006 | /* board serial number */ |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 1007 | fdt_setprop(blob, 0, "system-serial", env_get("serial#"), |
| 1008 | strlen(env_get("serial#")) + 1); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 1009 | |
| 1010 | /* board (model contains model from device-tree) */ |
| 1011 | fdt_setprop(blob, 0, "board", info->model, |
| 1012 | strlen((const char *)info->model) + 1); |
| 1013 | |
Tim Harvey | cf20e55 | 2015-04-08 12:55:01 -0700 | [diff] [blame] | 1014 | /* set desired digital video capture format */ |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 1015 | ft_sethdmiinfmt(blob, env_get("hdmiinfmt")); |
Tim Harvey | cf20e55 | 2015-04-08 12:55:01 -0700 | [diff] [blame] | 1016 | |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 1017 | /* |
Tim Harvey | a1d3222 | 2016-07-15 07:16:28 -0700 | [diff] [blame] | 1018 | * Board model specific fixups |
Tim Harvey | 865dc9c | 2015-04-08 12:54:56 -0700 | [diff] [blame] | 1019 | */ |
Tim Harvey | a1d3222 | 2016-07-15 07:16:28 -0700 | [diff] [blame] | 1020 | switch (board_type) { |
| 1021 | case GW51xx: |
| 1022 | /* |
| 1023 | * disable wdog node for GW51xx-A/B to work around |
| 1024 | * errata causing wdog timer to be unreliable. |
| 1025 | */ |
| 1026 | if (rev >= 'A' && rev < 'C') { |
Tim Harvey | 984aa0d | 2019-02-04 13:11:00 -0800 | [diff] [blame] | 1027 | i = fdt_node_offset_by_compat_reg(blob, "fsl,imx6q-wdt", |
| 1028 | WDOG1_ADDR); |
Tim Harvey | a1d3222 | 2016-07-15 07:16:28 -0700 | [diff] [blame] | 1029 | if (i) |
| 1030 | fdt_status_disabled(blob, i); |
| 1031 | } |
Tim Harvey | 8d76d0d | 2016-07-15 07:16:29 -0700 | [diff] [blame] | 1032 | |
| 1033 | /* GW51xx-E adds WDOG1_B external reset */ |
| 1034 | if (rev < 'E') |
Tim Harvey | 984aa0d | 2019-02-04 13:11:00 -0800 | [diff] [blame] | 1035 | ft_board_wdog_fixup(blob, WDOG1_ADDR); |
Tim Harvey | a1d3222 | 2016-07-15 07:16:28 -0700 | [diff] [blame] | 1036 | break; |
Pushpal Sidhu | d110056 | 2015-04-08 12:55:00 -0700 | [diff] [blame] | 1037 | |
Tim Harvey | a1d3222 | 2016-07-15 07:16:28 -0700 | [diff] [blame] | 1038 | case GW52xx: |
| 1039 | /* GW522x Uses GPIO3_IO23 instead of GPIO1_IO29 */ |
| 1040 | if (info->model[4] == '2') { |
| 1041 | u32 handle = 0; |
| 1042 | u32 *range = NULL; |
Pushpal Sidhu | d110056 | 2015-04-08 12:55:00 -0700 | [diff] [blame] | 1043 | |
Tim Harvey | a1d3222 | 2016-07-15 07:16:28 -0700 | [diff] [blame] | 1044 | i = fdt_node_offset_by_compatible(blob, -1, |
| 1045 | "fsl,imx6q-pcie"); |
Pushpal Sidhu | d110056 | 2015-04-08 12:55:00 -0700 | [diff] [blame] | 1046 | if (i) |
Tim Harvey | a1d3222 | 2016-07-15 07:16:28 -0700 | [diff] [blame] | 1047 | range = (u32 *)fdt_getprop(blob, i, |
| 1048 | "reset-gpio", NULL); |
| 1049 | |
| 1050 | if (range) { |
Tim Harvey | 984aa0d | 2019-02-04 13:11:00 -0800 | [diff] [blame] | 1051 | i = fdt_node_offset_by_compat_reg(blob, |
| 1052 | "fsl,imx6q-gpio", GPIO3_ADDR); |
Tim Harvey | a1d3222 | 2016-07-15 07:16:28 -0700 | [diff] [blame] | 1053 | if (i) |
| 1054 | handle = fdt_get_phandle(blob, i); |
| 1055 | if (handle) { |
| 1056 | range[0] = cpu_to_fdt32(handle); |
| 1057 | range[1] = cpu_to_fdt32(23); |
| 1058 | } |
Pushpal Sidhu | d110056 | 2015-04-08 12:55:00 -0700 | [diff] [blame] | 1059 | } |
Tim Harvey | a1d3222 | 2016-07-15 07:16:28 -0700 | [diff] [blame] | 1060 | |
| 1061 | /* these have broken usd_vsel */ |
| 1062 | if (strstr((const char *)info->model, "SP318-B") || |
| 1063 | strstr((const char *)info->model, "SP331-B")) |
| 1064 | gpio_cfg[board_type].usd_vsel = 0; |
Tim Harvey | 8d76d0d | 2016-07-15 07:16:29 -0700 | [diff] [blame] | 1065 | |
Tim Harvey | 8d76d0d | 2016-07-15 07:16:29 -0700 | [diff] [blame] | 1066 | /* GW522x-B adds WDOG1_B external reset */ |
Tim Harvey | 984aa0d | 2019-02-04 13:11:00 -0800 | [diff] [blame] | 1067 | if (rev < 'B') |
| 1068 | ft_board_wdog_fixup(blob, WDOG1_ADDR); |
Pushpal Sidhu | d110056 | 2015-04-08 12:55:00 -0700 | [diff] [blame] | 1069 | } |
Tim Harvey | dc5996a | 2017-05-15 10:05:06 -0700 | [diff] [blame] | 1070 | |
| 1071 | /* GW520x-E adds WDOG1_B external reset */ |
| 1072 | else if (info->model[4] == '0' && rev < 'E') |
Tim Harvey | 984aa0d | 2019-02-04 13:11:00 -0800 | [diff] [blame] | 1073 | ft_board_wdog_fixup(blob, WDOG1_ADDR); |
Tim Harvey | a1d3222 | 2016-07-15 07:16:28 -0700 | [diff] [blame] | 1074 | break; |
Tim Harvey | 147b576 | 2016-05-24 11:03:59 -0700 | [diff] [blame] | 1075 | |
Tim Harvey | a1d3222 | 2016-07-15 07:16:28 -0700 | [diff] [blame] | 1076 | case GW53xx: |
Tim Harvey | 8d76d0d | 2016-07-15 07:16:29 -0700 | [diff] [blame] | 1077 | /* GW53xx-E adds WDOG1_B external reset */ |
| 1078 | if (rev < 'E') |
Tim Harvey | 984aa0d | 2019-02-04 13:11:00 -0800 | [diff] [blame] | 1079 | ft_board_wdog_fixup(blob, WDOG1_ADDR); |
Tim Harvey | a1d3222 | 2016-07-15 07:16:28 -0700 | [diff] [blame] | 1080 | break; |
Pushpal Sidhu | d110056 | 2015-04-08 12:55:00 -0700 | [diff] [blame] | 1081 | |
Tim Harvey | a1d3222 | 2016-07-15 07:16:28 -0700 | [diff] [blame] | 1082 | case GW54xx: |
| 1083 | /* |
| 1084 | * disable serial2 node for GW54xx for compatibility with older |
| 1085 | * 3.10.x kernel that improperly had this node enabled in the DT |
| 1086 | */ |
Tim Harvey | 984aa0d | 2019-02-04 13:11:00 -0800 | [diff] [blame] | 1087 | fdt_set_status_by_alias(blob, "serial2", FDT_STATUS_DISABLED, |
| 1088 | 0); |
Tim Harvey | 8d76d0d | 2016-07-15 07:16:29 -0700 | [diff] [blame] | 1089 | |
| 1090 | /* GW54xx-E adds WDOG2_B external reset */ |
| 1091 | if (rev < 'E') |
Tim Harvey | 984aa0d | 2019-02-04 13:11:00 -0800 | [diff] [blame] | 1092 | ft_board_wdog_fixup(blob, WDOG2_ADDR); |
Tim Harvey | a1d3222 | 2016-07-15 07:16:28 -0700 | [diff] [blame] | 1093 | break; |
| 1094 | |
| 1095 | case GW551x: |
| 1096 | /* |
| 1097 | * isolate CSI0_DATA_EN for GW551x-A to work around errata |
| 1098 | * causing non functional digital video in (it is not hooked up) |
| 1099 | */ |
| 1100 | if (rev == 'A') { |
| 1101 | u32 *range = NULL; |
| 1102 | int len; |
| 1103 | const u32 *handle = NULL; |
| 1104 | |
| 1105 | i = fdt_node_offset_by_compatible(blob, -1, |
| 1106 | "fsl,imx-tda1997x-video"); |
| 1107 | if (i) |
| 1108 | handle = fdt_getprop(blob, i, "pinctrl-0", |
| 1109 | NULL); |
| 1110 | if (handle) |
| 1111 | i = fdt_node_offset_by_phandle(blob, |
| 1112 | fdt32_to_cpu(*handle)); |
| 1113 | if (i) |
| 1114 | range = (u32 *)fdt_getprop(blob, i, "fsl,pins", |
| 1115 | &len); |
| 1116 | if (range) { |
| 1117 | len /= sizeof(u32); |
| 1118 | for (i = 0; i < len; i += 6) { |
| 1119 | u32 mux_reg = fdt32_to_cpu(range[i+0]); |
| 1120 | u32 conf_reg = fdt32_to_cpu(range[i+1]); |
| 1121 | /* mux PAD_CSI0_DATA_EN to GPIO */ |
| 1122 | if (is_cpu_type(MXC_CPU_MX6Q) && |
| 1123 | mux_reg == 0x260 && |
| 1124 | conf_reg == 0x630) |
| 1125 | range[i+3] = cpu_to_fdt32(0x5); |
| 1126 | else if (!is_cpu_type(MXC_CPU_MX6Q) && |
| 1127 | mux_reg == 0x08c && |
| 1128 | conf_reg == 0x3a0) |
| 1129 | range[i+3] = cpu_to_fdt32(0x5); |
| 1130 | } |
| 1131 | fdt_setprop_inplace(blob, i, "fsl,pins", range, |
| 1132 | len); |
Tim Harvey | 6944ccf | 2015-04-08 12:54:53 -0700 | [diff] [blame] | 1133 | } |
Tim Harvey | dc8b5e6 | 2015-04-08 12:55:02 -0700 | [diff] [blame] | 1134 | |
Tim Harvey | a1d3222 | 2016-07-15 07:16:28 -0700 | [diff] [blame] | 1135 | /* set BT656 video format */ |
| 1136 | ft_sethdmiinfmt(blob, "yuv422bt656"); |
| 1137 | } |
Tim Harvey | 8d76d0d | 2016-07-15 07:16:29 -0700 | [diff] [blame] | 1138 | |
| 1139 | /* GW551x-C adds WDOG1_B external reset */ |
| 1140 | if (rev < 'C') |
Tim Harvey | 984aa0d | 2019-02-04 13:11:00 -0800 | [diff] [blame] | 1141 | ft_board_wdog_fixup(blob, WDOG1_ADDR); |
Tim Harvey | a1d3222 | 2016-07-15 07:16:28 -0700 | [diff] [blame] | 1142 | break; |
Tim Harvey | 5852a33 | 2019-02-04 13:10:58 -0800 | [diff] [blame] | 1143 | case GW5901: |
| 1144 | case GW5902: |
| 1145 | /* GW5901/GW5901 revB adds WDOG1_B as an external reset */ |
| 1146 | if (rev < 'B') |
Tim Harvey | 984aa0d | 2019-02-04 13:11:00 -0800 | [diff] [blame] | 1147 | ft_board_wdog_fixup(blob, WDOG1_ADDR); |
Tim Harvey | 5852a33 | 2019-02-04 13:10:58 -0800 | [diff] [blame] | 1148 | break; |
Tim Harvey | 6944ccf | 2015-04-08 12:54:53 -0700 | [diff] [blame] | 1149 | } |
| 1150 | |
Tim Harvey | 8d2d8df | 2016-05-24 11:03:55 -0700 | [diff] [blame] | 1151 | /* Configure DIO */ |
Tim Harvey | 41595b5 | 2016-07-15 07:14:23 -0700 | [diff] [blame] | 1152 | for (i = 0; i < gpio_cfg[board_type].dio_num; i++) { |
Tim Harvey | 8d2d8df | 2016-05-24 11:03:55 -0700 | [diff] [blame] | 1153 | struct dio_cfg *cfg = &gpio_cfg[board_type].dio_cfg[i]; |
| 1154 | char arg[10]; |
| 1155 | |
| 1156 | sprintf(arg, "dio%d", i); |
| 1157 | if (!hwconfig(arg)) |
| 1158 | continue; |
| 1159 | if (hwconfig_subarg_cmp(arg, "mode", "pwm") && cfg->pwm_param) |
| 1160 | { |
Tim Harvey | 984aa0d | 2019-02-04 13:11:00 -0800 | [diff] [blame] | 1161 | phys_addr_t addr; |
| 1162 | int off; |
| 1163 | |
Tim Harvey | 8d2d8df | 2016-05-24 11:03:55 -0700 | [diff] [blame] | 1164 | printf(" Enabling pwm%d for DIO%d\n", |
| 1165 | cfg->pwm_param, i); |
Tim Harvey | 984aa0d | 2019-02-04 13:11:00 -0800 | [diff] [blame] | 1166 | addr = PWM0_ADDR + (0x4000 * (cfg->pwm_param - 1)); |
| 1167 | off = fdt_node_offset_by_compat_reg(blob, |
| 1168 | "fsl,imx6q-pwm", |
| 1169 | addr); |
| 1170 | if (off) |
| 1171 | fdt_status_okay(blob, off); |
Tim Harvey | 8d2d8df | 2016-05-24 11:03:55 -0700 | [diff] [blame] | 1172 | } |
| 1173 | } |
| 1174 | |
Tim Harvey | 147b576 | 2016-05-24 11:03:59 -0700 | [diff] [blame] | 1175 | /* remove no-1-8-v if UHS-I support is present */ |
| 1176 | if (gpio_cfg[board_type].usd_vsel) { |
| 1177 | debug("Enabling UHS-I support\n"); |
Tim Harvey | 984aa0d | 2019-02-04 13:11:00 -0800 | [diff] [blame] | 1178 | i = fdt_node_offset_by_compat_reg(blob, "fsl,imx6q-usdhc", |
| 1179 | USDHC3_ADDR); |
| 1180 | if (i) |
| 1181 | fdt_delprop(blob, i, "no-1-8-v"); |
Tim Harvey | 147b576 | 2016-05-24 11:03:59 -0700 | [diff] [blame] | 1182 | } |
| 1183 | |
Tim Harvey | bfb240a | 2016-06-17 06:10:41 -0700 | [diff] [blame] | 1184 | #if defined(CONFIG_CMD_PCI) |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 1185 | if (!env_get("nopcifixup")) |
Tim Harvey | bfb240a | 2016-06-17 06:10:41 -0700 | [diff] [blame] | 1186 | ft_board_pci_fixup(blob, bd); |
| 1187 | #endif |
| 1188 | |
Tim Harvey | 6944ccf | 2015-04-08 12:54:53 -0700 | [diff] [blame] | 1189 | /* |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 1190 | * Peripheral Config: |
| 1191 | * remove nodes by alias path if EEPROM config tells us the |
| 1192 | * peripheral is not loaded on the board. |
| 1193 | */ |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 1194 | if (env_get("fdt_noconfig")) { |
Tim Harvey | 0da2c52 | 2014-08-07 22:35:45 -0700 | [diff] [blame] | 1195 | puts(" Skiping periperhal config (fdt_noconfig defined)\n"); |
Simon Glass | 2aec3cc | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 1196 | return 0; |
Tim Harvey | 0da2c52 | 2014-08-07 22:35:45 -0700 | [diff] [blame] | 1197 | } |
| 1198 | cfg = econfig; |
| 1199 | while (cfg->name) { |
| 1200 | if (!test_bit(cfg->bit, info->config)) { |
| 1201 | fdt_del_node_and_alias(blob, cfg->dtalias ? |
| 1202 | cfg->dtalias : cfg->name); |
| 1203 | } |
| 1204 | cfg++; |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 1205 | } |
Simon Glass | 2aec3cc | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 1206 | |
| 1207 | return 0; |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 1208 | } |
Robert P. J. Day | 3c75700 | 2016-05-19 15:23:12 -0400 | [diff] [blame] | 1209 | #endif /* CONFIG_OF_BOARD_SETUP */ |