2019-08-27 06:26:08 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
/*
|
2022-03-24 06:20:27 +00:00
|
|
|
* Copyright 2019, 2021 NXP
|
2019-08-27 06:26:08 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2020-05-10 17:40:03 +00:00
|
|
|
#include <command.h>
|
2019-12-28 17:45:01 +00:00
|
|
|
#include <cpu_func.h>
|
2019-12-28 17:45:07 +00:00
|
|
|
#include <hang.h>
|
2020-05-10 17:40:01 +00:00
|
|
|
#include <image.h>
|
2020-05-10 17:40:02 +00:00
|
|
|
#include <init.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2019-08-27 06:26:08 +00:00
|
|
|
#include <spl.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2019-08-27 06:26:08 +00:00
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/mach-imx/iomux-v3.h>
|
|
|
|
#include <asm/arch/clock.h>
|
|
|
|
#include <asm/arch/imx8mm_pins.h>
|
|
|
|
#include <asm/arch/sys_proto.h>
|
|
|
|
#include <asm/mach-imx/boot_mode.h>
|
|
|
|
#include <asm/arch/ddr.h>
|
|
|
|
|
|
|
|
#include <dm/uclass.h>
|
|
|
|
#include <dm/device.h>
|
|
|
|
#include <dm/uclass-internal.h>
|
|
|
|
#include <dm/device-internal.h>
|
|
|
|
|
2019-10-16 10:24:42 +00:00
|
|
|
#include <power/pmic.h>
|
2021-03-19 07:56:55 +00:00
|
|
|
#include <power/pca9450.h>
|
2019-10-16 10:24:42 +00:00
|
|
|
|
2019-08-27 06:26:08 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
|
|
|
int spl_board_boot_device(enum boot_device boot_dev_spl)
|
|
|
|
{
|
|
|
|
switch (boot_dev_spl) {
|
|
|
|
case SD2_BOOT:
|
|
|
|
case MMC2_BOOT:
|
|
|
|
return BOOT_DEVICE_MMC1;
|
|
|
|
case SD3_BOOT:
|
|
|
|
case MMC3_BOOT:
|
|
|
|
return BOOT_DEVICE_MMC2;
|
|
|
|
default:
|
|
|
|
return BOOT_DEVICE_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-14 18:55:00 +00:00
|
|
|
static void spl_dram_init(void)
|
2019-08-27 06:26:08 +00:00
|
|
|
{
|
|
|
|
ddr_init(&dram_timing);
|
|
|
|
}
|
|
|
|
|
|
|
|
void spl_board_init(void)
|
|
|
|
{
|
2022-03-24 06:20:27 +00:00
|
|
|
if (IS_ENABLED(CONFIG_FSL_CAAM)) {
|
|
|
|
struct udevice *dev;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = uclass_get_device_by_driver(UCLASS_MISC, DM_DRIVER_GET(caam_jr), &dev);
|
|
|
|
if (ret)
|
|
|
|
printf("Failed to initialize %s: %d\n", dev->name, ret);
|
|
|
|
}
|
2019-08-27 06:26:08 +00:00
|
|
|
puts("Normal Boot\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_SPL_LOAD_FIT
|
|
|
|
int board_fit_config_name_match(const char *name)
|
|
|
|
{
|
|
|
|
/* Just empty function now - can't decide what to choose */
|
|
|
|
debug("%s: %s\n", __func__, name);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-01-14 18:55:00 +00:00
|
|
|
static int power_init_board(void)
|
2019-10-16 10:24:42 +00:00
|
|
|
{
|
|
|
|
struct udevice *dev;
|
|
|
|
int ret;
|
|
|
|
|
2021-03-19 07:56:55 +00:00
|
|
|
ret = pmic_get("pca9450@25", &dev);
|
2019-10-16 10:24:42 +00:00
|
|
|
if (ret == -ENODEV) {
|
|
|
|
puts("No pmic\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (ret != 0)
|
|
|
|
return ret;
|
|
|
|
|
2021-03-19 07:56:55 +00:00
|
|
|
/* BUCKxOUT_DVS0/1 control BUCK123 output */
|
|
|
|
pmic_reg_write(dev, PCA9450_BUCK123_DVS, 0x29);
|
2019-10-16 10:24:42 +00:00
|
|
|
|
2021-03-19 07:56:55 +00:00
|
|
|
/* Buck 1 DVS control through PMIC_STBY_REQ */
|
|
|
|
pmic_reg_write(dev, PCA9450_BUCK1CTRL, 0x59);
|
2019-10-16 10:24:42 +00:00
|
|
|
|
2021-03-19 07:56:55 +00:00
|
|
|
/* Set DVS1 to 0.8v for suspend */
|
|
|
|
pmic_reg_write(dev, PCA9450_BUCK1OUT_DVS1, 0x10);
|
2019-10-16 10:24:42 +00:00
|
|
|
|
2021-03-19 07:56:55 +00:00
|
|
|
/* increase VDD_DRAM to 0.95v for 3Ghz DDR */
|
|
|
|
pmic_reg_write(dev, PCA9450_BUCK3OUT_DVS0, 0x1C);
|
2019-10-16 10:24:42 +00:00
|
|
|
|
2021-03-19 07:56:55 +00:00
|
|
|
/* VDD_DRAM needs off in suspend, set B1_ENMODE=10 (ON by PMIC_ON_REQ = H && PMIC_STBY_REQ = L) */
|
|
|
|
pmic_reg_write(dev, PCA9450_BUCK3CTRL, 0x4a);
|
|
|
|
|
|
|
|
/* set VDD_SNVS_0V8 from default 0.85V */
|
|
|
|
pmic_reg_write(dev, PCA9450_LDO2CTRL, 0xC0);
|
2019-10-16 10:24:42 +00:00
|
|
|
|
2021-03-19 07:56:55 +00:00
|
|
|
/* set WDOG_B_CFG to cold reset */
|
|
|
|
pmic_reg_write(dev, PCA9450_RESET_CTRL, 0xA1);
|
2019-10-16 10:24:42 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-08-27 06:26:08 +00:00
|
|
|
void board_init_f(ulong dummy)
|
|
|
|
{
|
2019-10-16 10:24:39 +00:00
|
|
|
struct udevice *dev;
|
2019-08-27 06:26:08 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
arch_cpu_init();
|
|
|
|
|
|
|
|
init_uart_clk(1);
|
|
|
|
|
|
|
|
timer_init();
|
|
|
|
|
|
|
|
/* Clear the BSS. */
|
|
|
|
memset(__bss_start, 0, __bss_end - __bss_start);
|
|
|
|
|
2019-10-16 10:24:39 +00:00
|
|
|
ret = spl_early_init();
|
2019-08-27 06:26:08 +00:00
|
|
|
if (ret) {
|
2019-10-16 10:24:39 +00:00
|
|
|
debug("spl_early_init() failed: %d\n", ret);
|
|
|
|
hang();
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = uclass_get_device_by_name(UCLASS_CLK,
|
|
|
|
"clock-controller@30380000",
|
|
|
|
&dev);
|
|
|
|
if (ret < 0) {
|
|
|
|
printf("Failed to find clock node. Check device tree\n");
|
2019-08-27 06:26:08 +00:00
|
|
|
hang();
|
|
|
|
}
|
|
|
|
|
2022-04-15 04:35:34 +00:00
|
|
|
preloader_console_init();
|
|
|
|
|
2019-08-27 06:26:08 +00:00
|
|
|
enable_tzc380();
|
|
|
|
|
2019-10-16 10:24:42 +00:00
|
|
|
power_init_board();
|
|
|
|
|
2019-08-27 06:26:08 +00:00
|
|
|
/* DDR initialization */
|
|
|
|
spl_dram_init();
|
|
|
|
|
|
|
|
board_init_r(NULL, 0);
|
|
|
|
}
|