Peng Fan | 018e3fd | 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> |
| 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 Estevam | 168fff2 | 2020-04-15 15:01:34 -0300 | [diff] [blame] | 15 | #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 Fan | 231401d | 2020-05-05 20:28:40 +0800 | [diff] [blame] | 20 | #include <asm/arch/sys_proto.h> |
Peng Fan | 018e3fd | 2018-12-21 06:21:34 +0000 | [diff] [blame] | 21 | |
| 22 | DECLARE_GLOBAL_DATA_PTR; |
| 23 | |
Fabio Estevam | 168fff2 | 2020-04-15 15:01:34 -0300 | [diff] [blame] | 24 | #define GPIO_PAD_CTRL ((SC_PAD_CONFIG_NORMAL << PADRING_CONFIG_SHIFT) | \ |
| 25 | (SC_PAD_ISO_OFF << PADRING_LPCONFIG_SHIFT) | \ |
| 26 | (SC_PAD_28FDSOI_DSE_DV_HIGH << PADRING_DSE_SHIFT) | \ |
| 27 | (SC_PAD_28FDSOI_PS_PU << PADRING_PULL_SHIFT)) |
| 28 | |
| 29 | #define USDHC2_SD_PWR IMX_GPIO_NR(4, 19) |
| 30 | static iomux_cfg_t usdhc2_sd_pwr[] = { |
| 31 | SC_P_USDHC1_RESET_B | MUX_PAD_CTRL(GPIO_PAD_CTRL), |
| 32 | }; |
| 33 | |
Peng Fan | 018e3fd | 2018-12-21 06:21:34 +0000 | [diff] [blame] | 34 | void spl_board_init(void) |
| 35 | { |
| 36 | struct udevice *dev; |
Peng Fan | 018e3fd | 2018-12-21 06:21:34 +0000 | [diff] [blame] | 37 | |
| 38 | uclass_find_first_device(UCLASS_MISC, &dev); |
| 39 | |
| 40 | for (; dev; uclass_find_next_device(&dev)) { |
| 41 | if (device_probe(dev)) |
| 42 | continue; |
| 43 | } |
| 44 | |
Peng Fan | 018e3fd | 2018-12-21 06:21:34 +0000 | [diff] [blame] | 45 | arch_cpu_init(); |
| 46 | |
| 47 | board_early_init_f(); |
| 48 | |
| 49 | timer_init(); |
| 50 | |
Fabio Estevam | 168fff2 | 2020-04-15 15:01:34 -0300 | [diff] [blame] | 51 | imx8_iomux_setup_multiple_pads(usdhc2_sd_pwr, ARRAY_SIZE(usdhc2_sd_pwr)); |
| 52 | gpio_direction_output(USDHC2_SD_PWR, 0); |
| 53 | |
Peng Fan | 018e3fd | 2018-12-21 06:21:34 +0000 | [diff] [blame] | 54 | preloader_console_init(); |
| 55 | |
| 56 | puts("Normal Boot\n"); |
| 57 | } |
| 58 | |
Peng Fan | 231401d | 2020-05-05 20:28:40 +0800 | [diff] [blame] | 59 | void spl_board_prepare_for_boot(void) |
| 60 | { |
Peng Fan | ed5b253 | 2020-05-05 20:28:43 +0800 | [diff] [blame] | 61 | imx8_power_off_pd_devices(NULL, 0); |
Peng Fan | 231401d | 2020-05-05 20:28:40 +0800 | [diff] [blame] | 62 | } |
| 63 | |
Peng Fan | 018e3fd | 2018-12-21 06:21:34 +0000 | [diff] [blame] | 64 | #ifdef CONFIG_SPL_LOAD_FIT |
| 65 | int board_fit_config_name_match(const char *name) |
| 66 | { |
| 67 | /* Just empty function now - can't decide what to choose */ |
| 68 | debug("%s: %s\n", __func__, name); |
| 69 | |
| 70 | return 0; |
| 71 | } |
| 72 | #endif |
| 73 | |
| 74 | void board_init_f(ulong dummy) |
| 75 | { |
| 76 | /* Clear global data */ |
| 77 | memset((void *)gd, 0, sizeof(gd_t)); |
| 78 | |
| 79 | /* Clear the BSS. */ |
| 80 | memset(__bss_start, 0, __bss_end - __bss_start); |
| 81 | |
| 82 | board_init_r(NULL, 0); |
| 83 | } |