LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v2 0/4] ARM: at91: add new nodes to DT and fix for PM
@ 2021-08-23 13:19 Claudiu Beznea
  2021-08-23 13:19 ` [PATCH v2 1/4] ARM: at91: pm: do not panic if ram controllers are not enabled Claudiu Beznea
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Claudiu Beznea @ 2021-08-23 13:19 UTC (permalink / raw)
  To: nicolas.ferre, alexandre.belloni, ludovic.desroches, robh+dt, linux
  Cc: linux-arm-kernel, devicetree, linux-kernel, Claudiu Beznea

Hi,

The following patches enable UDDRC, DDR3 PHY, SECURAM and SHDWC IPs
on SAMA7G5.

Besides this patch 1/1 avoid the panic on PM initialization code allowing
the system to boot when PM is enabled but not enough information is
provided in DT.

Thank you,
Claudiu Beznea

Changes in v2:
- changes cover letter title from
  "ARM: dts: at91: enable ips for sama7g5" to
  "ARM: at91: add new nodes to DT and fix for PM"
- update the device tree patches title and description
- added patch "ARM: at91: pm: do not panic if ram controllers are not
  enabled"

Claudiu Beznea (4):
  ARM: at91: pm: do not panic if ram controllers are not enabled
  ARM: dts: at91: sama7g5: add ram controllers
  ARM: dts: at91: sama7g5: add securam node
  ARM: dts: at91: sama7g5: add shdwc node

 arch/arm/boot/dts/at91-sama7g5ek.dts |  9 ++++
 arch/arm/boot/dts/sama7g5.dtsi       | 34 ++++++++++++
 arch/arm/mach-at91/pm.c              | 78 ++++++++++++++++++++++------
 3 files changed, 105 insertions(+), 16 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/4] ARM: at91: pm: do not panic if ram controllers are not enabled
  2021-08-23 13:19 [PATCH v2 0/4] ARM: at91: add new nodes to DT and fix for PM Claudiu Beznea
@ 2021-08-23 13:19 ` Claudiu Beznea
  2021-08-23 13:19 ` [PATCH v2 2/4] ARM: dts: at91: sama7g5: add ram controllers Claudiu Beznea
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Claudiu Beznea @ 2021-08-23 13:19 UTC (permalink / raw)
  To: nicolas.ferre, alexandre.belloni, ludovic.desroches, robh+dt, linux
  Cc: linux-arm-kernel, devicetree, linux-kernel, Claudiu Beznea,
	Eugen Hristev

In case PM is enabled but there is no RAM controller information
in DT the code will panic. Avoid such scenarios by not initializing
platform specific PM code in case RAM controller is not provided
via DT.

Reported-by: Eugen Hristev <eugen.hristev@microchip.com>
Fixes: 827de1f123ba0 ("ARM: at91: remove at91_dt_initialize and machine init_early()")
Fixes: 892e1f4a3ae58 ("ARM: at91: pm: add sama7g5 ddr phy controller")
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
 arch/arm/mach-at91/pm.c | 78 ++++++++++++++++++++++++++++++++---------
 1 file changed, 62 insertions(+), 16 deletions(-)

diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index d6cfe7c4bb00..d92afca64b49 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -589,18 +589,22 @@ static const struct of_device_id ramc_phy_ids[] __initconst = {
 	{ /* Sentinel. */ },
 };
 
-static __init void at91_dt_ramc(bool phy_mandatory)
+static __init int at91_dt_ramc(bool phy_mandatory)
 {
 	struct device_node *np;
 	const struct of_device_id *of_id;
 	int idx = 0;
 	void *standby = NULL;
 	const struct ramc_info *ramc;
+	int ret;
 
 	for_each_matching_node_and_match(np, ramc_ids, &of_id) {
 		soc_pm.data.ramc[idx] = of_iomap(np, 0);
-		if (!soc_pm.data.ramc[idx])
-			panic(pr_fmt("unable to map ramc[%d] cpu registers\n"), idx);
+		if (!soc_pm.data.ramc[idx]) {
+			pr_err("unable to map ramc[%d] cpu registers\n", idx);
+			ret = -ENOMEM;
+			goto unmap_ramc;
+		}
 
 		ramc = of_id->data;
 		if (ramc) {
@@ -612,25 +616,42 @@ static __init void at91_dt_ramc(bool phy_mandatory)
 		idx++;
 	}
 
-	if (!idx)
-		panic(pr_fmt("unable to find compatible ram controller node in dtb\n"));
+	if (!idx) {
+		pr_err("unable to find compatible ram controller node in dtb\n");
+		ret = -ENODEV;
+		goto unmap_ramc;
+	}
 
 	/* Lookup for DDR PHY node, if any. */
 	for_each_matching_node_and_match(np, ramc_phy_ids, &of_id) {
 		soc_pm.data.ramc_phy = of_iomap(np, 0);
-		if (!soc_pm.data.ramc_phy)
-			panic(pr_fmt("unable to map ramc phy cpu registers\n"));
+		if (!soc_pm.data.ramc_phy) {
+			pr_err("unable to map ramc phy cpu registers\n");
+			ret = -ENOMEM;
+			goto unmap_ramc;
+		}
 	}
 
-	if (phy_mandatory && !soc_pm.data.ramc_phy)
-		panic(pr_fmt("DDR PHY is mandatory!\n"));
+	if (phy_mandatory && !soc_pm.data.ramc_phy) {
+		pr_err("DDR PHY is mandatory!\n");
+		ret = -ENODEV;
+		goto unmap_ramc;
+	}
 
 	if (!standby) {
 		pr_warn("ramc no standby function available\n");
-		return;
+		return 0;
 	}
 
 	at91_cpuidle_device.dev.platform_data = standby;
+
+	return 0;
+
+unmap_ramc:
+	while (idx)
+		iounmap(soc_pm.data.ramc[--idx]);
+
+	return ret;
 }
 
 static void at91rm9200_idle(void)
@@ -1017,6 +1038,8 @@ static void __init at91_pm_init(void (*pm_idle)(void))
 
 void __init at91rm9200_pm_init(void)
 {
+	int ret;
+
 	if (!IS_ENABLED(CONFIG_SOC_AT91RM9200))
 		return;
 
@@ -1028,7 +1051,9 @@ void __init at91rm9200_pm_init(void)
 	soc_pm.data.standby_mode = AT91_PM_STANDBY;
 	soc_pm.data.suspend_mode = AT91_PM_ULP0;
 
-	at91_dt_ramc(false);
+	ret = at91_dt_ramc(false);
+	if (ret)
+		return;
 
 	/*
 	 * AT91RM9200 SDRAM low-power mode cannot be used with self-refresh.
@@ -1046,13 +1071,17 @@ void __init sam9x60_pm_init(void)
 	static const int iomaps[] __initconst = {
 		[AT91_PM_ULP1]		= AT91_PM_IOMAP(SHDWC),
 	};
+	int ret;
 
 	if (!IS_ENABLED(CONFIG_SOC_SAM9X60))
 		return;
 
 	at91_pm_modes_validate(modes, ARRAY_SIZE(modes));
 	at91_pm_modes_init(iomaps, ARRAY_SIZE(iomaps));
-	at91_dt_ramc(false);
+	ret = at91_dt_ramc(false);
+	if (ret)
+		return;
+
 	at91_pm_init(NULL);
 
 	soc_pm.ws_ids = sam9x60_ws_ids;
@@ -1061,6 +1090,8 @@ void __init sam9x60_pm_init(void)
 
 void __init at91sam9_pm_init(void)
 {
+	int ret;
+
 	if (!IS_ENABLED(CONFIG_SOC_AT91SAM9))
 		return;
 
@@ -1072,7 +1103,10 @@ void __init at91sam9_pm_init(void)
 	soc_pm.data.standby_mode = AT91_PM_STANDBY;
 	soc_pm.data.suspend_mode = AT91_PM_ULP0;
 
-	at91_dt_ramc(false);
+	ret = at91_dt_ramc(false);
+	if (ret)
+		return;
+
 	at91_pm_init(at91sam9_idle);
 }
 
@@ -1081,12 +1115,16 @@ void __init sama5_pm_init(void)
 	static const int modes[] __initconst = {
 		AT91_PM_STANDBY, AT91_PM_ULP0, AT91_PM_ULP0_FAST,
 	};
+	int ret;
 
 	if (!IS_ENABLED(CONFIG_SOC_SAMA5))
 		return;
 
 	at91_pm_modes_validate(modes, ARRAY_SIZE(modes));
-	at91_dt_ramc(false);
+	ret = at91_dt_ramc(false);
+	if (ret)
+		return;
+
 	at91_pm_init(NULL);
 }
 
@@ -1101,13 +1139,17 @@ void __init sama5d2_pm_init(void)
 		[AT91_PM_BACKUP]	= AT91_PM_IOMAP(SHDWC) |
 					  AT91_PM_IOMAP(SFRBU),
 	};
+	int ret;
 
 	if (!IS_ENABLED(CONFIG_SOC_SAMA5D2))
 		return;
 
 	at91_pm_modes_validate(modes, ARRAY_SIZE(modes));
 	at91_pm_modes_init(iomaps, ARRAY_SIZE(iomaps));
-	at91_dt_ramc(false);
+	ret = at91_dt_ramc(false);
+	if (ret)
+		return;
+
 	at91_pm_init(NULL);
 
 	soc_pm.ws_ids = sama5d2_ws_ids;
@@ -1127,13 +1169,17 @@ void __init sama7_pm_init(void)
 		[AT91_PM_BACKUP]	= AT91_PM_IOMAP(SFRBU) |
 					  AT91_PM_IOMAP(SHDWC),
 	};
+	int ret;
 
 	if (!IS_ENABLED(CONFIG_SOC_SAMA7))
 		return;
 
 	at91_pm_modes_validate(modes, ARRAY_SIZE(modes));
 
-	at91_dt_ramc(true);
+	ret = at91_dt_ramc(true);
+	if (ret)
+		return;
+
 	at91_pm_modes_init(iomaps, ARRAY_SIZE(iomaps));
 	at91_pm_init(NULL);
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 2/4] ARM: dts: at91: sama7g5: add ram controllers
  2021-08-23 13:19 [PATCH v2 0/4] ARM: at91: add new nodes to DT and fix for PM Claudiu Beznea
  2021-08-23 13:19 ` [PATCH v2 1/4] ARM: at91: pm: do not panic if ram controllers are not enabled Claudiu Beznea
@ 2021-08-23 13:19 ` Claudiu Beznea
  2021-08-23 13:19 ` [PATCH v2 3/4] ARM: dts: at91: sama7g5: add securam node Claudiu Beznea
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Claudiu Beznea @ 2021-08-23 13:19 UTC (permalink / raw)
  To: nicolas.ferre, alexandre.belloni, ludovic.desroches, robh+dt, linux
  Cc: linux-arm-kernel, devicetree, linux-kernel, Claudiu Beznea

Add RAM and RAMC PHY controllers. These are necessary for platform
specific power management code.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
 arch/arm/boot/dts/sama7g5.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/sama7g5.dtsi b/arch/arm/boot/dts/sama7g5.dtsi
index cc6be6db7b80..ecabab4343b6 100644
--- a/arch/arm/boot/dts/sama7g5.dtsi
+++ b/arch/arm/boot/dts/sama7g5.dtsi
@@ -515,6 +515,18 @@ spi11: spi@400 {
 			};
 		};
 
+		uddrc: uddrc@e3800000 {
+			compatible = "microchip,sama7g5-uddrc";
+			reg = <0xe3800000 0x4000>;
+			status = "okay";
+		};
+
+		ddr3phy: ddr3phy@e3804000 {
+			compatible = "microchip,sama7g5-ddr3phy";
+			reg = <0xe3804000 0x1000>;
+			status = "okay";
+		};
+
 		gic: interrupt-controller@e8c11000 {
 			compatible = "arm,cortex-a7-gic";
 			#interrupt-cells = <3>;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 3/4] ARM: dts: at91: sama7g5: add securam node
  2021-08-23 13:19 [PATCH v2 0/4] ARM: at91: add new nodes to DT and fix for PM Claudiu Beznea
  2021-08-23 13:19 ` [PATCH v2 1/4] ARM: at91: pm: do not panic if ram controllers are not enabled Claudiu Beznea
  2021-08-23 13:19 ` [PATCH v2 2/4] ARM: dts: at91: sama7g5: add ram controllers Claudiu Beznea
@ 2021-08-23 13:19 ` Claudiu Beznea
  2021-08-23 13:19 ` [PATCH v2 4/4] ARM: dts: at91: sama7g5: add shdwc node Claudiu Beznea
  2021-09-14 14:54 ` [PATCH v2 0/4] ARM: at91: add new nodes to DT and fix for PM Nicolas Ferre
  4 siblings, 0 replies; 6+ messages in thread
From: Claudiu Beznea @ 2021-08-23 13:19 UTC (permalink / raw)
  To: nicolas.ferre, alexandre.belloni, ludovic.desroches, robh+dt, linux
  Cc: linux-arm-kernel, devicetree, linux-kernel, Claudiu Beznea

Add securam node.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
 arch/arm/boot/dts/sama7g5.dtsi | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm/boot/dts/sama7g5.dtsi b/arch/arm/boot/dts/sama7g5.dtsi
index ecabab4343b6..3a4315ac0eb0 100644
--- a/arch/arm/boot/dts/sama7g5.dtsi
+++ b/arch/arm/boot/dts/sama7g5.dtsi
@@ -75,6 +75,17 @@ soc {
 		#size-cells = <1>;
 		ranges;
 
+		securam: securam@e0000000 {
+			compatible = "microchip,sama7g5-securam", "atmel,sama5d2-securam", "mmio-sram";
+			reg = <0xe0000000 0x4000>;
+			clocks = <&pmc PMC_TYPE_PERIPHERAL 18>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges = <0 0xe0000000 0x4000>;
+			no-memory-wc;
+			status = "okay";
+		};
+
 		secumod: secumod@e0004000 {
 			compatible = "microchip,sama7g5-secumod", "atmel,sama5d2-secumod", "syscon";
 			reg = <0xe0004000 0x4000>;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 4/4] ARM: dts: at91: sama7g5: add shdwc node
  2021-08-23 13:19 [PATCH v2 0/4] ARM: at91: add new nodes to DT and fix for PM Claudiu Beznea
                   ` (2 preceding siblings ...)
  2021-08-23 13:19 ` [PATCH v2 3/4] ARM: dts: at91: sama7g5: add securam node Claudiu Beznea
@ 2021-08-23 13:19 ` Claudiu Beznea
  2021-09-14 14:54 ` [PATCH v2 0/4] ARM: at91: add new nodes to DT and fix for PM Nicolas Ferre
  4 siblings, 0 replies; 6+ messages in thread
From: Claudiu Beznea @ 2021-08-23 13:19 UTC (permalink / raw)
  To: nicolas.ferre, alexandre.belloni, ludovic.desroches, robh+dt, linux
  Cc: linux-arm-kernel, devicetree, linux-kernel, Claudiu Beznea

Add shutdown controller node and enable it.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
 arch/arm/boot/dts/at91-sama7g5ek.dts |  9 +++++++++
 arch/arm/boot/dts/sama7g5.dtsi       | 11 +++++++++++
 2 files changed, 20 insertions(+)

diff --git a/arch/arm/boot/dts/at91-sama7g5ek.dts b/arch/arm/boot/dts/at91-sama7g5ek.dts
index 4cbed98cc2f4..8b13b031a167 100644
--- a/arch/arm/boot/dts/at91-sama7g5ek.dts
+++ b/arch/arm/boot/dts/at91-sama7g5ek.dts
@@ -634,6 +634,15 @@ &sdmmc2 {
 	pinctrl-0 = <&pinctrl_sdmmc2_default>;
 };
 
+&shdwc {
+	atmel,shdwc-debouncer = <976>;
+	status = "okay";
+
+	input@0 {
+		reg = <0>;
+	};
+};
+
 &spdifrx {
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_spdifrx_default>;
diff --git a/arch/arm/boot/dts/sama7g5.dtsi b/arch/arm/boot/dts/sama7g5.dtsi
index 3a4315ac0eb0..e50806cf7660 100644
--- a/arch/arm/boot/dts/sama7g5.dtsi
+++ b/arch/arm/boot/dts/sama7g5.dtsi
@@ -122,6 +122,17 @@ pmc: pmc@e0018000 {
 			clock-names = "td_slck", "md_slck", "main_xtal";
 		};
 
+		shdwc: shdwc@e001d010 {
+			compatible = "microchip,sama7g5-shdwc", "syscon";
+			reg = <0xe001d010 0x10>;
+			clocks = <&clk32k 0>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			atmel,wakeup-rtc-timer;
+			atmel,wakeup-rtt-timer;
+			status = "disabled";
+		};
+
 		rtt: rtt@e001d020 {
 			compatible = "microchip,sama7g5-rtt", "microchip,sam9x60-rtt", "atmel,at91sam9260-rtt";
 			reg = <0xe001d020 0x30>;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 0/4] ARM: at91: add new nodes to DT and fix for PM
  2021-08-23 13:19 [PATCH v2 0/4] ARM: at91: add new nodes to DT and fix for PM Claudiu Beznea
                   ` (3 preceding siblings ...)
  2021-08-23 13:19 ` [PATCH v2 4/4] ARM: dts: at91: sama7g5: add shdwc node Claudiu Beznea
@ 2021-09-14 14:54 ` Nicolas Ferre
  4 siblings, 0 replies; 6+ messages in thread
From: Nicolas Ferre @ 2021-09-14 14:54 UTC (permalink / raw)
  To: Claudiu Beznea, alexandre.belloni, ludovic.desroches, robh+dt, linux
  Cc: linux-arm-kernel, devicetree, linux-kernel

On 23/08/2021 at 15:19, Claudiu Beznea wrote:
> Hi,
> 
> The following patches enable UDDRC, DDR3 PHY, SECURAM and SHDWC IPs
> on SAMA7G5.
> 
> Besides this patch 1/1 avoid the panic on PM initialization code allowing
> the system to boot when PM is enabled but not enough information is
> provided in DT.

Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>

Whole series queued to at91-fixes for 5.15 as without these patches the 
SAMA7G5 don't have power management at full capacity.

Best regards,
   Nicolas

> Changes in v2:
> - changes cover letter title from
>    "ARM: dts: at91: enable ips for sama7g5" to
>    "ARM: at91: add new nodes to DT and fix for PM"
> - update the device tree patches title and description
> - added patch "ARM: at91: pm: do not panic if ram controllers are not
>    enabled"
> 
> Claudiu Beznea (4):
>    ARM: at91: pm: do not panic if ram controllers are not enabled
>    ARM: dts: at91: sama7g5: add ram controllers
>    ARM: dts: at91: sama7g5: add securam node
>    ARM: dts: at91: sama7g5: add shdwc node
> 
>   arch/arm/boot/dts/at91-sama7g5ek.dts |  9 ++++
>   arch/arm/boot/dts/sama7g5.dtsi       | 34 ++++++++++++
>   arch/arm/mach-at91/pm.c              | 78 ++++++++++++++++++++++------
>   3 files changed, 105 insertions(+), 16 deletions(-)
> 


-- 
Nicolas Ferre

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-09-14 14:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-23 13:19 [PATCH v2 0/4] ARM: at91: add new nodes to DT and fix for PM Claudiu Beznea
2021-08-23 13:19 ` [PATCH v2 1/4] ARM: at91: pm: do not panic if ram controllers are not enabled Claudiu Beznea
2021-08-23 13:19 ` [PATCH v2 2/4] ARM: dts: at91: sama7g5: add ram controllers Claudiu Beznea
2021-08-23 13:19 ` [PATCH v2 3/4] ARM: dts: at91: sama7g5: add securam node Claudiu Beznea
2021-08-23 13:19 ` [PATCH v2 4/4] ARM: dts: at91: sama7g5: add shdwc node Claudiu Beznea
2021-09-14 14:54 ` [PATCH v2 0/4] ARM: at91: add new nodes to DT and fix for PM Nicolas Ferre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).