blob: 05e3c0a2ff26ab99f1c8933771d308bccc8f7fec [file] [log] [blame]
Gaurav Jaincb5d0412022-03-24 11:50:33 +05301// SPDX-License-Identifier: GPL-2.0-or-later
Peng Fan018e3fd2018-12-21 06:21:34 +00002/*
Gaurav Jaincb5d0412022-03-24 11:50:33 +05303 * Copyright 2018, 2021 NXP
Peng Fan018e3fd2018-12-21 06:21:34 +00004 *
Peng Fan018e3fd2018-12-21 06:21:34 +00005 */
6
Peng Fan018e3fd2018-12-21 06:21:34 +00007#include <dm.h>
Simon Glass4d72caa2020-05-10 11:40:01 -06008#include <image.h>
Simon Glass691d7192020-05-10 11:40:02 -06009#include <init.h>
Simon Glassf7ae49f2020-05-10 11:40:05 -060010#include <log.h>
Peng Fan018e3fd2018-12-21 06:21:34 +000011#include <spl.h>
Simon Glass401d1c42020-10-30 21:38:53 -060012#include <asm/global_data.h>
Peng Fan018e3fd2018-12-21 06:21:34 +000013#include <dm/uclass.h>
14#include <dm/device.h>
15#include <dm/uclass-internal.h>
16#include <dm/device-internal.h>
17#include <dm/lists.h>
Fabio Estevam168fff22020-04-15 15:01:34 -030018#include <asm/io.h>
19#include <asm/gpio.h>
Peng Fan99ac6c72023-04-28 12:08:09 +080020#include <firmware/imx/sci/sci.h>
Fabio Estevam168fff22020-04-15 15:01:34 -030021#include <asm/arch/imx8-pins.h>
22#include <asm/arch/iomux.h>
Peng Fan231401d2020-05-05 20:28:40 +080023#include <asm/arch/sys_proto.h>
Shiji Yang506df9d2023-08-03 09:47:16 +080024#include <asm/sections.h>
Peng Fan018e3fd2018-12-21 06:21:34 +000025
26DECLARE_GLOBAL_DATA_PTR;
27
Fabio Estevam168fff22020-04-15 15:01:34 -030028#define GPIO_PAD_CTRL ((SC_PAD_CONFIG_NORMAL << PADRING_CONFIG_SHIFT) | \
29 (SC_PAD_ISO_OFF << PADRING_LPCONFIG_SHIFT) | \
30 (SC_PAD_28FDSOI_DSE_DV_HIGH << PADRING_DSE_SHIFT) | \
31 (SC_PAD_28FDSOI_PS_PU << PADRING_PULL_SHIFT))
32
33#define USDHC2_SD_PWR IMX_GPIO_NR(4, 19)
34static iomux_cfg_t usdhc2_sd_pwr[] = {
35 SC_P_USDHC1_RESET_B | MUX_PAD_CTRL(GPIO_PAD_CTRL),
36};
37
Peng Fan018e3fd2018-12-21 06:21:34 +000038void spl_board_init(void)
39{
40 struct udevice *dev;
Peng Fan018e3fd2018-12-21 06:21:34 +000041
Gaurav Jaincb5d0412022-03-24 11:50:33 +053042 uclass_get_device_by_driver(UCLASS_MISC, DM_DRIVER_GET(imx8_scu), &dev);
43
Peng Fan018e3fd2018-12-21 06:21:34 +000044 uclass_find_first_device(UCLASS_MISC, &dev);
45
46 for (; dev; uclass_find_next_device(&dev)) {
47 if (device_probe(dev))
48 continue;
49 }
50
Peng Fan018e3fd2018-12-21 06:21:34 +000051 arch_cpu_init();
52
53 board_early_init_f();
54
55 timer_init();
56
Fabio Estevam168fff22020-04-15 15:01:34 -030057 imx8_iomux_setup_multiple_pads(usdhc2_sd_pwr, ARRAY_SIZE(usdhc2_sd_pwr));
58 gpio_direction_output(USDHC2_SD_PWR, 0);
59
Peng Fan018e3fd2018-12-21 06:21:34 +000060 preloader_console_init();
61
62 puts("Normal Boot\n");
63}
64
Peng Fan231401d2020-05-05 20:28:40 +080065void spl_board_prepare_for_boot(void)
66{
Peng Faned5b2532020-05-05 20:28:43 +080067 imx8_power_off_pd_devices(NULL, 0);
Peng Fan231401d2020-05-05 20:28:40 +080068}
69
Peng Fan018e3fd2018-12-21 06:21:34 +000070#ifdef CONFIG_SPL_LOAD_FIT
71int board_fit_config_name_match(const char *name)
72{
73 /* Just empty function now - can't decide what to choose */
74 debug("%s: %s\n", __func__, name);
75
76 return 0;
77}
78#endif
79
80void board_init_f(ulong dummy)
81{
82 /* Clear global data */
83 memset((void *)gd, 0, sizeof(gd_t));
84
85 /* Clear the BSS. */
86 memset(__bss_start, 0, __bss_end - __bss_start);
87
88 board_init_r(NULL, 0);
89}