blob: a98ed69db880b437f251191c8da7bac74e8ee286 [file] [log] [blame]
Peng Fan86a17972022-07-26 16:41:10 +08001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright 2022 NXP
4 */
5
6#include <common.h>
7#include <command.h>
8#include <cpu_func.h>
9#include <hang.h>
10#include <image.h>
11#include <init.h>
12#include <log.h>
13#include <spl.h>
14#include <asm/global_data.h>
15#include <asm/io.h>
16#include <asm/arch/imx93_pins.h>
Mathieu Othacehe2029a4c2024-02-09 11:30:07 +010017#include <asm/arch/mu.h>
Peng Fan86a17972022-07-26 16:41:10 +080018#include <asm/arch/clock.h>
19#include <asm/arch/sys_proto.h>
20#include <asm/mach-imx/boot_mode.h>
21#include <asm/mach-imx/mxc_i2c.h>
22#include <asm/arch-mx7ulp/gpio.h>
23#include <asm/mach-imx/syscounter.h>
Shiji Yang506df9d2023-08-03 09:47:16 +080024#include <asm/sections.h>
Peng Fan86a17972022-07-26 16:41:10 +080025#include <dm/uclass.h>
26#include <dm/device.h>
27#include <dm/uclass-internal.h>
28#include <dm/device-internal.h>
29#include <linux/delay.h>
30#include <asm/arch/clock.h>
31#include <asm/arch/ccm_regs.h>
32#include <asm/arch/ddr.h>
33#include <power/pmic.h>
34#include <power/pca9450.h>
35#include <asm/arch/trdc.h>
36
37DECLARE_GLOBAL_DATA_PTR;
38
39int spl_board_boot_device(enum boot_device boot_dev_spl)
40{
41 return BOOT_DEVICE_BOOTROM;
42}
43
44void spl_board_init(void)
45{
46 puts("Normal Boot\n");
47}
48
49void spl_dram_init(void)
50{
51 ddr_init(&dram_timing);
52}
53
54#if CONFIG_IS_ENABLED(DM_PMIC_PCA9450)
55int power_init_board(void)
56{
57 struct udevice *dev;
58 int ret;
59
60 ret = pmic_get("pmic@25", &dev);
61 if (ret == -ENODEV) {
62 puts("No pca9450@25\n");
63 return 0;
64 }
65 if (ret != 0)
66 return ret;
67
68 /* BUCKxOUT_DVS0/1 control BUCK123 output */
69 pmic_reg_write(dev, PCA9450_BUCK123_DVS, 0x29);
70
Peng Fand59b9c32023-04-28 12:08:35 +080071 /* enable DVS control through PMIC_STBY_REQ */
72 pmic_reg_write(dev, PCA9450_BUCK1CTRL, 0x59);
73
74 if (IS_ENABLED(CONFIG_IMX9_LOW_DRIVE_MODE)) {
75 /* 0.75v for Low drive mode
76 */
77 pmic_reg_write(dev, PCA9450_BUCK1OUT_DVS0, 0x0c);
78 pmic_reg_write(dev, PCA9450_BUCK3OUT_DVS0, 0x0c);
79 } else {
80 /* 0.9v for Over drive mode
81 */
82 pmic_reg_write(dev, PCA9450_BUCK1OUT_DVS0, 0x18);
83 pmic_reg_write(dev, PCA9450_BUCK3OUT_DVS0, 0x18);
84 }
85
86 /* set standby voltage to 0.65v */
87 pmic_reg_write(dev, PCA9450_BUCK1OUT_DVS1, 0x4);
Peng Fan86a17972022-07-26 16:41:10 +080088
89 /* I2C_LT_EN*/
90 pmic_reg_write(dev, 0xa, 0x3);
Peng Fan86a17972022-07-26 16:41:10 +080091 return 0;
92}
93#endif
94
Peng Fan86a17972022-07-26 16:41:10 +080095void board_init_f(ulong dummy)
96{
97 int ret;
98
99 /* Clear the BSS. */
100 memset(__bss_start, 0, __bss_end - __bss_start);
101
102 timer_init();
103
104 arch_cpu_init();
105
106 board_early_init_f();
107
108 spl_early_init();
109
110 preloader_console_init();
111
112 ret = imx9_probe_mu(NULL, NULL);
113 if (ret) {
114 printf("Fail to init Sentinel API\n");
115 } else {
116 printf("SOC: 0x%x\n", gd->arch.soc_rev);
117 printf("LC: 0x%x\n", gd->arch.lifecycle);
118 }
Peng Fand59b9c32023-04-28 12:08:35 +0800119
Peng Fan86a17972022-07-26 16:41:10 +0800120 power_init_board();
121
Peng Fand59b9c32023-04-28 12:08:35 +0800122 if (!IS_ENABLED(CONFIG_IMX9_LOW_DRIVE_MODE))
123 set_arm_clk(get_cpu_speed_grade_hz());
Peng Fanfeaf8e02022-07-26 16:41:11 +0800124
Peng Fan86a17972022-07-26 16:41:10 +0800125 /* Init power of mix */
126 soc_power_init();
127
128 /* Setup TRDC for DDR access */
129 trdc_init();
130
131 /* DDR initialization */
132 spl_dram_init();
133
134 /* Put M33 into CPUWAIT for following kick */
135 ret = m33_prepare();
136 if (!ret)
137 printf("M33 prepare ok\n");
138
139 board_init_r(NULL, 0);
140}