wdt_v2.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. /*****************************************************************************
  2. * Copyright Statement:
  3. * --------------------
  4. * This software is protected by Copyright and the information contained
  5. * herein is confidential. The software may not be copied and the information
  6. * contained herein may not be used or disclosed except with the written
  7. * permission of MediaTek Inc. (C) 2018
  8. *
  9. * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
  27. *
  28. * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. #ifndef __MTK_WDT_H__
  36. #define __MTK_WDT_H__
  37. #define MTK_WDT_BASE RGU_BASE
  38. #define MTK_WDT_MODE (MTK_WDT_BASE+0x0000)
  39. #define MTK_WDT_LENGTH (MTK_WDT_BASE+0x0004)
  40. #define MTK_WDT_RESTART (MTK_WDT_BASE+0x0008)
  41. #define MTK_WDT_STATUS (MTK_WDT_BASE+0x000C)
  42. #define MTK_WDT_INTERVAL (MTK_WDT_BASE+0x0010)
  43. #define MTK_WDT_SWRST (MTK_WDT_BASE+0x0014)
  44. #define MTK_WDT_SWSYSRST (MTK_WDT_BASE+0x0018)
  45. #define MTK_WDT_NONRST_REG (MTK_WDT_BASE+0x0020)
  46. #define MTK_WDT_NONRST_REG2 (MTK_WDT_BASE+0x0024)
  47. #define MTK_WDT_REQ_MODE (MTK_WDT_BASE+0x0030)
  48. #define MTK_WDT_REQ_IRQ_EN (MTK_WDT_BASE+0x0034)
  49. #define MTK_WDT_DEBUG_CTL (MTK_WDT_BASE+0x0040)
  50. #define MTK_WDT_LATCH_CTL (MTK_WDT_BASE+0x0044)
  51. #define MTK_WDT_LATCH_CTL2 (MTK_WDT_BASE+0x0048)
  52. #define MTK_WDT_RSTDEG_EN1 (MTK_WDT_BASE+0x0080)
  53. #define MTK_WDT_RSTDEG_EN2 (MTK_WDT_BASE+0x0084)
  54. #define MTK_WDT_RESET_PROTECT (MTK_WDT_BASE+0x0090)
  55. #define MTK_WDT_DEBUG_CTL2 (MTK_WDT_BASE+0x00A0)
  56. #define MTK_WDT_PWR_LATCH (MTK_WDT_BASE+0x00A4)
  57. #define MTK_WDT_DEBUG_0_REG (MTK_WDT_BASE+0x0500)
  58. #define MTK_WDT_DEBUG_1_REG (MTK_WDT_BASE+0x0504)
  59. #define MTK_WDT_DEBUG_2_REG (MTK_WDT_BASE+0x0508)
  60. #define MTK_WDT_DEBUG_3_REG (MTK_WDT_BASE+0x050C)
  61. #define MTK_WDT_DEBUG_4_REG (MTK_WDT_BASE+0x0510)
  62. #define MTK_WDT_DEBUG_5_REG (MTK_WDT_BASE+0x0514)
  63. #define MTK_WDT_DEBUG_6_REG (MTK_WDT_BASE+0x0518)
  64. /*WDT_MODE*/
  65. #define MTK_WDT_MODE_KEYMASK (0xff00)
  66. #define MTK_WDT_MODE_KEY (0x22000000)
  67. #define MTK_WDT_MODE_DDR_RESERVE (0x0080)
  68. #define MTK_WDT_MODE_DUAL_MODE (0x0040)
  69. #define MTK_WDT_MODE_IN_DIS (0x0020) /* Reserved */
  70. #define MTK_WDT_MODE_AUTO_RESTART (0x0010) /* Reserved */
  71. #define MTK_WDT_MODE_IRQ (0x0008)
  72. #define MTK_WDT_MODE_EXTEN (0x0004)
  73. #define MTK_WDT_MODE_EXT_POL (0x0002)
  74. #define MTK_WDT_MODE_ENABLE (0x0001)
  75. /*WDT_LENGTH*/
  76. #define MTK_WDT_LENGTH_TIME_OUT (0xffe0)
  77. #define MTK_WDT_LENGTH_KEYMASK (0x001f)
  78. #define MTK_WDT_LENGTH_KEY (0x0008)
  79. #define MTK_WDT_LENGTH_CTL_KEY (0x95<<24)
  80. /*WDT_RESTART*/
  81. #define MTK_WDT_RESTART_KEY (0x1971)
  82. /*WDT_STATUS*/
  83. #define MTK_WDT_STATUS_HWWDT_RST (0x80000000)
  84. #define MTK_WDT_STATUS_SWWDT_RST (0x40000000)
  85. #define MTK_WDT_STATUS_IRQWDT_RST (0x20000000)
  86. #define MTK_WDT_STATUS_DEBUGWDT_RST (0x00080000)
  87. #define MTK_WDT_STATUS_SPMWDT_RST (0x0002)
  88. #define MTK_WDT_STATUS_SPM_THERMAL_RST (0x0001)
  89. #define MTK_WDT_STATUS_THERMAL_DIRECT_RST (1<<18)
  90. #define MTK_WDT_STATUS_SECURITY_RST (1<<28)
  91. #define MTK_WDT_STATUS_EINT_RST (1<<2)
  92. #define MTK_WDT_STATUS_SYSRST_RST (1<<3)
  93. #define MTK_WDT_STATUS_DVFSP_RST (1<<4)
  94. #define MTK_WDT_STATUS_SSPM_RST (1<<16)
  95. #define MTK_WDT_STATUS_MDDBG_RST (1<<17)
  96. /*WDT_RST_DEGLITCH*/
  97. #define MTK_WDT_RSTDEG_EN1_KEY (0xa357)
  98. #define MTK_WDT_RSTDEG_EN2_KEY (0x67d2)
  99. #define MTK_WDT_RSTDEG_CLOCK_SELETC_SHIFT (31)
  100. #define MTK_WDT_RSTDEG_CLOCK_SELECT_MASK (0x1 << MTK_WDT_RSTDEG_CLOCK_SELETC_SHIFT)
  101. #define MTK_WDT_RSTDEG_CLOCK_26M (0)
  102. #define MTK_WDT_RSTDEG_CLOCK_32K (1)
  103. #define MTK_WDT_RSTDEG_LATENCY_SHIFT (24)
  104. #define MTK_WDT_RSTDEG_LATENCY_MASK (0xF << MTK_WDT_RSTDEG_LATENCY_SHIFT)
  105. #define MTK_WDT_RSTDEG_LATENCY_118US_93MS (0x0)
  106. #define MTK_WDT_RSTDEG_LATENCY_59US_46MS (0x1)
  107. #define MTK_WDT_RSTDEG_LATENCY_29US_23MS (0x2)
  108. #define MTK_WDT_RSTDEG_LATENCY_14US_11MS (0x3)
  109. #define MTK_WDT_RSTDEG_LATENCY_7US_5MS (0x4)
  110. #define MTK_WDT_RSTDEG_LATENCY_3US_2MS (0x5)
  111. #define MTK_WDT_RSTDEG_LATENCY_1US_1MS (0x6)
  112. #define MTK_WDT_RSTDEG_LATENCY_923NS_732US (0x7)
  113. #define MTK_WDT_RSTDEG_LATENCY_461NS_366US (0x8)
  114. #define MTK_WDT_RSTDEG_LATENCY_230NS_183US (0x9)
  115. #define MTK_WDT_RSTDEG_LATENCY_115NS_91US (0xA)
  116. /*WDT_INTERVAL*/
  117. #define MTK_WDT_INTERVAL_KEY (0x66000000)
  118. #define MTK_WDT_INTERVAL_MASK (0x0FFF)
  119. /*WDT_SWRST*/
  120. #define MTK_WDT_SWRST_KEY (0x1209)
  121. /*WDT_SWSYSRST*/
  122. #define MTK_WDT_SWSYS_RST_PWRAP_SPI_CTL_RST (0x0800)
  123. #define MTK_WDT_SWSYS_RST_APMIXED_RST (0x0400)
  124. #define MTK_WDT_SWSYS_RST_MD_LITE_RST (0x0200)
  125. #define MTK_WDT_SWSYS_RST_INFRA_AO_RST (0x0100)
  126. #define MTK_WDT_SWSYS_RST_MD_RST (0x0080)
  127. #define MTK_WDT_SWSYS_RST_DDRPHY_RST (0x0040)
  128. #define MTK_WDT_SWSYS_RST_IMG_RST (0x0020)
  129. #define MTK_WDT_SWSYS_RST_VDEC_RST (0x0010)
  130. #define MTK_WDT_SWSYS_RST_VENC_RST (0x0008)
  131. #define MTK_WDT_SWSYS_RST_MFG_RST (0x0004)
  132. #define MTK_WDT_SWSYS_RST_DISP_RST (0x0002)
  133. #define MTK_WDT_SWSYS_RST_INFRA_RST (0x0001)
  134. /* Reboot source */
  135. #define RGU_STAGE_MASK (0x3)
  136. #define RGU_STAGE_PRELOADER (0x1)
  137. #define RGU_STAGE_LK (0x2)
  138. #define RGU_STAGE_KERNEL (0x3)
  139. /* WDT_NONRST_REG2 */
  140. #define MTK_WDT_NONRST2_SSPM_RESET (1 << 0)
  141. #define MTK_WDT_NONRST2_STAGE_OFS (30) /* 31:30: 2-bits for current stage */
  142. #define MTK_WDT_NONRST2_LAST_STAGE_OFS (28) /* 29:28: 2-bits for last stage */
  143. #define MTK_WDT_SWSYS_RST_KEY (0x88000000)
  144. #define MTK_WDT_REQ_IRQ_KEY (0x44000000)
  145. #define MTK_WDT_REQ_MODE_KEY (0x33000000)
  146. /* WDT_NONRST_REG */
  147. #define MTK_WDT_NONRST_DL (0x00008000)
  148. /* MTK_WDT_DEBUG_CTL */
  149. #define MTK_DEBUG_CTL_KEY (0x59000000)
  150. #define MTK_RG_DRAMC_SREF (0x00100)
  151. #define MTK_RG_DRAMC_ISO (0x00200)
  152. #define MTK_RG_CONF_ISO (0x00400)
  153. #define MTK_RGU_EMI_DCS_PAUSE (0x00004000) /* bit 14: dcs_pause */
  154. #define MTK_RGU_DVFSRC_PAUSE (0x00008000) /* bit 15: dvfsrc_pause */
  155. #define MTK_DDR_RESERVE_RTA (0x10000) /* bit 16: ddr_reserve_success */
  156. #define MTK_DDR_SREF_STA (0x20000) /* bit 17: ddr_sref_status */
  157. #define MTK_RGU_EMI_DCS_SUCCESS_OFFSET (18) /* bit 18: emi_dcs_success */
  158. #define MTK_RGU_EMI_DCS_SUCCESS (1 << MTK_RGU_EMI_DCS_SUCCESS_OFFSET)
  159. #define MTK_RGU_DVFSRC_SUCCESS_OFFSET (20) /* bit 20: dvfsrc_success */
  160. #define MTK_RGU_DVFSRC_SUCCESS (1 << MTK_RGU_DVFSRC_SUCCESS_OFFSET)
  161. /* MTK_WDT_DEBUG_CTL2 */
  162. #define MTK_DEBUG_CTL2_KEY (0x55000000)
  163. #define MTK_RGU_EMI_DCS_EN (1 << 8) /* emi_dcs_en */
  164. #define MTK_RGU_DVFSRC_EN (1 << 9) /* dvfsrc_en */
  165. /* MTK_WDT_LATCH_CTL */
  166. #define MTK_LATCH_CTL_KEY (0x95000000)
  167. #define MTK_RG_LATH_EN (1 << 0)
  168. #define MTK_RG_MCU_LATCH_SELECT (1 << 1)
  169. #define MTK_RG_SPM_LATCH_SELECT (1 << 2)
  170. #define MTK_RG_MCU_LATH_EN (1 << 4)
  171. #define MTK_RG_SPM_LATH_EN (1 << 5)
  172. #define MTK_RG_DRAMC_LATH_EN (1 << 6)
  173. #define MTK_RG_MPO_EXT_OFF_EN (1 << 8)
  174. #define MTK_RG_GPU_EXT_OFF_EN (1 << 9)
  175. #define MTK_RG_MD_EXT_OFF_EN (1 << 10)
  176. #define MTK_RG_DRAMC_RD_TEST_EN (1 << 11)
  177. #define MTK_RG_DRAMC_RDWT_TEST_EN (1 << 12)
  178. #define MTK_RG_DVFSRC_LATCH_EN (1 << 13) /* obsolete */
  179. #define MTK_RG_EMI_LATCH_EN (1 << 14)
  180. #define MTK_RG_DEBUGSYS_LATCH_EN (1 << 17)
  181. /* MTK_WDT_LATCH_CTL2 */
  182. #define MTK_LATCH_CTL2_KEY (0x95000000)
  183. #define MTK_RG_MCU_DFD_EN (1 << 17)
  184. #define MTK_RG_MCU_DFD_TIMEOUT_MASK (0x1FFFF)
  185. #define MTK_RG_MCU_DFD_TIMEOUT_OFS (0)
  186. #define MTK_RG_MCU_DFD_TIMEOUT_VALUE (0x30)
  187. /* Reboot reason */
  188. #define RE_BOOT_REASON_UNKNOW (0x00)
  189. #define RE_BOOT_BY_WDT_HW (0x01)
  190. #define RE_BOOT_BY_WDT_SW (0x02)
  191. #define RE_BOOT_WITH_INTTERUPT (0x04)
  192. #define RE_BOOT_BY_SPM_THERMAL (0x08)
  193. #define RE_BOOT_BY_SPM (0x10)
  194. #define RE_BOOT_BY_THERMAL_DIRECT (0x20)
  195. #define RE_BOOT_BY_DEBUG (0x40)
  196. #define RE_BOOT_BY_SECURITY (0x80)
  197. #define RE_BOOT_BY_EINT (0x100)
  198. #define RE_BOOT_BY_SYSRST (0x200)
  199. #define RE_BOOT_BY_SSPM_RST (0x400)
  200. #define RE_BOOT_BY_PMIC_FULL_RST (0x800) /* PMIC full (cold) reset */
  201. #define RE_BOOT_ABNORMAL (0xF0)
  202. /* Reboot from which stage */
  203. #define RE_BOOT_FROM_UNKNOW (0x00)
  204. #define RE_BOOT_FROM_PRE_LOADER (0x01)
  205. #define RE_BOOT_FROM_U_BOOT (0x02)
  206. #define RE_BOOT_FROM_KERNEL (0x03)
  207. #define RE_BOOT_FROM_POWER_ON (0x04)
  208. #define WDT_NORMAL_REBOOT (0x01)
  209. #define WDT_BY_PASS_PWK_REBOOT (0x02)
  210. #define WDT_NOT_WDT_REBOOT (0x00)
  211. typedef enum wd_swsys_reset_type {
  212. WD_MD_RST,
  213. }WD_SYS_RST_TYPE;
  214. typedef enum wk_req_en {
  215. WD_REQ_DIS,
  216. WD_REQ_EN,
  217. } WD_REQ_CTL;
  218. typedef enum wk_req_mode {
  219. WD_REQ_IRQ_MODE,
  220. WD_REQ_RST_MODE,
  221. } WD_REQ_MODE;
  222. enum {
  223. RGU_REG_CLR = 0,
  224. RGU_REG_SET = 1
  225. };
  226. extern void mtk_wdt_init(void);
  227. extern void mtk_arch_reset(char mode);
  228. extern BOOL mtk_is_rgu_trigger_reset(void);
  229. extern int mtk_wdt_boot_check(void);
  230. void mtk_wdt_pre_init(void);
  231. int mtk_wdt_request_en_set(int mark_bit, WD_REQ_CTL en);
  232. int mtk_wdt_request_mode_set(int mark_bit, WD_REQ_MODE mode);
  233. int rgu_dram_reserved(int enable);
  234. int rgu_cfg_emi_dcs_en(int enable);
  235. int rgu_is_dram_slf(void);
  236. int rgu_is_dvfsrc_enable(void);
  237. int rgu_is_dvfsrc_success(void);
  238. int rgu_is_emi_dcs_enable(void);
  239. int rgu_is_emi_dcs_success(void);
  240. int rgu_is_reserve_ddr_enabled(void);
  241. int rgu_is_reserve_ddr_mode_success(void);
  242. int rgu_release_rg_dram_setting(void);
  243. int rgu_release_rg_dramc_conf_iso(void);
  244. int rgu_release_rg_dramc_iso(void);
  245. int rgu_release_rg_dramc_sref(void);
  246. void rgu_swsys_reset(WD_SYS_RST_TYPE reset_type);
  247. extern unsigned g_rgu_status;
  248. #endif /*__MTK_WDT_H__*/