1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2011 Freescale Semiconductor, Inc.
4 * Jason Liu <r64343@freescale.com>
10 #include <asm/global_data.h>
12 #include <asm/arch/imx-regs.h>
13 #include <asm/arch/sys_proto.h>
14 #include <asm/arch/crm_regs.h>
15 #include <asm/arch/clock.h>
16 #include <asm/arch/iomux-mx53.h>
17 #include <asm/arch/clock.h>
19 #include <linux/errno.h>
20 #include <asm/mach-imx/mx5_video.h>
23 #include <fsl_esdhc_imx.h>
25 #include <power/pmic.h>
26 #include <dialog_pmic.h>
29 #include <ipu_pixfmt.h>
30 #include <dm/uclass.h>
31 #include <dm/device.h>
33 #define MX53LOCO_LCD_POWER IMX_GPIO_NR(3, 24)
35 DECLARE_GLOBAL_DATA_PTR;
37 #ifdef CONFIG_REVISION_TAG
38 u32 get_board_rev(void)
40 struct iim_regs *iim = (struct iim_regs *)IMX_IIM_BASE;
41 struct fuse_bank *bank = &iim->bank[0];
42 struct fuse_bank0_regs *fuse =
43 (struct fuse_bank0_regs *)bank->fuse_regs;
47 int rev = readl(&fuse->gp[6]);
49 ret = uclass_get_device_by_seq(UCLASS_I2C, 0, &bus);
53 if (!dm_i2c_probe(bus, CFG_SYS_DIALOG_PMIC_I2C_ADDR, 0, &dev))
56 return (get_cpu_rev() & ~(0xF << 8)) | (rev & 0xF) << 8;
60 #define UART_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_DSE_HIGH | \
61 PAD_CTL_PUS_100K_UP | PAD_CTL_ODE)
63 static void setup_iomux_uart(void)
65 static const iomux_v3_cfg_t uart_pads[] = {
66 NEW_PAD_CTRL(MX53_PAD_CSI0_DAT11__UART1_RXD_MUX, UART_PAD_CTRL),
67 NEW_PAD_CTRL(MX53_PAD_CSI0_DAT10__UART1_TXD_MUX, UART_PAD_CTRL),
70 imx_iomux_v3_setup_multiple_pads(uart_pads, ARRAY_SIZE(uart_pads));
73 static int power_init(void)
81 ret = uclass_get_device_by_seq(UCLASS_I2C, 0, &bus);
85 if (!dm_i2c_probe(bus, CFG_SYS_DIALOG_PMIC_I2C_ADDR, 0, &dev)) {
86 ret = pmic_dialog_init(I2C_PMIC);
90 p = pmic_get("DIALOG_PMIC");
94 env_set("fdt_file", "imx53-qsb.dtb");
96 /* Set VDDA to 1.25V */
97 val = DA9052_BUCKCORE_BCOREEN | DA_BUCKCORE_VBCORE_1_250V;
98 ret = pmic_reg_write(p, DA9053_BUCKCORE_REG, val);
100 printf("Writing to BUCKCORE_REG failed: %d\n", ret);
104 pmic_reg_read(p, DA9053_SUPPLY_REG, &val);
105 val |= DA9052_SUPPLY_VBCOREGO;
106 ret = pmic_reg_write(p, DA9053_SUPPLY_REG, val);
108 printf("Writing to SUPPLY_REG failed: %d\n", ret);
112 /* Set Vcc peripheral to 1.30V */
113 ret = pmic_reg_write(p, DA9053_BUCKPRO_REG, 0x62);
115 printf("Writing to BUCKPRO_REG failed: %d\n", ret);
119 ret = pmic_reg_write(p, DA9053_SUPPLY_REG, 0x62);
121 printf("Writing to SUPPLY_REG failed: %d\n", ret);
128 if (!dm_i2c_probe(bus, CFG_SYS_FSL_PMIC_I2C_ADDR, 0, &dev)) {
133 p = pmic_get("FSL_PMIC");
137 env_set("fdt_file", "imx53-qsrb.dtb");
139 /* Set VDDGP to 1.25V for 1GHz on SW1 */
140 pmic_reg_read(p, REG_SW_0, &val);
141 val = (val & ~SWx_VOLT_MASK_MC34708) | SWx_1_250V_MC34708;
142 ret = pmic_reg_write(p, REG_SW_0, val);
144 printf("Writing to REG_SW_0 failed: %d\n", ret);
148 /* Set VCC as 1.30V on SW2 */
149 pmic_reg_read(p, REG_SW_1, &val);
150 val = (val & ~SWx_VOLT_MASK_MC34708) | SWx_1_300V_MC34708;
151 ret = pmic_reg_write(p, REG_SW_1, val);
153 printf("Writing to REG_SW_1 failed: %d\n", ret);
157 /* Set global reset timer to 4s */
158 pmic_reg_read(p, REG_POWER_CTL2, &val);
159 val = (val & ~TIMER_MASK_MC34708) | TIMER_4S_MC34708;
160 ret = pmic_reg_write(p, REG_POWER_CTL2, val);
162 printf("Writing to REG_POWER_CTL2 failed: %d\n", ret);
166 /* Set VUSBSEL and VUSBEN for USB PHY supply*/
167 pmic_reg_read(p, REG_MODE_0, &val);
168 val |= (VUSBSEL_MC34708 | VUSBEN_MC34708);
169 ret = pmic_reg_write(p, REG_MODE_0, val);
171 printf("Writing to REG_MODE_0 failed: %d\n", ret);
175 /* Set SWBST to 5V in auto mode */
177 ret = pmic_reg_write(p, SWBST_CTRL, val);
179 printf("Writing to SWBST_CTRL failed: %d\n", ret);
189 static void clock_1GHz(void)
192 u32 ref_clk = MXC_HCLK;
194 * After increasing voltage to 1.25V, we can switch
195 * CPU clock to 1GHz and DDR to 400MHz safely
197 ret = mxc_set_clock(ref_clk, 1000, MXC_ARM_CLK);
199 printf("CPU: Switch CPU clock to 1GHZ failed\n");
201 ret = mxc_set_clock(ref_clk, 400, MXC_PERIPH_CLK);
202 ret |= mxc_set_clock(ref_clk, 400, MXC_DDR_CLK);
204 printf("CPU: Switch DDR clock to 400MHz failed\n");
207 int board_early_init_f(void)
216 * Do not overwrite the console
217 * Use always serial for U-Boot console
219 int overwrite_console(void)
226 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
228 mxc_set_sata_internal_clock();
233 int board_late_init(void)
243 puts("Board: MX53 LOCO\n");