2 * Boot ROM Entry Points and such
5 /* These Blackfins all have a Boot ROM that is not reusable (at all):
6 * BF531 / BF532 / BF533
9 * So there is nothing for us to export ;(
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
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.
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.
24 #ifndef __BFIN_PERIPHERAL_BOOTROM__
25 #define __BFIN_PERIPHERAL_BOOTROM__
27 /* All Blackfin's have the Boot ROM entry point at the same address */
28 #define _BOOTROM_RESET 0xEF000000
30 #if defined(__ADSPBF531__) || defined(__ADSPBF532__) || defined(__ADSPBF533__) || \
31 defined(__ADSPBF538__) || defined(__ADSPBF539__) || \
32 defined(__ADSPBF561__)
34 /* Nothing to export */
36 #elif defined(__ADSPBF534__) || defined(__ADSPBF536__) || defined(__ADSPBF537__)
38 /* The BF537 family */
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 */
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
61 /* All the newer Boot ROMs */
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
91 #define BOOTROM_FOLLOWS_C_ABI 1
93 #define BOOTROM_CAPS_ADI_BOOT_STRUCTS 1
97 #ifndef BOOTROM_FOLLOWS_C_ABI
98 #define BOOTROM_FOLLOWS_C_ABI 0
100 #ifndef BOOTROM_CAPS_ADI_BOOT_STRUCTS
101 #define BOOTROM_CAPS_ADI_BOOT_STRUCTS 0
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 */
121 #if BOOTROM_FOLLOWS_C_ABI
122 # define BOOTROM_CALLED_FUNC_ATTR
124 # define BOOTROM_CALLED_FUNC_ATTR __attribute__((saveall))
127 /* Structures for the syscontrol() function */
128 typedef struct ADI_SYSCTRL_VALUES {
132 uint16_t uwPllLockCnt;
134 } ADI_SYSCTRL_VALUES;
136 #ifndef _BOOTROM_SYSCONTROL
137 #define _BOOTROM_SYSCONTROL 0
139 static uint32_t (* const bfrom_SysControl)(uint32_t action_flags, ADI_SYSCTRL_VALUES *power_settings, void *reserved) = (void *)_BOOTROM_SYSCONTROL;
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.
145 __attribute__((__noreturn__))
146 static inline void bfrom_SoftReset(void *new_stack)
149 __asm__ __volatile__(
151 "jump (%[bfrom_syscontrol]);"
152 : : [bfrom_syscontrol] "p"(bfrom_SysControl),
153 "q0"(SYSCTRL_SOFTRESET),
156 [stack] "p"(new_stack)
160 /* Structures for working with LDRs and boot rom callbacks */
161 typedef struct ADI_BOOT_HEADER {
163 void *pTargetAddress;
168 typedef struct ADI_BOOT_BUFFER {
173 typedef struct ADI_BOOT_DATA {
176 int16_t *pControlRegister;
177 int16_t *pDmaControlRegister;
178 int32_t dControlValue;
182 int16_t uwSrcModifyMult;
183 int16_t uwDstModifyMult;
189 void *pErrorFunction;
191 void *pCallBackFunction;
192 ADI_BOOT_HEADER *pHeader;
195 int32_t dTempByteCount;
200 int32_t dLogByteCount;
203 typedef void ADI_BOOT_HOOK_FUNC (ADI_BOOT_DATA *);
205 #ifndef _BOOTROM_MEMBOOT
206 #define _BOOTROM_MEMBOOT 0
208 static uint32_t (* const bfrom_MemBoot)(void *pBootStream, int32_t dFlags, int32_t dBlockCount, ADI_BOOT_HOOK_FUNC *pCallHook) = (void *)_BOOTROM_MEMBOOT;
210 #ifndef _BOOTROM_TWIBOOT
211 #define _BOOTROM_TWIBOOT 0
213 static uint32_t (* const bfrom_TwiBoot)(int32_t dTwiAddress, int32_t dFlags, int32_t dBlockCount, ADI_BOOT_HOOK_FUNC *pCallHook) = (void *)_BOOTROM_TWIBOOT;
215 #ifndef _BOOTROM_SPIBOOT
216 #define _BOOTROM_SPIBOOT 0
218 static uint32_t (* const bfrom_SpiBoot)(int32_t dSpiAddress, int32_t dFlags, int32_t dBlockCount, ADI_BOOT_HOOK_FUNC *pCallHook) = (void *)_BOOTROM_SPIBOOT;
220 #ifndef _BOOTROM_OTPBOOT
221 #define _BOOTROM_OTPBOOT 0
223 static uint32_t (* const bfrom_OtpBoot)(int32_t dOtpAddress, int32_t dFlags, int32_t dBlockCount, ADI_BOOT_HOOK_FUNC *pCallHook) = (void *)_BOOTROM_OTPBOOT;
225 #ifndef _BOOTROM_NANDBOOT
226 #define _BOOTROM_NANDBOOT 0
228 static uint32_t (* const bfrom_NandBoot)(int32_t dNandAddress, int32_t dFlags, int32_t dBlockCount, ADI_BOOT_HOOK_FUNC *pCallHook) = (void *)_BOOTROM_NANDBOOT;
230 #endif /* __ASSEMBLY__ */
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