blob: 3f043c2b2e3b8458d8648cf34af6e5570f179fc2 [file] [log] [blame]
Peng Fanc47e09d2019-12-30 17:46:21 +08001/*
2 * Copyright 2018-2019 NXP
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#include <common.h>
Simon Glassed38aef2020-05-10 11:40:03 -06008#include <command.h>
Simon Glassafb02152019-12-28 10:45:01 -07009#include <cpu_func.h>
Simon Glassf11478f2019-12-28 10:45:07 -070010#include <hang.h>
Simon Glass2dc9c342020-05-10 11:40:01 -060011#include <image.h>
Simon Glass97589732020-05-10 11:40:02 -060012#include <init.h>
Simon Glass0f2af882020-05-10 11:40:05 -060013#include <log.h>
Peng Fanc47e09d2019-12-30 17:46:21 +080014#include <spl.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060015#include <asm/global_data.h>
Peng Fanc47e09d2019-12-30 17:46:21 +080016#include <asm/io.h>
17#include <errno.h>
18#include <asm/io.h>
19#include <asm/mach-imx/iomux-v3.h>
20#include <asm/arch/imx8mp_pins.h>
21#include <asm/arch/sys_proto.h>
22#include <asm/mach-imx/boot_mode.h>
23#include <power/pmic.h>
24
25#include <power/pca9450.h>
26#include <asm/arch/clock.h>
27#include <asm/mach-imx/gpio.h>
28#include <asm/mach-imx/mxc_i2c.h>
29#include <fsl_esdhc.h>
30#include <mmc.h>
31#include <asm/arch/ddr.h>
32
Peng Fanc47e09d2019-12-30 17:46:21 +080033DECLARE_GLOBAL_DATA_PTR;
34
35int spl_board_boot_device(enum boot_device boot_dev_spl)
36{
37 return BOOT_DEVICE_BOOTROM;
38}
39
40void spl_dram_init(void)
41{
42 ddr_init(&dram_timing);
43}
44
45void spl_board_init(void)
46{
Peng Fanc47e09d2019-12-30 17:46:21 +080047 puts("Normal Boot\n");
Peng Fanc47e09d2019-12-30 17:46:21 +080048}
49
50#define I2C_PAD_CTRL (PAD_CTL_DSE6 | PAD_CTL_HYS | PAD_CTL_PUE | PAD_CTL_PE)
51#define PC MUX_PAD_CTRL(I2C_PAD_CTRL)
52struct i2c_pads_info i2c_pad_info1 = {
53 .scl = {
54 .i2c_mode = MX8MP_PAD_I2C1_SCL__I2C1_SCL | PC,
55 .gpio_mode = MX8MP_PAD_I2C1_SCL__GPIO5_IO14 | PC,
56 .gp = IMX_GPIO_NR(5, 14),
57 },
58 .sda = {
59 .i2c_mode = MX8MP_PAD_I2C1_SDA__I2C1_SDA | PC,
60 .gpio_mode = MX8MP_PAD_I2C1_SDA__GPIO5_IO15 | PC,
61 .gp = IMX_GPIO_NR(5, 15),
62 },
63};
64
65#ifdef CONFIG_POWER
66#define I2C_PMIC 0
67int power_init_board(void)
68{
69 struct pmic *p;
70 int ret;
71
Sébastien Szymanski6ba69a22020-06-30 15:03:13 +020072 ret = power_pca9450_init(I2C_PMIC);
Peng Fanc47e09d2019-12-30 17:46:21 +080073 if (ret)
74 printf("power init failed");
75 p = pmic_get("PCA9450");
76 pmic_probe(p);
77
78 /* BUCKxOUT_DVS0/1 control BUCK123 output */
79 pmic_reg_write(p, PCA9450_BUCK123_DVS, 0x29);
80
81 /*
82 * increase VDD_SOC to typical value 0.95V before first
83 * DRAM access, set DVS1 to 0.85v for suspend.
84 * Enable DVS control through PMIC_STBY_REQ and
85 * set B1_ENMODE=1 (ON by PMIC_ON_REQ=H)
86 */
haidong.zheng62927832021-03-19 15:57:02 +080087#ifdef CONFIG_IMX8M_VDD_SOC_850MV
88 /* set DVS0 to 0.85v for special case*/
89 pmic_reg_write(p, PCA9450_BUCK1OUT_DVS0, 0x14);
90#else
Peng Fanc47e09d2019-12-30 17:46:21 +080091 pmic_reg_write(p, PCA9450_BUCK1OUT_DVS0, 0x1C);
haidong.zheng62927832021-03-19 15:57:02 +080092#endif
Peng Fanc47e09d2019-12-30 17:46:21 +080093 pmic_reg_write(p, PCA9450_BUCK1OUT_DVS1, 0x14);
94 pmic_reg_write(p, PCA9450_BUCK1CTRL, 0x59);
95
96 /* set WDOG_B_CFG to cold reset */
97 pmic_reg_write(p, PCA9450_RESET_CTRL, 0xA1);
98
99 return 0;
100}
101#endif
102
103#ifdef CONFIG_SPL_LOAD_FIT
104int board_fit_config_name_match(const char *name)
105{
106 /* Just empty function now - can't decide what to choose */
107 debug("%s: %s\n", __func__, name);
108
109 return 0;
110}
111#endif
112
Peng Fana50c0a32020-05-26 20:33:49 -0300113/* Do not use BSS area in this phase */
Peng Fanc47e09d2019-12-30 17:46:21 +0800114void board_init_f(ulong dummy)
115{
116 int ret;
117
118 arch_cpu_init();
119
120 init_uart_clk(1);
121
122 board_early_init_f();
123
Peng Fan5d93e1c2020-05-26 20:33:48 -0300124 ret = spl_early_init();
Peng Fanc47e09d2019-12-30 17:46:21 +0800125 if (ret) {
126 debug("spl_init() failed: %d\n", ret);
127 hang();
128 }
129
Peng Fan5d93e1c2020-05-26 20:33:48 -0300130 preloader_console_init();
131
Peng Fanc47e09d2019-12-30 17:46:21 +0800132 enable_tzc380();
133
Peng Fanc47e09d2019-12-30 17:46:21 +0800134 setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info1);
135
136 power_init_board();
137
138 /* DDR initialization */
139 spl_dram_init();
Peng Fanc47e09d2019-12-30 17:46:21 +0800140}