]> git.ipfire.org Git - people/ms/u-boot.git/blob - arch/blackfin/include/asm/mach-common/bits/bootrom.h
Move architecture-specific includes to arch/$ARCH/include/asm
[people/ms/u-boot.git] / arch / blackfin / include / asm / mach-common / bits / bootrom.h
1 /*
2 * Boot ROM Entry Points and such
3 */
4
5 /* These Blackfins all have a Boot ROM that is not reusable (at all):
6 * BF531 / BF532 / BF533
7 * BF538 / BF539
8 * BF561
9 * So there is nothing for us to export ;(
10 *
11 * These Blackfins started to roll with the idea that the Boot ROM can
12 * provide useful functions, but still only a few (and not really useful):
13 * BF534 / BF536 / BF537
14 *
15 * Looking forward, Boot ROM's on newer Blackfins have quite a few
16 * nice entry points that are usable at runtime and beyond. We'll
17 * only define known legacy parts (listed above) and otherwise just
18 * assume it's a newer part.
19 *
20 * These entry points are accomplished by placing a small jump table at
21 * the start of the Boot ROM. This way the addresses are fixed forever.
22 */
23
24 #ifndef __BFIN_PERIPHERAL_BOOTROM__
25 #define __BFIN_PERIPHERAL_BOOTROM__
26
27 /* All Blackfin's have the Boot ROM entry point at the same address */
28 #define _BOOTROM_RESET 0xEF000000
29
30 #if defined(__ADSPBF531__) || defined(__ADSPBF532__) || defined(__ADSPBF533__) || \
31 defined(__ADSPBF538__) || defined(__ADSPBF539__) || \
32 defined(__ADSPBF561__)
33
34 /* Nothing to export */
35
36 #elif defined(__ADSPBF534__) || defined(__ADSPBF536__) || defined(__ADSPBF537__)
37
38 /* The BF537 family */
39
40 #define _BOOTROM_FINAL_INIT 0xEF000002
41 /* reserved 0xEF000004 */
42 #define _BOOTROM_DO_MEMORY_DMA 0xEF000006
43 #define _BOOTROM_BOOT_DXE_FLASH 0xEF000008
44 #define _BOOTROM_BOOT_DXE_SPI 0xEF00000A
45 #define _BOOTROM_BOOT_DXE_TWI 0xEF00000C
46 /* reserved 0xEF00000E */
47 #define _BOOTROM_GET_DXE_ADDRESS_FLASH 0xEF000010
48 #define _BOOTROM_GET_DXE_ADDRESS_SPI 0xEF000012
49 #define _BOOTROM_GET_DXE_ADDRESS_TWI 0xEF000014
50 /* reserved 0xEF000016 */
51 /* reserved 0xEF000018 */
52
53 /* Glue to newer Boot ROMs */
54 #define _BOOTROM_MDMA _BOOTROM_DO_MEMORY_DMA
55 #define _BOOTROM_MEMBOOT _BOOTROM_BOOT_DXE_FLASH
56 #define _BOOTROM_SPIBOOT _BOOTROM_BOOT_DXE_FLASH
57 #define _BOOTROM_TWIBOOT _BOOTROM_BOOT_DXE_TWI
58
59 #else
60
61 /* All the newer Boot ROMs */
62
63 #define _BOOTROM_FINAL_INIT 0xEF000002
64 #define _BOOTROM_PDMA 0xEF000004
65 #define _BOOTROM_MDMA 0xEF000006
66 #define _BOOTROM_MEMBOOT 0xEF000008
67 #define _BOOTROM_SPIBOOT 0xEF00000A
68 #define _BOOTROM_TWIBOOT 0xEF00000C
69 /* reserved 0xEF00000E */
70 /* reserved 0xEF000010 */
71 /* reserved 0xEF000012 */
72 /* reserved 0xEF000014 */
73 /* reserved 0xEF000016 */
74 #define _BOOTROM_OTP_COMMAND 0xEF000018
75 #define _BOOTROM_OTP_READ 0xEF00001A
76 #define _BOOTROM_OTP_WRITE 0xEF00001C
77 #define _BOOTROM_ECC_TABLE 0xEF00001E
78 #define _BOOTROM_BOOTKERNEL 0xEF000020
79 #define _BOOTROM_GETPORT 0xEF000022
80 #define _BOOTROM_NMI 0xEF000024
81 #define _BOOTROM_HWERROR 0xEF000026
82 #define _BOOTROM_EXCEPTION 0xEF000028
83 #define _BOOTROM_CRC32 0xEF000030
84 #define _BOOTROM_CRC32POLY 0xEF000032
85 #define _BOOTROM_CRC32CALLBACK 0xEF000034
86 #define _BOOTROM_CRC32INITCODE 0xEF000036
87 #define _BOOTROM_SYSCONTROL 0xEF000038
88 #define _BOOTROM_REV 0xEF000040
89 #define _BOOTROM_SESR 0xEF001000
90
91 #define BOOTROM_FOLLOWS_C_ABI 1
92
93 #define BOOTROM_CAPS_ADI_BOOT_STRUCTS 1
94
95 #endif
96
97 #ifndef BOOTROM_FOLLOWS_C_ABI
98 #define BOOTROM_FOLLOWS_C_ABI 0
99 #endif
100 #ifndef BOOTROM_CAPS_ADI_BOOT_STRUCTS
101 #define BOOTROM_CAPS_ADI_BOOT_STRUCTS 0
102 #endif
103
104 /* Possible syscontrol action flags */
105 #define SYSCTRL_READ 0x00000000 /* read registers */
106 #define SYSCTRL_WRITE 0x00000001 /* write registers */
107 #define SYSCTRL_SYSRESET 0x00000002 /* perform system reset */
108 #define SYSCTRL_CORERESET 0x00000004 /* perform core reset */
109 #define SYSCTRL_SOFTRESET 0x00000006 /* perform core and system reset */
110 #define SYSCTRL_VRCTL 0x00000010 /* read/write VR_CTL register */
111 #define SYSCTRL_EXTVOLTAGE 0x00000020 /* VDDINT supplied externally */
112 #define SYSCTRL_INTVOLTAGE 0x00000000 /* VDDINT generated by on-chip regulator */
113 #define SYSCTRL_OTPVOLTAGE 0x00000040 /* For Factory Purposes Only */
114 #define SYSCTRL_PLLCTL 0x00000100 /* read/write PLL_CTL register */
115 #define SYSCTRL_PLLDIV 0x00000200 /* read/write PLL_DIV register */
116 #define SYSCTRL_LOCKCNT 0x00000400 /* read/write PLL_LOCKCNT register */
117 #define SYSCTRL_PLLSTAT 0x00000800 /* read/write PLL_STAT register */
118
119 #ifndef __ASSEMBLY__
120
121 #if BOOTROM_FOLLOWS_C_ABI
122 # define BOOTROM_CALLED_FUNC_ATTR
123 #else
124 # define BOOTROM_CALLED_FUNC_ATTR __attribute__((saveall))
125 #endif
126
127 /* Structures for the syscontrol() function */
128 typedef struct ADI_SYSCTRL_VALUES {
129 uint16_t uwVrCtl;
130 uint16_t uwPllCtl;
131 uint16_t uwPllDiv;
132 uint16_t uwPllLockCnt;
133 uint16_t uwPllStat;
134 } ADI_SYSCTRL_VALUES;
135
136 #ifndef _BOOTROM_SYSCONTROL
137 #define _BOOTROM_SYSCONTROL 0
138 #endif
139 static uint32_t (* const bfrom_SysControl)(uint32_t action_flags, ADI_SYSCTRL_VALUES *power_settings, void *reserved) = (void *)_BOOTROM_SYSCONTROL;
140
141 /* We need a dedicated function since we need to screw with the stack pointer
142 * when resetting. The on-chip ROM will save/restore registers on the stack
143 * when doing a system reset, so the stack cannot be outside of the chip.
144 */
145 __attribute__((__noreturn__))
146 static inline void bfrom_SoftReset(void *new_stack)
147 {
148 while (1)
149 __asm__ __volatile__(
150 "sp = %[stack];"
151 "jump (%[bfrom_syscontrol]);"
152 : : [bfrom_syscontrol] "p"(bfrom_SysControl),
153 "q0"(SYSCTRL_SOFTRESET),
154 "q1"(0),
155 "q2"(NULL),
156 [stack] "p"(new_stack)
157 );
158 }
159
160 /* Structures for working with LDRs and boot rom callbacks */
161 typedef struct ADI_BOOT_HEADER {
162 int32_t dBlockCode;
163 void *pTargetAddress;
164 int32_t dByteCount;
165 int32_t dArgument;
166 } ADI_BOOT_HEADER;
167
168 typedef struct ADI_BOOT_BUFFER {
169 void *pSource;
170 int32_t dByteCount;
171 } ADI_BOOT_BUFFER;
172
173 typedef struct ADI_BOOT_DATA {
174 void *pSource;
175 void *pDestination;
176 int16_t *pControlRegister;
177 int16_t *pDmaControlRegister;
178 int32_t dControlValue;
179 int32_t dByteCount;
180 int32_t dFlags;
181 int16_t uwDataWidth;
182 int16_t uwSrcModifyMult;
183 int16_t uwDstModifyMult;
184 int16_t uwHwait;
185 int16_t uwSsel;
186 int16_t uwUserShort;
187 int32_t dUserLong;
188 int32_t dReserved2;
189 void *pErrorFunction;
190 void *pLoadFunction;
191 void *pCallBackFunction;
192 ADI_BOOT_HEADER *pHeader;
193 void *pTempBuffer;
194 void *pTempCurrent;
195 int32_t dTempByteCount;
196 int32_t dBlockCount;
197 int32_t dClock;
198 void *pLogBuffer;
199 void *pLogCurrent;
200 int32_t dLogByteCount;
201 } ADI_BOOT_DATA;
202
203 typedef void ADI_BOOT_HOOK_FUNC (ADI_BOOT_DATA *);
204
205 #ifndef _BOOTROM_MEMBOOT
206 #define _BOOTROM_MEMBOOT 0
207 #endif
208 static uint32_t (* const bfrom_MemBoot)(void *pBootStream, int32_t dFlags, int32_t dBlockCount, ADI_BOOT_HOOK_FUNC *pCallHook) = (void *)_BOOTROM_MEMBOOT;
209
210 #ifndef _BOOTROM_TWIBOOT
211 #define _BOOTROM_TWIBOOT 0
212 #endif
213 static uint32_t (* const bfrom_TwiBoot)(int32_t dTwiAddress, int32_t dFlags, int32_t dBlockCount, ADI_BOOT_HOOK_FUNC *pCallHook) = (void *)_BOOTROM_TWIBOOT;
214
215 #ifndef _BOOTROM_SPIBOOT
216 #define _BOOTROM_SPIBOOT 0
217 #endif
218 static uint32_t (* const bfrom_SpiBoot)(int32_t dSpiAddress, int32_t dFlags, int32_t dBlockCount, ADI_BOOT_HOOK_FUNC *pCallHook) = (void *)_BOOTROM_SPIBOOT;
219
220 #ifndef _BOOTROM_OTPBOOT
221 #define _BOOTROM_OTPBOOT 0
222 #endif
223 static uint32_t (* const bfrom_OtpBoot)(int32_t dOtpAddress, int32_t dFlags, int32_t dBlockCount, ADI_BOOT_HOOK_FUNC *pCallHook) = (void *)_BOOTROM_OTPBOOT;
224
225 #ifndef _BOOTROM_NANDBOOT
226 #define _BOOTROM_NANDBOOT 0
227 #endif
228 static uint32_t (* const bfrom_NandBoot)(int32_t dNandAddress, int32_t dFlags, int32_t dBlockCount, ADI_BOOT_HOOK_FUNC *pCallHook) = (void *)_BOOTROM_NANDBOOT;
229
230 #endif /* __ASSEMBLY__ */
231
232 /* Bit defines for ADI_BOOT_DATA->dFlags */
233 #define BFLAG_DMACODE_MASK 0x0000000F
234 #define BFLAG_SAFE 0x00000010
235 #define BFLAG_AUX 0x00000020
236 #define BFLAG_FILL 0x00000100
237 #define BFLAG_QUICKBOOT 0x00000200
238 #define BFLAG_CALLBACK 0x00000400
239 #define BFLAG_INIT 0x00000800
240 #define BFLAG_IGNORE 0x00001000
241 #define BFLAG_INDIRECT 0x00002000
242 #define BFLAG_FIRST 0x00004000
243 #define BFLAG_FINAL 0x00008000
244 #define BFLAG_HOOK 0x00400000
245 #define BFLAG_HDRINDIRECT 0x00800000
246 #define BFLAG_TYPE_MASK 0x00300000
247 #define BFLAG_TYPE_1 0x00000000
248 #define BFLAG_TYPE_2 0x00100000
249 #define BFLAG_TYPE_3 0x00200000
250 #define BFLAG_TYPE_4 0x00300000
251 #define BFLAG_FASTREAD 0x00400000
252 #define BFLAG_NOAUTO 0x01000000
253 #define BFLAG_PERIPHERAL 0x02000000
254 #define BFLAG_SLAVE 0x04000000
255 #define BFLAG_WAKEUP 0x08000000
256 #define BFLAG_NEXTDXE 0x10000000
257 #define BFLAG_RETURN 0x20000000
258 #define BFLAG_RESET 0x40000000
259 #define BFLAG_NONRESTORE 0x80000000
260
261 #endif