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) |
Fabio Estevam | aec72fb | 2015-05-21 19:24:05 -0300 | [diff] [blame] | 53 | #define REV_DETECTION IMX_GPIO_NR(2, 28) |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 54 | |
| 55 | int dram_init(void) |
| 56 | { |
Fabio Estevam | 1fa6486 | 2015-05-11 20:50:22 -0300 | [diff] [blame] | 57 | gd->ram_size = imx_ddr_size(); |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 58 | |
| 59 | return 0; |
| 60 | } |
| 61 | |
| 62 | static iomux_v3_cfg_t const uart1_pads[] = { |
Fabio Estevam | 1fa6486 | 2015-05-11 20:50:22 -0300 | [diff] [blame] | 63 | IOMUX_PADS(PAD_CSI0_DAT10__UART1_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)), |
| 64 | IOMUX_PADS(PAD_CSI0_DAT11__UART1_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)), |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 65 | }; |
| 66 | |
Fabio Estevam | 4b89169 | 2014-02-15 14:51:58 -0200 | [diff] [blame] | 67 | static iomux_v3_cfg_t const usdhc1_pads[] = { |
Fabio Estevam | 1fa6486 | 2015-05-11 20:50:22 -0300 | [diff] [blame] | 68 | IOMUX_PADS(PAD_SD1_CLK__SD1_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 69 | IOMUX_PADS(PAD_SD1_CMD__SD1_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 70 | IOMUX_PADS(PAD_SD1_DAT0__SD1_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 71 | IOMUX_PADS(PAD_SD1_DAT1__SD1_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 72 | IOMUX_PADS(PAD_SD1_DAT2__SD1_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 73 | IOMUX_PADS(PAD_SD1_DAT3__SD1_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
Otavio Salvador | fe65104 | 2013-04-19 03:42:02 +0000 | [diff] [blame] | 74 | /* Carrier MicroSD Card Detect */ |
Fabio Estevam | 1fa6486 | 2015-05-11 20:50:22 -0300 | [diff] [blame] | 75 | IOMUX_PADS(PAD_GPIO_2__GPIO1_IO02 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
Otavio Salvador | fe65104 | 2013-04-19 03:42:02 +0000 | [diff] [blame] | 76 | }; |
| 77 | |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 78 | static iomux_v3_cfg_t const usdhc3_pads[] = { |
Fabio Estevam | 1fa6486 | 2015-05-11 20:50:22 -0300 | [diff] [blame] | 79 | IOMUX_PADS(PAD_SD3_CLK__SD3_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 80 | IOMUX_PADS(PAD_SD3_CMD__SD3_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 81 | IOMUX_PADS(PAD_SD3_DAT0__SD3_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 82 | IOMUX_PADS(PAD_SD3_DAT1__SD3_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 83 | IOMUX_PADS(PAD_SD3_DAT2__SD3_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 84 | IOMUX_PADS(PAD_SD3_DAT3__SD3_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
Otavio Salvador | 36fda7f | 2013-04-19 03:42:01 +0000 | [diff] [blame] | 85 | /* SOM MicroSD Card Detect */ |
Fabio Estevam | 1fa6486 | 2015-05-11 20:50:22 -0300 | [diff] [blame] | 86 | IOMUX_PADS(PAD_EIM_DA9__GPIO3_IO09 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 87 | }; |
| 88 | |
| 89 | static iomux_v3_cfg_t const enet_pads[] = { |
Fabio Estevam | 1fa6486 | 2015-05-11 20:50:22 -0300 | [diff] [blame] | 90 | IOMUX_PADS(PAD_ENET_MDIO__ENET_MDIO | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 91 | IOMUX_PADS(PAD_ENET_MDC__ENET_MDC | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 92 | IOMUX_PADS(PAD_RGMII_TXC__RGMII_TXC | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 93 | IOMUX_PADS(PAD_RGMII_TD0__RGMII_TD0 | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 94 | IOMUX_PADS(PAD_RGMII_TD1__RGMII_TD1 | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 95 | IOMUX_PADS(PAD_RGMII_TD2__RGMII_TD2 | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 96 | IOMUX_PADS(PAD_RGMII_TD3__RGMII_TD3 | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 97 | IOMUX_PADS(PAD_RGMII_TX_CTL__RGMII_TX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 98 | IOMUX_PADS(PAD_ENET_REF_CLK__ENET_TX_CLK | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 99 | IOMUX_PADS(PAD_RGMII_RXC__RGMII_RXC | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 100 | IOMUX_PADS(PAD_RGMII_RD0__RGMII_RD0 | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 101 | IOMUX_PADS(PAD_RGMII_RD1__RGMII_RD1 | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 102 | IOMUX_PADS(PAD_RGMII_RD2__RGMII_RD2 | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 103 | IOMUX_PADS(PAD_RGMII_RD3__RGMII_RD3 | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 104 | IOMUX_PADS(PAD_RGMII_RX_CTL__RGMII_RX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 105 | /* AR8031 PHY Reset */ |
Fabio Estevam | 1fa6486 | 2015-05-11 20:50:22 -0300 | [diff] [blame] | 106 | IOMUX_PADS(PAD_EIM_D29__GPIO3_IO29 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 107 | }; |
| 108 | |
Fabio Estevam | aec72fb | 2015-05-21 19:24:05 -0300 | [diff] [blame] | 109 | static iomux_v3_cfg_t const rev_detection_pad[] = { |
| 110 | IOMUX_PADS(PAD_EIM_EB0__GPIO2_IO28 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 111 | }; |
| 112 | |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 113 | static void setup_iomux_uart(void) |
| 114 | { |
Fabio Estevam | 1fa6486 | 2015-05-11 20:50:22 -0300 | [diff] [blame] | 115 | SETUP_IOMUX_PADS(uart1_pads); |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | static void setup_iomux_enet(void) |
| 119 | { |
Fabio Estevam | 1fa6486 | 2015-05-11 20:50:22 -0300 | [diff] [blame] | 120 | SETUP_IOMUX_PADS(enet_pads); |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 121 | |
| 122 | /* Reset AR8031 PHY */ |
| 123 | gpio_direction_output(ETH_PHY_RESET, 0); |
Fabio Estevam | 9f4c252 | 2016-01-05 17:02:54 -0200 | [diff] [blame] | 124 | mdelay(10); |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 125 | gpio_set_value(ETH_PHY_RESET, 1); |
Fabio Estevam | 9f4c252 | 2016-01-05 17:02:54 -0200 | [diff] [blame] | 126 | udelay(100); |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 127 | } |
| 128 | |
Otavio Salvador | fe65104 | 2013-04-19 03:42:02 +0000 | [diff] [blame] | 129 | static struct fsl_esdhc_cfg usdhc_cfg[2] = { |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 130 | {USDHC3_BASE_ADDR}, |
Otavio Salvador | fe65104 | 2013-04-19 03:42:02 +0000 | [diff] [blame] | 131 | {USDHC1_BASE_ADDR}, |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 132 | }; |
| 133 | |
Otavio Salvador | 36fda7f | 2013-04-19 03:42:01 +0000 | [diff] [blame] | 134 | int board_mmc_getcd(struct mmc *mmc) |
| 135 | { |
| 136 | struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv; |
| 137 | int ret = 0; |
| 138 | |
| 139 | switch (cfg->esdhc_base) { |
Otavio Salvador | fe65104 | 2013-04-19 03:42:02 +0000 | [diff] [blame] | 140 | case USDHC1_BASE_ADDR: |
| 141 | ret = !gpio_get_value(USDHC1_CD_GPIO); |
| 142 | break; |
Otavio Salvador | 36fda7f | 2013-04-19 03:42:01 +0000 | [diff] [blame] | 143 | case USDHC3_BASE_ADDR: |
| 144 | ret = !gpio_get_value(USDHC3_CD_GPIO); |
| 145 | break; |
| 146 | } |
| 147 | |
| 148 | return ret; |
| 149 | } |
| 150 | |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 151 | int board_mmc_init(bd_t *bis) |
| 152 | { |
Fabio Estevam | 522f059 | 2014-11-15 14:50:26 -0200 | [diff] [blame] | 153 | int ret; |
Otavio Salvador | fe65104 | 2013-04-19 03:42:02 +0000 | [diff] [blame] | 154 | u32 index = 0; |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 155 | |
Otavio Salvador | fe65104 | 2013-04-19 03:42:02 +0000 | [diff] [blame] | 156 | /* |
| 157 | * Following map is done: |
Bin Meng | 7557405 | 2016-02-05 19:30:11 -0800 | [diff] [blame] | 158 | * (U-Boot device node) (Physical Port) |
Otavio Salvador | fe65104 | 2013-04-19 03:42:02 +0000 | [diff] [blame] | 159 | * mmc0 SOM MicroSD |
| 160 | * mmc1 Carrier board MicroSD |
| 161 | */ |
| 162 | for (index = 0; index < CONFIG_SYS_FSL_USDHC_NUM; ++index) { |
| 163 | switch (index) { |
| 164 | case 0: |
Fabio Estevam | 1fa6486 | 2015-05-11 20:50:22 -0300 | [diff] [blame] | 165 | SETUP_IOMUX_PADS(usdhc3_pads); |
Otavio Salvador | fe65104 | 2013-04-19 03:42:02 +0000 | [diff] [blame] | 166 | usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK); |
| 167 | usdhc_cfg[0].max_bus_width = 4; |
| 168 | gpio_direction_input(USDHC3_CD_GPIO); |
| 169 | break; |
| 170 | case 1: |
Fabio Estevam | 1fa6486 | 2015-05-11 20:50:22 -0300 | [diff] [blame] | 171 | SETUP_IOMUX_PADS(usdhc1_pads); |
Otavio Salvador | fe65104 | 2013-04-19 03:42:02 +0000 | [diff] [blame] | 172 | usdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK); |
| 173 | usdhc_cfg[1].max_bus_width = 4; |
| 174 | gpio_direction_input(USDHC1_CD_GPIO); |
| 175 | break; |
| 176 | default: |
| 177 | printf("Warning: you configured more USDHC controllers" |
| 178 | "(%d) then supported by the board (%d)\n", |
| 179 | index + 1, CONFIG_SYS_FSL_USDHC_NUM); |
Fabio Estevam | 522f059 | 2014-11-15 14:50:26 -0200 | [diff] [blame] | 180 | return -EINVAL; |
Otavio Salvador | fe65104 | 2013-04-19 03:42:02 +0000 | [diff] [blame] | 181 | } |
| 182 | |
Fabio Estevam | 522f059 | 2014-11-15 14:50:26 -0200 | [diff] [blame] | 183 | ret = fsl_esdhc_initialize(bis, &usdhc_cfg[index]); |
| 184 | if (ret) |
| 185 | return ret; |
Otavio Salvador | fe65104 | 2013-04-19 03:42:02 +0000 | [diff] [blame] | 186 | } |
Abbas Raza | e6bf977 | 2013-03-25 09:13:34 +0000 | [diff] [blame] | 187 | |
Fabio Estevam | 522f059 | 2014-11-15 14:50:26 -0200 | [diff] [blame] | 188 | return 0; |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 189 | } |
| 190 | |
Fabio Estevam | 0296f28 | 2013-05-23 07:50:23 +0000 | [diff] [blame] | 191 | #if defined(CONFIG_VIDEO_IPUV3) |
Fabio Estevam | 1fa6486 | 2015-05-11 20:50:22 -0300 | [diff] [blame] | 192 | struct i2c_pads_info mx6q_i2c2_pad_info = { |
Otavio Salvador | 1d744d9 | 2014-05-01 19:02:31 -0300 | [diff] [blame] | 193 | .scl = { |
Fabio Estevam | 1fa6486 | 2015-05-11 20:50:22 -0300 | [diff] [blame] | 194 | .i2c_mode = MX6Q_PAD_KEY_COL3__I2C2_SCL |
Otavio Salvador | 1d744d9 | 2014-05-01 19:02:31 -0300 | [diff] [blame] | 195 | | MUX_PAD_CTRL(I2C_PAD_CTRL), |
Fabio Estevam | 1fa6486 | 2015-05-11 20:50:22 -0300 | [diff] [blame] | 196 | .gpio_mode = MX6Q_PAD_KEY_COL3__GPIO4_IO12 |
Otavio Salvador | 1d744d9 | 2014-05-01 19:02:31 -0300 | [diff] [blame] | 197 | | MUX_PAD_CTRL(I2C_PAD_CTRL), |
| 198 | .gp = IMX_GPIO_NR(4, 12) |
| 199 | }, |
| 200 | .sda = { |
Fabio Estevam | 1fa6486 | 2015-05-11 20:50:22 -0300 | [diff] [blame] | 201 | .i2c_mode = MX6Q_PAD_KEY_ROW3__I2C2_SDA |
Otavio Salvador | 1d744d9 | 2014-05-01 19:02:31 -0300 | [diff] [blame] | 202 | | MUX_PAD_CTRL(I2C_PAD_CTRL), |
Fabio Estevam | 1fa6486 | 2015-05-11 20:50:22 -0300 | [diff] [blame] | 203 | .gpio_mode = MX6Q_PAD_KEY_ROW3__GPIO4_IO13 |
Otavio Salvador | 1d744d9 | 2014-05-01 19:02:31 -0300 | [diff] [blame] | 204 | | MUX_PAD_CTRL(I2C_PAD_CTRL), |
| 205 | .gp = IMX_GPIO_NR(4, 13) |
| 206 | } |
Fabio Estevam | 0296f28 | 2013-05-23 07:50:23 +0000 | [diff] [blame] | 207 | }; |
| 208 | |
Fabio Estevam | 1fa6486 | 2015-05-11 20:50:22 -0300 | [diff] [blame] | 209 | struct i2c_pads_info mx6dl_i2c2_pad_info = { |
| 210 | .scl = { |
| 211 | .i2c_mode = MX6DL_PAD_KEY_COL3__I2C2_SCL |
| 212 | | MUX_PAD_CTRL(I2C_PAD_CTRL), |
| 213 | .gpio_mode = MX6DL_PAD_KEY_COL3__GPIO4_IO12 |
| 214 | | MUX_PAD_CTRL(I2C_PAD_CTRL), |
| 215 | .gp = IMX_GPIO_NR(4, 12) |
| 216 | }, |
| 217 | .sda = { |
| 218 | .i2c_mode = MX6DL_PAD_KEY_ROW3__I2C2_SDA |
| 219 | | MUX_PAD_CTRL(I2C_PAD_CTRL), |
| 220 | .gpio_mode = MX6DL_PAD_KEY_ROW3__GPIO4_IO13 |
| 221 | | MUX_PAD_CTRL(I2C_PAD_CTRL), |
| 222 | .gp = IMX_GPIO_NR(4, 13) |
| 223 | } |
| 224 | }; |
Fabio Estevam | 0296f28 | 2013-05-23 07:50:23 +0000 | [diff] [blame] | 225 | |
Fabio Estevam | 1fa6486 | 2015-05-11 20:50:22 -0300 | [diff] [blame] | 226 | static iomux_v3_cfg_t const fwadapt_7wvga_pads[] = { |
| 227 | IOMUX_PADS(PAD_DI0_DISP_CLK__IPU1_DI0_DISP_CLK), |
| 228 | IOMUX_PADS(PAD_DI0_PIN2__IPU1_DI0_PIN02), /* HSync */ |
| 229 | IOMUX_PADS(PAD_DI0_PIN3__IPU1_DI0_PIN03), /* VSync */ |
| 230 | IOMUX_PADS(PAD_DI0_PIN4__IPU1_DI0_PIN04 | MUX_PAD_CTRL(PAD_CTL_DSE_120ohm)), /* Contrast */ |
| 231 | IOMUX_PADS(PAD_DI0_PIN15__IPU1_DI0_PIN15), /* DISP0_DRDY */ |
| 232 | IOMUX_PADS(PAD_DISP0_DAT0__IPU1_DISP0_DATA00), |
| 233 | IOMUX_PADS(PAD_DISP0_DAT1__IPU1_DISP0_DATA01), |
| 234 | IOMUX_PADS(PAD_DISP0_DAT2__IPU1_DISP0_DATA02), |
| 235 | IOMUX_PADS(PAD_DISP0_DAT3__IPU1_DISP0_DATA03), |
| 236 | IOMUX_PADS(PAD_DISP0_DAT4__IPU1_DISP0_DATA04), |
| 237 | IOMUX_PADS(PAD_DISP0_DAT5__IPU1_DISP0_DATA05), |
| 238 | IOMUX_PADS(PAD_DISP0_DAT6__IPU1_DISP0_DATA06), |
| 239 | IOMUX_PADS(PAD_DISP0_DAT7__IPU1_DISP0_DATA07), |
| 240 | IOMUX_PADS(PAD_DISP0_DAT8__IPU1_DISP0_DATA08), |
| 241 | IOMUX_PADS(PAD_DISP0_DAT9__IPU1_DISP0_DATA09), |
| 242 | IOMUX_PADS(PAD_DISP0_DAT10__IPU1_DISP0_DATA10), |
| 243 | IOMUX_PADS(PAD_DISP0_DAT11__IPU1_DISP0_DATA11), |
| 244 | IOMUX_PADS(PAD_DISP0_DAT12__IPU1_DISP0_DATA12), |
| 245 | IOMUX_PADS(PAD_DISP0_DAT13__IPU1_DISP0_DATA13), |
| 246 | IOMUX_PADS(PAD_DISP0_DAT14__IPU1_DISP0_DATA14), |
| 247 | IOMUX_PADS(PAD_DISP0_DAT15__IPU1_DISP0_DATA15), |
| 248 | IOMUX_PADS(PAD_DISP0_DAT16__IPU1_DISP0_DATA16), |
| 249 | IOMUX_PADS(PAD_DISP0_DAT17__IPU1_DISP0_DATA17), |
| 250 | IOMUX_PADS(PAD_SD4_DAT2__GPIO2_IO10 | MUX_PAD_CTRL(NO_PAD_CTRL)), /* DISP0_BKLEN */ |
| 251 | IOMUX_PADS(PAD_SD4_DAT3__GPIO2_IO11 | MUX_PAD_CTRL(NO_PAD_CTRL)), /* DISP0_VDDEN */ |
Otavio Salvador | 1d744d9 | 2014-05-01 19:02:31 -0300 | [diff] [blame] | 252 | }; |
Fabio Estevam | 0296f28 | 2013-05-23 07:50:23 +0000 | [diff] [blame] | 253 | |
Otavio Salvador | 1d744d9 | 2014-05-01 19:02:31 -0300 | [diff] [blame] | 254 | static void do_enable_hdmi(struct display_info_t const *dev) |
| 255 | { |
Pardeep Kumar Singla | c1fa130 | 2013-07-25 12:12:13 -0500 | [diff] [blame] | 256 | imx_enable_hdmi_phy(); |
Otavio Salvador | 1d744d9 | 2014-05-01 19:02:31 -0300 | [diff] [blame] | 257 | } |
Fabio Estevam | 0296f28 | 2013-05-23 07:50:23 +0000 | [diff] [blame] | 258 | |
Otavio Salvador | 1d744d9 | 2014-05-01 19:02:31 -0300 | [diff] [blame] | 259 | static int detect_i2c(struct display_info_t const *dev) |
| 260 | { |
| 261 | return (0 == i2c_set_bus_num(dev->bus)) && |
| 262 | (0 == i2c_probe(dev->addr)); |
| 263 | } |
| 264 | |
| 265 | static void enable_fwadapt_7wvga(struct display_info_t const *dev) |
| 266 | { |
Fabio Estevam | 1fa6486 | 2015-05-11 20:50:22 -0300 | [diff] [blame] | 267 | SETUP_IOMUX_PADS(fwadapt_7wvga_pads); |
Otavio Salvador | 1d744d9 | 2014-05-01 19:02:31 -0300 | [diff] [blame] | 268 | |
| 269 | gpio_direction_output(IMX_GPIO_NR(2, 10), 1); |
| 270 | gpio_direction_output(IMX_GPIO_NR(2, 11), 1); |
Fabio Estevam | 0296f28 | 2013-05-23 07:50:23 +0000 | [diff] [blame] | 271 | } |
| 272 | |
Otavio Salvador | 1d744d9 | 2014-05-01 19:02:31 -0300 | [diff] [blame] | 273 | struct display_info_t const displays[] = {{ |
| 274 | .bus = -1, |
| 275 | .addr = 0, |
| 276 | .pixfmt = IPU_PIX_FMT_RGB24, |
| 277 | .detect = detect_hdmi, |
| 278 | .enable = do_enable_hdmi, |
| 279 | .mode = { |
| 280 | .name = "HDMI", |
| 281 | .refresh = 60, |
| 282 | .xres = 1024, |
| 283 | .yres = 768, |
| 284 | .pixclock = 15385, |
| 285 | .left_margin = 220, |
| 286 | .right_margin = 40, |
| 287 | .upper_margin = 21, |
| 288 | .lower_margin = 7, |
| 289 | .hsync_len = 60, |
| 290 | .vsync_len = 10, |
| 291 | .sync = FB_SYNC_EXT, |
| 292 | .vmode = FB_VMODE_NONINTERLACED |
| 293 | } }, { |
| 294 | .bus = 1, |
| 295 | .addr = 0x10, |
| 296 | .pixfmt = IPU_PIX_FMT_RGB666, |
| 297 | .detect = detect_i2c, |
| 298 | .enable = enable_fwadapt_7wvga, |
| 299 | .mode = { |
| 300 | .name = "FWBADAPT-LCD-F07A-0102", |
| 301 | .refresh = 60, |
| 302 | .xres = 800, |
| 303 | .yres = 480, |
| 304 | .pixclock = 33260, |
| 305 | .left_margin = 128, |
| 306 | .right_margin = 128, |
| 307 | .upper_margin = 22, |
| 308 | .lower_margin = 22, |
| 309 | .hsync_len = 1, |
| 310 | .vsync_len = 1, |
| 311 | .sync = 0, |
| 312 | .vmode = FB_VMODE_NONINTERLACED |
| 313 | } } }; |
| 314 | size_t display_count = ARRAY_SIZE(displays); |
| 315 | |
Fabio Estevam | 0296f28 | 2013-05-23 07:50:23 +0000 | [diff] [blame] | 316 | static void setup_display(void) |
| 317 | { |
| 318 | 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] | 319 | int reg; |
| 320 | |
Pardeep Kumar Singla | c1fa130 | 2013-07-25 12:12:13 -0500 | [diff] [blame] | 321 | enable_ipu_clock(); |
| 322 | imx_setup_hdmi(); |
Fabio Estevam | 0296f28 | 2013-05-23 07:50:23 +0000 | [diff] [blame] | 323 | |
| 324 | reg = readl(&mxc_ccm->chsccdr); |
Fabio Estevam | 0296f28 | 2013-05-23 07:50:23 +0000 | [diff] [blame] | 325 | reg |= (CHSCCDR_CLK_SEL_LDB_DI0 |
Pardeep Kumar Singla | c1fa130 | 2013-07-25 12:12:13 -0500 | [diff] [blame] | 326 | << MXC_CCM_CHSCCDR_IPU1_DI0_CLK_SEL_OFFSET); |
Fabio Estevam | 0296f28 | 2013-05-23 07:50:23 +0000 | [diff] [blame] | 327 | writel(reg, &mxc_ccm->chsccdr); |
Otavio Salvador | 1d744d9 | 2014-05-01 19:02:31 -0300 | [diff] [blame] | 328 | |
| 329 | /* Disable LCD backlight */ |
Fabio Estevam | 1fa6486 | 2015-05-11 20:50:22 -0300 | [diff] [blame] | 330 | SETUP_IOMUX_PAD(PAD_DI0_PIN4__GPIO4_IO20); |
Otavio Salvador | 1d744d9 | 2014-05-01 19:02:31 -0300 | [diff] [blame] | 331 | gpio_direction_input(IMX_GPIO_NR(4, 20)); |
Fabio Estevam | 0296f28 | 2013-05-23 07:50:23 +0000 | [diff] [blame] | 332 | } |
| 333 | #endif /* CONFIG_VIDEO_IPUV3 */ |
| 334 | |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 335 | int board_eth_init(bd_t *bis) |
| 336 | { |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 337 | setup_iomux_enet(); |
| 338 | |
Fabio Estevam | c3cc305 | 2014-01-04 17:36:28 -0200 | [diff] [blame] | 339 | return cpu_eth_init(bis); |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | int board_early_init_f(void) |
| 343 | { |
| 344 | setup_iomux_uart(); |
Fabio Estevam | 0296f28 | 2013-05-23 07:50:23 +0000 | [diff] [blame] | 345 | #if defined(CONFIG_VIDEO_IPUV3) |
| 346 | setup_display(); |
| 347 | #endif |
Gilles Chanteperdrix | b99d664 | 2016-06-09 10:33:27 +0200 | [diff] [blame] | 348 | #ifdef CONFIG_CMD_SATA |
| 349 | /* Only mx6q wandboard has SATA */ |
| 350 | if (is_cpu_type(MXC_CPU_MX6Q)) |
| 351 | setup_sata(); |
| 352 | #endif |
| 353 | |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 354 | return 0; |
| 355 | } |
| 356 | |
Fabio Estevam | 0296f28 | 2013-05-23 07:50:23 +0000 | [diff] [blame] | 357 | /* |
| 358 | * Do not overwrite the console |
| 359 | * Use always serial for U-Boot console |
| 360 | */ |
| 361 | int overwrite_console(void) |
| 362 | { |
| 363 | return 1; |
| 364 | } |
| 365 | |
Otavio Salvador | 54b8ce2 | 2013-04-19 03:42:03 +0000 | [diff] [blame] | 366 | #ifdef CONFIG_CMD_BMODE |
| 367 | static const struct boot_mode board_boot_modes[] = { |
| 368 | /* 4 bit bus width */ |
| 369 | {"mmc0", MAKE_CFGVAL(0x40, 0x30, 0x00, 0x00)}, |
| 370 | {"mmc1", MAKE_CFGVAL(0x40, 0x20, 0x00, 0x00)}, |
| 371 | {NULL, 0}, |
| 372 | }; |
| 373 | #endif |
| 374 | |
Fabio Estevam | aec72fb | 2015-05-21 19:24:05 -0300 | [diff] [blame] | 375 | static bool is_revc1(void) |
| 376 | { |
| 377 | SETUP_IOMUX_PADS(rev_detection_pad); |
| 378 | gpio_direction_input(REV_DETECTION); |
| 379 | |
| 380 | if (gpio_get_value(REV_DETECTION)) |
| 381 | return true; |
| 382 | else |
| 383 | return false; |
| 384 | } |
| 385 | |
Otavio Salvador | 54b8ce2 | 2013-04-19 03:42:03 +0000 | [diff] [blame] | 386 | int board_late_init(void) |
| 387 | { |
| 388 | #ifdef CONFIG_CMD_BMODE |
| 389 | add_board_boot_modes(board_boot_modes); |
| 390 | #endif |
| 391 | |
Fabio Estevam | 1fa6486 | 2015-05-11 20:50:22 -0300 | [diff] [blame] | 392 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
| 393 | if (is_cpu_type(MXC_CPU_MX6Q) || is_cpu_type(MXC_CPU_MX6D)) |
| 394 | setenv("board_rev", "MX6Q"); |
| 395 | else |
| 396 | setenv("board_rev", "MX6DL"); |
Fabio Estevam | aec72fb | 2015-05-21 19:24:05 -0300 | [diff] [blame] | 397 | |
| 398 | if (is_revc1()) |
| 399 | setenv("board_name", "C1"); |
| 400 | else |
| 401 | setenv("board_name", "B1"); |
Fabio Estevam | 1fa6486 | 2015-05-11 20:50:22 -0300 | [diff] [blame] | 402 | #endif |
Otavio Salvador | 54b8ce2 | 2013-04-19 03:42:03 +0000 | [diff] [blame] | 403 | return 0; |
| 404 | } |
| 405 | |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 406 | int board_init(void) |
| 407 | { |
| 408 | /* address of boot parameters */ |
| 409 | gd->bd->bi_boot_params = PHYS_SDRAM + 0x100; |
| 410 | |
Fabio Estevam | 1fa6486 | 2015-05-11 20:50:22 -0300 | [diff] [blame] | 411 | setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, &mx6dl_i2c2_pad_info); |
| 412 | if (is_cpu_type(MXC_CPU_MX6Q) || is_cpu_type(MXC_CPU_MX6D)) |
| 413 | setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, &mx6q_i2c2_pad_info); |
| 414 | else |
| 415 | setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, &mx6dl_i2c2_pad_info); |
Otavio Salvador | 1d744d9 | 2014-05-01 19:02:31 -0300 | [diff] [blame] | 416 | |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 417 | return 0; |
| 418 | } |
| 419 | |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 420 | int checkboard(void) |
| 421 | { |
Fabio Estevam | aec72fb | 2015-05-21 19:24:05 -0300 | [diff] [blame] | 422 | if (is_revc1()) |
| 423 | puts("Board: Wandboard rev C1\n"); |
| 424 | else |
| 425 | puts("Board: Wandboard rev B1\n"); |
Fabio Estevam | 1102740 | 2013-03-15 10:43:48 +0000 | [diff] [blame] | 426 | |
| 427 | return 0; |
| 428 | } |