bootrom.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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_CAPS_ADI_BOOT_STRUCTS 1
  79. /* Not available on initial BF54x or BF52x */
  80. #if (defined(__ADSPBF54x__) && __SILICON_REVISION__ < 1) || \
  81. (defined(__ADSPBF52x__) && __SILICON_REVISION__ < 2)
  82. #define BOOTROM_CAPS_SYSCONTROL 0
  83. #else
  84. #define BOOTROM_CAPS_SYSCONTROL 1
  85. #endif
  86. #endif
  87. #ifndef BOOTROM_CAPS_ADI_BOOT_STRUCTS
  88. #define BOOTROM_CAPS_ADI_BOOT_STRUCTS 0
  89. #endif
  90. #ifndef BOOTROM_CAPS_SYSCONTROL
  91. #define BOOTROM_CAPS_SYSCONTROL 0
  92. #endif
  93. #ifndef __ASSEMBLY__
  94. /* Structures for the syscontrol() function */
  95. typedef struct ADI_SYSCTRL_VALUES {
  96. uint16_t uwVrCtl;
  97. uint16_t uwPllCtl;
  98. uint16_t uwPllDiv;
  99. uint16_t uwPllLockCnt;
  100. uint16_t uwPllStat;
  101. } ADI_SYSCTRL_VALUES;
  102. #ifndef _BOOTROM_SYSCONTROL
  103. #define _BOOTROM_SYSCONTROL 0
  104. #endif
  105. static uint32_t (* const syscontrol)(uint32_t action_flags, ADI_SYSCTRL_VALUES *power_settings, void *reserved) = (void *)_BOOTROM_SYSCONTROL;
  106. #endif /* __ASSEMBLY__ */
  107. /* Possible syscontrol action flags */
  108. #define SYSCTRL_READ 0x00000000 /* read registers */
  109. #define SYSCTRL_WRITE 0x00000001 /* write registers */
  110. #define SYSCTRL_SYSRESET 0x00000002 /* perform system reset */
  111. #define SYSCTRL_SOFTRESET 0x00000004 /* perform core and system reset */
  112. #define SYSCTRL_VRCTL 0x00000010 /* read/write VR_CTL register */
  113. #define SYSCTRL_EXTVOLTAGE 0x00000020 /* VDDINT supplied externally */
  114. #define SYSCTRL_INTVOLTAGE 0x00000000 /* VDDINT generated by on-chip regulator */
  115. #define SYSCTRL_OTPVOLTAGE 0x00000040 /* For Factory Purposes Only */
  116. #define SYSCTRL_PLLCTL 0x00000100 /* read/write PLL_CTL register */
  117. #define SYSCTRL_PLLDIV 0x00000200 /* read/write PLL_DIV register */
  118. #define SYSCTRL_LOCKCNT 0x00000400 /* read/write PLL_LOCKCNT register */
  119. #define SYSCTRL_PLLSTAT 0x00000800 /* read/write PLL_STAT register */
  120. #ifndef __ASSEMBLY__
  121. /* Structures for working with LDRs and boot rom callbacks */
  122. typedef struct ADI_BOOT_HEADER {
  123. int32_t dBlockCode;
  124. void *pTargetAddress;
  125. int32_t dByteCount;
  126. int32_t dArgument;
  127. } ADI_BOOT_HEADER;
  128. typedef struct ADI_BOOT_BUFFER {
  129. void *pSource;
  130. int32_t dByteCount;
  131. } ADI_BOOT_BUFFER;
  132. typedef struct ADI_BOOT_DATA {
  133. void *pSource;
  134. void *pDestination;
  135. int16_t *pControlRegister;
  136. int16_t *pDmaControlRegister;
  137. int32_t dControlValue;
  138. int32_t dByteCount;
  139. int32_t dFlags;
  140. int16_t uwDataWidth;
  141. int16_t uwSrcModifyMult;
  142. int16_t uwDstModifyMult;
  143. int16_t uwHwait;
  144. int16_t uwSsel;
  145. int16_t uwUserShort;
  146. int32_t dUserLong;
  147. int32_t dReserved2;
  148. void *pErrorFunction;
  149. void *pLoadFunction;
  150. void *pCallBackFunction;
  151. ADI_BOOT_HEADER *pHeader;
  152. void *pTempBuffer;
  153. void *pTempCurrent;
  154. int32_t dTempByteCount;
  155. int32_t dBlockCount;
  156. int32_t dClock;
  157. void *pLogBuffer;
  158. void *pLogCurrent;
  159. int32_t dLogByteCount;
  160. } ADI_BOOT_DATA;
  161. #endif /* __ASSEMBLY__ */
  162. /* Bit defines for ADI_BOOT_DATA->dFlags */
  163. #define BFLAG_DMACODE_MASK 0x0000000F
  164. #define BFLAG_SAFE 0x00000010
  165. #define BFLAG_AUX 0x00000020
  166. #define BFLAG_FILL 0x00000100
  167. #define BFLAG_QUICKBOOT 0x00000200
  168. #define BFLAG_CALLBACK 0x00000400
  169. #define BFLAG_INIT 0x00000800
  170. #define BFLAG_IGNORE 0x00001000
  171. #define BFLAG_INDIRECT 0x00002000
  172. #define BFLAG_FIRST 0x00004000
  173. #define BFLAG_FINAL 0x00008000
  174. #define BFLAG_HOOK 0x00400000
  175. #define BFLAG_HDRINDIRECT 0x00800000
  176. #define BFLAG_TYPE_MASK 0x00300000
  177. #define BFLAG_TYPE_1 0x00000000
  178. #define BFLAG_TYPE_2 0x00100000
  179. #define BFLAG_TYPE_3 0x00200000
  180. #define BFLAG_TYPE_4 0x00300000
  181. #define BFLAG_FASTREAD 0x00400000
  182. #define BFLAG_NOAUTO 0x01000000
  183. #define BFLAG_PERIPHERAL 0x02000000
  184. #define BFLAG_SLAVE 0x04000000
  185. #define BFLAG_WAKEUP 0x08000000
  186. #define BFLAG_NEXTDXE 0x10000000
  187. #define BFLAG_RETURN 0x20000000
  188. #define BFLAG_RESET 0x40000000
  189. #define BFLAG_NONRESTORE 0x80000000
  190. #endif