dummy_ap.c 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845
  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) 2016. 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. //#define CTP_ENV
  32. #ifndef CTP_ENV
  33. /* Note: Pleae enable DUMMY_AP option at rule.mk if hope to use this function */
  34. #include <platform/boot_mode.h>
  35. #include <debug.h>
  36. #include <dev/uart.h>
  37. #include <platform/mtk_key.h>
  38. #include <target/cust_key.h>
  39. #include <platform/mt_gpio.h>
  40. #include <sys/types.h>
  41. #include <debug.h>
  42. #include <err.h>
  43. #include <reg.h>
  44. #include <string.h>
  45. #include <platform/mt_typedefs.h>
  46. #include <platform/mt_reg_base.h>
  47. #include <platform/mt_irq.h>
  48. #include <platform/mt_pmic.h>
  49. #include <platform/timer.h>
  50. #include <sys/types.h>
  51. #include <arch/ops.h>
  52. #include <platform/mt_pmic.h>
  53. #include <platform/upmu_common.h>
  54. #include <platform/upmu_hw.h>
  55. #include <platform/spm.h>
  56. #else
  57. /*CTP environment*/
  58. #include <gpio.h>
  59. #include <barriers.h>
  60. #include <sync_write.h>
  61. #include <upmu_hw.h>
  62. #include <mt_spm_reg.h>
  63. #include <mt_spm_mtcmos.h>
  64. #include <efuse.h>
  65. #define dprintf(CRITICAL, fmt, args...) dbg_print("[MD]: "fmt, ##args)
  66. static void let_md_go(int md_id);
  67. static void config_md_boot_env(int md_id, int boot_mode);
  68. #endif /*CTP_ENV*/
  69. //------- feature option part ---------------------------------------
  70. //#define DEFAULT_META
  71. #define ENABLE_MD_RESET_SPM
  72. //#define ENABLE_MD_RESET_RGU
  73. //#define IGNORE_MD_WDT
  74. //#define IGNORE_MD1_WDT
  75. //#define IGNORE_MD2_WDT
  76. //#define NO_UNGATE_MD
  77. //------- enum and macro part ---------------------------------------
  78. enum {
  79. MD_SYS1 = 0,
  80. MD_SYS2,
  81. MD_SYS3,
  82. MD_SYS4,
  83. };
  84. enum {
  85. AP_ONLY = -1,
  86. MD1_ONLY = 0,
  87. MD2_ONLY,
  88. MD1_MD2,
  89. };
  90. #define ccci_write32(b, a, v) DRV_WriteReg32((b)+(a), (v))
  91. #define ccci_read32(b, a) DRV_Reg32((b)+(a))
  92. #define ccci_write16(b, a, v) DRV_WriteReg16((b)+(a), (v))
  93. #define ccci_read16(b, a) DRV_Reg16((b)+(a))
  94. #define ccci_write8(b, a, v) DRV_WriteReg8((b)+(a), (v))
  95. #define ccci_read8(b, a) DRV_Reg8((b)+(a))
  96. struct sram_cfg {
  97. unsigned int offset;
  98. unsigned int start_bit;
  99. unsigned int end_bit;
  100. };
  101. //------- IRQ ID part ---------------------------------------
  102. #define GIC_PRIVATE_SIGNALS (32)
  103. #define MT_MD_WDT1_IRQ_ID (227+GIC_PRIVATE_SIGNALS)
  104. //------- register part ---------------------------------------
  105. #define MD1_BUS_PROTECT_SET (0x100012A0)
  106. #define MD1_BUS_PROTECT_CLR (0x100012A4)
  107. #define MD1_BUS_PROTECT_STA (0x10001228)
  108. #define MD1_BUS_PROTECT1_SET (0x100012A8)
  109. #define MD1_BUS_PROTECT1_CLR (0x100012AC)
  110. #define MD1_BUS_PROTECT1_STA (0x10001258)
  111. #define PROTECTION_BITMASK ((0x1 << 3)|(0x1 << 4)|(0x1 << 7)) // bit 3,4,7
  112. #define PROTECTION1_BITMASK (0x1 << 6) // bit 6
  113. #define MD1_BOOT_VECTOR_EN (0x20000024)
  114. #define MD1_META_FLAG (0x20000010)
  115. #define TOPRGU_BASE (0x10007000)
  116. #define TOP_RGU_WDT_MODE (0x0)
  117. #define TOP_RGU_WDT_SWRST (0x14)
  118. #define TOP_RGU_WDT_SWSYSRST (0x18)
  119. #define TOP_RGU_WDT_NONRST_REG (0x20)
  120. #define TOP_RGU_LATCH_CONTROL (0x44)
  121. #define MD1_SYS (1 << 7)
  122. #define UNLOCK_KEY (0x88000000)
  123. #define MD_USB_INTERRUPT_MUX 0x10000280
  124. // MD RGU PCore
  125. #define BASE_ADDR_MDRSTCTL 0x200F0000
  126. #define MD_RGU_BASE (BASE_ADDR_MDRSTCTL + 0x100)
  127. #define WDT_MD_MODE (0x0)
  128. #define WDT_MD_MODE_KEY (0x55000030)
  129. #define PLL_TYPE (volatile kal_uint32 *)
  130. // AP view
  131. #define BASE_MADDR_APMIXEDSYS (0x1000C000)
  132. #define BASE_MADDR_MDTOP_PLLMIXED (0x20140000)
  133. #define BASE_MADDR_MDTOP_CLKSW (0x20150000)
  134. #define REG_APMIXEDSYS_AP_PLL_CON0 (PLL_TYPE(BASE_MADDR_APMIXEDSYS+0x0))
  135. #define REG_MDTOP_PLLMIXED_PLL_VERSION (PLL_TYPE(BASE_MADDR_MDTOP_PLLMIXED))
  136. #define REG_MDTOP_PLLMIXED_DCXO_PLL_SETTLE_CTL (PLL_TYPE(BASE_MADDR_MDTOP_PLLMIXED+0x4))
  137. #define REG_MDTOP_PLLMIXED_PLL_ON_CTL (PLL_TYPE(BASE_MADDR_MDTOP_PLLMIXED+0x10))
  138. #define REG_MDTOP_PLLMIXED_PLL_SW_CTL0 (PLL_TYPE(BASE_MADDR_MDTOP_PLLMIXED+0x14))
  139. #define REG_MDTOP_PLLMIXED_MDMCUPLL_CTL0 (PLL_TYPE(BASE_MADDR_MDTOP_PLLMIXED+0x40))
  140. #define REG_MDTOP_PLLMIXED_MDVDSPPLL_CTL0 (PLL_TYPE(BASE_MADDR_MDTOP_PLLMIXED+0x48))
  141. #define REG_MDTOP_PLLMIXED_MDBRPPLL_CTL0 (PLL_TYPE(BASE_MADDR_MDTOP_PLLMIXED+0x50))
  142. #define REG_MDTOP_PLLMIXED_MDTXPLL_CTL0 (PLL_TYPE(BASE_MADDR_MDTOP_PLLMIXED+0x58))
  143. #define REG_MDTOP_PLLMIXED_MDBPIPLL_CTL0 (PLL_TYPE(BASE_MADDR_MDTOP_PLLMIXED+0x60))
  144. #define REG_MDTOP_PLLMIXED_MDBPIPLL_CTL1 (PLL_TYPE(BASE_MADDR_MDTOP_PLLMIXED+0x64))
  145. #define REG_MDTOP_PLLMIXED_MDPLL_CTL0 (PLL_TYPE(BASE_MADDR_MDTOP_PLLMIXED+0x100))
  146. #define REG_MDTOP_PLLMIXED_MDPLL_CTL1 (PLL_TYPE(BASE_MADDR_MDTOP_PLLMIXED+0x104))
  147. #define REG_MDTOP_PLLMIXED_MDPLL_CTL2 (PLL_TYPE(BASE_MADDR_MDTOP_PLLMIXED+0x108))
  148. #define REG_MDTOP_PLLMIXED_PLL_HP_RDY_IRQ (PLL_TYPE(BASE_MADDR_MDTOP_PLLMIXED+0x314))
  149. #define REG_MDTOP_PLLMIXED_PLL_HP_RDY_IRQ_MASK (PLL_TYPE(BASE_MADDR_MDTOP_PLLMIXED+0x318))
  150. #define REG_MDTOP_PLLMIXED_MDMCUPLL_STS (PLL_TYPE(BASE_MADDR_MDTOP_PLLMIXED+0xC00))
  151. #define REG_MDTOP_PLLMIXED_PLL_DUMMY (PLL_TYPE(BASE_MADDR_MDTOP_PLLMIXED+0xF00))
  152. #define REG_MDTOP_CLKSW_CLKON_CTL (PLL_TYPE(BASE_MADDR_MDTOP_CLKSW+0x20))
  153. #define REG_MDTOP_CLKSW_CLKSEL_CTL (PLL_TYPE(BASE_MADDR_MDTOP_CLKSW+0x24))
  154. #define REG_MDTOP_CLKSW_SDF_CK_CTL (PLL_TYPE(BASE_MADDR_MDTOP_CLKSW+0x28))
  155. #define REG_MDTOP_CLKSW_MDSYS_BUS_FLEXCKGEN_STS (PLL_TYPE(BASE_MADDR_MDTOP_CLKSW+0x84))
  156. #define MD_PLL_MAGIC_NUM 0x62930000
  157. #define APMIXED_BASE (BASE_MADDR_APMIXEDSYS)
  158. #define AP_PLL_CON0 (0x0)
  159. #define AP_PLL_CON1 (0x4)
  160. #define MDPLL_CON0 (0x3A0)
  161. #define MDPLL_CON3 (0x3AC)
  162. #define UINT32P (volatile unsigned int *)
  163. #define SLEEP_BASE (0x10006000)
  164. #define POWERON_CONFIG_EN (UINT32P (SLEEP_BASE+0x0))
  165. #define SPM_POWER_ON_VAL1 (UINT32P (SLEEP_BASE+0x8))
  166. #define INFRACFG_AO_BASE (0x10001000)
  167. #define INFRA_TOPAXI_PROTECTEN_1_SET (0x2A8)
  168. #define INFRA_TOPAXI_PROTECTEN_1_CLR (0x2AC)
  169. #define INFRA_MISC2 (0xF0C)
  170. //------- GPIO part ---------------------------------------
  171. #define GPIO_MAGIC (0x80000000)
  172. #if 0 // no need sim setting
  173. // -- SIM1
  174. #define SIM1_SIO_GPIO_ID (GPIO40 | GPIO_MAGIC)
  175. #define SIM1_SRST_GPIO_ID (GPIO39 | GPIO_MAGIC)
  176. #define SIM1_SCLK_GPIO_ID (GPIO38 | GPIO_MAGIC)
  177. //#define SIM1_HOT_PLUG_GPIO_ID (GPIO38 | GPIO_MAGIC)
  178. // -- SIM2
  179. #define SIM2_SIO_GPIO_ID (GPIO35 | GPIO_MAGIC)
  180. #define SIM2_SRST_GPIO_ID (GPIO36 | GPIO_MAGIC)
  181. #define SIM2_SCLK_GPIO_ID (GPIO37 | GPIO_MAGIC)
  182. //#define SIM2_HOT_PLUG_GPIO_ID (GPIO39 | GPIO_MAGIC)
  183. #endif
  184. // -- UART
  185. #define NO_NEED_UART_CONFIG
  186. #ifndef NO_NEED_UART_CONFIG
  187. #define UART1_TX_GPIO_ID (GPIO20 | GPIO_MAGIC)
  188. #define UART1_RX_GPIO_ID (GPIO21 | GPIO_MAGIC)
  189. #define UART2_TX_GPIO_ID (GPIO21 | GPIO_MAGIC)
  190. #define UART2_RX_GPIO_ID (GPIO20 | GPIO_MAGIC)
  191. #define UART3_TX_GPIO_ID (GPIO27 | GPIO_MAGIC)
  192. #define UART3_RX_GPIO_ID (GPIO28 | GPIO_MAGIC)
  193. #define UART4_TX_GPIO_ID (GPIO28 | GPIO_MAGIC)
  194. #define UART4_RX_GPIO_ID (GPIO27 | GPIO_MAGIC)
  195. #endif
  196. //------- code part ---------------------------------------
  197. static unsigned int img_load_flag = 0;
  198. #if 0 // no need sim setting
  199. static void md_gpio_get(GPIO_PIN pin, char *tag);
  200. static void md_gpio_set(GPIO_PIN pin, GPIO_MODE mode, GPIO_DIR dir, GPIO_OUT out, GPIO_PULL_EN pull_en, GPIO_PULL pull, GPIO_SMT smt);
  201. #endif
  202. #ifndef CTP_ENV
  203. extern BOOT_ARGUMENT *g_boot_arg;
  204. extern char *ld_md_errno_to_str(int errno);
  205. static int meta_detection(void)
  206. {
  207. int boot_mode;
  208. #ifdef DEFAULT_META
  209. boot_mode = 1;
  210. return boot_mode;
  211. #endif
  212. boot_mode = 0;
  213. if (g_boot_arg->boot_mode != NORMAL_BOOT)
  214. boot_mode = 1;
  215. dprintf(CRITICAL, "Meta mode: %d, boot_mode: %d\n", boot_mode, g_boot_arg->boot_mode);
  216. return boot_mode;
  217. }
  218. void md_wdt_init(void)
  219. {
  220. if (img_load_flag & (1 << MD_SYS1)) {
  221. mt_irq_set_sens(MT_MD_WDT1_IRQ_ID, MT65xx_EDGE_SENSITIVE);
  222. mt_irq_set_polarity(MT_MD_WDT1_IRQ_ID, MT65xx_POLARITY_LOW);
  223. mt_irq_unmask(MT_MD_WDT1_IRQ_ID);
  224. }
  225. }
  226. #if 0 // no need sim setting
  227. static void md_gpio_config(unsigned int boot_mode_case)
  228. {
  229. switch (boot_mode_case) {
  230. case MD1_ONLY:
  231. #if 1 // same as dws initial setting
  232. //SIM1=> MD1 SIM1IF
  233. mt_set_gpio_mode(SIM1_SCLK_GPIO_ID, GPIO_MODE_01);
  234. mt_set_gpio_mode(SIM1_SRST_GPIO_ID, GPIO_MODE_01);
  235. mt_set_gpio_mode(SIM1_SIO_GPIO_ID, GPIO_MODE_01);
  236. //mt_set_gpio_mode(SIM1_HOT_PLUG_GPIO_ID, GPIO_MODE_01);
  237. //SIM2=> MD1 SIM2IF
  238. mt_set_gpio_mode(SIM2_SCLK_GPIO_ID, GPIO_MODE_01);
  239. mt_set_gpio_mode(SIM2_SRST_GPIO_ID, GPIO_MODE_01);
  240. mt_set_gpio_mode(SIM2_SIO_GPIO_ID, GPIO_MODE_01);
  241. //mt_set_gpio_mode(SIM2_HOT_PLUG_GPIO_ID, GPIO_MODE_01);
  242. #endif
  243. break;
  244. default:
  245. break;
  246. }
  247. md_gpio_get(SIM1_SCLK_GPIO_ID, "sclk");
  248. md_gpio_get(SIM1_SRST_GPIO_ID, "srst");
  249. md_gpio_get(SIM1_SIO_GPIO_ID, "sio");
  250. //md_gpio_get(SIM1_HOT_PLUG_GPIO_ID, "hp");
  251. md_gpio_get(SIM2_SCLK_GPIO_ID, "sclk2");
  252. md_gpio_get(SIM2_SRST_GPIO_ID, "srst2");
  253. md_gpio_get(SIM2_SIO_GPIO_ID, "sio2");
  254. //md_gpio_get(SIM2_HOT_PLUG_GPIO_ID, "hp2");
  255. }
  256. #endif
  257. #endif //#ifndef CTP_ENV
  258. #if 0 // no need sim setting
  259. static void md_gpio_get(GPIO_PIN pin, char *tag)
  260. {
  261. pin |= GPIO_MAGIC;
  262. dprintf(CRITICAL, "GPIO(0x%X)(%s): mode=%d,dir=%d,in=%d,out=%d,pull_en=%d,pull_sel=%d,smt=%d\n",
  263. pin, tag,
  264. mt_get_gpio_mode(pin),
  265. mt_get_gpio_dir(pin),
  266. mt_get_gpio_in(pin),
  267. mt_get_gpio_out(pin),
  268. mt_get_gpio_pull_enable(pin),
  269. mt_get_gpio_pull_select(pin),
  270. mt_get_gpio_smt(pin));
  271. }
  272. static void md_gpio_set(GPIO_PIN pin, GPIO_MODE mode, GPIO_DIR dir, GPIO_OUT out, GPIO_PULL_EN pull_en, GPIO_PULL pull, GPIO_SMT smt)
  273. {
  274. pin |= GPIO_MAGIC;
  275. mt_set_gpio_mode(pin, mode);
  276. if (dir != GPIO_DIR_UNSUPPORTED)
  277. mt_set_gpio_dir(pin, dir);
  278. if (dir == GPIO_DIR_OUT) {
  279. mt_set_gpio_out(pin, out);
  280. }
  281. if (dir == GPIO_DIR_IN) {
  282. mt_set_gpio_smt(pin, smt);
  283. }
  284. if (pull_en != GPIO_PULL_EN_UNSUPPORTED) {
  285. mt_set_gpio_pull_enable(pin, pull_en);
  286. mt_set_gpio_pull_select(pin, pull);
  287. }
  288. md_gpio_get(pin, "-");
  289. }
  290. #endif
  291. void md_uart_config(int type_id, int boot_mode)
  292. {
  293. #ifndef NO_NEED_UART_CONFIG
  294. switch (type_id) {
  295. case AP_ONLY: // for AP only
  296. dprintf(CRITICAL, "md_uart_config:%d, UART1->AP_0, UART2->N/A, UART3->MD1_0, UART4->N/A\n", type_id);
  297. // same as dws initial setting
  298. mt_set_gpio_mode(UART1_TX_GPIO_ID, GPIO_MODE_01);
  299. mt_set_gpio_mode(UART1_RX_GPIO_ID, GPIO_MODE_01);
  300. mt_set_gpio_mode(UART3_TX_GPIO_ID, GPIO_MODE_06);
  301. mt_set_gpio_mode(UART3_RX_GPIO_ID, GPIO_MODE_06);
  302. break;
  303. case MD1_ONLY: // for AP & MD1
  304. case MD2_ONLY: // for AP & C2K
  305. case MD1_MD2: // for both MD1 and C2K
  306. if (boot_mode) {
  307. dprintf(CRITICAL, "md_uart_config:%d, UART3->MD1_0, UART1->AP_0, UART2->NA/A, UART4->N/A\n", type_id);
  308. mt_set_gpio_mode(UART1_TX_GPIO_ID, GPIO_MODE_01);
  309. mt_set_gpio_mode(UART1_RX_GPIO_ID, GPIO_MODE_01);
  310. mt_set_gpio_mode(UART3_TX_GPIO_ID, GPIO_MODE_06);
  311. mt_set_gpio_mode(UART3_RX_GPIO_ID, GPIO_MODE_06);
  312. }
  313. break;
  314. default:
  315. break;
  316. }
  317. #endif
  318. }
  319. void bus_protection_en(int md_id)
  320. {
  321. if (md_id == MD_SYS1) {
  322. /* enable protection for MD1 */
  323. dprintf(CRITICAL, "enable protection for md\n");
  324. DRV_WriteReg32(MD1_BUS_PROTECT_SET, PROTECTION_BITMASK);
  325. DRV_WriteReg32(MD1_BUS_PROTECT1_SET, PROTECTION1_BITMASK);
  326. /* poll protection ready */
  327. dprintf(CRITICAL, "wait protection ....\n");
  328. while ((DRV_Reg32(MD1_BUS_PROTECT_STA)&PROTECTION_BITMASK) != PROTECTION_BITMASK) {
  329. dprintf(CRITICAL, "0x%x\n", DRV_Reg32(MD1_BUS_PROTECT_STA));
  330. }
  331. dprintf(CRITICAL, "wait protection1 ....\n");
  332. while ((DRV_Reg32(MD1_BUS_PROTECT1_STA)&PROTECTION1_BITMASK) != PROTECTION1_BITMASK) {
  333. dprintf(CRITICAL, "0x%x\n", DRV_Reg32(MD1_BUS_PROTECT1_STA));
  334. }
  335. dprintf(CRITICAL, "protection enable done\n");
  336. return;
  337. }
  338. }
  339. void bus_protection_diable(int md_id)
  340. {
  341. if (md_id == MD_SYS1) {
  342. /* enable protection for MD1 */
  343. dprintf(CRITICAL, "disable protection for md\n");
  344. DRV_WriteReg32(MD1_BUS_PROTECT_CLR, PROTECTION_BITMASK);
  345. DRV_WriteReg32(MD1_BUS_PROTECT1_CLR, PROTECTION1_BITMASK);
  346. /* poll protection ready */
  347. dprintf(CRITICAL, "wait protection disable....\n");
  348. while ((DRV_Reg32(MD1_BUS_PROTECT_STA)&PROTECTION_BITMASK) != 0x00000000) {
  349. dprintf(CRITICAL, "0x%x\n", DRV_Reg32(MD1_BUS_PROTECT_STA));
  350. }
  351. dprintf(CRITICAL, "wait protection1 disable....\n");
  352. while ((DRV_Reg32(MD1_BUS_PROTECT1_STA)&PROTECTION1_BITMASK) != 0x00000000) {
  353. dprintf(CRITICAL, "0x%x\n", DRV_Reg32(MD1_BUS_PROTECT1_STA));
  354. }
  355. dprintf(CRITICAL, "protection disable done\n");
  356. return;
  357. }
  358. }
  359. #define INFRA_AO_BASE_LOCAL 0x10001000
  360. #define INFRA_AP2MD_DUMMY_REG 0x370
  361. #define INFRA_AP2MD_DUMMY_BIT 0
  362. #define INFRA_MD2PERI_PROT_EN 0x250
  363. #define INFRA_MD2PERI_PROT_RDY 0x258
  364. #define INFRA_MD2PERI_PROT_BIT 6
  365. #define INFRA_PERI2MD_PROT_EN 0x220
  366. #define INFRA_PERI2MD_PROT_RDY 0x228
  367. #define INFRA_PERI2MD_PROT_BIT 7
  368. static void md1_pre_access_md_reg(void)
  369. {
  370. unsigned int reg_val;
  371. unsigned int infra_ao_base = INFRA_AO_BASE_LOCAL;
  372. /*clear dummy reg flag to access modem reg*/
  373. reg_val = ccci_read32(infra_ao_base, INFRA_AP2MD_DUMMY_REG);
  374. reg_val &= (~(0x1 << INFRA_AP2MD_DUMMY_BIT));
  375. ccci_write32(infra_ao_base, INFRA_AP2MD_DUMMY_REG, reg_val);
  376. dprintf(CRITICAL, "pre: ap2md dummy reg 0x%X: 0x%X\n", INFRA_AO_BASE_LOCAL + INFRA_AP2MD_DUMMY_REG,
  377. ccci_read32(infra_ao_base, INFRA_AP2MD_DUMMY_REG));
  378. /*disable MD to AP*/
  379. reg_val = ccci_read32(infra_ao_base, INFRA_MD2PERI_PROT_EN);
  380. reg_val |= (0x1 << INFRA_MD2PERI_PROT_BIT);
  381. ccci_write32(infra_ao_base, INFRA_MD2PERI_PROT_EN, reg_val);
  382. while ((ccci_read32(infra_ao_base, INFRA_MD2PERI_PROT_RDY) & (0x1 << INFRA_MD2PERI_PROT_BIT))
  383. != (0x1 << INFRA_MD2PERI_PROT_BIT))
  384. ;
  385. dprintf(CRITICAL, "md2peri: en[0x%X], rdy[0x%X]\n",
  386. ccci_read32(infra_ao_base, INFRA_MD2PERI_PROT_EN),
  387. ccci_read32(infra_ao_base, INFRA_MD2PERI_PROT_RDY));
  388. }
  389. static void md1_post_access_md_reg(void)
  390. {
  391. unsigned int reg_val;
  392. unsigned int infra_ao_base = INFRA_AO_BASE_LOCAL;
  393. /*disable AP to MD*/
  394. reg_val = ccci_read32(infra_ao_base, INFRA_PERI2MD_PROT_EN);
  395. reg_val |= (0x1 << INFRA_PERI2MD_PROT_BIT);
  396. ccci_write32(infra_ao_base, INFRA_PERI2MD_PROT_EN, reg_val);
  397. while ((ccci_read32(infra_ao_base, INFRA_PERI2MD_PROT_RDY) & (0x1 << INFRA_PERI2MD_PROT_BIT))
  398. != (0x1 << INFRA_PERI2MD_PROT_BIT))
  399. ;
  400. dprintf(CRITICAL, "peri2md: en[0x%X], rdy[0x%X]\n",
  401. ccci_read32(infra_ao_base, INFRA_PERI2MD_PROT_EN),
  402. ccci_read32(infra_ao_base, INFRA_PERI2MD_PROT_RDY));
  403. /*enable MD to AP*/
  404. reg_val = ccci_read32(infra_ao_base, INFRA_MD2PERI_PROT_EN);
  405. reg_val &= (~(0x1 << INFRA_MD2PERI_PROT_BIT));
  406. ccci_write32(infra_ao_base, INFRA_MD2PERI_PROT_EN, reg_val);
  407. while ((ccci_read32(infra_ao_base, INFRA_MD2PERI_PROT_RDY) & (0x1 << INFRA_MD2PERI_PROT_BIT)))
  408. ;
  409. dprintf(CRITICAL, "md2peri: en[0x%X], rdy[0x%X]\n",
  410. ccci_read32(infra_ao_base, INFRA_MD2PERI_PROT_EN),
  411. ccci_read32(infra_ao_base, INFRA_MD2PERI_PROT_RDY));
  412. /*set dummy reg flag and let md access AP*/
  413. reg_val = ccci_read32(infra_ao_base, INFRA_AP2MD_DUMMY_REG);
  414. reg_val |= (0x1 << INFRA_AP2MD_DUMMY_BIT);
  415. ccci_write32(infra_ao_base, INFRA_AP2MD_DUMMY_REG, reg_val);
  416. dprintf(CRITICAL, "post: ap2md dummy reg 0x%X: 0x%X\n", INFRA_AO_BASE_LOCAL + INFRA_AP2MD_DUMMY_REG,
  417. ccci_read32(infra_ao_base, INFRA_AP2MD_DUMMY_REG));
  418. }
  419. void pmic_init_sequence(void)
  420. {
  421. dprintf(CRITICAL, "pmic_init_sequence skipped!\n");
  422. }
  423. static void md1_pmic_setting(void)
  424. {
  425. #ifndef CTP_ENV
  426. dprintf(CRITICAL, "md1_pmic_setting start!\n");
  427. vmd1_pmic_setting_on();
  428. dprintf(CRITICAL, "md1_pmic_setting done!\n");
  429. #else
  430. // assume set in preloader
  431. dprintf(CRITICAL, "md1_pmic_setting skipped!\n");
  432. #endif
  433. }
  434. int md_common_setting()
  435. {
  436. unsigned int reg_value;
  437. // MD srcclkena setting: [7:4]=4'h0110, [3:0]=4'h1101
  438. reg_value = ccci_read32(INFRACFG_AO_BASE, INFRA_MISC2);
  439. reg_value &= ~(0xFF);
  440. reg_value |= 0x21;
  441. ccci_write32(INFRACFG_AO_BASE, INFRA_MISC2, reg_value);
  442. dprintf(CRITICAL, "MD srcclkena setting:0x%x\n", ccci_read32(INFRACFG_AO_BASE, INFRA_MISC2));
  443. // clear MSDC0 interrupt as it's also connected to MD side
  444. //ccci_write32(0x1124000C, 0, 0xFFFFFFFF);
  445. pmic_init_sequence();
  446. return 0;
  447. }
  448. void md_common_pll_init(void)
  449. {
  450. // initial CLKSQ_LPF
  451. ccci_write32(APMIXED_BASE, AP_PLL_CON0, ccci_read32(APMIXED_BASE, AP_PLL_CON0) | (0x1 << 1));
  452. udelay(100);
  453. }
  454. void md1_pll_init(void)
  455. {
  456. md_common_pll_init();
  457. dprintf(CRITICAL, "Read MD PLL version:0x%x(@0x%x)\n", *REG_MDTOP_PLLMIXED_PLL_VERSION, (unsigned int)REG_MDTOP_PLLMIXED_PLL_VERSION);
  458. // Default md_srclkena_ack settle time = 136T 32K
  459. //*REG_MDTOP_PLLMIXED_DCXO_PLL_SETTLE_CTL = 0x02020E88;
  460. *REG_MDTOP_PLLMIXED_MDBPIPLL_CTL0 = 0x80118000; // fixed 606MHz(/4), 260MHz(/7) /* Fvco = 1820M */
  461. *REG_MDTOP_PLLMIXED_MDTXPLL_CTL0 = 0x800B8A00; // 300MHz /* Fvco = 1200M */
  462. *REG_MDTOP_PLLMIXED_MDBRPPLL_CTL0 = 0x80114E00; // 300MHz /* Fvco = 1800M */
  463. *REG_MDTOP_PLLMIXED_MDVDSPPLL_CTL0 = 0x80114E00; // 450MHz /* Fvco = 1800M */
  464. *REG_MDTOP_PLLMIXED_MDMCUPLL_CTL0 = 0x800B8A00; // 600MHz /* Fvco = 1200M */
  465. /*
  466. * Polling until MDMCUPLL complete frequency adjustment
  467. * Once MDMCUPLL complete, other PLL should complete too
  468. */
  469. while ((*REG_MDTOP_PLLMIXED_MDMCUPLL_STS >> 14) & 0x1) {};
  470. //In L17, MDPLL should be turn-on first manually, since first calabration requires longer time (100us).
  471. /*TINFO="MDSYS_INIT: MDPLL_208M_OUT_EN off"*/
  472. *REG_MDTOP_PLLMIXED_MDPLL_CTL2 &= ~(0x10000);
  473. /*TINFO="MDSYS_INIT: SW Force ON MDPLL"*/
  474. *REG_MDTOP_PLLMIXED_PLL_SW_CTL0 = 0x10000;
  475. *REG_MDTOP_PLLMIXED_PLL_SW_CTL0 = 0x10001;
  476. /*TINFO="MDSYS_INIT: Wait at least 100us"*/
  477. udelay(100);//Wait 100 us
  478. /*TINFO="MDSYS_INIT: SW Force OFF MDPLL"*/
  479. *REG_MDTOP_PLLMIXED_PLL_SW_CTL0 = 0x10000;
  480. *REG_MDTOP_PLLMIXED_PLL_SW_CTL0 = 0x0;
  481. /*TINFO="MDSYS_INIT: MDPLL_208M_OUT_EN on"*/
  482. *REG_MDTOP_PLLMIXED_MDPLL_CTL2 |= 0x10000;
  483. /*TINFO="MDSYS_INIT: Wait 1us"*/
  484. udelay(1);//Wait 1 us
  485. /*TINFO="MDSYS_INIT: Disable AUTOK_EN, MDPLL settle time is 20us NOW (AUTOK_EN can only be setting when MDPLL_EN is OFF, so we add 1us to avoid signals competition)"*/
  486. *REG_MDTOP_PLLMIXED_MDPLL_CTL1 &= ~(0x4000000);
  487. /*TINFO="MDSYS_INIT: Wait 1us"*/
  488. udelay(1);//Wait 1 us
  489. /* Force TXPLL ON due to TOPSM couldn't enable this PLL by default, TXPLL would be disable after DVFS Init.
  490. other PLL ON controlled by HW" */
  491. *REG_MDTOP_PLLMIXED_PLL_ON_CTL = 0x100010;
  492. /*
  493. * Wait MD bus clock ready
  494. * Once MD bus ready, other clock should be ready too
  495. * In FPGA, the following status checking must be removed since there is no flex ck gen in FPGA.
  496. */
  497. while ((*REG_MDTOP_CLKSW_MDSYS_BUS_FLEXCKGEN_STS & 0x8000) != 0x8000) {};
  498. // Switch MDMCU & MD BUS clock to PLL frequency
  499. *REG_MDTOP_CLKSW_CLKSEL_CTL |= 0x3;
  500. // Switch all clock to PLL frequency
  501. *REG_MDTOP_CLKSW_CLKSEL_CTL |= 0x58103FC;
  502. // Switch SDF clock to PLL frequency
  503. *REG_MDTOP_CLKSW_SDF_CK_CTL |= 0x10;
  504. // Turn off all SW clock request, except ATB
  505. *REG_MDTOP_CLKSW_CLKON_CTL = 0x1;
  506. // Clear PLL ADJ RDY IRQ fired by initial period adjustment
  507. *REG_MDTOP_PLLMIXED_PLL_HP_RDY_IRQ = 0xFFFF;
  508. // Mask all PLL ADJ RDY IRQ
  509. *REG_MDTOP_PLLMIXED_PLL_HP_RDY_IRQ_MASK = 0xFFFF;
  510. // Make a record that means MD pll has been initialized.
  511. /* Note: We use "MD_PLL_MAGIC_NUM|0x1" to know PLL init in MD C code.
  512. If AP init PLL, it would be "MD_PLL_MAGIC_NUM". */
  513. *REG_MDTOP_PLLMIXED_PLL_DUMMY = (MD_PLL_MAGIC_NUM);
  514. dprintf(CRITICAL, "md1_pll_init done!\n");
  515. }
  516. #define INFRA_AO_TOP_CLK_GEN 0x10000000
  517. #define MD_CLK_GATING_UNGATE (0)
  518. void md1_boot(int boot_mode)
  519. {
  520. unsigned int reg_value;
  521. //Clear BIT8 and BIT9 to ungate MD1 32K and 26M
  522. reg_value = ccci_read32(INFRA_AO_TOP_CLK_GEN, MD_CLK_GATING_UNGATE);
  523. reg_value &= ~(0x300);
  524. ccci_write32(INFRA_AO_TOP_CLK_GEN, MD_CLK_GATING_UNGATE, reg_value);
  525. // step 1: configure modem related buck
  526. md1_pmic_setting();
  527. dprintf(CRITICAL, "Spare3 0x11f1004c val:0x%x\n", *((volatile unsigned int*)0x11f1004c) );
  528. // step 2: Power on MTCMOS
  529. spm_mtcmos_ctrl_md1(STA_POWER_ON);
  530. dprintf(CRITICAL, "MD1 MTCMOS power on done!\n");
  531. md1_pre_access_md_reg();
  532. // step 5: configure md_srclkena setting
  533. // INFRA_MISC2 already finished in md_common_setting()
  534. // SRCLKEN_O1 force on
  535. spm_write(POWERON_CONFIG_EN, 0x0B160001);
  536. spm_write(SPM_POWER_ON_VAL1, 0x00215830);
  537. dprintf(CRITICAL, "md_srclkena done!\n");
  538. // step 6: configure PLL setting
  539. md1_pll_init();
  540. // step 7: disabel MD WDT
  541. #if !defined(ENABLE_MD_RESET_SPM) && !defined(ENABLE_MD_RESET_RGU)
  542. ccci_write32(MD_RGU_BASE, WDT_MD_MODE, WDT_MD_MODE_KEY); // disable MD WDT & MD AUX_WDT
  543. #endif
  544. // step+: set META Register
  545. if (boot_mode) {
  546. reg_value = DRV_Reg32(MD1_META_FLAG);
  547. DRV_WriteReg32(MD1_META_FLAG, (reg_value | 0x1));
  548. }
  549. }
  550. static void config_md_boot_env(int md_id, int boot_mode)
  551. {
  552. switch (md_id) {
  553. case MD_SYS1:
  554. md1_boot(boot_mode);
  555. break;
  556. default:
  557. break;
  558. }
  559. }
  560. static void let_md_go(int md_id)
  561. {
  562. switch (md_id) {
  563. case MD_SYS1:
  564. /* step 8: trigger modem SW to run */
  565. #ifndef NO_UNGATE_MD
  566. ccci_write32(MD1_BOOT_VECTOR_EN, 0, 1);
  567. md1_post_access_md_reg();
  568. #else
  569. md1_post_access_md_reg();
  570. dprintf(CRITICAL, "do not let MD1 go\n");
  571. #endif
  572. break;
  573. default:
  574. break;
  575. }
  576. }
  577. void md_wdt_irq_handler(unsigned int irq)
  578. {
  579. //spm_mtcmos_ctrl_audio(STA_POWER_DOWN);
  580. //dprintf(CRITICAL, "turn off audio.\n");
  581. #if defined(ENABLE_MD_RESET_SPM) || defined(ENABLE_MD_RESET_RGU)
  582. unsigned int reg_value = 0;
  583. unsigned int cnt = ccci_read32(TOPRGU_BASE, TOP_RGU_WDT_NONRST_REG);
  584. // update counter
  585. ccci_write32(TOPRGU_BASE, TOP_RGU_WDT_NONRST_REG, cnt + 1);
  586. // reset UART config
  587. md_uart_config(AP_ONLY, 0);
  588. dprintf(CRITICAL, "\n\n\n\nCurrent wdt cnt:%d\n", cnt + 1);
  589. if (irq == MT_MD_WDT1_IRQ_ID) {
  590. #ifdef ENABLE_MD_RESET_SPM
  591. dprintf(CRITICAL, "MD1 power off\n");
  592. spm_mtcmos_ctrl_md1(STA_POWER_DOWN);
  593. /* gating md related clock */
  594. reg_value = ccci_read32(INFRA_AO_TOP_CLK_GEN, MD_CLK_GATING_UNGATE);
  595. reg_value |= (0x300);
  596. ccci_write32(INFRA_AO_TOP_CLK_GEN, MD_CLK_GATING_UNGATE, reg_value);
  597. mdelay(5);
  598. config_md_boot_env(MD_SYS1, 0);
  599. #endif
  600. #ifdef ENABLE_MD_RESET_RGU
  601. dprintf(CRITICAL, "MD1 reset\n");
  602. bus_protection_en(0);
  603. ccci_write32(TOPRGU_BASE, TOP_RGU_WDT_SWSYSRST,
  604. (ccci_read32(TOPRGU_BASE, TOP_RGU_WDT_SWSYSRST) | UNLOCK_KEY) | MD1_SYS);
  605. mdelay(5);
  606. ccci_write32(TOPRGU_BASE, TOP_RGU_WDT_SWSYSRST,
  607. (ccci_read32(TOPRGU_BASE, TOP_RGU_WDT_SWSYSRST) | UNLOCK_KEY) & (~MD1_SYS));
  608. bus_protection_diable(0);
  609. #endif
  610. let_md_go(MD_SYS1);
  611. }
  612. #if 1
  613. dprintf(CRITICAL, "Config UART after MD WDT! %d\n", cnt+1);
  614. if ((img_load_flag&((1 << MD_SYS1) | (1 << MD_SYS3))) == ((1 << MD_SYS1) | (1 << MD_SYS3))) {
  615. md_uart_config(MD1_MD2, 0);
  616. } else if (img_load_flag & (1 << MD_SYS1)) {
  617. md_uart_config(MD1_ONLY, 0);
  618. } else if (img_load_flag & (1 << MD_SYS3)) {
  619. md_uart_config(MD2_ONLY, 0);
  620. }
  621. #endif
  622. #else
  623. md_uart_config(AP_ONLY, 0);
  624. dprintf(CRITICAL, "Get MD WDT irq, STA:%x!!\n", ccci_read32(MD_RGU_BASE, 0xC));
  625. #ifdef IGNORE_MD_WDT
  626. dprintf(CRITICAL, "ignore MD WDT\n");
  627. #else
  628. dprintf(CRITICAL, "whole system reboot\n");
  629. ccci_write32(TOPRGU_BASE, TOP_RGU_LATCH_CONTROL, 0x95000000);
  630. ccci_write32(TOPRGU_BASE, TOP_RGU_WDT_MODE, 0x22000004);
  631. ccci_write32(TOPRGU_BASE, TOP_RGU_WDT_SWRST, 0x1209);
  632. while (1);
  633. #endif
  634. #endif
  635. //spm_mtcmos_ctrl_audio(STA_POWER_ON);
  636. //dprintf(CRITICAL, "turn on audio.\n");
  637. }
  638. int dummy_ap_irq_helper(unsigned int irq)
  639. {
  640. switch (irq) {
  641. case MT_MD_WDT1_IRQ_ID:
  642. if (img_load_flag &(1 << MD_SYS1)) {
  643. #ifndef IGNORE_MD1_WDT
  644. md_wdt_irq_handler(MT_MD_WDT1_IRQ_ID);
  645. #else
  646. dprintf(CRITICAL, "ignore MD1 WDT\n");
  647. #endif
  648. }
  649. return 1;
  650. default:
  651. break;
  652. }
  653. return 0;
  654. }
  655. void dummy_ap_boot_up_md(int md_ld_flag)
  656. {
  657. int boot_mode = 0;
  658. int i;
  659. int ret;
  660. img_load_flag = (unsigned int)md_ld_flag;
  661. // reinit UART, overwrite DWS setting
  662. md_uart_config(AP_ONLY, 0);
  663. // Disable AP WDT
  664. *(volatile unsigned int *)(TOPRGU_BASE) = 0x22000000;
  665. dprintf(CRITICAL, "Welcome to use dummy AP!\n");
  666. dprintf(CRITICAL, "load flag for dummy AP: %x\n", img_load_flag);
  667. #ifndef CTP_ENV
  668. if (img_load_flag == 0) {
  669. dprintf(CRITICAL, "no MD loaded for dummy AP\n");
  670. ret = get_md_err_from_lk_info(MD_SYS1);
  671. dprintf(CRITICAL, "hint for MD1 errno: %x, %s\n", ret, ld_md_errno_to_str(-ret));
  672. ret = get_md_err_from_lk_info(MD_SYS3);
  673. dprintf(CRITICAL, "hint for MD3 errno: %x, %s\n", ret, ld_md_errno_to_str(-ret));
  674. dprintf(CRITICAL, "stop.....\n");
  675. while (1);
  676. }
  677. if (img_load_flag & (1 << MD_SYS1)) {
  678. dprintf(CRITICAL, "MD1 loaded");
  679. ret = get_md_err_from_lk_info(MD_SYS1);
  680. if (ret < 0) {
  681. dprintf(CRITICAL, "MD1 load image has error, errno:%s", ld_md_errno_to_str(-ret));
  682. while (1);
  683. }
  684. }
  685. #if 0 // no need sim setting
  686. // 1, Setup special GPIO request (RF/SIM/UART ... etc)
  687. dprintf(CRITICAL, "Configure GPIO!\n");
  688. if ((img_load_flag&((1 << MD_SYS1) | (1 << MD_SYS3))) == ((1 << MD_SYS1) | (1 << MD_SYS3))) {
  689. md_gpio_config(MD1_MD2);
  690. } else if (img_load_flag & (1 << MD_SYS1)) {
  691. md_gpio_config(MD1_ONLY);
  692. } else if (img_load_flag & (1 << MD_SYS3)) {
  693. md_gpio_config(MD2_ONLY);
  694. }
  695. #endif
  696. // 2, Check boot Mode
  697. boot_mode = meta_detection();
  698. dprintf(CRITICAL, "Get boot mode is %d\n", boot_mode);
  699. // 3, MD WDT ISR init
  700. dprintf(CRITICAL, "Init MD WDT\n");
  701. md_wdt_init();
  702. #endif
  703. // 4. Common setting for all MD
  704. md_common_setting();
  705. // 5. Setup per-MD env before boot up MD
  706. for (i=0; i<3; i++) {
  707. if (img_load_flag & (1 << i)) {
  708. dprintf(CRITICAL, "MD%d Enabled\n", i+1);
  709. config_md_boot_env(i, boot_mode);
  710. }
  711. }
  712. // 6. Switch UART
  713. dprintf(CRITICAL, "Switch UART!\n");
  714. if ((img_load_flag&((1 << MD_SYS1) | (1 << MD_SYS3))) == ((1 << MD_SYS1) | (1 << MD_SYS3))) {
  715. md_uart_config(MD1_MD2, boot_mode);
  716. } else if (img_load_flag & (1 << MD_SYS1)) {
  717. md_uart_config(MD1_ONLY, boot_mode);
  718. } else if (img_load_flag & (1 << MD_SYS3)) {
  719. md_uart_config(MD2_ONLY, boot_mode);
  720. }
  721. for (i=0; i<3; i++) {
  722. if (img_load_flag & (1 << i)) {
  723. dprintf(CRITICAL, "Trigger MD%d run\n", i+1);
  724. let_md_go(i);
  725. }
  726. }
  727. //spm_mtcmos_ctrl_audio(STA_POWER_ON);
  728. //dprintf(CRITICAL, "turn on audio.\n");
  729. #ifndef CTP_ENV
  730. dprintf(CRITICAL, "enter while(1), ^O^!!!!!!!!!\n");
  731. while (1);
  732. #endif
  733. }