1ced8f770aad02ada8ceaddf11380d2188042e9f
[pandora-u-boot.git] / board / freescale / imx8qxp_mek / spl.c
1 /*
2  * Copyright 2018 NXP
3  *
4  * SPDX-License-Identifier:     GPL-2.0+
5  */
6
7 #include <common.h>
8 #include <dm.h>
9 #include <image.h>
10 #include <spl.h>
11 #include <dm/uclass.h>
12 #include <dm/device.h>
13 #include <dm/uclass-internal.h>
14 #include <dm/device-internal.h>
15 #include <dm/lists.h>
16 #include <asm/io.h>
17 #include <asm/gpio.h>
18 #include <asm/arch/sci/sci.h>
19 #include <asm/arch/imx8-pins.h>
20 #include <asm/arch/iomux.h>
21 #include <asm/arch/sys_proto.h>
22
23 DECLARE_GLOBAL_DATA_PTR;
24
25 #define GPIO_PAD_CTRL   ((SC_PAD_CONFIG_NORMAL << PADRING_CONFIG_SHIFT) | \
26                          (SC_PAD_ISO_OFF << PADRING_LPCONFIG_SHIFT) | \
27                          (SC_PAD_28FDSOI_DSE_DV_HIGH << PADRING_DSE_SHIFT) | \
28                          (SC_PAD_28FDSOI_PS_PU << PADRING_PULL_SHIFT))
29
30 #define USDHC2_SD_PWR IMX_GPIO_NR(4, 19)
31 static iomux_cfg_t usdhc2_sd_pwr[] = {
32         SC_P_USDHC1_RESET_B | MUX_PAD_CTRL(GPIO_PAD_CTRL),
33 };
34
35 void spl_board_init(void)
36 {
37         struct udevice *dev;
38
39         uclass_find_first_device(UCLASS_MISC, &dev);
40
41         for (; dev; uclass_find_next_device(&dev)) {
42                 if (device_probe(dev))
43                         continue;
44         }
45
46         arch_cpu_init();
47
48         board_early_init_f();
49
50         timer_init();
51
52         imx8_iomux_setup_multiple_pads(usdhc2_sd_pwr, ARRAY_SIZE(usdhc2_sd_pwr));
53         gpio_direction_output(USDHC2_SD_PWR, 0);
54
55         preloader_console_init();
56
57         puts("Normal Boot\n");
58 }
59
60 void spl_board_prepare_for_boot(void)
61 {
62         imx8_power_off_pd_devices(NULL, 0);
63 }
64
65 #ifdef CONFIG_SPL_LOAD_FIT
66 int board_fit_config_name_match(const char *name)
67 {
68         /* Just empty function now - can't decide what to choose */
69         debug("%s: %s\n", __func__, name);
70
71         return 0;
72 }
73 #endif
74
75 void board_init_f(ulong dummy)
76 {
77         /* Clear global data */
78         memset((void *)gd, 0, sizeof(gd_t));
79
80         /* Clear the BSS. */
81         memset(__bss_start, 0, __bss_end - __bss_start);
82
83         board_init_r(NULL, 0);
84 }