Lokesh Vutla | ed0e605 | 2018-08-27 15:57:09 +0530 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * K3: Architecture initialization |
| 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> |
Lokesh Vutla | e006460 | 2018-08-27 15:57:11 +0530 | [diff] [blame^] | 10 | #include <asm/io.h> |
Lokesh Vutla | ed0e605 | 2018-08-27 15:57:09 +0530 | [diff] [blame] | 11 | #include <spl.h> |
Lokesh Vutla | e006460 | 2018-08-27 15:57:11 +0530 | [diff] [blame^] | 12 | #include <asm/arch/hardware.h> |
Lokesh Vutla | ed0e605 | 2018-08-27 15:57:09 +0530 | [diff] [blame] | 13 | |
| 14 | #ifdef CONFIG_SPL_BUILD |
Lokesh Vutla | e006460 | 2018-08-27 15:57:11 +0530 | [diff] [blame^] | 15 | static void store_boot_index_from_rom(void) |
| 16 | { |
| 17 | u32 *boot_index = (u32 *)K3_BOOT_PARAM_TABLE_INDEX_VAL; |
| 18 | |
| 19 | *boot_index = *(u32 *)(CONFIG_SYS_K3_BOOT_PARAM_TABLE_INDEX); |
| 20 | } |
| 21 | |
Lokesh Vutla | ed0e605 | 2018-08-27 15:57:09 +0530 | [diff] [blame] | 22 | void board_init_f(ulong dummy) |
| 23 | { |
Lokesh Vutla | e006460 | 2018-08-27 15:57:11 +0530 | [diff] [blame^] | 24 | /* |
| 25 | * Cannot delay this further as there is a chance that |
| 26 | * K3_BOOT_PARAM_TABLE_INDEX can be over written by SPL MALLOC section. |
| 27 | */ |
| 28 | store_boot_index_from_rom(); |
| 29 | |
Lokesh Vutla | ed0e605 | 2018-08-27 15:57:09 +0530 | [diff] [blame] | 30 | /* Init DM early in-order to invoke system controller */ |
| 31 | spl_early_init(); |
| 32 | |
| 33 | /* Prepare console output */ |
| 34 | preloader_console_init(); |
| 35 | } |
| 36 | |
Lokesh Vutla | e006460 | 2018-08-27 15:57:11 +0530 | [diff] [blame^] | 37 | static u32 __get_backup_bootmedia(u32 devstat) |
| 38 | { |
| 39 | u32 bkup_boot = (devstat & CTRLMMR_MAIN_DEVSTAT_BKUP_BOOTMODE_MASK) >> |
| 40 | CTRLMMR_MAIN_DEVSTAT_BKUP_BOOTMODE_SHIFT; |
| 41 | |
| 42 | switch (bkup_boot) { |
| 43 | case BACKUP_BOOT_DEVICE_USB: |
| 44 | return BOOT_DEVICE_USB; |
| 45 | case BACKUP_BOOT_DEVICE_UART: |
| 46 | return BOOT_DEVICE_UART; |
| 47 | case BACKUP_BOOT_DEVICE_ETHERNET: |
| 48 | return BOOT_DEVICE_ETHERNET; |
| 49 | case BACKUP_BOOT_DEVICE_MMC2: |
| 50 | return BOOT_DEVICE_MMC2; |
| 51 | case BACKUP_BOOT_DEVICE_SPI: |
| 52 | return BOOT_DEVICE_SPI; |
| 53 | case BACKUP_BOOT_DEVICE_HYPERFLASH: |
| 54 | return BOOT_DEVICE_HYPERFLASH; |
| 55 | case BACKUP_BOOT_DEVICE_I2C: |
| 56 | return BOOT_DEVICE_I2C; |
| 57 | }; |
| 58 | |
| 59 | return BOOT_DEVICE_RAM; |
| 60 | } |
| 61 | |
| 62 | static u32 __get_primary_bootmedia(u32 devstat) |
| 63 | { |
| 64 | u32 bootmode = devstat & CTRLMMR_MAIN_DEVSTAT_BOOTMODE_MASK; |
| 65 | |
| 66 | if (bootmode == BOOT_DEVICE_OSPI || bootmode == BOOT_DEVICE_QSPI) |
| 67 | bootmode = BOOT_DEVICE_SPI; |
| 68 | |
| 69 | return bootmode; |
| 70 | } |
| 71 | |
Lokesh Vutla | ed0e605 | 2018-08-27 15:57:09 +0530 | [diff] [blame] | 72 | u32 spl_boot_device(void) |
| 73 | { |
Lokesh Vutla | e006460 | 2018-08-27 15:57:11 +0530 | [diff] [blame^] | 74 | u32 devstat = readl(CTRLMMR_MAIN_DEVSTAT); |
| 75 | u32 bootindex = readl(K3_BOOT_PARAM_TABLE_INDEX_VAL); |
| 76 | |
| 77 | if (bootindex == K3_PRIMARY_BOOTMODE) |
| 78 | return __get_primary_bootmedia(devstat); |
| 79 | else |
| 80 | return __get_backup_bootmedia(devstat); |
Lokesh Vutla | ed0e605 | 2018-08-27 15:57:09 +0530 | [diff] [blame] | 81 | } |
| 82 | #endif |
| 83 | |
| 84 | #ifndef CONFIG_SYSRESET |
| 85 | void reset_cpu(ulong ignored) |
| 86 | { |
| 87 | } |
| 88 | #endif |