2 * (C) Copyright 2010 Freescale Semiconductor, Inc.
4 * See file CREDITS for list of people who contributed to this
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.
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.
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,
25 #include <asm/arch/imx-regs.h>
26 #include <asm/arch/mx5x_pins.h>
27 #include <asm/arch/sys_proto.h>
28 #include <asm/arch/crm_regs.h>
29 #include <asm/arch/clock.h>
30 #include <asm/arch/iomux.h>
31 #include <asm/errno.h>
32 #include <asm/imx-common/boot_mode.h>
36 #include <fsl_esdhc.h>
37 #include <power/pmic.h>
42 DECLARE_GLOBAL_DATA_PTR;
46 /* dram_init must store complete ramsize in gd->ram_size */
47 gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
52 static void setup_iomux_uart(void)
55 mxc_request_iomux(MX53_PIN_CSI0_D11, IOMUX_CONFIG_ALT2);
56 mxc_iomux_set_pad(MX53_PIN_CSI0_D11,
57 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
58 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
59 PAD_CTL_HYS_ENABLE | PAD_CTL_100K_PU |
60 PAD_CTL_ODE_OPENDRAIN_ENABLE);
61 mxc_iomux_set_input(MX53_UART1_IPP_UART_RXD_MUX_SELECT_INPUT, 0x1);
64 mxc_request_iomux(MX53_PIN_CSI0_D10, IOMUX_CONFIG_ALT2);
65 mxc_iomux_set_pad(MX53_PIN_CSI0_D10,
66 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
67 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
68 PAD_CTL_HYS_ENABLE | PAD_CTL_100K_PU |
69 PAD_CTL_ODE_OPENDRAIN_ENABLE);
72 static void setup_i2c(unsigned int port_number)
74 switch (port_number) {
77 mxc_request_iomux(MX53_PIN_CSI0_D8,
78 IOMUX_CONFIG_ALT5 | IOMUX_CONFIG_SION);
79 mxc_iomux_set_input(MX53_I2C1_IPP_SDA_IN_SELECT_INPUT,
81 mxc_iomux_set_pad(MX53_PIN_CSI0_D8,
82 PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH |
83 PAD_CTL_100K_PU | PAD_CTL_HYS_ENABLE |
84 PAD_CTL_ODE_OPENDRAIN_ENABLE);
86 mxc_request_iomux(MX53_PIN_CSI0_D9,
87 IOMUX_CONFIG_ALT5 | IOMUX_CONFIG_SION);
88 mxc_iomux_set_input(MX53_I2C1_IPP_SCL_IN_SELECT_INPUT,
90 mxc_iomux_set_pad(MX53_PIN_CSI0_D9,
91 PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH |
92 PAD_CTL_100K_PU | PAD_CTL_HYS_ENABLE |
93 PAD_CTL_ODE_OPENDRAIN_ENABLE);
97 mxc_request_iomux(MX53_PIN_KEY_ROW3,
98 IOMUX_CONFIG_ALT4 | IOMUX_CONFIG_SION);
99 mxc_iomux_set_input(MX53_I2C2_IPP_SDA_IN_SELECT_INPUT,
101 mxc_iomux_set_pad(MX53_PIN_KEY_ROW3,
102 PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH |
103 PAD_CTL_100K_PU | PAD_CTL_HYS_ENABLE |
104 PAD_CTL_ODE_OPENDRAIN_ENABLE);
107 mxc_request_iomux(MX53_PIN_KEY_COL3,
108 IOMUX_CONFIG_ALT4 | IOMUX_CONFIG_SION);
109 mxc_iomux_set_input(MX53_I2C2_IPP_SCL_IN_SELECT_INPUT,
111 mxc_iomux_set_pad(MX53_PIN_KEY_COL3,
112 PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH |
113 PAD_CTL_100K_PU | PAD_CTL_HYS_ENABLE |
114 PAD_CTL_ODE_OPENDRAIN_ENABLE);
117 printf("Warning: Wrong I2C port number\n");
122 void power_init(void)
128 ret = pmic_init(I2C_PMIC);
132 p = pmic_get("FSL_PMIC");
136 /* Set VDDA to 1.25V */
137 pmic_reg_read(p, REG_SW_2, &val);
138 val &= ~SWX_OUT_MASK;
140 pmic_reg_write(p, REG_SW_2, val);
143 * Need increase VCC and VDDA to 1.3V
144 * according to MX53 IC TO2 datasheet.
146 if (is_soc_rev(CHIP_REV_2_0) == 0) {
147 /* Set VCC to 1.3V for TO2 */
148 pmic_reg_read(p, REG_SW_1, &val);
149 val &= ~SWX_OUT_MASK;
151 pmic_reg_write(p, REG_SW_1, val);
153 /* Set VDDA to 1.3V for TO2 */
154 pmic_reg_read(p, REG_SW_2, &val);
155 val &= ~SWX_OUT_MASK;
157 pmic_reg_write(p, REG_SW_2, val);
161 static void setup_iomux_fec(void)
164 mxc_request_iomux(MX53_PIN_FEC_MDIO, IOMUX_CONFIG_ALT0);
165 mxc_iomux_set_pad(MX53_PIN_FEC_MDIO,
166 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
167 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
168 PAD_CTL_22K_PU | PAD_CTL_ODE_OPENDRAIN_ENABLE);
169 mxc_iomux_set_input(MX53_FEC_FEC_MDI_SELECT_INPUT, 0x1);
172 mxc_request_iomux(MX53_PIN_FEC_MDC, IOMUX_CONFIG_ALT0);
173 mxc_iomux_set_pad(MX53_PIN_FEC_MDC, PAD_CTL_DRV_HIGH);
176 mxc_request_iomux(MX53_PIN_FEC_RXD1, IOMUX_CONFIG_ALT0);
177 mxc_iomux_set_pad(MX53_PIN_FEC_RXD1,
178 PAD_CTL_HYS_ENABLE | PAD_CTL_PKE_ENABLE);
181 mxc_request_iomux(MX53_PIN_FEC_RXD0, IOMUX_CONFIG_ALT0);
182 mxc_iomux_set_pad(MX53_PIN_FEC_RXD0,
183 PAD_CTL_HYS_ENABLE | PAD_CTL_PKE_ENABLE);
186 mxc_request_iomux(MX53_PIN_FEC_TXD1, IOMUX_CONFIG_ALT0);
187 mxc_iomux_set_pad(MX53_PIN_FEC_TXD1, PAD_CTL_DRV_HIGH);
190 mxc_request_iomux(MX53_PIN_FEC_TXD0, IOMUX_CONFIG_ALT0);
191 mxc_iomux_set_pad(MX53_PIN_FEC_TXD0, PAD_CTL_DRV_HIGH);
194 mxc_request_iomux(MX53_PIN_FEC_TX_EN, IOMUX_CONFIG_ALT0);
195 mxc_iomux_set_pad(MX53_PIN_FEC_TX_EN, PAD_CTL_DRV_HIGH);
198 mxc_request_iomux(MX53_PIN_FEC_REF_CLK, IOMUX_CONFIG_ALT0);
199 mxc_iomux_set_pad(MX53_PIN_FEC_REF_CLK,
200 PAD_CTL_HYS_ENABLE | PAD_CTL_PKE_ENABLE);
203 mxc_request_iomux(MX53_PIN_FEC_RX_ER, IOMUX_CONFIG_ALT0);
204 mxc_iomux_set_pad(MX53_PIN_FEC_RX_ER,
205 PAD_CTL_HYS_ENABLE | PAD_CTL_PKE_ENABLE);
208 mxc_request_iomux(MX53_PIN_FEC_CRS_DV, IOMUX_CONFIG_ALT0);
209 mxc_iomux_set_pad(MX53_PIN_FEC_CRS_DV,
210 PAD_CTL_HYS_ENABLE | PAD_CTL_PKE_ENABLE);
213 #ifdef CONFIG_FSL_ESDHC
214 struct fsl_esdhc_cfg esdhc_cfg[2] = {
215 {MMC_SDHC1_BASE_ADDR},
216 {MMC_SDHC3_BASE_ADDR},
219 int board_mmc_getcd(struct mmc *mmc)
221 struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
224 mxc_request_iomux(MX53_PIN_EIM_DA11, IOMUX_CONFIG_ALT1);
225 gpio_direction_input(IMX_GPIO_NR(3, 11));
226 mxc_request_iomux(MX53_PIN_EIM_DA13, IOMUX_CONFIG_ALT1);
227 gpio_direction_input(IMX_GPIO_NR(3, 13));
229 if (cfg->esdhc_base == MMC_SDHC1_BASE_ADDR)
230 ret = !gpio_get_value(IMX_GPIO_NR(3, 13));
232 ret = !gpio_get_value(IMX_GPIO_NR(3, 11));
237 int board_mmc_init(bd_t *bis)
242 esdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK);
243 esdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
245 for (index = 0; index < CONFIG_SYS_FSL_ESDHC_NUM; index++) {
248 mxc_request_iomux(MX53_PIN_SD1_CMD, IOMUX_CONFIG_ALT0);
249 mxc_request_iomux(MX53_PIN_SD1_CLK, IOMUX_CONFIG_ALT0);
250 mxc_request_iomux(MX53_PIN_SD1_DATA0,
252 mxc_request_iomux(MX53_PIN_SD1_DATA1,
254 mxc_request_iomux(MX53_PIN_SD1_DATA2,
256 mxc_request_iomux(MX53_PIN_SD1_DATA3,
258 mxc_request_iomux(MX53_PIN_EIM_DA13,
261 mxc_iomux_set_pad(MX53_PIN_SD1_CMD,
262 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
263 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
264 PAD_CTL_HYS_ENABLE | PAD_CTL_100K_PU);
265 mxc_iomux_set_pad(MX53_PIN_SD1_CLK,
266 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
267 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU |
269 mxc_iomux_set_pad(MX53_PIN_SD1_DATA0,
270 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
271 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
272 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
273 mxc_iomux_set_pad(MX53_PIN_SD1_DATA1,
274 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
275 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
276 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
277 mxc_iomux_set_pad(MX53_PIN_SD1_DATA2,
278 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
279 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
280 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
281 mxc_iomux_set_pad(MX53_PIN_SD1_DATA3,
282 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
283 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
284 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
287 mxc_request_iomux(MX53_PIN_ATA_RESET_B,
289 mxc_request_iomux(MX53_PIN_ATA_IORDY,
291 mxc_request_iomux(MX53_PIN_ATA_DATA8,
293 mxc_request_iomux(MX53_PIN_ATA_DATA9,
295 mxc_request_iomux(MX53_PIN_ATA_DATA10,
297 mxc_request_iomux(MX53_PIN_ATA_DATA11,
299 mxc_request_iomux(MX53_PIN_ATA_DATA0,
301 mxc_request_iomux(MX53_PIN_ATA_DATA1,
303 mxc_request_iomux(MX53_PIN_ATA_DATA2,
305 mxc_request_iomux(MX53_PIN_ATA_DATA3,
307 mxc_request_iomux(MX53_PIN_EIM_DA11,
310 mxc_iomux_set_pad(MX53_PIN_ATA_RESET_B,
311 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
312 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
313 PAD_CTL_HYS_ENABLE | PAD_CTL_100K_PU);
314 mxc_iomux_set_pad(MX53_PIN_ATA_IORDY,
315 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
316 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU |
318 mxc_iomux_set_pad(MX53_PIN_ATA_DATA8,
319 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
320 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
321 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
322 mxc_iomux_set_pad(MX53_PIN_ATA_DATA9,
323 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
324 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
325 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
326 mxc_iomux_set_pad(MX53_PIN_ATA_DATA10,
327 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
328 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
329 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
330 mxc_iomux_set_pad(MX53_PIN_ATA_DATA11,
331 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
332 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
333 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
334 mxc_iomux_set_pad(MX53_PIN_ATA_DATA0,
335 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
336 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
337 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
338 mxc_iomux_set_pad(MX53_PIN_ATA_DATA1,
339 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
340 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
341 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
342 mxc_iomux_set_pad(MX53_PIN_ATA_DATA2,
343 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
344 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
345 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
346 mxc_iomux_set_pad(MX53_PIN_ATA_DATA3,
347 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
348 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
349 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
353 printf("Warning: you configured more ESDHC controller"
354 "(%d) as supported by the board(2)\n",
355 CONFIG_SYS_FSL_ESDHC_NUM);
358 status |= fsl_esdhc_initialize(bis, &esdhc_cfg[index]);
365 int board_early_init_f(void)
375 /* address of boot parameters */
376 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
381 #ifdef CONFIG_CMD_BMODE
382 static const struct boot_mode board_boot_modes[] = {
383 /* 4 bit bus width */
384 {"mmc0", MAKE_CFGVAL(0x40, 0x20, 0x00, 0x12)},
385 {"mmc1", MAKE_CFGVAL(0x40, 0x20, 0x08, 0x12)},
390 int board_late_init(void)
395 #ifdef CONFIG_CMD_BMODE
396 add_board_boot_modes(board_boot_modes);
403 puts("Board: MX53EVK\n");