suspend.c 16 KB

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