2 * (C) Copyright 2007 Michal Simek
3 * (C) Copyright 2004 Atmark Techno, Inc.
5 * Michal SIMEK <monstr@monstr.eu>
6 * Yasushi SHOJI <yashi@atmark-techno.com>
8 * SPDX-License-Identifier: GPL-2.0+
11 #include <asm-offsets.h>
19 * r10: Stores little/big endian offset for vectors
20 * r2: Stores imm opcode
21 * r3: Stores brai opcode
24 mts rmsr, r0 /* disable cache */
26 #if defined(CONFIG_SPL_BUILD)
27 addi r1, r0, CONFIG_SPL_STACK_ADDR
28 addi r1, r1, -4 /* Decrement SP to top of memory */
30 addi r1, r0, CONFIG_SYS_INIT_SP_OFFSET
31 addi r1, r1, -4 /* Decrement SP to top of memory */
33 /* Find-out if u-boot is running on BIG/LITTLE endian platform
34 * There are some steps which is necessary to keep in mind:
35 * 1. Setup offset value to r6
36 * 2. Store word offset value to address 0x0
37 * 3. Load just byte from address 0x0
38 * 4a) LITTLE endian - r10 contains 0x2 because it is the smallest
39 * value that's why is on address 0x0
40 * 4b) BIG endian - r10 contains 0x0 because 0x2 offset is on addr 0x3
42 addik r6, r0, 0x2 /* BIG/LITTLE endian offset */
44 swi r6, r0, 0x28 /* used first unused MB vector */
45 lbui r10, r0, 0x28 /* used first unused MB vector */
48 /* add opcode instruction for 32bit jump - 2 instruction imm & brai */
49 addi r2, r0, 0xb0000000 /* hex b000 opcode imm */
50 addi r3, r0, 0xb8080000 /* hew b808 opcode brai */
52 #ifdef CONFIG_SYS_RESET_ADDRESS
54 swi r2, r0, 0x0 /* reset address - imm opcode */
55 swi r3, r0, 0x4 /* reset address - brai opcode */
57 addik r6, r0, CONFIG_SYS_RESET_ADDRESS
66 #ifdef CONFIG_SYS_USR_EXCEP
67 /* user_vector_exception */
68 swi r2, r0, 0x8 /* user vector exception - imm opcode */
69 swi r3, r0, 0xC /* user vector exception - brai opcode */
71 addik r6, r0, _exception_handler
74 * BIG ENDIAN memory map for user exception
78 * then it is necessary to count address for storing the most significant
79 * 16bits from _exception_handler address and copy it to
80 * 0xa address. Big endian use offset in r10=0 that's why is it just
81 * 0xa address. The same is done for the least significant 16 bits
84 * LITTLE ENDIAN memory map for user exception
88 * Offset is for little endian setup to 0x2. rsubi instruction decrease
89 * address value to ensure that points to proper place which is
90 * 0x8 for the most significant 16 bits and
91 * 0xC for the least significant 16 bits
100 /* interrupt_handler */
101 swi r2, r0, 0x10 /* interrupt - imm opcode */
102 swi r3, r0, 0x14 /* interrupt - brai opcode */
104 addik r6, r0, _interrupt_handler
112 /* hardware exception */
113 swi r2, r0, 0x20 /* hardware exception - imm opcode */
114 swi r3, r0, 0x24 /* hardware exception - brai opcode */
116 addik r6, r0, _hw_exception_handler
123 #endif /* BUILD_SPL */
125 /* Flush cache before enable cache */
127 addik r6, r0, XILINX_DCACHE_BYTE_SIZE
128 flush: bralid r15, flush_cache
131 /* enable instruction and data cache */
137 /* clear BSS segments */
138 addi r5, r0, __bss_start
139 addi r4, r0, __bss_end
143 swi r0, r5, 0 /* write zero to loc */
144 addi r5, r5, 4 /* increment to next loc */
145 cmp r6, r5, r4 /* check if we have reach the end */
147 3: /* jumping to board_init */
148 #ifndef CONFIG_SPL_BUILD
155 #ifndef CONFIG_SPL_BUILD
157 * Read 16bit little endian
173 * Write 16bit little endian
174 * first parameter(r5) - address, second(r6) - short value
180 out16: bslli r3, r6, 8