1 From 76dbc56ad65350d78d12bd9b36b00c36fb27addf Mon Sep 17 00:00:00 2001
2 From: Claudiu Beznea <claudiu.beznea@microchip.com>
3 Date: Mon, 23 Aug 2021 16:19:12 +0300
4 Subject: [PATCH 223/247] ARM: at91: pm: do not panic if ram controllers are
7 In case PM is enabled but there is no RAM controller information
8 in DT the code will panic. Avoid such scenarios by not initializing
9 platform specific PM code in case RAM controller is not provided
12 Reported-by: Eugen Hristev <eugen.hristev@microchip.com>
13 Fixes: 827de1f123ba0 ("ARM: at91: remove at91_dt_initialize and machine init_early()")
14 Fixes: 892e1f4a3ae58 ("ARM: at91: pm: add sama7g5 ddr phy controller")
15 Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
16 Signed-off-by: Nicolas Ferre <nicolas.ferre@microchip.com>
17 Link: https://lore.kernel.org/r/20210823131915.23857-2-claudiu.beznea@microchip.com
19 arch/arm/mach-at91/pm.c | 22 ++++++++++++++++------
20 1 file changed, 16 insertions(+), 6 deletions(-)
22 --- a/arch/arm/mach-at91/pm.c
23 +++ b/arch/arm/mach-at91/pm.c
24 @@ -589,7 +589,7 @@ static const struct of_device_id ramc_ph
28 -static __init void at91_dt_ramc(bool phy_mandatory)
29 +static __init int at91_dt_ramc(bool phy_mandatory)
31 struct device_node *np;
32 const struct of_device_id *of_id;
33 @@ -625,12 +625,18 @@ static __init void at91_dt_ramc(bool phy
34 /* Lookup for DDR PHY node, if any. */
35 for_each_matching_node_and_match(np, ramc_phy_ids, &of_id) {
36 soc_pm.data.ramc_phy = of_iomap(np, 0);
37 - if (!soc_pm.data.ramc_phy)
38 - panic(pr_fmt("unable to map ramc phy cpu registers\n"));
39 + if (!soc_pm.data.ramc_phy) {
40 + pr_err("unable to map ramc phy cpu registers\n");
46 - if (phy_mandatory && !soc_pm.data.ramc_phy)
47 - panic(pr_fmt("DDR PHY is mandatory!\n"));
48 + if (phy_mandatory && !soc_pm.data.ramc_phy) {
49 + pr_err("DDR PHY is mandatory!\n");
55 pr_warn("ramc no standby function available\n");
56 @@ -1163,13 +1169,17 @@ void __init sama7_pm_init(void)
57 [AT91_PM_BACKUP] = AT91_PM_IOMAP(SFRBU) |
62 if (!IS_ENABLED(CONFIG_SOC_SAMA7))
65 at91_pm_modes_validate(modes, ARRAY_SIZE(modes));
68 + ret = at91_dt_ramc(true);
72 at91_pm_modes_init(iomaps, ARRAY_SIZE(iomaps));