bootrom.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. /*
  2. * Boot ROM Entry Points and such
  3. */
  4. /* These Blackfins all have a Boot ROM that is not reusable (at all):
  5. * BF531 / BF532 / BF533
  6. * BF538 / BF539
  7. * BF561
  8. * So there is nothing for us to export ;(
  9. *
  10. * These Blackfins started to roll with the idea that the Boot ROM can
  11. * provide useful functions, but still only a few (and not really useful):
  12. * BF534 / BF536 / BF537
  13. *
  14. * Looking forward, Boot ROM's on newer Blackfins have quite a few
  15. * nice entry points that are usable at runtime and beyond. We'll
  16. * only define known legacy parts (listed above) and otherwise just
  17. * assume it's a newer part.
  18. *
  19. * These entry points are accomplished by placing a small jump table at
  20. * the start of the Boot ROM. This way the addresses are fixed forever.
  21. */
  22. #ifndef __BFIN_PERIPHERAL_BOOTROM__
  23. #define __BFIN_PERIPHERAL_BOOTROM__
  24. /* All Blackfin's have the Boot ROM entry point at the same address */
  25. #define _BOOTROM_RESET 0xEF000000
  26. #if defined(__ADSPBF531__) || defined(__ADSPBF532__) || defined(__ADSPBF533__) || \
  27. defined(__ADSPBF538__) || defined(__ADSPBF539__) || \
  28. defined(__ADSPBF561__)
  29. /* Nothing to export */
  30. #elif defined(__ADSPBF534__) || defined(__ADSPBF536__) || defined(__ADSPBF537__)
  31. /* The BF537 family */
  32. #define _BOOTROM_FINAL_INIT 0xEF000002
  33. /* reserved 0xEF000004 */
  34. #define _BOOTROM_DO_MEMORY_DMA 0xEF000006
  35. #define _BOOTROM_BOOT_DXE_FLASH 0xEF000008
  36. #define _BOOTROM_BOOT_DXE_SPI 0xEF00000A
  37. #define _BOOTROM_BOOT_DXE_TWI 0xEF00000C
  38. /* reserved 0xEF00000E */
  39. #define _BOOTROM_GET_DXE_ADDRESS_FLASH 0xEF000010
  40. #define _BOOTROM_GET_DXE_ADDRESS_SPI 0xEF000012
  41. #define _BOOTROM_GET_DXE_ADDRESS_TWI 0xEF000014
  42. /* reserved 0xEF000016 */
  43. /* reserved 0xEF000018 */
  44. /* Glue to newer Boot ROMs */
  45. #define _BOOTROM_MDMA _BOOTROM_DO_MEMORY_DMA
  46. #define _BOOTROM_MEMBOOT _BOOTROM_BOOT_DXE_FLASH
  47. #define _BOOTROM_SPIBOOT _BOOTROM_BOOT_DXE_FLASH
  48. #define _BOOTROM_TWIBOOT _BOOTROM_BOOT_DXE_TWI
  49. #else
  50. /* All the newer Boot ROMs */
  51. #define _BOOTROM_FINAL_INIT 0xEF000002
  52. #define _BOOTROM_PDMA 0xEF000004
  53. #define _BOOTROM_MDMA 0xEF000006
  54. #define _BOOTROM_MEMBOOT 0xEF000008
  55. #define _BOOTROM_SPIBOOT 0xEF00000A
  56. #define _BOOTROM_TWIBOOT 0xEF00000C
  57. /* reserved 0xEF00000E */
  58. /* reserved 0xEF000010 */
  59. /* reserved 0xEF000012 */
  60. /* reserved 0xEF000014 */
  61. /* reserved 0xEF000016 */
  62. #define _BOOTROM_OTP_COMMAND 0xEF000018
  63. #define _BOOTROM_OTP_READ 0xEF00001A
  64. #define _BOOTROM_OTP_WRITE 0xEF00001C
  65. #define _BOOTROM_ECC_TABLE 0xEF00001E
  66. #define _BOOTROM_BOOTKERNEL 0xEF000020
  67. #define _BOOTROM_GETPORT 0xEF000022
  68. #define _BOOTROM_NMI 0xEF000024
  69. #define _BOOTROM_HWERROR 0xEF000026
  70. #define _BOOTROM_EXCEPTION 0xEF000028
  71. #define _BOOTROM_CRC32 0xEF000030
  72. #define _BOOTROM_CRC32POLY 0xEF000032
  73. #define _BOOTROM_CRC32CALLBACK 0xEF000034
  74. #define _BOOTROM_CRC32INITCODE 0xEF000036
  75. #define _BOOTROM_SYSCONTROL 0xEF000038
  76. #define _BOOTROM_REV 0xEF000040
  77. #define _BOOTROM_SESR 0xEF001000
  78. #define BOOTROM_FOLLOWS_C_ABI 1
  79. #define BOOTROM_CAPS_ADI_BOOT_STRUCTS 1
  80. /* Not available on initial BF54x or BF52x */
  81. #if (defined(__ADSPBF54x__) && __SILICON_REVISION__ < 1) || \
  82. (defined(__ADSPBF52x__) && __SILICON_REVISION__ < 2)
  83. #define BOOTROM_CAPS_SYSCONTROL 0
  84. #else
  85. #define BOOTROM_CAPS_SYSCONTROL 1
  86. #endif
  87. #endif
  88. #ifndef BOOTROM_FOLLOWS_C_ABI
  89. #define BOOTROM_FOLLOWS_C_ABI 0
  90. #endif
  91. #ifndef BOOTROM_CAPS_ADI_BOOT_STRUCTS
  92. #define BOOTROM_CAPS_ADI_BOOT_STRUCTS 0
  93. #endif
  94. #ifndef BOOTROM_CAPS_SYSCONTROL
  95. #define BOOTROM_CAPS_SYSCONTROL 0
  96. #endif
  97. #ifndef __ASSEMBLY__
  98. #if BOOTROM_FOLLOWS_C_ABI
  99. # define BOOTROM_CALLED_FUNC_ATTR
  100. #else
  101. # define BOOTROM_CALLED_FUNC_ATTR __attribute__((saveall))
  102. #endif
  103. /* Structures for the syscontrol() function */
  104. typedef struct ADI_SYSCTRL_VALUES {
  105. uint16_t uwVrCtl;
  106. uint16_t uwPllCtl;
  107. uint16_t uwPllDiv;
  108. uint16_t uwPllLockCnt;
  109. uint16_t uwPllStat;
  110. } ADI_SYSCTRL_VALUES;
  111. #ifndef _BOOTROM_SYSCONTROL
  112. #define _BOOTROM_SYSCONTROL 0
  113. #endif
  114. static uint32_t (* const syscontrol)(uint32_t action_flags, ADI_SYSCTRL_VALUES *power_settings, void *reserved) = (void *)_BOOTROM_SYSCONTROL;
  115. #endif /* __ASSEMBLY__ */
  116. /* Possible syscontrol action flags */
  117. #define SYSCTRL_READ 0x00000000 /* read registers */
  118. #define SYSCTRL_WRITE 0x00000001 /* write registers */
  119. #define SYSCTRL_SYSRESET 0x00000002 /* perform system reset */
  120. #define SYSCTRL_SOFTRESET 0x00000004 /* perform core and system reset */
  121. #define SYSCTRL_VRCTL 0x00000010 /* read/write VR_CTL register */
  122. #define SYSCTRL_EXTVOLTAGE 0x00000020 /* VDDINT supplied externally */
  123. #define SYSCTRL_INTVOLTAGE 0x00000000 /* VDDINT generated by on-chip regulator */
  124. #define SYSCTRL_OTPVOLTAGE 0x00000040 /* For Factory Purposes Only */
  125. #define SYSCTRL_PLLCTL 0x00000100 /* read/write PLL_CTL register */
  126. #define SYSCTRL_PLLDIV 0x00000200 /* read/write PLL_DIV register */
  127. #define SYSCTRL_LOCKCNT 0x00000400 /* read/write PLL_LOCKCNT register */
  128. #define SYSCTRL_PLLSTAT 0x00000800 /* read/write PLL_STAT register */
  129. #ifndef __ASSEMBLY__
  130. /* Structures for working with LDRs and boot rom callbacks */
  131. typedef struct ADI_BOOT_HEADER {
  132. int32_t dBlockCode;
  133. void *pTargetAddress;
  134. int32_t dByteCount;
  135. int32_t dArgument;
  136. } ADI_BOOT_HEADER;
  137. typedef struct ADI_BOOT_BUFFER {
  138. void *pSource;
  139. int32_t dByteCount;
  140. } ADI_BOOT_BUFFER;
  141. typedef struct ADI_BOOT_DATA {
  142. void *pSource;
  143. void *pDestination;
  144. int16_t *pControlRegister;
  145. int16_t *pDmaControlRegister;
  146. int32_t dControlValue;
  147. int32_t dByteCount;
  148. int32_t dFlags;
  149. int16_t uwDataWidth;
  150. int16_t uwSrcModifyMult;
  151. int16_t uwDstModifyMult;
  152. int16_t uwHwait;
  153. int16_t uwSsel;
  154. int16_t uwUserShort;
  155. int32_t dUserLong;
  156. int32_t dReserved2;
  157. void *pErrorFunction;
  158. void *pLoadFunction;
  159. void *pCallBackFunction;
  160. ADI_BOOT_HEADER *pHeader;
  161. void *pTempBuffer;
  162. void *pTempCurrent;
  163. int32_t dTempByteCount;
  164. int32_t dBlockCount;
  165. int32_t dClock;
  166. void *pLogBuffer;
  167. void *pLogCurrent;
  168. int32_t dLogByteCount;
  169. } ADI_BOOT_DATA;
  170. #endif /* __ASSEMBLY__ */
  171. /* Bit defines for ADI_BOOT_DATA->dFlags */
  172. #define BFLAG_DMACODE_MASK 0x0000000F
  173. #define BFLAG_SAFE 0x00000010
  174. #define BFLAG_AUX 0x00000020
  175. #define BFLAG_FILL 0x00000100
  176. #define BFLAG_QUICKBOOT 0x00000200
  177. #define BFLAG_CALLBACK 0x00000400
  178. #define BFLAG_INIT 0x00000800
  179. #define BFLAG_IGNORE 0x00001000
  180. #define BFLAG_INDIRECT 0x00002000
  181. #define BFLAG_FIRST 0x00004000
  182. #define BFLAG_FINAL 0x00008000
  183. #define BFLAG_HOOK 0x00400000
  184. #define BFLAG_HDRINDIRECT 0x00800000
  185. #define BFLAG_TYPE_MASK 0x00300000
  186. #define BFLAG_TYPE_1 0x00000000
  187. #define BFLAG_TYPE_2 0x00100000
  188. #define BFLAG_TYPE_3 0x00200000
  189. #define BFLAG_TYPE_4 0x00300000
  190. #define BFLAG_FASTREAD 0x00400000
  191. #define BFLAG_NOAUTO 0x01000000
  192. #define BFLAG_PERIPHERAL 0x02000000
  193. #define BFLAG_SLAVE 0x04000000
  194. #define BFLAG_WAKEUP 0x08000000
  195. #define BFLAG_NEXTDXE 0x10000000
  196. #define BFLAG_RETURN 0x20000000
  197. #define BFLAG_RESET 0x40000000
  198. #define BFLAG_NONRESTORE 0x80000000
  199. #endif