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