suspend.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  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. pmu_base_addr = NULL;
  170. return -ENOMEM;
  171. }
  172. /*
  173. * Clear the OF_POPULATED flag set in of_irq_init so that
  174. * later the Exynos PMU platform device won't be skipped.
  175. */
  176. of_node_clear_flag(node, OF_POPULATED);
  177. return 0;
  178. }
  179. #define EXYNOS_PMU_IRQ(symbol, name) IRQCHIP_DECLARE(symbol, name, exynos_pmu_irq_init)
  180. EXYNOS_PMU_IRQ(exynos3250_pmu_irq, "samsung,exynos3250-pmu");
  181. EXYNOS_PMU_IRQ(exynos4210_pmu_irq, "samsung,exynos4210-pmu");
  182. EXYNOS_PMU_IRQ(exynos4412_pmu_irq, "samsung,exynos4412-pmu");
  183. EXYNOS_PMU_IRQ(exynos5250_pmu_irq, "samsung,exynos5250-pmu");
  184. EXYNOS_PMU_IRQ(exynos5420_pmu_irq, "samsung,exynos5420-pmu");
  185. static int exynos_cpu_do_idle(void)
  186. {
  187. /* issue the standby signal into the pm unit. */
  188. cpu_do_idle();
  189. pr_info("Failed to suspend the system\n");
  190. return 1; /* Aborting suspend */
  191. }
  192. static void exynos_flush_cache_all(void)
  193. {
  194. flush_cache_all();
  195. outer_flush_all();
  196. }
  197. static int exynos_cpu_suspend(unsigned long arg)
  198. {
  199. exynos_flush_cache_all();
  200. return exynos_cpu_do_idle();
  201. }
  202. static int exynos3250_cpu_suspend(unsigned long arg)
  203. {
  204. flush_cache_all();
  205. return exynos_cpu_do_idle();
  206. }
  207. static int exynos5420_cpu_suspend(unsigned long arg)
  208. {
  209. /* MCPM works with HW CPU identifiers */
  210. unsigned int mpidr = read_cpuid_mpidr();
  211. unsigned int cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
  212. unsigned int cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
  213. writel_relaxed(0x0, sysram_base_addr + EXYNOS5420_CPU_STATE);
  214. if (IS_ENABLED(CONFIG_EXYNOS5420_MCPM)) {
  215. mcpm_set_entry_vector(cpu, cluster, exynos_cpu_resume);
  216. mcpm_cpu_suspend();
  217. }
  218. pr_info("Failed to suspend the system\n");
  219. /* return value != 0 means failure */
  220. return 1;
  221. }
  222. static void exynos_pm_set_wakeup_mask(void)
  223. {
  224. /* Set wake-up mask registers */
  225. pmu_raw_writel(exynos_get_eint_wake_mask(), EXYNOS_EINT_WAKEUP_MASK);
  226. pmu_raw_writel(exynos_irqwake_intmask & ~(1 << 31), S5P_WAKEUP_MASK);
  227. }
  228. static void exynos_pm_enter_sleep_mode(void)
  229. {
  230. /* Set value of power down register for sleep mode */
  231. exynos_sys_powerdown_conf(SYS_SLEEP);
  232. pmu_raw_writel(EXYNOS_SLEEP_MAGIC, S5P_INFORM1);
  233. }
  234. static void exynos_pm_prepare(void)
  235. {
  236. exynos_set_delayed_reset_assertion(false);
  237. /* Set wake-up mask registers */
  238. exynos_pm_set_wakeup_mask();
  239. exynos_pm_enter_sleep_mode();
  240. /* ensure at least INFORM0 has the resume address */
  241. pmu_raw_writel(__pa_symbol(exynos_cpu_resume), S5P_INFORM0);
  242. }
  243. static void exynos3250_pm_prepare(void)
  244. {
  245. unsigned int tmp;
  246. /* Set wake-up mask registers */
  247. exynos_pm_set_wakeup_mask();
  248. tmp = pmu_raw_readl(EXYNOS3_ARM_L2_OPTION);
  249. tmp &= ~EXYNOS5_OPTION_USE_RETENTION;
  250. pmu_raw_writel(tmp, EXYNOS3_ARM_L2_OPTION);
  251. exynos_pm_enter_sleep_mode();
  252. /* ensure at least INFORM0 has the resume address */
  253. pmu_raw_writel(__pa_symbol(exynos_cpu_resume), S5P_INFORM0);
  254. }
  255. static void exynos5420_pm_prepare(void)
  256. {
  257. unsigned int tmp;
  258. /* Set wake-up mask registers */
  259. exynos_pm_set_wakeup_mask();
  260. exynos_pmu_spare3 = pmu_raw_readl(S5P_PMU_SPARE3);
  261. /*
  262. * The cpu state needs to be saved and restored so that the
  263. * secondary CPUs will enter low power start. Though the U-Boot
  264. * is setting the cpu state with low power flag, the kernel
  265. * needs to restore it back in case, the primary cpu fails to
  266. * suspend for any reason.
  267. */
  268. exynos5420_cpu_state = readl_relaxed(sysram_base_addr +
  269. EXYNOS5420_CPU_STATE);
  270. exynos_pm_enter_sleep_mode();
  271. /* ensure at least INFORM0 has the resume address */
  272. if (IS_ENABLED(CONFIG_EXYNOS5420_MCPM))
  273. pmu_raw_writel(__pa_symbol(mcpm_entry_point), S5P_INFORM0);
  274. tmp = pmu_raw_readl(EXYNOS_L2_OPTION(0));
  275. tmp &= ~EXYNOS_L2_USE_RETENTION;
  276. pmu_raw_writel(tmp, EXYNOS_L2_OPTION(0));
  277. tmp = pmu_raw_readl(EXYNOS5420_SFR_AXI_CGDIS1);
  278. tmp |= EXYNOS5420_UFS;
  279. pmu_raw_writel(tmp, EXYNOS5420_SFR_AXI_CGDIS1);
  280. tmp = pmu_raw_readl(EXYNOS5420_ARM_COMMON_OPTION);
  281. tmp &= ~EXYNOS5420_L2RSTDISABLE_VALUE;
  282. pmu_raw_writel(tmp, EXYNOS5420_ARM_COMMON_OPTION);
  283. tmp = pmu_raw_readl(EXYNOS5420_FSYS2_OPTION);
  284. tmp |= EXYNOS5420_EMULATION;
  285. pmu_raw_writel(tmp, EXYNOS5420_FSYS2_OPTION);
  286. tmp = pmu_raw_readl(EXYNOS5420_PSGEN_OPTION);
  287. tmp |= EXYNOS5420_EMULATION;
  288. pmu_raw_writel(tmp, EXYNOS5420_PSGEN_OPTION);
  289. }
  290. static int exynos_pm_suspend(void)
  291. {
  292. exynos_pm_central_suspend();
  293. /* Setting SEQ_OPTION register */
  294. pmu_raw_writel(S5P_USE_STANDBY_WFI0 | S5P_USE_STANDBY_WFE0,
  295. S5P_CENTRAL_SEQ_OPTION);
  296. if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9)
  297. exynos_cpu_save_register();
  298. return 0;
  299. }
  300. static int exynos5420_pm_suspend(void)
  301. {
  302. u32 this_cluster;
  303. exynos_pm_central_suspend();
  304. /* Setting SEQ_OPTION register */
  305. this_cluster = MPIDR_AFFINITY_LEVEL(read_cpuid_mpidr(), 1);
  306. if (!this_cluster)
  307. pmu_raw_writel(EXYNOS5420_ARM_USE_STANDBY_WFI0,
  308. S5P_CENTRAL_SEQ_OPTION);
  309. else
  310. pmu_raw_writel(EXYNOS5420_KFC_USE_STANDBY_WFI0,
  311. S5P_CENTRAL_SEQ_OPTION);
  312. return 0;
  313. }
  314. static void exynos_pm_resume(void)
  315. {
  316. u32 cpuid = read_cpuid_part();
  317. if (exynos_pm_central_resume())
  318. goto early_wakeup;
  319. if (cpuid == ARM_CPU_PART_CORTEX_A9)
  320. exynos_scu_enable();
  321. if (call_firmware_op(resume) == -ENOSYS
  322. && cpuid == ARM_CPU_PART_CORTEX_A9)
  323. exynos_cpu_restore_register();
  324. early_wakeup:
  325. /* Clear SLEEP mode set in INFORM1 */
  326. pmu_raw_writel(0x0, S5P_INFORM1);
  327. exynos_set_delayed_reset_assertion(true);
  328. }
  329. static void exynos3250_pm_resume(void)
  330. {
  331. u32 cpuid = read_cpuid_part();
  332. if (exynos_pm_central_resume())
  333. goto early_wakeup;
  334. pmu_raw_writel(S5P_USE_STANDBY_WFI_ALL, S5P_CENTRAL_SEQ_OPTION);
  335. if (call_firmware_op(resume) == -ENOSYS
  336. && cpuid == ARM_CPU_PART_CORTEX_A9)
  337. exynos_cpu_restore_register();
  338. early_wakeup:
  339. /* Clear SLEEP mode set in INFORM1 */
  340. pmu_raw_writel(0x0, S5P_INFORM1);
  341. }
  342. static void exynos5420_prepare_pm_resume(void)
  343. {
  344. unsigned int mpidr, cluster;
  345. mpidr = read_cpuid_mpidr();
  346. cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
  347. if (IS_ENABLED(CONFIG_EXYNOS5420_MCPM))
  348. WARN_ON(mcpm_cpu_powered_up());
  349. if (IS_ENABLED(CONFIG_HW_PERF_EVENTS) && cluster != 0) {
  350. /*
  351. * When system is resumed on the LITTLE/KFC core (cluster 1),
  352. * the DSCR is not properly updated until the power is turned
  353. * on also for the cluster 0. Enable it for a while to
  354. * propagate the SPNIDEN and SPIDEN signals from Secure JTAG
  355. * block and avoid undefined instruction issue on CP14 reset.
  356. */
  357. pmu_raw_writel(S5P_CORE_LOCAL_PWR_EN,
  358. EXYNOS_COMMON_CONFIGURATION(0));
  359. pmu_raw_writel(0,
  360. EXYNOS_COMMON_CONFIGURATION(0));
  361. }
  362. }
  363. static void exynos5420_pm_resume(void)
  364. {
  365. unsigned long tmp;
  366. /* Restore the CPU0 low power state register */
  367. tmp = pmu_raw_readl(EXYNOS5_ARM_CORE0_SYS_PWR_REG);
  368. pmu_raw_writel(tmp | S5P_CORE_LOCAL_PWR_EN,
  369. EXYNOS5_ARM_CORE0_SYS_PWR_REG);
  370. /* Restore the sysram cpu state register */
  371. writel_relaxed(exynos5420_cpu_state,
  372. sysram_base_addr + EXYNOS5420_CPU_STATE);
  373. pmu_raw_writel(EXYNOS5420_USE_STANDBY_WFI_ALL,
  374. S5P_CENTRAL_SEQ_OPTION);
  375. if (exynos_pm_central_resume())
  376. goto early_wakeup;
  377. pmu_raw_writel(exynos_pmu_spare3, S5P_PMU_SPARE3);
  378. early_wakeup:
  379. tmp = pmu_raw_readl(EXYNOS5420_SFR_AXI_CGDIS1);
  380. tmp &= ~EXYNOS5420_UFS;
  381. pmu_raw_writel(tmp, EXYNOS5420_SFR_AXI_CGDIS1);
  382. tmp = pmu_raw_readl(EXYNOS5420_FSYS2_OPTION);
  383. tmp &= ~EXYNOS5420_EMULATION;
  384. pmu_raw_writel(tmp, EXYNOS5420_FSYS2_OPTION);
  385. tmp = pmu_raw_readl(EXYNOS5420_PSGEN_OPTION);
  386. tmp &= ~EXYNOS5420_EMULATION;
  387. pmu_raw_writel(tmp, EXYNOS5420_PSGEN_OPTION);
  388. /* Clear SLEEP mode set in INFORM1 */
  389. pmu_raw_writel(0x0, S5P_INFORM1);
  390. }
  391. /*
  392. * Suspend Ops
  393. */
  394. static int exynos_suspend_enter(suspend_state_t state)
  395. {
  396. int ret;
  397. s3c_pm_debug_init();
  398. S3C_PMDBG("%s: suspending the system...\n", __func__);
  399. S3C_PMDBG("%s: wakeup masks: %08x,%08x\n", __func__,
  400. exynos_irqwake_intmask, exynos_get_eint_wake_mask());
  401. if (exynos_irqwake_intmask == -1U
  402. && exynos_get_eint_wake_mask() == -1U) {
  403. pr_err("%s: No wake-up sources!\n", __func__);
  404. pr_err("%s: Aborting sleep\n", __func__);
  405. return -EINVAL;
  406. }
  407. s3c_pm_save_uarts();
  408. if (pm_data->pm_prepare)
  409. pm_data->pm_prepare();
  410. flush_cache_all();
  411. s3c_pm_check_store();
  412. ret = call_firmware_op(suspend);
  413. if (ret == -ENOSYS)
  414. ret = cpu_suspend(0, pm_data->cpu_suspend);
  415. if (ret)
  416. return ret;
  417. if (pm_data->pm_resume_prepare)
  418. pm_data->pm_resume_prepare();
  419. s3c_pm_restore_uarts();
  420. S3C_PMDBG("%s: wakeup stat: %08x\n", __func__,
  421. pmu_raw_readl(S5P_WAKEUP_STAT));
  422. s3c_pm_check_restore();
  423. S3C_PMDBG("%s: resuming the system...\n", __func__);
  424. return 0;
  425. }
  426. static int exynos_suspend_prepare(void)
  427. {
  428. int ret;
  429. /*
  430. * REVISIT: It would be better if struct platform_suspend_ops
  431. * .prepare handler get the suspend_state_t as a parameter to
  432. * avoid hard-coding the suspend to mem state. It's safe to do
  433. * it now only because the suspend_valid_only_mem function is
  434. * used as the .valid callback used to check if a given state
  435. * is supported by the platform anyways.
  436. */
  437. ret = regulator_suspend_prepare(PM_SUSPEND_MEM);
  438. if (ret) {
  439. pr_err("Failed to prepare regulators for suspend (%d)\n", ret);
  440. return ret;
  441. }
  442. s3c_pm_check_prepare();
  443. return 0;
  444. }
  445. static void exynos_suspend_finish(void)
  446. {
  447. int ret;
  448. s3c_pm_check_cleanup();
  449. ret = regulator_suspend_finish();
  450. if (ret)
  451. pr_warn("Failed to resume regulators from suspend (%d)\n", ret);
  452. }
  453. static const struct platform_suspend_ops exynos_suspend_ops = {
  454. .enter = exynos_suspend_enter,
  455. .prepare = exynos_suspend_prepare,
  456. .finish = exynos_suspend_finish,
  457. .valid = suspend_valid_only_mem,
  458. };
  459. static const struct exynos_pm_data exynos3250_pm_data = {
  460. .wkup_irq = exynos3250_wkup_irq,
  461. .wake_disable_mask = ((0xFF << 8) | (0x1F << 1)),
  462. .pm_suspend = exynos_pm_suspend,
  463. .pm_resume = exynos3250_pm_resume,
  464. .pm_prepare = exynos3250_pm_prepare,
  465. .cpu_suspend = exynos3250_cpu_suspend,
  466. };
  467. static const struct exynos_pm_data exynos4_pm_data = {
  468. .wkup_irq = exynos4_wkup_irq,
  469. .wake_disable_mask = ((0xFF << 8) | (0x1F << 1)),
  470. .pm_suspend = exynos_pm_suspend,
  471. .pm_resume = exynos_pm_resume,
  472. .pm_prepare = exynos_pm_prepare,
  473. .cpu_suspend = exynos_cpu_suspend,
  474. };
  475. static const struct exynos_pm_data exynos5250_pm_data = {
  476. .wkup_irq = exynos5250_wkup_irq,
  477. .wake_disable_mask = ((0xFF << 8) | (0x1F << 1)),
  478. .pm_suspend = exynos_pm_suspend,
  479. .pm_resume = exynos_pm_resume,
  480. .pm_prepare = exynos_pm_prepare,
  481. .cpu_suspend = exynos_cpu_suspend,
  482. };
  483. static const struct exynos_pm_data exynos5420_pm_data = {
  484. .wkup_irq = exynos5250_wkup_irq,
  485. .wake_disable_mask = (0x7F << 7) | (0x1F << 1),
  486. .pm_resume_prepare = exynos5420_prepare_pm_resume,
  487. .pm_resume = exynos5420_pm_resume,
  488. .pm_suspend = exynos5420_pm_suspend,
  489. .pm_prepare = exynos5420_pm_prepare,
  490. .cpu_suspend = exynos5420_cpu_suspend,
  491. };
  492. static const struct of_device_id exynos_pmu_of_device_ids[] __initconst = {
  493. {
  494. .compatible = "samsung,exynos3250-pmu",
  495. .data = &exynos3250_pm_data,
  496. }, {
  497. .compatible = "samsung,exynos4210-pmu",
  498. .data = &exynos4_pm_data,
  499. }, {
  500. .compatible = "samsung,exynos4412-pmu",
  501. .data = &exynos4_pm_data,
  502. }, {
  503. .compatible = "samsung,exynos5250-pmu",
  504. .data = &exynos5250_pm_data,
  505. }, {
  506. .compatible = "samsung,exynos5420-pmu",
  507. .data = &exynos5420_pm_data,
  508. },
  509. { /*sentinel*/ },
  510. };
  511. static struct syscore_ops exynos_pm_syscore_ops;
  512. void __init exynos_pm_init(void)
  513. {
  514. const struct of_device_id *match;
  515. struct device_node *np;
  516. u32 tmp;
  517. np = of_find_matching_node_and_match(NULL, exynos_pmu_of_device_ids, &match);
  518. if (!np) {
  519. pr_err("Failed to find PMU node\n");
  520. return;
  521. }
  522. if (WARN_ON(!of_find_property(np, "interrupt-controller", NULL))) {
  523. pr_warn("Outdated DT detected, suspend/resume will NOT work\n");
  524. of_node_put(np);
  525. return;
  526. }
  527. of_node_put(np);
  528. pm_data = (const struct exynos_pm_data *) match->data;
  529. /* All wakeup disable */
  530. tmp = pmu_raw_readl(S5P_WAKEUP_MASK);
  531. tmp |= pm_data->wake_disable_mask;
  532. pmu_raw_writel(tmp, S5P_WAKEUP_MASK);
  533. exynos_pm_syscore_ops.suspend = pm_data->pm_suspend;
  534. exynos_pm_syscore_ops.resume = pm_data->pm_resume;
  535. register_syscore_ops(&exynos_pm_syscore_ops);
  536. suspend_set_ops(&exynos_suspend_ops);
  537. }