rk808.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. /*++
  2. Copyright (c) 2016 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. rk808.h
  5. Abstract:
  6. This header contains hardware definitions for the RK808 Power Management IC.
  7. Author:
  8. Evan Green 4-Apr-2016
  9. --*/
  10. //
  11. // ------------------------------------------------------------------- Includes
  12. //
  13. //
  14. // --------------------------------------------------------------------- Macros
  15. //
  16. #define RK808_LDO_ON_VSEL(_Ldo) (Rk808Ldo1OnVsel + (((_Ldo) - 1) * 2))
  17. #define RK808_LDO_SLP_VSEL(_Ldo) (Rk808Ldo1SlpVsel + (((_Ldo) - 1) * 2))
  18. //
  19. // ---------------------------------------------------------------- Definitions
  20. //
  21. #define RK808_LDO_COUNT 8
  22. //
  23. // RTC status bits.
  24. //
  25. #define RK808_RTC_STATUS_RUNNING 0x02
  26. #define RK808_RTC_STATUS_1_SECOND_EVENT 0x04
  27. #define RK808_RTC_STATUS_1_MINUTE_EVENT 0x08
  28. #define RK808_RTC_STATUS_1_HOUR_EVENT 0x10
  29. #define RK808_RTC_STATUS_1_DAY_EVENT 0x20
  30. #define RK808_RTC_STATUS_ALARM 0x40
  31. #define RK808_RTC_STATUS_RESET 0x80
  32. //
  33. // RTC control bits.
  34. //
  35. #define RK808_RTC_CONTROL_STOP 0x01
  36. #define RK808_RTC_CONTROL_ROUND_30S 0x02
  37. #define RK808_RTC_CONTROL_AUTO_COMPENSATION 0x04
  38. #define RK808_RTC_CONTROL_12_HOUR_MODE 0x08
  39. #define RK808_RTC_CONTROL_TEST_MODE 0x10
  40. #define RK808_RTC_CONTROL_SET_32_COUNTER 0x20
  41. #define RK808_RTC_CONTROL_GET_TIME 0x40
  42. #define RK808_RTC_CONTROL_READ_SHADOWED 0x80
  43. //
  44. // RTC interrupt bits.
  45. //
  46. #define RK808_RTC_INTERRUPT_PERIODIC_MASK 0x03
  47. #define RK808_RTC_INTERRUPT_EVERY_SECOND 0x00
  48. #define RK808_RTC_INTERRUPT_EVERY_MINUTE 0x01
  49. #define RK808_RTC_INTERRUPT_EVERY_HOUR 0x02
  50. #define RK808_RTC_INTERRUPT_EVERY_DAY 0x03
  51. #define RK808_RTC_INTERRUPT_PERIODIC 0x04
  52. #define RK808_RTC_INTERRUPT_ALARM 0x08
  53. #define RK808_RTC_INTERRUPT_MASK_DURING_SLEEP 0x10
  54. //
  55. // Clock 32k out register bits.
  56. //
  57. #define RK808_CLOCK_32K_OUT2_ENABLE 0x01
  58. //
  59. // Battery voltage monitor register bits.
  60. //
  61. //
  62. // The low voltage is from 2.8 - 3.5V in steps of 100mV.
  63. //
  64. #define RK808_BATTERY_LOW_VOLTAGE_THRESHOLD_MASK 0x07
  65. #define RK808_BATTERY_LOW_VOLTAGE_STATUS 0x08
  66. #define RK808_BATTERY_LOW_ACTION_INTERRUPT 0x10
  67. #define RK808_BATTERY_UNDERVOLTAGE_LOCKOUT 0x20
  68. #define RK808_BATTERY_CHARGER_IN_EVENT 0x40
  69. #define RK808_BATTERY_CHARGER_OUT_EVENT 0x80
  70. //
  71. // Thermal control register bits.
  72. //
  73. #define RK808_THERMAL_SHUTDOWN 0x01
  74. #define RK808_THERMAL_HOT_DIE_WARNING 0x02
  75. #define RK808_THERMAL_HOT_THRESHOLD_MASK 0x0C
  76. #define RK808_THERMAL_HOT_THRESHOLD_85C (0x0 << 2)
  77. #define RK808_THERMAL_HOT_THRESHOLD_95C (0x1 << 2)
  78. #define RK808_THERMAL_HOT_THRESHOLD_105C (0x2 << 2)
  79. #define RK808_THERMAL_HOT_THRESHOLD_115C (0x3 << 2)
  80. #define RK808_THERMAL_SHUTDOWN_140C (0x0 << 4)
  81. #define RK808_THERMAL_SHUTDOWN_170C (0x1 << 4)
  82. //
  83. // DCDC converter enable register bits.
  84. //
  85. #define RK808_DCDC_BUCK1_ENABLE 0x01
  86. #define RK808_DCDC_BUCK2_ENABLE 0x02
  87. #define RK808_DCDC_BUCK3_ENABLE 0x04
  88. #define RK808_DCDC_BUCK4_ENABLE 0x08
  89. #define RK808_DCDC_SWITCH1_ENABLE 0x20
  90. #define RK808_DCDC_SWITCH2_ENABLE 0x40
  91. //
  92. // Buck n Configuration register bits.
  93. //
  94. #define RK808_BUCK_ILMIN_MASK 0x7
  95. #define RK808_BUCK_ILMIN_50MA 0x1
  96. #define RK808_BUCK_ILMIN_100MA 0x1
  97. #define RK808_BUCK_ILMIN_150MA 0x2
  98. #define RK808_BUCK_ILMIN_200MA 0x3
  99. #define RK808_BUCK_ILMIN_250MA 0x4
  100. #define RK808_BUCK_ILMIN_300MA 0x5
  101. #define RK808_BUCK_ILMIN_350MA 0x6
  102. #define RK808_BUCK_ILMIN_400MA 0x7
  103. #define RK808_BUCK_RATE_MASK (0x3 << 3)
  104. #define RK808_BUCK_RATE_2MV_US (0x0 << 3)
  105. #define RK808_BUCK_RATE_4MV_US (0x1 << 3)
  106. #define RK808_BUCK_RATE_6MV_US (0x2 << 3)
  107. #define RK808_BUCK_RATE_10MV_US (0x3 << 3)
  108. #define RK808_BUCK_PHASE_INVERTED 0x80
  109. //
  110. // Device control register bits.
  111. //
  112. #define RK808_DEVICE_OFF 0x01
  113. #define RK808_DEVICE_SLEEP 0x02
  114. #define RK808_DEVICE_OFF_RESET 0x08
  115. #define RK808_DEVICE_OFF_BUTTON_HOLD_MASK (0x3 << 4)
  116. #define RK808_DEVICE_OFF_BUTTON_HOLD_6S (0x0 << 4)
  117. #define RK808_DEVICE_OFF_BUTTON_HOLD_8S (0x1 << 4)
  118. #define RK808_DEVICE_OFF_BUTTON_HOLD_10S (0x2 << 4)
  119. #define RK808_DEVICE_OFF_BUTTON_HOLD_12S (0x3 << 4)
  120. #define RK808_DEVICE_CONTROL_SHUTDOWN (1 << 3)
  121. //
  122. // Interrupt status/mask 1 register bits. Status bits are write 1 to clear.
  123. // Masked interrupts do not fire if the mask bit is 1.
  124. //
  125. #define RK808_INTERRUPT1_VOUT_LOW 0x01
  126. #define RK808_INTERRUPT1_BATTERY_LOW 0x02
  127. #define RK808_INTERRUPT1_POWER_ON 0x04
  128. #define RK808_INTERRUPT1_POWER_ON_LONG_PRESS 0x08
  129. #define RK808_INTERRUPT1_HOT_DIE 0x10
  130. #define RK808_INTERRUPT1_RTC_ALARM 0x20
  131. #define RK808_INTERRUPT1_RTC_PERIOD 0x40
  132. //
  133. // Interrupt status/mask 2 register bits.
  134. //
  135. #define RK808_INTERRUPT2_PLUG_IN 0x01
  136. #define RK808_INTERRUPT2_PLUG_OUT 0x02
  137. //
  138. // I/O polarity register bits.
  139. //
  140. #define RK808_POLARITY_INT_ACTIVE_HIGH 0x01
  141. #define RK808_POLARITY_DVS1_ACTIVE_HIGH 0x02
  142. #define RK808_POLARITY_DVS2_ACTIVE_HIGH 0x04
  143. //
  144. // ------------------------------------------------------ Data Type Definitions
  145. //
  146. typedef enum _RK808_REGISTER {
  147. Rk808Seconds = 0x00,
  148. Rk808Minutes = 0x01,
  149. Rk808Hours = 0x02,
  150. Rk808Days = 0x03,
  151. Rk808Months = 0x04,
  152. Rk808Years = 0x05,
  153. Rk808Weeks = 0x06,
  154. Rk808AlarmSeconds = 0x08,
  155. Rk808AlarmMinutes = 0x09,
  156. Rk808AlarmHours = 0x0A,
  157. Rk808AlarmDays = 0x0B,
  158. Rk808AlarmMonths = 0x0C,
  159. Rk808AlarmYears = 0x0D,
  160. Rk808RtcControl = 0x10,
  161. Rk808RtcStatus = 0x11,
  162. Rk808RtcInterrupt = 0x12,
  163. Rk808CompensationLsb = 0x13,
  164. Rk808CompensationMsb = 0x14,
  165. Rk808Clock32kOut = 0x20,
  166. Rk808BatteryVoltageMonitor = 0x21,
  167. Rk808Thermal = 0x22,
  168. Rk808DcDcEnable = 0x23,
  169. Rk808LdoEnable = 0x24,
  170. Rk808SleepSetOff1 = 0x25,
  171. Rk808SleepSetOff2 = 0x26,
  172. Rk808DcDcUvStatus = 0x27,
  173. Rk808DcDcUvAct = 0x28,
  174. Rk808LdoUvStatus = 0x29,
  175. Rk808LdoUvAct = 0x2A,
  176. Rk808DcDcPg = 0x2B,
  177. Rk808LdoPg = 0x2C,
  178. Rk808VoutMonTdb = 0x2D,
  179. Rk808Buck1Config = 0x2E,
  180. Rk808Buck1OnVsel = 0x2F,
  181. Rk808Buck1SlpVsel = 0x30,
  182. Rk808Buck1DvsVsel = 0x31,
  183. Rk808Buck2Config = 0x32,
  184. Rk808Buck2OnVsel = 0x33,
  185. Rk808Buck2SlpVsel = 0x34,
  186. Rk808Buck2DvsVsel = 0x35,
  187. Rk808Buck3Config = 0x36,
  188. Rk808Buck4Config = 0x37,
  189. Rk808Buck4OnVsel = 0x38,
  190. Rk808Buck4SlpVsel = 0x39,
  191. Rk808Ldo1OnVsel = 0x3B,
  192. Rk808Ldo1SlpVsel = 0x3C,
  193. Rk808Ldo2OnVsel = 0x3D,
  194. Rk808Ldo2SlpVsel = 0x3E,
  195. Rk808Ldo3OnVsel = 0x3F,
  196. Rk808Ldo3SlpVsel = 0x40,
  197. Rk808Ldo4OnVsel = 0x41,
  198. Rk808Ldo4SlpVsel = 0x42,
  199. Rk808Ldo5OnVsel = 0x43,
  200. Rk808Ldo5SlpVsel = 0x44,
  201. Rk808Ldo6OnVsel = 0x45,
  202. Rk808Ldo6SlpVsel = 0x46,
  203. Rk808Ldo7OnVsel = 0x47,
  204. Rk808Ldo7SlpVsel = 0x48,
  205. Rk808Ldo8OnVsel = 0x49,
  206. Rk808Ldo8SlpVsel = 0x4A,
  207. Rk808DeviceControl = 0x4B,
  208. Rk808InterruptStatus1 = 0x4C,
  209. Rk808InterruptMask1 = 0x4D,
  210. Rk808InterruptStatus2 = 0x4E,
  211. Rk808InterruptMask2 = 0x4F,
  212. Rk808IoPol = 0x50,
  213. Rk808DcDcIlMax = 0x90,
  214. } RK808_REGISTER, *PRK808_REGISTER;
  215. /*++
  216. Structure Description:
  217. This structure stores the possible range for an LDO in the RK808.
  218. Members:
  219. Min - Stores the minimum millivolt value that the LDO can output, in
  220. millivolts.
  221. Max - Stores the maximum millivolt value that the LDO can output, in
  222. millivolts.
  223. Step - Stores the granularity of millivolt output between the minimum and
  224. the maximum, in millivolts.
  225. --*/
  226. typedef struct _RK808_LDO_RANGE {
  227. USHORT Min;
  228. USHORT Max;
  229. USHORT Step;
  230. } RK808_LDO_RANGE, *PRK808_LDO_RANGE;
  231. //
  232. // -------------------------------------------------------------------- Globals
  233. //
  234. //
  235. // -------------------------------------------------------- Function Prototypes
  236. //