blob: e07f35f2a8e4347b2d5d43b18d68eaa605180df4 [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>
Peng Fan0b2236d2018-12-21 06:21:34 +000011#include <spl.h>
12#include <dm/uclass.h>
13#include <dm/device.h>
14#include <dm/uclass-internal.h>
15#include <dm/device-internal.h>
16#include <dm/lists.h>
Fabio Estevamaf4d6e72020-04-15 15:01:34 -030017#include <asm/io.h>
18#include <asm/gpio.h>
19#include <asm/arch/sci/sci.h>
20#include <asm/arch/imx8-pins.h>
21#include <asm/arch/iomux.h>
Peng Fan1b9729a2020-05-05 20:28:40 +080022#include <asm/arch/sys_proto.h>
Peng Fan0b2236d2018-12-21 06:21:34 +000023
24DECLARE_GLOBAL_DATA_PTR;
25
Fabio Estevamaf4d6e72020-04-15 15:01:34 -030026#define GPIO_PAD_CTRL ((SC_PAD_CONFIG_NORMAL << PADRING_CONFIG_SHIFT) | \
27 (SC_PAD_ISO_OFF << PADRING_LPCONFIG_SHIFT) | \
28 (SC_PAD_28FDSOI_DSE_DV_HIGH << PADRING_DSE_SHIFT) | \
29 (SC_PAD_28FDSOI_PS_PU << PADRING_PULL_SHIFT))
30
31#define USDHC2_SD_PWR IMX_GPIO_NR(4, 19)
32static iomux_cfg_t usdhc2_sd_pwr[] = {
33 SC_P_USDHC1_RESET_B | MUX_PAD_CTRL(GPIO_PAD_CTRL),
34};
35
Peng Fan0b2236d2018-12-21 06:21:34 +000036void spl_board_init(void)
37{
38 struct udevice *dev;
Peng Fan0b2236d2018-12-21 06:21:34 +000039
40 uclass_find_first_device(UCLASS_MISC, &dev);
41
42 for (; dev; uclass_find_next_device(&dev)) {
43 if (device_probe(dev))
44 continue;
45 }
46
Peng Fan0b2236d2018-12-21 06:21:34 +000047 arch_cpu_init();
48
49 board_early_init_f();
50
51 timer_init();
52
Fabio Estevamaf4d6e72020-04-15 15:01:34 -030053 imx8_iomux_setup_multiple_pads(usdhc2_sd_pwr, ARRAY_SIZE(usdhc2_sd_pwr));
54 gpio_direction_output(USDHC2_SD_PWR, 0);
55
Peng Fan0b2236d2018-12-21 06:21:34 +000056 preloader_console_init();
57
58 puts("Normal Boot\n");
59}
60
Peng Fan1b9729a2020-05-05 20:28:40 +080061void spl_board_prepare_for_boot(void)
62{
Peng Fan2d65a162020-05-05 20:28:43 +080063 imx8_power_off_pd_devices(NULL, 0);
Peng Fan1b9729a2020-05-05 20:28:40 +080064}
65
Peng Fan0b2236d2018-12-21 06:21:34 +000066#ifdef CONFIG_SPL_LOAD_FIT
67int board_fit_config_name_match(const char *name)
68{
69 /* Just empty function now - can't decide what to choose */
70 debug("%s: %s\n", __func__, name);
71
72 return 0;
73}
74#endif
75
76void board_init_f(ulong dummy)
77{
78 /* Clear global data */
79 memset((void *)gd, 0, sizeof(gd_t));
80
81 /* Clear the BSS. */
82 memset(__bss_start, 0, __bss_end - __bss_start);
83
84 board_init_r(NULL, 0);
85}