Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 Gateworks Corporation |
| 3 | * |
| 4 | * Author: Tim Harvey <tharvey@gateworks.com> |
| 5 | * |
| 6 | * SPDX-License-Identifier: GPL-2.0+ |
| 7 | */ |
| 8 | |
| 9 | #include <common.h> |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 10 | #include <asm/arch/clock.h> |
Tim Harvey | 0cee224 | 2015-05-08 18:28:35 -0700 | [diff] [blame] | 11 | #include <asm/arch/crm_regs.h> |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 12 | #include <asm/arch/iomux.h> |
| 13 | #include <asm/arch/mx6-pins.h> |
Tim Harvey | fb64cc7 | 2014-04-25 15:39:07 -0700 | [diff] [blame] | 14 | #include <asm/arch/mxc_hdmi.h> |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 15 | #include <asm/arch/sys_proto.h> |
| 16 | #include <asm/gpio.h> |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 17 | #include <asm/imx-common/boot_mode.h> |
| 18 | #include <asm/imx-common/sata.h> |
Eric Nelson | 16acd1c | 2014-09-30 15:40:03 -0700 | [diff] [blame] | 19 | #include <asm/imx-common/spi.h> |
Tim Harvey | fb64cc7 | 2014-04-25 15:39:07 -0700 | [diff] [blame] | 20 | #include <asm/imx-common/video.h> |
Tim Harvey | 0cee224 | 2015-05-08 18:28:35 -0700 | [diff] [blame] | 21 | #include <asm/io.h> |
| 22 | #include <dm.h> |
Tim Harvey | 67ed792 | 2015-05-08 18:28:29 -0700 | [diff] [blame] | 23 | #include <dm/platform_data/serial_mxc.h> |
Tim Harvey | 8d2d8df | 2016-05-24 11:03:55 -0700 | [diff] [blame^] | 24 | #include <hwconfig.h> |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 25 | #include <i2c.h> |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 26 | #include <fdt_support.h> |
| 27 | #include <fsl_esdhc.h> |
Tim Harvey | 0cee224 | 2015-05-08 18:28:35 -0700 | [diff] [blame] | 28 | #include <jffs2/load_kernel.h> |
| 29 | #include <linux/ctype.h> |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 30 | #include <miiphy.h> |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 31 | #include <mtd_node.h> |
| 32 | #include <netdev.h> |
Tim Harvey | 33791d5 | 2014-08-07 22:49:57 -0700 | [diff] [blame] | 33 | #include <pci.h> |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 34 | #include <power/pmic.h> |
Tim Harvey | 0dff16f | 2014-05-05 08:22:25 -0700 | [diff] [blame] | 35 | #include <power/ltc3676_pmic.h> |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 36 | #include <power/pfuze100_pmic.h> |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 37 | #include <fdt_support.h> |
| 38 | #include <jffs2/load_kernel.h> |
| 39 | #include <spi_flash.h> |
| 40 | |
| 41 | #include "gsc.h" |
Tim Harvey | 0cee224 | 2015-05-08 18:28:35 -0700 | [diff] [blame] | 42 | #include "common.h" |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 43 | |
| 44 | DECLARE_GLOBAL_DATA_PTR; |
| 45 | |
Tim Harvey | 2699336 | 2014-08-07 22:35:49 -0700 | [diff] [blame] | 46 | |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 47 | /* |
| 48 | * EEPROM board info struct populated by read_eeprom so that we only have to |
| 49 | * read it once. |
| 50 | */ |
Tim Harvey | 0da2c52 | 2014-08-07 22:35:45 -0700 | [diff] [blame] | 51 | struct ventana_board_info ventana_info; |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 52 | |
Tim Harvey | 8b92bdf | 2015-04-08 12:54:43 -0700 | [diff] [blame] | 53 | static int board_type; |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 54 | |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 55 | /* MMC */ |
Tim Harvey | 8b92bdf | 2015-04-08 12:54:43 -0700 | [diff] [blame] | 56 | static iomux_v3_cfg_t const usdhc3_pads[] = { |
Tim Harvey | 02fb592 | 2014-06-02 16:13:26 -0700 | [diff] [blame] | 57 | IOMUX_PADS(PAD_SD3_CLK__SD3_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 58 | IOMUX_PADS(PAD_SD3_CMD__SD3_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 59 | IOMUX_PADS(PAD_SD3_DAT0__SD3_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 60 | IOMUX_PADS(PAD_SD3_DAT1__SD3_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 61 | IOMUX_PADS(PAD_SD3_DAT2__SD3_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 62 | IOMUX_PADS(PAD_SD3_DAT3__SD3_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 63 | /* CD */ |
Tim Harvey | 2699336 | 2014-08-07 22:35:49 -0700 | [diff] [blame] | 64 | IOMUX_PADS(PAD_SD3_DAT5__GPIO7_IO00 | MUX_PAD_CTRL(IRQ_PAD_CTRL)), |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | /* ENET */ |
Tim Harvey | 8b92bdf | 2015-04-08 12:54:43 -0700 | [diff] [blame] | 68 | static iomux_v3_cfg_t const enet_pads[] = { |
Tim Harvey | 02fb592 | 2014-06-02 16:13:26 -0700 | [diff] [blame] | 69 | IOMUX_PADS(PAD_ENET_MDIO__ENET_MDIO | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 70 | IOMUX_PADS(PAD_ENET_MDC__ENET_MDC | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 71 | IOMUX_PADS(PAD_RGMII_TXC__RGMII_TXC | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 72 | IOMUX_PADS(PAD_RGMII_TD0__RGMII_TD0 | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 73 | IOMUX_PADS(PAD_RGMII_TD1__RGMII_TD1 | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 74 | IOMUX_PADS(PAD_RGMII_TD2__RGMII_TD2 | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 75 | IOMUX_PADS(PAD_RGMII_TD3__RGMII_TD3 | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 76 | IOMUX_PADS(PAD_RGMII_TX_CTL__RGMII_TX_CTL | |
| 77 | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 78 | IOMUX_PADS(PAD_ENET_REF_CLK__ENET_TX_CLK | |
| 79 | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 80 | IOMUX_PADS(PAD_RGMII_RXC__RGMII_RXC | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 81 | IOMUX_PADS(PAD_RGMII_RD0__RGMII_RD0 | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 82 | IOMUX_PADS(PAD_RGMII_RD1__RGMII_RD1 | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 83 | IOMUX_PADS(PAD_RGMII_RD2__RGMII_RD2 | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 84 | IOMUX_PADS(PAD_RGMII_RD3__RGMII_RD3 | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 85 | IOMUX_PADS(PAD_RGMII_RX_CTL__RGMII_RX_CTL | |
| 86 | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 87 | /* PHY nRST */ |
Tim Harvey | 2699336 | 2014-08-07 22:35:49 -0700 | [diff] [blame] | 88 | IOMUX_PADS(PAD_ENET_TXD0__GPIO1_IO30 | DIO_PAD_CFG), |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 89 | }; |
| 90 | |
| 91 | /* NAND */ |
Tim Harvey | 8b92bdf | 2015-04-08 12:54:43 -0700 | [diff] [blame] | 92 | static iomux_v3_cfg_t const nfc_pads[] = { |
Tim Harvey | 02fb592 | 2014-06-02 16:13:26 -0700 | [diff] [blame] | 93 | IOMUX_PADS(PAD_NANDF_CLE__NAND_CLE | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 94 | IOMUX_PADS(PAD_NANDF_ALE__NAND_ALE | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 95 | IOMUX_PADS(PAD_NANDF_WP_B__NAND_WP_B | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 96 | IOMUX_PADS(PAD_NANDF_RB0__NAND_READY_B | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 97 | IOMUX_PADS(PAD_NANDF_CS0__NAND_CE0_B | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 98 | IOMUX_PADS(PAD_SD4_CMD__NAND_RE_B | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 99 | IOMUX_PADS(PAD_SD4_CLK__NAND_WE_B | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 100 | IOMUX_PADS(PAD_NANDF_D0__NAND_DATA00 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 101 | IOMUX_PADS(PAD_NANDF_D1__NAND_DATA01 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 102 | IOMUX_PADS(PAD_NANDF_D2__NAND_DATA02 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 103 | IOMUX_PADS(PAD_NANDF_D3__NAND_DATA03 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 104 | IOMUX_PADS(PAD_NANDF_D4__NAND_DATA04 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 105 | IOMUX_PADS(PAD_NANDF_D5__NAND_DATA05 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 106 | IOMUX_PADS(PAD_NANDF_D6__NAND_DATA06 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 107 | 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] | 108 | }; |
| 109 | |
| 110 | #ifdef CONFIG_CMD_NAND |
| 111 | static void setup_gpmi_nand(void) |
| 112 | { |
| 113 | struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR; |
| 114 | |
| 115 | /* config gpmi nand iomux */ |
Tim Harvey | 02fb592 | 2014-06-02 16:13:26 -0700 | [diff] [blame] | 116 | SETUP_IOMUX_PADS(nfc_pads); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 117 | |
| 118 | /* config gpmi and bch clock to 100 MHz */ |
| 119 | clrsetbits_le32(&mxc_ccm->cs2cdr, |
| 120 | MXC_CCM_CS2CDR_ENFC_CLK_PODF_MASK | |
| 121 | MXC_CCM_CS2CDR_ENFC_CLK_PRED_MASK | |
| 122 | MXC_CCM_CS2CDR_ENFC_CLK_SEL_MASK, |
| 123 | MXC_CCM_CS2CDR_ENFC_CLK_PODF(0) | |
| 124 | MXC_CCM_CS2CDR_ENFC_CLK_PRED(3) | |
| 125 | MXC_CCM_CS2CDR_ENFC_CLK_SEL(3)); |
| 126 | |
| 127 | /* enable gpmi and bch clock gating */ |
| 128 | setbits_le32(&mxc_ccm->CCGR4, |
| 129 | MXC_CCM_CCGR4_RAWNAND_U_BCH_INPUT_APB_MASK | |
| 130 | MXC_CCM_CCGR4_RAWNAND_U_GPMI_BCH_INPUT_BCH_MASK | |
| 131 | MXC_CCM_CCGR4_RAWNAND_U_GPMI_BCH_INPUT_GPMI_IO_MASK | |
| 132 | MXC_CCM_CCGR4_RAWNAND_U_GPMI_INPUT_APB_MASK | |
| 133 | MXC_CCM_CCGR4_PL301_MX6QPER1_BCH_OFFSET); |
| 134 | |
| 135 | /* enable apbh clock gating */ |
| 136 | setbits_le32(&mxc_ccm->CCGR0, MXC_CCM_CCGR0_APBHDMA_MASK); |
| 137 | } |
| 138 | #endif |
| 139 | |
Tim Harvey | f1f41db | 2015-05-08 18:28:28 -0700 | [diff] [blame] | 140 | static void setup_iomux_enet(int gpio) |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 141 | { |
Tim Harvey | 02fb592 | 2014-06-02 16:13:26 -0700 | [diff] [blame] | 142 | SETUP_IOMUX_PADS(enet_pads); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 143 | |
| 144 | /* toggle PHY_RST# */ |
Tim Harvey | f1f41db | 2015-05-08 18:28:28 -0700 | [diff] [blame] | 145 | gpio_request(gpio, "phy_rst#"); |
| 146 | gpio_direction_output(gpio, 0); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 147 | mdelay(2); |
Tim Harvey | f1f41db | 2015-05-08 18:28:28 -0700 | [diff] [blame] | 148 | gpio_set_value(gpio, 1); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 149 | } |
| 150 | |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 151 | #ifdef CONFIG_USB_EHCI_MX6 |
Tim Harvey | 8b92bdf | 2015-04-08 12:54:43 -0700 | [diff] [blame] | 152 | static iomux_v3_cfg_t const usb_pads[] = { |
Tim Harvey | 2699336 | 2014-08-07 22:35:49 -0700 | [diff] [blame] | 153 | IOMUX_PADS(PAD_GPIO_1__USB_OTG_ID | DIO_PAD_CFG), |
| 154 | IOMUX_PADS(PAD_KEY_COL4__USB_OTG_OC | DIO_PAD_CFG), |
Tim Harvey | 02fb592 | 2014-06-02 16:13:26 -0700 | [diff] [blame] | 155 | /* OTG PWR */ |
Tim Harvey | 2699336 | 2014-08-07 22:35:49 -0700 | [diff] [blame] | 156 | IOMUX_PADS(PAD_EIM_D22__GPIO3_IO22 | DIO_PAD_CFG), |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 157 | }; |
| 158 | |
| 159 | int board_ehci_hcd_init(int port) |
| 160 | { |
Tim Harvey | f1f41db | 2015-05-08 18:28:28 -0700 | [diff] [blame] | 161 | int gpio; |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 162 | |
Tim Harvey | 02fb592 | 2014-06-02 16:13:26 -0700 | [diff] [blame] | 163 | SETUP_IOMUX_PADS(usb_pads); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 164 | |
Tim Harvey | db7edfa | 2015-05-26 11:04:54 -0700 | [diff] [blame] | 165 | /* Reset USB HUB */ |
| 166 | switch (board_type) { |
| 167 | case GW53xx: |
| 168 | case GW552x: |
Tim Harvey | f1f41db | 2015-05-08 18:28:28 -0700 | [diff] [blame] | 169 | gpio = (IMX_GPIO_NR(1, 9)); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 170 | break; |
Tim Harvey | db7edfa | 2015-05-26 11:04:54 -0700 | [diff] [blame] | 171 | case GW54proto: |
| 172 | case GW54xx: |
Tim Harvey | f1f41db | 2015-05-08 18:28:28 -0700 | [diff] [blame] | 173 | gpio = (IMX_GPIO_NR(1, 16)); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 174 | break; |
Tim Harvey | f1f41db | 2015-05-08 18:28:28 -0700 | [diff] [blame] | 175 | default: |
| 176 | return 0; |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 177 | } |
| 178 | |
Tim Harvey | f1f41db | 2015-05-08 18:28:28 -0700 | [diff] [blame] | 179 | /* request and toggle hub rst */ |
| 180 | gpio_request(gpio, "usb_hub_rst#"); |
| 181 | gpio_direction_output(gpio, 0); |
| 182 | mdelay(2); |
| 183 | gpio_set_value(gpio, 1); |
| 184 | |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 185 | return 0; |
| 186 | } |
| 187 | |
| 188 | int board_ehci_power(int port, int on) |
| 189 | { |
| 190 | if (port) |
| 191 | return 0; |
| 192 | gpio_set_value(GP_USB_OTG_PWR, on); |
| 193 | return 0; |
| 194 | } |
| 195 | #endif /* CONFIG_USB_EHCI_MX6 */ |
| 196 | |
| 197 | #ifdef CONFIG_FSL_ESDHC |
Tim Harvey | 8b92bdf | 2015-04-08 12:54:43 -0700 | [diff] [blame] | 198 | static struct fsl_esdhc_cfg usdhc_cfg = { USDHC3_BASE_ADDR }; |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 199 | |
| 200 | int board_mmc_getcd(struct mmc *mmc) |
| 201 | { |
| 202 | /* Card Detect */ |
Tim Harvey | f1f41db | 2015-05-08 18:28:28 -0700 | [diff] [blame] | 203 | gpio_request(GP_SD3_CD, "sd_cd"); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 204 | gpio_direction_input(GP_SD3_CD); |
| 205 | return !gpio_get_value(GP_SD3_CD); |
| 206 | } |
| 207 | |
| 208 | int board_mmc_init(bd_t *bis) |
| 209 | { |
| 210 | /* Only one USDHC controller on Ventana */ |
Tim Harvey | 02fb592 | 2014-06-02 16:13:26 -0700 | [diff] [blame] | 211 | SETUP_IOMUX_PADS(usdhc3_pads); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 212 | usdhc_cfg.sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK); |
| 213 | usdhc_cfg.max_bus_width = 4; |
| 214 | |
| 215 | return fsl_esdhc_initialize(bis, &usdhc_cfg); |
| 216 | } |
| 217 | #endif /* CONFIG_FSL_ESDHC */ |
| 218 | |
| 219 | #ifdef CONFIG_MXC_SPI |
| 220 | iomux_v3_cfg_t const ecspi1_pads[] = { |
| 221 | /* SS1 */ |
Tim Harvey | 02fb592 | 2014-06-02 16:13:26 -0700 | [diff] [blame] | 222 | IOMUX_PADS(PAD_EIM_D19__GPIO3_IO19 | MUX_PAD_CTRL(SPI_PAD_CTRL)), |
| 223 | IOMUX_PADS(PAD_EIM_D17__ECSPI1_MISO | MUX_PAD_CTRL(SPI_PAD_CTRL)), |
| 224 | IOMUX_PADS(PAD_EIM_D18__ECSPI1_MOSI | MUX_PAD_CTRL(SPI_PAD_CTRL)), |
| 225 | 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] | 226 | }; |
| 227 | |
Nikita Kiryanov | 00cd738 | 2014-08-20 15:08:50 +0300 | [diff] [blame] | 228 | int board_spi_cs_gpio(unsigned bus, unsigned cs) |
| 229 | { |
| 230 | return (bus == 0 && cs == 0) ? (IMX_GPIO_NR(3, 19)) : -1; |
| 231 | } |
| 232 | |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 233 | static void setup_spi(void) |
| 234 | { |
Tim Harvey | f1f41db | 2015-05-08 18:28:28 -0700 | [diff] [blame] | 235 | gpio_request(IMX_GPIO_NR(3, 19), "spi_cs"); |
Nikita Kiryanov | 00cd738 | 2014-08-20 15:08:50 +0300 | [diff] [blame] | 236 | gpio_direction_output(IMX_GPIO_NR(3, 19), 1); |
Tim Harvey | 02fb592 | 2014-06-02 16:13:26 -0700 | [diff] [blame] | 237 | SETUP_IOMUX_PADS(ecspi1_pads); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 238 | } |
| 239 | #endif |
| 240 | |
| 241 | /* configure eth0 PHY board-specific LED behavior */ |
| 242 | int board_phy_config(struct phy_device *phydev) |
| 243 | { |
| 244 | unsigned short val; |
| 245 | |
| 246 | /* Marvel 88E1510 */ |
| 247 | if (phydev->phy_id == 0x1410dd1) { |
| 248 | /* |
| 249 | * Page 3, Register 16: LED[2:0] Function Control Register |
| 250 | * LED[0] (SPD:Amber) R16_3.3:0 to 0111: on-GbE link |
| 251 | * LED[1] (LNK:Green) R16_3.7:4 to 0001: on-link, blink-activity |
| 252 | */ |
| 253 | phy_write(phydev, MDIO_DEVAD_NONE, 22, 3); |
| 254 | val = phy_read(phydev, MDIO_DEVAD_NONE, 16); |
| 255 | val &= 0xff00; |
| 256 | val |= 0x0017; |
| 257 | phy_write(phydev, MDIO_DEVAD_NONE, 16, val); |
| 258 | phy_write(phydev, MDIO_DEVAD_NONE, 22, 0); |
| 259 | } |
| 260 | |
| 261 | if (phydev->drv->config) |
| 262 | phydev->drv->config(phydev); |
| 263 | |
| 264 | return 0; |
| 265 | } |
| 266 | |
| 267 | int board_eth_init(bd_t *bis) |
| 268 | { |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 269 | #ifdef CONFIG_FEC_MXC |
Tim Harvey | 8533182 | 2015-04-08 12:54:48 -0700 | [diff] [blame] | 270 | if (board_type != GW551x && board_type != GW552x) { |
Tim Harvey | f1f41db | 2015-05-08 18:28:28 -0700 | [diff] [blame] | 271 | setup_iomux_enet(GP_PHY_RST); |
Tim Harvey | 5058183 | 2014-08-20 23:35:14 -0700 | [diff] [blame] | 272 | cpu_eth_init(bis); |
Tim Harvey | 8533182 | 2015-04-08 12:54:48 -0700 | [diff] [blame] | 273 | } |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 274 | #endif |
| 275 | |
Tim Harvey | 472884d | 2015-04-08 12:54:32 -0700 | [diff] [blame] | 276 | #ifdef CONFIG_E1000 |
| 277 | e1000_initialize(bis); |
| 278 | #endif |
| 279 | |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 280 | #ifdef CONFIG_CI_UDC |
| 281 | /* For otg ethernet*/ |
| 282 | usb_eth_initialize(bis); |
| 283 | #endif |
| 284 | |
Tim Harvey | fc5ff94 | 2015-04-08 12:54:33 -0700 | [diff] [blame] | 285 | /* default to the first detected enet dev */ |
| 286 | if (!getenv("ethprime")) { |
| 287 | struct eth_device *dev = eth_get_dev_by_index(0); |
| 288 | if (dev) { |
| 289 | setenv("ethprime", dev->name); |
| 290 | printf("set ethprime to %s\n", getenv("ethprime")); |
| 291 | } |
| 292 | } |
| 293 | |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 294 | return 0; |
| 295 | } |
| 296 | |
Tim Harvey | fb64cc7 | 2014-04-25 15:39:07 -0700 | [diff] [blame] | 297 | #if defined(CONFIG_VIDEO_IPUV3) |
| 298 | |
| 299 | static void enable_hdmi(struct display_info_t const *dev) |
| 300 | { |
| 301 | imx_enable_hdmi_phy(); |
| 302 | } |
| 303 | |
| 304 | static int detect_i2c(struct display_info_t const *dev) |
| 305 | { |
| 306 | return i2c_set_bus_num(dev->bus) == 0 && |
| 307 | i2c_probe(dev->addr) == 0; |
| 308 | } |
| 309 | |
| 310 | static void enable_lvds(struct display_info_t const *dev) |
| 311 | { |
| 312 | struct iomuxc *iomux = (struct iomuxc *) |
| 313 | IOMUXC_BASE_ADDR; |
| 314 | |
| 315 | /* set CH0 data width to 24bit (IOMUXC_GPR2:5 0=18bit, 1=24bit) */ |
| 316 | u32 reg = readl(&iomux->gpr[2]); |
| 317 | reg |= IOMUXC_GPR2_DATA_WIDTH_CH0_24BIT; |
| 318 | writel(reg, &iomux->gpr[2]); |
| 319 | |
| 320 | /* Enable Backlight */ |
Tim Harvey | a67e07f | 2016-05-24 11:03:53 -0700 | [diff] [blame] | 321 | gpio_request(IMX_GPIO_NR(1, 10), "bklt_gpio"); |
| 322 | gpio_direction_output(IMX_GPIO_NR(1, 10), 0); |
Tim Harvey | f1f41db | 2015-05-08 18:28:28 -0700 | [diff] [blame] | 323 | gpio_request(IMX_GPIO_NR(1, 18), "bklt_en"); |
Tim Harvey | 2699336 | 2014-08-07 22:35:49 -0700 | [diff] [blame] | 324 | SETUP_IOMUX_PAD(PAD_SD1_CMD__GPIO1_IO18 | DIO_PAD_CFG); |
Tim Harvey | fb64cc7 | 2014-04-25 15:39:07 -0700 | [diff] [blame] | 325 | gpio_direction_output(IMX_GPIO_NR(1, 18), 1); |
| 326 | } |
| 327 | |
| 328 | struct display_info_t const displays[] = {{ |
| 329 | /* HDMI Output */ |
| 330 | .bus = -1, |
| 331 | .addr = 0, |
| 332 | .pixfmt = IPU_PIX_FMT_RGB24, |
| 333 | .detect = detect_hdmi, |
| 334 | .enable = enable_hdmi, |
| 335 | .mode = { |
| 336 | .name = "HDMI", |
| 337 | .refresh = 60, |
| 338 | .xres = 1024, |
| 339 | .yres = 768, |
| 340 | .pixclock = 15385, |
| 341 | .left_margin = 220, |
| 342 | .right_margin = 40, |
| 343 | .upper_margin = 21, |
| 344 | .lower_margin = 7, |
| 345 | .hsync_len = 60, |
| 346 | .vsync_len = 10, |
| 347 | .sync = FB_SYNC_EXT, |
| 348 | .vmode = FB_VMODE_NONINTERLACED |
| 349 | } }, { |
| 350 | /* Freescale MXC-LVDS1: HannStar HSD100PXN1-A00 w/ egalx_ts cont */ |
| 351 | .bus = 2, |
| 352 | .addr = 0x4, |
| 353 | .pixfmt = IPU_PIX_FMT_LVDS666, |
| 354 | .detect = detect_i2c, |
| 355 | .enable = enable_lvds, |
| 356 | .mode = { |
| 357 | .name = "Hannstar-XGA", |
| 358 | .refresh = 60, |
| 359 | .xres = 1024, |
| 360 | .yres = 768, |
| 361 | .pixclock = 15385, |
| 362 | .left_margin = 220, |
| 363 | .right_margin = 40, |
| 364 | .upper_margin = 21, |
| 365 | .lower_margin = 7, |
| 366 | .hsync_len = 60, |
| 367 | .vsync_len = 10, |
| 368 | .sync = FB_SYNC_EXT, |
| 369 | .vmode = FB_VMODE_NONINTERLACED |
Tim Harvey | a20bd63 | 2015-04-08 12:54:57 -0700 | [diff] [blame] | 370 | } }, { |
| 371 | /* DLC700JMG-T-4 */ |
| 372 | .bus = 0, |
| 373 | .addr = 0, |
| 374 | .detect = NULL, |
| 375 | .enable = enable_lvds, |
| 376 | .pixfmt = IPU_PIX_FMT_LVDS666, |
| 377 | .mode = { |
| 378 | .name = "DLC700JMGT4", |
| 379 | .refresh = 60, |
| 380 | .xres = 1024, /* 1024x600active pixels */ |
| 381 | .yres = 600, |
| 382 | .pixclock = 15385, /* 64MHz */ |
| 383 | .left_margin = 220, |
| 384 | .right_margin = 40, |
| 385 | .upper_margin = 21, |
| 386 | .lower_margin = 7, |
| 387 | .hsync_len = 60, |
| 388 | .vsync_len = 10, |
| 389 | .sync = FB_SYNC_EXT, |
| 390 | .vmode = FB_VMODE_NONINTERLACED |
| 391 | } }, { |
| 392 | /* DLC800FIG-T-3 */ |
| 393 | .bus = 0, |
| 394 | .addr = 0, |
| 395 | .detect = NULL, |
| 396 | .enable = enable_lvds, |
| 397 | .pixfmt = IPU_PIX_FMT_LVDS666, |
| 398 | .mode = { |
| 399 | .name = "DLC800FIGT3", |
| 400 | .refresh = 60, |
| 401 | .xres = 1024, /* 1024x768 active pixels */ |
| 402 | .yres = 768, |
| 403 | .pixclock = 15385, /* 64MHz */ |
| 404 | .left_margin = 220, |
| 405 | .right_margin = 40, |
| 406 | .upper_margin = 21, |
| 407 | .lower_margin = 7, |
| 408 | .hsync_len = 60, |
| 409 | .vsync_len = 10, |
| 410 | .sync = FB_SYNC_EXT, |
| 411 | .vmode = FB_VMODE_NONINTERLACED |
Tim Harvey | fb64cc7 | 2014-04-25 15:39:07 -0700 | [diff] [blame] | 412 | } } }; |
| 413 | size_t display_count = ARRAY_SIZE(displays); |
| 414 | |
| 415 | static void setup_display(void) |
| 416 | { |
| 417 | struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR; |
| 418 | struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR; |
| 419 | int reg; |
| 420 | |
| 421 | enable_ipu_clock(); |
| 422 | imx_setup_hdmi(); |
| 423 | /* Turn on LDB0,IPU,IPU DI0 clocks */ |
| 424 | reg = __raw_readl(&mxc_ccm->CCGR3); |
| 425 | reg |= MXC_CCM_CCGR3_LDB_DI0_MASK; |
| 426 | writel(reg, &mxc_ccm->CCGR3); |
| 427 | |
| 428 | /* set LDB0, LDB1 clk select to 011/011 */ |
| 429 | reg = readl(&mxc_ccm->cs2cdr); |
| 430 | reg &= ~(MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_MASK |
| 431 | |MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_MASK); |
| 432 | reg |= (3<<MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_OFFSET) |
| 433 | |(3<<MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_OFFSET); |
| 434 | writel(reg, &mxc_ccm->cs2cdr); |
| 435 | |
| 436 | reg = readl(&mxc_ccm->cscmr2); |
| 437 | reg |= MXC_CCM_CSCMR2_LDB_DI0_IPU_DIV; |
| 438 | writel(reg, &mxc_ccm->cscmr2); |
| 439 | |
| 440 | reg = readl(&mxc_ccm->chsccdr); |
| 441 | reg |= (CHSCCDR_CLK_SEL_LDB_DI0 |
| 442 | <<MXC_CCM_CHSCCDR_IPU1_DI0_CLK_SEL_OFFSET); |
| 443 | writel(reg, &mxc_ccm->chsccdr); |
| 444 | |
| 445 | reg = IOMUXC_GPR2_BGREF_RRMODE_EXTERNAL_RES |
| 446 | |IOMUXC_GPR2_DI1_VS_POLARITY_ACTIVE_HIGH |
| 447 | |IOMUXC_GPR2_DI0_VS_POLARITY_ACTIVE_LOW |
| 448 | |IOMUXC_GPR2_BIT_MAPPING_CH1_SPWG |
| 449 | |IOMUXC_GPR2_DATA_WIDTH_CH1_18BIT |
| 450 | |IOMUXC_GPR2_BIT_MAPPING_CH0_SPWG |
| 451 | |IOMUXC_GPR2_DATA_WIDTH_CH0_18BIT |
| 452 | |IOMUXC_GPR2_LVDS_CH1_MODE_DISABLED |
| 453 | |IOMUXC_GPR2_LVDS_CH0_MODE_ENABLED_DI0; |
| 454 | writel(reg, &iomux->gpr[2]); |
| 455 | |
| 456 | reg = readl(&iomux->gpr[3]); |
| 457 | reg = (reg & ~IOMUXC_GPR3_LVDS0_MUX_CTL_MASK) |
| 458 | | (IOMUXC_GPR3_MUX_SRC_IPU1_DI0 |
| 459 | <<IOMUXC_GPR3_LVDS0_MUX_CTL_OFFSET); |
| 460 | writel(reg, &iomux->gpr[3]); |
| 461 | |
Tim Harvey | a67e07f | 2016-05-24 11:03:53 -0700 | [diff] [blame] | 462 | /* LVDS Backlight GPIO on LVDS connector - output low */ |
Tim Harvey | 2699336 | 2014-08-07 22:35:49 -0700 | [diff] [blame] | 463 | SETUP_IOMUX_PAD(PAD_SD2_CLK__GPIO1_IO10 | DIO_PAD_CFG); |
Tim Harvey | fb64cc7 | 2014-04-25 15:39:07 -0700 | [diff] [blame] | 464 | gpio_direction_output(IMX_GPIO_NR(1, 10), 0); |
| 465 | } |
| 466 | #endif /* CONFIG_VIDEO_IPUV3 */ |
| 467 | |
Tim Harvey | 0dff16f | 2014-05-05 08:22:25 -0700 | [diff] [blame] | 468 | /* setup board specific PMIC */ |
| 469 | int power_init_board(void) |
| 470 | { |
Tim Harvey | 195bc97 | 2015-05-08 18:28:37 -0700 | [diff] [blame] | 471 | setup_pmic(); |
Tim Harvey | 0dff16f | 2014-05-05 08:22:25 -0700 | [diff] [blame] | 472 | return 0; |
| 473 | } |
| 474 | |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 475 | #if defined(CONFIG_CMD_PCI) |
| 476 | int imx6_pcie_toggle_reset(void) |
| 477 | { |
| 478 | if (board_type < GW_UNKNOWN) { |
Tim Harvey | 02fb592 | 2014-06-02 16:13:26 -0700 | [diff] [blame] | 479 | uint pin = gpio_cfg[board_type].pcie_rst; |
Tim Harvey | f1f41db | 2015-05-08 18:28:28 -0700 | [diff] [blame] | 480 | gpio_request(pin, "pci_rst#"); |
Tim Harvey | 02fb592 | 2014-06-02 16:13:26 -0700 | [diff] [blame] | 481 | gpio_direction_output(pin, 0); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 482 | mdelay(50); |
Tim Harvey | 02fb592 | 2014-06-02 16:13:26 -0700 | [diff] [blame] | 483 | gpio_direction_output(pin, 1); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 484 | } |
| 485 | return 0; |
| 486 | } |
Tim Harvey | 33791d5 | 2014-08-07 22:49:57 -0700 | [diff] [blame] | 487 | |
| 488 | /* |
| 489 | * Most Ventana boards have a PLX PEX860x PCIe switch onboard and use its |
| 490 | * GPIO's as PERST# signals for its downstream ports - configure the GPIO's |
| 491 | * properly and assert reset for 100ms. |
| 492 | */ |
| 493 | void board_pci_fixup_dev(struct pci_controller *hose, pci_dev_t dev, |
| 494 | unsigned short vendor, unsigned short device, |
| 495 | unsigned short class) |
| 496 | { |
| 497 | u32 dw; |
| 498 | |
| 499 | debug("%s: %02d:%02d.%02d: %04x:%04x\n", __func__, |
| 500 | PCI_BUS(dev), PCI_DEV(dev), PCI_FUNC(dev), vendor, device); |
| 501 | if (vendor == PCI_VENDOR_ID_PLX && |
| 502 | (device & 0xfff0) == 0x8600 && |
| 503 | PCI_DEV(dev) == 0 && PCI_FUNC(dev) == 0) { |
| 504 | debug("configuring PLX 860X downstream PERST#\n"); |
| 505 | pci_hose_read_config_dword(hose, dev, 0x62c, &dw); |
| 506 | dw |= 0xaaa8; /* GPIO1-7 outputs */ |
| 507 | pci_hose_write_config_dword(hose, dev, 0x62c, dw); |
| 508 | |
| 509 | pci_hose_read_config_dword(hose, dev, 0x644, &dw); |
| 510 | dw |= 0xfe; /* GPIO1-7 output high */ |
| 511 | pci_hose_write_config_dword(hose, dev, 0x644, dw); |
| 512 | |
| 513 | mdelay(100); |
| 514 | } |
| 515 | } |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 516 | #endif /* CONFIG_CMD_PCI */ |
| 517 | |
| 518 | #ifdef CONFIG_SERIAL_TAG |
| 519 | /* |
| 520 | * called when setting up ATAGS before booting kernel |
| 521 | * populate serialnum from the following (in order of priority): |
| 522 | * serial# env var |
| 523 | * eeprom |
| 524 | */ |
| 525 | void get_board_serial(struct tag_serialnr *serialnr) |
| 526 | { |
| 527 | char *serial = getenv("serial#"); |
| 528 | |
| 529 | if (serial) { |
| 530 | serialnr->high = 0; |
| 531 | serialnr->low = simple_strtoul(serial, NULL, 10); |
| 532 | } else if (ventana_info.model[0]) { |
| 533 | serialnr->high = 0; |
| 534 | serialnr->low = ventana_info.serial; |
| 535 | } else { |
| 536 | serialnr->high = 0; |
| 537 | serialnr->low = 0; |
| 538 | } |
| 539 | } |
| 540 | #endif |
| 541 | |
| 542 | /* |
| 543 | * Board Support |
| 544 | */ |
| 545 | |
| 546 | int board_early_init_f(void) |
| 547 | { |
| 548 | setup_iomux_uart(); |
Tim Harvey | f1f41db | 2015-05-08 18:28:28 -0700 | [diff] [blame] | 549 | |
Tim Harvey | fb64cc7 | 2014-04-25 15:39:07 -0700 | [diff] [blame] | 550 | #if defined(CONFIG_VIDEO_IPUV3) |
| 551 | setup_display(); |
| 552 | #endif |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 553 | return 0; |
| 554 | } |
| 555 | |
| 556 | int dram_init(void) |
| 557 | { |
Tim Harvey | bfa2dae | 2014-06-02 16:13:27 -0700 | [diff] [blame] | 558 | gd->ram_size = imx_ddr_size(); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 559 | return 0; |
| 560 | } |
| 561 | |
| 562 | int board_init(void) |
| 563 | { |
Fabio Estevam | ceb74c4 | 2014-07-09 17:59:54 -0300 | [diff] [blame] | 564 | struct iomuxc *const iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR; |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 565 | |
| 566 | clrsetbits_le32(&iomuxc_regs->gpr[1], |
| 567 | IOMUXC_GPR1_OTG_ID_MASK, |
| 568 | IOMUXC_GPR1_OTG_ID_GPIO1); |
| 569 | |
| 570 | /* address of linux boot parameters */ |
| 571 | gd->bd->bi_boot_params = PHYS_SDRAM + 0x100; |
| 572 | |
| 573 | #ifdef CONFIG_CMD_NAND |
| 574 | setup_gpmi_nand(); |
| 575 | #endif |
| 576 | #ifdef CONFIG_MXC_SPI |
| 577 | setup_spi(); |
| 578 | #endif |
Tim Harvey | 0cee224 | 2015-05-08 18:28:35 -0700 | [diff] [blame] | 579 | setup_ventana_i2c(); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 580 | |
| 581 | #ifdef CONFIG_CMD_SATA |
| 582 | setup_sata(); |
| 583 | #endif |
| 584 | /* read Gateworks EEPROM into global struct (used later) */ |
Tim Harvey | 0da2c52 | 2014-08-07 22:35:45 -0700 | [diff] [blame] | 585 | board_type = read_eeprom(CONFIG_I2C_GSC, &ventana_info); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 586 | |
Tim Harvey | 0cee224 | 2015-05-08 18:28:35 -0700 | [diff] [blame] | 587 | setup_iomux_gpio(board_type, &ventana_info); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 588 | |
| 589 | return 0; |
| 590 | } |
| 591 | |
| 592 | #if defined(CONFIG_DISPLAY_BOARDINFO_LATE) |
| 593 | /* |
| 594 | * called during late init (after relocation and after board_init()) |
| 595 | * by virtue of CONFIG_DISPLAY_BOARDINFO_LATE as we needed i2c initialized and |
| 596 | * EEPROM read. |
| 597 | */ |
| 598 | int checkboard(void) |
| 599 | { |
| 600 | struct ventana_board_info *info = &ventana_info; |
| 601 | unsigned char buf[4]; |
| 602 | const char *p; |
| 603 | int quiet; /* Quiet or minimal output mode */ |
| 604 | |
| 605 | quiet = 0; |
| 606 | p = getenv("quiet"); |
| 607 | if (p) |
| 608 | quiet = simple_strtol(p, NULL, 10); |
| 609 | else |
| 610 | setenv("quiet", "0"); |
| 611 | |
| 612 | puts("\nGateworks Corporation Copyright 2014\n"); |
| 613 | if (info->model[0]) { |
| 614 | printf("Model: %s\n", info->model); |
| 615 | printf("MFGDate: %02x-%02x-%02x%02x\n", |
| 616 | info->mfgdate[0], info->mfgdate[1], |
| 617 | info->mfgdate[2], info->mfgdate[3]); |
| 618 | printf("Serial:%d\n", info->serial); |
| 619 | } else { |
| 620 | puts("Invalid EEPROM - board will not function fully\n"); |
| 621 | } |
| 622 | if (quiet) |
| 623 | return 0; |
| 624 | |
| 625 | /* Display GSC firmware revision/CRC/status */ |
Tim Harvey | 92e3d84 | 2015-04-08 12:54:59 -0700 | [diff] [blame] | 626 | gsc_info(0); |
| 627 | |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 628 | /* Display RTC */ |
| 629 | if (!gsc_i2c_read(GSC_RTC_ADDR, 0x00, 1, buf, 4)) { |
| 630 | printf("RTC: %d\n", |
| 631 | buf[0] | buf[1]<<8 | buf[2]<<16 | buf[3]<<24); |
| 632 | } |
| 633 | |
| 634 | return 0; |
| 635 | } |
| 636 | #endif |
| 637 | |
| 638 | #ifdef CONFIG_CMD_BMODE |
| 639 | /* |
| 640 | * BOOT_CFG1, BOOT_CFG2, BOOT_CFG3, BOOT_CFG4 |
| 641 | * see Table 8-11 and Table 5-9 |
| 642 | * BOOT_CFG1[7] = 1 (boot from NAND) |
| 643 | * BOOT_CFG1[5] = 0 - raw NAND |
| 644 | * BOOT_CFG1[4] = 0 - default pad settings |
| 645 | * BOOT_CFG1[3:2] = 00 - devices = 1 |
| 646 | * BOOT_CFG1[1:0] = 00 - Row Address Cycles = 3 |
| 647 | * BOOT_CFG2[4:3] = 00 - Boot Search Count = 2 |
| 648 | * BOOT_CFG2[2:1] = 01 - Pages In Block = 64 |
| 649 | * BOOT_CFG2[0] = 0 - Reset time 12ms |
| 650 | */ |
| 651 | static const struct boot_mode board_boot_modes[] = { |
| 652 | /* NAND: 64pages per block, 3 row addr cycles, 2 copies of FCB/DBBT */ |
| 653 | { "nand", MAKE_CFGVAL(0x80, 0x02, 0x00, 0x00) }, |
| 654 | { NULL, 0 }, |
| 655 | }; |
| 656 | #endif |
| 657 | |
| 658 | /* late init */ |
| 659 | int misc_init_r(void) |
| 660 | { |
| 661 | struct ventana_board_info *info = &ventana_info; |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 662 | |
| 663 | /* set env vars based on EEPROM data */ |
| 664 | if (ventana_info.model[0]) { |
| 665 | char str[16], fdt[36]; |
| 666 | char *p; |
| 667 | const char *cputype = ""; |
| 668 | int i; |
| 669 | |
| 670 | /* |
| 671 | * FDT name will be prefixed with CPU type. Three versions |
| 672 | * will be created each increasingly generic and bootloader |
| 673 | * env scripts will try loading each from most specific to |
| 674 | * least. |
| 675 | */ |
Tim Harvey | bfa2dae | 2014-06-02 16:13:27 -0700 | [diff] [blame] | 676 | if (is_cpu_type(MXC_CPU_MX6Q) || |
| 677 | is_cpu_type(MXC_CPU_MX6D)) |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 678 | cputype = "imx6q"; |
Tim Harvey | bfa2dae | 2014-06-02 16:13:27 -0700 | [diff] [blame] | 679 | else if (is_cpu_type(MXC_CPU_MX6DL) || |
| 680 | is_cpu_type(MXC_CPU_MX6SOLO)) |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 681 | cputype = "imx6dl"; |
Tim Harvey | bf94258 | 2014-08-07 22:35:42 -0700 | [diff] [blame] | 682 | setenv("soctype", cputype); |
Tim Harvey | 06d8743 | 2014-08-07 22:35:41 -0700 | [diff] [blame] | 683 | if (8 << (ventana_info.nand_flash_size-1) >= 2048) |
| 684 | setenv("flash_layout", "large"); |
| 685 | else |
| 686 | setenv("flash_layout", "normal"); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 687 | memset(str, 0, sizeof(str)); |
| 688 | for (i = 0; i < (sizeof(str)-1) && info->model[i]; i++) |
| 689 | str[i] = tolower(info->model[i]); |
Tim Harvey | 0f9327d | 2015-05-26 11:04:55 -0700 | [diff] [blame] | 690 | setenv("model", str); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 691 | if (!getenv("fdt_file")) { |
| 692 | sprintf(fdt, "%s-%s.dtb", cputype, str); |
| 693 | setenv("fdt_file", fdt); |
| 694 | } |
| 695 | p = strchr(str, '-'); |
| 696 | if (p) { |
| 697 | *p++ = 0; |
| 698 | |
| 699 | setenv("model_base", str); |
Tim Harvey | f6db79a | 2015-05-26 11:04:56 -0700 | [diff] [blame] | 700 | sprintf(fdt, "%s-%s.dtb", cputype, str); |
| 701 | setenv("fdt_file1", fdt); |
Tim Harvey | b6de3b2 | 2015-04-08 12:54:45 -0700 | [diff] [blame] | 702 | if (board_type != GW551x && board_type != GW552x) |
Tim Harvey | 5058183 | 2014-08-20 23:35:14 -0700 | [diff] [blame] | 703 | str[4] = 'x'; |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 704 | str[5] = 'x'; |
| 705 | str[6] = 0; |
Tim Harvey | f6db79a | 2015-05-26 11:04:56 -0700 | [diff] [blame] | 706 | sprintf(fdt, "%s-%s.dtb", cputype, str); |
| 707 | setenv("fdt_file2", fdt); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 708 | } |
| 709 | |
| 710 | /* initialize env from EEPROM */ |
| 711 | if (test_bit(EECONFIG_ETH0, info->config) && |
| 712 | !getenv("ethaddr")) { |
| 713 | eth_setenv_enetaddr("ethaddr", info->mac0); |
| 714 | } |
| 715 | if (test_bit(EECONFIG_ETH1, info->config) && |
| 716 | !getenv("eth1addr")) { |
| 717 | eth_setenv_enetaddr("eth1addr", info->mac1); |
| 718 | } |
| 719 | |
| 720 | /* board serial-number */ |
| 721 | sprintf(str, "%6d", info->serial); |
| 722 | setenv("serial#", str); |
Tim Harvey | 2777082 | 2015-04-08 12:54:51 -0700 | [diff] [blame] | 723 | |
| 724 | /* memory MB */ |
| 725 | sprintf(str, "%d", (int) (gd->ram_size >> 20)); |
| 726 | setenv("mem_mb", str); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 727 | } |
| 728 | |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 729 | |
Tim Harvey | 0cee224 | 2015-05-08 18:28:35 -0700 | [diff] [blame] | 730 | /* setup baseboard specific GPIO based on board and env */ |
| 731 | setup_board_gpio(board_type, info); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 732 | |
| 733 | #ifdef CONFIG_CMD_BMODE |
| 734 | add_board_boot_modes(board_boot_modes); |
| 735 | #endif |
| 736 | |
Tim Harvey | 40feabb | 2015-05-08 18:28:36 -0700 | [diff] [blame] | 737 | /* disable boot watchdog */ |
| 738 | gsc_boot_wd_disable(); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 739 | |
| 740 | return 0; |
| 741 | } |
| 742 | |
| 743 | #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) |
| 744 | |
Tim Harvey | cf20e55 | 2015-04-08 12:55:01 -0700 | [diff] [blame] | 745 | static int ft_sethdmiinfmt(void *blob, char *mode) |
| 746 | { |
| 747 | int off; |
| 748 | |
| 749 | if (!mode) |
| 750 | return -EINVAL; |
| 751 | |
| 752 | off = fdt_node_offset_by_compatible(blob, -1, "nxp,tda1997x"); |
| 753 | if (off < 0) |
| 754 | return off; |
| 755 | |
| 756 | if (0 == strcasecmp(mode, "yuv422bt656")) { |
| 757 | u8 cfg[] = { 0x00, 0x00, 0x00, 0x82, 0x81, 0x00, |
| 758 | 0x00, 0x00, 0x00 }; |
| 759 | mode = "422_ccir"; |
| 760 | fdt_setprop(blob, off, "vidout_fmt", mode, strlen(mode) + 1); |
| 761 | fdt_setprop_u32(blob, off, "vidout_trc", 1); |
| 762 | fdt_setprop_u32(blob, off, "vidout_blc", 1); |
| 763 | fdt_setprop(blob, off, "vidout_portcfg", cfg, sizeof(cfg)); |
| 764 | printf(" set HDMI input mode to %s\n", mode); |
| 765 | } else if (0 == strcasecmp(mode, "yuv422smp")) { |
| 766 | u8 cfg[] = { 0x00, 0x00, 0x00, 0x88, 0x87, 0x00, |
| 767 | 0x82, 0x81, 0x00 }; |
| 768 | mode = "422_smp"; |
| 769 | fdt_setprop(blob, off, "vidout_fmt", mode, strlen(mode) + 1); |
| 770 | fdt_setprop_u32(blob, off, "vidout_trc", 0); |
| 771 | fdt_setprop_u32(blob, off, "vidout_blc", 0); |
| 772 | fdt_setprop(blob, off, "vidout_portcfg", cfg, sizeof(cfg)); |
| 773 | printf(" set HDMI input mode to %s\n", mode); |
| 774 | } else { |
| 775 | return -EINVAL; |
| 776 | } |
| 777 | |
| 778 | return 0; |
| 779 | } |
| 780 | |
Tim Harvey | 8d2d8df | 2016-05-24 11:03:55 -0700 | [diff] [blame^] | 781 | /* enable a property of a node if the node is found */ |
| 782 | static inline void ft_enable_path(void *blob, const char *path) |
| 783 | { |
| 784 | int i = fdt_path_offset(blob, path); |
| 785 | if (i >= 0) { |
| 786 | debug("enabling %s\n", path); |
| 787 | fdt_status_okay(blob, i); |
| 788 | } |
| 789 | } |
| 790 | |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 791 | /* |
| 792 | * called prior to booting kernel or by 'fdt boardsetup' command |
| 793 | * |
| 794 | * unless 'fdt_noauto' env var is set we will update the following in the DTB: |
| 795 | * - mtd partitions based on mtdparts/mtdids env |
| 796 | * - system-serial (board serial num from EEPROM) |
| 797 | * - board (full model from EEPROM) |
| 798 | * - peripherals removed from DTB if not loaded on board (per EEPROM config) |
| 799 | */ |
Simon Glass | 2aec3cc | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 800 | int ft_board_setup(void *blob, bd_t *bd) |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 801 | { |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 802 | struct ventana_board_info *info = &ventana_info; |
Tim Harvey | 0da2c52 | 2014-08-07 22:35:45 -0700 | [diff] [blame] | 803 | struct ventana_eeprom_config *cfg; |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 804 | struct node_info nodes[] = { |
| 805 | { "sst,w25q256", MTD_DEV_TYPE_NOR, }, /* SPI flash */ |
| 806 | { "fsl,imx6q-gpmi-nand", MTD_DEV_TYPE_NAND, }, /* NAND flash */ |
| 807 | }; |
| 808 | const char *model = getenv("model"); |
Tim Harvey | e4af5d3 | 2015-04-08 12:54:58 -0700 | [diff] [blame] | 809 | const char *display = getenv("display"); |
Tim Harvey | 16e0eae | 2015-04-08 12:54:44 -0700 | [diff] [blame] | 810 | int i; |
| 811 | char rev = 0; |
| 812 | |
| 813 | /* determine board revision */ |
| 814 | for (i = sizeof(ventana_info.model) - 1; i > 0; i--) { |
| 815 | if (ventana_info.model[i] >= 'A') { |
| 816 | rev = ventana_info.model[i]; |
| 817 | break; |
| 818 | } |
| 819 | } |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 820 | |
| 821 | if (getenv("fdt_noauto")) { |
| 822 | puts(" Skiping ft_board_setup (fdt_noauto defined)\n"); |
Simon Glass | 2aec3cc | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 823 | return 0; |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 824 | } |
| 825 | |
Tim Harvey | c9e43e0 | 2015-05-26 11:04:58 -0700 | [diff] [blame] | 826 | if (test_bit(EECONFIG_NAND, info->config)) { |
| 827 | /* Update partition nodes using info from mtdparts env var */ |
| 828 | puts(" Updating MTD partitions...\n"); |
| 829 | fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes)); |
| 830 | } |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 831 | |
Tim Harvey | e4af5d3 | 2015-04-08 12:54:58 -0700 | [diff] [blame] | 832 | /* Update display timings from display env var */ |
| 833 | if (display) { |
| 834 | if (fdt_fixup_display(blob, fdt_get_alias(blob, "lvds0"), |
| 835 | display) >= 0) |
| 836 | printf(" Set display timings for %s...\n", display); |
| 837 | } |
| 838 | |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 839 | printf(" Adjusting FDT per EEPROM for %s...\n", model); |
| 840 | |
| 841 | /* board serial number */ |
| 842 | fdt_setprop(blob, 0, "system-serial", getenv("serial#"), |
Tim Harvey | ae35ded | 2014-04-25 09:18:33 -0700 | [diff] [blame] | 843 | strlen(getenv("serial#")) + 1); |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 844 | |
| 845 | /* board (model contains model from device-tree) */ |
| 846 | fdt_setprop(blob, 0, "board", info->model, |
| 847 | strlen((const char *)info->model) + 1); |
| 848 | |
Tim Harvey | cf20e55 | 2015-04-08 12:55:01 -0700 | [diff] [blame] | 849 | /* set desired digital video capture format */ |
| 850 | ft_sethdmiinfmt(blob, getenv("hdmiinfmt")); |
| 851 | |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 852 | /* |
Tim Harvey | 865dc9c | 2015-04-08 12:54:56 -0700 | [diff] [blame] | 853 | * disable serial2 node for GW54xx for compatibility with older |
| 854 | * 3.10.x kernel that improperly had this node enabled in the DT |
| 855 | */ |
| 856 | if (board_type == GW54xx) { |
| 857 | i = fdt_path_offset(blob, |
| 858 | "/soc/aips-bus@02100000/serial@021ec000"); |
| 859 | if (i) |
| 860 | fdt_del_node(blob, i); |
| 861 | } |
| 862 | |
| 863 | /* |
Tim Harvey | 16e0eae | 2015-04-08 12:54:44 -0700 | [diff] [blame] | 864 | * disable wdog1/wdog2 nodes for GW51xx below revC to work around |
| 865 | * errata causing wdog timer to be unreliable. |
| 866 | */ |
| 867 | if (board_type == GW51xx && rev >= 'A' && rev < 'C') { |
| 868 | i = fdt_path_offset(blob, |
| 869 | "/soc/aips-bus@02000000/wdog@020bc000"); |
| 870 | if (i) |
| 871 | fdt_status_disabled(blob, i); |
| 872 | } |
| 873 | |
Pushpal Sidhu | d110056 | 2015-04-08 12:55:00 -0700 | [diff] [blame] | 874 | /* GW522x Uses GPIO3_IO23 instead of GPIO1_IO29 */ |
| 875 | else if (board_type == GW52xx && info->model[4] == '2') { |
| 876 | u32 handle = 0; |
| 877 | u32 *range = NULL; |
| 878 | |
| 879 | i = fdt_node_offset_by_compatible(blob, -1, "fsl,imx6q-pcie"); |
| 880 | if (i) |
| 881 | range = (u32 *)fdt_getprop(blob, i, "reset-gpio", |
| 882 | NULL); |
| 883 | |
| 884 | if (range) { |
| 885 | i = fdt_path_offset(blob, |
| 886 | "/soc/aips-bus@02000000/gpio@020a4000"); |
| 887 | if (i) |
| 888 | handle = fdt_get_phandle(blob, i); |
| 889 | if (handle) { |
| 890 | range[0] = cpu_to_fdt32(handle); |
| 891 | range[1] = cpu_to_fdt32(23); |
| 892 | } |
| 893 | } |
| 894 | } |
| 895 | |
Tim Harvey | 16e0eae | 2015-04-08 12:54:44 -0700 | [diff] [blame] | 896 | /* |
Tim Harvey | 6944ccf | 2015-04-08 12:54:53 -0700 | [diff] [blame] | 897 | * isolate CSI0_DATA_EN for GW551x below revB to work around |
| 898 | * errata causing non functional digital video in (it is not hooked up) |
| 899 | */ |
| 900 | else if (board_type == GW551x && rev == 'A') { |
| 901 | u32 *range = NULL; |
| 902 | int len; |
| 903 | const u32 *handle = NULL; |
| 904 | |
| 905 | i = fdt_node_offset_by_compatible(blob, -1, |
| 906 | "fsl,imx-tda1997x-video"); |
| 907 | if (i) |
| 908 | handle = fdt_getprop(blob, i, "pinctrl-0", NULL); |
| 909 | if (handle) |
| 910 | i = fdt_node_offset_by_phandle(blob, |
| 911 | fdt32_to_cpu(*handle)); |
| 912 | if (i) |
| 913 | range = (u32 *)fdt_getprop(blob, i, "fsl,pins", &len); |
| 914 | if (range) { |
| 915 | len /= sizeof(u32); |
| 916 | for (i = 0; i < len; i += 6) { |
| 917 | u32 mux_reg = fdt32_to_cpu(range[i+0]); |
| 918 | u32 conf_reg = fdt32_to_cpu(range[i+1]); |
| 919 | /* mux PAD_CSI0_DATA_EN to GPIO */ |
| 920 | if (is_cpu_type(MXC_CPU_MX6Q) && |
| 921 | mux_reg == 0x260 && conf_reg == 0x630) |
| 922 | range[i+3] = cpu_to_fdt32(0x5); |
| 923 | else if (!is_cpu_type(MXC_CPU_MX6Q) && |
| 924 | mux_reg == 0x08c && conf_reg == 0x3a0) |
| 925 | range[i+3] = cpu_to_fdt32(0x5); |
| 926 | } |
| 927 | fdt_setprop_inplace(blob, i, "fsl,pins", range, len); |
| 928 | } |
Tim Harvey | dc8b5e6 | 2015-04-08 12:55:02 -0700 | [diff] [blame] | 929 | |
| 930 | /* set BT656 video format */ |
| 931 | ft_sethdmiinfmt(blob, "yuv422bt656"); |
Tim Harvey | 6944ccf | 2015-04-08 12:54:53 -0700 | [diff] [blame] | 932 | } |
| 933 | |
Tim Harvey | 8d2d8df | 2016-05-24 11:03:55 -0700 | [diff] [blame^] | 934 | /* Configure DIO */ |
| 935 | for (i = 0; i < gpio_cfg[board_type].num_gpios; i++) { |
| 936 | struct dio_cfg *cfg = &gpio_cfg[board_type].dio_cfg[i]; |
| 937 | char arg[10]; |
| 938 | |
| 939 | sprintf(arg, "dio%d", i); |
| 940 | if (!hwconfig(arg)) |
| 941 | continue; |
| 942 | if (hwconfig_subarg_cmp(arg, "mode", "pwm") && cfg->pwm_param) |
| 943 | { |
| 944 | char path[48]; |
| 945 | sprintf(path, "/soc/aips-bus@02000000/pwm@%08x", |
| 946 | 0x02080000 + (0x4000 * (cfg->pwm_param - 1))); |
| 947 | printf(" Enabling pwm%d for DIO%d\n", |
| 948 | cfg->pwm_param, i); |
| 949 | ft_enable_path(blob, path); |
| 950 | } |
| 951 | } |
| 952 | |
Tim Harvey | 6944ccf | 2015-04-08 12:54:53 -0700 | [diff] [blame] | 953 | /* |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 954 | * Peripheral Config: |
| 955 | * remove nodes by alias path if EEPROM config tells us the |
| 956 | * peripheral is not loaded on the board. |
| 957 | */ |
Tim Harvey | 0da2c52 | 2014-08-07 22:35:45 -0700 | [diff] [blame] | 958 | if (getenv("fdt_noconfig")) { |
| 959 | puts(" Skiping periperhal config (fdt_noconfig defined)\n"); |
Simon Glass | 2aec3cc | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 960 | return 0; |
Tim Harvey | 0da2c52 | 2014-08-07 22:35:45 -0700 | [diff] [blame] | 961 | } |
| 962 | cfg = econfig; |
| 963 | while (cfg->name) { |
| 964 | if (!test_bit(cfg->bit, info->config)) { |
| 965 | fdt_del_node_and_alias(blob, cfg->dtalias ? |
| 966 | cfg->dtalias : cfg->name); |
| 967 | } |
| 968 | cfg++; |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 969 | } |
Simon Glass | 2aec3cc | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 970 | |
| 971 | return 0; |
Tim Harvey | 552c358 | 2014-03-06 07:46:30 -0800 | [diff] [blame] | 972 | } |
| 973 | #endif /* defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP) */ |
| 974 | |
Tim Harvey | 67ed792 | 2015-05-08 18:28:29 -0700 | [diff] [blame] | 975 | static struct mxc_serial_platdata ventana_mxc_serial_plat = { |
| 976 | .reg = (struct mxc_uart *)UART2_BASE, |
| 977 | }; |
| 978 | |
| 979 | U_BOOT_DEVICE(ventana_serial) = { |
| 980 | .name = "serial_mxc", |
| 981 | .platdata = &ventana_mxc_serial_plat, |
| 982 | }; |