pm.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. /*
  2. * arch/arm/mach-at91/pm.c
  3. * AT91 Power Management
  4. *
  5. * Copyright (C) 2005 David Brownell
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. */
  12. #include <linux/genalloc.h>
  13. #include <linux/io.h>
  14. #include <linux/of_address.h>
  15. #include <linux/of.h>
  16. #include <linux/of_platform.h>
  17. #include <linux/parser.h>
  18. #include <linux/suspend.h>
  19. #include <linux/clk/at91_pmc.h>
  20. #include <asm/cacheflush.h>
  21. #include <asm/fncpy.h>
  22. #include <asm/system_misc.h>
  23. #include <asm/suspend.h>
  24. #include "generic.h"
  25. #include "pm.h"
  26. /*
  27. * FIXME: this is needed to communicate between the pinctrl driver and
  28. * the PM implementation in the machine. Possibly part of the PM
  29. * implementation should be moved down into the pinctrl driver and get
  30. * called as part of the generic suspend/resume path.
  31. */
  32. #ifdef CONFIG_PINCTRL_AT91
  33. extern void at91_pinctrl_gpio_suspend(void);
  34. extern void at91_pinctrl_gpio_resume(void);
  35. #endif
  36. static const match_table_t pm_modes __initconst = {
  37. { 0, "standby" },
  38. { AT91_PM_SLOW_CLOCK, "ulp0" },
  39. { AT91_PM_BACKUP, "backup" },
  40. { -1, NULL },
  41. };
  42. static struct at91_pm_data pm_data = {
  43. .standby_mode = 0,
  44. .suspend_mode = AT91_PM_SLOW_CLOCK,
  45. };
  46. #define at91_ramc_read(id, field) \
  47. __raw_readl(pm_data.ramc[id] + field)
  48. #define at91_ramc_write(id, field, value) \
  49. __raw_writel(value, pm_data.ramc[id] + field)
  50. static int at91_pm_valid_state(suspend_state_t state)
  51. {
  52. switch (state) {
  53. case PM_SUSPEND_ON:
  54. case PM_SUSPEND_STANDBY:
  55. case PM_SUSPEND_MEM:
  56. return 1;
  57. default:
  58. return 0;
  59. }
  60. }
  61. static int canary = 0xA5A5A5A5;
  62. static struct at91_pm_bu {
  63. int suspended;
  64. unsigned long reserved;
  65. phys_addr_t canary;
  66. phys_addr_t resume;
  67. } *pm_bu;
  68. /*
  69. * Called after processes are frozen, but before we shutdown devices.
  70. */
  71. static int at91_pm_begin(suspend_state_t state)
  72. {
  73. switch (state) {
  74. case PM_SUSPEND_MEM:
  75. pm_data.mode = pm_data.suspend_mode;
  76. break;
  77. case PM_SUSPEND_STANDBY:
  78. pm_data.mode = pm_data.standby_mode;
  79. break;
  80. default:
  81. pm_data.mode = -1;
  82. }
  83. return 0;
  84. }
  85. /*
  86. * Verify that all the clocks are correct before entering
  87. * slow-clock mode.
  88. */
  89. static int at91_pm_verify_clocks(void)
  90. {
  91. unsigned long scsr;
  92. int i;
  93. scsr = readl(pm_data.pmc + AT91_PMC_SCSR);
  94. /* USB must not be using PLLB */
  95. if ((scsr & pm_data.uhp_udp_mask) != 0) {
  96. pr_err("AT91: PM - Suspend-to-RAM with USB still active\n");
  97. return 0;
  98. }
  99. /* PCK0..PCK3 must be disabled, or configured to use clk32k */
  100. for (i = 0; i < 4; i++) {
  101. u32 css;
  102. if ((scsr & (AT91_PMC_PCK0 << i)) == 0)
  103. continue;
  104. css = readl(pm_data.pmc + AT91_PMC_PCKR(i)) & AT91_PMC_CSS;
  105. if (css != AT91_PMC_CSS_SLOW) {
  106. pr_err("AT91: PM - Suspend-to-RAM with PCK%d src %d\n", i, css);
  107. return 0;
  108. }
  109. }
  110. return 1;
  111. }
  112. /*
  113. * Call this from platform driver suspend() to see how deeply to suspend.
  114. * For example, some controllers (like OHCI) need one of the PLL clocks
  115. * in order to act as a wakeup source, and those are not available when
  116. * going into slow clock mode.
  117. *
  118. * REVISIT: generalize as clk_will_be_available(clk)? Other platforms have
  119. * the very same problem (but not using at91 main_clk), and it'd be better
  120. * to add one generic API rather than lots of platform-specific ones.
  121. */
  122. int at91_suspend_entering_slow_clock(void)
  123. {
  124. return (pm_data.mode >= AT91_PM_SLOW_CLOCK);
  125. }
  126. EXPORT_SYMBOL(at91_suspend_entering_slow_clock);
  127. static void (*at91_suspend_sram_fn)(struct at91_pm_data *);
  128. extern void at91_pm_suspend_in_sram(struct at91_pm_data *pm_data);
  129. extern u32 at91_pm_suspend_in_sram_sz;
  130. static int at91_suspend_finish(unsigned long val)
  131. {
  132. flush_cache_all();
  133. outer_disable();
  134. at91_suspend_sram_fn(&pm_data);
  135. return 0;
  136. }
  137. static void at91_pm_suspend(suspend_state_t state)
  138. {
  139. if (pm_data.mode == AT91_PM_BACKUP) {
  140. pm_bu->suspended = 1;
  141. cpu_suspend(0, at91_suspend_finish);
  142. /* The SRAM is lost between suspend cycles */
  143. at91_suspend_sram_fn = fncpy(at91_suspend_sram_fn,
  144. &at91_pm_suspend_in_sram,
  145. at91_pm_suspend_in_sram_sz);
  146. } else {
  147. at91_suspend_finish(0);
  148. }
  149. outer_resume();
  150. }
  151. /*
  152. * STANDBY mode has *all* drivers suspended; ignores irqs not marked as 'wakeup'
  153. * event sources; and reduces DRAM power. But otherwise it's identical to
  154. * PM_SUSPEND_ON: cpu idle, and nothing fancy done with main or cpu clocks.
  155. *
  156. * AT91_PM_SLOW_CLOCK is like STANDBY plus slow clock mode, so drivers must
  157. * suspend more deeply, the master clock switches to the clk32k and turns off
  158. * the main oscillator
  159. *
  160. * AT91_PM_BACKUP turns off the whole SoC after placing the DDR in self refresh
  161. */
  162. static int at91_pm_enter(suspend_state_t state)
  163. {
  164. #ifdef CONFIG_PINCTRL_AT91
  165. at91_pinctrl_gpio_suspend();
  166. #endif
  167. switch (state) {
  168. case PM_SUSPEND_MEM:
  169. case PM_SUSPEND_STANDBY:
  170. /*
  171. * Ensure that clocks are in a valid state.
  172. */
  173. if ((pm_data.mode >= AT91_PM_SLOW_CLOCK) &&
  174. !at91_pm_verify_clocks())
  175. goto error;
  176. at91_pm_suspend(state);
  177. break;
  178. case PM_SUSPEND_ON:
  179. cpu_do_idle();
  180. break;
  181. default:
  182. pr_debug("AT91: PM - bogus suspend state %d\n", state);
  183. goto error;
  184. }
  185. error:
  186. #ifdef CONFIG_PINCTRL_AT91
  187. at91_pinctrl_gpio_resume();
  188. #endif
  189. return 0;
  190. }
  191. /*
  192. * Called right prior to thawing processes.
  193. */
  194. static void at91_pm_end(void)
  195. {
  196. }
  197. static const struct platform_suspend_ops at91_pm_ops = {
  198. .valid = at91_pm_valid_state,
  199. .begin = at91_pm_begin,
  200. .enter = at91_pm_enter,
  201. .end = at91_pm_end,
  202. };
  203. static struct platform_device at91_cpuidle_device = {
  204. .name = "cpuidle-at91",
  205. };
  206. /*
  207. * The AT91RM9200 goes into self-refresh mode with this command, and will
  208. * terminate self-refresh automatically on the next SDRAM access.
  209. *
  210. * Self-refresh mode is exited as soon as a memory access is made, but we don't
  211. * know for sure when that happens. However, we need to restore the low-power
  212. * mode if it was enabled before going idle. Restoring low-power mode while
  213. * still in self-refresh is "not recommended", but seems to work.
  214. */
  215. static void at91rm9200_standby(void)
  216. {
  217. asm volatile(
  218. "b 1f\n\t"
  219. ".align 5\n\t"
  220. "1: mcr p15, 0, %0, c7, c10, 4\n\t"
  221. " str %2, [%1, %3]\n\t"
  222. " mcr p15, 0, %0, c7, c0, 4\n\t"
  223. :
  224. : "r" (0), "r" (pm_data.ramc[0]),
  225. "r" (1), "r" (AT91_MC_SDRAMC_SRR));
  226. }
  227. /* We manage both DDRAM/SDRAM controllers, we need more than one value to
  228. * remember.
  229. */
  230. static void at91_ddr_standby(void)
  231. {
  232. /* Those two values allow us to delay self-refresh activation
  233. * to the maximum. */
  234. u32 lpr0, lpr1 = 0;
  235. u32 mdr, saved_mdr0, saved_mdr1 = 0;
  236. u32 saved_lpr0, saved_lpr1 = 0;
  237. /* LPDDR1 --> force DDR2 mode during self-refresh */
  238. saved_mdr0 = at91_ramc_read(0, AT91_DDRSDRC_MDR);
  239. if ((saved_mdr0 & AT91_DDRSDRC_MD) == AT91_DDRSDRC_MD_LOW_POWER_DDR) {
  240. mdr = saved_mdr0 & ~AT91_DDRSDRC_MD;
  241. mdr |= AT91_DDRSDRC_MD_DDR2;
  242. at91_ramc_write(0, AT91_DDRSDRC_MDR, mdr);
  243. }
  244. if (pm_data.ramc[1]) {
  245. saved_lpr1 = at91_ramc_read(1, AT91_DDRSDRC_LPR);
  246. lpr1 = saved_lpr1 & ~AT91_DDRSDRC_LPCB;
  247. lpr1 |= AT91_DDRSDRC_LPCB_SELF_REFRESH;
  248. saved_mdr1 = at91_ramc_read(1, AT91_DDRSDRC_MDR);
  249. if ((saved_mdr1 & AT91_DDRSDRC_MD) == AT91_DDRSDRC_MD_LOW_POWER_DDR) {
  250. mdr = saved_mdr1 & ~AT91_DDRSDRC_MD;
  251. mdr |= AT91_DDRSDRC_MD_DDR2;
  252. at91_ramc_write(1, AT91_DDRSDRC_MDR, mdr);
  253. }
  254. }
  255. saved_lpr0 = at91_ramc_read(0, AT91_DDRSDRC_LPR);
  256. lpr0 = saved_lpr0 & ~AT91_DDRSDRC_LPCB;
  257. lpr0 |= AT91_DDRSDRC_LPCB_SELF_REFRESH;
  258. /* self-refresh mode now */
  259. at91_ramc_write(0, AT91_DDRSDRC_LPR, lpr0);
  260. if (pm_data.ramc[1])
  261. at91_ramc_write(1, AT91_DDRSDRC_LPR, lpr1);
  262. cpu_do_idle();
  263. at91_ramc_write(0, AT91_DDRSDRC_MDR, saved_mdr0);
  264. at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr0);
  265. if (pm_data.ramc[1]) {
  266. at91_ramc_write(0, AT91_DDRSDRC_MDR, saved_mdr1);
  267. at91_ramc_write(1, AT91_DDRSDRC_LPR, saved_lpr1);
  268. }
  269. }
  270. static void sama5d3_ddr_standby(void)
  271. {
  272. u32 lpr0;
  273. u32 saved_lpr0;
  274. saved_lpr0 = at91_ramc_read(0, AT91_DDRSDRC_LPR);
  275. lpr0 = saved_lpr0 & ~AT91_DDRSDRC_LPCB;
  276. lpr0 |= AT91_DDRSDRC_LPCB_POWER_DOWN;
  277. at91_ramc_write(0, AT91_DDRSDRC_LPR, lpr0);
  278. cpu_do_idle();
  279. at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr0);
  280. }
  281. /* We manage both DDRAM/SDRAM controllers, we need more than one value to
  282. * remember.
  283. */
  284. static void at91sam9_sdram_standby(void)
  285. {
  286. u32 lpr0, lpr1 = 0;
  287. u32 saved_lpr0, saved_lpr1 = 0;
  288. if (pm_data.ramc[1]) {
  289. saved_lpr1 = at91_ramc_read(1, AT91_SDRAMC_LPR);
  290. lpr1 = saved_lpr1 & ~AT91_SDRAMC_LPCB;
  291. lpr1 |= AT91_SDRAMC_LPCB_SELF_REFRESH;
  292. }
  293. saved_lpr0 = at91_ramc_read(0, AT91_SDRAMC_LPR);
  294. lpr0 = saved_lpr0 & ~AT91_SDRAMC_LPCB;
  295. lpr0 |= AT91_SDRAMC_LPCB_SELF_REFRESH;
  296. /* self-refresh mode now */
  297. at91_ramc_write(0, AT91_SDRAMC_LPR, lpr0);
  298. if (pm_data.ramc[1])
  299. at91_ramc_write(1, AT91_SDRAMC_LPR, lpr1);
  300. cpu_do_idle();
  301. at91_ramc_write(0, AT91_SDRAMC_LPR, saved_lpr0);
  302. if (pm_data.ramc[1])
  303. at91_ramc_write(1, AT91_SDRAMC_LPR, saved_lpr1);
  304. }
  305. struct ramc_info {
  306. void (*idle)(void);
  307. unsigned int memctrl;
  308. };
  309. static const struct ramc_info ramc_infos[] __initconst = {
  310. { .idle = at91rm9200_standby, .memctrl = AT91_MEMCTRL_MC},
  311. { .idle = at91sam9_sdram_standby, .memctrl = AT91_MEMCTRL_SDRAMC},
  312. { .idle = at91_ddr_standby, .memctrl = AT91_MEMCTRL_DDRSDR},
  313. { .idle = sama5d3_ddr_standby, .memctrl = AT91_MEMCTRL_DDRSDR},
  314. };
  315. static const struct of_device_id ramc_ids[] __initconst = {
  316. { .compatible = "atmel,at91rm9200-sdramc", .data = &ramc_infos[0] },
  317. { .compatible = "atmel,at91sam9260-sdramc", .data = &ramc_infos[1] },
  318. { .compatible = "atmel,at91sam9g45-ddramc", .data = &ramc_infos[2] },
  319. { .compatible = "atmel,sama5d3-ddramc", .data = &ramc_infos[3] },
  320. { /*sentinel*/ }
  321. };
  322. static __init void at91_dt_ramc(void)
  323. {
  324. struct device_node *np;
  325. const struct of_device_id *of_id;
  326. int idx = 0;
  327. void *standby = NULL;
  328. const struct ramc_info *ramc;
  329. for_each_matching_node_and_match(np, ramc_ids, &of_id) {
  330. pm_data.ramc[idx] = of_iomap(np, 0);
  331. if (!pm_data.ramc[idx])
  332. panic(pr_fmt("unable to map ramc[%d] cpu registers\n"), idx);
  333. ramc = of_id->data;
  334. if (!standby)
  335. standby = ramc->idle;
  336. pm_data.memctrl = ramc->memctrl;
  337. idx++;
  338. }
  339. if (!idx)
  340. panic(pr_fmt("unable to find compatible ram controller node in dtb\n"));
  341. if (!standby) {
  342. pr_warn("ramc no standby function available\n");
  343. return;
  344. }
  345. at91_cpuidle_device.dev.platform_data = standby;
  346. }
  347. static void at91rm9200_idle(void)
  348. {
  349. /*
  350. * Disable the processor clock. The processor will be automatically
  351. * re-enabled by an interrupt or by a reset.
  352. */
  353. writel(AT91_PMC_PCK, pm_data.pmc + AT91_PMC_SCDR);
  354. }
  355. static void at91sam9_idle(void)
  356. {
  357. writel(AT91_PMC_PCK, pm_data.pmc + AT91_PMC_SCDR);
  358. cpu_do_idle();
  359. }
  360. static void __init at91_pm_sram_init(void)
  361. {
  362. struct gen_pool *sram_pool;
  363. phys_addr_t sram_pbase;
  364. unsigned long sram_base;
  365. struct device_node *node;
  366. struct platform_device *pdev = NULL;
  367. for_each_compatible_node(node, NULL, "mmio-sram") {
  368. pdev = of_find_device_by_node(node);
  369. if (pdev) {
  370. of_node_put(node);
  371. break;
  372. }
  373. }
  374. if (!pdev) {
  375. pr_warn("%s: failed to find sram device!\n", __func__);
  376. return;
  377. }
  378. sram_pool = gen_pool_get(&pdev->dev, NULL);
  379. if (!sram_pool) {
  380. pr_warn("%s: sram pool unavailable!\n", __func__);
  381. return;
  382. }
  383. sram_base = gen_pool_alloc(sram_pool, at91_pm_suspend_in_sram_sz);
  384. if (!sram_base) {
  385. pr_warn("%s: unable to alloc sram!\n", __func__);
  386. return;
  387. }
  388. sram_pbase = gen_pool_virt_to_phys(sram_pool, sram_base);
  389. at91_suspend_sram_fn = __arm_ioremap_exec(sram_pbase,
  390. at91_pm_suspend_in_sram_sz, false);
  391. if (!at91_suspend_sram_fn) {
  392. pr_warn("SRAM: Could not map\n");
  393. return;
  394. }
  395. /* Copy the pm suspend handler to SRAM */
  396. at91_suspend_sram_fn = fncpy(at91_suspend_sram_fn,
  397. &at91_pm_suspend_in_sram, at91_pm_suspend_in_sram_sz);
  398. }
  399. static void __init at91_pm_backup_init(void)
  400. {
  401. struct gen_pool *sram_pool;
  402. struct device_node *np;
  403. struct platform_device *pdev = NULL;
  404. if ((pm_data.standby_mode != AT91_PM_BACKUP) &&
  405. (pm_data.suspend_mode != AT91_PM_BACKUP))
  406. return;
  407. pm_bu = NULL;
  408. np = of_find_compatible_node(NULL, NULL, "atmel,sama5d2-shdwc");
  409. if (!np) {
  410. pr_warn("%s: failed to find shdwc!\n", __func__);
  411. return;
  412. }
  413. pm_data.shdwc = of_iomap(np, 0);
  414. of_node_put(np);
  415. np = of_find_compatible_node(NULL, NULL, "atmel,sama5d2-sfrbu");
  416. if (!np) {
  417. pr_warn("%s: failed to find sfrbu!\n", __func__);
  418. goto sfrbu_fail;
  419. }
  420. pm_data.sfrbu = of_iomap(np, 0);
  421. of_node_put(np);
  422. pm_bu = NULL;
  423. np = of_find_compatible_node(NULL, NULL, "atmel,sama5d2-securam");
  424. if (!np)
  425. goto securam_fail;
  426. pdev = of_find_device_by_node(np);
  427. of_node_put(np);
  428. if (!pdev) {
  429. pr_warn("%s: failed to find securam device!\n", __func__);
  430. goto securam_fail;
  431. }
  432. sram_pool = gen_pool_get(&pdev->dev, NULL);
  433. if (!sram_pool) {
  434. pr_warn("%s: securam pool unavailable!\n", __func__);
  435. goto securam_fail;
  436. }
  437. pm_bu = (void *)gen_pool_alloc(sram_pool, sizeof(struct at91_pm_bu));
  438. if (!pm_bu) {
  439. pr_warn("%s: unable to alloc securam!\n", __func__);
  440. goto securam_fail;
  441. }
  442. pm_bu->suspended = 0;
  443. pm_bu->canary = __pa_symbol(&canary);
  444. pm_bu->resume = __pa_symbol(cpu_resume);
  445. return;
  446. sfrbu_fail:
  447. iounmap(pm_data.shdwc);
  448. pm_data.shdwc = NULL;
  449. securam_fail:
  450. iounmap(pm_data.sfrbu);
  451. pm_data.sfrbu = NULL;
  452. if (pm_data.standby_mode == AT91_PM_BACKUP)
  453. pm_data.standby_mode = AT91_PM_SLOW_CLOCK;
  454. if (pm_data.suspend_mode == AT91_PM_BACKUP)
  455. pm_data.suspend_mode = AT91_PM_SLOW_CLOCK;
  456. }
  457. struct pmc_info {
  458. unsigned long uhp_udp_mask;
  459. };
  460. static const struct pmc_info pmc_infos[] __initconst = {
  461. { .uhp_udp_mask = AT91RM9200_PMC_UHP | AT91RM9200_PMC_UDP },
  462. { .uhp_udp_mask = AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP },
  463. { .uhp_udp_mask = AT91SAM926x_PMC_UHP },
  464. };
  465. static const struct of_device_id atmel_pmc_ids[] __initconst = {
  466. { .compatible = "atmel,at91rm9200-pmc", .data = &pmc_infos[0] },
  467. { .compatible = "atmel,at91sam9260-pmc", .data = &pmc_infos[1] },
  468. { .compatible = "atmel,at91sam9g45-pmc", .data = &pmc_infos[2] },
  469. { .compatible = "atmel,at91sam9n12-pmc", .data = &pmc_infos[1] },
  470. { .compatible = "atmel,at91sam9x5-pmc", .data = &pmc_infos[1] },
  471. { .compatible = "atmel,sama5d3-pmc", .data = &pmc_infos[1] },
  472. { .compatible = "atmel,sama5d2-pmc", .data = &pmc_infos[1] },
  473. { /* sentinel */ },
  474. };
  475. static void __init at91_pm_init(void (*pm_idle)(void))
  476. {
  477. struct device_node *pmc_np;
  478. const struct of_device_id *of_id;
  479. const struct pmc_info *pmc;
  480. if (at91_cpuidle_device.dev.platform_data)
  481. platform_device_register(&at91_cpuidle_device);
  482. pmc_np = of_find_matching_node_and_match(NULL, atmel_pmc_ids, &of_id);
  483. pm_data.pmc = of_iomap(pmc_np, 0);
  484. if (!pm_data.pmc) {
  485. pr_err("AT91: PM not supported, PMC not found\n");
  486. return;
  487. }
  488. pmc = of_id->data;
  489. pm_data.uhp_udp_mask = pmc->uhp_udp_mask;
  490. if (pm_idle)
  491. arm_pm_idle = pm_idle;
  492. at91_pm_sram_init();
  493. if (at91_suspend_sram_fn) {
  494. suspend_set_ops(&at91_pm_ops);
  495. pr_info("AT91: PM: standby: %s, suspend: %s\n",
  496. pm_modes[pm_data.standby_mode].pattern,
  497. pm_modes[pm_data.suspend_mode].pattern);
  498. } else {
  499. pr_info("AT91: PM not supported, due to no SRAM allocated\n");
  500. }
  501. }
  502. void __init at91rm9200_pm_init(void)
  503. {
  504. if (!IS_ENABLED(CONFIG_SOC_AT91RM9200))
  505. return;
  506. at91_dt_ramc();
  507. /*
  508. * AT91RM9200 SDRAM low-power mode cannot be used with self-refresh.
  509. */
  510. at91_ramc_write(0, AT91_MC_SDRAMC_LPR, 0);
  511. at91_pm_init(at91rm9200_idle);
  512. }
  513. void __init at91sam9_pm_init(void)
  514. {
  515. if (!IS_ENABLED(CONFIG_SOC_AT91SAM9))
  516. return;
  517. at91_dt_ramc();
  518. at91_pm_init(at91sam9_idle);
  519. }
  520. void __init sama5_pm_init(void)
  521. {
  522. if (!IS_ENABLED(CONFIG_SOC_SAMA5))
  523. return;
  524. at91_dt_ramc();
  525. at91_pm_init(NULL);
  526. }
  527. void __init sama5d2_pm_init(void)
  528. {
  529. if (!IS_ENABLED(CONFIG_SOC_SAMA5D2))
  530. return;
  531. at91_pm_backup_init();
  532. sama5_pm_init();
  533. }
  534. static int __init at91_pm_modes_select(char *str)
  535. {
  536. char *s;
  537. substring_t args[MAX_OPT_ARGS];
  538. int standby, suspend;
  539. if (!str)
  540. return 0;
  541. s = strsep(&str, ",");
  542. standby = match_token(s, pm_modes, args);
  543. if (standby < 0)
  544. return 0;
  545. suspend = match_token(str, pm_modes, args);
  546. if (suspend < 0)
  547. return 0;
  548. pm_data.standby_mode = standby;
  549. pm_data.suspend_mode = suspend;
  550. return 0;
  551. }
  552. early_param("atmel.pm_modes", at91_pm_modes_select);