2 * Copyright (C) 2011 Freescale Semiconductor, Inc.
3 * Jason Liu <r64343@freescale.com>
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
26 #include <asm/arch/imx-regs.h>
27 #include <asm/arch/mx5x_pins.h>
28 #include <asm/arch/sys_proto.h>
29 #include <asm/arch/crm_regs.h>
30 #include <asm/arch/clock.h>
31 #include <asm/arch/iomux.h>
32 #include <asm/arch/clock.h>
33 #include <asm/errno.h>
37 #include <fsl_esdhc.h>
40 #include <dialog_pmic.h>
43 DECLARE_GLOBAL_DATA_PTR;
49 size1 = get_ram_size((void *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
50 size2 = get_ram_size((void *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE);
52 gd->ram_size = size1 + size2;
56 void dram_init_banksize(void)
58 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
59 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
61 gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
62 gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE;
65 u32 get_board_rev(void)
67 struct iim_regs *iim = (struct iim_regs *)IMX_IIM_BASE;
68 struct fuse_bank *bank = &iim->bank[0];
69 struct fuse_bank0_regs *fuse =
70 (struct fuse_bank0_regs *)bank->fuse_regs;
72 int rev = readl(&fuse->gp[6]);
74 return (get_cpu_rev() & ~(0xF << 8)) | (rev & 0xF) << 8;
77 static void setup_iomux_uart(void)
80 mxc_request_iomux(MX53_PIN_CSI0_D11, IOMUX_CONFIG_ALT2);
81 mxc_iomux_set_pad(MX53_PIN_CSI0_D11,
82 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
83 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
84 PAD_CTL_HYS_ENABLE | PAD_CTL_100K_PU |
85 PAD_CTL_ODE_OPENDRAIN_ENABLE);
86 mxc_iomux_set_input(MX53_UART1_IPP_UART_RXD_MUX_SELECT_INPUT, 0x1);
89 mxc_request_iomux(MX53_PIN_CSI0_D10, IOMUX_CONFIG_ALT2);
90 mxc_iomux_set_pad(MX53_PIN_CSI0_D10,
91 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
92 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
93 PAD_CTL_HYS_ENABLE | PAD_CTL_100K_PU |
94 PAD_CTL_ODE_OPENDRAIN_ENABLE);
97 #ifdef CONFIG_USB_EHCI_MX5
98 int board_ehci_hcd_init(int port)
100 /* request VBUS power enable pin, GPIO7_8 */
101 mxc_request_iomux(MX53_PIN_ATA_DA_2, IOMUX_CONFIG_ALT1);
102 gpio_direction_output(IOMUX_TO_GPIO(MX53_PIN_ATA_DA_2), 1);
107 static void setup_iomux_fec(void)
110 mxc_request_iomux(MX53_PIN_FEC_MDIO, IOMUX_CONFIG_ALT0);
111 mxc_iomux_set_pad(MX53_PIN_FEC_MDIO,
112 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
113 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
114 PAD_CTL_22K_PU | PAD_CTL_ODE_OPENDRAIN_ENABLE);
115 mxc_iomux_set_input(MX53_FEC_FEC_MDI_SELECT_INPUT, 0x1);
118 mxc_request_iomux(MX53_PIN_FEC_MDC, IOMUX_CONFIG_ALT0);
119 mxc_iomux_set_pad(MX53_PIN_FEC_MDC, PAD_CTL_DRV_HIGH);
122 mxc_request_iomux(MX53_PIN_FEC_RXD1, IOMUX_CONFIG_ALT0);
123 mxc_iomux_set_pad(MX53_PIN_FEC_RXD1,
124 PAD_CTL_HYS_ENABLE | PAD_CTL_PKE_ENABLE);
127 mxc_request_iomux(MX53_PIN_FEC_RXD0, IOMUX_CONFIG_ALT0);
128 mxc_iomux_set_pad(MX53_PIN_FEC_RXD0,
129 PAD_CTL_HYS_ENABLE | PAD_CTL_PKE_ENABLE);
132 mxc_request_iomux(MX53_PIN_FEC_TXD1, IOMUX_CONFIG_ALT0);
133 mxc_iomux_set_pad(MX53_PIN_FEC_TXD1, PAD_CTL_DRV_HIGH);
136 mxc_request_iomux(MX53_PIN_FEC_TXD0, IOMUX_CONFIG_ALT0);
137 mxc_iomux_set_pad(MX53_PIN_FEC_TXD0, PAD_CTL_DRV_HIGH);
140 mxc_request_iomux(MX53_PIN_FEC_TX_EN, IOMUX_CONFIG_ALT0);
141 mxc_iomux_set_pad(MX53_PIN_FEC_TX_EN, PAD_CTL_DRV_HIGH);
144 mxc_request_iomux(MX53_PIN_FEC_REF_CLK, IOMUX_CONFIG_ALT0);
145 mxc_iomux_set_pad(MX53_PIN_FEC_REF_CLK,
146 PAD_CTL_HYS_ENABLE | PAD_CTL_PKE_ENABLE);
149 mxc_request_iomux(MX53_PIN_FEC_RX_ER, IOMUX_CONFIG_ALT0);
150 mxc_iomux_set_pad(MX53_PIN_FEC_RX_ER,
151 PAD_CTL_HYS_ENABLE | PAD_CTL_PKE_ENABLE);
154 mxc_request_iomux(MX53_PIN_FEC_CRS_DV, IOMUX_CONFIG_ALT0);
155 mxc_iomux_set_pad(MX53_PIN_FEC_CRS_DV,
156 PAD_CTL_HYS_ENABLE | PAD_CTL_PKE_ENABLE);
159 #ifdef CONFIG_FSL_ESDHC
160 struct fsl_esdhc_cfg esdhc_cfg[2] = {
161 {MMC_SDHC1_BASE_ADDR, 1},
162 {MMC_SDHC3_BASE_ADDR, 1},
165 int board_mmc_getcd(struct mmc *mmc)
167 struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
170 mxc_request_iomux(MX53_PIN_EIM_DA11, IOMUX_CONFIG_ALT1);
171 gpio_direction_input(75);
172 mxc_request_iomux(MX53_PIN_EIM_DA13, IOMUX_CONFIG_ALT1);
173 gpio_direction_input(77);
175 if (cfg->esdhc_base == MMC_SDHC1_BASE_ADDR)
176 ret = !gpio_get_value(77); /* GPIO3_13 */
178 ret = !gpio_get_value(75); /* GPIO3_11 */
183 int board_mmc_init(bd_t *bis)
188 for (index = 0; index < CONFIG_SYS_FSL_ESDHC_NUM; index++) {
191 mxc_request_iomux(MX53_PIN_SD1_CMD, IOMUX_CONFIG_ALT0);
192 mxc_request_iomux(MX53_PIN_SD1_CLK, IOMUX_CONFIG_ALT0);
193 mxc_request_iomux(MX53_PIN_SD1_DATA0,
195 mxc_request_iomux(MX53_PIN_SD1_DATA1,
197 mxc_request_iomux(MX53_PIN_SD1_DATA2,
199 mxc_request_iomux(MX53_PIN_SD1_DATA3,
201 mxc_request_iomux(MX53_PIN_EIM_DA13,
204 mxc_iomux_set_pad(MX53_PIN_SD1_CMD,
205 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
206 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
207 PAD_CTL_HYS_ENABLE | PAD_CTL_100K_PU);
208 mxc_iomux_set_pad(MX53_PIN_SD1_CLK,
209 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
210 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU |
212 mxc_iomux_set_pad(MX53_PIN_SD1_DATA0,
213 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
214 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
215 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
216 mxc_iomux_set_pad(MX53_PIN_SD1_DATA1,
217 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
218 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
219 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
220 mxc_iomux_set_pad(MX53_PIN_SD1_DATA2,
221 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
222 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
223 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
224 mxc_iomux_set_pad(MX53_PIN_SD1_DATA3,
225 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
226 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
227 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
230 mxc_request_iomux(MX53_PIN_ATA_RESET_B,
232 mxc_request_iomux(MX53_PIN_ATA_IORDY,
234 mxc_request_iomux(MX53_PIN_ATA_DATA8,
236 mxc_request_iomux(MX53_PIN_ATA_DATA9,
238 mxc_request_iomux(MX53_PIN_ATA_DATA10,
240 mxc_request_iomux(MX53_PIN_ATA_DATA11,
242 mxc_request_iomux(MX53_PIN_ATA_DATA0,
244 mxc_request_iomux(MX53_PIN_ATA_DATA1,
246 mxc_request_iomux(MX53_PIN_ATA_DATA2,
248 mxc_request_iomux(MX53_PIN_ATA_DATA3,
250 mxc_request_iomux(MX53_PIN_EIM_DA11,
253 mxc_iomux_set_pad(MX53_PIN_ATA_RESET_B,
254 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
255 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
256 PAD_CTL_HYS_ENABLE | PAD_CTL_100K_PU);
257 mxc_iomux_set_pad(MX53_PIN_ATA_IORDY,
258 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
259 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU |
261 mxc_iomux_set_pad(MX53_PIN_ATA_DATA8,
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_47K_PU);
265 mxc_iomux_set_pad(MX53_PIN_ATA_DATA9,
266 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
267 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
268 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
269 mxc_iomux_set_pad(MX53_PIN_ATA_DATA10,
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_ATA_DATA11,
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_ATA_DATA0,
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_ATA_DATA1,
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);
285 mxc_iomux_set_pad(MX53_PIN_ATA_DATA2,
286 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
287 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
288 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
289 mxc_iomux_set_pad(MX53_PIN_ATA_DATA3,
290 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
291 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
292 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
296 printf("Warning: you configured more ESDHC controller"
297 "(%d) as supported by the board(2)\n",
298 CONFIG_SYS_FSL_ESDHC_NUM);
301 status |= fsl_esdhc_initialize(bis, &esdhc_cfg[index]);
308 static void setup_iomux_i2c(void)
311 mxc_request_iomux(MX53_PIN_CSI0_D8,
312 IOMUX_CONFIG_ALT5 | IOMUX_CONFIG_SION);
313 mxc_iomux_set_input(MX53_I2C1_IPP_SDA_IN_SELECT_INPUT,
315 mxc_iomux_set_pad(MX53_PIN_CSI0_D8,
316 PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH |
317 PAD_CTL_100K_PU | PAD_CTL_PKE_ENABLE |
319 PAD_CTL_ODE_OPENDRAIN_ENABLE);
321 mxc_request_iomux(MX53_PIN_CSI0_D9,
322 IOMUX_CONFIG_ALT5 | IOMUX_CONFIG_SION);
323 mxc_iomux_set_input(MX53_I2C1_IPP_SCL_IN_SELECT_INPUT,
325 mxc_iomux_set_pad(MX53_PIN_CSI0_D9,
326 PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH |
327 PAD_CTL_100K_PU | PAD_CTL_PKE_ENABLE |
329 PAD_CTL_ODE_OPENDRAIN_ENABLE);
332 static int power_init(void)
338 if (!i2c_probe(CONFIG_SYS_DIALOG_PMIC_I2C_ADDR)) {
342 /* Set VDDA to 1.25V */
343 val = DA9052_BUCKCORE_BCOREEN | DA_BUCKCORE_VBCORE_1_250V;
344 ret = pmic_reg_write(p, DA9053_BUCKCORE_REG, val);
346 ret |= pmic_reg_read(p, DA9053_SUPPLY_REG, &val);
347 val |= DA9052_SUPPLY_VBCOREGO;
348 ret |= pmic_reg_write(p, DA9053_SUPPLY_REG, val);
350 /* Set Vcc peripheral to 1.30V */
351 ret |= pmic_reg_write(p, DA9053_BUCKPRO_REG, 0x62);
352 ret |= pmic_reg_write(p, DA9053_SUPPLY_REG, 0x62);
355 if (!i2c_probe(CONFIG_SYS_FSL_PMIC_I2C_ADDR)) {
359 /* Set VDDGP to 1.25V for 1GHz on SW1 */
360 pmic_reg_read(p, REG_SW_0, &val);
361 val = (val & ~SWx_VOLT_MASK_MC34708) | SWx_1_250V_MC34708;
362 ret = pmic_reg_write(p, REG_SW_0, val);
364 /* Set VCC as 1.30V on SW2 */
365 pmic_reg_read(p, REG_SW_1, &val);
366 val = (val & ~SWx_VOLT_MASK_MC34708) | SWx_1_300V_MC34708;
367 ret |= pmic_reg_write(p, REG_SW_1, val);
369 /* Set global reset timer to 4s */
370 pmic_reg_read(p, REG_POWER_CTL2, &val);
371 val = (val & ~TIMER_MASK_MC34708) | TIMER_4S_MC34708;
372 ret |= pmic_reg_write(p, REG_POWER_CTL2, val);
374 /* Set VUSBSEL and VUSBEN for USB PHY supply*/
375 pmic_reg_read(p, REG_MODE_0, &val);
376 val |= (VUSBSEL_MC34708 | VUSBEN_MC34708);
377 ret |= pmic_reg_write(p, REG_MODE_0, val);
379 /* Set SWBST to 5V in auto mode */
381 ret |= pmic_reg_write(p, SWBST_CTRL, val);
387 static void clock_1GHz(void)
390 u32 ref_clk = CONFIG_SYS_MX5_HCLK;
392 * After increasing voltage to 1.25V, we can switch
393 * CPU clock to 1GHz and DDR to 400MHz safely
395 ret = mxc_set_clock(ref_clk, 1000, MXC_ARM_CLK);
397 printf("CPU: Switch CPU clock to 1GHZ failed\n");
399 ret = mxc_set_clock(ref_clk, 400, MXC_PERIPH_CLK);
400 ret |= mxc_set_clock(ref_clk, 400, MXC_DDR_CLK);
402 printf("CPU: Switch DDR clock to 400MHz failed\n");
405 int board_early_init_f(void)
413 int print_cpuinfo(void)
417 cpurev = get_cpu_rev();
418 printf("CPU: Freescale i.MX%x family rev%d.%d at %d MHz\n",
419 (cpurev & 0xFF000) >> 12,
420 (cpurev & 0x000F0) >> 4,
421 (cpurev & 0x0000F) >> 0,
422 mxc_get_clock(MXC_ARM_CLK) / 1000000);
423 printf("Reset cause: %s\n", get_reset_cause());
427 #ifdef CONFIG_BOARD_LATE_INIT
428 int board_late_init(void)
441 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
443 mxc_set_sata_internal_clock();
450 puts("Board: MX53 LOCO\n");