veyronfw.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. /*++
  2. Copyright (c) 2015 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. veyronfw.h
  5. Abstract:
  6. This header contains internal definitions for the Veyron firmware, which
  7. supports the Asus C201 Chromebook.
  8. Author:
  9. Evan Green 9-Jul-2015
  10. --*/
  11. //
  12. // ------------------------------------------------------------------- Includes
  13. //
  14. #include <minoca/soc/rk32xx.h>
  15. //
  16. // --------------------------------------------------------------------- Macros
  17. //
  18. #define RK32_READ_CRU(_Register) \
  19. EfiReadRegister32((VOID *)RK32_CRU_BASE + (_Register))
  20. #define RK32_WRITE_CRU(_Register, _Value) \
  21. EfiWriteRegister32((VOID *)RK32_CRU_BASE + (_Register), (_Value))
  22. #define RK32_READ_GRF(_Register) \
  23. EfiReadRegister32((VOID *)RK32_GRF_BASE + (_Register))
  24. #define RK32_WRITE_GRF(_Register, _Value) \
  25. EfiWriteRegister32((VOID *)RK32_GRF_BASE + (_Register), (_Value))
  26. //
  27. // ---------------------------------------------------------------- Definitions
  28. //
  29. //
  30. // Do not use the last 16MB of RAM as it causes AHB errors during DMA
  31. // transations.
  32. //
  33. #define VEYRON_RAM_START 0x00000000
  34. #define VEYRON_RAM_SIZE 0xFE000000
  35. #define VEYRON_OSC_HERTZ 24000000
  36. #define VEYRON_ARM_CPU_HERTZ 1704000000
  37. //
  38. // ------------------------------------------------------ Data Type Definitions
  39. //
  40. //
  41. // -------------------------------------------------------------------- Globals
  42. //
  43. //
  44. // Store a boolean used for debugging that disables the watchdog timer.
  45. //
  46. extern BOOLEAN EfiDisableWatchdog;
  47. //
  48. // The runtime stores a pointer to GPIO0 for system reset purposes.
  49. //
  50. extern VOID *EfiRk32Gpio0Base;
  51. //
  52. // The runtime stores a pointer to the I2C PMU for the RTC.
  53. //
  54. extern VOID *EfiRk32I2cPmuBase;
  55. //
  56. // Define a boolean indicating whether the firmware was loaded via SD or eMMC.
  57. //
  58. extern BOOLEAN EfiBootedViaSd;
  59. //
  60. // -------------------------------------------------------- Function Prototypes
  61. //
  62. EFI_STATUS
  63. EfipPlatformSetInterruptLineState (
  64. UINT32 LineNumber,
  65. BOOLEAN Enabled,
  66. BOOLEAN EdgeTriggered
  67. );
  68. /*++
  69. Routine Description:
  70. This routine enables or disables an interrupt line.
  71. Arguments:
  72. LineNumber - Supplies the line number to enable or disable.
  73. Enabled - Supplies a boolean indicating if the line should be enabled or
  74. disabled.
  75. EdgeTriggered - Supplies a boolean indicating if the interrupt is edge
  76. triggered (TRUE) or level triggered (FALSE).
  77. Return Value:
  78. EFI Status code.
  79. --*/
  80. EFI_STATUS
  81. EfipRk32GetPllClockFrequency (
  82. RK32_PLL_TYPE PllType,
  83. UINT32 *Frequency
  84. );
  85. /*++
  86. Routine Description:
  87. This routine returns the base PLL clock frequency of the given type.
  88. Arguments:
  89. PllType - Supplies the type of the PLL clock whose frequency is being
  90. queried.
  91. Frequency - Supplies a pointer that receives the PLL clock's frequency in
  92. Hertz.
  93. Return Value:
  94. Status code.
  95. --*/
  96. EFI_STATUS
  97. EfipVeyronCreateSmbiosTables (
  98. VOID
  99. );
  100. /*++
  101. Routine Description:
  102. This routine creates the SMBIOS tables.
  103. Arguments:
  104. None.
  105. Return Value:
  106. EFI Status code.
  107. --*/
  108. EFI_STATUS
  109. EfipEnumerateRamDisks (
  110. VOID
  111. );
  112. /*++
  113. Routine Description:
  114. This routine enumerates any RAM disks embedded in the firmware.
  115. Arguments:
  116. None.
  117. Return Value:
  118. EFI Status code.
  119. --*/
  120. EFI_STATUS
  121. EfipVeyronEnumerateVideo (
  122. VOID
  123. );
  124. /*++
  125. Routine Description:
  126. This routine enumerates the display on the Veyron.
  127. Arguments:
  128. None.
  129. Return Value:
  130. EFI status code.
  131. --*/
  132. EFI_STATUS
  133. EfipVeyronEnumerateSerial (
  134. VOID
  135. );
  136. /*++
  137. Routine Description:
  138. This routine enumerates the serial port on the Veyron RK3288 SoC.
  139. Arguments:
  140. None.
  141. Return Value:
  142. EFI status code.
  143. --*/
  144. VOID
  145. EfipVeyronInitializeUart (
  146. VOID
  147. );
  148. /*++
  149. Routine Description:
  150. This routine completes any platform specific UART initialization steps.
  151. Arguments:
  152. None.
  153. Return Value:
  154. None.
  155. --*/
  156. EFI_STATUS
  157. EfipSmpInitialize (
  158. VOID
  159. );
  160. /*++
  161. Routine Description:
  162. This routine initializes and parks the second core on the RK32xx.
  163. Arguments:
  164. None.
  165. Return Value:
  166. EFI status code.
  167. --*/
  168. EFI_STATUS
  169. EfipVeyronEnumerateSd (
  170. VOID
  171. );
  172. /*++
  173. Routine Description:
  174. This routine enumerates the SD card on the Veyron SoC.
  175. Arguments:
  176. None.
  177. Return Value:
  178. EFI status code.
  179. --*/
  180. VOID
  181. EfipVeyronUsbInitialize (
  182. VOID
  183. );
  184. /*++
  185. Routine Description:
  186. This routine performs any board-specific high speed USB initialization.
  187. Arguments:
  188. None.
  189. Return Value:
  190. None.
  191. --*/
  192. EFI_STATUS
  193. EfipRk32I2cInitialize (
  194. VOID
  195. );
  196. /*++
  197. Routine Description:
  198. This routine initializes the I2C device.
  199. Arguments:
  200. None.
  201. Return Value:
  202. Status code.
  203. --*/
  204. EFI_STATUS
  205. EfipRk32I2cWrite (
  206. UINT8 Chip,
  207. UINT32 Address,
  208. UINT32 AddressLength,
  209. VOID *Buffer,
  210. UINT32 Length
  211. );
  212. /*++
  213. Routine Description:
  214. This routine writes the given buffer out to the given i2c device.
  215. Arguments:
  216. Chip - Supplies the device to write to.
  217. Address - Supplies the address.
  218. AddressLength - Supplies the width of the address. Valid values are zero
  219. through two.
  220. Buffer - Supplies the buffer containing the data to write.
  221. Length - Supplies the length of the buffer in bytes.
  222. Return Value:
  223. Status code.
  224. --*/
  225. EFI_STATUS
  226. EfipRk32I2cRead (
  227. UINT8 Chip,
  228. UINT32 Address,
  229. UINT32 AddressLength,
  230. VOID *Buffer,
  231. UINT32 Length
  232. );
  233. /*++
  234. Routine Description:
  235. This routine reads from the given i2c device into the given buffer.
  236. Arguments:
  237. Chip - Supplies the device to read from.
  238. Address - Supplies the address.
  239. AddressLength - Supplies the width of the address. Valid values are zero
  240. through two.
  241. Buffer - Supplies a pointer to the buffer where the read data will be
  242. returned.
  243. Length - Supplies the length of the buffer in bytes.
  244. Return Value:
  245. Status code.
  246. --*/
  247. EFI_STATUS
  248. EfipRk808InitializeRtc (
  249. VOID
  250. );
  251. /*++
  252. Routine Description:
  253. This routine enables the MMC power rails controlled by the TWL4030.
  254. Arguments:
  255. None.
  256. Return Value:
  257. Status code.
  258. --*/
  259. EFI_STATUS
  260. EfipRk808ReadRtc (
  261. EFI_TIME *Time
  262. );
  263. /*++
  264. Routine Description:
  265. This routine reads the current time from the RK808.
  266. Arguments:
  267. Time - Supplies a pointer where the time is returned on success.
  268. Return Value:
  269. Status code.
  270. --*/
  271. EFI_STATUS
  272. EfipRk808ReadRtcWakeupTime (
  273. BOOLEAN *Enabled,
  274. BOOLEAN *Pending,
  275. EFI_TIME *Time
  276. );
  277. /*++
  278. Routine Description:
  279. This routine reads the wake alarm time from the RK808.
  280. Arguments:
  281. Enabled - Supplies a pointer where a boolean will be returned indicating if
  282. the wake time interrupt is enabled.
  283. Pending - Supplies a pointer where a boolean will be returned indicating if
  284. the wake alarm interrupt is pending and requires service.
  285. Time - Supplies a pointer where the time is returned on success.
  286. Return Value:
  287. Status code.
  288. --*/
  289. EFI_STATUS
  290. EfipRk808WriteRtc (
  291. EFI_TIME *Time
  292. );
  293. /*++
  294. Routine Description:
  295. This routine writes the current time to the RK808.
  296. Arguments:
  297. Time - Supplies a pointer to the new time to set.
  298. Return Value:
  299. Status code.
  300. --*/
  301. EFI_STATUS
  302. EfipRk808WriteRtcWakeupTime (
  303. BOOLEAN Enable,
  304. EFI_TIME *Time
  305. );
  306. /*++
  307. Routine Description:
  308. This routine writes the alarm time to the RK808.
  309. Arguments:
  310. Enable - Supplies a boolean enabling or disabling the wakeup timer.
  311. Time - Supplies an optional pointer to the time to set. This parameter is
  312. only optional if the enable parameter is FALSE.
  313. Return Value:
  314. Status code.
  315. --*/
  316. EFI_STATUS
  317. EfipRk808Shutdown (
  318. VOID
  319. );
  320. /*++
  321. Routine Description:
  322. This routine performs a system shutdown using the RK808.
  323. Arguments:
  324. None.
  325. Return Value:
  326. Status code.
  327. --*/
  328. //
  329. // Runtime service functions
  330. //
  331. EFIAPI
  332. VOID
  333. EfipRk32ResetSystem (
  334. EFI_RESET_TYPE ResetType,
  335. EFI_STATUS ResetStatus,
  336. UINTN DataSize,
  337. VOID *ResetData
  338. );
  339. /*++
  340. Routine Description:
  341. This routine resets the entire platform.
  342. Arguments:
  343. ResetType - Supplies the type of reset to perform.
  344. ResetStatus - Supplies the status code for this reset.
  345. DataSize - Supplies the size of the reset data.
  346. ResetData - Supplies an optional pointer for reset types of cold, warm, or
  347. shutdown to a null-terminated string, optionally followed by additional
  348. binary data.
  349. Return Value:
  350. None. This routine does not return.
  351. --*/
  352. EFIAPI
  353. EFI_STATUS
  354. EfipRk32GetTime (
  355. EFI_TIME *Time,
  356. EFI_TIME_CAPABILITIES *Capabilities
  357. );
  358. /*++
  359. Routine Description:
  360. This routine returns the current time and dat information, and
  361. timekeeping capabilities of the hardware platform.
  362. Arguments:
  363. Time - Supplies a pointer where the current time will be returned.
  364. Capabilities - Supplies an optional pointer where the capabilities will be
  365. returned on success.
  366. Return Value:
  367. EFI_SUCCESS on success.
  368. EFI_INVALID_PARAMETER if the time parameter was NULL.
  369. EFI_DEVICE_ERROR if there was a hardware error accessing the device.
  370. --*/
  371. EFIAPI
  372. EFI_STATUS
  373. EfipRk32SetTime (
  374. EFI_TIME *Time
  375. );
  376. /*++
  377. Routine Description:
  378. This routine sets the current local time and date information.
  379. Arguments:
  380. Time - Supplies a pointer to the time to set.
  381. Return Value:
  382. EFI_SUCCESS on success.
  383. EFI_INVALID_PARAMETER if a time field is out of range.
  384. EFI_DEVICE_ERROR if there was a hardware error accessing the device.
  385. --*/
  386. EFIAPI
  387. EFI_STATUS
  388. EfipRk32GetWakeupTime (
  389. BOOLEAN *Enabled,
  390. BOOLEAN *Pending,
  391. EFI_TIME *Time
  392. );
  393. /*++
  394. Routine Description:
  395. This routine gets the current wake alarm setting.
  396. Arguments:
  397. Enabled - Supplies a pointer that receives a boolean indicating if the
  398. alarm is currently enabled or disabled.
  399. Pending - Supplies a pointer that receives a boolean indicating if the
  400. alarm signal is pending and requires acknowledgement.
  401. Time - Supplies a pointer that receives the current wake time.
  402. Return Value:
  403. EFI_SUCCESS on success.
  404. EFI_INVALID_PARAMETER if any parameter is NULL.
  405. EFI_DEVICE_ERROR if there was a hardware error accessing the device.
  406. EFI_UNSUPPORTED if the wakeup timer is not supported on this platform.
  407. --*/
  408. EFIAPI
  409. EFI_STATUS
  410. EfipRk32SetWakeupTime (
  411. BOOLEAN Enable,
  412. EFI_TIME *Time
  413. );
  414. /*++
  415. Routine Description:
  416. This routine sets the current wake alarm setting.
  417. Arguments:
  418. Enable - Supplies a boolean enabling or disabling the wakeup timer.
  419. Time - Supplies an optional pointer to the time to set. This parameter is
  420. only optional if the enable parameter is FALSE.
  421. Return Value:
  422. EFI_SUCCESS on success.
  423. EFI_INVALID_PARAMETER if a time field is out of range.
  424. EFI_DEVICE_ERROR if there was a hardware error accessing the device.
  425. EFI_UNSUPPORTED if the wakeup timer is not supported on this platform.
  426. --*/