Skip to contentSkip to conversation

AT91 Low Power Mode adjustments

PATCH Superseded [email protected] 5 participants 9 messages Sep 10, 2025 – Sep 16, 2025

Subsystems (6)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover AT91 Low Power Mode adjustments

From: Ryan Wanner <[email protected]>

This patch set adds the LPM pin feature to the SAMA7 SoCs.

This set also removes the 2.5V regulator since this is no longer supported.

Claudiu Beznea (2):
ARM: at91: PM: implement selection of LPM
ARM: dts: at91: sama7g5ek: add microchip,lpm-connection on shdwc node

Ryan Wanner (1):
ARM: at91: pm: Remove 2.5V regulator

Varshini Rajendran (1):
dt-bindings: power: reset: atmel,sama5d2-shdwc: add lpm binding

 .../power/reset/atmel,sama5d2-shdwc.yaml      | 16 +++
 .../arm/boot/dts/microchip/at91-sama7g5ek.dts |  1 +
 arch/arm/mach-at91/pm.c                       | 98 ++++++++++++++++++-
 arch/arm/mach-at91/pm.h                       |  1 +
 arch/arm/mach-at91/pm_data-offsets.c          |  1 +
 arch/arm/mach-at91/pm_suspend.S               | 75 +++++++-------
 include/soc/at91/sama7-sfrbu.h                |  7 --
 7 files changed, 156 insertions(+), 43 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/4 dt-bindings: power: reset: atmel,sama5d2-shdwc: add lpm binding

From: Varshini Rajendran <[email protected]>

Add microchip,lpm-connection binding which allows to specify the devices the SHDWC's LPM pin is connected.

[[email protected]: Add sam9x7-shdwc SoC to properties check]
---
 .../power/reset/atmel,sama5d2-shdwc.yaml         | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
Documentation/devicetree/bindings/power/reset/atmel,sama5d2-shdwc.yaml +16 -0
index 9c34249b2d6d..b1a8ccd0873d 100644
@@ -56,6 +56,10 @@ properties:
     description: enable real-time timer wake-up
     type: boolean
 
+  microchip,lpm-connection:
+    description: list of phandles to devices which are connected to SHDWC's LPM pin
+    $ref: /schemas/types.yaml#/definitions/phandle
+
 patternProperties:
   "^input@[0-15]$":
     description:
@@ -96,6 +100,18 @@ allOf:
       properties:
         atmel,wakeup-rtt-timer: false
 
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - atmel,sama5d2-shdwc
+              - microchip,sam9x60-shdwc
+              - microchip,sam9x7-shdwc
+    then:
+      properties:
+        microchip,lpm-connection: false
+
 additionalProperties: false
 
 examples:
Signature · 1 line
2.43.0
maintainer
#2 lore raw

Re: [PATCH 1/4] dt-bindings: power: reset: atmel,sama5d2-shdwc: add lpm binding

Quoted 4 lines · On Wed, Sep 10, 2025 at 09:20:36AM -0700, [email protected] wrote:

From: Varshini Rajendran <[email protected]>

Add microchip,lpm-connection binding which allows to specify the devices the SHDWC's LPM pin is connected.

What is LPM? It's not defined anywhere in this patch.

Quoted 13 lines
[[email protected]: Add sam9x7-shdwc SoC to properties check]
---
 .../power/reset/atmel,sama5d2-shdwc.yaml         | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
Documentation/devicetree/bindings/power/reset/atmel,sama5d2-shdwc.yaml +0 -0
index 9c34249b2d6d..b1a8ccd0873d 100644

Documentation/devicetree/bindings/power/reset/atmel,sama5d2-shdwc.yaml properties: · line 61

Quoted 6 lines
Documentation/devicetree/bindings/power/reset/atmel,sama5d2-shdwc.yaml +3 -0
@@ -56,6 +56,10 @@ properties:
     description: enable real-time timer wake-up
     type: boolean
 
+  microchip,lpm-connection:
+    description: list of phandles to devices which are connected to SHDWC's LPM pin
+    $ref: /schemas/types.yaml#/definitions/phandle

This only allows 1 phandle.

Quoted 26 lines
Documentation/devicetree/bindings/power/reset/atmel,sama5d2-shdwc.yaml +13 -0
+
 patternProperties:
   "^input@[0-15]$":
     description:
@@ -96,6 +100,18 @@ allOf:
       properties:
         atmel,wakeup-rtt-timer: false
 
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - atmel,sama5d2-shdwc
+              - microchip,sam9x60-shdwc
+              - microchip,sam9x7-shdwc
+    then:
+      properties:
+        microchip,lpm-connection: false
+
 additionalProperties: false
 
 examples:
Signature · 1 line
2.43.0
#3 lore raw

PATCH 2/4 ARM: at91: PM: implement selection of LPM

In reply to [email protected]

From: Claudiu Beznea <[email protected]>

The LPM shutdown controller output could signal the transition to PM state for different devices connected on board. On different boards LPM could be connected to different devices (e.g. on SAMA7G5-EK REV4 the LPM is connected to on main crystal oscillator, KSZ8081 PHY and to MCP16502 PMIC). Toggling LPM on BSR PM mode is done unconditionally and it helps PMIC to transition to a power saving mode. Toggling LPM on ULP0 and ULP1 should be done conditionally based on user defined wakeup sources, available wakeup source for PM mode and connections to SHDWC's LPM pin. On ULP0 any device could act as wakeup sources. On ULP1 only some of the on SoC controllers could act as wakeup sources. For this the architecture specific PM code parses board specific LPM devices, check them against possible wakeup source (in case of ULP1) and tells assembly code to act properly on SHDWC's LPM pin.

[[email protected]: Fixed conflicts when applying.]
---
 arch/arm/mach-at91/pm.c              | 98 +++++++++++++++++++++++++++-
 arch/arm/mach-at91/pm.h              |  1 +
 arch/arm/mach-at91/pm_data-offsets.c |  1 +
 arch/arm/mach-at91/pm_suspend.S      | 50 ++++++++++++--
 4 files changed, 141 insertions(+), 9 deletions(-)
arch/arm/mach-at91/pm.c +95 -3
index 35058b99069c..29348d6c852b 100644
@@ -116,6 +116,7 @@ struct at91_pm_quirks {
  * @config_shdwc_ws: wakeup sources configuration function for SHDWC
  * @config_pmc_ws: wakeup srouces configuration function for PMC
  * @ws_ids: wakup sources of_device_id array
+ * @shdwc_np: pointer to shdwc node
  * @bu: backup unit mapped data (for backup mode)
  * @quirks: PM quirks
  * @data: PM data to be used on last phase of suspend
@@ -126,6 +127,7 @@ struct at91_soc_pm {
 	int (*config_shdwc_ws)(void __iomem *shdwc, u32 *mode, u32 *polarity);
 	int (*config_pmc_ws)(void __iomem *pmc, u32 mode, u32 polarity);
 	const struct of_device_id *ws_ids;
+	struct device_node *shdwc_np;
 	struct at91_pm_bu *bu;
 	struct at91_pm_quirks quirks;
 	struct at91_pm_data data;
@@ -243,6 +245,84 @@ static const struct of_device_id sam9x7_ws_ids[] = {
 	{ /* sentinel */ }
 };
 
+static int at91_pm_device_in_list(const struct platform_device *pdev,
+				  const struct of_device_id *ids)
+{
+	struct platform_device *local_pdev;
+	const struct of_device_id *match;
+	struct device_node *np;
+	int in_list = 0;
+
+	for_each_matching_node_and_match(np, ids, &match) {
+		local_pdev = of_find_device_by_node(np);
+		if (!local_pdev)
+			continue;
+
+		if (pdev == local_pdev)
+			in_list = 1;
+
+		put_device(&local_pdev->dev);
+		if (in_list)
+			return in_list;
+	}
+
+	return in_list;
+}
+
+static int at91_pm_prepare_lpm(unsigned int pm_mode)
+{
+	struct platform_device *pdev;
+	int ndevices, i, ret;
+	struct of_phandle_args lpmspec;
+
+	if ((pm_mode != AT91_PM_ULP0 && pm_mode != AT91_PM_ULP1) ||
+	    !soc_pm.shdwc_np)
+		return 0;
+
+	ndevices = of_count_phandle_with_args(soc_pm.shdwc_np,
+					      "microchip,lpm-connection", 0);
+	if (ndevices < 0)
+		return 0;
+
+	soc_pm.data.lpm = 1;
+	for (i = 0; i < ndevices; i++) {
+		ret = of_parse_phandle_with_args(soc_pm.shdwc_np,
+						 "microchip,lpm-connection",
+						 NULL, i, &lpmspec);
+		if (ret < 0) {
+			if (ret == -ENOENT) {
+				continue;
+			} else {
+				soc_pm.data.lpm = 0;
+				return ret;
+			}
+		}
+
+		pdev = of_find_device_by_node(lpmspec.np);
+		if (!pdev)
+			continue;
+
+		if (device_may_wakeup(&pdev->dev)) {
+			if (pm_mode == AT91_PM_ULP1) {
+				/*
+				 * ULP1 wake-up sources are limited. Ignore it if not
+				 * in soc_pm.ws_ids.
+				 */
+				if (at91_pm_device_in_list(pdev, soc_pm.ws_ids))
+					soc_pm.data.lpm = 0;
+			} else {
+				soc_pm.data.lpm = 0;
+			}
+		}
+
+		put_device(&pdev->dev);
+		if (!soc_pm.data.lpm)
+			break;
+	}
+
+	return 0;
+}
+
 static int at91_pm_config_ws(unsigned int pm_mode, bool set)
 {
 	const struct wakeup_source_info *wsi;
@@ -481,10 +561,17 @@ static int at91_pm_begin(suspend_state_t state)
 		soc_pm.data.mode = -1;
 	}
 
-	ret = at91_pm_config_ws(soc_pm.data.mode, true);
+	ret = at91_pm_prepare_lpm(soc_pm.data.mode);
 	if (ret)
 		return ret;
 
+	ret = at91_pm_config_ws(soc_pm.data.mode, true);
+	if (ret) {
+		/* Revert LPM if any. */
+		soc_pm.data.lpm = 0;
+		return ret;
+	}
+
 	if (soc_pm.data.mode == AT91_PM_BACKUP)
 		soc_pm.bu->suspended = 1;
 	else if (soc_pm.bu)
@@ -1266,7 +1353,11 @@ static void __init at91_pm_modes_init(const u32 *maps, int len)
 			AT91_PM_REPLACE_MODES(maps, SHDWC);
 		} else {
 			soc_pm.data.shdwc = of_iomap(np, 0);
-			of_node_put(np);
+			/*
+			 * np is used further on suspend/resume path so we skip the
+			 * of_node_put(np) here.
+			 */
+			soc_pm.shdwc_np = np;
 		}
 	}
 
@@ -1669,7 +1760,8 @@ void __init sama7_pm_init(void)
 		AT91_PM_STANDBY, AT91_PM_ULP0, AT91_PM_ULP1, AT91_PM_BACKUP,
 	};
 	static const u32 iomaps[] __initconst = {
-		[AT91_PM_ULP0]		= AT91_PM_IOMAP(SFRBU),
+		[AT91_PM_ULP0]		= AT91_PM_IOMAP(SFRBU) |
+					  AT91_PM_IOMAP(SHDWC),
 		[AT91_PM_ULP1]		= AT91_PM_IOMAP(SFRBU) |
 					  AT91_PM_IOMAP(SHDWC) |
 					  AT91_PM_IOMAP(ETHC),
arch/arm/mach-at91/pm.h +1 -0
index 50c3a425d140..5707ff6ff444 100644
@@ -40,6 +40,7 @@ struct at91_pm_data {
 	unsigned int pmc_mckr_offset;
 	unsigned int pmc_version;
 	unsigned int pmc_mcks;
+	unsigned int lpm;
 };
 #endif
 
arch/arm/mach-at91/pm_data-offsets.c +1 -0
index 0ca5da66dc26..fb9651abdfdf 100644
@@ -20,6 +20,7 @@ int main(void)
 						 pmc_version));
 	DEFINE(PM_DATA_PMC_MCKS,	offsetof(struct at91_pm_data,
 						 pmc_mcks));
+	DEFINE(PM_DATA_LPM,		offsetof(struct at91_pm_data, lpm));
 
 	return 0;
 }
arch/arm/mach-at91/pm_suspend.S +44 -6

105 lines not on this page · raw message

Signature · 1 line
2.43.0
maintainer
#4 lore raw

Re: [PATCH 2/4] ARM: at91: PM: implement selection of LPM

Hi, Ryan,

Quoted 1 line · On 9/10/25 19:20, [email protected] wrote:

From: Claudiu Beznea <[email protected]>

Actually, this was developed while I was with Microchip. I think this still belongs to Microchip, so I would use the old email address.

Quoted 46 lines

The LPM shutdown controller output could signal the transition to PM state for different devices connected on board. On different boards LPM could be connected to different devices (e.g. on SAMA7G5-EK REV4 the LPM is connected to on main crystal oscillator, KSZ8081 PHY and to MCP16502 PMIC). Toggling LPM on BSR PM mode is done unconditionally and it helps PMIC to transition to a power saving mode. Toggling LPM on ULP0 and ULP1 should be done conditionally based on user defined wakeup sources, available wakeup source for PM mode and connections to SHDWC's LPM pin. On ULP0 any device could act as wakeup sources. On ULP1 only some of the on SoC controllers could act as wakeup sources. For this the architecture specific PM code parses board specific LPM devices, check them against possible wakeup source (in case of ULP1) and tells assembly code to act properly on SHDWC's LPM pin.

[[email protected]: Fixed conflicts when applying.]
---
  arch/arm/mach-at91/pm.c              | 98 +++++++++++++++++++++++++++-
  arch/arm/mach-at91/pm.h              |  1 +
  arch/arm/mach-at91/pm_data-offsets.c |  1 +
  arch/arm/mach-at91/pm_suspend.S      | 50 ++++++++++++--
  4 files changed, 141 insertions(+), 9 deletions(-)
arch/arm/mach-at91/pm.c +2 -0
index 35058b99069c..29348d6c852b 100644
@@ -116,6 +116,7 @@ struct at91_pm_quirks {
   * @config_shdwc_ws: wakeup sources configuration function for SHDWC
   * @config_pmc_ws: wakeup srouces configuration function for PMC
   * @ws_ids: wakup sources of_device_id array
+ * @shdwc_np: pointer to shdwc node
   * @bu: backup unit mapped data (for backup mode)
   * @quirks: PM quirks
   * @data: PM data to be used on last phase of suspend
@@ -126,6 +127,7 @@ struct at91_soc_pm {
  	int (*config_shdwc_ws)(void __iomem *shdwc, u32 *mode, u32 *polarity);
  	int (*config_pmc_ws)(void __iomem *pmc, u32 mode, u32 polarity);
  	const struct of_device_id *ws_ids;
+	struct device_node *shdwc_np;
  	struct at91_pm_bu *bu;
  	struct at91_pm_quirks quirks;
  	struct at91_pm_data data;

arch/arm/mach-at91/pm.c static const struct of_device_id sam9x7_ws_ids[] = { · line 249

Quoted 5 lines
arch/arm/mach-at91/pm.c +2 -0
@@ -243,6 +245,84 @@ static const struct of_device_id sam9x7_ws_ids[] = {
  	{ /* sentinel */ }
  };
 
+static int at91_pm_device_in_list(const struct platform_device *pdev,
+				  const struct of_device_id *ids)

I think would be better to make it return bool

Quoted 8 lines
arch/arm/mach-at91/pm.c +8 -0
+{
+	struct platform_device *local_pdev;
+	const struct of_device_id *match;
+	struct device_node *np;
+	int in_list = 0;
+
+	for_each_matching_node_and_match(np, ids, &match) {
+		local_pdev = of_find_device_by_node(np);

arch/arm/mach-at91/pm.c static const struct of_device_id sam9x7_ws_ids[] = { · line 267

Quoted 10 lines
arch/arm/mach-at91/pm.c +10 -0
+		if (!local_pdev)
+			continue;
+
+		if (pdev == local_pdev)
+			in_list = 1;
+
+		put_device(&local_pdev->dev);
+		if (in_list)
+			return in_list;
+	}

And simplify this a bit as:

static bool at91_pm_device_in_list(const struct platform_device *pdev,
const struct of_device_id *ids)

{
	struct platform_device *local_pdev;
	const struct of_device_id *match;
	struct device_node *np;

	for_each_matching_node_and_match(np, ids, &match) {
		local_pdev = of_find_device_by_node(np);
		if (!local_pdev)
			continue;

		put_device(&local_pdev->dev);
		if (pdev == local_pdev)
			return true;
	}

	return false;
}
Quoted 24 lines
arch/arm/mach-at91/pm.c +24 -0
+
+	return in_list;
+}
+
+static int at91_pm_prepare_lpm(unsigned int pm_mode)
+{
+	struct platform_device *pdev;
+	int ndevices, i, ret;
+	struct of_phandle_args lpmspec;
+
+	if ((pm_mode != AT91_PM_ULP0 && pm_mode != AT91_PM_ULP1) ||
+	    !soc_pm.shdwc_np)
+		return 0;
+
+	ndevices = of_count_phandle_with_args(soc_pm.shdwc_np,
+					      "microchip,lpm-connection", 0);
+	if (ndevices < 0)
+		return 0;
+
+	soc_pm.data.lpm = 1;
+	for (i = 0; i < ndevices; i++) {
+		ret = of_parse_phandle_with_args(soc_pm.shdwc_np,
+						 "microchip,lpm-connection",
+						 NULL, i, &lpmspec);

arch/arm/mach-at91/pm.c static const struct of_device_id sam9x7_ws_ids[] = { · line 301

Quoted 10 lines
arch/arm/mach-at91/pm.c +10 -0
+		if (ret < 0) {
+			if (ret == -ENOENT) {
+				continue;
+			} else {
+				soc_pm.data.lpm = 0;
+				return ret;
+			}
+		}
+
+		pdev = of_find_device_by_node(lpmspec.np);

From the documentation of of_parse_phandle_with_args() this code would have to call of_node_put(lpmspec.np);

Here would be the place to do it.

Quoted 150 lines
arch/arm/mach-at91/pm.c +39 -3
+		if (!pdev)
+			continue;
+
+		if (device_may_wakeup(&pdev->dev)) {
+			if (pm_mode == AT91_PM_ULP1) {
+				/*
+				 * ULP1 wake-up sources are limited. Ignore it if not
+				 * in soc_pm.ws_ids.
+				 */
+				if (at91_pm_device_in_list(pdev, soc_pm.ws_ids))
+					soc_pm.data.lpm = 0;
+			} else {
+				soc_pm.data.lpm = 0;
+			}
+		}
+
+		put_device(&pdev->dev);
+		if (!soc_pm.data.lpm)
+			break;
+	}
+
+	return 0;
+}
+
  static int at91_pm_config_ws(unsigned int pm_mode, bool set)
  {
  	const struct wakeup_source_info *wsi;
@@ -481,10 +561,17 @@ static int at91_pm_begin(suspend_state_t state)
  		soc_pm.data.mode = -1;
  	}
 
-	ret = at91_pm_config_ws(soc_pm.data.mode, true);
+	ret = at91_pm_prepare_lpm(soc_pm.data.mode);
  	if (ret)
  		return ret;
 
+	ret = at91_pm_config_ws(soc_pm.data.mode, true);
+	if (ret) {
+		/* Revert LPM if any. */
+		soc_pm.data.lpm = 0;
+		return ret;
+	}
+
  	if (soc_pm.data.mode == AT91_PM_BACKUP)
  		soc_pm.bu->suspended = 1;
  	else if (soc_pm.bu)
@@ -1266,7 +1353,11 @@ static void __init at91_pm_modes_init(const u32 *maps, int len)
  			AT91_PM_REPLACE_MODES(maps, SHDWC);
  		} else {
  			soc_pm.data.shdwc = of_iomap(np, 0);
-			of_node_put(np);
+			/*
+			 * np is used further on suspend/resume path so we skip the
+			 * of_node_put(np) here.
+			 */
+			soc_pm.shdwc_np = np;
  		}
  	}
 
@@ -1669,7 +1760,8 @@ void __init sama7_pm_init(void)
  		AT91_PM_STANDBY, AT91_PM_ULP0, AT91_PM_ULP1, AT91_PM_BACKUP,
  	};
  	static const u32 iomaps[] __initconst = {
-		[AT91_PM_ULP0]		= AT91_PM_IOMAP(SFRBU),
+		[AT91_PM_ULP0]		= AT91_PM_IOMAP(SFRBU) |
+					  AT91_PM_IOMAP(SHDWC),
  		[AT91_PM_ULP1]		= AT91_PM_IOMAP(SFRBU) |
  					  AT91_PM_IOMAP(SHDWC) |
  					  AT91_PM_IOMAP(ETHC),
arch/arm/mach-at91/pm.h +1 -0
index 50c3a425d140..5707ff6ff444 100644
@@ -40,6 +40,7 @@ struct at91_pm_data {
  	unsigned int pmc_mckr_offset;
  	unsigned int pmc_version;
  	unsigned int pmc_mcks;
+	unsigned int lpm;
  };
  #endif
 
arch/arm/mach-at91/pm_data-offsets.c +1 -0
index 0ca5da66dc26..fb9651abdfdf 100644
@@ -20,6 +20,7 @@ int main(void)
  						 pmc_version));
  	DEFINE(PM_DATA_PMC_MCKS,	offsetof(struct at91_pm_data,
  						 pmc_mcks));
+	DEFINE(PM_DATA_LPM,		offsetof(struct at91_pm_data, lpm));
 
  	return 0;
  }
arch/arm/mach-at91/pm_suspend.S +27 -3
index aad53ec9e957..198236bdbbb3 100644
@@ -110,9 +110,30 @@ lp_done_\ena:
  #endif
  	.endm
 
-	.macro at91_backup_set_lpm reg
+/*
+ * Set LPM
+ * @ena: 0 - disable LPM
+ *	 1 - enable LPM
+ *
+ * Side effects: overwrites r7, r8, r9
+ */
+	.macro at91_set_lpm ena
  #ifdef CONFIG_SOC_SAMA7
-	orr	\reg, \reg, #0x200000
+	ldr	r7, .lpm
+	cmp	r7, #1
+	bne	21f
+	ldr	r7, .shdwc
+	cmp	r7, #0
+	beq	21f
+	mov	r8, #0xA5000000
+	add	r8, #0x200000
+	mov	r9, #\ena
+	cmp	r9, #1
+	beq	20f
+	add	r8, #0x200000
+20:
+	str	r8, [r7]
+21:
  #endif
  	.endm
 
@@ -502,7 +523,7 @@ sr_dis_exit:
  	ldr	tmp1, [pmc, #AT91_PMC_SR]
  	str	tmp1, .saved_osc_status
  	tst	tmp1, #AT91_PMC_MOSCRCS
-	bne	1f
+	bne	7f
 
  	/* Turn off RC oscillator */
  	ldr	tmp1, [pmc, #AT91_CKGR_MOR]
@@ -516,6 +537,9 @@ sr_dis_exit:
  	tst	tmp1, #AT91_PMC_MOSCRCS
  	bne	2b
 
+	/* Enable LPM. */
+7:	at91_set_lpm 1
+
  	/* Wait for interrupt */
  1:	at91_cpu_idle
 

arch/arm/mach-at91/pm_suspend.S sr_dis_exit: · line 563

Quoted 9 lines
arch/arm/mach-at91/pm_suspend.S +4 -2
@@ -533,8 +557,10 @@ sr_dis_exit:
  	wait_mckrdy tmp3
  	b	6f
 
-5:	/* Restore RC oscillator state */
-	ldr	tmp1, .saved_osc_status
+5:	at91_set_lpm 0
+
+	/* Restore RC oscillator state */
+8:	ldr	tmp1, .saved_osc_status

"8:" in front of the line could be dropped

Thank you,
Claudiu

Quoted 52 lines
arch/arm/mach-at91/pm_suspend.S +13 -1
  	tst	tmp1, #AT91_PMC_MOSCRCS
  	beq	4f
 
@@ -611,6 +637,9 @@ sr_dis_exit:
 
  	wait_mckrdy tmp3
 
+	/* Enable LPM */
+	at91_set_lpm 1
+
  	/* Enter the ULP1 mode by set WAITMODE bit in CKGR_MOR */
  	ldr	tmp1, [pmc, #AT91_CKGR_MOR]
  	orr	tmp1, tmp1, #AT91_PMC_WAITMODE
@@ -624,6 +653,9 @@ sr_dis_exit:
 
  	wait_mckrdy tmp3
 
+	/* Disable LPM. */
+	at91_set_lpm 0
+
  	/* Enable the crystal oscillator */
  	ldr	tmp1, [pmc, #AT91_CKGR_MOR]
  	orr	tmp1, tmp1, #AT91_PMC_MOSCEN
@@ -1083,7 +1115,9 @@ ulp_exit:
  	ldr	r0, .shdwc
  	mov	tmp1, #0xA5000000
  	add	tmp1, tmp1, #0x1
-	at91_backup_set_lpm tmp1
+#ifdef CONFIG_SOC_SAMA7
+	orr	tmp1, tmp1, #0x200000
+#endif
  	str	tmp1, [r0, #0]
  .endm
 
@@ -1117,6 +1151,8 @@ ENTRY(at91_pm_suspend_in_sram)
  #ifdef CONFIG_SOC_SAMA7
  	ldr	tmp1, [r0, #PM_DATA_PMC_MCKS]
  	str	tmp1, .mcks
+	ldr	tmp1, [r0, #PM_DATA_LPM]
+	str	tmp1, .lpm
  #endif
 
  	/*
@@ -1208,6 +1244,8 @@ ENDPROC(at91_pm_suspend_in_sram)
  #ifdef CONFIG_SOC_SAMA7
  .mcks:
  	.word 0
+.lpm:
+	.word 0
  #endif
  .saved_mckr:
  	.word 0
#5 lore raw

Re: [PATCH 2/4] ARM: at91: PM: implement selection of LPM

In reply to [email protected]
kernel test robot noticed the following build warnings:

Hi,

kernel test robot noticed the following build warnings:

[auto build test WARNING on soc/for-next]
[also build test WARNING on cbeznea/tests linus/master v6.17-rc6] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Ryan-Wanner-microchip-com/dt-bindings-power-reset-atmel-sama5d2-shdwc-add-lpm-binding/20250911-002354
base:   https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git for-next
patch link:    https://lore.kernel.org/r/e72d9af1326cf44888059270263afde875ccc994.1757519351.git.Ryan.Wanner%40microchip.com
patch subject: [PATCH 2/4] ARM: at91: PM: implement selection of LPM
config: arm-randconfig-r131-20250915 (https://download.01.org/0day-ci/archive/20250915/[email protected]/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 21857ae337e0892a5522b6e7337899caa61de2a6)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250915/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

sparse warnings: (new ones prefixed by >>)

>> arch/arm/mach-at91/pm.c:283:75: sparse: sparse: Using plain integer as NULL pointer

arch/arm/mach-at91/pm.c:1101:30: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected void ( *static [assigned] [toplevel] at91_suspend_sram_fn )( ... ) @@ got void [noderef] __iomem * @@
arch/arm/mach-at91/pm.c:1101:30: sparse: expected void ( *static [assigned] [toplevel] at91_suspend_sram_fn )( ... )
arch/arm/mach-at91/pm.c:1101:30: sparse: got void [noderef] __iomem *

vim +283 arch/arm/mach-at91/pm.c

271
272 static int at91_pm_prepare_lpm(unsigned int pm_mode)
273 {
274 struct platform_device *pdev;
275 int ndevices, i, ret;
276 struct of_phandle_args lpmspec;
277
278 if ((pm_mode != AT91_PM_ULP0 && pm_mode != AT91_PM_ULP1) ||
279 !soc_pm.shdwc_np)
280 return 0;
281
282 ndevices = of_count_phandle_with_args(soc_pm.shdwc_np,

 > 283						      "microchip,lpm-connection", 0);

284 if (ndevices < 0)
285 return 0;
286
287 soc_pm.data.lpm = 1;
288 for (i = 0; i < ndevices; i++) {
289 ret = of_parse_phandle_with_args(soc_pm.shdwc_np,
290 "microchip,lpm-connection",
291 NULL, i, &lpmspec);
292 if (ret < 0) {
293 if (ret == -ENOENT) {
294 continue;
295 } else {
296 soc_pm.data.lpm = 0;
297 return ret;
298 }
299 }
300
301 pdev = of_find_device_by_node(lpmspec.np);
302 if (!pdev)
303 continue;
304
305 if (device_may_wakeup(&pdev->dev)) {
306 if (pm_mode == AT91_PM_ULP1) {
307 /*
308 * ULP1 wake-up sources are limited. Ignore it if not
309 * in soc_pm.ws_ids.
310 */
311 if (at91_pm_device_in_list(pdev, soc_pm.ws_ids))
312 soc_pm.data.lpm = 0;
313 } else {
314 soc_pm.data.lpm = 0;
315 }
316 }
317
318 put_device(&pdev->dev);
319 if (!soc_pm.data.lpm)
320 break;
321 }
322
323 return 0;
324 }
325

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#6 lore raw

PATCH 3/4 ARM: at91: pm: Remove 2.5V regulator

In reply to [email protected]

From: Ryan Wanner <[email protected]>

Remove 2.5V regulator since enabling and disabling this regulator is no longer supported.

---
 arch/arm/mach-at91/pm_suspend.S | 29 -----------------------------
 include/soc/at91/sama7-sfrbu.h  |  7 -------
 2 files changed, 36 deletions(-)
arch/arm/mach-at91/pm_suspend.S +0 -29
index 198236bdbbb3..36cae7b1a490 100644
@@ -87,29 +87,6 @@ tmp3	.req	r6
 
 	.endm
 
-/**
- * Set state for 2.5V low power regulator
- * @ena: 0 - disable regulator
- *	 1 - enable regulator
- *
- * Side effects: overwrites r7, r8, r9, r10
- */
-	.macro at91_2_5V_reg_set_low_power ena
-#ifdef CONFIG_SOC_SAMA7
-	ldr	r7, .sfrbu
-	mov	r8, #\ena
-	ldr	r9, [r7, #AT91_SFRBU_25LDOCR]
-	orr	r9, r9, #AT91_SFRBU_25LDOCR_LP
-	cmp	r8, #1
-	beq	lp_done_\ena
-	bic	r9, r9, #AT91_SFRBU_25LDOCR_LP
-lp_done_\ena:
-	ldr	r10, =AT91_SFRBU_25LDOCR_LDOANAKEY
-	orr	r9, r9, r10
-	str	r9, [r7, #AT91_SFRBU_25LDOCR]
-#endif
-	.endm
-
 /*
  * Set LPM
  * @ena: 0 - disable LPM
@@ -1055,9 +1032,6 @@ save_mck:
 
 	at91_plla_disable
 
-	/* Enable low power mode for 2.5V regulator. */
-	at91_2_5V_reg_set_low_power 1
-
 	ldr	tmp3, .pm_mode
 	cmp	tmp3, #AT91_PM_ULP1
 	beq	ulp1_mode
@@ -1070,9 +1044,6 @@ ulp1_mode:
 	b	ulp_exit
 
 ulp_exit:
-	/* Disable low power mode for 2.5V regulator. */
-	at91_2_5V_reg_set_low_power 0
-
 	ldr	pmc, .pmc_base
 
 	at91_plla_enable
include/soc/at91/sama7-sfrbu.h +0 -7
index 76b740810d34..8cee48d1ae2c 100644
@@ -18,13 +18,6 @@
 #define		AT91_SFRBU_PSWBU_SOFTSWITCH	(1 << 1)	/* Power switch BU source selection */
 #define		AT91_SFRBU_PSWBU_CTRL		(1 << 0)	/* Power switch BU control */
 
-#define AT91_SFRBU_25LDOCR			(0x0C)		/* SFRBU 2.5V LDO Control Register */
-#define		AT91_SFRBU_25LDOCR_LDOANAKEY	(0x3B6E18 << 8)	/* Specific value mandatory to allow writing of other register bits. */
-#define		AT91_SFRBU_25LDOCR_STATE	(1 << 3)	/* LDOANA Switch On/Off Control */
-#define		AT91_SFRBU_25LDOCR_LP		(1 << 2)	/* LDOANA Low-Power Mode Control */
-#define		AT91_SFRBU_PD_VALUE_MSK		(0x3)
-#define		AT91_SFRBU_25LDOCR_PD_VALUE(v)	((v) & AT91_SFRBU_PD_VALUE_MSK)	/* LDOANA Pull-down value */
-
 #define AT91_FRBU_DDRPWR			(0x10)		/* SFRBU DDR Power Control Register */
 #define		AT91_FRBU_DDRPWR_STATE		(1 << 0)	/* DDR Power Mode State */
 
Signature · 1 line
2.43.0
maintainer Acked-by on v1 3/4
#7 lore raw

Re: [PATCH 3/4] ARM: at91: pm: Remove 2.5V regulator

Quoted 6 lines · On 10/09/2025 at 18:20, [email protected] wrote:

From: Ryan Wanner <[email protected]>

Remove 2.5V regulator since enabling and disabling this regulator is no longer supported.

I take this one for at91-soc now. We will come back for the rest.

Regards,
Nicolas

Quoted 77 lines
---
  arch/arm/mach-at91/pm_suspend.S | 29 -----------------------------
  include/soc/at91/sama7-sfrbu.h  |  7 -------
  2 files changed, 36 deletions(-)
arch/arm/mach-at91/pm_suspend.S +0 -29
index 198236bdbbb3..36cae7b1a490 100644
@@ -87,29 +87,6 @@ tmp3	.req	r6
 
  	.endm
 
-/**
- * Set state for 2.5V low power regulator
- * @ena: 0 - disable regulator
- *	 1 - enable regulator
- *
- * Side effects: overwrites r7, r8, r9, r10
- */
-	.macro at91_2_5V_reg_set_low_power ena
-#ifdef CONFIG_SOC_SAMA7
-	ldr	r7, .sfrbu
-	mov	r8, #\ena
-	ldr	r9, [r7, #AT91_SFRBU_25LDOCR]
-	orr	r9, r9, #AT91_SFRBU_25LDOCR_LP
-	cmp	r8, #1
-	beq	lp_done_\ena
-	bic	r9, r9, #AT91_SFRBU_25LDOCR_LP
-lp_done_\ena:
-	ldr	r10, =AT91_SFRBU_25LDOCR_LDOANAKEY
-	orr	r9, r9, r10
-	str	r9, [r7, #AT91_SFRBU_25LDOCR]
-#endif
-	.endm
-
  /*
   * Set LPM
   * @ena: 0 - disable LPM
@@ -1055,9 +1032,6 @@ save_mck:
 
  	at91_plla_disable
 
-	/* Enable low power mode for 2.5V regulator. */
-	at91_2_5V_reg_set_low_power 1
-
  	ldr	tmp3, .pm_mode
  	cmp	tmp3, #AT91_PM_ULP1
  	beq	ulp1_mode
@@ -1070,9 +1044,6 @@ ulp1_mode:
  	b	ulp_exit
 
  ulp_exit:
-	/* Disable low power mode for 2.5V regulator. */
-	at91_2_5V_reg_set_low_power 0
-
  	ldr	pmc, .pmc_base
 
  	at91_plla_enable
include/soc/at91/sama7-sfrbu.h +0 -7
index 76b740810d34..8cee48d1ae2c 100644
@@ -18,13 +18,6 @@
  #define		AT91_SFRBU_PSWBU_SOFTSWITCH	(1 << 1)	/* Power switch BU source selection */
  #define		AT91_SFRBU_PSWBU_CTRL		(1 << 0)	/* Power switch BU control */
 
-#define AT91_SFRBU_25LDOCR			(0x0C)		/* SFRBU 2.5V LDO Control Register */
-#define		AT91_SFRBU_25LDOCR_LDOANAKEY	(0x3B6E18 << 8)	/* Specific value mandatory to allow writing of other register bits. */
-#define		AT91_SFRBU_25LDOCR_STATE	(1 << 3)	/* LDOANA Switch On/Off Control */
-#define		AT91_SFRBU_25LDOCR_LP		(1 << 2)	/* LDOANA Low-Power Mode Control */
-#define		AT91_SFRBU_PD_VALUE_MSK		(0x3)
-#define		AT91_SFRBU_25LDOCR_PD_VALUE(v)	((v) & AT91_SFRBU_PD_VALUE_MSK)	/* LDOANA Pull-down value */
-
  #define AT91_FRBU_DDRPWR			(0x10)		/* SFRBU DDR Power Control Register */
  #define		AT91_FRBU_DDRPWR_STATE		(1 << 0)	/* DDR Power Mode State */
 
#8 lore raw

PATCH 4/4 ARM: dts: at91: sama7g5ek: add microchip,lpm-connection on shdwc node

In reply to [email protected]

From: Claudiu Beznea <[email protected]>

Add microchip,lpm-connection binding to shdwc node. On SAMA7G5-EK REV4 LPM is connected to GMAC1's PHY, 24MHz oscillator and PMIC. On board PMIC is not listed here as it is only treated on BSR mode uncoditionally.

---
 arch/arm/boot/dts/microchip/at91-sama7g5ek.dts | 1 +
 1 file changed, 1 insertion(+)
arch/arm/boot/dts/microchip/at91-sama7g5ek.dts +1 -0
index 3924f62ff0fb..50e9a5a5732a 100644
@@ -872,6 +872,7 @@ &sdmmc2 {
 
 &shdwc {
 	debounce-delay-us = <976>;
+	microchip,lpm-connection = <&gmac1 &main_xtal>;
 	status = "okay";
 
 	input@0 {
Signature · 1 line
2.43.0