blob: e4e4cbe7163cd46091f77a92ed709ae9bbded823 [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>
9#include <spl.h>
10#include <dm/uclass.h>
11#include <dm/device.h>
12#include <dm/uclass-internal.h>
13#include <dm/device-internal.h>
14#include <dm/lists.h>
Fabio Estevamaf4d6e72020-04-15 15:01:34 -030015#include <asm/io.h>
16#include <asm/gpio.h>
17#include <asm/arch/sci/sci.h>
18#include <asm/arch/imx8-pins.h>
19#include <asm/arch/iomux.h>
Peng Fan0b2236d2018-12-21 06:21:34 +000020
21DECLARE_GLOBAL_DATA_PTR;
22
Fabio Estevamaf4d6e72020-04-15 15:01:34 -030023#define GPIO_PAD_CTRL ((SC_PAD_CONFIG_NORMAL << PADRING_CONFIG_SHIFT) | \
24 (SC_PAD_ISO_OFF << PADRING_LPCONFIG_SHIFT) | \
25 (SC_PAD_28FDSOI_DSE_DV_HIGH << PADRING_DSE_SHIFT) | \
26 (SC_PAD_28FDSOI_PS_PU << PADRING_PULL_SHIFT))
27
28#define USDHC2_SD_PWR IMX_GPIO_NR(4, 19)
29static iomux_cfg_t usdhc2_sd_pwr[] = {
30 SC_P_USDHC1_RESET_B | MUX_PAD_CTRL(GPIO_PAD_CTRL),
31};
32
Peng Fan0b2236d2018-12-21 06:21:34 +000033void spl_board_init(void)
34{
35 struct udevice *dev;
Peng Fan0b2236d2018-12-21 06:21:34 +000036
37 uclass_find_first_device(UCLASS_MISC, &dev);
38
39 for (; dev; uclass_find_next_device(&dev)) {
40 if (device_probe(dev))
41 continue;
42 }
43
Peng Fan0b2236d2018-12-21 06:21:34 +000044 arch_cpu_init();
45
46 board_early_init_f();
47
48 timer_init();
49
Fabio Estevamaf4d6e72020-04-15 15:01:34 -030050 imx8_iomux_setup_multiple_pads(usdhc2_sd_pwr, ARRAY_SIZE(usdhc2_sd_pwr));
51 gpio_direction_output(USDHC2_SD_PWR, 0);
52
Peng Fan0b2236d2018-12-21 06:21:34 +000053 preloader_console_init();
54
55 puts("Normal Boot\n");
56}
57
58#ifdef CONFIG_SPL_LOAD_FIT
59int board_fit_config_name_match(const char *name)
60{
61 /* Just empty function now - can't decide what to choose */
62 debug("%s: %s\n", __func__, name);
63
64 return 0;
65}
66#endif
67
68void board_init_f(ulong dummy)
69{
70 /* Clear global data */
71 memset((void *)gd, 0, sizeof(gd_t));
72
73 /* Clear the BSS. */
74 memset(__bss_start, 0, __bss_end - __bss_start);
75
76 board_init_r(NULL, 0);
77}