blob: 881d297cf17fe46a0c37fa2925f2fdf9ce08abc1 [file] [log] [blame]
Peng Fan0b2236d2018-12-21 06:21:34 +00001/*
2 * Copyright 2018 NXP
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#include <common.h>
8#include <dm.h>
Simon Glass2dc9c342020-05-10 11:40:01 -06009#include <image.h>
Simon Glass97589732020-05-10 11:40:02 -060010#include <init.h>
Simon Glass0f2af882020-05-10 11:40:05 -060011#include <log.h>
Peng Fan0b2236d2018-12-21 06:21:34 +000012#include <spl.h>
13#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 Estevamaf4d6e72020-04-15 15:01:34 -030018#include <asm/io.h>
19#include <asm/gpio.h>
20#include <asm/arch/sci/sci.h>
21#include <asm/arch/imx8-pins.h>
22#include <asm/arch/iomux.h>
Peng Fan1b9729a2020-05-05 20:28:40 +080023#include <asm/arch/sys_proto.h>
Peng Fan0b2236d2018-12-21 06:21:34 +000024
25DECLARE_GLOBAL_DATA_PTR;
26
Fabio Estevamaf4d6e72020-04-15 15:01:34 -030027#define GPIO_PAD_CTRL ((SC_PAD_CONFIG_NORMAL << PADRING_CONFIG_SHIFT) | \
28 (SC_PAD_ISO_OFF << PADRING_LPCONFIG_SHIFT) | \
29 (SC_PAD_28FDSOI_DSE_DV_HIGH << PADRING_DSE_SHIFT) | \
30 (SC_PAD_28FDSOI_PS_PU << PADRING_PULL_SHIFT))
31
32#define USDHC2_SD_PWR IMX_GPIO_NR(4, 19)
33static iomux_cfg_t usdhc2_sd_pwr[] = {
34 SC_P_USDHC1_RESET_B | MUX_PAD_CTRL(GPIO_PAD_CTRL),
35};
36
Peng Fan0b2236d2018-12-21 06:21:34 +000037void spl_board_init(void)
38{
39 struct udevice *dev;
Peng Fan0b2236d2018-12-21 06:21:34 +000040
41 uclass_find_first_device(UCLASS_MISC, &dev);
42
43 for (; dev; uclass_find_next_device(&dev)) {
44 if (device_probe(dev))
45 continue;
46 }
47
Peng Fan0b2236d2018-12-21 06:21:34 +000048 arch_cpu_init();
49
50 board_early_init_f();
51
52 timer_init();
53
Fabio Estevamaf4d6e72020-04-15 15:01:34 -030054 imx8_iomux_setup_multiple_pads(usdhc2_sd_pwr, ARRAY_SIZE(usdhc2_sd_pwr));
55 gpio_direction_output(USDHC2_SD_PWR, 0);
56
Peng Fan0b2236d2018-12-21 06:21:34 +000057 preloader_console_init();
58
59 puts("Normal Boot\n");
60}
61
Peng Fan1b9729a2020-05-05 20:28:40 +080062void spl_board_prepare_for_boot(void)
63{
Peng Fan2d65a162020-05-05 20:28:43 +080064 imx8_power_off_pd_devices(NULL, 0);
Peng Fan1b9729a2020-05-05 20:28:40 +080065}
66
Peng Fan0b2236d2018-12-21 06:21:34 +000067#ifdef CONFIG_SPL_LOAD_FIT
68int board_fit_config_name_match(const char *name)
69{
70 /* Just empty function now - can't decide what to choose */
71 debug("%s: %s\n", __func__, name);
72
73 return 0;
74}
75#endif
76
77void board_init_f(ulong dummy)
78{
79 /* Clear global data */
80 memset((void *)gd, 0, sizeof(gd_t));
81
82 /* Clear the BSS. */
83 memset(__bss_start, 0, __bss_end - __bss_start);
84
85 board_init_r(NULL, 0);
86}