init.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. /*++
  2. Copyright (c) 2014 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. init.h
  5. Abstract:
  6. This header contains definitions for the TI AM335x first stage boot loader.
  7. Author:
  8. Evan Green 17-Dec-2014
  9. --*/
  10. //
  11. // ------------------------------------------------------------------- Includes
  12. //
  13. #include <minoca/soc/am335x.h>
  14. #include <dev/tirom.h>
  15. //
  16. // --------------------------------------------------------------------- Macros
  17. //
  18. //
  19. // These macros read from and write to generic registers.
  20. //
  21. #define AM3_READ8(_Register) \
  22. *(volatile UINT8 *)(_Register)
  23. #define AM3_WRITE8(_Register, _Value) \
  24. *((volatile UINT8 *)(_Register)) = (_Value)
  25. #define AM3_READ16(_Register) \
  26. *(volatile UINT16 *)(_Register)
  27. #define AM3_WRITE16(_Register, _Value) \
  28. *((volatile UINT16 *)(_Register)) = (_Value)
  29. #define AM3_READ32(_Register) \
  30. *(volatile UINT32 *)(_Register)
  31. #define AM3_WRITE32(_Register, _Value) \
  32. *((volatile UINT32 *)(_Register)) = (_Value)
  33. //
  34. // Define macros for accessing peripheral base registers.
  35. //
  36. #define AM3_CM_PER_READ(_Register) \
  37. AM3_READ32(AM335_CM_PER_REGISTERS + _Register)
  38. #define AM3_CM_PER_WRITE(_Register, _Value) \
  39. AM3_WRITE32(AM335_CM_PER_REGISTERS + _Register, _Value)
  40. #define AM3_CM_WAKEUP_READ(_Register) \
  41. AM3_READ32(AM335_CM_WAKEUP_REGISTERS + _Register)
  42. #define AM3_CM_WAKEUP_WRITE(_Register, _Value) \
  43. AM3_WRITE32(AM335_CM_WAKEUP_REGISTERS + _Register, _Value)
  44. //
  45. // ---------------------------------------------------------------- Definitions
  46. //
  47. //
  48. // Define the address the boot loader is loaded to on SD.
  49. //
  50. #define AM335_SD_BOOT_ADDRESS (0x82000000 - 64)
  51. //
  52. // Define the working space where the CRC32 table can go.
  53. //
  54. #define BEAGLEBONE_CRC_TABLE_ADDRESS 0x81FE0000
  55. //
  56. // Define the name of the firmware file to load.
  57. //
  58. #define AM335_FIRMWARE_NAME "bbonefw"
  59. //
  60. // ------------------------------------------------------ Data Type Definitions
  61. //
  62. /*++
  63. Structure Description:
  64. This structure defines the various potential operating conditions of the
  65. AM335x.
  66. Members:
  67. PllMultiplier - Stores the PLL multiplier used to create the desired
  68. frequency.
  69. PmicVoltage - Stores the PMIC voltage value used to get the desired voltage.
  70. --*/
  71. typedef struct _AM335_OPP_TABLE_ENTRY {
  72. UINT32 PllMultiplier;
  73. UINT32 PmicVoltage;
  74. } AM335_OPP_TABLE_ENTRY, *PAM335_OPP_TABLE_ENTRY;
  75. //
  76. // -------------------------------------------------------------------- Globals
  77. //
  78. //
  79. // Define the device version of the AM335x.
  80. //
  81. extern UINT32 EfiAm335DeviceVersion;
  82. //
  83. // Define the operating conditions table.
  84. //
  85. extern AM335_OPP_TABLE_ENTRY EfiAm335OppTable[];
  86. //
  87. // -------------------------------------------------------- Function Prototypes
  88. //
  89. VOID
  90. EfipAm335InitializeClocks (
  91. VOID
  92. );
  93. /*++
  94. Routine Description:
  95. This routine initializes functional clocks for needed modules and domains.
  96. Arguments:
  97. None.
  98. Return Value:
  99. None.
  100. --*/
  101. VOID
  102. EfipAm335InitializePlls (
  103. UINT32 OppIndex,
  104. UINT32 DdrFrequencyMultiplier
  105. );
  106. /*++
  107. Routine Description:
  108. This routine initializes the PLLs for the AM335x.
  109. Arguments:
  110. OppIndex - Supplies the index into the operating conditions table that the
  111. PLLs should be configured for.
  112. DdrFrequencyMultiplier - Supplies the multiplier value to initialize the
  113. DDR PLL with (depends on whether DDR2 or DDR3 is in use).
  114. Return Value:
  115. None.
  116. --*/
  117. VOID
  118. EfipAm335ConfigureVddOpVoltage (
  119. VOID
  120. );
  121. /*++
  122. Routine Description:
  123. This routine configures the Vdd op voltage for the AM335x, assuming a
  124. TPS65217 PMIC hanging off of I2C bus 0.
  125. Arguments:
  126. None.
  127. Return Value:
  128. None.
  129. --*/
  130. VOID
  131. EfipAm335SetVdd1Voltage (
  132. UINT32 PmicVoltage
  133. );
  134. /*++
  135. Routine Description:
  136. This routine configures the Vdd1 voltage for the given operating condition.
  137. Arguments:
  138. PmicVoltage - Supplies the selected PMIC voltage.
  139. Return Value:
  140. None.
  141. --*/
  142. UINT32
  143. EfipAm335GetMaxOpp (
  144. VOID
  145. );
  146. /*++
  147. Routine Description:
  148. This routine determines the maximum operating conditions for this SoC.
  149. Arguments:
  150. None.
  151. Return Value:
  152. Returns the index into the opp table that this SoC can support. See
  153. AM335_EFUSE_OPP* definitions.
  154. --*/
  155. VOID
  156. EfipInitializeBoardMux (
  157. VOID
  158. );
  159. /*++
  160. Routine Description:
  161. This routine sets up the correct pin muxing for the BeagleBone.
  162. Arguments:
  163. None.
  164. Return Value:
  165. None.
  166. --*/
  167. VOID
  168. EfipBeagleBoneBlackInitializeLeds (
  169. VOID
  170. );
  171. /*++
  172. Routine Description:
  173. This routine initializes the SoC so that the LEDs can be driven.
  174. Arguments:
  175. None.
  176. Return Value:
  177. None.
  178. --*/
  179. VOID
  180. EfipBeagleBoneBlackSetLeds (
  181. UINT32 Leds
  182. );
  183. /*++
  184. Routine Description:
  185. This routine sets the LEDs to a new value.
  186. Arguments:
  187. Leds - Supplies the four bits containing whether to set the LEDs high or
  188. low.
  189. Return Value:
  190. None.
  191. --*/
  192. VOID
  193. EfipAm335InitializeEmif (
  194. VOID
  195. );
  196. /*++
  197. Routine Description:
  198. This routine performs EMIF initialization in preparation for firing up DDR
  199. RAM.
  200. Arguments:
  201. None.
  202. Return Value:
  203. None.
  204. --*/
  205. VOID
  206. EfipBeagleBoneBlackInitializeDdr3 (
  207. VOID
  208. );
  209. /*++
  210. Routine Description:
  211. This routine fires up the DDR3 main memory.
  212. Arguments:
  213. None.
  214. Return Value:
  215. None.
  216. --*/
  217. VOID
  218. EfipAm335EnableUart (
  219. VOID
  220. );
  221. /*++
  222. Routine Description:
  223. This routine performs rudimentary initialization so that UART0 can be used
  224. as a debug console.
  225. Arguments:
  226. None.
  227. Return Value:
  228. None.
  229. --*/