suspend.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  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/irqchip/arm-gic.h>
  21. #include <linux/err.h>
  22. #include <linux/regulator/machine.h>
  23. #include <asm/cacheflush.h>
  24. #include <asm/hardware/cache-l2x0.h>
  25. #include <asm/firmware.h>
  26. #include <asm/mcpm.h>
  27. #include <asm/smp_scu.h>
  28. #include <asm/suspend.h>
  29. #include <plat/pm-common.h>
  30. #include <plat/regs-srom.h>
  31. #include "common.h"
  32. #include "regs-pmu.h"
  33. #include "exynos-pmu.h"
  34. #define S5P_CHECK_SLEEP 0x00000BAD
  35. #define REG_TABLE_END (-1U)
  36. #define EXYNOS5420_CPU_STATE 0x28
  37. /**
  38. * struct exynos_wkup_irq - Exynos GIC to PMU IRQ mapping
  39. * @hwirq: Hardware IRQ signal of the GIC
  40. * @mask: Mask in PMU wake-up mask register
  41. */
  42. struct exynos_wkup_irq {
  43. unsigned int hwirq;
  44. u32 mask;
  45. };
  46. static struct sleep_save exynos_core_save[] = {
  47. /* SROM side */
  48. SAVE_ITEM(S5P_SROM_BW),
  49. SAVE_ITEM(S5P_SROM_BC0),
  50. SAVE_ITEM(S5P_SROM_BC1),
  51. SAVE_ITEM(S5P_SROM_BC2),
  52. SAVE_ITEM(S5P_SROM_BC3),
  53. };
  54. struct exynos_pm_data {
  55. const struct exynos_wkup_irq *wkup_irq;
  56. struct sleep_save *extra_save;
  57. int num_extra_save;
  58. unsigned int wake_disable_mask;
  59. unsigned int *release_ret_regs;
  60. void (*pm_prepare)(void);
  61. void (*pm_resume_prepare)(void);
  62. void (*pm_resume)(void);
  63. int (*pm_suspend)(void);
  64. int (*cpu_suspend)(unsigned long);
  65. };
  66. struct exynos_pm_data *pm_data;
  67. static int exynos5420_cpu_state;
  68. static unsigned int exynos_pmu_spare3;
  69. /*
  70. * GIC wake-up support
  71. */
  72. static u32 exynos_irqwake_intmask = 0xffffffff;
  73. static const struct exynos_wkup_irq exynos3250_wkup_irq[] = {
  74. { 105, BIT(1) }, /* RTC alarm */
  75. { 106, BIT(2) }, /* RTC tick */
  76. { /* sentinel */ },
  77. };
  78. static const struct exynos_wkup_irq exynos4_wkup_irq[] = {
  79. { 76, BIT(1) }, /* RTC alarm */
  80. { 77, BIT(2) }, /* RTC tick */
  81. { /* sentinel */ },
  82. };
  83. static const struct exynos_wkup_irq exynos5250_wkup_irq[] = {
  84. { 75, BIT(1) }, /* RTC alarm */
  85. { 76, BIT(2) }, /* RTC tick */
  86. { /* sentinel */ },
  87. };
  88. unsigned int exynos_release_ret_regs[] = {
  89. S5P_PAD_RET_MAUDIO_OPTION,
  90. S5P_PAD_RET_GPIO_OPTION,
  91. S5P_PAD_RET_UART_OPTION,
  92. S5P_PAD_RET_MMCA_OPTION,
  93. S5P_PAD_RET_MMCB_OPTION,
  94. S5P_PAD_RET_EBIA_OPTION,
  95. S5P_PAD_RET_EBIB_OPTION,
  96. REG_TABLE_END,
  97. };
  98. unsigned int exynos3250_release_ret_regs[] = {
  99. S5P_PAD_RET_MAUDIO_OPTION,
  100. S5P_PAD_RET_GPIO_OPTION,
  101. S5P_PAD_RET_UART_OPTION,
  102. S5P_PAD_RET_MMCA_OPTION,
  103. S5P_PAD_RET_MMCB_OPTION,
  104. S5P_PAD_RET_EBIA_OPTION,
  105. S5P_PAD_RET_EBIB_OPTION,
  106. S5P_PAD_RET_MMC2_OPTION,
  107. S5P_PAD_RET_SPI_OPTION,
  108. REG_TABLE_END,
  109. };
  110. unsigned int exynos5420_release_ret_regs[] = {
  111. EXYNOS_PAD_RET_DRAM_OPTION,
  112. EXYNOS_PAD_RET_MAUDIO_OPTION,
  113. EXYNOS_PAD_RET_JTAG_OPTION,
  114. EXYNOS5420_PAD_RET_GPIO_OPTION,
  115. EXYNOS5420_PAD_RET_UART_OPTION,
  116. EXYNOS5420_PAD_RET_MMCA_OPTION,
  117. EXYNOS5420_PAD_RET_MMCB_OPTION,
  118. EXYNOS5420_PAD_RET_MMCC_OPTION,
  119. EXYNOS5420_PAD_RET_HSI_OPTION,
  120. EXYNOS_PAD_RET_EBIA_OPTION,
  121. EXYNOS_PAD_RET_EBIB_OPTION,
  122. EXYNOS5420_PAD_RET_SPI_OPTION,
  123. EXYNOS5420_PAD_RET_DRAM_COREBLK_OPTION,
  124. REG_TABLE_END,
  125. };
  126. static int exynos_irq_set_wake(struct irq_data *data, unsigned int state)
  127. {
  128. const struct exynos_wkup_irq *wkup_irq;
  129. if (!pm_data->wkup_irq)
  130. return -ENOENT;
  131. wkup_irq = pm_data->wkup_irq;
  132. while (wkup_irq->mask) {
  133. if (wkup_irq->hwirq == data->hwirq) {
  134. if (!state)
  135. exynos_irqwake_intmask |= wkup_irq->mask;
  136. else
  137. exynos_irqwake_intmask &= ~wkup_irq->mask;
  138. return 0;
  139. }
  140. ++wkup_irq;
  141. }
  142. return -ENOENT;
  143. }
  144. static int exynos_cpu_do_idle(void)
  145. {
  146. /* issue the standby signal into the pm unit. */
  147. cpu_do_idle();
  148. pr_info("Failed to suspend the system\n");
  149. return 1; /* Aborting suspend */
  150. }
  151. static void exynos_flush_cache_all(void)
  152. {
  153. flush_cache_all();
  154. outer_flush_all();
  155. }
  156. static int exynos_cpu_suspend(unsigned long arg)
  157. {
  158. exynos_flush_cache_all();
  159. return exynos_cpu_do_idle();
  160. }
  161. static int exynos3250_cpu_suspend(unsigned long arg)
  162. {
  163. flush_cache_all();
  164. return exynos_cpu_do_idle();
  165. }
  166. static int exynos5420_cpu_suspend(unsigned long arg)
  167. {
  168. /* MCPM works with HW CPU identifiers */
  169. unsigned int mpidr = read_cpuid_mpidr();
  170. unsigned int cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
  171. unsigned int cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
  172. __raw_writel(0x0, sysram_base_addr + EXYNOS5420_CPU_STATE);
  173. if (IS_ENABLED(CONFIG_EXYNOS5420_MCPM)) {
  174. mcpm_set_entry_vector(cpu, cluster, exynos_cpu_resume);
  175. /*
  176. * Residency value passed to mcpm_cpu_suspend back-end
  177. * has to be given clear semantics. Set to 0 as a
  178. * temporary value.
  179. */
  180. mcpm_cpu_suspend(0);
  181. }
  182. pr_info("Failed to suspend the system\n");
  183. /* return value != 0 means failure */
  184. return 1;
  185. }
  186. static void exynos_pm_set_wakeup_mask(void)
  187. {
  188. /* Set wake-up mask registers */
  189. pmu_raw_writel(exynos_get_eint_wake_mask(), S5P_EINT_WAKEUP_MASK);
  190. pmu_raw_writel(exynos_irqwake_intmask & ~(1 << 31), S5P_WAKEUP_MASK);
  191. }
  192. static void exynos_pm_enter_sleep_mode(void)
  193. {
  194. /* Set value of power down register for sleep mode */
  195. exynos_sys_powerdown_conf(SYS_SLEEP);
  196. pmu_raw_writel(S5P_CHECK_SLEEP, S5P_INFORM1);
  197. }
  198. static void exynos_pm_prepare(void)
  199. {
  200. /* Set wake-up mask registers */
  201. exynos_pm_set_wakeup_mask();
  202. s3c_pm_do_save(exynos_core_save, ARRAY_SIZE(exynos_core_save));
  203. if (pm_data->extra_save)
  204. s3c_pm_do_save(pm_data->extra_save,
  205. pm_data->num_extra_save);
  206. exynos_pm_enter_sleep_mode();
  207. /* ensure at least INFORM0 has the resume address */
  208. pmu_raw_writel(virt_to_phys(exynos_cpu_resume), S5P_INFORM0);
  209. }
  210. static void exynos3250_pm_prepare(void)
  211. {
  212. unsigned int tmp;
  213. /* Set wake-up mask registers */
  214. exynos_pm_set_wakeup_mask();
  215. tmp = pmu_raw_readl(EXYNOS3_ARM_L2_OPTION);
  216. tmp &= ~EXYNOS5_OPTION_USE_RETENTION;
  217. pmu_raw_writel(tmp, EXYNOS3_ARM_L2_OPTION);
  218. exynos_pm_enter_sleep_mode();
  219. /* ensure at least INFORM0 has the resume address */
  220. pmu_raw_writel(virt_to_phys(exynos_cpu_resume), S5P_INFORM0);
  221. }
  222. static void exynos5420_pm_prepare(void)
  223. {
  224. unsigned int tmp;
  225. /* Set wake-up mask registers */
  226. exynos_pm_set_wakeup_mask();
  227. s3c_pm_do_save(exynos_core_save, ARRAY_SIZE(exynos_core_save));
  228. exynos_pmu_spare3 = pmu_raw_readl(S5P_PMU_SPARE3);
  229. /*
  230. * The cpu state needs to be saved and restored so that the
  231. * secondary CPUs will enter low power start. Though the U-Boot
  232. * is setting the cpu state with low power flag, the kernel
  233. * needs to restore it back in case, the primary cpu fails to
  234. * suspend for any reason.
  235. */
  236. exynos5420_cpu_state = __raw_readl(sysram_base_addr +
  237. EXYNOS5420_CPU_STATE);
  238. exynos_pm_enter_sleep_mode();
  239. /* ensure at least INFORM0 has the resume address */
  240. if (IS_ENABLED(CONFIG_EXYNOS5420_MCPM))
  241. pmu_raw_writel(virt_to_phys(mcpm_entry_point), S5P_INFORM0);
  242. tmp = pmu_raw_readl(EXYNOS5_ARM_L2_OPTION);
  243. tmp &= ~EXYNOS5_USE_RETENTION;
  244. pmu_raw_writel(tmp, EXYNOS5_ARM_L2_OPTION);
  245. tmp = pmu_raw_readl(EXYNOS5420_SFR_AXI_CGDIS1);
  246. tmp |= EXYNOS5420_UFS;
  247. pmu_raw_writel(tmp, EXYNOS5420_SFR_AXI_CGDIS1);
  248. tmp = pmu_raw_readl(EXYNOS5420_ARM_COMMON_OPTION);
  249. tmp &= ~EXYNOS5420_L2RSTDISABLE_VALUE;
  250. pmu_raw_writel(tmp, EXYNOS5420_ARM_COMMON_OPTION);
  251. tmp = pmu_raw_readl(EXYNOS5420_FSYS2_OPTION);
  252. tmp |= EXYNOS5420_EMULATION;
  253. pmu_raw_writel(tmp, EXYNOS5420_FSYS2_OPTION);
  254. tmp = pmu_raw_readl(EXYNOS5420_PSGEN_OPTION);
  255. tmp |= EXYNOS5420_EMULATION;
  256. pmu_raw_writel(tmp, EXYNOS5420_PSGEN_OPTION);
  257. }
  258. static int exynos_pm_suspend(void)
  259. {
  260. exynos_pm_central_suspend();
  261. /* Setting SEQ_OPTION register */
  262. pmu_raw_writel(S5P_USE_STANDBY_WFI0 | S5P_USE_STANDBY_WFE0,
  263. S5P_CENTRAL_SEQ_OPTION);
  264. if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9)
  265. exynos_cpu_save_register();
  266. return 0;
  267. }
  268. static int exynos5420_pm_suspend(void)
  269. {
  270. u32 this_cluster;
  271. exynos_pm_central_suspend();
  272. /* Setting SEQ_OPTION register */
  273. this_cluster = MPIDR_AFFINITY_LEVEL(read_cpuid_mpidr(), 1);
  274. if (!this_cluster)
  275. pmu_raw_writel(EXYNOS5420_ARM_USE_STANDBY_WFI0,
  276. S5P_CENTRAL_SEQ_OPTION);
  277. else
  278. pmu_raw_writel(EXYNOS5420_KFC_USE_STANDBY_WFI0,
  279. S5P_CENTRAL_SEQ_OPTION);
  280. return 0;
  281. }
  282. static void exynos_pm_release_retention(void)
  283. {
  284. unsigned int i;
  285. for (i = 0; (pm_data->release_ret_regs[i] != REG_TABLE_END); i++)
  286. pmu_raw_writel(EXYNOS_WAKEUP_FROM_LOWPWR,
  287. pm_data->release_ret_regs[i]);
  288. }
  289. static void exynos_pm_resume(void)
  290. {
  291. u32 cpuid = read_cpuid_part();
  292. if (exynos_pm_central_resume())
  293. goto early_wakeup;
  294. /* For release retention */
  295. exynos_pm_release_retention();
  296. if (pm_data->extra_save)
  297. s3c_pm_do_restore_core(pm_data->extra_save,
  298. pm_data->num_extra_save);
  299. s3c_pm_do_restore_core(exynos_core_save, ARRAY_SIZE(exynos_core_save));
  300. if (cpuid == ARM_CPU_PART_CORTEX_A9)
  301. scu_enable(S5P_VA_SCU);
  302. if (call_firmware_op(resume) == -ENOSYS
  303. && cpuid == ARM_CPU_PART_CORTEX_A9)
  304. exynos_cpu_restore_register();
  305. early_wakeup:
  306. /* Clear SLEEP mode set in INFORM1 */
  307. pmu_raw_writel(0x0, S5P_INFORM1);
  308. }
  309. static void exynos3250_pm_resume(void)
  310. {
  311. u32 cpuid = read_cpuid_part();
  312. if (exynos_pm_central_resume())
  313. goto early_wakeup;
  314. /* For release retention */
  315. exynos_pm_release_retention();
  316. pmu_raw_writel(S5P_USE_STANDBY_WFI_ALL, S5P_CENTRAL_SEQ_OPTION);
  317. if (call_firmware_op(resume) == -ENOSYS
  318. && cpuid == ARM_CPU_PART_CORTEX_A9)
  319. exynos_cpu_restore_register();
  320. early_wakeup:
  321. /* Clear SLEEP mode set in INFORM1 */
  322. pmu_raw_writel(0x0, S5P_INFORM1);
  323. }
  324. static void exynos5420_prepare_pm_resume(void)
  325. {
  326. if (IS_ENABLED(CONFIG_EXYNOS5420_MCPM))
  327. WARN_ON(mcpm_cpu_powered_up());
  328. }
  329. static void exynos5420_pm_resume(void)
  330. {
  331. unsigned long tmp;
  332. /* Restore the CPU0 low power state register */
  333. tmp = pmu_raw_readl(EXYNOS5_ARM_CORE0_SYS_PWR_REG);
  334. pmu_raw_writel(tmp | S5P_CORE_LOCAL_PWR_EN,
  335. EXYNOS5_ARM_CORE0_SYS_PWR_REG);
  336. /* Restore the sysram cpu state register */
  337. __raw_writel(exynos5420_cpu_state,
  338. sysram_base_addr + EXYNOS5420_CPU_STATE);
  339. pmu_raw_writel(EXYNOS5420_USE_STANDBY_WFI_ALL,
  340. S5P_CENTRAL_SEQ_OPTION);
  341. if (exynos_pm_central_resume())
  342. goto early_wakeup;
  343. /* For release retention */
  344. exynos_pm_release_retention();
  345. pmu_raw_writel(exynos_pmu_spare3, S5P_PMU_SPARE3);
  346. s3c_pm_do_restore_core(exynos_core_save, ARRAY_SIZE(exynos_core_save));
  347. early_wakeup:
  348. tmp = pmu_raw_readl(EXYNOS5420_SFR_AXI_CGDIS1);
  349. tmp &= ~EXYNOS5420_UFS;
  350. pmu_raw_writel(tmp, EXYNOS5420_SFR_AXI_CGDIS1);
  351. tmp = pmu_raw_readl(EXYNOS5420_FSYS2_OPTION);
  352. tmp &= ~EXYNOS5420_EMULATION;
  353. pmu_raw_writel(tmp, EXYNOS5420_FSYS2_OPTION);
  354. tmp = pmu_raw_readl(EXYNOS5420_PSGEN_OPTION);
  355. tmp &= ~EXYNOS5420_EMULATION;
  356. pmu_raw_writel(tmp, EXYNOS5420_PSGEN_OPTION);
  357. /* Clear SLEEP mode set in INFORM1 */
  358. pmu_raw_writel(0x0, S5P_INFORM1);
  359. }
  360. /*
  361. * Suspend Ops
  362. */
  363. static int exynos_suspend_enter(suspend_state_t state)
  364. {
  365. int ret;
  366. s3c_pm_debug_init();
  367. S3C_PMDBG("%s: suspending the system...\n", __func__);
  368. S3C_PMDBG("%s: wakeup masks: %08x,%08x\n", __func__,
  369. exynos_irqwake_intmask, exynos_get_eint_wake_mask());
  370. if (exynos_irqwake_intmask == -1U
  371. && exynos_get_eint_wake_mask() == -1U) {
  372. pr_err("%s: No wake-up sources!\n", __func__);
  373. pr_err("%s: Aborting sleep\n", __func__);
  374. return -EINVAL;
  375. }
  376. s3c_pm_save_uarts();
  377. if (pm_data->pm_prepare)
  378. pm_data->pm_prepare();
  379. flush_cache_all();
  380. s3c_pm_check_store();
  381. ret = call_firmware_op(suspend);
  382. if (ret == -ENOSYS)
  383. ret = cpu_suspend(0, pm_data->cpu_suspend);
  384. if (ret)
  385. return ret;
  386. if (pm_data->pm_resume_prepare)
  387. pm_data->pm_resume_prepare();
  388. s3c_pm_restore_uarts();
  389. S3C_PMDBG("%s: wakeup stat: %08x\n", __func__,
  390. pmu_raw_readl(S5P_WAKEUP_STAT));
  391. s3c_pm_check_restore();
  392. S3C_PMDBG("%s: resuming the system...\n", __func__);
  393. return 0;
  394. }
  395. static int exynos_suspend_prepare(void)
  396. {
  397. int ret;
  398. /*
  399. * REVISIT: It would be better if struct platform_suspend_ops
  400. * .prepare handler get the suspend_state_t as a parameter to
  401. * avoid hard-coding the suspend to mem state. It's safe to do
  402. * it now only because the suspend_valid_only_mem function is
  403. * used as the .valid callback used to check if a given state
  404. * is supported by the platform anyways.
  405. */
  406. ret = regulator_suspend_prepare(PM_SUSPEND_MEM);
  407. if (ret) {
  408. pr_err("Failed to prepare regulators for suspend (%d)\n", ret);
  409. return ret;
  410. }
  411. s3c_pm_check_prepare();
  412. return 0;
  413. }
  414. static void exynos_suspend_finish(void)
  415. {
  416. int ret;
  417. s3c_pm_check_cleanup();
  418. ret = regulator_suspend_finish();
  419. if (ret)
  420. pr_warn("Failed to resume regulators from suspend (%d)\n", ret);
  421. }
  422. static const struct platform_suspend_ops exynos_suspend_ops = {
  423. .enter = exynos_suspend_enter,
  424. .prepare = exynos_suspend_prepare,
  425. .finish = exynos_suspend_finish,
  426. .valid = suspend_valid_only_mem,
  427. };
  428. static const struct exynos_pm_data exynos3250_pm_data = {
  429. .wkup_irq = exynos3250_wkup_irq,
  430. .wake_disable_mask = ((0xFF << 8) | (0x1F << 1)),
  431. .release_ret_regs = exynos3250_release_ret_regs,
  432. .pm_suspend = exynos_pm_suspend,
  433. .pm_resume = exynos3250_pm_resume,
  434. .pm_prepare = exynos3250_pm_prepare,
  435. .cpu_suspend = exynos3250_cpu_suspend,
  436. };
  437. static const struct exynos_pm_data exynos4_pm_data = {
  438. .wkup_irq = exynos4_wkup_irq,
  439. .wake_disable_mask = ((0xFF << 8) | (0x1F << 1)),
  440. .release_ret_regs = exynos_release_ret_regs,
  441. .pm_suspend = exynos_pm_suspend,
  442. .pm_resume = exynos_pm_resume,
  443. .pm_prepare = exynos_pm_prepare,
  444. .cpu_suspend = exynos_cpu_suspend,
  445. };
  446. static const struct exynos_pm_data exynos5250_pm_data = {
  447. .wkup_irq = exynos5250_wkup_irq,
  448. .wake_disable_mask = ((0xFF << 8) | (0x1F << 1)),
  449. .release_ret_regs = exynos_release_ret_regs,
  450. .pm_suspend = exynos_pm_suspend,
  451. .pm_resume = exynos_pm_resume,
  452. .pm_prepare = exynos_pm_prepare,
  453. .cpu_suspend = exynos_cpu_suspend,
  454. };
  455. static struct exynos_pm_data exynos5420_pm_data = {
  456. .wkup_irq = exynos5250_wkup_irq,
  457. .wake_disable_mask = (0x7F << 7) | (0x1F << 1),
  458. .release_ret_regs = exynos5420_release_ret_regs,
  459. .pm_resume_prepare = exynos5420_prepare_pm_resume,
  460. .pm_resume = exynos5420_pm_resume,
  461. .pm_suspend = exynos5420_pm_suspend,
  462. .pm_prepare = exynos5420_pm_prepare,
  463. .cpu_suspend = exynos5420_cpu_suspend,
  464. };
  465. static const struct of_device_id exynos_pmu_of_device_ids[] __initconst = {
  466. {
  467. .compatible = "samsung,exynos3250-pmu",
  468. .data = &exynos3250_pm_data,
  469. }, {
  470. .compatible = "samsung,exynos4210-pmu",
  471. .data = &exynos4_pm_data,
  472. }, {
  473. .compatible = "samsung,exynos4212-pmu",
  474. .data = &exynos4_pm_data,
  475. }, {
  476. .compatible = "samsung,exynos4412-pmu",
  477. .data = &exynos4_pm_data,
  478. }, {
  479. .compatible = "samsung,exynos5250-pmu",
  480. .data = &exynos5250_pm_data,
  481. }, {
  482. .compatible = "samsung,exynos5420-pmu",
  483. .data = &exynos5420_pm_data,
  484. },
  485. { /*sentinel*/ },
  486. };
  487. static struct syscore_ops exynos_pm_syscore_ops;
  488. void __init exynos_pm_init(void)
  489. {
  490. const struct of_device_id *match;
  491. u32 tmp;
  492. of_find_matching_node_and_match(NULL, exynos_pmu_of_device_ids, &match);
  493. if (!match) {
  494. pr_err("Failed to find PMU node\n");
  495. return;
  496. }
  497. pm_data = (struct exynos_pm_data *) match->data;
  498. /* Platform-specific GIC callback */
  499. gic_arch_extn.irq_set_wake = exynos_irq_set_wake;
  500. /* All wakeup disable */
  501. tmp = pmu_raw_readl(S5P_WAKEUP_MASK);
  502. tmp |= pm_data->wake_disable_mask;
  503. pmu_raw_writel(tmp, S5P_WAKEUP_MASK);
  504. exynos_pm_syscore_ops.suspend = pm_data->pm_suspend;
  505. exynos_pm_syscore_ops.resume = pm_data->pm_resume;
  506. register_syscore_ops(&exynos_pm_syscore_ops);
  507. suspend_set_ops(&exynos_suspend_ops);
  508. }