Lines Matching +full:suspend +full:- +full:mode

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * arch/arm/mach-at91/pm.c
15 #include <linux/suspend.h>
23 #include <asm/suspend.h>
32 * called as part of the generic suspend/resume path.
40 int (*config_shdwc_ws)(void __iomem *shdwc, u32 *mode, u32 *polarity);
41 int (*config_pmc_ws)(void __iomem *pmc, u32 mode, u32 polarity);
56 { AT91_PM_ULP0_FAST, "ulp0-fast" },
59 { -1, NULL },
106 { .compatible = "atmel,sama5d2-gem", .data = &ws_info[0] },
107 { .compatible = "atmel,at91rm9200-rtc", .data = &ws_info[1] },
108 { .compatible = "atmel,sama5d3-udc", .data = &ws_info[2] },
109 { .compatible = "atmel,at91rm9200-ohci", .data = &ws_info[2] },
110 { .compatible = "usb-ohci", .data = &ws_info[2] },
111 { .compatible = "atmel,at91sam9g45-ehci", .data = &ws_info[2] },
112 { .compatible = "usb-ehci", .data = &ws_info[2] },
113 { .compatible = "atmel,sama5d2-sdhci", .data = &ws_info[3] },
118 { .compatible = "atmel,at91sam9x5-rtc", .data = &ws_info[1] },
119 { .compatible = "atmel,at91rm9200-ohci", .data = &ws_info[2] },
120 { .compatible = "usb-ohci", .data = &ws_info[2] },
121 { .compatible = "atmel,at91sam9g45-ehci", .data = &ws_info[2] },
122 { .compatible = "usb-ehci", .data = &ws_info[2] },
123 { .compatible = "atmel,at91sam9260-rtt", .data = &ws_info[4] },
124 { .compatible = "cdns,sam9x60-macb", .data = &ws_info[5] },
134 unsigned int mode = 0, polarity = 0, val = 0; in at91_pm_config_ws() local
140 return -EPERM; in at91_pm_config_ws()
143 writel(mode, soc_pm.data.pmc + AT91_PMC_FSMR); in at91_pm_config_ws()
148 soc_pm.config_shdwc_ws(soc_pm.data.shdwc, &mode, &polarity); in at91_pm_config_ws()
159 if (device_may_wakeup(&pdev->dev)) { in at91_pm_config_ws()
160 wsi = match->data; in at91_pm_config_ws()
163 if (wsi->shdwc_mr_bit && !(val & wsi->shdwc_mr_bit)) in at91_pm_config_ws()
166 mode |= wsi->pmc_fsmr_bit; in at91_pm_config_ws()
167 if (wsi->set_polarity) in at91_pm_config_ws()
168 polarity |= wsi->pmc_fsmr_bit; in at91_pm_config_ws()
172 put_device(&pdev->dev); in at91_pm_config_ws()
175 if (mode) { in at91_pm_config_ws()
177 soc_pm.config_pmc_ws(soc_pm.data.pmc, mode, polarity); in at91_pm_config_ws()
182 return mode ? 0 : -EPERM; in at91_pm_config_ws()
185 static int at91_sama5d2_config_shdwc_ws(void __iomem *shdwc, u32 *mode, in at91_sama5d2_config_shdwc_ws() argument
192 *mode |= (val & 0x3ff); in at91_sama5d2_config_shdwc_ws()
198 static int at91_sama5d2_config_pmc_ws(void __iomem *pmc, u32 mode, u32 polarity) in at91_sama5d2_config_pmc_ws() argument
200 writel(mode, pmc + AT91_PMC_FSMR); in at91_sama5d2_config_pmc_ws()
206 static int at91_sam9x60_config_pmc_ws(void __iomem *pmc, u32 mode, u32 polarity) in at91_sam9x60_config_pmc_ws() argument
208 writel(mode, pmc + AT91_PMC_FSMR); in at91_sam9x60_config_pmc_ws()
220 soc_pm.data.mode = soc_pm.data.suspend_mode; in at91_pm_begin()
224 soc_pm.data.mode = soc_pm.data.standby_mode; in at91_pm_begin()
228 soc_pm.data.mode = -1; in at91_pm_begin()
231 return at91_pm_config_ws(soc_pm.data.mode, true); in at91_pm_begin()
236 * slow-clock mode.
247 pr_err("AT91: PM - Suspend-to-RAM with USB still active\n"); in at91_pm_verify_clocks()
259 pr_err("AT91: PM - Suspend-to-RAM with PCK%d src %d\n", i, css); in at91_pm_verify_clocks()
268 * Call this from platform driver suspend() to see how deeply to suspend.
271 * going into slow clock mode.
275 * to add one generic API rather than lots of platform-specific ones.
279 return (soc_pm.data.mode >= AT91_PM_ULP0); in at91_suspend_entering_slow_clock()
299 if (soc_pm.data.mode == AT91_PM_BACKUP) { in at91_pm_suspend()
300 pm_bu->suspended = 1; in at91_pm_suspend()
304 /* The SRAM is lost between suspend cycles */ in at91_pm_suspend()
316 * STANDBY mode has *all* drivers suspended; ignores irqs not marked as 'wakeup'
320 * AT91_PM_ULP0 is like STANDBY plus slow clock mode, so drivers must
321 * suspend more deeply, the master clock switches to the clk32k and turns off
338 if (soc_pm.data.mode >= AT91_PM_ULP0 && in at91_pm_enter()
351 pr_debug("AT91: PM - bogus suspend state %d\n", state); in at91_pm_enter()
367 at91_pm_config_ws(soc_pm.data.mode, false); in at91_pm_end()
379 .name = "cpuidle-at91",
383 * The AT91RM9200 goes into self-refresh mode with this command, and will
384 * terminate self-refresh automatically on the next SDRAM access.
386 * Self-refresh mode is exited as soon as a memory access is made, but we don't
387 * know for sure when that happens. However, we need to restore the low-power
388 * mode if it was enabled before going idle. Restoring low-power mode while
389 * still in self-refresh is "not recommended", but seems to work.
409 /* Those two values allow us to delay self-refresh activation in at91_ddr_standby()
415 /* LPDDR1 --> force DDR2 mode during self-refresh */ in at91_ddr_standby()
439 /* self-refresh mode now */ in at91_ddr_standby()
488 /* self-refresh mode now */ in at91sam9_sdram_standby()
513 { .compatible = "atmel,at91rm9200-sdramc", .data = &ramc_infos[0] },
514 { .compatible = "atmel,at91sam9260-sdramc", .data = &ramc_infos[1] },
515 { .compatible = "atmel,at91sam9g45-ddramc", .data = &ramc_infos[2] },
516 { .compatible = "atmel,sama5d3-ddramc", .data = &ramc_infos[3] },
533 ramc = of_id->data; in at91_dt_ramc()
535 standby = ramc->idle; in at91_dt_ramc()
536 soc_pm.data.memctrl = ramc->memctrl; in at91_dt_ramc()
556 * re-enabled by an interrupt or by a reset. in at91rm9200_idle()
575 for_each_compatible_node(node, NULL, "mmio-sram") { in at91_pm_sram_init()
588 sram_pool = gen_pool_get(&pdev->dev, NULL); in at91_pm_sram_init()
608 /* Copy the pm suspend handler to SRAM */ in at91_pm_sram_init()
614 put_device(&pdev->dev); in at91_pm_sram_init()
629 int ret = -ENODEV; in at91_pm_backup_init()
632 return -EPERM; in at91_pm_backup_init()
637 np = of_find_compatible_node(NULL, NULL, "atmel,sama5d2-sfrbu"); in at91_pm_backup_init()
646 np = of_find_compatible_node(NULL, NULL, "atmel,sama5d2-securam"); in at91_pm_backup_init()
657 sram_pool = gen_pool_get(&pdev->dev, NULL); in at91_pm_backup_init()
666 ret = -ENOMEM; in at91_pm_backup_init()
670 pm_bu->suspended = 0; in at91_pm_backup_init()
671 pm_bu->canary = __pa_symbol(&canary); in at91_pm_backup_init()
672 pm_bu->resume = __pa_symbol(cpu_resume); in at91_pm_backup_init()
677 put_device(&pdev->dev); in at91_pm_backup_init()
696 { .compatible = "atmel,sama5d2-shdwc" },
697 { .compatible = "microchip,sam9x60-shdwc" },
773 { .compatible = "atmel,at91rm9200-pmc", .data = &pmc_infos[0] },
774 { .compatible = "atmel,at91sam9260-pmc", .data = &pmc_infos[1] },
775 { .compatible = "atmel,at91sam9261-pmc", .data = &pmc_infos[1] },
776 { .compatible = "atmel,at91sam9263-pmc", .data = &pmc_infos[1] },
777 { .compatible = "atmel,at91sam9g45-pmc", .data = &pmc_infos[2] },
778 { .compatible = "atmel,at91sam9n12-pmc", .data = &pmc_infos[1] },
779 { .compatible = "atmel,at91sam9rl-pmc", .data = &pmc_infos[3] },
780 { .compatible = "atmel,at91sam9x5-pmc", .data = &pmc_infos[1] },
781 { .compatible = "atmel,sama5d3-pmc", .data = &pmc_infos[1] },
782 { .compatible = "atmel,sama5d4-pmc", .data = &pmc_infos[1] },
783 { .compatible = "atmel,sama5d2-pmc", .data = &pmc_infos[1] },
784 { .compatible = "microchip,sam9x60-pmc", .data = &pmc_infos[4] },
790 u8 i, standby = 0, suspend = 0; in at91_pm_modes_validate() local
791 int mode; in at91_pm_modes_validate() local
794 if (standby && suspend) in at91_pm_modes_validate()
802 if (modes[i] == soc_pm.data.suspend_mode && !suspend) { in at91_pm_modes_validate()
803 suspend = 1; in at91_pm_modes_validate()
810 mode = AT91_PM_ULP0; in at91_pm_modes_validate()
812 mode = AT91_PM_STANDBY; in at91_pm_modes_validate()
814 pr_warn("AT91: PM: %s mode not supported! Using %s.\n", in at91_pm_modes_validate()
816 pm_modes[mode].pattern); in at91_pm_modes_validate()
817 soc_pm.data.standby_mode = mode; in at91_pm_modes_validate()
820 if (!suspend) { in at91_pm_modes_validate()
822 mode = AT91_PM_STANDBY; in at91_pm_modes_validate()
824 mode = AT91_PM_ULP0; in at91_pm_modes_validate()
826 pr_warn("AT91: PM: %s mode not supported! Using %s.\n", in at91_pm_modes_validate()
828 pm_modes[mode].pattern); in at91_pm_modes_validate()
829 soc_pm.data.suspend_mode = mode; in at91_pm_modes_validate()
850 pmc = of_id->data; in at91_pm_init()
851 soc_pm.data.uhp_udp_mask = pmc->uhp_udp_mask; in at91_pm_init()
852 soc_pm.data.pmc_mckr_offset = pmc->mckr; in at91_pm_init()
853 soc_pm.data.pmc_version = pmc->version; in at91_pm_init()
862 pr_info("AT91: PM: standby: %s, suspend: %s\n", in at91_pm_init()
876 * Force STANDBY and ULP0 mode to avoid calling in at91rm9200_pm_init()
886 * AT91RM9200 SDRAM low-power mode cannot be used with self-refresh. in at91rm9200_pm_init()
917 * Force STANDBY and ULP0 mode to avoid calling in at91sam9_pm_init()
966 int standby, suspend; in at91_pm_modes_select() local
976 suspend = match_token(str, pm_modes, args); in at91_pm_modes_select()
977 if (suspend < 0) in at91_pm_modes_select()
981 soc_pm.data.suspend_mode = suspend; in at91_pm_modes_select()