Advertisement
deadman96385

Untitled

Jan 27th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.60 KB | None | 0 0
  1. /* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. */
  13.  
  14. #include <linux/delay.h>
  15. #include <linux/err.h>
  16. #include <linux/init.h>
  17. #include <linux/kernel.h>
  18. #include <linux/io.h>
  19. #include <linux/of.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/module.h>
  22. #include <linux/reboot.h>
  23. #include <linux/pm.h>
  24. #include <linux/delay.h>
  25. #include <linux/qpnp/power-on.h>
  26. #include <linux/of_address.h>
  27.  
  28. #include <asm/cacheflush.h>
  29. #include <asm/system_misc.h>
  30.  
  31. #include <soc/qcom/scm.h>
  32. #include <soc/qcom/restart.h>
  33. #include <soc/qcom/watchdog.h>
  34.  
  35. #ifdef CONFIG_HUAWEI_RESET_DETECT
  36. #include <linux/huawei_reset_detect.h>
  37. #endif
  38. #ifdef CONFIG_HUAWEI_KERNEL
  39. #include <linux/fcntl.h>
  40. #include <linux/syscalls.h>
  41. #ifdef CONFIG_HUAWEI_FEATURE_NFF
  42. #include <linux/huawei_boot_log.h>
  43. #endif
  44.  
  45. #define MISC_DEVICE "/dev/block/bootdevice/by-name/misc"
  46. #define USB_UPDATE_POLL_TIME 2000
  47. struct bootloader_message {
  48. char command[32];
  49. char status[32];
  50. char recovery[768];
  51. char stage[32];
  52. };
  53. #endif
  54. #define EMERGENCY_DLOAD_MAGIC1 0x322A4F99
  55. #define EMERGENCY_DLOAD_MAGIC2 0xC67E4350
  56. #define EMERGENCY_DLOAD_MAGIC3 0x77777777
  57.  
  58. #define SCM_IO_DISABLE_PMIC_ARBITER 1
  59. #define SCM_IO_DEASSERT_PS_HOLD 2
  60. #define SCM_WDOG_DEBUG_BOOT_PART 0x9
  61. #define SCM_DLOAD_MODE 0X10
  62. #define SCM_EDLOAD_MODE 0X01
  63. #define SCM_DLOAD_CMD 0x10
  64.  
  65. #ifdef CONFIG_FEATURE_HUAWEI_EMERGENCY_DATA
  66. #define MOUNTFAIL_MAGIC_NUM 0x77665527
  67. #endif
  68.  
  69. static int restart_mode;
  70. #ifdef CONFIG_HUAWEI_KERNEL
  71. void *restart_reason = NULL;
  72. #else
  73. void *restart_reason;
  74. #endif
  75. #ifdef CONFIG_HUAWEI_KERNEL
  76. #define RESTART_FLAG_MAGIC_NUM 0x20890206
  77. void *restart_flag_addr = NULL;
  78. #endif
  79. #ifdef CONFIG_HUAWEI_DEBUG_MODE
  80. extern char *saved_command_line;
  81. #endif
  82. static bool scm_pmic_arbiter_disable_supported;
  83. static bool scm_deassert_ps_hold_supported;
  84. /* Download mode master kill-switch */
  85. static void __iomem *msm_ps_hold;
  86. static phys_addr_t tcsr_boot_misc_detect;
  87.  
  88. #ifdef CONFIG_MSM_DLOAD_MODE
  89. #define EDL_MODE_PROP "qcom,msm-imem-emergency_download_mode"
  90. #define DL_MODE_PROP "qcom,msm-imem-download_mode"
  91.  
  92. #ifdef CONFIG_HUAWEI_KERNEL
  93. #define SDUPDATE_FLAG_MAGIC_NUM 0x77665528
  94. #define USBUPDATE_FLAG_MAGIC_NUM 0x77665523
  95. #define SD_UPDATE_RESET_FLAG "sdupdate"
  96. #define USB_UPDATE_RESET_FLAG "usbupdate"
  97. #endif
  98.  
  99. #ifdef CONFIG_HUAWEI_FEATURE_NFF
  100. static uint32_t *reboot_flag_addr;
  101. #endif
  102.  
  103. static int in_panic;
  104. static void *dload_mode_addr;
  105. static bool dload_mode_enabled;
  106. static void *emergency_dload_mode_addr;
  107. static bool scm_dload_supported;
  108.  
  109. static int dload_set(const char *val, struct kernel_param *kp);
  110. #ifdef CONFIG_HUAWEI_KERNEL_DEBUG
  111. static int download_mode = 1;
  112. #else
  113. static int download_mode = 0;
  114. #endif
  115. module_param_call(download_mode, dload_set, param_get_int,
  116. &download_mode, 0644);
  117. static int panic_prep_restart(struct notifier_block *this,
  118. unsigned long event, void *ptr)
  119. {
  120. in_panic = 1;
  121. return NOTIFY_DONE;
  122. }
  123.  
  124. static struct notifier_block panic_blk = {
  125. .notifier_call = panic_prep_restart,
  126. };
  127.  
  128. int scm_set_dload_mode(int arg1, int arg2)
  129. {
  130. struct scm_desc desc = {
  131. .args[0] = arg1,
  132. .args[1] = arg2,
  133. .arginfo = SCM_ARGS(2),
  134. };
  135.  
  136. if (!scm_dload_supported) {
  137. if (tcsr_boot_misc_detect)
  138. return scm_io_write(tcsr_boot_misc_detect, arg1);
  139.  
  140. return 0;
  141. }
  142.  
  143.  
  144. if (!is_scm_armv8())
  145. return scm_call_atomic2(SCM_SVC_BOOT, SCM_DLOAD_CMD, arg1,
  146. arg2);
  147.  
  148. return scm_call2_atomic(SCM_SIP_FNID(SCM_SVC_BOOT, SCM_DLOAD_CMD),
  149. &desc);
  150. }
  151.  
  152. static void set_dload_mode(int on)
  153. {
  154. int ret;
  155.  
  156. if (dload_mode_addr) {
  157. __raw_writel(on ? 0xE47B337D : 0, dload_mode_addr);
  158. __raw_writel(on ? 0xCE14091A : 0,
  159. dload_mode_addr + sizeof(unsigned int));
  160. mb();
  161. }
  162.  
  163. ret = scm_set_dload_mode(on ? SCM_DLOAD_MODE : 0, 0);
  164. if (ret)
  165. pr_err("Failed to set secure DLOAD mode: %d\n", ret);
  166.  
  167. dload_mode_enabled = on;
  168. }
  169.  
  170. #ifdef CONFIG_HUAWEI_KERNEL
  171. void clear_dload_mode(void)
  172. {
  173. set_dload_mode(0);
  174. }
  175. #endif
  176. static bool get_dload_mode(void)
  177. {
  178. return dload_mode_enabled;
  179. }
  180. #ifdef CONFIG_HUAWEI_FEATURE_NFF
  181. static void clear_bootup_flag(void)
  182. {
  183. /*move the ioremap_nocache for reboot_flag_addr into msm_restart_probe()*/
  184. if(NULL != reboot_flag_addr)
  185. {
  186. uint32_t *magic = (uint32_t*)(reboot_flag_addr);
  187.  
  188. /* If by any chance (version upgreade) the addresses are changed,
  189. * We might crash. Lets avoid that difficult to debug scenrio.
  190. * We trading it off with the non-availability of NFF logs*/
  191. if (*magic != HUAWEI_BOOT_MAGIC_NUMBER) {
  192. pr_notice("NFF: Invalid magic number %x. Disabled NFF\n", *magic);
  193. return;
  194. }
  195. __raw_writel( 0x00000000, reboot_flag_addr);
  196. mb();
  197. /*move the iounmap(reboot_flag_addr);*/
  198. }
  199. return;
  200. }
  201. #endif
  202. #ifdef CONFIG_HUAWEI_KERNEL
  203. /*This function write usb_update sign to the misc partion,
  204. if write successfull, then hard restart the device*/
  205. void huawei_restart(void)
  206. {
  207. struct bootloader_message boot;
  208. int fd = 0;
  209.  
  210. memset((void*)&boot, 0x0, sizeof(struct bootloader_message));
  211. strlcpy(boot.command, "boot-recovery", sizeof(boot.command));
  212. strcpy(boot.recovery, "recovery\n");
  213. strcat(boot.recovery, "--");
  214. strcat(boot.recovery, "usb_update");
  215.  
  216. fd = sys_open(MISC_DEVICE,O_RDWR,0);
  217. if( fd < 0 )
  218. {
  219. pr_err("open the devices %s fail",MISC_DEVICE);
  220. return ;
  221. }
  222. if(sys_write((unsigned int )fd, (char*)&boot, sizeof(boot)) < 0)
  223. {
  224. pr_err("write to the devices %s fail",MISC_DEVICE);
  225. return;
  226. }
  227. sys_sync();
  228. kernel_restart(NULL);
  229. }
  230. /*This function poll the address restart_reason,if
  231. there is the magic SDUPDATE_FLAG_MAGIC_NUM, restart
  232. the devices.,the magic is written by modem when the
  233. user click the usb update tool to update*/
  234. int usb_update_thread(void *__unused)
  235. {
  236. unsigned int dload_magic = 0;
  237. for(;;)
  238. {
  239. if(NULL != restart_reason)
  240. {
  241. dload_magic = __raw_readl(restart_reason);
  242. }
  243. else
  244. {
  245. pr_info("restart_reason is null,wait for ready\n");
  246. }
  247. if(SDUPDATE_FLAG_MAGIC_NUM == dload_magic)
  248. {
  249. pr_info("update mode, restart to usb update\n");
  250. huawei_restart();
  251. }
  252. msleep(USB_UPDATE_POLL_TIME);
  253. }
  254. return 0;
  255. }
  256. #endif
  257. static void enable_emergency_dload_mode(void)
  258. {
  259. int ret;
  260.  
  261. if (emergency_dload_mode_addr) {
  262. __raw_writel(EMERGENCY_DLOAD_MAGIC1,
  263. emergency_dload_mode_addr);
  264. __raw_writel(EMERGENCY_DLOAD_MAGIC2,
  265. emergency_dload_mode_addr +
  266. sizeof(unsigned int));
  267. __raw_writel(EMERGENCY_DLOAD_MAGIC3,
  268. emergency_dload_mode_addr +
  269. (2 * sizeof(unsigned int)));
  270.  
  271. /* Need disable the pmic wdt, then the emergency dload mode
  272. * will not auto reset. */
  273. qpnp_pon_wd_config(0);
  274. mb();
  275. }
  276.  
  277. ret = scm_set_dload_mode(SCM_EDLOAD_MODE, 0);
  278. if (ret)
  279. pr_err("Failed to set secure EDLOAD mode: %d\n", ret);
  280. }
  281.  
  282. static int dload_set(const char *val, struct kernel_param *kp)
  283. {
  284. int ret;
  285. int old_val = download_mode;
  286.  
  287. ret = param_set_int(val, kp);
  288.  
  289. if (ret)
  290. return ret;
  291.  
  292. /* If download_mode is not zero or one, ignore. */
  293. if (download_mode >> 1) {
  294. download_mode = old_val;
  295. return -EINVAL;
  296. }
  297.  
  298. set_dload_mode(download_mode);
  299.  
  300. return 0;
  301. }
  302. #else
  303. #define set_dload_mode(x) do {} while (0)
  304.  
  305. static void enable_emergency_dload_mode(void)
  306. {
  307. pr_err("dload mode is not enabled on target\n");
  308. }
  309.  
  310. static bool get_dload_mode(void)
  311. {
  312. return false;
  313. }
  314. #endif
  315.  
  316. void msm_set_restart_mode(int mode)
  317. {
  318. restart_mode = mode;
  319. }
  320. EXPORT_SYMBOL(msm_set_restart_mode);
  321.  
  322. /*
  323. * Force the SPMI PMIC arbiter to shutdown so that no more SPMI transactions
  324. * are sent from the MSM to the PMIC. This is required in order to avoid an
  325. * SPMI lockup on certain PMIC chips if PS_HOLD is lowered in the middle of
  326. * an SPMI transaction.
  327. */
  328. static void halt_spmi_pmic_arbiter(void)
  329. {
  330. struct scm_desc desc = {
  331. .args[0] = 0,
  332. .arginfo = SCM_ARGS(1),
  333. };
  334.  
  335. if (scm_pmic_arbiter_disable_supported) {
  336. pr_crit("Calling SCM to disable SPMI PMIC arbiter\n");
  337. if (!is_scm_armv8())
  338. scm_call_atomic1(SCM_SVC_PWR,
  339. SCM_IO_DISABLE_PMIC_ARBITER, 0);
  340. else
  341. scm_call2_atomic(SCM_SIP_FNID(SCM_SVC_PWR,
  342. SCM_IO_DISABLE_PMIC_ARBITER), &desc);
  343. }
  344. }
  345.  
  346. static void msm_restart_prepare(const char *cmd)
  347. {
  348. bool need_warm_reset = false;
  349.  
  350. #ifdef CONFIG_MSM_DLOAD_MODE
  351.  
  352. /* Write download mode flags if we're panic'ing
  353. * Write download mode flags if restart_mode says so
  354. * Kill download mode if master-kill switch is set
  355. */
  356.  
  357. set_dload_mode(download_mode &&
  358. (in_panic || restart_mode == RESTART_DLOAD));
  359. #endif
  360.  
  361. #ifdef CONFIG_HUAWEI_RESET_DETECT
  362. /* if the restart is triggered by panic, keep the magic number
  363. * if the restart is a nomal reboot, clear the reset magic number
  364. */
  365. if(!in_panic)
  366. {
  367. clear_reset_magic();
  368. }
  369. #endif
  370.  
  371. #ifdef CONFIG_HUAWEI_KERNEL
  372. if(restart_flag_addr)
  373. {
  374. __raw_writel(RESTART_FLAG_MAGIC_NUM, restart_flag_addr);
  375. }
  376. #endif
  377.  
  378. #ifdef CONFIG_HUAWEI_FEATURE_NFF
  379. clear_bootup_flag();
  380. #endif
  381. need_warm_reset = (in_panic || get_dload_mode() ||
  382. (cmd != NULL && cmd[0] != '\0'));
  383.  
  384. if (qpnp_pon_check_hard_reset_stored()) {
  385. /* Set warm reset as true when device is in dload mode
  386. * or device doesn't boot up into recovery, bootloader or rtc.
  387. */
  388. if (get_dload_mode() ||
  389. ((cmd != NULL && cmd[0] != '\0') &&
  390. strcmp(cmd, "recovery") &&
  391. strcmp(cmd, "bootloader") &&
  392. strcmp(cmd, "rtc")))
  393. need_warm_reset = true;
  394. }
  395.  
  396. /* Hard reset the PMIC unless memory contents must be maintained. */
  397. if (need_warm_reset) {
  398. qpnp_pon_system_pwr_off(PON_POWER_OFF_WARM_RESET);
  399. } else {
  400. qpnp_pon_system_pwr_off(PON_POWER_OFF_HARD_RESET);
  401. }
  402.  
  403. if (cmd != NULL) {
  404. if (!strncmp(cmd, "bootloader", 10)) {
  405. qpnp_pon_set_restart_reason(
  406. PON_RESTART_REASON_BOOTLOADER);
  407. __raw_writel(0x77665500, restart_reason);
  408. } else if (!strncmp(cmd, "recovery", 8)) {
  409. qpnp_pon_set_restart_reason(
  410. PON_RESTART_REASON_RECOVERY);
  411. __raw_writel(0x77665502, restart_reason);
  412. } else if (!strcmp(cmd, "rtc")) {
  413. qpnp_pon_set_restart_reason(
  414. PON_RESTART_REASON_RTC);
  415. __raw_writel(0x77665503, restart_reason);
  416. } else if (!strncmp(cmd, "oem-", 4)) {
  417. unsigned long code;
  418. int ret;
  419. ret = kstrtoul(cmd + 4, 16, &code);
  420. if (!ret)
  421. __raw_writel(0x6f656d00 | (code & 0xff),
  422. restart_reason);
  423. } else if (!strncmp(cmd, "edl", 3)) {
  424. enable_emergency_dload_mode();
  425. #ifdef CONFIG_FEATURE_HUAWEI_EMERGENCY_DATA
  426. } else if (!strncmp(cmd, "mountfail", strlen("mountfail"))) {
  427. __raw_writel(MOUNTFAIL_MAGIC_NUM, restart_reason);
  428. #endif
  429. #ifdef CONFIG_HUAWEI_KERNEL
  430. } else if (!strncmp(cmd, "huawei_rtc", 10)) {
  431. __raw_writel(0x77665524, restart_reason);
  432. #endif
  433. #ifdef CONFIG_HUAWEI_KERNEL
  434. } else if (!strncmp(cmd, "huawei_dload", 12)) {
  435. __raw_writel(0x77665529, restart_reason);
  436. //Added adb reboot sdupdate/usbupdate command support
  437. } else if(!strncmp(cmd, SD_UPDATE_RESET_FLAG, strlen(SD_UPDATE_RESET_FLAG))) {
  438. __raw_writel(SDUPDATE_FLAG_MAGIC_NUM, restart_reason);
  439. } else if(!strncmp(cmd, USB_UPDATE_RESET_FLAG, strlen(USB_UPDATE_RESET_FLAG))) {
  440. __raw_writel(USBUPDATE_FLAG_MAGIC_NUM, restart_reason);
  441. #endif
  442. #ifdef CONFIG_HUAWEI_RESET_DETECT
  443. } else if (!strncmp(cmd, "emergency_restart", 17)) {
  444. pr_info("do nothing\n");
  445. #endif
  446. } else {
  447. __raw_writel(0x77665501, restart_reason);
  448. }
  449. }
  450.  
  451. flush_cache_all();
  452.  
  453. /*outer_flush_all is not supported by 64bit kernel*/
  454. #ifndef CONFIG_ARM64
  455. outer_flush_all();
  456. #endif
  457.  
  458. }
  459.  
  460. /*
  461. * Deassert PS_HOLD to signal the PMIC that we are ready to power down or reset.
  462. * Do this by calling into the secure environment, if available, or by directly
  463. * writing to a hardware register.
  464. *
  465. * This function should never return.
  466. */
  467. static void deassert_ps_hold(void)
  468. {
  469. struct scm_desc desc = {
  470. .args[0] = 0,
  471. .arginfo = SCM_ARGS(1),
  472. };
  473.  
  474. if (scm_deassert_ps_hold_supported) {
  475. /* This call will be available on ARMv8 only */
  476. scm_call2_atomic(SCM_SIP_FNID(SCM_SVC_PWR,
  477. SCM_IO_DEASSERT_PS_HOLD), &desc);
  478. }
  479.  
  480. /* Fall-through to the direct write in case the scm_call "returns" */
  481. __raw_writel(0, msm_ps_hold);
  482. }
  483.  
  484. static void do_msm_restart(enum reboot_mode reboot_mode, const char *cmd)
  485. {
  486. int ret;
  487. struct scm_desc desc = {
  488. .args[0] = 1,
  489. .args[1] = 0,
  490. .arginfo = SCM_ARGS(2),
  491. };
  492.  
  493. pr_notice("Going down for restart now\n");
  494.  
  495. msm_restart_prepare(cmd);
  496.  
  497. #ifdef CONFIG_MSM_DLOAD_MODE
  498. /*
  499. * Trigger a watchdog bite here and if this fails,
  500. * device will take the usual restart path.
  501. */
  502.  
  503. if (WDOG_BITE_ON_PANIC && in_panic)
  504. msm_trigger_wdog_bite();
  505. #endif
  506.  
  507. /* Needed to bypass debug image on some chips */
  508. if (!is_scm_armv8())
  509. ret = scm_call_atomic2(SCM_SVC_BOOT,
  510. SCM_WDOG_DEBUG_BOOT_PART, 1, 0);
  511. else
  512. ret = scm_call2_atomic(SCM_SIP_FNID(SCM_SVC_BOOT,
  513. SCM_WDOG_DEBUG_BOOT_PART), &desc);
  514. if (ret)
  515. pr_err("Failed to disable secure wdog debug: %d\n", ret);
  516.  
  517. halt_spmi_pmic_arbiter();
  518. deassert_ps_hold();
  519.  
  520. mdelay(10000);
  521. }
  522.  
  523. static void do_msm_poweroff(void)
  524. {
  525. int ret;
  526. struct scm_desc desc = {
  527. .args[0] = 1,
  528. .args[1] = 0,
  529. .arginfo = SCM_ARGS(2),
  530. };
  531.  
  532. pr_notice("Powering off the SoC\n");
  533. #ifdef CONFIG_MSM_DLOAD_MODE
  534. set_dload_mode(0);
  535. #endif
  536.  
  537. #ifdef CONFIG_HUAWEI_RESET_DETECT
  538. clear_reset_magic();
  539. #endif
  540.  
  541.  
  542. qpnp_pon_system_pwr_off(PON_POWER_OFF_SHUTDOWN);
  543. /* Needed to bypass debug image on some chips */
  544. if (!is_scm_armv8())
  545. ret = scm_call_atomic2(SCM_SVC_BOOT,
  546. SCM_WDOG_DEBUG_BOOT_PART, 1, 0);
  547. else
  548. ret = scm_call2_atomic(SCM_SIP_FNID(SCM_SVC_BOOT,
  549. SCM_WDOG_DEBUG_BOOT_PART), &desc);
  550. if (ret)
  551. pr_err("Failed to disable wdog debug: %d\n", ret);
  552.  
  553. halt_spmi_pmic_arbiter();
  554. deassert_ps_hold();
  555.  
  556. mdelay(10000);
  557. pr_err("Powering off has failed\n");
  558. return;
  559. }
  560.  
  561. static int msm_restart_probe(struct platform_device *pdev)
  562. {
  563. struct device *dev = &pdev->dev;
  564. struct resource *mem;
  565. struct device_node *np;
  566. int ret = 0;
  567.  
  568. #ifdef CONFIG_MSM_DLOAD_MODE
  569. if (scm_is_call_available(SCM_SVC_BOOT, SCM_DLOAD_CMD) > 0)
  570. scm_dload_supported = true;
  571.  
  572. atomic_notifier_chain_register(&panic_notifier_list, &panic_blk);
  573. np = of_find_compatible_node(NULL, NULL, DL_MODE_PROP);
  574. if (!np) {
  575. pr_err("unable to find DT imem DLOAD mode node\n");
  576. } else {
  577. dload_mode_addr = of_iomap(np, 0);
  578. if (!dload_mode_addr)
  579. pr_err("unable to map imem DLOAD offset\n");
  580. }
  581.  
  582. np = of_find_compatible_node(NULL, NULL, EDL_MODE_PROP);
  583. if (!np) {
  584. pr_err("unable to find DT imem EDLOAD mode node\n");
  585. } else {
  586. emergency_dload_mode_addr = of_iomap(np, 0);
  587. if (!emergency_dload_mode_addr)
  588. pr_err("unable to map imem EDLOAD mode offset\n");
  589. }
  590. #ifdef CONFIG_HUAWEI_DEBUG_MODE
  591. if(strstr(saved_command_line,"huawei_debug_mode=1")!=NULL
  592. || strstr(saved_command_line,"emcno=1")!=NULL)
  593. {
  594. download_mode = 1;
  595. }
  596. #endif
  597.  
  598. #endif
  599. np = of_find_compatible_node(NULL, NULL,
  600. "qcom,msm-imem-restart_reason");
  601. if (!np) {
  602. pr_err("unable to find DT imem restart reason node\n");
  603. } else {
  604. restart_reason = of_iomap(np, 0);
  605. if (!restart_reason) {
  606. pr_err("unable to map imem restart reason offset\n");
  607. ret = -ENOMEM;
  608. goto err_restart_reason;
  609. }
  610. }
  611. #ifdef CONFIG_HUAWEI_KERNEL
  612. np = of_find_compatible_node(NULL, NULL,
  613. "qcom,msm-imem-restart_flag_addr");
  614. if (!np) {
  615. pr_err("unable to find DT imem restart flag addr node\n");
  616. } else {
  617. restart_flag_addr = of_iomap(np, 0);
  618. if (!restart_flag_addr) {
  619. pr_err("unable to map imem restart flag addr\n");
  620. }
  621. }
  622. #endif
  623. mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  624. msm_ps_hold = devm_ioremap_resource(dev, mem);
  625. if (IS_ERR(msm_ps_hold))
  626. return PTR_ERR(msm_ps_hold);
  627.  
  628. mem = platform_get_resource(pdev, IORESOURCE_MEM, 1);
  629. if (mem)
  630. tcsr_boot_misc_detect = mem->start;
  631.  
  632. pm_power_off = do_msm_poweroff;
  633. arm_pm_restart = do_msm_restart;
  634.  
  635. if (scm_is_call_available(SCM_SVC_PWR, SCM_IO_DISABLE_PMIC_ARBITER) > 0)
  636. scm_pmic_arbiter_disable_supported = true;
  637.  
  638. if (scm_is_call_available(SCM_SVC_PWR, SCM_IO_DEASSERT_PS_HOLD) > 0)
  639. scm_deassert_ps_hold_supported = true;
  640.  
  641. set_dload_mode(download_mode);
  642.  
  643. #ifdef CONFIG_HUAWEI_FEATURE_NFF
  644. reboot_flag_addr = (uint32_t *)ioremap_nocache(HUAWEI_BOOT_LOG_ADDR,0x100000);
  645. if (!reboot_flag_addr) {
  646. pr_err("ioremap failed for address: %x \n", HUAWEI_BOOT_LOG_ADDR);
  647. }
  648. #endif
  649.  
  650. return 0;
  651.  
  652. err_restart_reason:
  653. #ifdef CONFIG_MSM_DLOAD_MODE
  654. iounmap(emergency_dload_mode_addr);
  655. iounmap(dload_mode_addr);
  656. #endif
  657. return ret;
  658. }
  659.  
  660. static const struct of_device_id of_msm_restart_match[] = {
  661. { .compatible = "qcom,pshold", },
  662. {},
  663. };
  664. MODULE_DEVICE_TABLE(of, of_msm_restart_match);
  665.  
  666. static struct platform_driver msm_restart_driver = {
  667. .probe = msm_restart_probe,
  668. .driver = {
  669. .name = "msm-restart",
  670. .of_match_table = of_match_ptr(of_msm_restart_match),
  671. },
  672. };
  673.  
  674. static int __init msm_restart_init(void)
  675. {
  676. return platform_driver_register(&msm_restart_driver);
  677. }
  678. device_initcall(msm_restart_init);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement