1 // SPDX-License-Identifier: GPL-2.0+
13 #include <asm/global_data.h>
15 #include <asm/mach-imx/iomux-v3.h>
16 #include <asm/arch/clock.h>
17 #include <asm/arch/imx8mm_pins.h>
18 #include <asm/arch/sys_proto.h>
19 #include <asm/mach-imx/boot_mode.h>
20 #include <asm/arch/ddr.h>
21 #include <asm/sections.h>
23 #include <dm/uclass.h>
24 #include <dm/device.h>
25 #include <dm/uclass-internal.h>
26 #include <dm/device-internal.h>
28 #include <power/pmic.h>
29 #include <power/pca9450.h>
31 DECLARE_GLOBAL_DATA_PTR;
33 int spl_board_boot_device(enum boot_device boot_dev_spl)
35 switch (boot_dev_spl) {
37 return BOOT_DEVICE_BOARD;
40 return BOOT_DEVICE_MMC1;
43 return BOOT_DEVICE_MMC2;
45 return BOOT_DEVICE_NONE;
49 static void spl_dram_init(void)
51 ddr_init(&dram_timing);
54 void spl_board_init(void)
59 puts("Normal Boot\n");
62 #ifdef CONFIG_SPL_LOAD_FIT
63 int board_fit_config_name_match(const char *name)
65 /* Just empty function now - can't decide what to choose */
66 debug("%s: %s\n", __func__, name);
72 static int power_init_board(void)
77 ret = pmic_get("pmic@25", &dev);
85 /* BUCKxOUT_DVS0/1 control BUCK123 output */
86 pmic_reg_write(dev, PCA9450_BUCK123_DVS, 0x29);
88 /* Buck 1 DVS control through PMIC_STBY_REQ */
89 pmic_reg_write(dev, PCA9450_BUCK1CTRL, 0x59);
91 /* Set DVS1 to 0.8V for suspend */
92 pmic_reg_write(dev, PCA9450_BUCK1OUT_DVS1, 0x10);
94 /* increase VDD_DRAM to 0.95V for 3GHz DDR */
95 pmic_reg_write(dev, PCA9450_BUCK3OUT_DVS0, 0x1C);
97 /* VDD_DRAM needs off in suspend, set B1_ENMODE=10 (ON by PMIC_ON_REQ = H && PMIC_STBY_REQ = L) */
98 pmic_reg_write(dev, PCA9450_BUCK3CTRL, 0x4a);
100 /* set VDD_SNVS_0V8 from default 0.85V */
101 pmic_reg_write(dev, PCA9450_LDO2CTRL, 0xC0);
103 /* set WDOG_B_CFG to cold reset */
104 pmic_reg_write(dev, PCA9450_RESET_CTRL, 0xA1);
109 void board_init_f(ulong dummy)
121 memset(__bss_start, 0, __bss_end - __bss_start);
123 ret = spl_early_init();
125 debug("spl_early_init() failed: %d\n", ret);
129 ret = uclass_get_device_by_name(UCLASS_CLK,
130 "clock-controller@30380000",
133 printf("Failed to find clock node. Check device tree\n");
137 preloader_console_init();
143 /* DDR initialization */
146 board_init_r(NULL, 0);