Ye Li | ba604b8 | 2019-05-16 03:18:51 +0000 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
| 2 | /* |
| 3 | * Copyright 2019 NXP |
| 4 | */ |
| 5 | |
| 6 | #include <config.h> |
| 7 | |
| 8 | #define ROM_API_TABLE_BASE_ADDR_LEGACY 0x180 |
Wolfgang Denk | 62fb2b4 | 2021-09-27 17:42:39 +0200 | [diff] [blame] | 9 | #define ROM_VERSION_OFFSET 0x80 |
Ye Li | ba604b8 | 2019-05-16 03:18:51 +0000 | [diff] [blame] | 10 | #define ROM_API_HWCNFG_SETUP_OFFSET 0x08 |
| 11 | |
| 12 | plugin_start: |
| 13 | |
| 14 | push {r0-r4, lr} |
| 15 | |
| 16 | imx7ulp_ddr_setting |
| 17 | imx7ulp_clock_gating |
| 18 | imx7ulp_qos_setting |
| 19 | |
| 20 | normal_boot: |
| 21 | |
| 22 | /* |
| 23 | * The following is to fill in those arguments for this ROM function |
| 24 | * pu_irom_hwcnfg_setup(void **start, size_t *bytes, const void *boot_data) |
| 25 | * This function is used to copy data from the storage media into DDR. |
| 26 | * start - Initial (possibly partial) image load address on entry. |
| 27 | * Final image load address on exit. |
| 28 | * bytes - Initial (possibly partial) image size on entry. |
| 29 | * Final image size on exit. |
| 30 | * boot_data - Initial @ref ivt Boot Data load address. |
| 31 | */ |
| 32 | adr r0, boot_data2 |
| 33 | adr r1, image_len2 |
| 34 | adr r2, boot_data2 |
| 35 | |
| 36 | /* |
| 37 | * check the _pu_irom_api_table for the address |
| 38 | */ |
| 39 | before_calling_rom___pu_irom_hwcnfg_setup: |
| 40 | ldr r3, =ROM_VERSION_OFFSET |
| 41 | ldr r4, [r3] |
| 42 | ldr r3, =ROM_API_TABLE_BASE_ADDR_LEGACY |
| 43 | ldr r4, [r3, #ROM_API_HWCNFG_SETUP_OFFSET] |
| 44 | blx r4 |
| 45 | after_calling_rom___pu_irom_hwcnfg_setup: |
| 46 | |
| 47 | /* |
| 48 | * To return to ROM from plugin, we need to fill in these argument. |
| 49 | * Here is what need to do: |
| 50 | * Need to construct the parameters for this function before return to ROM: |
| 51 | * plugin_download(void **start, size_t *bytes, UINT32 *ivt_offset) |
| 52 | */ |
| 53 | pop {r0-r4, lr} |
| 54 | push {r5} |
| 55 | ldr r5, boot_data2 |
| 56 | str r5, [r0] |
| 57 | ldr r5, image_len2 |
| 58 | str r5, [r1] |
| 59 | ldr r5, second_ivt_offset |
| 60 | str r5, [r2] |
| 61 | mov r0, #1 |
| 62 | pop {r5} |
| 63 | |
| 64 | /* return back to ROM code */ |
| 65 | bx lr |
| 66 | |
| 67 | /* make the following data right in the end of the output*/ |
| 68 | .ltorg |
| 69 | |
| 70 | #define FLASH_OFFSET 0x400 |
| 71 | |
| 72 | /* |
| 73 | * second_ivt_offset is the offset from the "second_ivt_header" to |
| 74 | * "image_copy_start", which involves FLASH_OFFSET, plus the first |
| 75 | * ivt_header, the plugin code size itself recorded by "ivt2_header" |
| 76 | */ |
| 77 | |
| 78 | second_ivt_offset: .long (ivt2_header + 0x2C + FLASH_OFFSET) |
| 79 | |
| 80 | /* |
| 81 | * The following is the second IVT header plus the second boot data |
| 82 | */ |
| 83 | ivt2_header: .long 0x0 |
| 84 | app2_code_jump_v: .long 0x0 |
| 85 | reserv3: .long 0x0 |
| 86 | dcd2_ptr: .long 0x0 |
| 87 | boot_data2_ptr: .long 0x0 |
| 88 | self_ptr2: .long 0x0 |
| 89 | app_code_csf2: .long 0x0 |
| 90 | reserv4: .long 0x0 |
| 91 | boot_data2: .long 0x0 |
| 92 | image_len2: .long 0x0 |
| 93 | plugin2: .long 0x0 |