suspend.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. /*
  2. * Copyright (c) 2011-2014 Samsung Electronics Co., Ltd.
  3. * http://www.samsung.com
  4. *
  5. * EXYNOS - Suspend support
  6. *
  7. * Based on arch/arm/mach-s3c2410/pm.c
  8. * Copyright (c) 2006 Simtec Electronics
  9. * Ben Dooks <ben@simtec.co.uk>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. */
  15. #include <linux/init.h>
  16. #include <linux/suspend.h>
  17. #include <linux/syscore_ops.h>
  18. #include <linux/cpu_pm.h>
  19. #include <linux/io.h>
  20. #include <linux/irq.h>
  21. #include <linux/irqchip.h>
  22. #include <linux/irqdomain.h>
  23. #include <linux/of_address.h>
  24. #include <linux/err.h>
  25. #include <linux/regulator/machine.h>
  26. #include <linux/soc/samsung/exynos-pmu.h>
  27. #include <linux/soc/samsung/exynos-regs-pmu.h>
  28. #include <asm/cacheflush.h>
  29. #include <asm/hardware/cache-l2x0.h>
  30. #include <asm/firmware.h>
  31. #include <asm/mcpm.h>
  32. #include <asm/smp_scu.h>
  33. #include <asm/suspend.h>
  34. #include <mach/map.h>
  35. #include <plat/pm-common.h>
  36. #include "common.h"
  37. #define REG_TABLE_END (-1U)
  38. #define EXYNOS5420_CPU_STATE 0x28
  39. /**
  40. * struct exynos_wkup_irq - PMU IRQ to mask mapping
  41. * @hwirq: Hardware IRQ signal of the PMU
  42. * @mask: Mask in PMU wake-up mask register
  43. */
  44. struct exynos_wkup_irq {
  45. unsigned int hwirq;
  46. u32 mask;
  47. };
  48. struct exynos_pm_data {
  49. const struct exynos_wkup_irq *wkup_irq;
  50. unsigned int wake_disable_mask;
  51. void (*pm_prepare)(void);
  52. void (*pm_resume_prepare)(void);
  53. void (*pm_resume)(void);
  54. int (*pm_suspend)(void);
  55. int (*cpu_suspend)(unsigned long);
  56. };
  57. static const struct exynos_pm_data *pm_data __ro_after_init;
  58. static int exynos5420_cpu_state;
  59. static unsigned int exynos_pmu_spare3;
  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("%s: no parent, giving up\n", node->full_name);
  157. return -ENODEV;
  158. }
  159. parent_domain = irq_find_host(parent);
  160. if (!parent_domain) {
  161. pr_err("%s: unable to obtain parent domain\n", node->full_name);
  162. return -ENXIO;
  163. }
  164. pmu_base_addr = of_iomap(node, 0);
  165. if (!pmu_base_addr) {
  166. pr_err("%s: failed to find exynos pmu register\n",
  167. node->full_name);
  168. return -ENOMEM;
  169. }
  170. domain = irq_domain_add_hierarchy(parent_domain, 0, 0,
  171. node, &exynos_pmu_domain_ops,
  172. NULL);
  173. if (!domain) {
  174. iounmap(pmu_base_addr);
  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(exynos4212_pmu_irq, "samsung,exynos4212-pmu");
  188. EXYNOS_PMU_IRQ(exynos4412_pmu_irq, "samsung,exynos4412-pmu");
  189. EXYNOS_PMU_IRQ(exynos5250_pmu_irq, "samsung,exynos5250-pmu");
  190. EXYNOS_PMU_IRQ(exynos5420_pmu_irq, "samsung,exynos5420-pmu");
  191. static int exynos_cpu_do_idle(void)
  192. {
  193. /* issue the standby signal into the pm unit. */
  194. cpu_do_idle();
  195. pr_info("Failed to suspend the system\n");
  196. return 1; /* Aborting suspend */
  197. }
  198. static void exynos_flush_cache_all(void)
  199. {
  200. flush_cache_all();
  201. outer_flush_all();
  202. }
  203. static int exynos_cpu_suspend(unsigned long arg)
  204. {
  205. exynos_flush_cache_all();
  206. return exynos_cpu_do_idle();
  207. }
  208. static int exynos3250_cpu_suspend(unsigned long arg)
  209. {
  210. flush_cache_all();
  211. return exynos_cpu_do_idle();
  212. }
  213. static int exynos5420_cpu_suspend(unsigned long arg)
  214. {
  215. /* MCPM works with HW CPU identifiers */
  216. unsigned int mpidr = read_cpuid_mpidr();
  217. unsigned int cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
  218. unsigned int cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
  219. writel_relaxed(0x0, sysram_base_addr + EXYNOS5420_CPU_STATE);
  220. if (IS_ENABLED(CONFIG_EXYNOS5420_MCPM)) {
  221. mcpm_set_entry_vector(cpu, cluster, exynos_cpu_resume);
  222. mcpm_cpu_suspend();
  223. }
  224. pr_info("Failed to suspend the system\n");
  225. /* return value != 0 means failure */
  226. return 1;
  227. }
  228. static void exynos_pm_set_wakeup_mask(void)
  229. {
  230. /* Set wake-up mask registers */
  231. pmu_raw_writel(exynos_get_eint_wake_mask(), S5P_EINT_WAKEUP_MASK);
  232. pmu_raw_writel(exynos_irqwake_intmask & ~(1 << 31), S5P_WAKEUP_MASK);
  233. }
  234. static void exynos_pm_enter_sleep_mode(void)
  235. {
  236. /* Set value of power down register for sleep mode */
  237. exynos_sys_powerdown_conf(SYS_SLEEP);
  238. pmu_raw_writel(EXYNOS_SLEEP_MAGIC, S5P_INFORM1);
  239. }
  240. static void exynos_pm_prepare(void)
  241. {
  242. exynos_set_delayed_reset_assertion(false);
  243. /* Set wake-up mask registers */
  244. exynos_pm_set_wakeup_mask();
  245. exynos_pm_enter_sleep_mode();
  246. /* ensure at least INFORM0 has the resume address */
  247. pmu_raw_writel(__pa_symbol(exynos_cpu_resume), S5P_INFORM0);
  248. }
  249. static void exynos3250_pm_prepare(void)
  250. {
  251. unsigned int tmp;
  252. /* Set wake-up mask registers */
  253. exynos_pm_set_wakeup_mask();
  254. tmp = pmu_raw_readl(EXYNOS3_ARM_L2_OPTION);
  255. tmp &= ~EXYNOS5_OPTION_USE_RETENTION;
  256. pmu_raw_writel(tmp, EXYNOS3_ARM_L2_OPTION);
  257. exynos_pm_enter_sleep_mode();
  258. /* ensure at least INFORM0 has the resume address */
  259. pmu_raw_writel(__pa_symbol(exynos_cpu_resume), S5P_INFORM0);
  260. }
  261. static void exynos5420_pm_prepare(void)
  262. {
  263. unsigned int tmp;
  264. /* Set wake-up mask registers */
  265. exynos_pm_set_wakeup_mask();
  266. exynos_pmu_spare3 = pmu_raw_readl(S5P_PMU_SPARE3);
  267. /*
  268. * The cpu state needs to be saved and restored so that the
  269. * secondary CPUs will enter low power start. Though the U-Boot
  270. * is setting the cpu state with low power flag, the kernel
  271. * needs to restore it back in case, the primary cpu fails to
  272. * suspend for any reason.
  273. */
  274. exynos5420_cpu_state = readl_relaxed(sysram_base_addr +
  275. EXYNOS5420_CPU_STATE);
  276. exynos_pm_enter_sleep_mode();
  277. /* ensure at least INFORM0 has the resume address */
  278. if (IS_ENABLED(CONFIG_EXYNOS5420_MCPM))
  279. pmu_raw_writel(__pa_symbol(mcpm_entry_point), S5P_INFORM0);
  280. tmp = pmu_raw_readl(EXYNOS_L2_OPTION(0));
  281. tmp &= ~EXYNOS_L2_USE_RETENTION;
  282. pmu_raw_writel(tmp, EXYNOS_L2_OPTION(0));
  283. tmp = pmu_raw_readl(EXYNOS5420_SFR_AXI_CGDIS1);
  284. tmp |= EXYNOS5420_UFS;
  285. pmu_raw_writel(tmp, EXYNOS5420_SFR_AXI_CGDIS1);
  286. tmp = pmu_raw_readl(EXYNOS5420_ARM_COMMON_OPTION);
  287. tmp &= ~EXYNOS5420_L2RSTDISABLE_VALUE;
  288. pmu_raw_writel(tmp, EXYNOS5420_ARM_COMMON_OPTION);
  289. tmp = pmu_raw_readl(EXYNOS5420_FSYS2_OPTION);
  290. tmp |= EXYNOS5420_EMULATION;
  291. pmu_raw_writel(tmp, EXYNOS5420_FSYS2_OPTION);
  292. tmp = pmu_raw_readl(EXYNOS5420_PSGEN_OPTION);
  293. tmp |= EXYNOS5420_EMULATION;
  294. pmu_raw_writel(tmp, EXYNOS5420_PSGEN_OPTION);
  295. }
  296. static int exynos_pm_suspend(void)
  297. {
  298. exynos_pm_central_suspend();
  299. /* Setting SEQ_OPTION register */
  300. pmu_raw_writel(S5P_USE_STANDBY_WFI0 | S5P_USE_STANDBY_WFE0,
  301. S5P_CENTRAL_SEQ_OPTION);
  302. if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9)
  303. exynos_cpu_save_register();
  304. return 0;
  305. }
  306. static int exynos5420_pm_suspend(void)
  307. {
  308. u32 this_cluster;
  309. exynos_pm_central_suspend();
  310. /* Setting SEQ_OPTION register */
  311. this_cluster = MPIDR_AFFINITY_LEVEL(read_cpuid_mpidr(), 1);
  312. if (!this_cluster)
  313. pmu_raw_writel(EXYNOS5420_ARM_USE_STANDBY_WFI0,
  314. S5P_CENTRAL_SEQ_OPTION);
  315. else
  316. pmu_raw_writel(EXYNOS5420_KFC_USE_STANDBY_WFI0,
  317. S5P_CENTRAL_SEQ_OPTION);
  318. return 0;
  319. }
  320. static void exynos_pm_resume(void)
  321. {
  322. u32 cpuid = read_cpuid_part();
  323. if (exynos_pm_central_resume())
  324. goto early_wakeup;
  325. if (cpuid == ARM_CPU_PART_CORTEX_A9)
  326. scu_enable(S5P_VA_SCU);
  327. if (call_firmware_op(resume) == -ENOSYS
  328. && cpuid == ARM_CPU_PART_CORTEX_A9)
  329. exynos_cpu_restore_register();
  330. early_wakeup:
  331. /* Clear SLEEP mode set in INFORM1 */
  332. pmu_raw_writel(0x0, S5P_INFORM1);
  333. exynos_set_delayed_reset_assertion(true);
  334. }
  335. static void exynos3250_pm_resume(void)
  336. {
  337. u32 cpuid = read_cpuid_part();
  338. if (exynos_pm_central_resume())
  339. goto early_wakeup;
  340. pmu_raw_writel(S5P_USE_STANDBY_WFI_ALL, S5P_CENTRAL_SEQ_OPTION);
  341. if (call_firmware_op(resume) == -ENOSYS
  342. && cpuid == ARM_CPU_PART_CORTEX_A9)
  343. exynos_cpu_restore_register();
  344. early_wakeup:
  345. /* Clear SLEEP mode set in INFORM1 */
  346. pmu_raw_writel(0x0, S5P_INFORM1);
  347. }
  348. static void exynos5420_prepare_pm_resume(void)
  349. {
  350. if (IS_ENABLED(CONFIG_EXYNOS5420_MCPM))
  351. WARN_ON(mcpm_cpu_powered_up());
  352. }
  353. static void exynos5420_pm_resume(void)
  354. {
  355. unsigned long tmp;
  356. /* Restore the CPU0 low power state register */
  357. tmp = pmu_raw_readl(EXYNOS5_ARM_CORE0_SYS_PWR_REG);
  358. pmu_raw_writel(tmp | S5P_CORE_LOCAL_PWR_EN,
  359. EXYNOS5_ARM_CORE0_SYS_PWR_REG);
  360. /* Restore the sysram cpu state register */
  361. writel_relaxed(exynos5420_cpu_state,
  362. sysram_base_addr + EXYNOS5420_CPU_STATE);
  363. pmu_raw_writel(EXYNOS5420_USE_STANDBY_WFI_ALL,
  364. S5P_CENTRAL_SEQ_OPTION);
  365. if (exynos_pm_central_resume())
  366. goto early_wakeup;
  367. pmu_raw_writel(exynos_pmu_spare3, S5P_PMU_SPARE3);
  368. early_wakeup:
  369. tmp = pmu_raw_readl(EXYNOS5420_SFR_AXI_CGDIS1);
  370. tmp &= ~EXYNOS5420_UFS;
  371. pmu_raw_writel(tmp, EXYNOS5420_SFR_AXI_CGDIS1);
  372. tmp = pmu_raw_readl(EXYNOS5420_FSYS2_OPTION);
  373. tmp &= ~EXYNOS5420_EMULATION;
  374. pmu_raw_writel(tmp, EXYNOS5420_FSYS2_OPTION);
  375. tmp = pmu_raw_readl(EXYNOS5420_PSGEN_OPTION);
  376. tmp &= ~EXYNOS5420_EMULATION;
  377. pmu_raw_writel(tmp, EXYNOS5420_PSGEN_OPTION);
  378. /* Clear SLEEP mode set in INFORM1 */
  379. pmu_raw_writel(0x0, S5P_INFORM1);
  380. }
  381. /*
  382. * Suspend Ops
  383. */
  384. static int exynos_suspend_enter(suspend_state_t state)
  385. {
  386. int ret;
  387. s3c_pm_debug_init();
  388. S3C_PMDBG("%s: suspending the system...\n", __func__);
  389. S3C_PMDBG("%s: wakeup masks: %08x,%08x\n", __func__,
  390. exynos_irqwake_intmask, exynos_get_eint_wake_mask());
  391. if (exynos_irqwake_intmask == -1U
  392. && exynos_get_eint_wake_mask() == -1U) {
  393. pr_err("%s: No wake-up sources!\n", __func__);
  394. pr_err("%s: Aborting sleep\n", __func__);
  395. return -EINVAL;
  396. }
  397. s3c_pm_save_uarts();
  398. if (pm_data->pm_prepare)
  399. pm_data->pm_prepare();
  400. flush_cache_all();
  401. s3c_pm_check_store();
  402. ret = call_firmware_op(suspend);
  403. if (ret == -ENOSYS)
  404. ret = cpu_suspend(0, pm_data->cpu_suspend);
  405. if (ret)
  406. return ret;
  407. if (pm_data->pm_resume_prepare)
  408. pm_data->pm_resume_prepare();
  409. s3c_pm_restore_uarts();
  410. S3C_PMDBG("%s: wakeup stat: %08x\n", __func__,
  411. pmu_raw_readl(S5P_WAKEUP_STAT));
  412. s3c_pm_check_restore();
  413. S3C_PMDBG("%s: resuming the system...\n", __func__);
  414. return 0;
  415. }
  416. static int exynos_suspend_prepare(void)
  417. {
  418. int ret;
  419. /*
  420. * REVISIT: It would be better if struct platform_suspend_ops
  421. * .prepare handler get the suspend_state_t as a parameter to
  422. * avoid hard-coding the suspend to mem state. It's safe to do
  423. * it now only because the suspend_valid_only_mem function is
  424. * used as the .valid callback used to check if a given state
  425. * is supported by the platform anyways.
  426. */
  427. ret = regulator_suspend_prepare(PM_SUSPEND_MEM);
  428. if (ret) {
  429. pr_err("Failed to prepare regulators for suspend (%d)\n", ret);
  430. return ret;
  431. }
  432. s3c_pm_check_prepare();
  433. return 0;
  434. }
  435. static void exynos_suspend_finish(void)
  436. {
  437. int ret;
  438. s3c_pm_check_cleanup();
  439. ret = regulator_suspend_finish();
  440. if (ret)
  441. pr_warn("Failed to resume regulators from suspend (%d)\n", ret);
  442. }
  443. static const struct platform_suspend_ops exynos_suspend_ops = {
  444. .enter = exynos_suspend_enter,
  445. .prepare = exynos_suspend_prepare,
  446. .finish = exynos_suspend_finish,
  447. .valid = suspend_valid_only_mem,
  448. };
  449. static const struct exynos_pm_data exynos3250_pm_data = {
  450. .wkup_irq = exynos3250_wkup_irq,
  451. .wake_disable_mask = ((0xFF << 8) | (0x1F << 1)),
  452. .pm_suspend = exynos_pm_suspend,
  453. .pm_resume = exynos3250_pm_resume,
  454. .pm_prepare = exynos3250_pm_prepare,
  455. .cpu_suspend = exynos3250_cpu_suspend,
  456. };
  457. static const struct exynos_pm_data exynos4_pm_data = {
  458. .wkup_irq = exynos4_wkup_irq,
  459. .wake_disable_mask = ((0xFF << 8) | (0x1F << 1)),
  460. .pm_suspend = exynos_pm_suspend,
  461. .pm_resume = exynos_pm_resume,
  462. .pm_prepare = exynos_pm_prepare,
  463. .cpu_suspend = exynos_cpu_suspend,
  464. };
  465. static const struct exynos_pm_data exynos5250_pm_data = {
  466. .wkup_irq = exynos5250_wkup_irq,
  467. .wake_disable_mask = ((0xFF << 8) | (0x1F << 1)),
  468. .pm_suspend = exynos_pm_suspend,
  469. .pm_resume = exynos_pm_resume,
  470. .pm_prepare = exynos_pm_prepare,
  471. .cpu_suspend = exynos_cpu_suspend,
  472. };
  473. static const struct exynos_pm_data exynos5420_pm_data = {
  474. .wkup_irq = exynos5250_wkup_irq,
  475. .wake_disable_mask = (0x7F << 7) | (0x1F << 1),
  476. .pm_resume_prepare = exynos5420_prepare_pm_resume,
  477. .pm_resume = exynos5420_pm_resume,
  478. .pm_suspend = exynos5420_pm_suspend,
  479. .pm_prepare = exynos5420_pm_prepare,
  480. .cpu_suspend = exynos5420_cpu_suspend,
  481. };
  482. static const struct of_device_id exynos_pmu_of_device_ids[] __initconst = {
  483. {
  484. .compatible = "samsung,exynos3250-pmu",
  485. .data = &exynos3250_pm_data,
  486. }, {
  487. .compatible = "samsung,exynos4210-pmu",
  488. .data = &exynos4_pm_data,
  489. }, {
  490. .compatible = "samsung,exynos4212-pmu",
  491. .data = &exynos4_pm_data,
  492. }, {
  493. .compatible = "samsung,exynos4412-pmu",
  494. .data = &exynos4_pm_data,
  495. }, {
  496. .compatible = "samsung,exynos5250-pmu",
  497. .data = &exynos5250_pm_data,
  498. }, {
  499. .compatible = "samsung,exynos5420-pmu",
  500. .data = &exynos5420_pm_data,
  501. },
  502. { /*sentinel*/ },
  503. };
  504. static struct syscore_ops exynos_pm_syscore_ops;
  505. void __init exynos_pm_init(void)
  506. {
  507. const struct of_device_id *match;
  508. struct device_node *np;
  509. u32 tmp;
  510. np = of_find_matching_node_and_match(NULL, exynos_pmu_of_device_ids, &match);
  511. if (!np) {
  512. pr_err("Failed to find PMU node\n");
  513. return;
  514. }
  515. if (WARN_ON(!of_find_property(np, "interrupt-controller", NULL))) {
  516. pr_warn("Outdated DT detected, suspend/resume will NOT work\n");
  517. return;
  518. }
  519. pm_data = (const struct exynos_pm_data *) match->data;
  520. /* All wakeup disable */
  521. tmp = pmu_raw_readl(S5P_WAKEUP_MASK);
  522. tmp |= pm_data->wake_disable_mask;
  523. pmu_raw_writel(tmp, S5P_WAKEUP_MASK);
  524. exynos_pm_syscore_ops.suspend = pm_data->pm_suspend;
  525. exynos_pm_syscore_ops.resume = pm_data->pm_resume;
  526. register_syscore_ops(&exynos_pm_syscore_ops);
  527. suspend_set_ops(&exynos_suspend_ops);
  528. }