blob: ebfd94dc1fa0d9e7317884f82238fd9a64774bca [file] [log] [blame]
Peng Fan439321b2019-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 Glass09140112020-05-10 11:40:03 -06008#include <command.h>
Simon Glass9a3b4ce2019-12-28 10:45:01 -07009#include <cpu_func.h>
Simon Glassdb41d652019-12-28 10:45:07 -070010#include <hang.h>
Simon Glass4d72caa2020-05-10 11:40:01 -060011#include <image.h>
Simon Glass691d7192020-05-10 11:40:02 -060012#include <init.h>
Simon Glassf7ae49f2020-05-10 11:40:05 -060013#include <log.h>
Peng Fan439321b2019-12-30 17:46:21 +080014#include <spl.h>
Simon Glass401d1c42020-10-30 21:38:53 -060015#include <asm/global_data.h>
Peng Fan439321b2019-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 Fan439321b2019-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 Fan439321b2019-12-30 17:46:21 +080047 puts("Normal Boot\n");
Peng Fan439321b2019-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 Szymanskieefd93e2020-06-30 15:03:13 +020072 ret = power_pca9450_init(I2C_PMIC);
Peng Fan439321b2019-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 */
87 pmic_reg_write(p, PCA9450_BUCK1OUT_DVS0, 0x1C);
88 pmic_reg_write(p, PCA9450_BUCK1OUT_DVS1, 0x14);
89 pmic_reg_write(p, PCA9450_BUCK1CTRL, 0x59);
90
91 /* set WDOG_B_CFG to cold reset */
92 pmic_reg_write(p, PCA9450_RESET_CTRL, 0xA1);
93
94 return 0;
95}
96#endif
97
98#ifdef CONFIG_SPL_LOAD_FIT
99int board_fit_config_name_match(const char *name)
100{
101 /* Just empty function now - can't decide what to choose */
102 debug("%s: %s\n", __func__, name);
103
104 return 0;
105}
106#endif
107
Peng Fan0ec9d5b2020-05-26 20:33:49 -0300108/* Do not use BSS area in this phase */
Peng Fan439321b2019-12-30 17:46:21 +0800109void board_init_f(ulong dummy)
110{
111 int ret;
112
113 arch_cpu_init();
114
115 init_uart_clk(1);
116
117 board_early_init_f();
118
Peng Fanbdada3b2020-05-26 20:33:48 -0300119 ret = spl_early_init();
Peng Fan439321b2019-12-30 17:46:21 +0800120 if (ret) {
121 debug("spl_init() failed: %d\n", ret);
122 hang();
123 }
124
Peng Fanbdada3b2020-05-26 20:33:48 -0300125 preloader_console_init();
126
Peng Fan439321b2019-12-30 17:46:21 +0800127 enable_tzc380();
128
Peng Fan439321b2019-12-30 17:46:21 +0800129 setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info1);
130
131 power_init_board();
132
133 /* DDR initialization */
134 spl_dram_init();
Peng Fan439321b2019-12-30 17:46:21 +0800135}