Lines Matching +full:sama5d4 +full:- +full:pmc
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * arch/arm/mach-at91/pm.c
35 * struct at91_pm_bu - AT91 power management backup unit data structure
52 * struct at91_pm_sfrbu_regs - registers mapping for SFRBU
65 * enum at91_pm_eth_clk - Ethernet clock indexes
77 * enum at91_pm_eth - Ethernet controller indexes
89 * struct at91_pm_quirk_eth - AT91 PM Ethernet quirks
107 * struct at91_pm_quirks - AT91 PM quirks
115 * struct at91_soc_pm - AT91 SoC power management data structure
117 * @config_pmc_ws: wakeup srouces configuration function for PMC
127 int (*config_pmc_ws)(void __iomem *pmc, u32 mode, u32 polarity);
137 * enum at91_pm_iomaps - IOs that needs to be mapped for different PM modes
160 { AT91_PM_ULP0_FAST, "ulp0-fast" },
163 { -1, NULL },
203 { .compatible = "atmel,sama5d2-gem", .data = &ws_info[0] },
204 { .compatible = "atmel,sama5d2-rtc", .data = &ws_info[1] },
205 { .compatible = "atmel,sama5d3-udc", .data = &ws_info[2] },
206 { .compatible = "atmel,at91rm9200-ohci", .data = &ws_info[2] },
207 { .compatible = "usb-ohci", .data = &ws_info[2] },
208 { .compatible = "atmel,at91sam9g45-ehci", .data = &ws_info[2] },
209 { .compatible = "usb-ehci", .data = &ws_info[2] },
210 { .compatible = "atmel,sama5d2-sdhci", .data = &ws_info[3] },
215 { .compatible = "microchip,sam9x60-rtc", .data = &ws_info[1] },
216 { .compatible = "atmel,at91rm9200-ohci", .data = &ws_info[2] },
217 { .compatible = "usb-ohci", .data = &ws_info[2] },
218 { .compatible = "atmel,at91sam9g45-ehci", .data = &ws_info[2] },
219 { .compatible = "usb-ehci", .data = &ws_info[2] },
220 { .compatible = "microchip,sam9x60-rtt", .data = &ws_info[4] },
221 { .compatible = "cdns,sam9x60-macb", .data = &ws_info[5] },
226 { .compatible = "microchip,sama7g5-rtc", .data = &ws_info[1] },
227 { .compatible = "microchip,sama7g5-ohci", .data = &ws_info[2] },
228 { .compatible = "usb-ohci", .data = &ws_info[2] },
229 { .compatible = "atmel,at91sam9g45-ehci", .data = &ws_info[2] },
230 { .compatible = "usb-ehci", .data = &ws_info[2] },
231 { .compatible = "microchip,sama7g5-sdhci", .data = &ws_info[3] },
232 { .compatible = "microchip,sama7g5-rtt", .data = &ws_info[4] },
237 { .compatible = "microchip,sam9x7-rtc", .data = &ws_info[1] },
238 { .compatible = "microchip,sam9x7-rtt", .data = &ws_info[4] },
239 { .compatible = "microchip,sam9x7-gem", .data = &ws_info[5] },
254 if (!soc_pm.data.pmc || !soc_pm.data.shdwc || !soc_pm.ws_ids) in at91_pm_config_ws()
255 return -EPERM; in at91_pm_config_ws()
258 writel(mode, soc_pm.data.pmc + AT91_PMC_FSMR); in at91_pm_config_ws()
274 if (device_may_wakeup(&pdev->dev)) { in at91_pm_config_ws()
275 wsi = match->data; in at91_pm_config_ws()
278 if (wsi->shdwc_mr_bit && !(val & wsi->shdwc_mr_bit)) in at91_pm_config_ws()
281 mode |= wsi->pmc_fsmr_bit; in at91_pm_config_ws()
282 if (wsi->set_polarity) in at91_pm_config_ws()
283 polarity |= wsi->pmc_fsmr_bit; in at91_pm_config_ws()
287 put_device(&pdev->dev); in at91_pm_config_ws()
292 soc_pm.config_pmc_ws(soc_pm.data.pmc, mode, polarity); in at91_pm_config_ws()
297 return mode ? 0 : -EPERM; in at91_pm_config_ws()
313 static int at91_sama5d2_config_pmc_ws(void __iomem *pmc, u32 mode, u32 polarity) in at91_sama5d2_config_pmc_ws() argument
315 writel(mode, pmc + AT91_PMC_FSMR); in at91_sama5d2_config_pmc_ws()
316 writel(polarity, pmc + AT91_PMC_FSPR); in at91_sama5d2_config_pmc_ws()
321 static int at91_sam9x60_config_pmc_ws(void __iomem *pmc, u32 mode, u32 polarity) in at91_sam9x60_config_pmc_ws() argument
323 writel(mode, pmc + AT91_PMC_FSMR); in at91_sam9x60_config_pmc_ws()
333 if (!eth->np) in at91_pm_eth_quirk_is_valid()
337 if (!(eth->modes & BIT(soc_pm.data.mode))) in at91_pm_eth_quirk_is_valid()
340 if (!eth->dev) { in at91_pm_eth_quirk_is_valid()
342 pdev = of_find_device_by_node(eth->np); in at91_pm_eth_quirk_is_valid()
345 /* put_device(eth->dev) is called at the end of suspend. */ in at91_pm_eth_quirk_is_valid()
346 eth->dev = &pdev->dev; in at91_pm_eth_quirk_is_valid()
350 if (!device_may_wakeup(eth->dev)) in at91_pm_eth_quirk_is_valid()
383 if (suspend && eth->dns_modes & BIT(soc_pm.data.mode)) { in at91_pm_config_quirks()
389 if (ws->dev == eth->dev) in at91_pm_config_quirks()
404 ret = -EPERM; in at91_pm_config_quirks()
405 put_device(eth->dev); in at91_pm_config_quirks()
406 eth->dev = NULL; in at91_pm_config_quirks()
408 i--; in at91_pm_config_quirks()
414 clk_bulk_disable_unprepare(AT91_PM_ETH_MAX_CLK, eth->clks); in at91_pm_config_quirks()
417 eth->clks); in at91_pm_config_quirks()
421 * Release the reference to eth->dev taken in in at91_pm_config_quirks()
424 put_device(eth->dev); in at91_pm_config_quirks()
425 eth->dev = NULL; in at91_pm_config_quirks()
437 for (j = i; j >= 0; j--) { in at91_pm_config_quirks()
443 tmp = clk_bulk_prepare_enable(AT91_PM_ETH_MAX_CLK, eth->clks); in at91_pm_config_quirks()
451 * Release the reference to eth->dev taken in in at91_pm_config_quirks()
454 put_device(eth->dev); in at91_pm_config_quirks()
455 eth->dev = NULL; in at91_pm_config_quirks()
478 soc_pm.data.mode = -1; in at91_pm_begin()
486 soc_pm.bu->suspended = 1; in at91_pm_begin()
488 soc_pm.bu->suspended = 0; in at91_pm_begin()
495 * slow-clock mode.
502 scsr = readl(soc_pm.data.pmc + AT91_PMC_SCSR); in at91_pm_verify_clocks()
506 pr_err("AT91: PM - Suspend-to-RAM with USB still active\n"); in at91_pm_verify_clocks()
516 css = readl(soc_pm.data.pmc + AT91_PMC_PCKR(i)) & AT91_PMC_CSS; in at91_pm_verify_clocks()
518 pr_err("AT91: PM - Suspend-to-RAM with PCK%d src %d\n", i, css); in at91_pm_verify_clocks()
534 * to add one generic API rather than lots of platform-specific ones.
567 /* Store pull-down output impedance select. */ in at91_suspend_finish()
569 soc_pm.bu->ddr_phy_calibration[0] = modified_gray_code[index]; in at91_suspend_finish()
571 /* Store pull-up output impedance select. */ in at91_suspend_finish()
573 soc_pm.bu->ddr_phy_calibration[0] |= modified_gray_code[index]; in at91_suspend_finish()
575 /* Store pull-down on-die termination impedance select. */ in at91_suspend_finish()
577 soc_pm.bu->ddr_phy_calibration[0] |= modified_gray_code[index]; in at91_suspend_finish()
579 /* Store pull-up on-die termination impedance select. */ in at91_suspend_finish()
581 soc_pm.bu->ddr_phy_calibration[0] |= modified_gray_code[index]; in at91_suspend_finish()
589 soc_pm.bu->ddr_phy_calibration[i] = in at91_suspend_finish()
590 *((unsigned int *)soc_pm.memcs + (i - 1)); in at91_suspend_finish()
682 pr_debug("AT91: PM - bogus suspend state %d\n", state); in at91_pm_enter()
708 .name = "cpuidle-at91",
712 * The AT91RM9200 goes into self-refresh mode with this command, and will
713 * terminate self-refresh automatically on the next SDRAM access.
715 * Self-refresh mode is exited as soon as a memory access is made, but we don't
716 * know for sure when that happens. However, we need to restore the low-power
717 * mode if it was enabled before going idle. Restoring low-power mode while
718 * still in self-refresh is "not recommended", but seems to work.
738 /* Those two values allow us to delay self-refresh activation in at91_ddr_standby()
744 /* LPDDR1 --> force DDR2 mode during self-refresh */ in at91_ddr_standby()
768 /* self-refresh mode now */ in at91_ddr_standby()
817 /* self-refresh mode now */ in at91sam9_sdram_standby()
834 ratio = readl(soc_pm.data.pmc + AT91_PMC_RATIO); in sama7g5_standby()
837 * Place RAM into self-refresh after a maximum idle clocks. The maximum in sama7g5_standby()
844 writel(ratio & ~AT91_PMC_RATIO_RATIO, soc_pm.data.pmc + AT91_PMC_RATIO); in sama7g5_standby()
849 writel(ratio, soc_pm.data.pmc + AT91_PMC_RATIO); in sama7g5_standby()
867 { .compatible = "atmel,at91rm9200-sdramc", .data = &ramc_infos[0] },
868 { .compatible = "atmel,at91sam9260-sdramc", .data = &ramc_infos[1] },
869 { .compatible = "atmel,at91sam9g45-ddramc", .data = &ramc_infos[2] },
870 { .compatible = "atmel,sama5d3-ddramc", .data = &ramc_infos[3] },
871 { .compatible = "microchip,sama7g5-uddrc", .data = &ramc_infos[4], },
876 { .compatible = "microchip,sama7g5-ddr3phy", },
893 ret = -ENOMEM; in at91_dt_ramc()
898 ramc = of_id->data; in at91_dt_ramc()
901 standby = ramc->idle; in at91_dt_ramc()
902 soc_pm.data.memctrl = ramc->memctrl; in at91_dt_ramc()
910 ret = -ENODEV; in at91_dt_ramc()
919 ret = -ENOMEM; in at91_dt_ramc()
927 ret = -ENODEV; in at91_dt_ramc()
942 iounmap(soc_pm.data.ramc[--idx]); in at91_dt_ramc()
951 * re-enabled by an interrupt or by a reset. in at91rm9200_idle()
953 writel(AT91_PMC_PCK, soc_pm.data.pmc + AT91_PMC_SCDR); in at91rm9200_idle()
958 writel(AT91_PMC_PCK, soc_pm.data.pmc + AT91_PMC_SCDR); in at91sam9_idle()
970 for_each_compatible_node(node, NULL, "mmio-sram") { in at91_pm_sram_init()
983 sram_pool = gen_pool_get(&pdev->dev, NULL); in at91_pm_sram_init()
1009 put_device(&pdev->dev); in at91_pm_sram_init()
1052 int ret = -ENODEV, located = 0; in at91_pm_backup_init()
1056 return -EPERM; in at91_pm_backup_init()
1061 np = of_find_compatible_node(NULL, NULL, "atmel,sama5d2-securam"); in at91_pm_backup_init()
1072 sram_pool = gen_pool_get(&pdev->dev, NULL); in at91_pm_backup_init()
1081 ret = -ENOMEM; in at91_pm_backup_init()
1085 soc_pm.bu->suspended = 0; in at91_pm_backup_init()
1086 soc_pm.bu->canary = __pa_symbol(&canary); in at91_pm_backup_init()
1087 soc_pm.bu->resume = __pa_symbol(cpu_resume); in at91_pm_backup_init()
1097 put_device(&pdev->dev); in at91_pm_backup_init()
1123 soc_pm.data.mode = -1; in at91_pm_secure_init()
1134 { .compatible = "atmel,sama5d2-shdwc" },
1135 { .compatible = "microchip,sam9x60-shdwc" },
1136 { .compatible = "microchip,sama7g5-shdwc" },
1141 { .compatible = "atmel,sama5d3-gem" },
1142 { .compatible = "atmel,sama5d2-gem" },
1143 { .compatible = "atmel,sama5d29-gem" },
1144 { .compatible = "microchip,sama7g5-gem" },
1149 { .compatible = "atmel,sama5d3-macb" },
1150 { .compatible = "microchip,sama7g5-emac" },
1256 np = of_find_compatible_node(NULL, NULL, "atmel,sama5d2-sfrbu"); in at91_pm_modes_init()
1279 gmac->np = np; in at91_pm_modes_init()
1280 at91_pm_get_eth_clks(np, gmac->clks); in at91_pm_modes_init()
1285 if (at91_pm_eth_clks_empty(gmac->clks)) in at91_pm_modes_init()
1289 emac->np = np; in at91_pm_modes_init()
1290 ret = at91_pm_get_eth_clks(np, emac->clks); in at91_pm_modes_init()
1291 if (ret && at91_pm_eth_clks_empty(gmac->clks)) { in at91_pm_modes_init()
1292 of_node_put(gmac->np); in at91_pm_modes_init()
1293 of_node_put(emac->np); in at91_pm_modes_init()
1294 gmac->np = NULL; in at91_pm_modes_init()
1295 emac->np = NULL; in at91_pm_modes_init()
1359 { .compatible = "atmel,at91rm9200-pmc", .data = &pmc_infos[0] },
1360 { .compatible = "atmel,at91sam9260-pmc", .data = &pmc_infos[1] },
1361 { .compatible = "atmel,at91sam9261-pmc", .data = &pmc_infos[1] },
1362 { .compatible = "atmel,at91sam9263-pmc", .data = &pmc_infos[1] },
1363 { .compatible = "atmel,at91sam9g45-pmc", .data = &pmc_infos[2] },
1364 { .compatible = "atmel,at91sam9n12-pmc", .data = &pmc_infos[1] },
1365 { .compatible = "atmel,at91sam9rl-pmc", .data = &pmc_infos[3] },
1366 { .compatible = "atmel,at91sam9x5-pmc", .data = &pmc_infos[1] },
1367 { .compatible = "atmel,sama5d3-pmc", .data = &pmc_infos[1] },
1368 { .compatible = "atmel,sama5d4-pmc", .data = &pmc_infos[1] },
1369 { .compatible = "atmel,sama5d2-pmc", .data = &pmc_infos[1] },
1370 { .compatible = "microchip,sam9x60-pmc", .data = &pmc_infos[4] },
1371 { .compatible = "microchip,sam9x7-pmc", .data = &pmc_infos[4] },
1372 { .compatible = "microchip,sama7g5-pmc", .data = &pmc_infos[5] },
1425 const struct pmc_info *pmc; in at91_pm_init() local
1431 soc_pm.data.pmc = of_iomap(pmc_np, 0); in at91_pm_init()
1433 if (!soc_pm.data.pmc) { in at91_pm_init()
1434 pr_err("AT91: PM not supported, PMC not found\n"); in at91_pm_init()
1438 pmc = of_id->data; in at91_pm_init()
1439 soc_pm.data.uhp_udp_mask = pmc->uhp_udp_mask; in at91_pm_init()
1440 soc_pm.data.pmc_mckr_offset = pmc->mckr; in at91_pm_init()
1441 soc_pm.data.pmc_version = pmc->version; in at91_pm_init()
1478 * AT91RM9200 SDRAM low-power mode cannot be used with self-refresh. in at91rm9200_pm_init()