2 * Copyright (C) 2016 Freescale Semiconductor, Inc.
4 * SPDX-License-Identifier: GPL-2.0+
9 #ifdef CONFIG_ROM_UNIFIED_SECTIONS
10 #define ROM_API_TABLE_BASE_ADDR_LEGACY 0x180
11 #define ROM_VERSION_OFFSET 0x80
13 #define ROM_API_TABLE_BASE_ADDR_LEGACY 0xC0
14 #define ROM_VERSION_OFFSET 0x48
16 #define ROM_API_TABLE_BASE_ADDR_MX6DQ_TO15 0xC4
17 #define ROM_API_TABLE_BASE_ADDR_MX6DL_TO12 0xC4
18 #define ROM_API_HWCNFG_SETUP_OFFSET 0x08
19 #define ROM_VERSION_TO10 0x10
20 #define ROM_VERSION_TO12 0x12
21 #define ROM_VERSION_TO15 0x15
32 * The following is to fill in those arguments for this ROM function
33 * pu_irom_hwcnfg_setup(void **start, size_t *bytes, const void *boot_data)
34 * This function is used to copy data from the storage media into DDR.
35 * start - Initial (possibly partial) image load address on entry.
36 * Final image load address on exit.
37 * bytes - Initial (possibly partial) image size on entry.
38 * Final image size on exit.
39 * boot_data - Initial @ref ivt Boot Data load address.
45 #ifdef CONFIG_NOR_BOOT
47 ldr r3, =ROM_VERSION_OFFSET
49 cmp r4, #ROM_VERSION_TO10
50 bgt before_calling_rom___pu_irom_hwcnfg_setup
62 * check the _pu_irom_api_table for the address
64 before_calling_rom___pu_irom_hwcnfg_setup:
65 ldr r3, =ROM_VERSION_OFFSET
67 #if defined(CONFIG_MX6SOLO) || defined(CONFIG_MX6DL)
68 ldr r3, =ROM_VERSION_TO12
70 ldrge r3, =ROM_API_TABLE_BASE_ADDR_MX6DL_TO12
71 ldrlt r3, =ROM_API_TABLE_BASE_ADDR_LEGACY
72 #elif defined(CONFIG_MX6Q)
73 ldr r3, =ROM_VERSION_TO15
75 ldrge r3, =ROM_API_TABLE_BASE_ADDR_MX6DQ_TO15
76 ldrlt r3, =ROM_API_TABLE_BASE_ADDR_LEGACY
78 ldr r3, =ROM_API_TABLE_BASE_ADDR_LEGACY
80 ldr r4, [r3, #ROM_API_HWCNFG_SETUP_OFFSET]
82 after_calling_rom___pu_irom_hwcnfg_setup:
85 * ROM_API_HWCNFG_SETUP function enables MMU & Caches.
86 * Thus disable MMU & Caches.
89 mrc p15, 0, r0, c1, c0, 0 /* read CP15 register 1 into r0*/
90 ands r0, r0, #0x1 /* check if MMU is enabled */
91 beq mmu_disable_notreq /* exit if MMU is already disabled */
93 /* Disable caches, MMU */
94 mrc p15, 0, r0, c1, c0, 0 /* read CP15 register 1 into r0 */
95 bic r0, r0, #(1 << 2) /* disable D Cache */
96 bic r0, r0, #0x1 /* clear bit 0 ; MMU off */
98 bic r0, r0, #(0x1 << 11) /* disable Z, branch prediction */
99 bic r0, r0, #(0x1 << 1) /* disable A, Strict alignment */
101 mcr p15, 0, r0, c1, c0, 0 /* write CP15 register 1 */
110 /* To return to ROM from plugin, we need to fill in these argument.
111 * Here is what need to do:
112 * Need to construct the paramters for this function before return to ROM:
113 * plugin_download(void **start, size_t *bytes, UINT32 *ivt_offset)
121 ldr r5, second_ivt_offset
126 /* return back to ROM code */
129 /* make the following data right in the end of the output*/
132 #if (defined(CONFIG_NOR_BOOT) || defined(CONFIG_QSPI_BOOT))
133 #define FLASH_OFFSET 0x1000
135 #define FLASH_OFFSET 0x400
139 * second_ivt_offset is the offset from the "second_ivt_header" to
140 * "image_copy_start", which involves FLASH_OFFSET, plus the first
141 * ivt_header, the plugin code size itself recorded by "ivt2_header"
144 second_ivt_offset: .long (ivt2_header + 0x2C + FLASH_OFFSET)
147 * The following is the second IVT header plus the second boot data
149 ivt2_header: .long 0x0
150 app2_code_jump_v: .long 0x0
153 boot_data2_ptr: .long 0x0
155 app_code_csf2: .long 0x0
157 boot_data2: .long 0x0
158 image_len2: .long 0x0