blob: 369da6de5be9e517f7469f596be3d504c1626916 [file] [log] [blame]
Stefano Babicc5fb70c2010-02-05 15:13:58 +01001/*
2 * (C) Copyright 2009 Freescale Semiconductor, Inc.
3 *
4 * See file CREDITS for list of people who contributed to this
5 * project.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 * MA 02111-1307 USA
21 */
22
23#include <common.h>
24#include <asm/io.h>
Stefano Babic753fc2e2011-08-21 23:29:52 +020025#include <asm/gpio.h>
Stefano Babicc5fb70c2010-02-05 15:13:58 +010026#include <asm/arch/imx-regs.h>
Benoît Thébaudeau4d15d362013-05-03 10:32:27 +000027#include <asm/arch/iomux-mx51.h>
Stefano Babicc5fb70c2010-02-05 15:13:58 +010028#include <asm/errno.h>
Stefano Babice4d34492010-03-05 17:54:37 +010029#include <asm/arch/sys_proto.h>
Stefano Babicb4377e12010-03-16 17:22:21 +010030#include <asm/arch/crm_regs.h>
Benoît Thébaudeaua2ac1b32012-10-01 08:36:25 +000031#include <asm/arch/clock.h>
Vikram Narayanan5d71bd22012-11-10 02:28:52 +000032#include <asm/imx-common/mx5_video.h>
Stefano Babicc5fb70c2010-02-05 15:13:58 +010033#include <i2c.h>
34#include <mmc.h>
35#include <fsl_esdhc.h>
Łukasz Majewskic7336812012-11-13 03:21:55 +000036#include <power/pmic.h>
Stefano Babicb4377e12010-03-16 17:22:21 +010037#include <fsl_pmic.h>
38#include <mc13892.h>
Wolfgang Grandegger055d9692011-11-11 14:03:38 +010039#include <usb/ehci-fsl.h>
Stefano Babicc5fb70c2010-02-05 15:13:58 +010040
41DECLARE_GLOBAL_DATA_PTR;
42
Stefano Babicc5fb70c2010-02-05 15:13:58 +010043#ifdef CONFIG_FSL_ESDHC
44struct fsl_esdhc_cfg esdhc_cfg[2] = {
Benoît Thébaudeau16e43f32012-08-13 07:28:16 +000045 {MMC_SDHC1_BASE_ADDR},
46 {MMC_SDHC2_BASE_ADDR},
Stefano Babicc5fb70c2010-02-05 15:13:58 +010047};
48#endif
49
Stefano Babicc5fb70c2010-02-05 15:13:58 +010050int dram_init(void)
51{
Shawn Guo1ab027c2010-10-28 10:13:15 +080052 /* dram_init must store complete ramsize in gd->ram_size */
Albert ARIBAUDa55d23c2011-07-03 05:55:33 +000053 gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
Shawn Guo1ab027c2010-10-28 10:13:15 +080054 PHYS_SDRAM_1_SIZE);
Stefano Babicc5fb70c2010-02-05 15:13:58 +010055 return 0;
56}
57
Benoît Thébaudeau362635b2012-09-18 04:48:42 +000058u32 get_board_rev(void)
59{
60 u32 rev = get_cpu_rev();
61 if (!gpio_get_value(IMX_GPIO_NR(1, 22)))
62 rev |= BOARD_REV_2_0 << BOARD_VER_OFFSET;
63 return rev;
64}
65
Benoît Thébaudeau4d15d362013-05-03 10:32:27 +000066#define UART_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_PUS_100K_DOWN | PAD_CTL_DSE_HIGH)
67
Stefano Babicc5fb70c2010-02-05 15:13:58 +010068static void setup_iomux_uart(void)
69{
Benoît Thébaudeau4d15d362013-05-03 10:32:27 +000070 static const iomux_v3_cfg_t uart_pads[] = {
71 MX51_PAD_UART1_RXD__UART1_RXD,
72 MX51_PAD_UART1_TXD__UART1_TXD,
73 NEW_PAD_CTRL(MX51_PAD_UART1_RTS__UART1_RTS, UART_PAD_CTRL),
74 NEW_PAD_CTRL(MX51_PAD_UART1_CTS__UART1_CTS, UART_PAD_CTRL),
75 };
Stefano Babicc5fb70c2010-02-05 15:13:58 +010076
Benoît Thébaudeau4d15d362013-05-03 10:32:27 +000077 imx_iomux_v3_setup_multiple_pads(uart_pads, ARRAY_SIZE(uart_pads));
Stefano Babicc5fb70c2010-02-05 15:13:58 +010078}
79
Stefano Babicc5fb70c2010-02-05 15:13:58 +010080static void setup_iomux_fec(void)
81{
Benoît Thébaudeau4d15d362013-05-03 10:32:27 +000082 static const iomux_v3_cfg_t fec_pads[] = {
83 NEW_PAD_CTRL(MX51_PAD_EIM_EB2__FEC_MDIO, PAD_CTL_HYS |
84 PAD_CTL_PUS_22K_UP | PAD_CTL_ODE |
85 PAD_CTL_DSE_HIGH | PAD_CTL_SRE_FAST),
86 MX51_PAD_NANDF_CS3__FEC_MDC,
87 NEW_PAD_CTRL(MX51_PAD_EIM_CS3__FEC_RDATA3, MX51_PAD_CTRL_2),
88 NEW_PAD_CTRL(MX51_PAD_EIM_CS2__FEC_RDATA2, MX51_PAD_CTRL_2),
89 NEW_PAD_CTRL(MX51_PAD_EIM_EB3__FEC_RDATA1, MX51_PAD_CTRL_2),
90 MX51_PAD_NANDF_D9__FEC_RDATA0,
91 MX51_PAD_NANDF_CS6__FEC_TDATA3,
92 MX51_PAD_NANDF_CS5__FEC_TDATA2,
93 MX51_PAD_NANDF_CS4__FEC_TDATA1,
94 MX51_PAD_NANDF_D8__FEC_TDATA0,
95 MX51_PAD_NANDF_CS7__FEC_TX_EN,
96 MX51_PAD_NANDF_CS2__FEC_TX_ER,
97 MX51_PAD_NANDF_RDY_INT__FEC_TX_CLK,
98 NEW_PAD_CTRL(MX51_PAD_NANDF_RB2__FEC_COL, MX51_PAD_CTRL_4),
99 NEW_PAD_CTRL(MX51_PAD_NANDF_RB3__FEC_RX_CLK, MX51_PAD_CTRL_4),
100 MX51_PAD_EIM_CS5__FEC_CRS,
101 MX51_PAD_EIM_CS4__FEC_RX_ER,
102 NEW_PAD_CTRL(MX51_PAD_NANDF_D11__FEC_RX_DV, MX51_PAD_CTRL_4),
103 };
Stefano Babicc5fb70c2010-02-05 15:13:58 +0100104
Benoît Thébaudeau4d15d362013-05-03 10:32:27 +0000105 imx_iomux_v3_setup_multiple_pads(fec_pads, ARRAY_SIZE(fec_pads));
Stefano Babicc5fb70c2010-02-05 15:13:58 +0100106}
107
Stefano Babicb4377e12010-03-16 17:22:21 +0100108#ifdef CONFIG_MXC_SPI
109static void setup_iomux_spi(void)
110{
Benoît Thébaudeau4d15d362013-05-03 10:32:27 +0000111 static const iomux_v3_cfg_t spi_pads[] = {
112 NEW_PAD_CTRL(MX51_PAD_CSPI1_MOSI__ECSPI1_MOSI, PAD_CTL_HYS |
113 PAD_CTL_DSE_HIGH | PAD_CTL_SRE_FAST),
114 NEW_PAD_CTRL(MX51_PAD_CSPI1_MISO__ECSPI1_MISO, PAD_CTL_HYS |
115 PAD_CTL_DSE_HIGH | PAD_CTL_SRE_FAST),
116 NEW_PAD_CTRL(MX51_PAD_CSPI1_SS1__ECSPI1_SS1,
117 MX51_GPIO_PAD_CTRL),
118 MX51_PAD_CSPI1_SS0__ECSPI1_SS0,
119 NEW_PAD_CTRL(MX51_PAD_CSPI1_RDY__ECSPI1_RDY, MX51_PAD_CTRL_2),
120 NEW_PAD_CTRL(MX51_PAD_CSPI1_SCLK__ECSPI1_SCLK, PAD_CTL_HYS |
121 PAD_CTL_DSE_HIGH | PAD_CTL_SRE_FAST),
122 };
Stefano Babicb4377e12010-03-16 17:22:21 +0100123
Benoît Thébaudeau4d15d362013-05-03 10:32:27 +0000124 imx_iomux_v3_setup_multiple_pads(spi_pads, ARRAY_SIZE(spi_pads));
Stefano Babicb4377e12010-03-16 17:22:21 +0100125}
126#endif
127
Wolfgang Grandegger055d9692011-11-11 14:03:38 +0100128#ifdef CONFIG_USB_EHCI_MX5
Benoît Thébaudeau4d15d362013-05-03 10:32:27 +0000129#define MX51EVK_USBH1_HUB_RST IMX_GPIO_NR(1, 7)
130#define MX51EVK_USBH1_STP IMX_GPIO_NR(1, 27)
131#define MX51EVK_USB_CLK_EN_B IMX_GPIO_NR(2, 2)
132#define MX51EVK_USB_PHY_RESET IMX_GPIO_NR(2, 5)
Wolfgang Grandegger055d9692011-11-11 14:03:38 +0100133
134static void setup_usb_h1(void)
135{
Benoît Thébaudeau4d15d362013-05-03 10:32:27 +0000136 static const iomux_v3_cfg_t usb_h1_pads[] = {
137 MX51_PAD_USBH1_CLK__USBH1_CLK,
138 MX51_PAD_USBH1_DIR__USBH1_DIR,
139 MX51_PAD_USBH1_STP__USBH1_STP,
140 MX51_PAD_USBH1_NXT__USBH1_NXT,
141 MX51_PAD_USBH1_DATA0__USBH1_DATA0,
142 MX51_PAD_USBH1_DATA1__USBH1_DATA1,
143 MX51_PAD_USBH1_DATA2__USBH1_DATA2,
144 MX51_PAD_USBH1_DATA3__USBH1_DATA3,
145 MX51_PAD_USBH1_DATA4__USBH1_DATA4,
146 MX51_PAD_USBH1_DATA5__USBH1_DATA5,
147 MX51_PAD_USBH1_DATA6__USBH1_DATA6,
148 MX51_PAD_USBH1_DATA7__USBH1_DATA7,
Wolfgang Grandegger055d9692011-11-11 14:03:38 +0100149
Benoît Thébaudeau4d15d362013-05-03 10:32:27 +0000150 NEW_PAD_CTRL(MX51_PAD_GPIO1_7__GPIO1_7, 0), /* H1 hub reset */
151 MX51_PAD_EIM_D17__GPIO2_1,
152 MX51_PAD_EIM_D21__GPIO2_5, /* PHY reset */
153 };
Wolfgang Grandegger055d9692011-11-11 14:03:38 +0100154
Benoît Thébaudeau4d15d362013-05-03 10:32:27 +0000155 imx_iomux_v3_setup_multiple_pads(usb_h1_pads, ARRAY_SIZE(usb_h1_pads));
Wolfgang Grandegger055d9692011-11-11 14:03:38 +0100156}
157
Anatolij Gustschin60bae5e2011-12-12 01:25:46 +0000158int board_ehci_hcd_init(int port)
Wolfgang Grandegger055d9692011-11-11 14:03:38 +0100159{
160 /* Set USBH1_STP to GPIO and toggle it */
Benoît Thébaudeau4d15d362013-05-03 10:32:27 +0000161 imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_USBH1_STP__GPIO1_27,
162 MX51_USBH_PAD_CTRL));
Wolfgang Grandegger055d9692011-11-11 14:03:38 +0100163
164 gpio_direction_output(MX51EVK_USBH1_STP, 0);
165 gpio_direction_output(MX51EVK_USB_PHY_RESET, 0);
166 mdelay(10);
167 gpio_set_value(MX51EVK_USBH1_STP, 1);
168
169 /* Set back USBH1_STP to be function */
Benoît Thébaudeau4d15d362013-05-03 10:32:27 +0000170 imx_iomux_v3_setup_pad(MX51_PAD_USBH1_STP__USBH1_STP);
Wolfgang Grandegger055d9692011-11-11 14:03:38 +0100171
172 /* De-assert USB PHY RESETB */
173 gpio_set_value(MX51EVK_USB_PHY_RESET, 1);
174
175 /* Drive USB_CLK_EN_B line low */
176 gpio_direction_output(MX51EVK_USB_CLK_EN_B, 0);
177
178 /* Reset USB hub */
179 gpio_direction_output(MX51EVK_USBH1_HUB_RST, 0);
180 mdelay(2);
181 gpio_set_value(MX51EVK_USBH1_HUB_RST, 1);
Anatolij Gustschin60bae5e2011-12-12 01:25:46 +0000182 return 0;
Wolfgang Grandegger055d9692011-11-11 14:03:38 +0100183}
184#endif
185
Stefano Babicb4377e12010-03-16 17:22:21 +0100186static void power_init(void)
187{
188 unsigned int val;
Stefano Babicb4377e12010-03-16 17:22:21 +0100189 struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)MXC_CCM_BASE;
Stefano Babic53572652011-10-08 10:59:20 +0200190 struct pmic *p;
Łukasz Majewskic7336812012-11-13 03:21:55 +0000191 int ret;
Stefano Babic53572652011-10-08 10:59:20 +0200192
Łukasz Majewskic7336812012-11-13 03:21:55 +0000193 ret = pmic_init(I2C_PMIC);
194 if (ret)
195 return;
196
197 p = pmic_get("FSL_PMIC");
198 if (!p)
199 return;
Stefano Babicb4377e12010-03-16 17:22:21 +0100200
201 /* Write needed to Power Gate 2 register */
Stefano Babic53572652011-10-08 10:59:20 +0200202 pmic_reg_read(p, REG_POWER_MISC, &val);
Stefano Babicb4377e12010-03-16 17:22:21 +0100203 val &= ~PWGT2SPIEN;
Stefano Babic53572652011-10-08 10:59:20 +0200204 pmic_reg_write(p, REG_POWER_MISC, val);
Stefano Babicb4377e12010-03-16 17:22:21 +0100205
Shawn Guo888b4f42010-10-27 23:36:04 +0800206 /* Externally powered */
Stefano Babic53572652011-10-08 10:59:20 +0200207 pmic_reg_read(p, REG_CHARGE, &val);
Shawn Guo888b4f42010-10-27 23:36:04 +0800208 val |= ICHRG0 | ICHRG1 | ICHRG2 | ICHRG3 | CHGAUTOB;
Stefano Babic53572652011-10-08 10:59:20 +0200209 pmic_reg_write(p, REG_CHARGE, val);
Stefano Babicb4377e12010-03-16 17:22:21 +0100210
211 /* power up the system first */
Stefano Babic53572652011-10-08 10:59:20 +0200212 pmic_reg_write(p, REG_POWER_MISC, PWUP);
Stefano Babicb4377e12010-03-16 17:22:21 +0100213
214 /* Set core voltage to 1.1V */
Stefano Babic53572652011-10-08 10:59:20 +0200215 pmic_reg_read(p, REG_SW_0, &val);
Marek Vasutc4a3c742011-01-19 04:40:36 +0000216 val = (val & ~SWx_VOLT_MASK) | SWx_1_100V;
Stefano Babic53572652011-10-08 10:59:20 +0200217 pmic_reg_write(p, REG_SW_0, val);
Stefano Babicb4377e12010-03-16 17:22:21 +0100218
219 /* Setup VCC (SW2) to 1.25 */
Stefano Babic53572652011-10-08 10:59:20 +0200220 pmic_reg_read(p, REG_SW_1, &val);
Marek Vasutc4a3c742011-01-19 04:40:36 +0000221 val = (val & ~SWx_VOLT_MASK) | SWx_1_250V;
Stefano Babic53572652011-10-08 10:59:20 +0200222 pmic_reg_write(p, REG_SW_1, val);
Stefano Babicb4377e12010-03-16 17:22:21 +0100223
224 /* Setup 1V2_DIG1 (SW3) to 1.25 */
Stefano Babic53572652011-10-08 10:59:20 +0200225 pmic_reg_read(p, REG_SW_2, &val);
Marek Vasutc4a3c742011-01-19 04:40:36 +0000226 val = (val & ~SWx_VOLT_MASK) | SWx_1_250V;
Stefano Babic53572652011-10-08 10:59:20 +0200227 pmic_reg_write(p, REG_SW_2, val);
Stefano Babicb4377e12010-03-16 17:22:21 +0100228 udelay(50);
229
230 /* Raise the core frequency to 800MHz */
231 writel(0x0, &mxc_ccm->cacrr);
232
233 /* Set switchers in Auto in NORMAL mode & STANDBY mode */
234 /* Setup the switcher mode for SW1 & SW2*/
Stefano Babic53572652011-10-08 10:59:20 +0200235 pmic_reg_read(p, REG_SW_4, &val);
Stefano Babicb4377e12010-03-16 17:22:21 +0100236 val = (val & ~((SWMODE_MASK << SWMODE1_SHIFT) |
237 (SWMODE_MASK << SWMODE2_SHIFT)));
238 val |= (SWMODE_AUTO_AUTO << SWMODE1_SHIFT) |
239 (SWMODE_AUTO_AUTO << SWMODE2_SHIFT);
Stefano Babic53572652011-10-08 10:59:20 +0200240 pmic_reg_write(p, REG_SW_4, val);
Stefano Babicb4377e12010-03-16 17:22:21 +0100241
242 /* Setup the switcher mode for SW3 & SW4 */
Stefano Babic53572652011-10-08 10:59:20 +0200243 pmic_reg_read(p, REG_SW_5, &val);
Stefano Babicb4377e12010-03-16 17:22:21 +0100244 val = (val & ~((SWMODE_MASK << SWMODE3_SHIFT) |
245 (SWMODE_MASK << SWMODE4_SHIFT)));
246 val |= (SWMODE_AUTO_AUTO << SWMODE3_SHIFT) |
247 (SWMODE_AUTO_AUTO << SWMODE4_SHIFT);
Stefano Babic53572652011-10-08 10:59:20 +0200248 pmic_reg_write(p, REG_SW_5, val);
Stefano Babicb4377e12010-03-16 17:22:21 +0100249
250 /* Set VDIG to 1.65V, VGEN3 to 1.8V, VCAM to 2.6V */
Stefano Babic53572652011-10-08 10:59:20 +0200251 pmic_reg_read(p, REG_SETTING_0, &val);
Stefano Babicb4377e12010-03-16 17:22:21 +0100252 val &= ~(VCAM_MASK | VGEN3_MASK | VDIG_MASK);
253 val |= VDIG_1_65 | VGEN3_1_8 | VCAM_2_6;
Stefano Babic53572652011-10-08 10:59:20 +0200254 pmic_reg_write(p, REG_SETTING_0, val);
Stefano Babicb4377e12010-03-16 17:22:21 +0100255
256 /* Set VVIDEO to 2.775V, VAUDIO to 3V, VSD to 3.15V */
Stefano Babic53572652011-10-08 10:59:20 +0200257 pmic_reg_read(p, REG_SETTING_1, &val);
Stefano Babicb4377e12010-03-16 17:22:21 +0100258 val &= ~(VVIDEO_MASK | VSD_MASK | VAUDIO_MASK);
259 val |= VSD_3_15 | VAUDIO_3_0 | VVIDEO_2_775;
Stefano Babic53572652011-10-08 10:59:20 +0200260 pmic_reg_write(p, REG_SETTING_1, val);
Stefano Babicb4377e12010-03-16 17:22:21 +0100261
262 /* Configure VGEN3 and VCAM regulators to use external PNP */
263 val = VGEN3CONFIG | VCAMCONFIG;
Stefano Babic53572652011-10-08 10:59:20 +0200264 pmic_reg_write(p, REG_MODE_1, val);
Stefano Babicb4377e12010-03-16 17:22:21 +0100265 udelay(200);
266
Stefano Babicb4377e12010-03-16 17:22:21 +0100267 /* Enable VGEN3, VCAM, VAUDIO, VVIDEO, VSD regulators */
268 val = VGEN3EN | VGEN3CONFIG | VCAMEN | VCAMCONFIG |
269 VVIDEOEN | VAUDIOEN | VSDEN;
Stefano Babic53572652011-10-08 10:59:20 +0200270 pmic_reg_write(p, REG_MODE_1, val);
Stefano Babicb4377e12010-03-16 17:22:21 +0100271
Benoît Thébaudeau4d15d362013-05-03 10:32:27 +0000272 imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_EIM_A20__GPIO2_14,
273 NO_PAD_CTRL));
Ashok Kumar Reddy92550702012-08-28 07:39:38 +0530274 gpio_direction_output(IMX_GPIO_NR(2, 14), 0);
Fabio Estevamd736ebe2011-10-25 03:14:00 +0000275
Stefano Babicb4377e12010-03-16 17:22:21 +0100276 udelay(500);
277
Ashok Kumar Reddy92550702012-08-28 07:39:38 +0530278 gpio_set_value(IMX_GPIO_NR(2, 14), 1);
Stefano Babicb4377e12010-03-16 17:22:21 +0100279}
280
Stefano Babicc5fb70c2010-02-05 15:13:58 +0100281#ifdef CONFIG_FSL_ESDHC
Thierry Reding314284b2012-01-02 01:15:36 +0000282int board_mmc_getcd(struct mmc *mmc)
Stefano Babicc5fb70c2010-02-05 15:13:58 +0100283{
284 struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
Thierry Reding314284b2012-01-02 01:15:36 +0000285 int ret;
Stefano Babicc5fb70c2010-02-05 15:13:58 +0100286
Benoît Thébaudeau4d15d362013-05-03 10:32:27 +0000287 imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_GPIO1_0__GPIO1_0,
288 NO_PAD_CTRL));
Ashok Kumar Reddy92550702012-08-28 07:39:38 +0530289 gpio_direction_input(IMX_GPIO_NR(1, 0));
Benoît Thébaudeau4d15d362013-05-03 10:32:27 +0000290 imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_GPIO1_6__GPIO1_6,
291 NO_PAD_CTRL));
Ashok Kumar Reddy92550702012-08-28 07:39:38 +0530292 gpio_direction_input(IMX_GPIO_NR(1, 6));
Fabio Estevam58aef722011-11-15 05:51:33 +0000293
Stefano Babicc5fb70c2010-02-05 15:13:58 +0100294 if (cfg->esdhc_base == MMC_SDHC1_BASE_ADDR)
Ashok Kumar Reddy92550702012-08-28 07:39:38 +0530295 ret = !gpio_get_value(IMX_GPIO_NR(1, 0));
Stefano Babicc5fb70c2010-02-05 15:13:58 +0100296 else
Ashok Kumar Reddy92550702012-08-28 07:39:38 +0530297 ret = !gpio_get_value(IMX_GPIO_NR(1, 6));
Stefano Babicc5fb70c2010-02-05 15:13:58 +0100298
Thierry Reding314284b2012-01-02 01:15:36 +0000299 return ret;
Stefano Babicc5fb70c2010-02-05 15:13:58 +0100300}
301
302int board_mmc_init(bd_t *bis)
303{
Benoît Thébaudeau4d15d362013-05-03 10:32:27 +0000304 static const iomux_v3_cfg_t sd1_pads[] = {
305 NEW_PAD_CTRL(MX51_PAD_SD1_CMD__SD1_CMD, PAD_CTL_DSE_MAX |
306 PAD_CTL_HYS | PAD_CTL_PUS_47K_UP | PAD_CTL_SRE_FAST),
307 NEW_PAD_CTRL(MX51_PAD_SD1_CLK__SD1_CLK, PAD_CTL_DSE_MAX |
308 PAD_CTL_PUS_47K_UP | PAD_CTL_SRE_FAST),
309 NEW_PAD_CTRL(MX51_PAD_SD1_DATA0__SD1_DATA0, PAD_CTL_DSE_MAX |
310 PAD_CTL_HYS | PAD_CTL_PUS_47K_UP | PAD_CTL_SRE_FAST),
311 NEW_PAD_CTRL(MX51_PAD_SD1_DATA1__SD1_DATA1, PAD_CTL_DSE_MAX |
312 PAD_CTL_HYS | PAD_CTL_PUS_47K_UP | PAD_CTL_SRE_FAST),
313 NEW_PAD_CTRL(MX51_PAD_SD1_DATA2__SD1_DATA2, PAD_CTL_DSE_MAX |
314 PAD_CTL_HYS | PAD_CTL_PUS_47K_UP | PAD_CTL_SRE_FAST),
315 NEW_PAD_CTRL(MX51_PAD_SD1_DATA3__SD1_DATA3, PAD_CTL_DSE_MAX |
316 PAD_CTL_HYS | PAD_CTL_PUS_100K_DOWN | PAD_CTL_SRE_FAST),
317 NEW_PAD_CTRL(MX51_PAD_GPIO1_0__SD1_CD, PAD_CTL_HYS),
318 NEW_PAD_CTRL(MX51_PAD_GPIO1_1__SD1_WP, PAD_CTL_HYS),
319 };
320
321 static const iomux_v3_cfg_t sd2_pads[] = {
322 NEW_PAD_CTRL(MX51_PAD_SD2_CMD__SD2_CMD,
323 PAD_CTL_DSE_MAX | PAD_CTL_SRE_FAST),
324 NEW_PAD_CTRL(MX51_PAD_SD2_CLK__SD2_CLK,
325 PAD_CTL_DSE_MAX | PAD_CTL_SRE_FAST),
326 NEW_PAD_CTRL(MX51_PAD_SD2_DATA0__SD2_DATA0,
327 PAD_CTL_DSE_MAX | PAD_CTL_SRE_FAST),
328 NEW_PAD_CTRL(MX51_PAD_SD2_DATA1__SD2_DATA1,
329 PAD_CTL_DSE_MAX | PAD_CTL_SRE_FAST),
330 NEW_PAD_CTRL(MX51_PAD_SD2_DATA2__SD2_DATA2,
331 PAD_CTL_DSE_MAX | PAD_CTL_SRE_FAST),
332 NEW_PAD_CTRL(MX51_PAD_SD2_DATA3__SD2_DATA3,
333 PAD_CTL_DSE_MAX | PAD_CTL_SRE_FAST),
334 NEW_PAD_CTRL(MX51_PAD_GPIO1_6__GPIO1_6, PAD_CTL_HYS),
335 NEW_PAD_CTRL(MX51_PAD_GPIO1_5__GPIO1_5, PAD_CTL_HYS),
336 };
337
Stefano Babicc5fb70c2010-02-05 15:13:58 +0100338 u32 index;
339 s32 status = 0;
340
Benoît Thébaudeaua2ac1b32012-10-01 08:36:25 +0000341 esdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK);
342 esdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC2_CLK);
343
Stefano Babicc5fb70c2010-02-05 15:13:58 +0100344 for (index = 0; index < CONFIG_SYS_FSL_ESDHC_NUM;
345 index++) {
346 switch (index) {
347 case 0:
Benoît Thébaudeau4d15d362013-05-03 10:32:27 +0000348 imx_iomux_v3_setup_multiple_pads(sd1_pads,
349 ARRAY_SIZE(sd1_pads));
Stefano Babicc5fb70c2010-02-05 15:13:58 +0100350 break;
351 case 1:
Benoît Thébaudeau4d15d362013-05-03 10:32:27 +0000352 imx_iomux_v3_setup_multiple_pads(sd2_pads,
353 ARRAY_SIZE(sd2_pads));
Stefano Babicc5fb70c2010-02-05 15:13:58 +0100354 break;
355 default:
356 printf("Warning: you configured more ESDHC controller"
357 "(%d) as supported by the board(2)\n",
358 CONFIG_SYS_FSL_ESDHC_NUM);
359 return status;
360 }
361 status |= fsl_esdhc_initialize(bis, &esdhc_cfg[index]);
362 }
363 return status;
364}
365#endif
366
Liu Hui-R64343877eb0f2010-12-23 01:13:17 +0000367int board_early_init_f(void)
368{
369 setup_iomux_uart();
370 setup_iomux_fec();
Wolfgang Grandegger055d9692011-11-11 14:03:38 +0100371#ifdef CONFIG_USB_EHCI_MX5
372 setup_usb_h1();
373#endif
Vikram Narayanan5d71bd22012-11-10 02:28:52 +0000374 setup_iomux_lcd();
Liu Hui-R64343877eb0f2010-12-23 01:13:17 +0000375
376 return 0;
377}
378
Stefano Babicc5fb70c2010-02-05 15:13:58 +0100379int board_init(void)
380{
Stefano Babicc5fb70c2010-02-05 15:13:58 +0100381 /* address of boot parameters */
382 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
383
Stefano Babicc5fb70c2010-02-05 15:13:58 +0100384 return 0;
385}
386
Helmut Raiger9660e442011-10-20 04:19:47 +0000387#ifdef CONFIG_BOARD_LATE_INIT
Stefano Babicb4377e12010-03-16 17:22:21 +0100388int board_late_init(void)
389{
390#ifdef CONFIG_MXC_SPI
391 setup_iomux_spi();
392 power_init();
393#endif
Fabio Estevamf1adefd2012-05-09 06:39:41 +0000394
Stefano Babicb4377e12010-03-16 17:22:21 +0100395 return 0;
396}
397#endif
398
Fabio Estevam1e080982012-08-05 07:31:33 +0000399/*
400 * Do not overwrite the console
401 * Use always serial for U-Boot console
402 */
403int overwrite_console(void)
404{
405 return 1;
406}
407
Stefano Babicc5fb70c2010-02-05 15:13:58 +0100408int checkboard(void)
409{
Jason Liu51958902011-04-22 02:55:42 +0000410 puts("Board: MX51EVK\n");
Stefano Babicc5fb70c2010-02-05 15:13:58 +0100411
Stefano Babicc5fb70c2010-02-05 15:13:58 +0100412 return 0;
413}