Peng Fan | 0b2236d | 2018-12-21 06:21:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 NXP |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <dm.h> |
Simon Glass | 2dc9c34 | 2020-05-10 11:40:01 -0600 | [diff] [blame] | 9 | #include <image.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 10 | #include <init.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 11 | #include <log.h> |
Peng Fan | 0b2236d | 2018-12-21 06:21:34 +0000 | [diff] [blame] | 12 | #include <spl.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 13 | #include <asm/global_data.h> |
Peng Fan | 0b2236d | 2018-12-21 06:21:34 +0000 | [diff] [blame] | 14 | #include <dm/uclass.h> |
| 15 | #include <dm/device.h> |
| 16 | #include <dm/uclass-internal.h> |
| 17 | #include <dm/device-internal.h> |
| 18 | #include <dm/lists.h> |
Fabio Estevam | af4d6e7 | 2020-04-15 15:01:34 -0300 | [diff] [blame] | 19 | #include <asm/io.h> |
| 20 | #include <asm/gpio.h> |
| 21 | #include <asm/arch/sci/sci.h> |
| 22 | #include <asm/arch/imx8-pins.h> |
| 23 | #include <asm/arch/iomux.h> |
Peng Fan | 1b9729a | 2020-05-05 20:28:40 +0800 | [diff] [blame] | 24 | #include <asm/arch/sys_proto.h> |
Peng Fan | 0b2236d | 2018-12-21 06:21:34 +0000 | [diff] [blame] | 25 | |
| 26 | DECLARE_GLOBAL_DATA_PTR; |
| 27 | |
Fabio Estevam | af4d6e7 | 2020-04-15 15:01:34 -0300 | [diff] [blame] | 28 | #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) |
| 34 | static iomux_cfg_t usdhc2_sd_pwr[] = { |
| 35 | SC_P_USDHC1_RESET_B | MUX_PAD_CTRL(GPIO_PAD_CTRL), |
| 36 | }; |
| 37 | |
Peng Fan | 0b2236d | 2018-12-21 06:21:34 +0000 | [diff] [blame] | 38 | void spl_board_init(void) |
| 39 | { |
| 40 | struct udevice *dev; |
Peng Fan | 0b2236d | 2018-12-21 06:21:34 +0000 | [diff] [blame] | 41 | |
| 42 | uclass_find_first_device(UCLASS_MISC, &dev); |
| 43 | |
| 44 | for (; dev; uclass_find_next_device(&dev)) { |
| 45 | if (device_probe(dev)) |
| 46 | continue; |
| 47 | } |
| 48 | |
Peng Fan | 0b2236d | 2018-12-21 06:21:34 +0000 | [diff] [blame] | 49 | arch_cpu_init(); |
| 50 | |
| 51 | board_early_init_f(); |
| 52 | |
| 53 | timer_init(); |
| 54 | |
Fabio Estevam | af4d6e7 | 2020-04-15 15:01:34 -0300 | [diff] [blame] | 55 | imx8_iomux_setup_multiple_pads(usdhc2_sd_pwr, ARRAY_SIZE(usdhc2_sd_pwr)); |
| 56 | gpio_direction_output(USDHC2_SD_PWR, 0); |
| 57 | |
Peng Fan | 0b2236d | 2018-12-21 06:21:34 +0000 | [diff] [blame] | 58 | preloader_console_init(); |
| 59 | |
| 60 | puts("Normal Boot\n"); |
| 61 | } |
| 62 | |
Peng Fan | 1b9729a | 2020-05-05 20:28:40 +0800 | [diff] [blame] | 63 | void spl_board_prepare_for_boot(void) |
| 64 | { |
Peng Fan | 2d65a16 | 2020-05-05 20:28:43 +0800 | [diff] [blame] | 65 | imx8_power_off_pd_devices(NULL, 0); |
Peng Fan | 1b9729a | 2020-05-05 20:28:40 +0800 | [diff] [blame] | 66 | } |
| 67 | |
Peng Fan | 0b2236d | 2018-12-21 06:21:34 +0000 | [diff] [blame] | 68 | #ifdef CONFIG_SPL_LOAD_FIT |
| 69 | int board_fit_config_name_match(const char *name) |
| 70 | { |
| 71 | /* Just empty function now - can't decide what to choose */ |
| 72 | debug("%s: %s\n", __func__, name); |
| 73 | |
| 74 | return 0; |
| 75 | } |
| 76 | #endif |
| 77 | |
| 78 | void board_init_f(ulong dummy) |
| 79 | { |
| 80 | /* Clear global data */ |
| 81 | memset((void *)gd, 0, sizeof(gd_t)); |
| 82 | |
| 83 | /* Clear the BSS. */ |
| 84 | memset(__bss_start, 0, __bss_end - __bss_start); |
| 85 | |
| 86 | board_init_r(NULL, 0); |
| 87 | } |