blob: 4250efddde77144002294db1b7fb453a2a48e927 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Stefano Babic421834e2010-02-05 15:13:58 +01002/*
3 * (C) Copyright 2009 Freescale Semiconductor, Inc.
Stefano Babic421834e2010-02-05 15:13:58 +01004 */
5
6#include <common.h>
Simon Glassa7b51302019-11-14 12:57:46 -07007#include <init.h>
Stefano Babic421834e2010-02-05 15:13:58 +01008#include <asm/io.h>
Stefano Babic57008812011-08-21 23:29:52 +02009#include <asm/gpio.h>
Stefano Babic421834e2010-02-05 15:13:58 +010010#include <asm/arch/imx-regs.h>
Benoît Thébaudeau168dc712013-05-03 10:32:27 +000011#include <asm/arch/iomux-mx51.h>
Simon Glassdbd79542020-05-10 11:40:11 -060012#include <linux/delay.h>
Masahiro Yamada56a931c2016-09-21 11:28:55 +090013#include <linux/errno.h>
Stefano Babicac41d4d2010-03-05 17:54:37 +010014#include <asm/arch/sys_proto.h>
Stefano Babic96651272010-03-16 17:22:21 +010015#include <asm/arch/crm_regs.h>
Benoît Thébaudeauc58ff342012-10-01 08:36:25 +000016#include <asm/arch/clock.h>
Stefano Babic33731bc2017-06-29 10:16:06 +020017#include <asm/mach-imx/mx5_video.h>
Stefano Babic421834e2010-02-05 15:13:58 +010018#include <i2c.h>
Diego Dorta2661c9c2017-09-22 12:12:18 -030019#include <input.h>
Stefano Babic421834e2010-02-05 15:13:58 +010020#include <mmc.h>
Yangbo Lu73340382019-06-21 11:42:28 +080021#include <fsl_esdhc_imx.h>
Łukasz Majewski1c6dba12012-11-13 03:21:55 +000022#include <power/pmic.h>
Stefano Babic96651272010-03-16 17:22:21 +010023#include <fsl_pmic.h>
24#include <mc13892.h>
Mateusz Kulikowski3add69e2016-03-31 23:12:23 +020025#include <usb/ehci-ci.h>
Stefano Babic421834e2010-02-05 15:13:58 +010026
27DECLARE_GLOBAL_DATA_PTR;
28
Yangbo Lu73340382019-06-21 11:42:28 +080029#ifdef CONFIG_FSL_ESDHC_IMX
Stefano Babic421834e2010-02-05 15:13:58 +010030struct fsl_esdhc_cfg esdhc_cfg[2] = {
Benoît Thébaudeauc08d11c2012-08-13 07:28:16 +000031 {MMC_SDHC1_BASE_ADDR},
32 {MMC_SDHC2_BASE_ADDR},
Stefano Babic421834e2010-02-05 15:13:58 +010033};
34#endif
35
Stefano Babic421834e2010-02-05 15:13:58 +010036int dram_init(void)
37{
Shawn Guobc08e7e2010-10-28 10:13:15 +080038 /* dram_init must store complete ramsize in gd->ram_size */
Albert ARIBAUDa9606732011-07-03 05:55:33 +000039 gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
Shawn Guobc08e7e2010-10-28 10:13:15 +080040 PHYS_SDRAM_1_SIZE);
Stefano Babic421834e2010-02-05 15:13:58 +010041 return 0;
42}
43
Benoît Thébaudeau7477d112012-09-18 04:48:42 +000044u32 get_board_rev(void)
45{
46 u32 rev = get_cpu_rev();
47 if (!gpio_get_value(IMX_GPIO_NR(1, 22)))
48 rev |= BOARD_REV_2_0 << BOARD_VER_OFFSET;
49 return rev;
50}
51
Benoît Thébaudeau168dc712013-05-03 10:32:27 +000052#define UART_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_PUS_100K_DOWN | PAD_CTL_DSE_HIGH)
53
Stefano Babic421834e2010-02-05 15:13:58 +010054static void setup_iomux_uart(void)
55{
Benoît Thébaudeau168dc712013-05-03 10:32:27 +000056 static const iomux_v3_cfg_t uart_pads[] = {
57 MX51_PAD_UART1_RXD__UART1_RXD,
58 MX51_PAD_UART1_TXD__UART1_TXD,
59 NEW_PAD_CTRL(MX51_PAD_UART1_RTS__UART1_RTS, UART_PAD_CTRL),
60 NEW_PAD_CTRL(MX51_PAD_UART1_CTS__UART1_CTS, UART_PAD_CTRL),
61 };
Stefano Babic421834e2010-02-05 15:13:58 +010062
Benoît Thébaudeau168dc712013-05-03 10:32:27 +000063 imx_iomux_v3_setup_multiple_pads(uart_pads, ARRAY_SIZE(uart_pads));
Stefano Babic421834e2010-02-05 15:13:58 +010064}
65
Stefano Babic421834e2010-02-05 15:13:58 +010066static void setup_iomux_fec(void)
67{
Benoît Thébaudeau168dc712013-05-03 10:32:27 +000068 static const iomux_v3_cfg_t fec_pads[] = {
69 NEW_PAD_CTRL(MX51_PAD_EIM_EB2__FEC_MDIO, PAD_CTL_HYS |
70 PAD_CTL_PUS_22K_UP | PAD_CTL_ODE |
71 PAD_CTL_DSE_HIGH | PAD_CTL_SRE_FAST),
72 MX51_PAD_NANDF_CS3__FEC_MDC,
73 NEW_PAD_CTRL(MX51_PAD_EIM_CS3__FEC_RDATA3, MX51_PAD_CTRL_2),
74 NEW_PAD_CTRL(MX51_PAD_EIM_CS2__FEC_RDATA2, MX51_PAD_CTRL_2),
75 NEW_PAD_CTRL(MX51_PAD_EIM_EB3__FEC_RDATA1, MX51_PAD_CTRL_2),
76 MX51_PAD_NANDF_D9__FEC_RDATA0,
77 MX51_PAD_NANDF_CS6__FEC_TDATA3,
78 MX51_PAD_NANDF_CS5__FEC_TDATA2,
79 MX51_PAD_NANDF_CS4__FEC_TDATA1,
80 MX51_PAD_NANDF_D8__FEC_TDATA0,
81 MX51_PAD_NANDF_CS7__FEC_TX_EN,
82 MX51_PAD_NANDF_CS2__FEC_TX_ER,
83 MX51_PAD_NANDF_RDY_INT__FEC_TX_CLK,
84 NEW_PAD_CTRL(MX51_PAD_NANDF_RB2__FEC_COL, MX51_PAD_CTRL_4),
85 NEW_PAD_CTRL(MX51_PAD_NANDF_RB3__FEC_RX_CLK, MX51_PAD_CTRL_4),
86 MX51_PAD_EIM_CS5__FEC_CRS,
87 MX51_PAD_EIM_CS4__FEC_RX_ER,
88 NEW_PAD_CTRL(MX51_PAD_NANDF_D11__FEC_RX_DV, MX51_PAD_CTRL_4),
89 };
Stefano Babic421834e2010-02-05 15:13:58 +010090
Benoît Thébaudeau168dc712013-05-03 10:32:27 +000091 imx_iomux_v3_setup_multiple_pads(fec_pads, ARRAY_SIZE(fec_pads));
Stefano Babic421834e2010-02-05 15:13:58 +010092}
93
Stefano Babic96651272010-03-16 17:22:21 +010094#ifdef CONFIG_MXC_SPI
95static void setup_iomux_spi(void)
96{
Benoît Thébaudeau168dc712013-05-03 10:32:27 +000097 static const iomux_v3_cfg_t spi_pads[] = {
98 NEW_PAD_CTRL(MX51_PAD_CSPI1_MOSI__ECSPI1_MOSI, PAD_CTL_HYS |
99 PAD_CTL_DSE_HIGH | PAD_CTL_SRE_FAST),
100 NEW_PAD_CTRL(MX51_PAD_CSPI1_MISO__ECSPI1_MISO, PAD_CTL_HYS |
101 PAD_CTL_DSE_HIGH | PAD_CTL_SRE_FAST),
102 NEW_PAD_CTRL(MX51_PAD_CSPI1_SS1__ECSPI1_SS1,
103 MX51_GPIO_PAD_CTRL),
104 MX51_PAD_CSPI1_SS0__ECSPI1_SS0,
105 NEW_PAD_CTRL(MX51_PAD_CSPI1_RDY__ECSPI1_RDY, MX51_PAD_CTRL_2),
106 NEW_PAD_CTRL(MX51_PAD_CSPI1_SCLK__ECSPI1_SCLK, PAD_CTL_HYS |
107 PAD_CTL_DSE_HIGH | PAD_CTL_SRE_FAST),
108 };
Stefano Babic96651272010-03-16 17:22:21 +0100109
Benoît Thébaudeau168dc712013-05-03 10:32:27 +0000110 imx_iomux_v3_setup_multiple_pads(spi_pads, ARRAY_SIZE(spi_pads));
Stefano Babic96651272010-03-16 17:22:21 +0100111}
112#endif
113
Wolfgang Grandegger2e865da2011-11-11 14:03:38 +0100114#ifdef CONFIG_USB_EHCI_MX5
Benoît Thébaudeau168dc712013-05-03 10:32:27 +0000115#define MX51EVK_USBH1_HUB_RST IMX_GPIO_NR(1, 7)
116#define MX51EVK_USBH1_STP IMX_GPIO_NR(1, 27)
Fabio Estevama293e192014-12-12 12:33:32 -0200117#define MX51EVK_USB_CLK_EN_B IMX_GPIO_NR(2, 1)
Benoît Thébaudeau168dc712013-05-03 10:32:27 +0000118#define MX51EVK_USB_PHY_RESET IMX_GPIO_NR(2, 5)
Wolfgang Grandegger2e865da2011-11-11 14:03:38 +0100119
120static void setup_usb_h1(void)
121{
Benoît Thébaudeau168dc712013-05-03 10:32:27 +0000122 static const iomux_v3_cfg_t usb_h1_pads[] = {
123 MX51_PAD_USBH1_CLK__USBH1_CLK,
124 MX51_PAD_USBH1_DIR__USBH1_DIR,
125 MX51_PAD_USBH1_STP__USBH1_STP,
126 MX51_PAD_USBH1_NXT__USBH1_NXT,
127 MX51_PAD_USBH1_DATA0__USBH1_DATA0,
128 MX51_PAD_USBH1_DATA1__USBH1_DATA1,
129 MX51_PAD_USBH1_DATA2__USBH1_DATA2,
130 MX51_PAD_USBH1_DATA3__USBH1_DATA3,
131 MX51_PAD_USBH1_DATA4__USBH1_DATA4,
132 MX51_PAD_USBH1_DATA5__USBH1_DATA5,
133 MX51_PAD_USBH1_DATA6__USBH1_DATA6,
134 MX51_PAD_USBH1_DATA7__USBH1_DATA7,
Wolfgang Grandegger2e865da2011-11-11 14:03:38 +0100135
Benoît Thébaudeau168dc712013-05-03 10:32:27 +0000136 NEW_PAD_CTRL(MX51_PAD_GPIO1_7__GPIO1_7, 0), /* H1 hub reset */
137 MX51_PAD_EIM_D17__GPIO2_1,
138 MX51_PAD_EIM_D21__GPIO2_5, /* PHY reset */
139 };
Wolfgang Grandegger2e865da2011-11-11 14:03:38 +0100140
Benoît Thébaudeau168dc712013-05-03 10:32:27 +0000141 imx_iomux_v3_setup_multiple_pads(usb_h1_pads, ARRAY_SIZE(usb_h1_pads));
Wolfgang Grandegger2e865da2011-11-11 14:03:38 +0100142}
143
Anatolij Gustschinef2f5792011-12-12 01:25:46 +0000144int board_ehci_hcd_init(int port)
Wolfgang Grandegger2e865da2011-11-11 14:03:38 +0100145{
146 /* Set USBH1_STP to GPIO and toggle it */
Benoît Thébaudeau168dc712013-05-03 10:32:27 +0000147 imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_USBH1_STP__GPIO1_27,
148 MX51_USBH_PAD_CTRL));
Wolfgang Grandegger2e865da2011-11-11 14:03:38 +0100149
150 gpio_direction_output(MX51EVK_USBH1_STP, 0);
151 gpio_direction_output(MX51EVK_USB_PHY_RESET, 0);
152 mdelay(10);
153 gpio_set_value(MX51EVK_USBH1_STP, 1);
154
155 /* Set back USBH1_STP to be function */
Benoît Thébaudeau168dc712013-05-03 10:32:27 +0000156 imx_iomux_v3_setup_pad(MX51_PAD_USBH1_STP__USBH1_STP);
Wolfgang Grandegger2e865da2011-11-11 14:03:38 +0100157
158 /* De-assert USB PHY RESETB */
159 gpio_set_value(MX51EVK_USB_PHY_RESET, 1);
160
161 /* Drive USB_CLK_EN_B line low */
162 gpio_direction_output(MX51EVK_USB_CLK_EN_B, 0);
163
164 /* Reset USB hub */
165 gpio_direction_output(MX51EVK_USBH1_HUB_RST, 0);
166 mdelay(2);
167 gpio_set_value(MX51EVK_USBH1_HUB_RST, 1);
Anatolij Gustschinef2f5792011-12-12 01:25:46 +0000168 return 0;
Wolfgang Grandegger2e865da2011-11-11 14:03:38 +0100169}
170#endif
171
Stefano Babic96651272010-03-16 17:22:21 +0100172static void power_init(void)
173{
174 unsigned int val;
Stefano Babic96651272010-03-16 17:22:21 +0100175 struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)MXC_CCM_BASE;
Stefano Babicdba2efc2011-10-08 10:59:20 +0200176 struct pmic *p;
Łukasz Majewski1c6dba12012-11-13 03:21:55 +0000177 int ret;
178
Fabio Estevam21cb23f2013-11-20 20:26:03 -0200179 ret = pmic_init(CONFIG_FSL_PMIC_BUS);
Łukasz Majewski1c6dba12012-11-13 03:21:55 +0000180 if (ret)
181 return;
Stefano Babicdba2efc2011-10-08 10:59:20 +0200182
Łukasz Majewski1c6dba12012-11-13 03:21:55 +0000183 p = pmic_get("FSL_PMIC");
184 if (!p)
185 return;
Stefano Babic96651272010-03-16 17:22:21 +0100186
187 /* Write needed to Power Gate 2 register */
Stefano Babicdba2efc2011-10-08 10:59:20 +0200188 pmic_reg_read(p, REG_POWER_MISC, &val);
Stefano Babic96651272010-03-16 17:22:21 +0100189 val &= ~PWGT2SPIEN;
Stefano Babicdba2efc2011-10-08 10:59:20 +0200190 pmic_reg_write(p, REG_POWER_MISC, val);
Stefano Babic96651272010-03-16 17:22:21 +0100191
Shawn Guo4546eb72010-10-27 23:36:04 +0800192 /* Externally powered */
Stefano Babicdba2efc2011-10-08 10:59:20 +0200193 pmic_reg_read(p, REG_CHARGE, &val);
Shawn Guo4546eb72010-10-27 23:36:04 +0800194 val |= ICHRG0 | ICHRG1 | ICHRG2 | ICHRG3 | CHGAUTOB;
Stefano Babicdba2efc2011-10-08 10:59:20 +0200195 pmic_reg_write(p, REG_CHARGE, val);
Stefano Babic96651272010-03-16 17:22:21 +0100196
197 /* power up the system first */
Stefano Babicdba2efc2011-10-08 10:59:20 +0200198 pmic_reg_write(p, REG_POWER_MISC, PWUP);
Stefano Babic96651272010-03-16 17:22:21 +0100199
200 /* Set core voltage to 1.1V */
Stefano Babicdba2efc2011-10-08 10:59:20 +0200201 pmic_reg_read(p, REG_SW_0, &val);
Marek Vasutb043f702011-01-19 04:40:36 +0000202 val = (val & ~SWx_VOLT_MASK) | SWx_1_100V;
Stefano Babicdba2efc2011-10-08 10:59:20 +0200203 pmic_reg_write(p, REG_SW_0, val);
Stefano Babic96651272010-03-16 17:22:21 +0100204
205 /* Setup VCC (SW2) to 1.25 */
Stefano Babicdba2efc2011-10-08 10:59:20 +0200206 pmic_reg_read(p, REG_SW_1, &val);
Marek Vasutb043f702011-01-19 04:40:36 +0000207 val = (val & ~SWx_VOLT_MASK) | SWx_1_250V;
Stefano Babicdba2efc2011-10-08 10:59:20 +0200208 pmic_reg_write(p, REG_SW_1, val);
Stefano Babic96651272010-03-16 17:22:21 +0100209
210 /* Setup 1V2_DIG1 (SW3) to 1.25 */
Stefano Babicdba2efc2011-10-08 10:59:20 +0200211 pmic_reg_read(p, REG_SW_2, &val);
Marek Vasutb043f702011-01-19 04:40:36 +0000212 val = (val & ~SWx_VOLT_MASK) | SWx_1_250V;
Stefano Babicdba2efc2011-10-08 10:59:20 +0200213 pmic_reg_write(p, REG_SW_2, val);
Stefano Babic96651272010-03-16 17:22:21 +0100214 udelay(50);
215
216 /* Raise the core frequency to 800MHz */
217 writel(0x0, &mxc_ccm->cacrr);
218
219 /* Set switchers in Auto in NORMAL mode & STANDBY mode */
220 /* Setup the switcher mode for SW1 & SW2*/
Stefano Babicdba2efc2011-10-08 10:59:20 +0200221 pmic_reg_read(p, REG_SW_4, &val);
Stefano Babic96651272010-03-16 17:22:21 +0100222 val = (val & ~((SWMODE_MASK << SWMODE1_SHIFT) |
223 (SWMODE_MASK << SWMODE2_SHIFT)));
224 val |= (SWMODE_AUTO_AUTO << SWMODE1_SHIFT) |
225 (SWMODE_AUTO_AUTO << SWMODE2_SHIFT);
Stefano Babicdba2efc2011-10-08 10:59:20 +0200226 pmic_reg_write(p, REG_SW_4, val);
Stefano Babic96651272010-03-16 17:22:21 +0100227
228 /* Setup the switcher mode for SW3 & SW4 */
Stefano Babicdba2efc2011-10-08 10:59:20 +0200229 pmic_reg_read(p, REG_SW_5, &val);
Stefano Babic96651272010-03-16 17:22:21 +0100230 val = (val & ~((SWMODE_MASK << SWMODE3_SHIFT) |
231 (SWMODE_MASK << SWMODE4_SHIFT)));
232 val |= (SWMODE_AUTO_AUTO << SWMODE3_SHIFT) |
233 (SWMODE_AUTO_AUTO << SWMODE4_SHIFT);
Stefano Babicdba2efc2011-10-08 10:59:20 +0200234 pmic_reg_write(p, REG_SW_5, val);
Stefano Babic96651272010-03-16 17:22:21 +0100235
236 /* Set VDIG to 1.65V, VGEN3 to 1.8V, VCAM to 2.6V */
Stefano Babicdba2efc2011-10-08 10:59:20 +0200237 pmic_reg_read(p, REG_SETTING_0, &val);
Stefano Babic96651272010-03-16 17:22:21 +0100238 val &= ~(VCAM_MASK | VGEN3_MASK | VDIG_MASK);
239 val |= VDIG_1_65 | VGEN3_1_8 | VCAM_2_6;
Stefano Babicdba2efc2011-10-08 10:59:20 +0200240 pmic_reg_write(p, REG_SETTING_0, val);
Stefano Babic96651272010-03-16 17:22:21 +0100241
242 /* Set VVIDEO to 2.775V, VAUDIO to 3V, VSD to 3.15V */
Stefano Babicdba2efc2011-10-08 10:59:20 +0200243 pmic_reg_read(p, REG_SETTING_1, &val);
Stefano Babic96651272010-03-16 17:22:21 +0100244 val &= ~(VVIDEO_MASK | VSD_MASK | VAUDIO_MASK);
245 val |= VSD_3_15 | VAUDIO_3_0 | VVIDEO_2_775;
Stefano Babicdba2efc2011-10-08 10:59:20 +0200246 pmic_reg_write(p, REG_SETTING_1, val);
Stefano Babic96651272010-03-16 17:22:21 +0100247
248 /* Configure VGEN3 and VCAM regulators to use external PNP */
249 val = VGEN3CONFIG | VCAMCONFIG;
Stefano Babicdba2efc2011-10-08 10:59:20 +0200250 pmic_reg_write(p, REG_MODE_1, val);
Stefano Babic96651272010-03-16 17:22:21 +0100251 udelay(200);
252
Stefano Babic96651272010-03-16 17:22:21 +0100253 /* Enable VGEN3, VCAM, VAUDIO, VVIDEO, VSD regulators */
254 val = VGEN3EN | VGEN3CONFIG | VCAMEN | VCAMCONFIG |
255 VVIDEOEN | VAUDIOEN | VSDEN;
Stefano Babicdba2efc2011-10-08 10:59:20 +0200256 pmic_reg_write(p, REG_MODE_1, val);
Stefano Babic96651272010-03-16 17:22:21 +0100257
Benoît Thébaudeau168dc712013-05-03 10:32:27 +0000258 imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_EIM_A20__GPIO2_14,
259 NO_PAD_CTRL));
Ashok Kumar Reddy7d04bd72012-08-28 07:39:38 +0530260 gpio_direction_output(IMX_GPIO_NR(2, 14), 0);
Fabio Estevamc38e0d62011-10-25 03:14:00 +0000261
Stefano Babic96651272010-03-16 17:22:21 +0100262 udelay(500);
263
Ashok Kumar Reddy7d04bd72012-08-28 07:39:38 +0530264 gpio_set_value(IMX_GPIO_NR(2, 14), 1);
Stefano Babic96651272010-03-16 17:22:21 +0100265}
266
Yangbo Lu73340382019-06-21 11:42:28 +0800267#ifdef CONFIG_FSL_ESDHC_IMX
Thierry Redingd7aebf42012-01-02 01:15:36 +0000268int board_mmc_getcd(struct mmc *mmc)
Stefano Babic421834e2010-02-05 15:13:58 +0100269{
270 struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
Thierry Redingd7aebf42012-01-02 01:15:36 +0000271 int ret;
Stefano Babic421834e2010-02-05 15:13:58 +0100272
Benoît Thébaudeau168dc712013-05-03 10:32:27 +0000273 imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_GPIO1_0__GPIO1_0,
274 NO_PAD_CTRL));
Ashok Kumar Reddy7d04bd72012-08-28 07:39:38 +0530275 gpio_direction_input(IMX_GPIO_NR(1, 0));
Benoît Thébaudeau168dc712013-05-03 10:32:27 +0000276 imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_GPIO1_6__GPIO1_6,
277 NO_PAD_CTRL));
Ashok Kumar Reddy7d04bd72012-08-28 07:39:38 +0530278 gpio_direction_input(IMX_GPIO_NR(1, 6));
Fabio Estevam77c0f1b2011-11-15 05:51:33 +0000279
Stefano Babic421834e2010-02-05 15:13:58 +0100280 if (cfg->esdhc_base == MMC_SDHC1_BASE_ADDR)
Ashok Kumar Reddy7d04bd72012-08-28 07:39:38 +0530281 ret = !gpio_get_value(IMX_GPIO_NR(1, 0));
Stefano Babic421834e2010-02-05 15:13:58 +0100282 else
Ashok Kumar Reddy7d04bd72012-08-28 07:39:38 +0530283 ret = !gpio_get_value(IMX_GPIO_NR(1, 6));
Stefano Babic421834e2010-02-05 15:13:58 +0100284
Thierry Redingd7aebf42012-01-02 01:15:36 +0000285 return ret;
Stefano Babic421834e2010-02-05 15:13:58 +0100286}
287
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +0900288int board_mmc_init(struct bd_info *bis)
Stefano Babic421834e2010-02-05 15:13:58 +0100289{
Benoît Thébaudeau168dc712013-05-03 10:32:27 +0000290 static const iomux_v3_cfg_t sd1_pads[] = {
291 NEW_PAD_CTRL(MX51_PAD_SD1_CMD__SD1_CMD, PAD_CTL_DSE_MAX |
292 PAD_CTL_HYS | PAD_CTL_PUS_47K_UP | PAD_CTL_SRE_FAST),
293 NEW_PAD_CTRL(MX51_PAD_SD1_CLK__SD1_CLK, PAD_CTL_DSE_MAX |
294 PAD_CTL_PUS_47K_UP | PAD_CTL_SRE_FAST),
295 NEW_PAD_CTRL(MX51_PAD_SD1_DATA0__SD1_DATA0, PAD_CTL_DSE_MAX |
296 PAD_CTL_HYS | PAD_CTL_PUS_47K_UP | PAD_CTL_SRE_FAST),
297 NEW_PAD_CTRL(MX51_PAD_SD1_DATA1__SD1_DATA1, PAD_CTL_DSE_MAX |
298 PAD_CTL_HYS | PAD_CTL_PUS_47K_UP | PAD_CTL_SRE_FAST),
299 NEW_PAD_CTRL(MX51_PAD_SD1_DATA2__SD1_DATA2, PAD_CTL_DSE_MAX |
300 PAD_CTL_HYS | PAD_CTL_PUS_47K_UP | PAD_CTL_SRE_FAST),
301 NEW_PAD_CTRL(MX51_PAD_SD1_DATA3__SD1_DATA3, PAD_CTL_DSE_MAX |
302 PAD_CTL_HYS | PAD_CTL_PUS_100K_DOWN | PAD_CTL_SRE_FAST),
303 NEW_PAD_CTRL(MX51_PAD_GPIO1_0__SD1_CD, PAD_CTL_HYS),
304 NEW_PAD_CTRL(MX51_PAD_GPIO1_1__SD1_WP, PAD_CTL_HYS),
305 };
306
307 static const iomux_v3_cfg_t sd2_pads[] = {
308 NEW_PAD_CTRL(MX51_PAD_SD2_CMD__SD2_CMD,
309 PAD_CTL_DSE_MAX | PAD_CTL_SRE_FAST),
310 NEW_PAD_CTRL(MX51_PAD_SD2_CLK__SD2_CLK,
311 PAD_CTL_DSE_MAX | PAD_CTL_SRE_FAST),
312 NEW_PAD_CTRL(MX51_PAD_SD2_DATA0__SD2_DATA0,
313 PAD_CTL_DSE_MAX | PAD_CTL_SRE_FAST),
314 NEW_PAD_CTRL(MX51_PAD_SD2_DATA1__SD2_DATA1,
315 PAD_CTL_DSE_MAX | PAD_CTL_SRE_FAST),
316 NEW_PAD_CTRL(MX51_PAD_SD2_DATA2__SD2_DATA2,
317 PAD_CTL_DSE_MAX | PAD_CTL_SRE_FAST),
318 NEW_PAD_CTRL(MX51_PAD_SD2_DATA3__SD2_DATA3,
319 PAD_CTL_DSE_MAX | PAD_CTL_SRE_FAST),
320 NEW_PAD_CTRL(MX51_PAD_GPIO1_6__GPIO1_6, PAD_CTL_HYS),
321 NEW_PAD_CTRL(MX51_PAD_GPIO1_5__GPIO1_5, PAD_CTL_HYS),
322 };
323
Stefano Babic421834e2010-02-05 15:13:58 +0100324 u32 index;
Fabio Estevame48f0382014-11-20 16:35:16 -0200325 int ret;
Stefano Babic421834e2010-02-05 15:13:58 +0100326
Benoît Thébaudeauc58ff342012-10-01 08:36:25 +0000327 esdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK);
328 esdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC2_CLK);
329
Stefano Babic421834e2010-02-05 15:13:58 +0100330 for (index = 0; index < CONFIG_SYS_FSL_ESDHC_NUM;
331 index++) {
332 switch (index) {
333 case 0:
Benoît Thébaudeau168dc712013-05-03 10:32:27 +0000334 imx_iomux_v3_setup_multiple_pads(sd1_pads,
335 ARRAY_SIZE(sd1_pads));
Stefano Babic421834e2010-02-05 15:13:58 +0100336 break;
337 case 1:
Benoît Thébaudeau168dc712013-05-03 10:32:27 +0000338 imx_iomux_v3_setup_multiple_pads(sd2_pads,
339 ARRAY_SIZE(sd2_pads));
Stefano Babic421834e2010-02-05 15:13:58 +0100340 break;
341 default:
342 printf("Warning: you configured more ESDHC controller"
343 "(%d) as supported by the board(2)\n",
344 CONFIG_SYS_FSL_ESDHC_NUM);
Fabio Estevame48f0382014-11-20 16:35:16 -0200345 return -EINVAL;
Stefano Babic421834e2010-02-05 15:13:58 +0100346 }
Fabio Estevame48f0382014-11-20 16:35:16 -0200347 ret = fsl_esdhc_initialize(bis, &esdhc_cfg[index]);
348 if (ret)
349 return ret;
Stefano Babic421834e2010-02-05 15:13:58 +0100350 }
Fabio Estevame48f0382014-11-20 16:35:16 -0200351 return 0;
Stefano Babic421834e2010-02-05 15:13:58 +0100352}
353#endif
354
Liu Hui-R643431e929df2010-12-23 01:13:17 +0000355int board_early_init_f(void)
356{
357 setup_iomux_uart();
358 setup_iomux_fec();
Wolfgang Grandegger2e865da2011-11-11 14:03:38 +0100359#ifdef CONFIG_USB_EHCI_MX5
360 setup_usb_h1();
361#endif
Vikram Narayanan9ddfa242012-11-10 02:28:52 +0000362 setup_iomux_lcd();
Liu Hui-R643431e929df2010-12-23 01:13:17 +0000363
364 return 0;
365}
366
Stefano Babic421834e2010-02-05 15:13:58 +0100367int board_init(void)
368{
Stefano Babic421834e2010-02-05 15:13:58 +0100369 /* address of boot parameters */
370 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
371
Stefano Babic421834e2010-02-05 15:13:58 +0100372 return 0;
373}
374
Helmut Raigerd5a184b2011-10-20 04:19:47 +0000375#ifdef CONFIG_BOARD_LATE_INIT
Stefano Babic96651272010-03-16 17:22:21 +0100376int board_late_init(void)
377{
378#ifdef CONFIG_MXC_SPI
379 setup_iomux_spi();
380 power_init();
381#endif
Fabio Estevam12ba8602012-05-09 06:39:41 +0000382
Stefano Babic96651272010-03-16 17:22:21 +0100383 return 0;
384}
385#endif
386
Fabio Estevam88920582012-08-05 07:31:33 +0000387/*
388 * Do not overwrite the console
389 * Use always serial for U-Boot console
390 */
391int overwrite_console(void)
392{
393 return 1;
394}
395
Stefano Babic421834e2010-02-05 15:13:58 +0100396int checkboard(void)
397{
Jason Liu8b7b69b2011-04-22 02:55:42 +0000398 puts("Board: MX51EVK\n");
Stefano Babic421834e2010-02-05 15:13:58 +0100399
Stefano Babic421834e2010-02-05 15:13:58 +0100400 return 0;
401}