Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 Freescale Semiconductor, Inc. |
Otavio Salvador | 1d744d9 | 2014-05-01 19:02:31 -0300 | [diff] [blame] | 3 | * Copyright (C) 2014 O.S. Systems Software LTDA. |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 4 | * |
| 5 | * Author: Fabio Estevam <fabio.estevam@freescale.com> |
| 6 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 7 | * SPDX-License-Identifier: GPL-2.0+ |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <asm/arch/clock.h> |
Fabio Estevam | 0296f28 | 2013-05-23 07:50:23 +0000 | [diff] [blame] | 11 | #include <asm/arch/crm_regs.h> |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 12 | #include <asm/arch/iomux.h> |
| 13 | #include <asm/arch/imx-regs.h> |
| 14 | #include <asm/arch/mx6-pins.h> |
Fabio Estevam | 0296f28 | 2013-05-23 07:50:23 +0000 | [diff] [blame] | 15 | #include <asm/arch/mxc_hdmi.h> |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 16 | #include <asm/arch/sys_proto.h> |
| 17 | #include <asm/gpio.h> |
| 18 | #include <asm/imx-common/iomux-v3.h> |
Otavio Salvador | 1d744d9 | 2014-05-01 19:02:31 -0300 | [diff] [blame] | 19 | #include <asm/imx-common/mxc_i2c.h> |
Otavio Salvador | 54b8ce2 | 2013-04-19 03:42:03 +0000 | [diff] [blame] | 20 | #include <asm/imx-common/boot_mode.h> |
Otavio Salvador | 1d744d9 | 2014-05-01 19:02:31 -0300 | [diff] [blame] | 21 | #include <asm/imx-common/video.h> |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 22 | #include <asm/io.h> |
Alexey Brodkin | 267d8e2 | 2014-02-26 17:47:58 +0400 | [diff] [blame] | 23 | #include <linux/sizes.h> |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 24 | #include <common.h> |
| 25 | #include <fsl_esdhc.h> |
| 26 | #include <mmc.h> |
| 27 | #include <miiphy.h> |
| 28 | #include <netdev.h> |
Fabio Estevam | 55e0f19 | 2014-02-15 14:52:00 -0200 | [diff] [blame] | 29 | #include <phy.h> |
Fabio Estevam | 4d66313 | 2014-02-15 14:52:01 -0200 | [diff] [blame] | 30 | #include <input.h> |
Otavio Salvador | 1d744d9 | 2014-05-01 19:02:31 -0300 | [diff] [blame] | 31 | #include <i2c.h> |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 32 | |
| 33 | DECLARE_GLOBAL_DATA_PTR; |
| 34 | |
Benoît Thébaudeau | 2167024 | 2013-04-26 01:34:47 +0000 | [diff] [blame] | 35 | #define UART_PAD_CTRL (PAD_CTL_PUS_100K_UP | \ |
| 36 | PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | \ |
| 37 | PAD_CTL_SRE_FAST | PAD_CTL_HYS) |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 38 | |
Benoît Thébaudeau | 2167024 | 2013-04-26 01:34:47 +0000 | [diff] [blame] | 39 | #define USDHC_PAD_CTRL (PAD_CTL_PUS_47K_UP | \ |
| 40 | PAD_CTL_SPEED_LOW | PAD_CTL_DSE_80ohm | \ |
| 41 | PAD_CTL_SRE_FAST | PAD_CTL_HYS) |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 42 | |
Benoît Thébaudeau | 2167024 | 2013-04-26 01:34:47 +0000 | [diff] [blame] | 43 | #define ENET_PAD_CTRL (PAD_CTL_PUS_100K_UP | \ |
| 44 | PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS) |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 45 | |
Otavio Salvador | 1d744d9 | 2014-05-01 19:02:31 -0300 | [diff] [blame] | 46 | #define I2C_PAD_CTRL (PAD_CTL_PUS_100K_UP | \ |
| 47 | PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS | \ |
| 48 | PAD_CTL_ODE | PAD_CTL_SRE_FAST) |
| 49 | |
Otavio Salvador | fe65104 | 2013-04-19 03:42:02 +0000 | [diff] [blame] | 50 | #define USDHC1_CD_GPIO IMX_GPIO_NR(1, 2) |
Otavio Salvador | 36fda7f | 2013-04-19 03:42:01 +0000 | [diff] [blame] | 51 | #define USDHC3_CD_GPIO IMX_GPIO_NR(3, 9) |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 52 | #define ETH_PHY_RESET IMX_GPIO_NR(3, 29) |
| 53 | |
| 54 | int dram_init(void) |
| 55 | { |
Tapani Utriainen | 048a64d | 2013-06-26 17:51:49 +0800 | [diff] [blame] | 56 | gd->ram_size = (phys_size_t)CONFIG_DDR_MB * 1024 * 1024; |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 57 | |
| 58 | return 0; |
| 59 | } |
| 60 | |
| 61 | static iomux_v3_cfg_t const uart1_pads[] = { |
Eric Nelson | 3d3be0a | 2013-11-04 17:00:51 -0700 | [diff] [blame] | 62 | MX6_PAD_CSI0_DAT10__UART1_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL), |
| 63 | MX6_PAD_CSI0_DAT11__UART1_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL), |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 64 | }; |
| 65 | |
Fabio Estevam | 4b89169 | 2014-02-15 14:51:58 -0200 | [diff] [blame] | 66 | static iomux_v3_cfg_t const usdhc1_pads[] = { |
Eric Nelson | 3d3be0a | 2013-11-04 17:00:51 -0700 | [diff] [blame] | 67 | MX6_PAD_SD1_CLK__SD1_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 68 | MX6_PAD_SD1_CMD__SD1_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 69 | MX6_PAD_SD1_DAT0__SD1_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 70 | MX6_PAD_SD1_DAT1__SD1_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 71 | MX6_PAD_SD1_DAT2__SD1_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 72 | MX6_PAD_SD1_DAT3__SD1_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
Otavio Salvador | fe65104 | 2013-04-19 03:42:02 +0000 | [diff] [blame] | 73 | /* Carrier MicroSD Card Detect */ |
Eric Nelson | 3d3be0a | 2013-11-04 17:00:51 -0700 | [diff] [blame] | 74 | MX6_PAD_GPIO_2__GPIO1_IO02 | MUX_PAD_CTRL(NO_PAD_CTRL), |
Otavio Salvador | fe65104 | 2013-04-19 03:42:02 +0000 | [diff] [blame] | 75 | }; |
| 76 | |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 77 | static iomux_v3_cfg_t const usdhc3_pads[] = { |
Eric Nelson | 3d3be0a | 2013-11-04 17:00:51 -0700 | [diff] [blame] | 78 | MX6_PAD_SD3_CLK__SD3_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 79 | MX6_PAD_SD3_CMD__SD3_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 80 | MX6_PAD_SD3_DAT0__SD3_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 81 | MX6_PAD_SD3_DAT1__SD3_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 82 | MX6_PAD_SD3_DAT2__SD3_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 83 | MX6_PAD_SD3_DAT3__SD3_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
Otavio Salvador | 36fda7f | 2013-04-19 03:42:01 +0000 | [diff] [blame] | 84 | /* SOM MicroSD Card Detect */ |
Eric Nelson | 3d3be0a | 2013-11-04 17:00:51 -0700 | [diff] [blame] | 85 | MX6_PAD_EIM_DA9__GPIO3_IO09 | MUX_PAD_CTRL(NO_PAD_CTRL), |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | static iomux_v3_cfg_t const enet_pads[] = { |
| 89 | MX6_PAD_ENET_MDIO__ENET_MDIO | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 90 | MX6_PAD_ENET_MDC__ENET_MDC | MUX_PAD_CTRL(ENET_PAD_CTRL), |
Eric Nelson | 3d3be0a | 2013-11-04 17:00:51 -0700 | [diff] [blame] | 91 | MX6_PAD_RGMII_TXC__RGMII_TXC | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 92 | MX6_PAD_RGMII_TD0__RGMII_TD0 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 93 | MX6_PAD_RGMII_TD1__RGMII_TD1 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 94 | MX6_PAD_RGMII_TD2__RGMII_TD2 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 95 | MX6_PAD_RGMII_TD3__RGMII_TD3 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 96 | MX6_PAD_RGMII_TX_CTL__RGMII_TX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 97 | MX6_PAD_ENET_REF_CLK__ENET_TX_CLK | MUX_PAD_CTRL(ENET_PAD_CTRL), |
Eric Nelson | 3d3be0a | 2013-11-04 17:00:51 -0700 | [diff] [blame] | 98 | MX6_PAD_RGMII_RXC__RGMII_RXC | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 99 | MX6_PAD_RGMII_RD0__RGMII_RD0 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 100 | MX6_PAD_RGMII_RD1__RGMII_RD1 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 101 | MX6_PAD_RGMII_RD2__RGMII_RD2 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 102 | MX6_PAD_RGMII_RD3__RGMII_RD3 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 103 | MX6_PAD_RGMII_RX_CTL__RGMII_RX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 104 | /* AR8031 PHY Reset */ |
Eric Nelson | 3d3be0a | 2013-11-04 17:00:51 -0700 | [diff] [blame] | 105 | MX6_PAD_EIM_D29__GPIO3_IO29 | MUX_PAD_CTRL(NO_PAD_CTRL), |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 106 | }; |
| 107 | |
| 108 | static void setup_iomux_uart(void) |
| 109 | { |
| 110 | imx_iomux_v3_setup_multiple_pads(uart1_pads, ARRAY_SIZE(uart1_pads)); |
| 111 | } |
| 112 | |
| 113 | static void setup_iomux_enet(void) |
| 114 | { |
| 115 | imx_iomux_v3_setup_multiple_pads(enet_pads, ARRAY_SIZE(enet_pads)); |
| 116 | |
| 117 | /* Reset AR8031 PHY */ |
| 118 | gpio_direction_output(ETH_PHY_RESET, 0); |
| 119 | udelay(500); |
| 120 | gpio_set_value(ETH_PHY_RESET, 1); |
| 121 | } |
| 122 | |
Otavio Salvador | fe65104 | 2013-04-19 03:42:02 +0000 | [diff] [blame] | 123 | static struct fsl_esdhc_cfg usdhc_cfg[2] = { |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 124 | {USDHC3_BASE_ADDR}, |
Otavio Salvador | fe65104 | 2013-04-19 03:42:02 +0000 | [diff] [blame] | 125 | {USDHC1_BASE_ADDR}, |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 126 | }; |
| 127 | |
Otavio Salvador | 36fda7f | 2013-04-19 03:42:01 +0000 | [diff] [blame] | 128 | int board_mmc_getcd(struct mmc *mmc) |
| 129 | { |
| 130 | struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv; |
| 131 | int ret = 0; |
| 132 | |
| 133 | switch (cfg->esdhc_base) { |
Otavio Salvador | fe65104 | 2013-04-19 03:42:02 +0000 | [diff] [blame] | 134 | case USDHC1_BASE_ADDR: |
| 135 | ret = !gpio_get_value(USDHC1_CD_GPIO); |
| 136 | break; |
Otavio Salvador | 36fda7f | 2013-04-19 03:42:01 +0000 | [diff] [blame] | 137 | case USDHC3_BASE_ADDR: |
| 138 | ret = !gpio_get_value(USDHC3_CD_GPIO); |
| 139 | break; |
| 140 | } |
| 141 | |
| 142 | return ret; |
| 143 | } |
| 144 | |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 145 | int board_mmc_init(bd_t *bis) |
| 146 | { |
Fabio Estevam | 522f059 | 2014-11-15 14:50:26 -0200 | [diff] [blame] | 147 | int ret; |
Otavio Salvador | fe65104 | 2013-04-19 03:42:02 +0000 | [diff] [blame] | 148 | u32 index = 0; |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 149 | |
Otavio Salvador | fe65104 | 2013-04-19 03:42:02 +0000 | [diff] [blame] | 150 | /* |
| 151 | * Following map is done: |
| 152 | * (U-boot device node) (Physical Port) |
| 153 | * mmc0 SOM MicroSD |
| 154 | * mmc1 Carrier board MicroSD |
| 155 | */ |
| 156 | for (index = 0; index < CONFIG_SYS_FSL_USDHC_NUM; ++index) { |
| 157 | switch (index) { |
| 158 | case 0: |
| 159 | imx_iomux_v3_setup_multiple_pads( |
| 160 | usdhc3_pads, ARRAY_SIZE(usdhc3_pads)); |
| 161 | usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK); |
| 162 | usdhc_cfg[0].max_bus_width = 4; |
| 163 | gpio_direction_input(USDHC3_CD_GPIO); |
| 164 | break; |
| 165 | case 1: |
| 166 | imx_iomux_v3_setup_multiple_pads( |
| 167 | usdhc1_pads, ARRAY_SIZE(usdhc1_pads)); |
| 168 | usdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK); |
| 169 | usdhc_cfg[1].max_bus_width = 4; |
| 170 | gpio_direction_input(USDHC1_CD_GPIO); |
| 171 | break; |
| 172 | default: |
| 173 | printf("Warning: you configured more USDHC controllers" |
| 174 | "(%d) then supported by the board (%d)\n", |
| 175 | index + 1, CONFIG_SYS_FSL_USDHC_NUM); |
Fabio Estevam | 522f059 | 2014-11-15 14:50:26 -0200 | [diff] [blame] | 176 | return -EINVAL; |
Otavio Salvador | fe65104 | 2013-04-19 03:42:02 +0000 | [diff] [blame] | 177 | } |
| 178 | |
Fabio Estevam | 522f059 | 2014-11-15 14:50:26 -0200 | [diff] [blame] | 179 | ret = fsl_esdhc_initialize(bis, &usdhc_cfg[index]); |
| 180 | if (ret) |
| 181 | return ret; |
Otavio Salvador | fe65104 | 2013-04-19 03:42:02 +0000 | [diff] [blame] | 182 | } |
Abbas Raza | e6bf977 | 2013-03-25 09:13:34 +0000 | [diff] [blame] | 183 | |
Fabio Estevam | 522f059 | 2014-11-15 14:50:26 -0200 | [diff] [blame] | 184 | return 0; |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 185 | } |
| 186 | |
| 187 | static int mx6_rgmii_rework(struct phy_device *phydev) |
| 188 | { |
| 189 | unsigned short val; |
| 190 | |
| 191 | /* To enable AR8031 ouput a 125MHz clk from CLK_25M */ |
| 192 | phy_write(phydev, MDIO_DEVAD_NONE, 0xd, 0x7); |
| 193 | phy_write(phydev, MDIO_DEVAD_NONE, 0xe, 0x8016); |
| 194 | phy_write(phydev, MDIO_DEVAD_NONE, 0xd, 0x4007); |
| 195 | |
| 196 | val = phy_read(phydev, MDIO_DEVAD_NONE, 0xe); |
| 197 | val &= 0xffe3; |
| 198 | val |= 0x18; |
| 199 | phy_write(phydev, MDIO_DEVAD_NONE, 0xe, val); |
| 200 | |
| 201 | /* introduce tx clock delay */ |
| 202 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x5); |
| 203 | val = phy_read(phydev, MDIO_DEVAD_NONE, 0x1e); |
| 204 | val |= 0x0100; |
| 205 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, val); |
| 206 | |
| 207 | return 0; |
| 208 | } |
| 209 | |
| 210 | int board_phy_config(struct phy_device *phydev) |
| 211 | { |
| 212 | mx6_rgmii_rework(phydev); |
| 213 | |
| 214 | if (phydev->drv->config) |
| 215 | phydev->drv->config(phydev); |
| 216 | |
| 217 | return 0; |
| 218 | } |
| 219 | |
Fabio Estevam | 0296f28 | 2013-05-23 07:50:23 +0000 | [diff] [blame] | 220 | #if defined(CONFIG_VIDEO_IPUV3) |
Otavio Salvador | 1d744d9 | 2014-05-01 19:02:31 -0300 | [diff] [blame] | 221 | struct i2c_pads_info i2c2_pad_info = { |
| 222 | .scl = { |
| 223 | .i2c_mode = MX6_PAD_KEY_COL3__I2C2_SCL |
| 224 | | MUX_PAD_CTRL(I2C_PAD_CTRL), |
| 225 | .gpio_mode = MX6_PAD_KEY_COL3__GPIO4_IO12 |
| 226 | | MUX_PAD_CTRL(I2C_PAD_CTRL), |
| 227 | .gp = IMX_GPIO_NR(4, 12) |
| 228 | }, |
| 229 | .sda = { |
| 230 | .i2c_mode = MX6_PAD_KEY_ROW3__I2C2_SDA |
| 231 | | MUX_PAD_CTRL(I2C_PAD_CTRL), |
| 232 | .gpio_mode = MX6_PAD_KEY_ROW3__GPIO4_IO13 |
| 233 | | MUX_PAD_CTRL(I2C_PAD_CTRL), |
| 234 | .gp = IMX_GPIO_NR(4, 13) |
| 235 | } |
Fabio Estevam | 0296f28 | 2013-05-23 07:50:23 +0000 | [diff] [blame] | 236 | }; |
| 237 | |
Otavio Salvador | 1d744d9 | 2014-05-01 19:02:31 -0300 | [diff] [blame] | 238 | static iomux_v3_cfg_t const fwadapt_7wvga_pads[] = { |
| 239 | MX6_PAD_DI0_DISP_CLK__IPU1_DI0_DISP_CLK, |
| 240 | MX6_PAD_DI0_PIN2__IPU1_DI0_PIN02, /* HSync */ |
| 241 | MX6_PAD_DI0_PIN3__IPU1_DI0_PIN03, /* VSync */ |
| 242 | MX6_PAD_DI0_PIN4__IPU1_DI0_PIN04 |
| 243 | | MUX_PAD_CTRL(PAD_CTL_DSE_120ohm), /* Contrast */ |
| 244 | MX6_PAD_DI0_PIN15__IPU1_DI0_PIN15, /* DISP0_DRDY */ |
Fabio Estevam | 0296f28 | 2013-05-23 07:50:23 +0000 | [diff] [blame] | 245 | |
Otavio Salvador | 1d744d9 | 2014-05-01 19:02:31 -0300 | [diff] [blame] | 246 | MX6_PAD_DISP0_DAT0__IPU1_DISP0_DATA00, |
| 247 | MX6_PAD_DISP0_DAT1__IPU1_DISP0_DATA01, |
| 248 | MX6_PAD_DISP0_DAT2__IPU1_DISP0_DATA02, |
| 249 | MX6_PAD_DISP0_DAT3__IPU1_DISP0_DATA03, |
| 250 | MX6_PAD_DISP0_DAT4__IPU1_DISP0_DATA04, |
| 251 | MX6_PAD_DISP0_DAT5__IPU1_DISP0_DATA05, |
| 252 | MX6_PAD_DISP0_DAT6__IPU1_DISP0_DATA06, |
| 253 | MX6_PAD_DISP0_DAT7__IPU1_DISP0_DATA07, |
| 254 | MX6_PAD_DISP0_DAT8__IPU1_DISP0_DATA08, |
| 255 | MX6_PAD_DISP0_DAT9__IPU1_DISP0_DATA09, |
| 256 | MX6_PAD_DISP0_DAT10__IPU1_DISP0_DATA10, |
| 257 | MX6_PAD_DISP0_DAT11__IPU1_DISP0_DATA11, |
| 258 | MX6_PAD_DISP0_DAT12__IPU1_DISP0_DATA12, |
| 259 | MX6_PAD_DISP0_DAT13__IPU1_DISP0_DATA13, |
| 260 | MX6_PAD_DISP0_DAT14__IPU1_DISP0_DATA14, |
| 261 | MX6_PAD_DISP0_DAT15__IPU1_DISP0_DATA15, |
| 262 | MX6_PAD_DISP0_DAT16__IPU1_DISP0_DATA16, |
| 263 | MX6_PAD_DISP0_DAT17__IPU1_DISP0_DATA17, |
Fabio Estevam | 0296f28 | 2013-05-23 07:50:23 +0000 | [diff] [blame] | 264 | |
Otavio Salvador | 1d744d9 | 2014-05-01 19:02:31 -0300 | [diff] [blame] | 265 | MX6_PAD_SD4_DAT2__GPIO2_IO10 |
| 266 | | MUX_PAD_CTRL(NO_PAD_CTRL), /* DISP0_BKLEN */ |
| 267 | MX6_PAD_SD4_DAT3__GPIO2_IO11 |
| 268 | | MUX_PAD_CTRL(NO_PAD_CTRL), /* DISP0_VDDEN */ |
| 269 | }; |
Fabio Estevam | 0296f28 | 2013-05-23 07:50:23 +0000 | [diff] [blame] | 270 | |
Otavio Salvador | 1d744d9 | 2014-05-01 19:02:31 -0300 | [diff] [blame] | 271 | static void do_enable_hdmi(struct display_info_t const *dev) |
| 272 | { |
Pardeep Kumar Singla | c1fa130 | 2013-07-25 12:12:13 -0500 | [diff] [blame] | 273 | imx_enable_hdmi_phy(); |
Otavio Salvador | 1d744d9 | 2014-05-01 19:02:31 -0300 | [diff] [blame] | 274 | } |
Fabio Estevam | 0296f28 | 2013-05-23 07:50:23 +0000 | [diff] [blame] | 275 | |
Otavio Salvador | 1d744d9 | 2014-05-01 19:02:31 -0300 | [diff] [blame] | 276 | static int detect_i2c(struct display_info_t const *dev) |
| 277 | { |
| 278 | return (0 == i2c_set_bus_num(dev->bus)) && |
| 279 | (0 == i2c_probe(dev->addr)); |
| 280 | } |
| 281 | |
| 282 | static void enable_fwadapt_7wvga(struct display_info_t const *dev) |
| 283 | { |
| 284 | imx_iomux_v3_setup_multiple_pads( |
| 285 | fwadapt_7wvga_pads, |
| 286 | ARRAY_SIZE(fwadapt_7wvga_pads)); |
| 287 | |
| 288 | gpio_direction_output(IMX_GPIO_NR(2, 10), 1); |
| 289 | gpio_direction_output(IMX_GPIO_NR(2, 11), 1); |
Fabio Estevam | 0296f28 | 2013-05-23 07:50:23 +0000 | [diff] [blame] | 290 | } |
| 291 | |
Otavio Salvador | 1d744d9 | 2014-05-01 19:02:31 -0300 | [diff] [blame] | 292 | struct display_info_t const displays[] = {{ |
| 293 | .bus = -1, |
| 294 | .addr = 0, |
| 295 | .pixfmt = IPU_PIX_FMT_RGB24, |
| 296 | .detect = detect_hdmi, |
| 297 | .enable = do_enable_hdmi, |
| 298 | .mode = { |
| 299 | .name = "HDMI", |
| 300 | .refresh = 60, |
| 301 | .xres = 1024, |
| 302 | .yres = 768, |
| 303 | .pixclock = 15385, |
| 304 | .left_margin = 220, |
| 305 | .right_margin = 40, |
| 306 | .upper_margin = 21, |
| 307 | .lower_margin = 7, |
| 308 | .hsync_len = 60, |
| 309 | .vsync_len = 10, |
| 310 | .sync = FB_SYNC_EXT, |
| 311 | .vmode = FB_VMODE_NONINTERLACED |
| 312 | } }, { |
| 313 | .bus = 1, |
| 314 | .addr = 0x10, |
| 315 | .pixfmt = IPU_PIX_FMT_RGB666, |
| 316 | .detect = detect_i2c, |
| 317 | .enable = enable_fwadapt_7wvga, |
| 318 | .mode = { |
| 319 | .name = "FWBADAPT-LCD-F07A-0102", |
| 320 | .refresh = 60, |
| 321 | .xres = 800, |
| 322 | .yres = 480, |
| 323 | .pixclock = 33260, |
| 324 | .left_margin = 128, |
| 325 | .right_margin = 128, |
| 326 | .upper_margin = 22, |
| 327 | .lower_margin = 22, |
| 328 | .hsync_len = 1, |
| 329 | .vsync_len = 1, |
| 330 | .sync = 0, |
| 331 | .vmode = FB_VMODE_NONINTERLACED |
| 332 | } } }; |
| 333 | size_t display_count = ARRAY_SIZE(displays); |
| 334 | |
Fabio Estevam | 0296f28 | 2013-05-23 07:50:23 +0000 | [diff] [blame] | 335 | static void setup_display(void) |
| 336 | { |
| 337 | struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR; |
Fabio Estevam | 0296f28 | 2013-05-23 07:50:23 +0000 | [diff] [blame] | 338 | int reg; |
| 339 | |
Pardeep Kumar Singla | c1fa130 | 2013-07-25 12:12:13 -0500 | [diff] [blame] | 340 | enable_ipu_clock(); |
| 341 | imx_setup_hdmi(); |
Fabio Estevam | 0296f28 | 2013-05-23 07:50:23 +0000 | [diff] [blame] | 342 | |
| 343 | reg = readl(&mxc_ccm->chsccdr); |
Fabio Estevam | 0296f28 | 2013-05-23 07:50:23 +0000 | [diff] [blame] | 344 | reg |= (CHSCCDR_CLK_SEL_LDB_DI0 |
Pardeep Kumar Singla | c1fa130 | 2013-07-25 12:12:13 -0500 | [diff] [blame] | 345 | << MXC_CCM_CHSCCDR_IPU1_DI0_CLK_SEL_OFFSET); |
Fabio Estevam | 0296f28 | 2013-05-23 07:50:23 +0000 | [diff] [blame] | 346 | writel(reg, &mxc_ccm->chsccdr); |
Otavio Salvador | 1d744d9 | 2014-05-01 19:02:31 -0300 | [diff] [blame] | 347 | |
| 348 | /* Disable LCD backlight */ |
| 349 | imx_iomux_v3_setup_pad(MX6_PAD_DI0_PIN4__GPIO4_IO20); |
| 350 | gpio_direction_input(IMX_GPIO_NR(4, 20)); |
Fabio Estevam | 0296f28 | 2013-05-23 07:50:23 +0000 | [diff] [blame] | 351 | } |
| 352 | #endif /* CONFIG_VIDEO_IPUV3 */ |
| 353 | |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 354 | int board_eth_init(bd_t *bis) |
| 355 | { |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 356 | setup_iomux_enet(); |
| 357 | |
Fabio Estevam | c3cc305 | 2014-01-04 17:36:28 -0200 | [diff] [blame] | 358 | return cpu_eth_init(bis); |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 359 | } |
| 360 | |
| 361 | int board_early_init_f(void) |
| 362 | { |
| 363 | setup_iomux_uart(); |
Fabio Estevam | 0296f28 | 2013-05-23 07:50:23 +0000 | [diff] [blame] | 364 | #if defined(CONFIG_VIDEO_IPUV3) |
| 365 | setup_display(); |
| 366 | #endif |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 367 | return 0; |
| 368 | } |
| 369 | |
Fabio Estevam | 0296f28 | 2013-05-23 07:50:23 +0000 | [diff] [blame] | 370 | /* |
| 371 | * Do not overwrite the console |
| 372 | * Use always serial for U-Boot console |
| 373 | */ |
| 374 | int overwrite_console(void) |
| 375 | { |
| 376 | return 1; |
| 377 | } |
| 378 | |
Otavio Salvador | 54b8ce2 | 2013-04-19 03:42:03 +0000 | [diff] [blame] | 379 | #ifdef CONFIG_CMD_BMODE |
| 380 | static const struct boot_mode board_boot_modes[] = { |
| 381 | /* 4 bit bus width */ |
| 382 | {"mmc0", MAKE_CFGVAL(0x40, 0x30, 0x00, 0x00)}, |
| 383 | {"mmc1", MAKE_CFGVAL(0x40, 0x20, 0x00, 0x00)}, |
| 384 | {NULL, 0}, |
| 385 | }; |
| 386 | #endif |
| 387 | |
| 388 | int board_late_init(void) |
| 389 | { |
| 390 | #ifdef CONFIG_CMD_BMODE |
| 391 | add_board_boot_modes(board_boot_modes); |
| 392 | #endif |
| 393 | |
| 394 | return 0; |
| 395 | } |
| 396 | |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 397 | int board_init(void) |
| 398 | { |
| 399 | /* address of boot parameters */ |
| 400 | gd->bd->bi_boot_params = PHYS_SDRAM + 0x100; |
| 401 | |
Otavio Salvador | 1d744d9 | 2014-05-01 19:02:31 -0300 | [diff] [blame] | 402 | setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c2_pad_info); |
| 403 | |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 404 | return 0; |
| 405 | } |
| 406 | |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 407 | int checkboard(void) |
| 408 | { |
| 409 | puts("Board: Wandboard\n"); |
| 410 | |
| 411 | return 0; |
| 412 | } |