Lokesh Vutla | ed0e605 | 2018-08-27 15:57:09 +0530 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
Andrew F. Davis | 9b322db | 2020-01-10 14:35:20 -0500 | [diff] [blame] | 3 | * AM6: SoC specific initialization |
Lokesh Vutla | ed0e605 | 2018-08-27 15:57:09 +0530 | [diff] [blame] | 4 | * |
| 5 | * Copyright (C) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/ |
| 6 | * Lokesh Vutla <lokeshvutla@ti.com> |
| 7 | */ |
| 8 | |
| 9 | #include <common.h> |
Simon Glass | 691d719 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 10 | #include <init.h> |
Lokesh Vutla | e006460 | 2018-08-27 15:57:11 +0530 | [diff] [blame] | 11 | #include <asm/io.h> |
Lokesh Vutla | ed0e605 | 2018-08-27 15:57:09 +0530 | [diff] [blame] | 12 | #include <spl.h> |
Lokesh Vutla | e006460 | 2018-08-27 15:57:11 +0530 | [diff] [blame] | 13 | #include <asm/arch/hardware.h> |
Andreas Dannenberg | c222e3d | 2019-06-04 17:55:50 -0500 | [diff] [blame] | 14 | #include <asm/arch/sysfw-loader.h> |
Andreas Dannenberg | 03facc7 | 2019-06-04 18:08:26 -0500 | [diff] [blame] | 15 | #include <asm/arch/sys_proto.h> |
Lokesh Vutla | 23f7b1a | 2018-11-02 19:51:03 +0530 | [diff] [blame] | 16 | #include "common.h" |
Lokesh Vutla | 59ebf4a | 2018-11-02 19:51:06 +0530 | [diff] [blame] | 17 | #include <dm.h> |
Andreas Dannenberg | c222e3d | 2019-06-04 17:55:50 -0500 | [diff] [blame] | 18 | #include <dm/uclass-internal.h> |
| 19 | #include <dm/pinctrl.h> |
Andreas Dannenberg | f9380a7 | 2019-06-07 19:24:42 +0530 | [diff] [blame] | 20 | #include <linux/soc/ti/ti_sci_protocol.h> |
Faiz Abbas | f9916b6 | 2020-08-03 11:35:06 +0530 | [diff] [blame] | 21 | #include <log.h> |
Faiz Abbas | d45ffb7 | 2020-02-26 13:44:36 +0530 | [diff] [blame] | 22 | #include <mmc.h> |
Faiz Abbas | f9916b6 | 2020-08-03 11:35:06 +0530 | [diff] [blame] | 23 | #include <stdlib.h> |
Lokesh Vutla | ed0e605 | 2018-08-27 15:57:09 +0530 | [diff] [blame] | 24 | |
| 25 | #ifdef CONFIG_SPL_BUILD |
Andrew F. Davis | ea70da1 | 2020-01-10 14:35:21 -0500 | [diff] [blame] | 26 | #ifdef CONFIG_K3_LOAD_SYSFW |
| 27 | #ifdef CONFIG_TI_SECURE_DEVICE |
| 28 | struct fwl_data main_cbass_fwls[] = { |
| 29 | { "MMCSD1_CFG", 2057, 1 }, |
| 30 | { "MMCSD0_CFG", 2058, 1 }, |
| 31 | { "USB3SS0_SLV0", 2176, 2 }, |
| 32 | { "PCIE0_SLV", 2336, 8 }, |
| 33 | { "PCIE1_SLV", 2337, 8 }, |
| 34 | { "PCIE0_CFG", 2688, 1 }, |
| 35 | { "PCIE1_CFG", 2689, 1 }, |
| 36 | }, mcu_cbass_fwls[] = { |
| 37 | { "MCU_ARMSS0_CORE0_SLV", 1024, 1 }, |
| 38 | { "MCU_ARMSS0_CORE1_SLV", 1028, 1 }, |
| 39 | { "MCU_FSS0_S1", 1033, 8 }, |
| 40 | { "MCU_FSS0_S0", 1036, 8 }, |
| 41 | { "MCU_CPSW0", 1220, 1 }, |
| 42 | }; |
| 43 | #endif |
| 44 | #endif |
| 45 | |
Andreas Dannenberg | c68721d | 2018-08-27 15:57:12 +0530 | [diff] [blame] | 46 | static void mmr_unlock(u32 base, u32 partition) |
| 47 | { |
| 48 | /* Translate the base address */ |
| 49 | phys_addr_t part_base = base + partition * CTRL_MMR0_PARTITION_SIZE; |
| 50 | |
| 51 | /* Unlock the requested partition if locked using two-step sequence */ |
| 52 | writel(CTRLMMR_LOCK_KICK0_UNLOCK_VAL, part_base + CTRLMMR_LOCK_KICK0); |
| 53 | writel(CTRLMMR_LOCK_KICK1_UNLOCK_VAL, part_base + CTRLMMR_LOCK_KICK1); |
| 54 | } |
| 55 | |
| 56 | static void ctrl_mmr_unlock(void) |
| 57 | { |
| 58 | /* Unlock all WKUP_CTRL_MMR0 module registers */ |
| 59 | mmr_unlock(WKUP_CTRL_MMR0_BASE, 0); |
| 60 | mmr_unlock(WKUP_CTRL_MMR0_BASE, 1); |
| 61 | mmr_unlock(WKUP_CTRL_MMR0_BASE, 2); |
| 62 | mmr_unlock(WKUP_CTRL_MMR0_BASE, 3); |
| 63 | mmr_unlock(WKUP_CTRL_MMR0_BASE, 6); |
| 64 | mmr_unlock(WKUP_CTRL_MMR0_BASE, 7); |
| 65 | |
| 66 | /* Unlock all MCU_CTRL_MMR0 module registers */ |
| 67 | mmr_unlock(MCU_CTRL_MMR0_BASE, 0); |
| 68 | mmr_unlock(MCU_CTRL_MMR0_BASE, 1); |
| 69 | mmr_unlock(MCU_CTRL_MMR0_BASE, 2); |
| 70 | mmr_unlock(MCU_CTRL_MMR0_BASE, 6); |
| 71 | |
| 72 | /* Unlock all CTRL_MMR0 module registers */ |
| 73 | mmr_unlock(CTRL_MMR0_BASE, 0); |
| 74 | mmr_unlock(CTRL_MMR0_BASE, 1); |
| 75 | mmr_unlock(CTRL_MMR0_BASE, 2); |
| 76 | mmr_unlock(CTRL_MMR0_BASE, 3); |
| 77 | mmr_unlock(CTRL_MMR0_BASE, 6); |
| 78 | mmr_unlock(CTRL_MMR0_BASE, 7); |
| 79 | } |
| 80 | |
Andrew F. Davis | 407a219 | 2019-04-12 12:54:42 -0400 | [diff] [blame] | 81 | /* |
| 82 | * This uninitialized global variable would normal end up in the .bss section, |
| 83 | * but the .bss is cleared between writing and reading this variable, so move |
| 84 | * it to the .data section. |
| 85 | */ |
| 86 | u32 bootindex __attribute__((section(".data"))); |
| 87 | |
Lokesh Vutla | e006460 | 2018-08-27 15:57:11 +0530 | [diff] [blame] | 88 | static void store_boot_index_from_rom(void) |
| 89 | { |
Andrew F. Davis | 407a219 | 2019-04-12 12:54:42 -0400 | [diff] [blame] | 90 | bootindex = *(u32 *)(CONFIG_SYS_K3_BOOT_PARAM_TABLE_INDEX); |
Lokesh Vutla | e006460 | 2018-08-27 15:57:11 +0530 | [diff] [blame] | 91 | } |
| 92 | |
Faiz Abbas | febb47a | 2020-08-03 11:35:08 +0530 | [diff] [blame^] | 93 | #if defined(CONFIG_K3_LOAD_SYSFW) && CONFIG_IS_ENABLED(DM_MMC) |
Faiz Abbas | d45ffb7 | 2020-02-26 13:44:36 +0530 | [diff] [blame] | 94 | void k3_mmc_stop_clock(void) |
| 95 | { |
| 96 | if (spl_boot_device() == BOOT_DEVICE_MMC1) { |
| 97 | struct mmc *mmc = find_mmc_device(0); |
| 98 | |
| 99 | if (!mmc) |
| 100 | return; |
| 101 | |
| 102 | mmc->saved_clock = mmc->clock; |
| 103 | mmc_set_clock(mmc, 0, true); |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | void k3_mmc_restart_clock(void) |
| 108 | { |
| 109 | if (spl_boot_device() == BOOT_DEVICE_MMC1) { |
| 110 | struct mmc *mmc = find_mmc_device(0); |
| 111 | |
| 112 | if (!mmc) |
| 113 | return; |
| 114 | |
| 115 | mmc_set_clock(mmc, mmc->saved_clock, false); |
| 116 | } |
| 117 | } |
Faiz Abbas | febb47a | 2020-08-03 11:35:08 +0530 | [diff] [blame^] | 118 | #else |
| 119 | void k3_mmc_stop_clock(void) {} |
| 120 | void k3_mmc_restart_clock(void) {} |
Faiz Abbas | d45ffb7 | 2020-02-26 13:44:36 +0530 | [diff] [blame] | 121 | #endif |
| 122 | |
Lokesh Vutla | ed0e605 | 2018-08-27 15:57:09 +0530 | [diff] [blame] | 123 | void board_init_f(ulong dummy) |
| 124 | { |
Andreas Dannenberg | c222e3d | 2019-06-04 17:55:50 -0500 | [diff] [blame] | 125 | #if defined(CONFIG_K3_LOAD_SYSFW) || defined(CONFIG_K3_AM654_DDRSS) |
Lokesh Vutla | 59ebf4a | 2018-11-02 19:51:06 +0530 | [diff] [blame] | 126 | struct udevice *dev; |
Faiz Abbas | f9916b6 | 2020-08-03 11:35:06 +0530 | [diff] [blame] | 127 | size_t pool_size; |
| 128 | void *pool_addr; |
Lokesh Vutla | 59ebf4a | 2018-11-02 19:51:06 +0530 | [diff] [blame] | 129 | int ret; |
| 130 | #endif |
Lokesh Vutla | e006460 | 2018-08-27 15:57:11 +0530 | [diff] [blame] | 131 | /* |
| 132 | * Cannot delay this further as there is a chance that |
| 133 | * K3_BOOT_PARAM_TABLE_INDEX can be over written by SPL MALLOC section. |
| 134 | */ |
| 135 | store_boot_index_from_rom(); |
| 136 | |
Andreas Dannenberg | c68721d | 2018-08-27 15:57:12 +0530 | [diff] [blame] | 137 | /* Make all control module registers accessible */ |
| 138 | ctrl_mmr_unlock(); |
| 139 | |
Lokesh Vutla | 23f7b1a | 2018-11-02 19:51:03 +0530 | [diff] [blame] | 140 | #ifdef CONFIG_CPU_V7R |
Lokesh Vutla | 40109f4 | 2019-12-31 15:49:55 +0530 | [diff] [blame] | 141 | disable_linefill_optimization(); |
Lokesh Vutla | 23f7b1a | 2018-11-02 19:51:03 +0530 | [diff] [blame] | 142 | setup_k3_mpu_regions(); |
| 143 | #endif |
| 144 | |
Lokesh Vutla | ed0e605 | 2018-08-27 15:57:09 +0530 | [diff] [blame] | 145 | /* Init DM early in-order to invoke system controller */ |
| 146 | spl_early_init(); |
| 147 | |
Andreas Dannenberg | 96dd223 | 2018-12-04 22:29:47 -0600 | [diff] [blame] | 148 | #ifdef CONFIG_K3_EARLY_CONS |
| 149 | /* |
| 150 | * Allow establishing an early console as required for example when |
| 151 | * doing a UART-based boot. Note that this console may not "survive" |
| 152 | * through a SYSFW PM-init step and will need a re-init in some way |
| 153 | * due to changing module clock frequencies. |
| 154 | */ |
| 155 | early_console_init(); |
| 156 | #endif |
| 157 | |
Andreas Dannenberg | c222e3d | 2019-06-04 17:55:50 -0500 | [diff] [blame] | 158 | #ifdef CONFIG_K3_LOAD_SYSFW |
| 159 | /* |
Faiz Abbas | f9916b6 | 2020-08-03 11:35:06 +0530 | [diff] [blame] | 160 | * Initialize an early full malloc environment. Do so by allocating a |
| 161 | * new malloc area inside the currently active pre-relocation "first" |
| 162 | * malloc pool of which we use all that's left. |
| 163 | */ |
| 164 | pool_size = CONFIG_VAL(SYS_MALLOC_F_LEN) - gd->malloc_ptr; |
| 165 | pool_addr = malloc(pool_size); |
| 166 | if (!pool_addr) |
| 167 | panic("ERROR: Can't allocate full malloc pool!\n"); |
| 168 | |
| 169 | mem_malloc_init((ulong)pool_addr, (ulong)pool_size); |
| 170 | gd->flags |= GD_FLG_FULL_MALLOC_INIT; |
| 171 | debug("%s: initialized an early full malloc pool at 0x%08lx of 0x%lx bytes\n", |
| 172 | __func__, (unsigned long)pool_addr, (unsigned long)pool_size); |
| 173 | /* |
Andreas Dannenberg | c222e3d | 2019-06-04 17:55:50 -0500 | [diff] [blame] | 174 | * Process pinctrl for the serial0 a.k.a. WKUP_UART0 module and continue |
| 175 | * regardless of the result of pinctrl. Do this without probing the |
| 176 | * device, but instead by searching the device that would request the |
| 177 | * given sequence number if probed. The UART will be used by the system |
| 178 | * firmware (SYSFW) image for various purposes and SYSFW depends on us |
| 179 | * to initialize its pin settings. |
| 180 | */ |
| 181 | ret = uclass_find_device_by_seq(UCLASS_SERIAL, 0, true, &dev); |
| 182 | if (!ret) |
| 183 | pinctrl_select_state(dev, "default"); |
| 184 | |
| 185 | /* |
Lokesh Vutla | 6e44aeb | 2020-03-10 16:50:58 +0530 | [diff] [blame] | 186 | * Load, start up, and configure system controller firmware while |
| 187 | * also populating the SYSFW post-PM configuration callback hook. |
Andreas Dannenberg | c222e3d | 2019-06-04 17:55:50 -0500 | [diff] [blame] | 188 | */ |
Faiz Abbas | d45ffb7 | 2020-02-26 13:44:36 +0530 | [diff] [blame] | 189 | k3_sysfw_loader(k3_mmc_stop_clock, k3_mmc_restart_clock); |
| 190 | |
| 191 | /* Prepare console output */ |
| 192 | preloader_console_init(); |
Andrew F. Davis | ea70da1 | 2020-01-10 14:35:21 -0500 | [diff] [blame] | 193 | |
| 194 | /* Disable ROM configured firewalls right after loading sysfw */ |
| 195 | #ifdef CONFIG_TI_SECURE_DEVICE |
| 196 | remove_fwl_configs(main_cbass_fwls, ARRAY_SIZE(main_cbass_fwls)); |
| 197 | remove_fwl_configs(mcu_cbass_fwls, ARRAY_SIZE(mcu_cbass_fwls)); |
| 198 | #endif |
Andreas Dannenberg | c222e3d | 2019-06-04 17:55:50 -0500 | [diff] [blame] | 199 | #else |
Lokesh Vutla | ed0e605 | 2018-08-27 15:57:09 +0530 | [diff] [blame] | 200 | /* Prepare console output */ |
| 201 | preloader_console_init(); |
Andreas Dannenberg | c222e3d | 2019-06-04 17:55:50 -0500 | [diff] [blame] | 202 | #endif |
Lokesh Vutla | 59ebf4a | 2018-11-02 19:51:06 +0530 | [diff] [blame] | 203 | |
Lokesh Vutla | 6e44aeb | 2020-03-10 16:50:58 +0530 | [diff] [blame] | 204 | /* Output System Firmware version info */ |
| 205 | k3_sysfw_print_ver(); |
| 206 | |
Andreas Dannenberg | 03facc7 | 2019-06-04 18:08:26 -0500 | [diff] [blame] | 207 | /* Perform EEPROM-based board detection */ |
| 208 | do_board_detect(); |
| 209 | |
Keerthy | 27380cb | 2019-10-24 15:00:52 +0530 | [diff] [blame] | 210 | #if defined(CONFIG_CPU_V7R) && defined(CONFIG_K3_AVS0) |
| 211 | ret = uclass_get_device_by_driver(UCLASS_MISC, DM_GET_DRIVER(k3_avs), |
| 212 | &dev); |
| 213 | if (ret) |
| 214 | printf("AVS init failed: %d\n", ret); |
| 215 | #endif |
| 216 | |
Lokesh Vutla | 59ebf4a | 2018-11-02 19:51:06 +0530 | [diff] [blame] | 217 | #ifdef CONFIG_K3_AM654_DDRSS |
| 218 | ret = uclass_get_device(UCLASS_RAM, 0, &dev); |
Andreas Dannenberg | 3e9b9c1 | 2019-03-11 15:15:43 -0500 | [diff] [blame] | 219 | if (ret) |
| 220 | panic("DRAM init failed: %d\n", ret); |
Lokesh Vutla | 59ebf4a | 2018-11-02 19:51:06 +0530 | [diff] [blame] | 221 | #endif |
Jan Kiszka | c02712a | 2020-05-18 07:57:22 +0200 | [diff] [blame] | 222 | spl_enable_dcache(); |
Lokesh Vutla | ed0e605 | 2018-08-27 15:57:09 +0530 | [diff] [blame] | 223 | } |
| 224 | |
Harald Seiler | e975906 | 2020-04-15 11:33:30 +0200 | [diff] [blame] | 225 | u32 spl_mmc_boot_mode(const u32 boot_device) |
Andrew F. Davis | 81089a5 | 2018-10-03 10:03:23 -0500 | [diff] [blame] | 226 | { |
| 227 | #if defined(CONFIG_SUPPORT_EMMC_BOOT) |
| 228 | u32 devstat = readl(CTRLMMR_MAIN_DEVSTAT); |
Andrew F. Davis | 81089a5 | 2018-10-03 10:03:23 -0500 | [diff] [blame] | 229 | |
| 230 | u32 bootmode = (devstat & CTRLMMR_MAIN_DEVSTAT_BOOTMODE_MASK) >> |
| 231 | CTRLMMR_MAIN_DEVSTAT_BOOTMODE_SHIFT; |
| 232 | |
| 233 | /* eMMC boot0 mode is only supported for primary boot */ |
| 234 | if (bootindex == K3_PRIMARY_BOOTMODE && |
| 235 | bootmode == BOOT_DEVICE_MMC1) |
| 236 | return MMCSD_MODE_EMMCBOOT; |
| 237 | #endif |
| 238 | |
| 239 | /* Everything else use filesystem if available */ |
Tien Fong Chee | f4b4092 | 2019-01-23 14:20:05 +0800 | [diff] [blame] | 240 | #if defined(CONFIG_SPL_FS_FAT) || defined(CONFIG_SPL_FS_EXT4) |
Andrew F. Davis | 81089a5 | 2018-10-03 10:03:23 -0500 | [diff] [blame] | 241 | return MMCSD_MODE_FS; |
| 242 | #else |
| 243 | return MMCSD_MODE_RAW; |
| 244 | #endif |
| 245 | } |
| 246 | |
Lokesh Vutla | e006460 | 2018-08-27 15:57:11 +0530 | [diff] [blame] | 247 | static u32 __get_backup_bootmedia(u32 devstat) |
| 248 | { |
| 249 | u32 bkup_boot = (devstat & CTRLMMR_MAIN_DEVSTAT_BKUP_BOOTMODE_MASK) >> |
| 250 | CTRLMMR_MAIN_DEVSTAT_BKUP_BOOTMODE_SHIFT; |
| 251 | |
| 252 | switch (bkup_boot) { |
| 253 | case BACKUP_BOOT_DEVICE_USB: |
| 254 | return BOOT_DEVICE_USB; |
| 255 | case BACKUP_BOOT_DEVICE_UART: |
| 256 | return BOOT_DEVICE_UART; |
| 257 | case BACKUP_BOOT_DEVICE_ETHERNET: |
| 258 | return BOOT_DEVICE_ETHERNET; |
| 259 | case BACKUP_BOOT_DEVICE_MMC2: |
Andrew F. Davis | b5700ef | 2018-10-03 10:03:22 -0500 | [diff] [blame] | 260 | { |
| 261 | u32 port = (devstat & CTRLMMR_MAIN_DEVSTAT_BKUP_MMC_PORT_MASK) >> |
| 262 | CTRLMMR_MAIN_DEVSTAT_BKUP_MMC_PORT_SHIFT; |
| 263 | if (port == 0x0) |
| 264 | return BOOT_DEVICE_MMC1; |
Lokesh Vutla | e006460 | 2018-08-27 15:57:11 +0530 | [diff] [blame] | 265 | return BOOT_DEVICE_MMC2; |
Andrew F. Davis | b5700ef | 2018-10-03 10:03:22 -0500 | [diff] [blame] | 266 | } |
Lokesh Vutla | e006460 | 2018-08-27 15:57:11 +0530 | [diff] [blame] | 267 | case BACKUP_BOOT_DEVICE_SPI: |
| 268 | return BOOT_DEVICE_SPI; |
| 269 | case BACKUP_BOOT_DEVICE_HYPERFLASH: |
| 270 | return BOOT_DEVICE_HYPERFLASH; |
| 271 | case BACKUP_BOOT_DEVICE_I2C: |
| 272 | return BOOT_DEVICE_I2C; |
| 273 | }; |
| 274 | |
| 275 | return BOOT_DEVICE_RAM; |
| 276 | } |
| 277 | |
| 278 | static u32 __get_primary_bootmedia(u32 devstat) |
| 279 | { |
Andrew F. Davis | b5700ef | 2018-10-03 10:03:22 -0500 | [diff] [blame] | 280 | u32 bootmode = (devstat & CTRLMMR_MAIN_DEVSTAT_BOOTMODE_MASK) >> |
| 281 | CTRLMMR_MAIN_DEVSTAT_BOOTMODE_SHIFT; |
Lokesh Vutla | e006460 | 2018-08-27 15:57:11 +0530 | [diff] [blame] | 282 | |
| 283 | if (bootmode == BOOT_DEVICE_OSPI || bootmode == BOOT_DEVICE_QSPI) |
| 284 | bootmode = BOOT_DEVICE_SPI; |
| 285 | |
Andrew F. Davis | b5700ef | 2018-10-03 10:03:22 -0500 | [diff] [blame] | 286 | if (bootmode == BOOT_DEVICE_MMC2) { |
| 287 | u32 port = (devstat & CTRLMMR_MAIN_DEVSTAT_MMC_PORT_MASK) >> |
| 288 | CTRLMMR_MAIN_DEVSTAT_MMC_PORT_SHIFT; |
| 289 | if (port == 0x0) |
| 290 | bootmode = BOOT_DEVICE_MMC1; |
| 291 | } else if (bootmode == BOOT_DEVICE_MMC1) { |
| 292 | u32 port = (devstat & CTRLMMR_MAIN_DEVSTAT_EMMC_PORT_MASK) >> |
| 293 | CTRLMMR_MAIN_DEVSTAT_EMMC_PORT_SHIFT; |
| 294 | if (port == 0x1) |
| 295 | bootmode = BOOT_DEVICE_MMC2; |
| 296 | } |
| 297 | |
Lokesh Vutla | e006460 | 2018-08-27 15:57:11 +0530 | [diff] [blame] | 298 | return bootmode; |
| 299 | } |
| 300 | |
Lokesh Vutla | ed0e605 | 2018-08-27 15:57:09 +0530 | [diff] [blame] | 301 | u32 spl_boot_device(void) |
| 302 | { |
Lokesh Vutla | e006460 | 2018-08-27 15:57:11 +0530 | [diff] [blame] | 303 | u32 devstat = readl(CTRLMMR_MAIN_DEVSTAT); |
Lokesh Vutla | e006460 | 2018-08-27 15:57:11 +0530 | [diff] [blame] | 304 | |
| 305 | if (bootindex == K3_PRIMARY_BOOTMODE) |
| 306 | return __get_primary_bootmedia(devstat); |
| 307 | else |
| 308 | return __get_backup_bootmedia(devstat); |
Lokesh Vutla | ed0e605 | 2018-08-27 15:57:09 +0530 | [diff] [blame] | 309 | } |
| 310 | #endif |
| 311 | |
Andreas Dannenberg | f9380a7 | 2019-06-07 19:24:42 +0530 | [diff] [blame] | 312 | #ifdef CONFIG_SYS_K3_SPL_ATF |
| 313 | |
| 314 | #define AM6_DEV_MCU_RTI0 134 |
| 315 | #define AM6_DEV_MCU_RTI1 135 |
| 316 | #define AM6_DEV_MCU_ARMSS0_CPU0 159 |
| 317 | #define AM6_DEV_MCU_ARMSS0_CPU1 245 |
| 318 | |
| 319 | void release_resources_for_core_shutdown(void) |
| 320 | { |
Lokesh Vutla | 78e5121 | 2019-09-09 12:47:38 +0530 | [diff] [blame] | 321 | struct ti_sci_handle *ti_sci = get_ti_sci_handle(); |
| 322 | struct ti_sci_dev_ops *dev_ops = &ti_sci->ops.dev_ops; |
| 323 | struct ti_sci_proc_ops *proc_ops = &ti_sci->ops.proc_ops; |
Andreas Dannenberg | f9380a7 | 2019-06-07 19:24:42 +0530 | [diff] [blame] | 324 | int ret; |
| 325 | u32 i; |
| 326 | |
| 327 | const u32 put_device_ids[] = { |
| 328 | AM6_DEV_MCU_RTI0, |
| 329 | AM6_DEV_MCU_RTI1, |
| 330 | }; |
| 331 | |
Andreas Dannenberg | f9380a7 | 2019-06-07 19:24:42 +0530 | [diff] [blame] | 332 | /* Iterate through list of devices to put (shutdown) */ |
| 333 | for (i = 0; i < ARRAY_SIZE(put_device_ids); i++) { |
| 334 | u32 id = put_device_ids[i]; |
| 335 | |
| 336 | ret = dev_ops->put_device(ti_sci, id); |
| 337 | if (ret) |
| 338 | panic("Failed to put device %u (%d)\n", id, ret); |
| 339 | } |
| 340 | |
| 341 | const u32 put_core_ids[] = { |
| 342 | AM6_DEV_MCU_ARMSS0_CPU1, |
| 343 | AM6_DEV_MCU_ARMSS0_CPU0, /* Handle CPU0 after CPU1 */ |
| 344 | }; |
| 345 | |
| 346 | /* Iterate through list of cores to put (shutdown) */ |
| 347 | for (i = 0; i < ARRAY_SIZE(put_core_ids); i++) { |
| 348 | u32 id = put_core_ids[i]; |
| 349 | |
| 350 | /* |
| 351 | * Queue up the core shutdown request. Note that this call |
| 352 | * needs to be followed up by an actual invocation of an WFE |
| 353 | * or WFI CPU instruction. |
| 354 | */ |
| 355 | ret = proc_ops->proc_shutdown_no_wait(ti_sci, id); |
| 356 | if (ret) |
| 357 | panic("Failed sending core %u shutdown message (%d)\n", |
| 358 | id, ret); |
| 359 | } |
| 360 | } |
| 361 | #endif |