spm_md_mtcmos.c 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069
  1. /* Copyright Statement:
  2. *
  3. * This software/firmware and related documentation ("MediaTek Software") are
  4. * protected under relevant copyright laws. The information contained herein
  5. * is confidential and proprietary to MediaTek Inc. and/or its licensors.
  6. * Without the prior written permission of MediaTek inc. and/or its licensors,
  7. * any reproduction, modification, use or disclosure of MediaTek Software,
  8. * and information contained herein, in whole or in part, shall be strictly prohibited.
  9. */
  10. /* MediaTek Inc. (C) 2015. All rights reserved.
  11. *
  12. * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  13. * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  14. * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON
  15. * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  16. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  18. * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  19. * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  20. * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
  21. * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
  22. * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
  23. * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
  24. * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
  25. * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
  26. * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  27. * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  28. * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
  29. * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
  30. */
  31. #include <platform/spm.h>
  32. #include <platform/mt_gpt.h>
  33. int spm_mtcmos_ctrl_md1(int state)
  34. {
  35. int err = 0;
  36. /* TINFO="enable SPM register control" */
  37. spm_write(POWERON_CONFIG_EN, (SPM_PROJECT_CODE << 16) | (0x1 << 0));
  38. if (state == STA_POWER_DOWN) {
  39. /* TINFO="Start to turn off MD1" */
  40. /* TINFO="Set bus protect - step1 : 0" */
  41. spm_write(INFRA_TOPAXI_PROTECTEN_SET, MD1_PROT_STEP1_0_MASK);
  42. #ifndef IGNORE_MTCMOS_CHECK
  43. while ((spm_read(INFRA_TOPAXI_PROTECTEN_STA1) & MD1_PROT_STEP1_0_ACK_MASK) != MD1_PROT_STEP1_0_ACK_MASK) {
  44. }
  45. #endif
  46. /* TINFO="Set bus protect - step2 : 0" */
  47. spm_write(INFRA_TOPAXI_PROTECTEN_INFRA_VDNR_SET, MD1_PROT_STEP2_0_MASK);
  48. #ifndef IGNORE_MTCMOS_CHECK
  49. while ((spm_read(INFRA_TOPAXI_PROTECTEN_INFRA_VDNR_STA1) & MD1_PROT_STEP2_0_ACK_MASK) != MD1_PROT_STEP2_0_ACK_MASK) {
  50. }
  51. #endif
  52. /* TINFO="Set bus protect - step2 : 1" */
  53. spm_write(INFRA_TOPAXI_PROTECTEN_SUB_INFRA_VDNR_SET, MD1_PROT_STEP2_1_MASK);
  54. #ifndef IGNORE_MTCMOS_CHECK
  55. while ((spm_read(INFRA_TOPAXI_PROTECTEN_SUB_INFRA_VDNR_STA1) & MD1_PROT_STEP2_1_ACK_MASK) != MD1_PROT_STEP2_1_ACK_MASK) {
  56. }
  57. #endif
  58. /* TINFO="Set PWR_ON = 0" */
  59. spm_write(MD1_PWR_CON, spm_read(MD1_PWR_CON) & ~PWR_ON);
  60. #ifndef IGNORE_MTCMOS_CHECK
  61. /* TINFO="Wait until MD1_PWR_STA_MASK = 0" */
  62. while (spm_read(PWR_STATUS) & MD1_PWR_STA_MASK) {
  63. /* No logic between pwr_on and pwr_ack. Print SRAM / MTCMOS control and PWR_ACK for debug. */
  64. }
  65. #endif
  66. /* TINFO="Finish to turn off MD1" */
  67. } else { /* STA_POWER_ON */
  68. /* TINFO="Start to turn on MD1" */
  69. /* TINFO="Set PWR_ON = 1" */
  70. spm_write(MD1_PWR_CON, spm_read(MD1_PWR_CON) | PWR_ON);
  71. #ifndef IGNORE_MTCMOS_CHECK
  72. /* TINFO="Wait until MD1_PWR_STA_MASK = 1" */
  73. while ((spm_read(PWR_STATUS) & MD1_PWR_STA_MASK) != MD1_PWR_STA_MASK) {
  74. /* No logic between pwr_on and pwr_ack. Print SRAM / MTCMOS control and PWR_ACK for debug. */
  75. }
  76. #endif
  77. /* TINFO="Release bus protect - step2 : 0" */
  78. spm_write(INFRA_TOPAXI_PROTECTEN_INFRA_VDNR_CLR, MD1_PROT_STEP2_0_MASK);
  79. #ifndef IGNORE_MTCMOS_CHECK
  80. /* Note that this protect ack check after releasing protect has been ignored */
  81. #endif
  82. /* TINFO="Release bus protect - step2 : 1" */
  83. spm_write(INFRA_TOPAXI_PROTECTEN_SUB_INFRA_VDNR_CLR, MD1_PROT_STEP2_1_MASK);
  84. #ifndef IGNORE_MTCMOS_CHECK
  85. /* Note that this protect ack check after releasing protect has been ignored */
  86. #endif
  87. /* TINFO="Release bus protect - step1 : 0" */
  88. spm_write(INFRA_TOPAXI_PROTECTEN_CLR, MD1_PROT_STEP1_0_MASK);
  89. #ifndef IGNORE_MTCMOS_CHECK
  90. /* Note that this protect ack check after releasing protect has been ignored */
  91. #endif
  92. /* TINFO="Finish to turn on MD1" */
  93. }
  94. return err;
  95. }
  96. int spm_mtcmos_ctrl_mdp(int state)
  97. {
  98. int err = 0;
  99. /* TINFO="enable SPM register control" */
  100. spm_write(POWERON_CONFIG_EN, (SPM_PROJECT_CODE << 16) | (0x1 << 0));
  101. if (state == STA_POWER_DOWN) {
  102. /* TINFO="Start to turn off MDP" */
  103. /* TINFO="Set bus protect - step1 : 0" */
  104. spm_write(INFRA_TOPAXI_PROTECTEN_SET, MDP_PROT_STEP1_0_MASK);
  105. #ifndef IGNORE_MTCMOS_CHECK
  106. while ((spm_read(INFRA_TOPAXI_PROTECTEN_STA1) & MDP_PROT_STEP1_0_ACK_MASK) != MDP_PROT_STEP1_0_ACK_MASK) {
  107. }
  108. #endif
  109. /* TINFO="Set bus protect - step1 : 1" */
  110. spm_write(INFRA_TOPAXI_PROTECTEN_MM_SET, MDP_PROT_STEP1_1_MASK);
  111. #ifndef IGNORE_MTCMOS_CHECK
  112. while ((spm_read(INFRA_TOPAXI_PROTECTEN_MM_STA1) & MDP_PROT_STEP1_1_ACK_MASK) != MDP_PROT_STEP1_1_ACK_MASK) {
  113. }
  114. #endif
  115. /* TINFO="Set bus protect - step1 : 2" */
  116. spm_write(INFRA_TOPAXI_PROTECTEN_MM_2_SET, MDP_PROT_STEP1_2_MASK);
  117. #ifndef IGNORE_MTCMOS_CHECK
  118. while ((spm_read(INFRA_TOPAXI_PROTECTEN_MM_2_STA1) & MDP_PROT_STEP1_2_ACK_MASK) != MDP_PROT_STEP1_2_ACK_MASK) {
  119. }
  120. #endif
  121. /* TINFO="Set bus protect - step2 : 0" */
  122. spm_write(INFRA_TOPAXI_PROTECTEN_SET, MDP_PROT_STEP2_0_MASK);
  123. #ifndef IGNORE_MTCMOS_CHECK
  124. while ((spm_read(INFRA_TOPAXI_PROTECTEN_STA1) & MDP_PROT_STEP2_0_ACK_MASK) != MDP_PROT_STEP2_0_ACK_MASK) {
  125. }
  126. #endif
  127. /* TINFO="Set bus protect - step2 : 1" */
  128. spm_write(INFRA_TOPAXI_PROTECTEN_MM_SET, MDP_PROT_STEP2_1_MASK);
  129. #ifndef IGNORE_MTCMOS_CHECK
  130. while ((spm_read(INFRA_TOPAXI_PROTECTEN_MM_STA1) & MDP_PROT_STEP2_1_ACK_MASK) != (unsigned int)MDP_PROT_STEP2_1_ACK_MASK) {
  131. }
  132. #endif
  133. /* TINFO="Set bus protect - step2 : 2" */
  134. spm_write(INFRA_TOPAXI_PROTECTEN_MM_2_SET, MDP_PROT_STEP2_2_MASK);
  135. #ifndef IGNORE_MTCMOS_CHECK
  136. while ((spm_read(INFRA_TOPAXI_PROTECTEN_MM_2_STA1) & MDP_PROT_STEP2_2_ACK_MASK) != MDP_PROT_STEP2_2_ACK_MASK) {
  137. }
  138. #endif
  139. /* TINFO="Set bus protect - step2 : 3" */
  140. spm_write(INFRA_TOPAXI_PROTECTEN_SUB_INFRA_VDNR_SET, MDP_PROT_STEP2_3_MASK);
  141. #ifndef IGNORE_MTCMOS_CHECK
  142. while ((spm_read(INFRA_TOPAXI_PROTECTEN_SUB_INFRA_VDNR_STA1) & MDP_PROT_STEP2_3_ACK_MASK) != MDP_PROT_STEP2_3_ACK_MASK) {
  143. }
  144. #endif
  145. /* TINFO="Set SRAM_PDN = 1" */
  146. spm_write(MDP_PWR_CON, spm_read(MDP_PWR_CON) | MDP_SRAM_PDN);
  147. #ifndef IGNORE_MTCMOS_CHECK
  148. /* TINFO="Wait until MDP_SRAM_PDN_ACK = 1" */
  149. while ((spm_read(MDP_PWR_CON) & MDP_SRAM_PDN_ACK) != MDP_SRAM_PDN_ACK) {
  150. /* Need hf_fmm_ck for SRAM PDN delay IP. */
  151. }
  152. #endif
  153. /* TINFO="Set PWR_ISO = 1" */
  154. spm_write(MDP_PWR_CON, spm_read(MDP_PWR_CON) | PWR_ISO);
  155. /* TINFO="Set PWR_CLK_DIS = 1" */
  156. spm_write(MDP_PWR_CON, spm_read(MDP_PWR_CON) | PWR_CLK_DIS);
  157. /* TINFO="Set PWR_RST_B = 0" */
  158. spm_write(MDP_PWR_CON, spm_read(MDP_PWR_CON) & ~PWR_RST_B);
  159. /* TINFO="Set PWR_ON = 0" */
  160. spm_write(MDP_PWR_CON, spm_read(MDP_PWR_CON) & ~PWR_ON);
  161. /* TINFO="Set PWR_ON_2ND = 0" */
  162. spm_write(MDP_PWR_CON, spm_read(MDP_PWR_CON) & ~PWR_ON_2ND);
  163. #ifndef IGNORE_MTCMOS_CHECK
  164. /* TINFO="Wait until PWR_STATUS = 0 and PWR_STATUS_2ND = 0" */
  165. while ((spm_read(PWR_STATUS) & MDP_PWR_STA_MASK)
  166. || (spm_read(PWR_STATUS_2ND) & MDP_PWR_STA_MASK)) {
  167. /* No logic between pwr_on and pwr_ack. Print SRAM / MTCMOS control and PWR_ACK for debug. */
  168. }
  169. #endif
  170. /* TINFO="Finish to turn off MDP" */
  171. } else { /* STA_POWER_ON */
  172. /* TINFO="Start to turn on MDP" */
  173. /* TINFO="Set PWR_ON = 1" */
  174. spm_write(MDP_PWR_CON, spm_read(MDP_PWR_CON) | PWR_ON);
  175. /* TINFO="Set PWR_ON_2ND = 1" */
  176. spm_write(MDP_PWR_CON, spm_read(MDP_PWR_CON) | PWR_ON_2ND);
  177. #ifndef IGNORE_MTCMOS_CHECK
  178. /* TINFO="Wait until PWR_STATUS = 1 and PWR_STATUS_2ND = 1" */
  179. while (((spm_read(PWR_STATUS) & MDP_PWR_STA_MASK) != MDP_PWR_STA_MASK)
  180. || ((spm_read(PWR_STATUS_2ND) & MDP_PWR_STA_MASK) != MDP_PWR_STA_MASK)) {
  181. /* No logic between pwr_on and pwr_ack. Print SRAM / MTCMOS control and PWR_ACK for debug. */
  182. }
  183. #endif
  184. /* TINFO="Set PWR_CLK_DIS = 0" */
  185. spm_write(MDP_PWR_CON, spm_read(MDP_PWR_CON) & ~PWR_CLK_DIS);
  186. /* TINFO="Set PWR_ISO = 0" */
  187. spm_write(MDP_PWR_CON, spm_read(MDP_PWR_CON) & ~PWR_ISO);
  188. /* TINFO="Set PWR_RST_B = 1" */
  189. spm_write(MDP_PWR_CON, spm_read(MDP_PWR_CON) | PWR_RST_B);
  190. /* TINFO="Set SRAM_PDN = 0" */
  191. spm_write(MDP_PWR_CON, spm_read(MDP_PWR_CON) & ~(0x1 << 8));
  192. #ifndef IGNORE_MTCMOS_CHECK
  193. /* TINFO="Wait until MDP_SRAM_PDN_ACK_BIT0 = 0" */
  194. while (spm_read(MDP_PWR_CON) & MDP_SRAM_PDN_ACK_BIT0) {
  195. /* Need hf_fmm_ck for SRAM PDN delay IP. */
  196. }
  197. #endif
  198. /* TINFO="Release bus protect - step2 : 0" */
  199. spm_write(INFRA_TOPAXI_PROTECTEN_CLR, MDP_PROT_STEP2_0_MASK);
  200. #ifndef IGNORE_MTCMOS_CHECK
  201. /* Note that this protect ack check after releasing protect has been ignored */
  202. #endif
  203. /* TINFO="Release bus protect - step2 : 1" */
  204. spm_write(INFRA_TOPAXI_PROTECTEN_MM_CLR, MDP_PROT_STEP2_1_MASK);
  205. #ifndef IGNORE_MTCMOS_CHECK
  206. /* Note that this protect ack check after releasing protect has been ignored */
  207. #endif
  208. /* TINFO="Release bus protect - step2 : 2" */
  209. spm_write(INFRA_TOPAXI_PROTECTEN_MM_2_CLR, MDP_PROT_STEP2_2_MASK);
  210. #ifndef IGNORE_MTCMOS_CHECK
  211. /* Note that this protect ack check after releasing protect has been ignored */
  212. #endif
  213. /* TINFO="Release bus protect - step2 : 3" */
  214. spm_write(INFRA_TOPAXI_PROTECTEN_SUB_INFRA_VDNR_CLR, MDP_PROT_STEP2_3_MASK);
  215. #ifndef IGNORE_MTCMOS_CHECK
  216. /* Note that this protect ack check after releasing protect has been ignored */
  217. #endif
  218. /* TINFO="Release bus protect - step1 : 0" */
  219. spm_write(INFRA_TOPAXI_PROTECTEN_CLR, MDP_PROT_STEP1_0_MASK);
  220. #ifndef IGNORE_MTCMOS_CHECK
  221. /* Note that this protect ack check after releasing protect has been ignored */
  222. #endif
  223. /* TINFO="Release bus protect - step1 : 1" */
  224. spm_write(INFRA_TOPAXI_PROTECTEN_MM_CLR, MDP_PROT_STEP1_1_MASK);
  225. #ifndef IGNORE_MTCMOS_CHECK
  226. /* Note that this protect ack check after releasing protect has been ignored */
  227. #endif
  228. /* TINFO="Release bus protect - step1 : 2" */
  229. spm_write(INFRA_TOPAXI_PROTECTEN_MM_2_CLR, MDP_PROT_STEP1_2_MASK);
  230. #ifndef IGNORE_MTCMOS_CHECK
  231. /* Note that this protect ack check after releasing protect has been ignored */
  232. #endif
  233. /* TINFO="Finish to turn on MDP" */
  234. }
  235. return err;
  236. }
  237. int spm_mtcmos_ctrl_dis(int state)
  238. {
  239. int err = 0;
  240. /* TINFO="enable SPM register control" */
  241. spm_write(POWERON_CONFIG_EN, (SPM_PROJECT_CODE << 16) | (0x1 << 0));
  242. if (state == STA_POWER_DOWN) {
  243. /* TINFO="Start to turn off DIS" */
  244. /* TINFO="Set bus protect - step1 : 0" */
  245. spm_write(INFRA_TOPAXI_PROTECTEN_MM_SET, DIS_PROT_STEP1_0_MASK);
  246. #ifndef IGNORE_MTCMOS_CHECK
  247. while ((spm_read(INFRA_TOPAXI_PROTECTEN_MM_STA1) & DIS_PROT_STEP1_0_ACK_MASK) != DIS_PROT_STEP1_0_ACK_MASK) {
  248. }
  249. #endif
  250. /* TINFO="Set bus protect - step2 : 0" */
  251. spm_write(INFRA_TOPAXI_PROTECTEN_SET, DIS_PROT_STEP2_0_MASK);
  252. #ifndef IGNORE_MTCMOS_CHECK
  253. while ((spm_read(INFRA_TOPAXI_PROTECTEN_STA1) & DIS_PROT_STEP2_0_ACK_MASK) != DIS_PROT_STEP2_0_ACK_MASK) {
  254. }
  255. #endif
  256. /* TINFO="Set bus protect - step2 : 1" */
  257. spm_write(INFRA_TOPAXI_PROTECTEN_MM_SET, DIS_PROT_STEP2_1_MASK);
  258. #ifndef IGNORE_MTCMOS_CHECK
  259. while ((spm_read(INFRA_TOPAXI_PROTECTEN_MM_STA1) & DIS_PROT_STEP2_1_ACK_MASK) != DIS_PROT_STEP2_1_ACK_MASK) {
  260. }
  261. #endif
  262. /* TINFO="Set bus protect - step2 : 2" */
  263. spm_write(INFRA_TOPAXI_PROTECTEN_SUB_INFRA_VDNR_SET, DIS_PROT_STEP2_2_MASK);
  264. #ifndef IGNORE_MTCMOS_CHECK
  265. while ((spm_read(INFRA_TOPAXI_PROTECTEN_SUB_INFRA_VDNR_STA1) & DIS_PROT_STEP2_2_ACK_MASK) != DIS_PROT_STEP2_2_ACK_MASK) {
  266. }
  267. #endif
  268. /* TINFO="Set SRAM_PDN = 1" */
  269. spm_write(DIS_PWR_CON, spm_read(DIS_PWR_CON) | DIS_SRAM_PDN);
  270. #ifndef IGNORE_MTCMOS_CHECK
  271. /* TINFO="Wait until DIS_SRAM_PDN_ACK = 1" */
  272. while ((spm_read(DIS_PWR_CON) & DIS_SRAM_PDN_ACK) != DIS_SRAM_PDN_ACK) {
  273. /* Need hf_fmm_ck for SRAM PDN delay IP. */
  274. }
  275. #endif
  276. /* TINFO="Set PWR_ISO = 1" */
  277. spm_write(DIS_PWR_CON, spm_read(DIS_PWR_CON) | PWR_ISO);
  278. /* TINFO="Set PWR_CLK_DIS = 1" */
  279. spm_write(DIS_PWR_CON, spm_read(DIS_PWR_CON) | PWR_CLK_DIS);
  280. /* TINFO="Set PWR_RST_B = 0" */
  281. spm_write(DIS_PWR_CON, spm_read(DIS_PWR_CON) & ~PWR_RST_B);
  282. /* TINFO="Set PWR_ON = 0" */
  283. spm_write(DIS_PWR_CON, spm_read(DIS_PWR_CON) & ~PWR_ON);
  284. /* TINFO="Set PWR_ON_2ND = 0" */
  285. spm_write(DIS_PWR_CON, spm_read(DIS_PWR_CON) & ~PWR_ON_2ND);
  286. #ifndef IGNORE_MTCMOS_CHECK
  287. /* TINFO="Wait until PWR_STATUS = 0 and PWR_STATUS_2ND = 0" */
  288. while ((spm_read(PWR_STATUS) & DIS_PWR_STA_MASK)
  289. || (spm_read(PWR_STATUS_2ND) & DIS_PWR_STA_MASK)) {
  290. /* No logic between pwr_on and pwr_ack. Print SRAM / MTCMOS control and PWR_ACK for debug. */
  291. }
  292. #endif
  293. /* TINFO="Finish to turn off DIS" */
  294. } else { /* STA_POWER_ON */
  295. /* TINFO="Start to turn on DIS" */
  296. /* TINFO="Set PWR_ON = 1" */
  297. spm_write(DIS_PWR_CON, spm_read(DIS_PWR_CON) | PWR_ON);
  298. /* TINFO="Set PWR_ON_2ND = 1" */
  299. spm_write(DIS_PWR_CON, spm_read(DIS_PWR_CON) | PWR_ON_2ND);
  300. #ifndef IGNORE_MTCMOS_CHECK
  301. /* TINFO="Wait until PWR_STATUS = 1 and PWR_STATUS_2ND = 1" */
  302. while (((spm_read(PWR_STATUS) & DIS_PWR_STA_MASK) != DIS_PWR_STA_MASK)
  303. || ((spm_read(PWR_STATUS_2ND) & DIS_PWR_STA_MASK) != DIS_PWR_STA_MASK)) {
  304. /* No logic between pwr_on and pwr_ack. Print SRAM / MTCMOS control and PWR_ACK for debug. */
  305. }
  306. #endif
  307. /* TINFO="Set PWR_CLK_DIS = 0" */
  308. spm_write(DIS_PWR_CON, spm_read(DIS_PWR_CON) & ~PWR_CLK_DIS);
  309. /* TINFO="Set PWR_ISO = 0" */
  310. spm_write(DIS_PWR_CON, spm_read(DIS_PWR_CON) & ~PWR_ISO);
  311. /* TINFO="Set PWR_RST_B = 1" */
  312. spm_write(DIS_PWR_CON, spm_read(DIS_PWR_CON) | PWR_RST_B);
  313. /* TINFO="Set SRAM_PDN = 0" */
  314. spm_write(DIS_PWR_CON, spm_read(DIS_PWR_CON) & ~(0x1 << 8));
  315. #ifndef IGNORE_MTCMOS_CHECK
  316. /* TINFO="Wait until DIS_SRAM_PDN_ACK_BIT0 = 0" */
  317. while (spm_read(DIS_PWR_CON) & DIS_SRAM_PDN_ACK_BIT0) {
  318. /* Need hf_fmm_ck for SRAM PDN delay IP. */
  319. }
  320. #endif
  321. /* TINFO="Release bus protect - step2 : 0" */
  322. spm_write(INFRA_TOPAXI_PROTECTEN_CLR, DIS_PROT_STEP2_0_MASK);
  323. #ifndef IGNORE_MTCMOS_CHECK
  324. /* Note that this protect ack check after releasing protect has been ignored */
  325. #endif
  326. /* TINFO="Release bus protect - step2 : 1" */
  327. spm_write(INFRA_TOPAXI_PROTECTEN_MM_CLR, DIS_PROT_STEP2_1_MASK);
  328. #ifndef IGNORE_MTCMOS_CHECK
  329. /* Note that this protect ack check after releasing protect has been ignored */
  330. #endif
  331. /* TINFO="Release bus protect - step2 : 2" */
  332. spm_write(INFRA_TOPAXI_PROTECTEN_SUB_INFRA_VDNR_CLR, DIS_PROT_STEP2_2_MASK);
  333. #ifndef IGNORE_MTCMOS_CHECK
  334. /* Note that this protect ack check after releasing protect has been ignored */
  335. #endif
  336. /* TINFO="Release bus protect - step1 : 0" */
  337. spm_write(INFRA_TOPAXI_PROTECTEN_MM_CLR, DIS_PROT_STEP1_0_MASK);
  338. #ifndef IGNORE_MTCMOS_CHECK
  339. /* Note that this protect ack check after releasing protect has been ignored */
  340. #endif
  341. /* TINFO="Finish to turn on DIS" */
  342. }
  343. return err;
  344. }
  345. int spm_mtcmos_ctrl_adsp_shut_down(int state)
  346. {
  347. int err = 0;
  348. /* TINFO="enable SPM register control" */
  349. spm_write(POWERON_CONFIG_EN, (SPM_PROJECT_CODE << 16) | (0x1 << 0));
  350. if (state == STA_POWER_DOWN) {
  351. /* TINFO="Start to turn off ADSP" */
  352. /* TINFO="Set bus protect - step1 : 0" */
  353. spm_write(INFRA_TOPAXI_PROTECTEN_2_SET, ADSP_PROT_STEP1_0_MASK);
  354. #ifndef IGNORE_MTCMOS_CHECK
  355. while ((spm_read(INFRA_TOPAXI_PROTECTEN_STA1_2) & ADSP_PROT_STEP1_0_ACK_MASK) != ADSP_PROT_STEP1_0_ACK_MASK) {
  356. }
  357. #endif
  358. /* TINFO="Set SRAM_CKISO = 1" */
  359. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) | SRAM_CKISO);
  360. /* TINFO="Set SRAM_ISOINT_B = 0" */
  361. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) & ~SRAM_ISOINT_B);
  362. /* TINFO="Delay 1us" */
  363. udelay(1);
  364. /* TINFO="Set SRAM_PDN = 1" */
  365. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) | ADSP_SRAM_PDN);
  366. #ifndef IGNORE_MTCMOS_CHECK
  367. /* TINFO="Wait until ADSP_SRAM_PDN_ACK = 1" */
  368. while ((spm_read(ADSP_PWR_CON) & ADSP_SRAM_PDN_ACK) != ADSP_SRAM_PDN_ACK) {
  369. /* Need f_f26M_aud_ck for SRAM PDN delay IP. */
  370. }
  371. #endif
  372. /* TINFO="Set PWR_ISO = 1" */
  373. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) | PWR_ISO);
  374. /* TINFO="Set PWR_CLK_DIS = 1" */
  375. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) | PWR_CLK_DIS);
  376. /* TINFO="Set PWR_RST_B = 0" */
  377. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) & ~PWR_RST_B);
  378. /* TINFO="Set PWR_ON = 0" */
  379. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) & ~PWR_ON);
  380. /* TINFO="Set PWR_ON_2ND = 0" */
  381. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) & ~PWR_ON_2ND);
  382. #ifndef IGNORE_MTCMOS_CHECK
  383. /* TINFO="Wait until PWR_STATUS = 0 and PWR_STATUS_2ND = 0" */
  384. while ((spm_read(PWR_STATUS) & ADSP_PWR_STA_MASK)
  385. || (spm_read(PWR_STATUS_2ND) & ADSP_PWR_STA_MASK)) {
  386. /* No logic between pwr_on and pwr_ack. Print SRAM / MTCMOS control and PWR_ACK for debug. */
  387. }
  388. #endif
  389. /* TINFO="Finish to turn off ADSP" */
  390. } else { /* STA_POWER_ON */
  391. /* TINFO="Start to turn on ADSP" */
  392. /* TINFO="Set SRAM_ISOINT_B = 1" */
  393. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) | SRAM_ISOINT_B);
  394. /* TINFO="Set PWR_ON = 1" */
  395. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) | PWR_ON);
  396. /* TINFO="Set PWR_ON_2ND = 1" */
  397. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) | PWR_ON_2ND);
  398. #ifndef IGNORE_MTCMOS_CHECK
  399. /* TINFO="Wait until PWR_STATUS = 1 and PWR_STATUS_2ND = 1" */
  400. while (((spm_read(PWR_STATUS) & ADSP_PWR_STA_MASK) != ADSP_PWR_STA_MASK)
  401. || ((spm_read(PWR_STATUS_2ND) & ADSP_PWR_STA_MASK) != ADSP_PWR_STA_MASK)) {
  402. /* No logic between pwr_on and pwr_ack. Print SRAM / MTCMOS control and PWR_ACK for debug. */
  403. }
  404. #endif
  405. /* TINFO="Set PWR_CLK_DIS = 0" */
  406. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) & ~PWR_CLK_DIS);
  407. /* TINFO="Set PWR_ISO = 0" */
  408. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) & ~PWR_ISO);
  409. /* TINFO="Set PWR_RST_B = 1" */
  410. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) | PWR_RST_B);
  411. /* TINFO="Set SRAM_PDN = 0" */
  412. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) & ~(0x1 << 8));
  413. #ifndef IGNORE_MTCMOS_CHECK
  414. /* TINFO="Wait until ADSP_SRAM_PDN_ACK_BIT0 = 0" */
  415. while (spm_read(ADSP_PWR_CON) & ADSP_SRAM_PDN_ACK_BIT0) {
  416. /* Need f_f26M_aud_ck for SRAM PDN delay IP. */
  417. }
  418. #endif
  419. /* TINFO="Delay 1us" */
  420. udelay(1);
  421. /* TINFO="Set SRAM_CKISO = 0" */
  422. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) & ~SRAM_CKISO);
  423. /* TINFO="Release bus protect - step1 : 0" */
  424. spm_write(INFRA_TOPAXI_PROTECTEN_2_CLR, ADSP_PROT_STEP1_0_MASK);
  425. #ifndef IGNORE_MTCMOS_CHECK
  426. /* Note that this protect ack check after releasing protect has been ignored */
  427. #endif
  428. /* TINFO="Finish to turn on ADSP" */
  429. }
  430. return err;
  431. }
  432. int spm_mtcmos_ctrl_adsp_dormant(int state)
  433. {
  434. int err = 0;
  435. /* TINFO="enable SPM register control" */
  436. spm_write(POWERON_CONFIG_EN, (SPM_PROJECT_CODE << 16) | (0x1 << 0));
  437. if (state == STA_POWER_DOWN) {
  438. /* TINFO="Start to turn off ADSP" */
  439. /* TINFO="Set bus protect - step1 : 0" */
  440. spm_write(INFRA_TOPAXI_PROTECTEN_2_SET, ADSP_PROT_STEP1_0_MASK);
  441. #ifndef IGNORE_MTCMOS_CHECK
  442. while ((spm_read(INFRA_TOPAXI_PROTECTEN_STA1_2) & ADSP_PROT_STEP1_0_ACK_MASK) != ADSP_PROT_STEP1_0_ACK_MASK) {
  443. }
  444. #endif
  445. /* TINFO="Set SRAM_CKISO = 1" */
  446. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) | SRAM_CKISO);
  447. /* TINFO="Set SRAM_ISOINT_B = 0" */
  448. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) & ~SRAM_ISOINT_B);
  449. /* TINFO="Delay 1us" */
  450. udelay(1);
  451. /* TINFO="Set SRAM_SLEEP_B = 0" */
  452. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) & ~ADSP_SRAM_SLEEP_B);
  453. #ifndef IGNORE_MTCMOS_CHECK
  454. /* TINFO="Wait until ADSP_SRAM_SLEEP_B_ACK = 0" */
  455. while (spm_read(ADSP_PWR_CON) & ADSP_SRAM_SLEEP_B_ACK) {
  456. /* n/a */
  457. }
  458. #endif
  459. /* TINFO="Set PWR_ISO = 1" */
  460. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) | PWR_ISO);
  461. /* TINFO="Set PWR_CLK_DIS = 1" */
  462. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) | PWR_CLK_DIS);
  463. /* TINFO="Set PWR_RST_B = 0" */
  464. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) & ~PWR_RST_B);
  465. /* TINFO="Set PWR_ON = 0" */
  466. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) & ~PWR_ON);
  467. /* TINFO="Set PWR_ON_2ND = 0" */
  468. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) & ~PWR_ON_2ND);
  469. #ifndef IGNORE_MTCMOS_CHECK
  470. /* TINFO="Wait until PWR_STATUS = 0 and PWR_STATUS_2ND = 0" */
  471. while ((spm_read(PWR_STATUS) & ADSP_PWR_STA_MASK)
  472. || (spm_read(PWR_STATUS_2ND) & ADSP_PWR_STA_MASK)) {
  473. /* No logic between pwr_on and pwr_ack. Print SRAM / MTCMOS control and PWR_ACK for debug. */
  474. }
  475. #endif
  476. /* TINFO="Finish to turn off ADSP" */
  477. } else { /* STA_POWER_ON */
  478. /* TINFO="Start to turn on ADSP" */
  479. /* TINFO="Set PWR_ON = 1" */
  480. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) | PWR_ON);
  481. /* TINFO="Set PWR_ON_2ND = 1" */
  482. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) | PWR_ON_2ND);
  483. #ifndef IGNORE_MTCMOS_CHECK
  484. /* TINFO="Wait until PWR_STATUS = 1 and PWR_STATUS_2ND = 1" */
  485. while (((spm_read(PWR_STATUS) & ADSP_PWR_STA_MASK) != ADSP_PWR_STA_MASK)
  486. || ((spm_read(PWR_STATUS_2ND) & ADSP_PWR_STA_MASK) != ADSP_PWR_STA_MASK)) {
  487. /* No logic between pwr_on and pwr_ack. Print SRAM / MTCMOS control and PWR_ACK for debug. */
  488. }
  489. #endif
  490. /* TINFO="Set PWR_CLK_DIS = 0" */
  491. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) & ~PWR_CLK_DIS);
  492. /* TINFO="Set PWR_ISO = 0" */
  493. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) & ~PWR_ISO);
  494. /* TINFO="Set PWR_RST_B = 1" */
  495. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) | PWR_RST_B);
  496. /* TINFO="Set SRAM_SLEEP_B = 1" */
  497. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) | ADSP_SRAM_SLEEP_B);
  498. #ifndef IGNORE_MTCMOS_CHECK
  499. /* TINFO="Wait until ADSP_SRAM_SLEEP_B_ACK = 1" */
  500. while ((spm_read(ADSP_PWR_CON) & ADSP_SRAM_SLEEP_B_ACK) != ADSP_SRAM_SLEEP_B_ACK) {
  501. /* n/a */
  502. }
  503. #endif
  504. /* TINFO="Delay 1us" */
  505. udelay(1);
  506. /* TINFO="Set SRAM_ISOINT_B = 1" */
  507. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) | SRAM_ISOINT_B);
  508. /* TINFO="Delay 1us" */
  509. udelay(1);
  510. /* TINFO="Set SRAM_CKISO = 0" */
  511. spm_write(ADSP_PWR_CON, spm_read(ADSP_PWR_CON) & ~SRAM_CKISO);
  512. /* TINFO="Release bus protect - step1 : 0" */
  513. spm_write(INFRA_TOPAXI_PROTECTEN_2_CLR, ADSP_PROT_STEP1_0_MASK);
  514. #ifndef IGNORE_MTCMOS_CHECK
  515. /* Note that this protect ack check after releasing protect has been ignored */
  516. #endif
  517. /* TINFO="Finish to turn on ADSP" */
  518. }
  519. return err;
  520. }
  521. int spm_mtcmos_ctrl_audio(int state)
  522. {
  523. return 0;
  524. }
  525. int spm_mtcmos_ctrl_mfg0(int state)
  526. {
  527. int err = 0;
  528. /* TINFO="enable SPM register control" */
  529. spm_write(POWERON_CONFIG_EN, (SPM_PROJECT_CODE << 16) | (0x1 << 0));
  530. if (state == STA_POWER_DOWN) {
  531. /* TINFO="Start to turn off MFG0" */
  532. /* TINFO="Set SRAM_PDN = 1" */
  533. spm_write(MFG0_PWR_CON, spm_read(MFG0_PWR_CON) | MFG0_SRAM_PDN);
  534. #ifndef IGNORE_MTCMOS_CHECK
  535. /* TINFO="Wait until MFG0_SRAM_PDN_ACK = 1" */
  536. while ((spm_read(MFG0_PWR_CON) & MFG0_SRAM_PDN_ACK) != MFG0_SRAM_PDN_ACK) {
  537. /* Need f_fmfg_core_ck for SRAM PDN delay IP. */
  538. }
  539. #endif
  540. /* TINFO="Set PWR_ISO = 1" */
  541. spm_write(MFG0_PWR_CON, spm_read(MFG0_PWR_CON) | PWR_ISO);
  542. /* TINFO="Set PWR_CLK_DIS = 1" */
  543. spm_write(MFG0_PWR_CON, spm_read(MFG0_PWR_CON) | PWR_CLK_DIS);
  544. /* TINFO="Set PWR_RST_B = 0" */
  545. spm_write(MFG0_PWR_CON, spm_read(MFG0_PWR_CON) & ~PWR_RST_B);
  546. /* TINFO="Set PWR_ON = 0" */
  547. spm_write(MFG0_PWR_CON, spm_read(MFG0_PWR_CON) & ~PWR_ON);
  548. /* TINFO="Set PWR_ON_2ND = 0" */
  549. spm_write(MFG0_PWR_CON, spm_read(MFG0_PWR_CON) & ~PWR_ON_2ND);
  550. #ifndef IGNORE_MTCMOS_CHECK
  551. /* TINFO="Wait until PWR_STATUS = 0 and PWR_STATUS_2ND = 0" */
  552. while ((spm_read(PWR_STATUS) & MFG0_PWR_STA_MASK)
  553. || (spm_read(PWR_STATUS_2ND) & MFG0_PWR_STA_MASK)) {
  554. /* No logic between pwr_on and pwr_ack. Print SRAM / MTCMOS control and PWR_ACK for debug. */
  555. }
  556. #endif
  557. /* TINFO="Finish to turn off MFG0" */
  558. } else { /* STA_POWER_ON */
  559. /* TINFO="Start to turn on MFG0" */
  560. /* TINFO="Set PWR_ON = 1" */
  561. spm_write(MFG0_PWR_CON, spm_read(MFG0_PWR_CON) | PWR_ON);
  562. /* TINFO="Set PWR_ON_2ND = 1" */
  563. spm_write(MFG0_PWR_CON, spm_read(MFG0_PWR_CON) | PWR_ON_2ND);
  564. #ifndef IGNORE_MTCMOS_CHECK
  565. /* TINFO="Wait until PWR_STATUS = 1 and PWR_STATUS_2ND = 1" */
  566. while (((spm_read(PWR_STATUS) & MFG0_PWR_STA_MASK) != MFG0_PWR_STA_MASK)
  567. || ((spm_read(PWR_STATUS_2ND) & MFG0_PWR_STA_MASK) != MFG0_PWR_STA_MASK)) {
  568. /* No logic between pwr_on and pwr_ack. Print SRAM / MTCMOS control and PWR_ACK for debug. */
  569. }
  570. #endif
  571. /* TINFO="Set PWR_CLK_DIS = 0" */
  572. spm_write(MFG0_PWR_CON, spm_read(MFG0_PWR_CON) & ~PWR_CLK_DIS);
  573. /* TINFO="Set PWR_ISO = 0" */
  574. spm_write(MFG0_PWR_CON, spm_read(MFG0_PWR_CON) & ~PWR_ISO);
  575. /* TINFO="Set PWR_RST_B = 1" */
  576. spm_write(MFG0_PWR_CON, spm_read(MFG0_PWR_CON) | PWR_RST_B);
  577. /* TINFO="Set SRAM_PDN = 0" */
  578. spm_write(MFG0_PWR_CON, spm_read(MFG0_PWR_CON) & ~(0x1 << 8));
  579. #ifndef IGNORE_MTCMOS_CHECK
  580. /* TINFO="Wait until MFG0_SRAM_PDN_ACK_BIT0 = 0" */
  581. while (spm_read(MFG0_PWR_CON) & MFG0_SRAM_PDN_ACK_BIT0) {
  582. /* Need f_fmfg_core_ck for SRAM PDN delay IP. */
  583. }
  584. #endif
  585. /* TINFO="Finish to turn on MFG0" */
  586. }
  587. return err;
  588. }
  589. int spm_mtcmos_ctrl_mfg1(int state)
  590. {
  591. int err = 0;
  592. /* TINFO="enable SPM register control" */
  593. spm_write(POWERON_CONFIG_EN, (SPM_PROJECT_CODE << 16) | (0x1 << 0));
  594. if (state == STA_POWER_DOWN) {
  595. /* TINFO="Start to turn off MFG1" */
  596. /* TINFO="Set bus protect - step1 : 0" */
  597. spm_write(INFRA_TOPAXI_PROTECTEN_1_SET, MFG1_PROT_STEP1_0_MASK);
  598. #ifndef IGNORE_MTCMOS_CHECK
  599. while ((spm_read(INFRA_TOPAXI_PROTECTEN_STA1_1) & MFG1_PROT_STEP1_0_ACK_MASK) != MFG1_PROT_STEP1_0_ACK_MASK) {
  600. }
  601. #endif
  602. /* TINFO="Set bus protect - step1 : 1" */
  603. spm_write(INFRA_TOPAXI_PROTECTEN_2_SET, MFG1_PROT_STEP1_1_MASK);
  604. #ifndef IGNORE_MTCMOS_CHECK
  605. while ((spm_read(INFRA_TOPAXI_PROTECTEN_STA1_2) & MFG1_PROT_STEP1_1_ACK_MASK) != MFG1_PROT_STEP1_1_ACK_MASK) {
  606. }
  607. #endif
  608. /* TINFO="Set bus protect - step2 : 0" */
  609. spm_write(INFRA_TOPAXI_PROTECTEN_SET, MFG1_PROT_STEP2_0_MASK);
  610. #ifndef IGNORE_MTCMOS_CHECK
  611. while ((spm_read(INFRA_TOPAXI_PROTECTEN_STA1) & MFG1_PROT_STEP2_0_ACK_MASK) != MFG1_PROT_STEP2_0_ACK_MASK) {
  612. }
  613. #endif
  614. /* TINFO="Set bus protect - step2 : 1" */
  615. spm_write(INFRA_TOPAXI_PROTECTEN_2_SET, MFG1_PROT_STEP2_1_MASK);
  616. #ifndef IGNORE_MTCMOS_CHECK
  617. while ((spm_read(INFRA_TOPAXI_PROTECTEN_STA1_2) & MFG1_PROT_STEP2_1_ACK_MASK) != MFG1_PROT_STEP2_1_ACK_MASK) {
  618. }
  619. #endif
  620. /* TINFO="Set bus protect - step2 : 2" */
  621. spm_write(INFRA_TOPAXI_PROTECTEN_SUB_INFRA_VDNR_SET, MFG1_PROT_STEP2_2_MASK);
  622. #ifndef IGNORE_MTCMOS_CHECK
  623. while ((spm_read(INFRA_TOPAXI_PROTECTEN_SUB_INFRA_VDNR_STA1) & MFG1_PROT_STEP2_2_ACK_MASK) != MFG1_PROT_STEP2_2_ACK_MASK) {
  624. }
  625. #endif
  626. /* TINFO="Set SRAM_PDN = 1" */
  627. spm_write(MFG1_PWR_CON, spm_read(MFG1_PWR_CON) | MFG1_SRAM_PDN);
  628. #ifndef IGNORE_MTCMOS_CHECK
  629. /* TINFO="Wait until MFG1_SRAM_PDN_ACK = 1" */
  630. while ((spm_read(MFG1_PWR_CON) & MFG1_SRAM_PDN_ACK) != MFG1_SRAM_PDN_ACK) {
  631. /* */
  632. }
  633. #endif
  634. /* TINFO="Set PWR_ISO = 1" */
  635. spm_write(MFG1_PWR_CON, spm_read(MFG1_PWR_CON) | PWR_ISO);
  636. /* TINFO="Set PWR_CLK_DIS = 1" */
  637. spm_write(MFG1_PWR_CON, spm_read(MFG1_PWR_CON) | PWR_CLK_DIS);
  638. /* TINFO="Set PWR_RST_B = 0" */
  639. spm_write(MFG1_PWR_CON, spm_read(MFG1_PWR_CON) & ~PWR_RST_B);
  640. /* TINFO="Set PWR_ON = 0" */
  641. spm_write(MFG1_PWR_CON, spm_read(MFG1_PWR_CON) & ~PWR_ON);
  642. /* TINFO="Set PWR_ON_2ND = 0" */
  643. spm_write(MFG1_PWR_CON, spm_read(MFG1_PWR_CON) & ~PWR_ON_2ND);
  644. #ifndef IGNORE_MTCMOS_CHECK
  645. /* TINFO="Wait until PWR_STATUS = 0 and PWR_STATUS_2ND = 0" */
  646. while ((spm_read(PWR_STATUS) & MFG1_PWR_STA_MASK)
  647. || (spm_read(PWR_STATUS_2ND) & MFG1_PWR_STA_MASK)) {
  648. /* No logic between pwr_on and pwr_ack. Print SRAM / MTCMOS control and PWR_ACK for debug. */
  649. }
  650. #endif
  651. /* TINFO="Finish to turn off MFG1" */
  652. } else { /* STA_POWER_ON */
  653. /* TINFO="Start to turn on MFG1" */
  654. /* TINFO="Set PWR_ON = 1" */
  655. spm_write(MFG1_PWR_CON, spm_read(MFG1_PWR_CON) | PWR_ON);
  656. /* TINFO="Set PWR_ON_2ND = 1" */
  657. spm_write(MFG1_PWR_CON, spm_read(MFG1_PWR_CON) | PWR_ON_2ND);
  658. #ifndef IGNORE_MTCMOS_CHECK
  659. /* TINFO="Wait until PWR_STATUS = 1 and PWR_STATUS_2ND = 1" */
  660. while (((spm_read(PWR_STATUS) & MFG1_PWR_STA_MASK) != MFG1_PWR_STA_MASK)
  661. || ((spm_read(PWR_STATUS_2ND) & MFG1_PWR_STA_MASK) != MFG1_PWR_STA_MASK)) {
  662. /* No logic between pwr_on and pwr_ack. Print SRAM / MTCMOS control and PWR_ACK for debug. */
  663. }
  664. #endif
  665. /* TINFO="Set PWR_CLK_DIS = 0" */
  666. spm_write(MFG1_PWR_CON, spm_read(MFG1_PWR_CON) & ~PWR_CLK_DIS);
  667. /* TINFO="Set PWR_ISO = 0" */
  668. spm_write(MFG1_PWR_CON, spm_read(MFG1_PWR_CON) & ~PWR_ISO);
  669. /* TINFO="Set PWR_RST_B = 1" */
  670. spm_write(MFG1_PWR_CON, spm_read(MFG1_PWR_CON) | PWR_RST_B);
  671. /* TINFO="Set SRAM_PDN = 0" */
  672. spm_write(MFG1_PWR_CON, spm_read(MFG1_PWR_CON) & ~(0x1 << 8));
  673. #ifndef IGNORE_MTCMOS_CHECK
  674. /* TINFO="Wait until MFG1_SRAM_PDN_ACK_BIT0 = 0" */
  675. while (spm_read(MFG1_PWR_CON) & MFG1_SRAM_PDN_ACK_BIT0) {
  676. /* */
  677. }
  678. #endif
  679. /* TINFO="Release bus protect - step2 : 0" */
  680. spm_write(INFRA_TOPAXI_PROTECTEN_CLR, MFG1_PROT_STEP2_0_MASK);
  681. #ifndef IGNORE_MTCMOS_CHECK
  682. /* Note that this protect ack check after releasing protect has been ignored */
  683. #endif
  684. /* TINFO="Release bus protect - step2 : 1" */
  685. spm_write(INFRA_TOPAXI_PROTECTEN_2_CLR, MFG1_PROT_STEP2_1_MASK);
  686. #ifndef IGNORE_MTCMOS_CHECK
  687. /* Note that this protect ack check after releasing protect has been ignored */
  688. #endif
  689. /* TINFO="Release bus protect - step2 : 2" */
  690. spm_write(INFRA_TOPAXI_PROTECTEN_SUB_INFRA_VDNR_CLR, MFG1_PROT_STEP2_2_MASK);
  691. #ifndef IGNORE_MTCMOS_CHECK
  692. /* Note that this protect ack check after releasing protect has been ignored */
  693. #endif
  694. /* TINFO="Release bus protect - step1 : 0" */
  695. spm_write(INFRA_TOPAXI_PROTECTEN_1_CLR, MFG1_PROT_STEP1_0_MASK);
  696. #ifndef IGNORE_MTCMOS_CHECK
  697. /* Note that this protect ack check after releasing protect has been ignored */
  698. #endif
  699. /* TINFO="Release bus protect - step1 : 1" */
  700. spm_write(INFRA_TOPAXI_PROTECTEN_2_CLR, MFG1_PROT_STEP1_1_MASK);
  701. #ifndef IGNORE_MTCMOS_CHECK
  702. /* Note that this protect ack check after releasing protect has been ignored */
  703. #endif
  704. /* TINFO="Finish to turn on MFG1" */
  705. }
  706. return err;
  707. }
  708. int spm_mtcmos_ctrl_mfg2(int state)
  709. {
  710. int err = 0;
  711. /* TINFO="enable SPM register control" */
  712. spm_write(POWERON_CONFIG_EN, (SPM_PROJECT_CODE << 16) | (0x1 << 0));
  713. if (state == STA_POWER_DOWN) {
  714. /* TINFO="Start to turn off MFG2" */
  715. /* TINFO="Set SRAM_PDN = 1" */
  716. spm_write(MFG2_PWR_CON, spm_read(MFG2_PWR_CON) | MFG2_SRAM_PDN);
  717. #ifndef IGNORE_MTCMOS_CHECK
  718. /* TINFO="Wait until MFG2_SRAM_PDN_ACK = 1" */
  719. while ((spm_read(MFG2_PWR_CON) & MFG2_SRAM_PDN_ACK) != MFG2_SRAM_PDN_ACK) {
  720. /* */
  721. }
  722. #endif
  723. /* TINFO="Set PWR_ISO = 1" */
  724. spm_write(MFG2_PWR_CON, spm_read(MFG2_PWR_CON) | PWR_ISO);
  725. /* TINFO="Set PWR_CLK_DIS = 1" */
  726. spm_write(MFG2_PWR_CON, spm_read(MFG2_PWR_CON) | PWR_CLK_DIS);
  727. /* TINFO="Set PWR_RST_B = 0" */
  728. spm_write(MFG2_PWR_CON, spm_read(MFG2_PWR_CON) & ~PWR_RST_B);
  729. /* TINFO="Set PWR_ON = 0" */
  730. spm_write(MFG2_PWR_CON, spm_read(MFG2_PWR_CON) & ~PWR_ON);
  731. /* TINFO="Set PWR_ON_2ND = 0" */
  732. spm_write(MFG2_PWR_CON, spm_read(MFG2_PWR_CON) & ~PWR_ON_2ND);
  733. #ifndef IGNORE_MTCMOS_CHECK
  734. /* TINFO="Wait until PWR_STATUS = 0 and PWR_STATUS_2ND = 0" */
  735. while ((spm_read(PWR_STATUS) & MFG2_PWR_STA_MASK)
  736. || (spm_read(PWR_STATUS_2ND) & MFG2_PWR_STA_MASK)) {
  737. /* No logic between pwr_on and pwr_ack. Print SRAM / MTCMOS control and PWR_ACK for debug. */
  738. }
  739. #endif
  740. /* TINFO="Finish to turn off MFG2" */
  741. } else { /* STA_POWER_ON */
  742. /* TINFO="Start to turn on MFG2" */
  743. /* TINFO="Set PWR_ON = 1" */
  744. spm_write(MFG2_PWR_CON, spm_read(MFG2_PWR_CON) | PWR_ON);
  745. /* TINFO="Set PWR_ON_2ND = 1" */
  746. spm_write(MFG2_PWR_CON, spm_read(MFG2_PWR_CON) | PWR_ON_2ND);
  747. #ifndef IGNORE_MTCMOS_CHECK
  748. /* TINFO="Wait until PWR_STATUS = 1 and PWR_STATUS_2ND = 1" */
  749. while (((spm_read(PWR_STATUS) & MFG2_PWR_STA_MASK) != MFG2_PWR_STA_MASK)
  750. || ((spm_read(PWR_STATUS_2ND) & MFG2_PWR_STA_MASK) != MFG2_PWR_STA_MASK)) {
  751. /* No logic between pwr_on and pwr_ack. Print SRAM / MTCMOS control and PWR_ACK for debug. */
  752. }
  753. #endif
  754. /* TINFO="Set PWR_CLK_DIS = 0" */
  755. spm_write(MFG2_PWR_CON, spm_read(MFG2_PWR_CON) & ~PWR_CLK_DIS);
  756. /* TINFO="Set PWR_ISO = 0" */
  757. spm_write(MFG2_PWR_CON, spm_read(MFG2_PWR_CON) & ~PWR_ISO);
  758. /* TINFO="Set PWR_RST_B = 1" */
  759. spm_write(MFG2_PWR_CON, spm_read(MFG2_PWR_CON) | PWR_RST_B);
  760. /* TINFO="Set SRAM_PDN = 0" */
  761. spm_write(MFG2_PWR_CON, spm_read(MFG2_PWR_CON) & ~(0x1 << 8));
  762. #ifndef IGNORE_MTCMOS_CHECK
  763. /* TINFO="Wait until MFG2_SRAM_PDN_ACK_BIT0 = 0" */
  764. while (spm_read(MFG2_PWR_CON) & MFG2_SRAM_PDN_ACK_BIT0) {
  765. /* */
  766. }
  767. #endif
  768. /* TINFO="Finish to turn on MFG2" */
  769. }
  770. return err;
  771. }
  772. int spm_mtcmos_ctrl_mfg3(int state)
  773. {
  774. int err = 0;
  775. /* TINFO="enable SPM register control" */
  776. spm_write(POWERON_CONFIG_EN, (SPM_PROJECT_CODE << 16) | (0x1 << 0));
  777. if (state == STA_POWER_DOWN) {
  778. /* TINFO="Start to turn off MFG3" */
  779. /* TINFO="Set SRAM_PDN = 1" */
  780. spm_write(MFG3_PWR_CON, spm_read(MFG3_PWR_CON) | MFG3_SRAM_PDN);
  781. #ifndef IGNORE_MTCMOS_CHECK
  782. /* TINFO="Wait until MFG3_SRAM_PDN_ACK = 1" */
  783. while ((spm_read(MFG3_PWR_CON) & MFG3_SRAM_PDN_ACK) != MFG3_SRAM_PDN_ACK) {
  784. /* */
  785. }
  786. #endif
  787. /* TINFO="Set PWR_ISO = 1" */
  788. spm_write(MFG3_PWR_CON, spm_read(MFG3_PWR_CON) | PWR_ISO);
  789. /* TINFO="Set PWR_CLK_DIS = 1" */
  790. spm_write(MFG3_PWR_CON, spm_read(MFG3_PWR_CON) | PWR_CLK_DIS);
  791. /* TINFO="Set PWR_RST_B = 0" */
  792. spm_write(MFG3_PWR_CON, spm_read(MFG3_PWR_CON) & ~PWR_RST_B);
  793. /* TINFO="Set PWR_ON = 0" */
  794. spm_write(MFG3_PWR_CON, spm_read(MFG3_PWR_CON) & ~PWR_ON);
  795. /* TINFO="Set PWR_ON_2ND = 0" */
  796. spm_write(MFG3_PWR_CON, spm_read(MFG3_PWR_CON) & ~PWR_ON_2ND);
  797. #ifndef IGNORE_MTCMOS_CHECK
  798. /* TINFO="Wait until PWR_STATUS = 0 and PWR_STATUS_2ND = 0" */
  799. while ((spm_read(PWR_STATUS) & MFG3_PWR_STA_MASK)
  800. || (spm_read(PWR_STATUS_2ND) & MFG3_PWR_STA_MASK)) {
  801. /* No logic between pwr_on and pwr_ack. Print SRAM / MTCMOS control and PWR_ACK for debug. */
  802. }
  803. #endif
  804. /* TINFO="Finish to turn off MFG3" */
  805. } else { /* STA_POWER_ON */
  806. /* TINFO="Start to turn on MFG3" */
  807. /* TINFO="Set PWR_ON = 1" */
  808. spm_write(MFG3_PWR_CON, spm_read(MFG3_PWR_CON) | PWR_ON);
  809. /* TINFO="Set PWR_ON_2ND = 1" */
  810. spm_write(MFG3_PWR_CON, spm_read(MFG3_PWR_CON) | PWR_ON_2ND);
  811. #ifndef IGNORE_MTCMOS_CHECK
  812. /* TINFO="Wait until PWR_STATUS = 1 and PWR_STATUS_2ND = 1" */
  813. while (((spm_read(PWR_STATUS) & MFG3_PWR_STA_MASK) != MFG3_PWR_STA_MASK)
  814. || ((spm_read(PWR_STATUS_2ND) & MFG3_PWR_STA_MASK) != MFG3_PWR_STA_MASK)) {
  815. /* No logic between pwr_on and pwr_ack. Print SRAM / MTCMOS control and PWR_ACK for debug. */
  816. }
  817. #endif
  818. /* TINFO="Set PWR_CLK_DIS = 0" */
  819. spm_write(MFG3_PWR_CON, spm_read(MFG3_PWR_CON) & ~PWR_CLK_DIS);
  820. /* TINFO="Set PWR_ISO = 0" */
  821. spm_write(MFG3_PWR_CON, spm_read(MFG3_PWR_CON) & ~PWR_ISO);
  822. /* TINFO="Set PWR_RST_B = 1" */
  823. spm_write(MFG3_PWR_CON, spm_read(MFG3_PWR_CON) | PWR_RST_B);
  824. /* TINFO="Set SRAM_PDN = 0" */
  825. spm_write(MFG3_PWR_CON, spm_read(MFG3_PWR_CON) & ~(0x1 << 8));
  826. #ifndef IGNORE_MTCMOS_CHECK
  827. /* TINFO="Wait until MFG3_SRAM_PDN_ACK_BIT0 = 0" */
  828. while (spm_read(MFG3_PWR_CON) & MFG3_SRAM_PDN_ACK_BIT0) {
  829. /* */
  830. }
  831. #endif
  832. /* TINFO="Finish to turn on MFG3" */
  833. }
  834. return err;
  835. }
  836. int spm_mtcmos_ctrl_mfg4(int state)
  837. {
  838. int err = 0;
  839. /* TINFO="enable SPM register control" */
  840. spm_write(POWERON_CONFIG_EN, (SPM_PROJECT_CODE << 16) | (0x1 << 0));
  841. if (state == STA_POWER_DOWN) {
  842. /* TINFO="Start to turn off MFG4" */
  843. /* TINFO="Set SRAM_PDN = 1" */
  844. spm_write(MFG4_PWR_CON, spm_read(MFG4_PWR_CON) | MFG4_SRAM_PDN);
  845. #ifndef IGNORE_MTCMOS_CHECK
  846. /* TINFO="Wait until MFG4_SRAM_PDN_ACK = 1" */
  847. while ((spm_read(MFG4_PWR_CON) & MFG4_SRAM_PDN_ACK) != MFG4_SRAM_PDN_ACK) {
  848. /* */
  849. }
  850. #endif
  851. /* TINFO="Set PWR_ISO = 1" */
  852. spm_write(MFG4_PWR_CON, spm_read(MFG4_PWR_CON) | PWR_ISO);
  853. /* TINFO="Set PWR_CLK_DIS = 1" */
  854. spm_write(MFG4_PWR_CON, spm_read(MFG4_PWR_CON) | PWR_CLK_DIS);
  855. /* TINFO="Set PWR_RST_B = 0" */
  856. spm_write(MFG4_PWR_CON, spm_read(MFG4_PWR_CON) & ~PWR_RST_B);
  857. /* TINFO="Set PWR_ON = 0" */
  858. spm_write(MFG4_PWR_CON, spm_read(MFG4_PWR_CON) & ~PWR_ON);
  859. /* TINFO="Set PWR_ON_2ND = 0" */
  860. spm_write(MFG4_PWR_CON, spm_read(MFG4_PWR_CON) & ~PWR_ON_2ND);
  861. #ifndef IGNORE_MTCMOS_CHECK
  862. /* TINFO="Wait until PWR_STATUS = 0 and PWR_STATUS_2ND = 0" */
  863. while ((spm_read(PWR_STATUS) & MFG4_PWR_STA_MASK)
  864. || (spm_read(PWR_STATUS_2ND) & MFG4_PWR_STA_MASK)) {
  865. /* No logic between pwr_on and pwr_ack. Print SRAM / MTCMOS control and PWR_ACK for debug. */
  866. }
  867. #endif
  868. /* TINFO="Finish to turn off MFG4" */
  869. } else { /* STA_POWER_ON */
  870. /* TINFO="Start to turn on MFG4" */
  871. /* TINFO="Set PWR_ON = 1" */
  872. spm_write(MFG4_PWR_CON, spm_read(MFG4_PWR_CON) | PWR_ON);
  873. /* TINFO="Set PWR_ON_2ND = 1" */
  874. spm_write(MFG4_PWR_CON, spm_read(MFG4_PWR_CON) | PWR_ON_2ND);
  875. #ifndef IGNORE_MTCMOS_CHECK
  876. /* TINFO="Wait until PWR_STATUS = 1 and PWR_STATUS_2ND = 1" */
  877. while (((spm_read(PWR_STATUS) & MFG4_PWR_STA_MASK) != MFG4_PWR_STA_MASK)
  878. || ((spm_read(PWR_STATUS_2ND) & MFG4_PWR_STA_MASK) != MFG4_PWR_STA_MASK)) {
  879. /* No logic between pwr_on and pwr_ack. Print SRAM / MTCMOS control and PWR_ACK for debug. */
  880. }
  881. #endif
  882. /* TINFO="Set PWR_CLK_DIS = 0" */
  883. spm_write(MFG4_PWR_CON, spm_read(MFG4_PWR_CON) & ~PWR_CLK_DIS);
  884. /* TINFO="Set PWR_ISO = 0" */
  885. spm_write(MFG4_PWR_CON, spm_read(MFG4_PWR_CON) & ~PWR_ISO);
  886. /* TINFO="Set PWR_RST_B = 1" */
  887. spm_write(MFG4_PWR_CON, spm_read(MFG4_PWR_CON) | PWR_RST_B);
  888. /* TINFO="Set SRAM_PDN = 0" */
  889. spm_write(MFG4_PWR_CON, spm_read(MFG4_PWR_CON) & ~(0x1 << 8));
  890. #ifndef IGNORE_MTCMOS_CHECK
  891. /* TINFO="Wait until MFG4_SRAM_PDN_ACK_BIT0 = 0" */
  892. while (spm_read(MFG4_PWR_CON) & MFG4_SRAM_PDN_ACK_BIT0) {
  893. /* */
  894. }
  895. #endif
  896. /* TINFO="Finish to turn on MFG4" */
  897. }
  898. return err;
  899. }
  900. int spm_mtcmos_ctrl_mfg5(int state)
  901. {
  902. int err = 0;
  903. /* TINFO="enable SPM register control" */
  904. spm_write(POWERON_CONFIG_EN, (SPM_PROJECT_CODE << 16) | (0x1 << 0));
  905. if (state == STA_POWER_DOWN) {
  906. /* TINFO="Start to turn off MFG5" */
  907. /* TINFO="Set SRAM_PDN = 1" */
  908. spm_write(MFG5_PWR_CON, spm_read(MFG5_PWR_CON) | MFG5_SRAM_PDN);
  909. #ifndef IGNORE_MTCMOS_CHECK
  910. /* TINFO="Wait until MFG5_SRAM_PDN_ACK = 1" */
  911. while ((spm_read(MFG5_PWR_CON) & MFG5_SRAM_PDN_ACK) != MFG5_SRAM_PDN_ACK) {
  912. /* */
  913. }
  914. #endif
  915. /* TINFO="Set PWR_ISO = 1" */
  916. spm_write(MFG5_PWR_CON, spm_read(MFG5_PWR_CON) | PWR_ISO);
  917. /* TINFO="Set PWR_CLK_DIS = 1" */
  918. spm_write(MFG5_PWR_CON, spm_read(MFG5_PWR_CON) | PWR_CLK_DIS);
  919. /* TINFO="Set PWR_RST_B = 0" */
  920. spm_write(MFG5_PWR_CON, spm_read(MFG5_PWR_CON) & ~PWR_RST_B);
  921. /* TINFO="Set PWR_ON = 0" */
  922. spm_write(MFG5_PWR_CON, spm_read(MFG5_PWR_CON) & ~PWR_ON);
  923. /* TINFO="Set PWR_ON_2ND = 0" */
  924. spm_write(MFG5_PWR_CON, spm_read(MFG5_PWR_CON) & ~PWR_ON_2ND);
  925. #ifndef IGNORE_MTCMOS_CHECK
  926. /* TINFO="Wait until PWR_STATUS = 0 and PWR_STATUS_2ND = 0" */
  927. while ((spm_read(PWR_STATUS) & MFG5_PWR_STA_MASK)
  928. || (spm_read(PWR_STATUS_2ND) & MFG5_PWR_STA_MASK)) {
  929. /* No logic between pwr_on and pwr_ack. Print SRAM / MTCMOS control and PWR_ACK for debug. */
  930. }
  931. #endif
  932. /* TINFO="Finish to turn off MFG5" */
  933. } else { /* STA_POWER_ON */
  934. /* TINFO="Start to turn on MFG5" */
  935. /* TINFO="Set PWR_ON = 1" */
  936. spm_write(MFG5_PWR_CON, spm_read(MFG5_PWR_CON) | PWR_ON);
  937. /* TINFO="Set PWR_ON_2ND = 1" */
  938. spm_write(MFG5_PWR_CON, spm_read(MFG5_PWR_CON) | PWR_ON_2ND);
  939. #ifndef IGNORE_MTCMOS_CHECK
  940. /* TINFO="Wait until PWR_STATUS = 1 and PWR_STATUS_2ND = 1" */
  941. while (((spm_read(PWR_STATUS) & MFG5_PWR_STA_MASK) != MFG5_PWR_STA_MASK)
  942. || ((spm_read(PWR_STATUS_2ND) & MFG5_PWR_STA_MASK) != MFG5_PWR_STA_MASK)) {
  943. /* No logic between pwr_on and pwr_ack. Print SRAM / MTCMOS control and PWR_ACK for debug. */
  944. }
  945. #endif
  946. /* TINFO="Set PWR_CLK_DIS = 0" */
  947. spm_write(MFG5_PWR_CON, spm_read(MFG5_PWR_CON) & ~PWR_CLK_DIS);
  948. /* TINFO="Set PWR_ISO = 0" */
  949. spm_write(MFG5_PWR_CON, spm_read(MFG5_PWR_CON) & ~PWR_ISO);
  950. /* TINFO="Set PWR_RST_B = 1" */
  951. spm_write(MFG5_PWR_CON, spm_read(MFG5_PWR_CON) | PWR_RST_B);
  952. /* TINFO="Set SRAM_PDN = 0" */
  953. spm_write(MFG5_PWR_CON, spm_read(MFG5_PWR_CON) & ~(0x1 << 8));
  954. #ifndef IGNORE_MTCMOS_CHECK
  955. /* TINFO="Wait until MFG5_SRAM_PDN_ACK_BIT0 = 0" */
  956. while (spm_read(MFG5_PWR_CON) & MFG5_SRAM_PDN_ACK_BIT0) {
  957. /* */
  958. }
  959. #endif
  960. /* TINFO="Finish to turn on MFG5" */
  961. }
  962. return err;
  963. }
  964. int spm_mtcmos_ctrl_mfg6(int state)
  965. {
  966. int err = 0;
  967. /* TINFO="enable SPM register control" */
  968. spm_write(POWERON_CONFIG_EN, (SPM_PROJECT_CODE << 16) | (0x1 << 0));
  969. if (state == STA_POWER_DOWN) {
  970. /* TINFO="Start to turn off MFG6" */
  971. /* TINFO="Set SRAM_PDN = 1" */
  972. spm_write(MFG6_PWR_CON, spm_read(MFG6_PWR_CON) | MFG6_SRAM_PDN);
  973. #ifndef IGNORE_MTCMOS_CHECK
  974. /* TINFO="Wait until MFG6_SRAM_PDN_ACK = 1" */
  975. while ((spm_read(MFG6_PWR_CON) & MFG6_SRAM_PDN_ACK) != MFG6_SRAM_PDN_ACK) {
  976. /* n/a */
  977. }
  978. #endif
  979. /* TINFO="Set PWR_ISO = 1" */
  980. spm_write(MFG6_PWR_CON, spm_read(MFG6_PWR_CON) | PWR_ISO);
  981. /* TINFO="Set PWR_CLK_DIS = 1" */
  982. spm_write(MFG6_PWR_CON, spm_read(MFG6_PWR_CON) | PWR_CLK_DIS);
  983. /* TINFO="Set PWR_RST_B = 0" */
  984. spm_write(MFG6_PWR_CON, spm_read(MFG6_PWR_CON) & ~PWR_RST_B);
  985. /* TINFO="Set PWR_ON = 0" */
  986. spm_write(MFG6_PWR_CON, spm_read(MFG6_PWR_CON) & ~PWR_ON);
  987. /* TINFO="Set PWR_ON_2ND = 0" */
  988. spm_write(MFG6_PWR_CON, spm_read(MFG6_PWR_CON) & ~PWR_ON_2ND);
  989. #ifndef IGNORE_MTCMOS_CHECK
  990. /* TINFO="Wait until PWR_STATUS = 0 and PWR_STATUS_2ND = 0" */
  991. while ((spm_read(PWR_STATUS) & MFG6_PWR_STA_MASK)
  992. || (spm_read(PWR_STATUS_2ND) & MFG6_PWR_STA_MASK)) {
  993. /* No logic between pwr_on and pwr_ack. Print SRAM / MTCMOS control and PWR_ACK for debug. */
  994. }
  995. #endif
  996. /* TINFO="Finish to turn off MFG6" */
  997. } else { /* STA_POWER_ON */
  998. /* TINFO="Start to turn on MFG6" */
  999. /* TINFO="Set PWR_ON = 1" */
  1000. spm_write(MFG6_PWR_CON, spm_read(MFG6_PWR_CON) | PWR_ON);
  1001. /* TINFO="Set PWR_ON_2ND = 1" */
  1002. spm_write(MFG6_PWR_CON, spm_read(MFG6_PWR_CON) | PWR_ON_2ND);
  1003. #ifndef IGNORE_MTCMOS_CHECK
  1004. /* TINFO="Wait until PWR_STATUS = 1 and PWR_STATUS_2ND = 1" */
  1005. while (((spm_read(PWR_STATUS) & MFG6_PWR_STA_MASK) != MFG6_PWR_STA_MASK)
  1006. || ((spm_read(PWR_STATUS_2ND) & MFG6_PWR_STA_MASK) != MFG6_PWR_STA_MASK)) {
  1007. /* No logic between pwr_on and pwr_ack. Print SRAM / MTCMOS control and PWR_ACK for debug. */
  1008. }
  1009. #endif
  1010. /* TINFO="Set PWR_CLK_DIS = 0" */
  1011. spm_write(MFG6_PWR_CON, spm_read(MFG6_PWR_CON) & ~PWR_CLK_DIS);
  1012. /* TINFO="Set PWR_ISO = 0" */
  1013. spm_write(MFG6_PWR_CON, spm_read(MFG6_PWR_CON) & ~PWR_ISO);
  1014. /* TINFO="Set PWR_RST_B = 1" */
  1015. spm_write(MFG6_PWR_CON, spm_read(MFG6_PWR_CON) | PWR_RST_B);
  1016. /* TINFO="Set SRAM_PDN = 0" */
  1017. spm_write(MFG6_PWR_CON, spm_read(MFG6_PWR_CON) & ~(0x1 << 8));
  1018. #ifndef IGNORE_MTCMOS_CHECK
  1019. /* TINFO="Wait until MFG6_SRAM_PDN_ACK_BIT0 = 0" */
  1020. while (spm_read(MFG6_PWR_CON) & MFG6_SRAM_PDN_ACK_BIT0) {
  1021. /* n/a */
  1022. }
  1023. #endif
  1024. /* TINFO="Finish to turn on MFG6" */
  1025. }
  1026. return err;
  1027. }