suspend.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. // SPDX-License-Identifier: GPL-2.0
  2. //
  3. // Copyright (c) 2011-2014 Samsung Electronics Co., Ltd.
  4. // http://www.samsung.com
  5. //
  6. // EXYNOS - Suspend support
  7. //
  8. // Based on arch/arm/mach-s3c2410/pm.c
  9. // Copyright (c) 2006 Simtec Electronics
  10. // Ben Dooks <ben@simtec.co.uk>
  11. #include <linux/init.h>
  12. #include <linux/suspend.h>
  13. #include <linux/syscore_ops.h>
  14. #include <linux/cpu_pm.h>
  15. #include <linux/io.h>
  16. #include <linux/irq.h>
  17. #include <linux/irqchip.h>
  18. #include <linux/irqdomain.h>
  19. #include <linux/of_address.h>
  20. #include <linux/err.h>
  21. #include <linux/regulator/machine.h>
  22. #include <linux/soc/samsung/exynos-pmu.h>
  23. #include <linux/soc/samsung/exynos-regs-pmu.h>
  24. #include <asm/cacheflush.h>
  25. #include <asm/hardware/cache-l2x0.h>
  26. #include <asm/firmware.h>
  27. #include <asm/mcpm.h>
  28. #include <asm/smp_scu.h>
  29. #include <asm/suspend.h>
  30. #include <plat/pm-common.h>
  31. #include "common.h"
  32. #define REG_TABLE_END (-1U)
  33. #define EXYNOS5420_CPU_STATE 0x28
  34. /**
  35. * struct exynos_wkup_irq - PMU IRQ to mask mapping
  36. * @hwirq: Hardware IRQ signal of the PMU
  37. * @mask: Mask in PMU wake-up mask register
  38. */
  39. struct exynos_wkup_irq {
  40. unsigned int hwirq;
  41. u32 mask;
  42. };
  43. struct exynos_pm_data {
  44. const struct exynos_wkup_irq *wkup_irq;
  45. unsigned int wake_disable_mask;
  46. void (*pm_prepare)(void);
  47. void (*pm_resume_prepare)(void);
  48. void (*pm_resume)(void);
  49. int (*pm_suspend)(void);
  50. int (*cpu_suspend)(unsigned long);
  51. };
  52. /* Used only on Exynos542x/5800 */
  53. struct exynos_pm_state {
  54. int cpu_state;
  55. unsigned int pmu_spare3;
  56. void __iomem *sysram_base;
  57. };
  58. static const struct exynos_pm_data *pm_data __ro_after_init;
  59. static struct exynos_pm_state pm_state;
  60. /*
  61. * GIC wake-up support
  62. */
  63. static u32 exynos_irqwake_intmask = 0xffffffff;
  64. static const struct exynos_wkup_irq exynos3250_wkup_irq[] = {
  65. { 73, BIT(1) }, /* RTC alarm */
  66. { 74, BIT(2) }, /* RTC tick */
  67. { /* sentinel */ },
  68. };
  69. static const struct exynos_wkup_irq exynos4_wkup_irq[] = {
  70. { 44, BIT(1) }, /* RTC alarm */
  71. { 45, BIT(2) }, /* RTC tick */
  72. { /* sentinel */ },
  73. };
  74. static const struct exynos_wkup_irq exynos5250_wkup_irq[] = {
  75. { 43, BIT(1) }, /* RTC alarm */
  76. { 44, BIT(2) }, /* RTC tick */
  77. { /* sentinel */ },
  78. };
  79. static int exynos_irq_set_wake(struct irq_data *data, unsigned int state)
  80. {
  81. const struct exynos_wkup_irq *wkup_irq;
  82. if (!pm_data->wkup_irq)
  83. return -ENOENT;
  84. wkup_irq = pm_data->wkup_irq;
  85. while (wkup_irq->mask) {
  86. if (wkup_irq->hwirq == data->hwirq) {
  87. if (!state)
  88. exynos_irqwake_intmask |= wkup_irq->mask;
  89. else
  90. exynos_irqwake_intmask &= ~wkup_irq->mask;
  91. return 0;
  92. }
  93. ++wkup_irq;
  94. }
  95. return -ENOENT;
  96. }
  97. static struct irq_chip exynos_pmu_chip = {
  98. .name = "PMU",
  99. .irq_eoi = irq_chip_eoi_parent,
  100. .irq_mask = irq_chip_mask_parent,
  101. .irq_unmask = irq_chip_unmask_parent,
  102. .irq_retrigger = irq_chip_retrigger_hierarchy,
  103. .irq_set_wake = exynos_irq_set_wake,
  104. #ifdef CONFIG_SMP
  105. .irq_set_affinity = irq_chip_set_affinity_parent,
  106. #endif
  107. };
  108. static int exynos_pmu_domain_translate(struct irq_domain *d,
  109. struct irq_fwspec *fwspec,
  110. unsigned long *hwirq,
  111. unsigned int *type)
  112. {
  113. if (is_of_node(fwspec->fwnode)) {
  114. if (fwspec->param_count != 3)
  115. return -EINVAL;
  116. /* No PPI should point to this domain */
  117. if (fwspec->param[0] != 0)
  118. return -EINVAL;
  119. *hwirq = fwspec->param[1];
  120. *type = fwspec->param[2];
  121. return 0;
  122. }
  123. return -EINVAL;
  124. }
  125. static int exynos_pmu_domain_alloc(struct irq_domain *domain,
  126. unsigned int virq,
  127. unsigned int nr_irqs, void *data)
  128. {
  129. struct irq_fwspec *fwspec = data;
  130. struct irq_fwspec parent_fwspec;
  131. irq_hw_number_t hwirq;
  132. int i;
  133. if (fwspec->param_count != 3)
  134. return -EINVAL; /* Not GIC compliant */
  135. if (fwspec->param[0] != 0)
  136. return -EINVAL; /* No PPI should point to this domain */
  137. hwirq = fwspec->param[1];
  138. for (i = 0; i < nr_irqs; i++)
  139. irq_domain_set_hwirq_and_chip(domain, virq + i, hwirq + i,
  140. &exynos_pmu_chip, NULL);
  141. parent_fwspec = *fwspec;
  142. parent_fwspec.fwnode = domain->parent->fwnode;
  143. return irq_domain_alloc_irqs_parent(domain, virq, nr_irqs,
  144. &parent_fwspec);
  145. }
  146. static const struct irq_domain_ops exynos_pmu_domain_ops = {
  147. .translate = exynos_pmu_domain_translate,
  148. .alloc = exynos_pmu_domain_alloc,
  149. .free = irq_domain_free_irqs_common,
  150. };
  151. static int __init exynos_pmu_irq_init(struct device_node *node,
  152. struct device_node *parent)
  153. {
  154. struct irq_domain *parent_domain, *domain;
  155. if (!parent) {
  156. pr_err("%pOF: no parent, giving up\n", node);
  157. return -ENODEV;
  158. }
  159. parent_domain = irq_find_host(parent);
  160. if (!parent_domain) {
  161. pr_err("%pOF: unable to obtain parent domain\n", node);
  162. return -ENXIO;
  163. }
  164. pmu_base_addr = of_iomap(node, 0);
  165. if (!pmu_base_addr) {
  166. pr_err("%pOF: failed to find exynos pmu register\n", node);
  167. return -ENOMEM;
  168. }
  169. domain = irq_domain_add_hierarchy(parent_domain, 0, 0,
  170. node, &exynos_pmu_domain_ops,
  171. NULL);
  172. if (!domain) {
  173. iounmap(pmu_base_addr);
  174. pmu_base_addr = NULL;
  175. return -ENOMEM;
  176. }
  177. /*
  178. * Clear the OF_POPULATED flag set in of_irq_init so that
  179. * later the Exynos PMU platform device won't be skipped.
  180. */
  181. of_node_clear_flag(node, OF_POPULATED);
  182. return 0;
  183. }
  184. #define EXYNOS_PMU_IRQ(symbol, name) IRQCHIP_DECLARE(symbol, name, exynos_pmu_irq_init)
  185. EXYNOS_PMU_IRQ(exynos3250_pmu_irq, "samsung,exynos3250-pmu");
  186. EXYNOS_PMU_IRQ(exynos4210_pmu_irq, "samsung,exynos4210-pmu");
  187. EXYNOS_PMU_IRQ(exynos4412_pmu_irq, "samsung,exynos4412-pmu");
  188. EXYNOS_PMU_IRQ(exynos5250_pmu_irq, "samsung,exynos5250-pmu");
  189. EXYNOS_PMU_IRQ(exynos5420_pmu_irq, "samsung,exynos5420-pmu");
  190. static int exynos_cpu_do_idle(void)
  191. {
  192. /* issue the standby signal into the pm unit. */
  193. cpu_do_idle();
  194. pr_info("Failed to suspend the system\n");
  195. return 1; /* Aborting suspend */
  196. }
  197. static void exynos_flush_cache_all(void)
  198. {
  199. flush_cache_all();
  200. outer_flush_all();
  201. }
  202. static int exynos_cpu_suspend(unsigned long arg)
  203. {
  204. exynos_flush_cache_all();
  205. return exynos_cpu_do_idle();
  206. }
  207. static int exynos3250_cpu_suspend(unsigned long arg)
  208. {
  209. flush_cache_all();
  210. return exynos_cpu_do_idle();
  211. }
  212. static int exynos5420_cpu_suspend(unsigned long arg)
  213. {
  214. /* MCPM works with HW CPU identifiers */
  215. unsigned int mpidr = read_cpuid_mpidr();
  216. unsigned int cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
  217. unsigned int cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
  218. writel_relaxed(0x0, pm_state.sysram_base + EXYNOS5420_CPU_STATE);
  219. if (IS_ENABLED(CONFIG_EXYNOS5420_MCPM)) {
  220. mcpm_set_entry_vector(cpu, cluster, exynos_cpu_resume);
  221. mcpm_cpu_suspend();
  222. }
  223. pr_info("Failed to suspend the system\n");
  224. /* return value != 0 means failure */
  225. return 1;
  226. }
  227. static void exynos_pm_set_wakeup_mask(void)
  228. {
  229. /* Set wake-up mask registers */
  230. pmu_raw_writel(exynos_get_eint_wake_mask(), EXYNOS_EINT_WAKEUP_MASK);
  231. pmu_raw_writel(exynos_irqwake_intmask & ~(1 << 31), S5P_WAKEUP_MASK);
  232. }
  233. static void exynos_pm_enter_sleep_mode(void)
  234. {
  235. /* Set value of power down register for sleep mode */
  236. exynos_sys_powerdown_conf(SYS_SLEEP);
  237. pmu_raw_writel(EXYNOS_SLEEP_MAGIC, S5P_INFORM1);
  238. }
  239. static void exynos_pm_prepare(void)
  240. {
  241. exynos_set_delayed_reset_assertion(false);
  242. /* Set wake-up mask registers */
  243. exynos_pm_set_wakeup_mask();
  244. exynos_pm_enter_sleep_mode();
  245. /* ensure at least INFORM0 has the resume address */
  246. pmu_raw_writel(__pa_symbol(exynos_cpu_resume), S5P_INFORM0);
  247. }
  248. static void exynos3250_pm_prepare(void)
  249. {
  250. unsigned int tmp;
  251. /* Set wake-up mask registers */
  252. exynos_pm_set_wakeup_mask();
  253. tmp = pmu_raw_readl(EXYNOS3_ARM_L2_OPTION);
  254. tmp &= ~EXYNOS5_OPTION_USE_RETENTION;
  255. pmu_raw_writel(tmp, EXYNOS3_ARM_L2_OPTION);
  256. exynos_pm_enter_sleep_mode();
  257. /* ensure at least INFORM0 has the resume address */
  258. pmu_raw_writel(__pa_symbol(exynos_cpu_resume), S5P_INFORM0);
  259. }
  260. static void exynos5420_pm_prepare(void)
  261. {
  262. unsigned int tmp;
  263. /* Set wake-up mask registers */
  264. exynos_pm_set_wakeup_mask();
  265. pm_state.pmu_spare3 = pmu_raw_readl(S5P_PMU_SPARE3);
  266. /*
  267. * The cpu state needs to be saved and restored so that the
  268. * secondary CPUs will enter low power start. Though the U-Boot
  269. * is setting the cpu state with low power flag, the kernel
  270. * needs to restore it back in case, the primary cpu fails to
  271. * suspend for any reason.
  272. */
  273. pm_state.cpu_state = readl_relaxed(pm_state.sysram_base +
  274. EXYNOS5420_CPU_STATE);
  275. exynos_pm_enter_sleep_mode();
  276. /* ensure at least INFORM0 has the resume address */
  277. if (IS_ENABLED(CONFIG_EXYNOS5420_MCPM))
  278. pmu_raw_writel(__pa_symbol(mcpm_entry_point), S5P_INFORM0);
  279. tmp = pmu_raw_readl(EXYNOS_L2_OPTION(0));
  280. tmp &= ~EXYNOS_L2_USE_RETENTION;
  281. pmu_raw_writel(tmp, EXYNOS_L2_OPTION(0));
  282. tmp = pmu_raw_readl(EXYNOS5420_SFR_AXI_CGDIS1);
  283. tmp |= EXYNOS5420_UFS;
  284. pmu_raw_writel(tmp, EXYNOS5420_SFR_AXI_CGDIS1);
  285. tmp = pmu_raw_readl(EXYNOS5420_ARM_COMMON_OPTION);
  286. tmp &= ~EXYNOS5420_L2RSTDISABLE_VALUE;
  287. pmu_raw_writel(tmp, EXYNOS5420_ARM_COMMON_OPTION);
  288. tmp = pmu_raw_readl(EXYNOS5420_FSYS2_OPTION);
  289. tmp |= EXYNOS5420_EMULATION;
  290. pmu_raw_writel(tmp, EXYNOS5420_FSYS2_OPTION);
  291. tmp = pmu_raw_readl(EXYNOS5420_PSGEN_OPTION);
  292. tmp |= EXYNOS5420_EMULATION;
  293. pmu_raw_writel(tmp, EXYNOS5420_PSGEN_OPTION);
  294. }
  295. static int exynos_pm_suspend(void)
  296. {
  297. exynos_pm_central_suspend();
  298. /* Setting SEQ_OPTION register */
  299. pmu_raw_writel(S5P_USE_STANDBY_WFI0 | S5P_USE_STANDBY_WFE0,
  300. S5P_CENTRAL_SEQ_OPTION);
  301. if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9)
  302. exynos_cpu_save_register();
  303. return 0;
  304. }
  305. static int exynos5420_pm_suspend(void)
  306. {
  307. u32 this_cluster;
  308. exynos_pm_central_suspend();
  309. /* Setting SEQ_OPTION register */
  310. this_cluster = MPIDR_AFFINITY_LEVEL(read_cpuid_mpidr(), 1);
  311. if (!this_cluster)
  312. pmu_raw_writel(EXYNOS5420_ARM_USE_STANDBY_WFI0,
  313. S5P_CENTRAL_SEQ_OPTION);
  314. else
  315. pmu_raw_writel(EXYNOS5420_KFC_USE_STANDBY_WFI0,
  316. S5P_CENTRAL_SEQ_OPTION);
  317. return 0;
  318. }
  319. static void exynos_pm_resume(void)
  320. {
  321. u32 cpuid = read_cpuid_part();
  322. if (exynos_pm_central_resume())
  323. goto early_wakeup;
  324. if (cpuid == ARM_CPU_PART_CORTEX_A9)
  325. exynos_scu_enable();
  326. if (call_firmware_op(resume) == -ENOSYS
  327. && cpuid == ARM_CPU_PART_CORTEX_A9)
  328. exynos_cpu_restore_register();
  329. early_wakeup:
  330. /* Clear SLEEP mode set in INFORM1 */
  331. pmu_raw_writel(0x0, S5P_INFORM1);
  332. exynos_set_delayed_reset_assertion(true);
  333. }
  334. static void exynos3250_pm_resume(void)
  335. {
  336. u32 cpuid = read_cpuid_part();
  337. if (exynos_pm_central_resume())
  338. goto early_wakeup;
  339. pmu_raw_writel(S5P_USE_STANDBY_WFI_ALL, S5P_CENTRAL_SEQ_OPTION);
  340. if (call_firmware_op(resume) == -ENOSYS
  341. && cpuid == ARM_CPU_PART_CORTEX_A9)
  342. exynos_cpu_restore_register();
  343. early_wakeup:
  344. /* Clear SLEEP mode set in INFORM1 */
  345. pmu_raw_writel(0x0, S5P_INFORM1);
  346. }
  347. static void exynos5420_prepare_pm_resume(void)
  348. {
  349. if (IS_ENABLED(CONFIG_EXYNOS5420_MCPM))
  350. WARN_ON(mcpm_cpu_powered_up());
  351. }
  352. static void exynos5420_pm_resume(void)
  353. {
  354. unsigned long tmp;
  355. /* Restore the CPU0 low power state register */
  356. tmp = pmu_raw_readl(EXYNOS5_ARM_CORE0_SYS_PWR_REG);
  357. pmu_raw_writel(tmp | S5P_CORE_LOCAL_PWR_EN,
  358. EXYNOS5_ARM_CORE0_SYS_PWR_REG);
  359. /* Restore the sysram cpu state register */
  360. writel_relaxed(pm_state.cpu_state,
  361. pm_state.sysram_base + EXYNOS5420_CPU_STATE);
  362. pmu_raw_writel(EXYNOS5420_USE_STANDBY_WFI_ALL,
  363. S5P_CENTRAL_SEQ_OPTION);
  364. if (exynos_pm_central_resume())
  365. goto early_wakeup;
  366. pmu_raw_writel(pm_state.pmu_spare3, S5P_PMU_SPARE3);
  367. early_wakeup:
  368. tmp = pmu_raw_readl(EXYNOS5420_SFR_AXI_CGDIS1);
  369. tmp &= ~EXYNOS5420_UFS;
  370. pmu_raw_writel(tmp, EXYNOS5420_SFR_AXI_CGDIS1);
  371. tmp = pmu_raw_readl(EXYNOS5420_FSYS2_OPTION);
  372. tmp &= ~EXYNOS5420_EMULATION;
  373. pmu_raw_writel(tmp, EXYNOS5420_FSYS2_OPTION);
  374. tmp = pmu_raw_readl(EXYNOS5420_PSGEN_OPTION);
  375. tmp &= ~EXYNOS5420_EMULATION;
  376. pmu_raw_writel(tmp, EXYNOS5420_PSGEN_OPTION);
  377. /* Clear SLEEP mode set in INFORM1 */
  378. pmu_raw_writel(0x0, S5P_INFORM1);
  379. }
  380. /*
  381. * Suspend Ops
  382. */
  383. static int exynos_suspend_enter(suspend_state_t state)
  384. {
  385. int ret;
  386. s3c_pm_debug_init();
  387. S3C_PMDBG("%s: suspending the system...\n", __func__);
  388. S3C_PMDBG("%s: wakeup masks: %08x,%08x\n", __func__,
  389. exynos_irqwake_intmask, exynos_get_eint_wake_mask());
  390. if (exynos_irqwake_intmask == -1U
  391. && exynos_get_eint_wake_mask() == -1U) {
  392. pr_err("%s: No wake-up sources!\n", __func__);
  393. pr_err("%s: Aborting sleep\n", __func__);
  394. return -EINVAL;
  395. }
  396. s3c_pm_save_uarts();
  397. if (pm_data->pm_prepare)
  398. pm_data->pm_prepare();
  399. flush_cache_all();
  400. s3c_pm_check_store();
  401. ret = call_firmware_op(suspend);
  402. if (ret == -ENOSYS)
  403. ret = cpu_suspend(0, pm_data->cpu_suspend);
  404. if (ret)
  405. return ret;
  406. if (pm_data->pm_resume_prepare)
  407. pm_data->pm_resume_prepare();
  408. s3c_pm_restore_uarts();
  409. S3C_PMDBG("%s: wakeup stat: %08x\n", __func__,
  410. pmu_raw_readl(S5P_WAKEUP_STAT));
  411. s3c_pm_check_restore();
  412. S3C_PMDBG("%s: resuming the system...\n", __func__);
  413. return 0;
  414. }
  415. static int exynos_suspend_prepare(void)
  416. {
  417. int ret;
  418. /*
  419. * REVISIT: It would be better if struct platform_suspend_ops
  420. * .prepare handler get the suspend_state_t as a parameter to
  421. * avoid hard-coding the suspend to mem state. It's safe to do
  422. * it now only because the suspend_valid_only_mem function is
  423. * used as the .valid callback used to check if a given state
  424. * is supported by the platform anyways.
  425. */
  426. ret = regulator_suspend_prepare(PM_SUSPEND_MEM);
  427. if (ret) {
  428. pr_err("Failed to prepare regulators for suspend (%d)\n", ret);
  429. return ret;
  430. }
  431. s3c_pm_check_prepare();
  432. return 0;
  433. }
  434. static void exynos_suspend_finish(void)
  435. {
  436. int ret;
  437. s3c_pm_check_cleanup();
  438. ret = regulator_suspend_finish();
  439. if (ret)
  440. pr_warn("Failed to resume regulators from suspend (%d)\n", ret);
  441. }
  442. static const struct platform_suspend_ops exynos_suspend_ops = {
  443. .enter = exynos_suspend_enter,
  444. .prepare = exynos_suspend_prepare,
  445. .finish = exynos_suspend_finish,
  446. .valid = suspend_valid_only_mem,
  447. };
  448. static const struct exynos_pm_data exynos3250_pm_data = {
  449. .wkup_irq = exynos3250_wkup_irq,
  450. .wake_disable_mask = ((0xFF << 8) | (0x1F << 1)),
  451. .pm_suspend = exynos_pm_suspend,
  452. .pm_resume = exynos3250_pm_resume,
  453. .pm_prepare = exynos3250_pm_prepare,
  454. .cpu_suspend = exynos3250_cpu_suspend,
  455. };
  456. static const struct exynos_pm_data exynos4_pm_data = {
  457. .wkup_irq = exynos4_wkup_irq,
  458. .wake_disable_mask = ((0xFF << 8) | (0x1F << 1)),
  459. .pm_suspend = exynos_pm_suspend,
  460. .pm_resume = exynos_pm_resume,
  461. .pm_prepare = exynos_pm_prepare,
  462. .cpu_suspend = exynos_cpu_suspend,
  463. };
  464. static const struct exynos_pm_data exynos5250_pm_data = {
  465. .wkup_irq = exynos5250_wkup_irq,
  466. .wake_disable_mask = ((0xFF << 8) | (0x1F << 1)),
  467. .pm_suspend = exynos_pm_suspend,
  468. .pm_resume = exynos_pm_resume,
  469. .pm_prepare = exynos_pm_prepare,
  470. .cpu_suspend = exynos_cpu_suspend,
  471. };
  472. static const struct exynos_pm_data exynos5420_pm_data = {
  473. .wkup_irq = exynos5250_wkup_irq,
  474. .wake_disable_mask = (0x7F << 7) | (0x1F << 1),
  475. .pm_resume_prepare = exynos5420_prepare_pm_resume,
  476. .pm_resume = exynos5420_pm_resume,
  477. .pm_suspend = exynos5420_pm_suspend,
  478. .pm_prepare = exynos5420_pm_prepare,
  479. .cpu_suspend = exynos5420_cpu_suspend,
  480. };
  481. static const struct of_device_id exynos_pmu_of_device_ids[] __initconst = {
  482. {
  483. .compatible = "samsung,exynos3250-pmu",
  484. .data = &exynos3250_pm_data,
  485. }, {
  486. .compatible = "samsung,exynos4210-pmu",
  487. .data = &exynos4_pm_data,
  488. }, {
  489. .compatible = "samsung,exynos4412-pmu",
  490. .data = &exynos4_pm_data,
  491. }, {
  492. .compatible = "samsung,exynos5250-pmu",
  493. .data = &exynos5250_pm_data,
  494. }, {
  495. .compatible = "samsung,exynos5420-pmu",
  496. .data = &exynos5420_pm_data,
  497. },
  498. { /*sentinel*/ },
  499. };
  500. static struct syscore_ops exynos_pm_syscore_ops;
  501. void __init exynos_pm_init(void)
  502. {
  503. const struct of_device_id *match;
  504. struct device_node *np;
  505. u32 tmp;
  506. np = of_find_matching_node_and_match(NULL, exynos_pmu_of_device_ids, &match);
  507. if (!np) {
  508. pr_err("Failed to find PMU node\n");
  509. return;
  510. }
  511. if (WARN_ON(!of_find_property(np, "interrupt-controller", NULL))) {
  512. pr_warn("Outdated DT detected, suspend/resume will NOT work\n");
  513. return;
  514. }
  515. pm_data = (const struct exynos_pm_data *) match->data;
  516. /* All wakeup disable */
  517. tmp = pmu_raw_readl(S5P_WAKEUP_MASK);
  518. tmp |= pm_data->wake_disable_mask;
  519. pmu_raw_writel(tmp, S5P_WAKEUP_MASK);
  520. exynos_pm_syscore_ops.suspend = pm_data->pm_suspend;
  521. exynos_pm_syscore_ops.resume = pm_data->pm_resume;
  522. register_syscore_ops(&exynos_pm_syscore_ops);
  523. suspend_set_ops(&exynos_suspend_ops);
  524. /*
  525. * Applicable as of now only to Exynos542x. If booted under secure
  526. * firmware, the non-secure region of sysram should be used.
  527. */
  528. if (exynos_secure_firmware_available())
  529. pm_state.sysram_base = sysram_ns_base_addr;
  530. else
  531. pm_state.sysram_base = sysram_base_addr;
  532. }