Gaurav Jain | cb5d041 | 2022-03-24 11:50:33 +0530 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Peng Fan | 018e3fd | 2018-12-21 06:21:34 +0000 | [diff] [blame] | 2 | /* |
Gaurav Jain | cb5d041 | 2022-03-24 11:50:33 +0530 | [diff] [blame] | 3 | * Copyright 2018, 2021 NXP |
Peng Fan | 018e3fd | 2018-12-21 06:21:34 +0000 | [diff] [blame] | 4 | * |
Peng Fan | 018e3fd | 2018-12-21 06:21:34 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <dm.h> |
Simon Glass | 4d72caa | 2020-05-10 11:40:01 -0600 | [diff] [blame] | 9 | #include <image.h> |
Simon Glass | 691d719 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 10 | #include <init.h> |
Simon Glass | f7ae49f | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 11 | #include <log.h> |
Peng Fan | 018e3fd | 2018-12-21 06:21:34 +0000 | [diff] [blame] | 12 | #include <spl.h> |
Simon Glass | 401d1c4 | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 13 | #include <asm/global_data.h> |
Peng Fan | 018e3fd | 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 | 168fff2 | 2020-04-15 15:01:34 -0300 | [diff] [blame] | 19 | #include <asm/io.h> |
| 20 | #include <asm/gpio.h> |
Peng Fan | 99ac6c7 | 2023-04-28 12:08:09 +0800 | [diff] [blame] | 21 | #include <firmware/imx/sci/sci.h> |
Fabio Estevam | 168fff2 | 2020-04-15 15:01:34 -0300 | [diff] [blame] | 22 | #include <asm/arch/imx8-pins.h> |
| 23 | #include <asm/arch/iomux.h> |
Peng Fan | 231401d | 2020-05-05 20:28:40 +0800 | [diff] [blame] | 24 | #include <asm/arch/sys_proto.h> |
Shiji Yang | 506df9d | 2023-08-03 09:47:16 +0800 | [diff] [blame] | 25 | #include <asm/sections.h> |
Peng Fan | 018e3fd | 2018-12-21 06:21:34 +0000 | [diff] [blame] | 26 | |
| 27 | DECLARE_GLOBAL_DATA_PTR; |
| 28 | |
Fabio Estevam | 168fff2 | 2020-04-15 15:01:34 -0300 | [diff] [blame] | 29 | #define GPIO_PAD_CTRL ((SC_PAD_CONFIG_NORMAL << PADRING_CONFIG_SHIFT) | \ |
| 30 | (SC_PAD_ISO_OFF << PADRING_LPCONFIG_SHIFT) | \ |
| 31 | (SC_PAD_28FDSOI_DSE_DV_HIGH << PADRING_DSE_SHIFT) | \ |
| 32 | (SC_PAD_28FDSOI_PS_PU << PADRING_PULL_SHIFT)) |
| 33 | |
| 34 | #define USDHC2_SD_PWR IMX_GPIO_NR(4, 19) |
| 35 | static iomux_cfg_t usdhc2_sd_pwr[] = { |
| 36 | SC_P_USDHC1_RESET_B | MUX_PAD_CTRL(GPIO_PAD_CTRL), |
| 37 | }; |
| 38 | |
Peng Fan | 018e3fd | 2018-12-21 06:21:34 +0000 | [diff] [blame] | 39 | void spl_board_init(void) |
| 40 | { |
| 41 | struct udevice *dev; |
Peng Fan | 018e3fd | 2018-12-21 06:21:34 +0000 | [diff] [blame] | 42 | |
Gaurav Jain | cb5d041 | 2022-03-24 11:50:33 +0530 | [diff] [blame] | 43 | uclass_get_device_by_driver(UCLASS_MISC, DM_DRIVER_GET(imx8_scu), &dev); |
| 44 | |
Peng Fan | 018e3fd | 2018-12-21 06:21:34 +0000 | [diff] [blame] | 45 | uclass_find_first_device(UCLASS_MISC, &dev); |
| 46 | |
| 47 | for (; dev; uclass_find_next_device(&dev)) { |
| 48 | if (device_probe(dev)) |
| 49 | continue; |
| 50 | } |
| 51 | |
Peng Fan | 018e3fd | 2018-12-21 06:21:34 +0000 | [diff] [blame] | 52 | arch_cpu_init(); |
| 53 | |
| 54 | board_early_init_f(); |
| 55 | |
| 56 | timer_init(); |
| 57 | |
Fabio Estevam | 168fff2 | 2020-04-15 15:01:34 -0300 | [diff] [blame] | 58 | imx8_iomux_setup_multiple_pads(usdhc2_sd_pwr, ARRAY_SIZE(usdhc2_sd_pwr)); |
| 59 | gpio_direction_output(USDHC2_SD_PWR, 0); |
| 60 | |
Peng Fan | 018e3fd | 2018-12-21 06:21:34 +0000 | [diff] [blame] | 61 | preloader_console_init(); |
| 62 | |
| 63 | puts("Normal Boot\n"); |
| 64 | } |
| 65 | |
Peng Fan | 231401d | 2020-05-05 20:28:40 +0800 | [diff] [blame] | 66 | void spl_board_prepare_for_boot(void) |
| 67 | { |
Peng Fan | ed5b253 | 2020-05-05 20:28:43 +0800 | [diff] [blame] | 68 | imx8_power_off_pd_devices(NULL, 0); |
Peng Fan | 231401d | 2020-05-05 20:28:40 +0800 | [diff] [blame] | 69 | } |
| 70 | |
Peng Fan | 018e3fd | 2018-12-21 06:21:34 +0000 | [diff] [blame] | 71 | #ifdef CONFIG_SPL_LOAD_FIT |
| 72 | int board_fit_config_name_match(const char *name) |
| 73 | { |
| 74 | /* Just empty function now - can't decide what to choose */ |
| 75 | debug("%s: %s\n", __func__, name); |
| 76 | |
| 77 | return 0; |
| 78 | } |
| 79 | #endif |
| 80 | |
| 81 | void board_init_f(ulong dummy) |
| 82 | { |
| 83 | /* Clear global data */ |
| 84 | memset((void *)gd, 0, sizeof(gd_t)); |
| 85 | |
| 86 | /* Clear the BSS. */ |
| 87 | memset(__bss_start, 0, __bss_end - __bss_start); |
| 88 | |
| 89 | board_init_r(NULL, 0); |
| 90 | } |