Skip to contentSkip to conversation

Enable Power Modes Support for SAMA7D65 SoC

PATCH Superseded [email protected] 2 participants 25 messages Jan 30, 2025

Subsystems (9)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover Enable Power Modes Support for SAMA7D65 SoC

From: Ryan Wanner <[email protected]>

This patch set adds support for low power modes for the SAMA7D65 SoC and the required components and changes for low power modes.

The series includes changes in the asm code to account for the addtional clocks that are in this SoC.

The Device tree additions are to enable all the components needed to keep the SoC in low power mode.

There are some DTB check warnings but that is due to the dt-binding not in the correct .yaml file format.

Li Bin (1):
ARM: at91: pm: fix at91_suspend_finish for ZQ calibration

Ryan Wanner (15):
dt-bindings: mfd: syscon: add microchip,sama7d65-ddr3phy
dt-bindings: mfd: syscon: add microchip,sama7d65-sfrbu
dt-bindings: sram: Add microchip,sama7d65-sram
dt-bindings: power: reset: atmel,sama5d2-shdwc: Add
microchip,sama7d65-shdwc
dt-bindings: reset: atmel,at91sam9260-reset: add
microchip,sama7d65-rstc
dt-bindings: rtc: at91rm9200: Reorganize compatible items
dt-bindings: rtc: at91rm9200: add microchip,sama7d65-rtc
dt-bindings: at91rm9260-rtt: add microchip,sama7d65-rtt
ARM: at91: Add PM support to sama7d65
ARM: at91: pm: add DT compatible support for sama7d65
ARM: at91: PM: Add Backup mode for SAMA7D65
ARM: at91: pm: Enable ULP0 for SAMA7D65
power: reset: at91-sama5d2_shdwc: Add sama7d65 PMC
ARM: dts: microchip: sama7d65: Add Reset and Shutdown and PM support
ARM: dts: microchip: add shutdown controller and rtt timer

 .../devicetree/bindings/mfd/syscon.yaml       |  3 +
 .../power/reset/atmel,sama5d2-shdwc.yaml      |  5 +
 .../reset/atmel,at91sam9260-reset.yaml        |  5 +
 .../bindings/rtc/atmel,at91rm9200-rtc.yaml    |  6 +-
 .../bindings/rtc/atmel,at91sam9260-rtt.yaml   |  5 +
 .../devicetree/bindings/sram/sram.yaml        |  1 +
 .../dts/microchip/at91-sama7d65_curiosity.dts | 14 +++
 arch/arm/boot/dts/microchip/sama7d65.dtsi     | 77 +++++++++++++++
 arch/arm/mach-at91/Kconfig                    |  1 +
 arch/arm/mach-at91/pm.c                       | 53 +++++++---
 arch/arm/mach-at91/pm.h                       |  1 +
 arch/arm/mach-at91/pm_data-offsets.c          |  2 +
 arch/arm/mach-at91/pm_suspend.S               | 97 +++++++++++++++++--
 drivers/power/reset/at91-sama5d2_shdwc.c      |  1 +
 14 files changed, 247 insertions(+), 24 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/16 dt-bindings: mfd: syscon: add microchip,sama7d65-ddr3phy

From: Ryan Wanner <[email protected]>

Add SAMA7D65 DDR3phy compatible to DT bindings documentation

---
 Documentation/devicetree/bindings/mfd/syscon.yaml | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/mfd/syscon.yaml +1 -0
index b414de4fa779b..54a6d5957e13a 100644
@@ -188,6 +188,7 @@ properties:
           - microchip,lan966x-cpu-syscon
           - microchip,mpfs-sysreg-scb
           - microchip,sam9x60-sfr
+          - microchip,sama7d65-ddr3phy
           - microchip,sama7g5-ddr3phy
           - mscc,ocelot-cpu-syscon
           - mstar,msc313-pmsleep
Signature · 1 line
2.43.0
maintainer Acked-by on v1 1/16
#2 lore raw

Re: [PATCH 01/16] dt-bindings: mfd: syscon: add microchip,sama7d65-ddr3phy

Quoted 9 lines · On Thu, 30 Jan 2025 10:33:41 -0700, [email protected] wrote:

From: Ryan Wanner <[email protected]>

Add SAMA7D65 DDR3phy compatible to DT bindings documentation

---
 Documentation/devicetree/bindings/mfd/syscon.yaml | 1 +
 1 file changed, 1 insertion(+)
maintainer
#3 lore raw

Re: [PATCH 01/16] dt-bindings: mfd: syscon: add microchip,sama7d65-ddr3phy

In reply to [email protected]
Quoted 14 lines · On Thu, Jan 30, 2025 at 10:33:41AM -0700, [email protected] wrote:

From: Ryan Wanner <[email protected]>

Add SAMA7D65 DDR3phy compatible to DT bindings documentation

---
 Documentation/devicetree/bindings/mfd/syscon.yaml | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/mfd/syscon.yaml +0 -0
index b414de4fa779b..54a6d5957e13a 100644

Documentation/devicetree/bindings/mfd/syscon.yaml properties: · line 194

Quoted 7 lines
Documentation/devicetree/bindings/mfd/syscon.yaml +1 -0
@@ -188,6 +188,7 @@ properties:
           - microchip,lan966x-cpu-syscon
           - microchip,mpfs-sysreg-scb
           - microchip,sam9x60-sfr
+          - microchip,sama7d65-ddr3phy
           - microchip,sama7g5-ddr3phy
           - mscc,ocelot-cpu-syscon
           - mstar,msc313-pmsleep

Actually, this needs to be in both lists of compatibles.

Quoted 3 lines
Signature · 1 line
2.43.0
#4 lore raw

PATCH 2/16 dt-bindings: mfd: syscon: add microchip,sama7d65-sfrbu

In reply to [email protected]

From: Ryan Wanner <[email protected]>

Add SAMA7D65 SFRBU compatible string to DT bindings documentation

---
 Documentation/devicetree/bindings/mfd/syscon.yaml | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/mfd/syscon.yaml +2 -0
index 54a6d5957e13a..25c4ed6cbf5d1 100644
@@ -90,6 +90,7 @@ select:
           - microchip,lan966x-cpu-syscon
           - microchip,mpfs-sysreg-scb
           - microchip,sam9x60-sfr
+          - microchip,sama7d65-sfrbu
           - microchip,sama7g5-ddr3phy
           - mscc,ocelot-cpu-syscon
           - mstar,msc313-pmsleep
@@ -188,6 +189,7 @@ properties:
           - microchip,lan966x-cpu-syscon
           - microchip,mpfs-sysreg-scb
           - microchip,sam9x60-sfr
+          - microchip,sama7d65-sfrbu
           - microchip,sama7d65-ddr3phy
           - microchip,sama7g5-ddr3phy
           - mscc,ocelot-cpu-syscon
Signature · 1 line
2.43.0
maintainer
#5 lore raw

Re: [PATCH 02/16] dt-bindings: mfd: syscon: add microchip,sama7d65-sfrbu

Quoted 22 lines · On Thu, Jan 30, 2025 at 10:33:42AM -0700, [email protected] wrote:

From: Ryan Wanner <[email protected]>

Add SAMA7D65 SFRBU compatible string to DT bindings documentation

---
 Documentation/devicetree/bindings/mfd/syscon.yaml | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/mfd/syscon.yaml +1 -0
index 54a6d5957e13a..25c4ed6cbf5d1 100644
@@ -90,6 +90,7 @@ select:
           - microchip,lan966x-cpu-syscon
           - microchip,mpfs-sysreg-scb
           - microchip,sam9x60-sfr
+          - microchip,sama7d65-sfrbu
           - microchip,sama7g5-ddr3phy
           - mscc,ocelot-cpu-syscon
           - mstar,msc313-pmsleep

Documentation/devicetree/bindings/mfd/syscon.yaml properties: · line 193

Quoted 5 lines
Documentation/devicetree/bindings/mfd/syscon.yaml +1 -0
@@ -188,6 +189,7 @@ properties:
           - microchip,lan966x-cpu-syscon
           - microchip,mpfs-sysreg-scb
           - microchip,sam9x60-sfr
+          - microchip,sama7d65-sfrbu
           - microchip,sama7d65-ddr3phy

Alphabetical order.

Quoted 5 lines
Documentation/devicetree/bindings/mfd/syscon.yaml +0 -0
           - microchip,sama7g5-ddr3phy
           - mscc,ocelot-cpu-syscon
Signature · 1 line
2.43.0
#6 lore raw

PATCH 3/16 dt-bindings: sram: Add microchip,sama7d65-sram

In reply to [email protected]

From: Ryan Wanner <[email protected]>

Add microchip,sama7d65-sram compatibility to DT binding documentation.

---
 Documentation/devicetree/bindings/sram/sram.yaml | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/sram/sram.yaml +1 -0
index 7c1337e159f23..3071c5075ee48 100644
@@ -31,6 +31,7 @@ properties:
         - amlogic,meson-gxbb-sram
         - arm,juno-sram-ns
         - atmel,sama5d2-securam
+        - microchip,sama7d65-securam
         - nvidia,tegra186-sysram
         - nvidia,tegra194-sysram
         - nvidia,tegra234-sysram
Signature · 1 line
2.43.0
maintainer Acked-by on v1 3/16
#7 lore raw

Re: [PATCH 03/16] dt-bindings: sram: Add microchip,sama7d65-sram

Quoted 9 lines · On Thu, 30 Jan 2025 10:33:43 -0700, [email protected] wrote:

From: Ryan Wanner <[email protected]>

Add microchip,sama7d65-sram compatibility to DT binding documentation.

---
 Documentation/devicetree/bindings/sram/sram.yaml | 1 +
 1 file changed, 1 insertion(+)
#8 lore raw

PATCH 4/16 dt-bindings: power: reset: atmel,sama5d2-shdwc: Add microchip,sama7d65-shdwc

In reply to [email protected]

From: Ryan Wanner <[email protected]>

Add SAMA7D65 SHDWC compatible to DT bindings documentation

---
 .../devicetree/bindings/power/reset/atmel,sama5d2-shdwc.yaml | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/power/reset/atmel,sama5d2-shdwc.yaml +5 -0
index 8c58e12cdb600..2930607480ea2 100644
@@ -16,6 +16,11 @@ description: |
 properties:
   compatible:
     oneOf:
+      - items:
+          - enum:
+              - microchip,sama7d65-shdwc
+          - const: microchip,sama7g5-shdwc
+          - const: syscon
       - items:
           - const: microchip,sama7g5-shdwc
           - const: syscon
Signature · 1 line
2.43.0
maintainer Acked-by on v1 4/16
#9 lore raw

Re: [PATCH 04/16] dt-bindings: power: reset: atmel,sama5d2-shdwc: Add microchip,sama7d65-shdwc

Quoted 9 lines · On Thu, 30 Jan 2025 10:33:44 -0700, [email protected] wrote:

From: Ryan Wanner <[email protected]>

Add SAMA7D65 SHDWC compatible to DT bindings documentation

---
 .../devicetree/bindings/power/reset/atmel,sama5d2-shdwc.yaml | 5 +++++
 1 file changed, 5 insertions(+)
#10 lore raw

PATCH 5/16 dt-bindings: reset: atmel,at91sam9260-reset: add microchip,sama7d65-rstc

In reply to [email protected]

From: Ryan Wanner <[email protected]>

Add SAMA7D65 RSTC compatible to DT bindings documentation. The sama7g54-rstc is compatible with the sama7g5-rstc.

---
 .../devicetree/bindings/reset/atmel,at91sam9260-reset.yaml   | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/reset/atmel,at91sam9260-reset.yaml +5 -0
index 98465d26949ee..a1c21c3880f9d 100644
@@ -23,6 +23,11 @@ properties:
               - atmel,sama5d3-rstc
               - microchip,sam9x60-rstc
               - microchip,sama7g5-rstc
+
+      - items:
+          - const: microchip,sama7d65-rstc
+          - const: microchip,sama7g5-rstc
+
       - items:
           - const: atmel,sama5d3-rstc
           - const: atmel,at91sam9g45-rstc
Signature · 1 line
2.43.0
maintainer
#11 lore raw

Re: [PATCH 05/16] dt-bindings: reset: atmel,at91sam9260-reset: add microchip,sama7d65-rstc

Quoted 4 lines · On Thu, Jan 30, 2025 at 10:33:45AM -0700, [email protected] wrote:

From: Ryan Wanner <[email protected]>

Add SAMA7D65 RSTC compatible to DT bindings documentation. The sama7g54-rstc is compatible with the sama7g5-rstc.

sama7d65-rstc?

Quoted 25 lines
---
 .../devicetree/bindings/reset/atmel,at91sam9260-reset.yaml   | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/reset/atmel,at91sam9260-reset.yaml +5 -0
index 98465d26949ee..a1c21c3880f9d 100644
@@ -23,6 +23,11 @@ properties:
               - atmel,sama5d3-rstc
               - microchip,sam9x60-rstc
               - microchip,sama7g5-rstc
+
+      - items:
+          - const: microchip,sama7d65-rstc
+          - const: microchip,sama7g5-rstc
+
       - items:
           - const: atmel,sama5d3-rstc
           - const: atmel,at91sam9g45-rstc
Signature · 1 line
2.43.0
#12 lore raw

PATCH 6/16 dt-bindings: rtc: at91rm9200: Reorganize compatible items

In reply to [email protected]

From: Ryan Wanner <[email protected]>

Reorganize compatible to allow more devices to be added to this enum.

---
 .../devicetree/bindings/rtc/atmel,at91rm9200-rtc.yaml        | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/rtc/atmel,at91rm9200-rtc.yaml +3 -2
index c8bb2eef442dd..30d87b74c51dc 100644
@@ -21,9 +21,10 @@ properties:
           - atmel,sama5d4-rtc
           - atmel,sama5d2-rtc
           - microchip,sam9x60-rtc
-          - microchip,sama7g5-rtc
       - items:
-          - const: microchip,sam9x7-rtc
+          - enum:
+              - microchip,sama7g5-rtc
+              - microchip,sam9x7-rtc
           - const: microchip,sam9x60-rtc
 
   reg:
Signature · 1 line
2.43.0
maintainer
#13 lore raw

Re: [PATCH 06/16] dt-bindings: rtc: at91rm9200: Reorganize compatible items

Quoted 3 lines · On Thu, Jan 30, 2025 at 10:33:46AM -0700, [email protected] wrote:

From: Ryan Wanner <[email protected]>

Reorganize compatible to allow more devices to be added to this enum.

This is doing more than reorganizing. It is changing the binding. Now 7g5 is compatible with 9x60?

Quoted 26 lines
---
 .../devicetree/bindings/rtc/atmel,at91rm9200-rtc.yaml        | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/rtc/atmel,at91rm9200-rtc.yaml +3 -2
index c8bb2eef442dd..30d87b74c51dc 100644
@@ -21,9 +21,10 @@ properties:
           - atmel,sama5d4-rtc
           - atmel,sama5d2-rtc
           - microchip,sam9x60-rtc
-          - microchip,sama7g5-rtc
       - items:
-          - const: microchip,sam9x7-rtc
+          - enum:
+              - microchip,sama7g5-rtc
+              - microchip,sam9x7-rtc
           - const: microchip,sam9x60-rtc
 
   reg:
Signature · 1 line
2.43.0
#14 lore raw

PATCH 7/16 dt-bindings: rtc: at91rm9200: add microchip,sama7d65-rtc

In reply to [email protected]

From: Ryan Wanner <[email protected]>

Add SAMA7D65 RTC compatible to DT bindings documentation.

---
 Documentation/devicetree/bindings/rtc/atmel,at91rm9200-rtc.yaml | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/rtc/atmel,at91rm9200-rtc.yaml +1 -0
index 30d87b74c51dc..d248cd49dbe23 100644
@@ -23,6 +23,7 @@ properties:
           - microchip,sam9x60-rtc
       - items:
           - enum:
+              - microchip,sama7d65-rtc
               - microchip,sama7g5-rtc
               - microchip,sam9x7-rtc
           - const: microchip,sam9x60-rtc
Signature · 1 line
2.43.0
#15 lore raw

PATCH 8/16 dt-bindings: at91rm9260-rtt: add microchip,sama7d65-rtt

In reply to [email protected]

From: Ryan Wanner <[email protected]>

Add SAMA7D65 RTT compatible to DT bindings documentation.

---
 .../devicetree/bindings/rtc/atmel,at91sam9260-rtt.yaml       | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/rtc/atmel,at91sam9260-rtt.yaml +5 -0
index a7f6c1d1a08ab..078b753f453b4 100644
@@ -23,6 +23,11 @@ properties:
               - microchip,sam9x60-rtt
               - microchip,sam9x7-rtt
           - const: atmel,at91sam9260-rtt
+      - items:
+          - enum:
+              - microchip,sama7d65-rtt
+          - const: microchip,sama7g5-rtt
+          - const: atmel,at91sam9260-rtt
       - items:
           - const: microchip,sama7g5-rtt
           - const: microchip,sam9x60-rtt
Signature · 1 line
2.43.0
maintainer
#16 lore raw

Re: [PATCH 08/16] dt-bindings: at91rm9260-rtt: add microchip,sama7d65-rtt

Quoted 14 lines · On Thu, Jan 30, 2025 at 10:33:48AM -0700, [email protected] wrote:

From: Ryan Wanner <[email protected]>

Add SAMA7D65 RTT compatible to DT bindings documentation.

---
 .../devicetree/bindings/rtc/atmel,at91sam9260-rtt.yaml       | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/rtc/atmel,at91sam9260-rtt.yaml +0 -0
index a7f6c1d1a08ab..078b753f453b4 100644

Documentation/devicetree/bindings/rtc/atmel,at91sam9260-rtt.yaml properties: · line 30

Quoted 8 lines
Documentation/devicetree/bindings/rtc/atmel,at91sam9260-rtt.yaml +5 -0
@@ -23,6 +23,11 @@ properties:
               - microchip,sam9x60-rtt
               - microchip,sam9x7-rtt
           - const: atmel,at91sam9260-rtt
+      - items:
+          - enum:
+              - microchip,sama7d65-rtt
+          - const: microchip,sama7g5-rtt
+          - const: atmel,at91sam9260-rtt

Does being compatible with 7g5 provide something over 9260? If not, probably better to just have 9260 as the only fallback.

Quoted 6 lines
Documentation/devicetree/bindings/rtc/atmel,at91sam9260-rtt.yaml +0 -0
       - items:
           - const: microchip,sama7g5-rtt
           - const: microchip,sam9x60-rtt
Signature · 1 line
2.43.0
#17 lore raw

PATCH 9/16 ARM: at91: Add PM support to sama7d65

In reply to [email protected]

From: Ryan Wanner <[email protected]>

Add PM support to SAMA7D65 SoC.

---
 arch/arm/mach-at91/Kconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm/mach-at91/Kconfig +1 -0
index 04bd91c72521c..f3ff1220c0fb0 100644
@@ -65,6 +65,7 @@ config SOC_SAMA7D65
 	select HAVE_AT91_SAM9X60_PLL
 	select HAVE_AT91_USB_CLK
 	select HAVE_AT91_UTMI
+	select PM_OPP
 	select SOC_SAMA7
 	help
 	  Select this if you are using one of Microchip's SAMA7D65 family SoC.
Signature · 1 line
2.43.0
#18 lore raw

PATCH 10/16 ARM: at91: pm: fix at91_suspend_finish for ZQ calibration

In reply to [email protected]

From: Li Bin <[email protected]>

For sama7g5 and sama7d65 backup mode, we encountered a "ZQ calibrate error" during recalibrating the impedance in BootStrap.
We found that the impedance value saved in at91_suspend_finish() before the DDR entered self-refresh mode did not match the resistor values. The ZDATA field in the DDR3PHY_ZQ0CR0 register uses a modified gray code to select the different impedance setting.
But these gray code are incorrect, a workaournd from design team fixed the bug in the calibration logic. The ZDATA contains four independent impedance elements, but the algorithm combined the four elements into one. The elements were fixed using properly shifted offsets.

---
 arch/arm/mach-at91/pm.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
arch/arm/mach-at91/pm.c +11 -10
index 05a1547642b60..32b8354738752 100644
@@ -545,11 +545,12 @@ extern u32 at91_pm_suspend_in_sram_sz;
 
 static int at91_suspend_finish(unsigned long val)
 {
-	unsigned char modified_gray_code[] = {
-		0x00, 0x01, 0x02, 0x03, 0x06, 0x07, 0x04, 0x05, 0x0c, 0x0d,
-		0x0e, 0x0f, 0x0a, 0x0b, 0x08, 0x09, 0x18, 0x19, 0x1a, 0x1b,
-		0x1e, 0x1f, 0x1c, 0x1d, 0x14, 0x15, 0x16, 0x17, 0x12, 0x13,
-		0x10, 0x11,
+	/* SYNOPSYS workaround to fix a bug in the calibration logic (SYNOPSYS Case Number 01331341) */
+	unsigned char modified_fix_code[] = {
+		0x00, 0x01, 0x01, 0x06, 0x07, 0x0c, 0x06, 0x07, 0x0b, 0x18,
+		0x0a, 0x0b, 0x0c, 0x0d, 0x0d, 0x0a, 0x13, 0x13, 0x12, 0x13,
+		0x14, 0x15, 0x15, 0x12, 0x18, 0x19, 0x19, 0x1e, 0x1f, 0x14,
+		0x1e, 0x1f,
 	};
 	unsigned int tmp, index;
 	int i;
@@ -560,25 +561,25 @@ static int at91_suspend_finish(unsigned long val)
 		 * restore the ZQ0SR0 with the value saved here. But the
 		 * calibration is buggy and restoring some values from ZQ0SR0
 		 * is forbidden and risky thus we need to provide processed
-		 * values for these (modified gray code values).
+		 * values for these.
 		 */
 		tmp = readl(soc_pm.data.ramc_phy + DDR3PHY_ZQ0SR0);
 
 		/* Store pull-down output impedance select. */
 		index = (tmp >> DDR3PHY_ZQ0SR0_PDO_OFF) & 0x1f;
-		soc_pm.bu->ddr_phy_calibration[0] = modified_gray_code[index];
+		soc_pm.bu->ddr_phy_calibration[0] = modified_fix_code[index] << DDR3PHY_ZQ0SR0_PDO_OFF;
 
 		/* Store pull-up output impedance select. */
 		index = (tmp >> DDR3PHY_ZQ0SR0_PUO_OFF) & 0x1f;
-		soc_pm.bu->ddr_phy_calibration[0] |= modified_gray_code[index];
+		soc_pm.bu->ddr_phy_calibration[0] |= modified_fix_code[index] << DDR3PHY_ZQ0SR0_PUO_OFF;
 
 		/* Store pull-down on-die termination impedance select. */
 		index = (tmp >> DDR3PHY_ZQ0SR0_PDODT_OFF) & 0x1f;
-		soc_pm.bu->ddr_phy_calibration[0] |= modified_gray_code[index];
+		soc_pm.bu->ddr_phy_calibration[0] |= modified_fix_code[index] << DDR3PHY_ZQ0SR0_PDODT_OFF;
 
 		/* Store pull-up on-die termination impedance select. */
 		index = (tmp >> DDR3PHY_ZQ0SRO_PUODT_OFF) & 0x1f;
-		soc_pm.bu->ddr_phy_calibration[0] |= modified_gray_code[index];
+		soc_pm.bu->ddr_phy_calibration[0] |= modified_fix_code[index] << DDR3PHY_ZQ0SRO_PUODT_OFF;
 
 		/*
 		 * The 1st 8 words of memory might get corrupted in the process
Signature · 1 line
2.43.0
#19 lore raw

PATCH 11/16 ARM: at91: pm: add DT compatible support for sama7d65

In reply to [email protected]

From: Ryan Wanner <[email protected]>

Add support for SAMA7D65 new compatible strings in pm.c file for wakeup source IDs and PMC.
This is the first bits of PM for this new SoC. PM depends on other patches.

[[email protected]: split patch and address only the pm.c changes]
---
 arch/arm/mach-at91/pm.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
arch/arm/mach-at91/pm.c +6 -3
index 32b8354738752..a8cd1300a8f33 100644
@@ -222,12 +222,14 @@ static const struct of_device_id sam9x60_ws_ids[] = {
 	{ /* sentinel */ }
 };
 
-static const struct of_device_id sama7g5_ws_ids[] = {
-	{ .compatible = "microchip,sama7g5-rtc",	.data = &ws_info[1] },
+static const struct of_device_id sama7_ws_ids[] = {
+	{ .compatible = "microchip,sama7d65-rtc",	.data = &ws_info[1] },
+	{ .compatible = "microchip,sama7g5-rtc",        .data = &ws_info[1] },
 	{ .compatible = "microchip,sama7g5-ohci",	.data = &ws_info[2] },
 	{ .compatible = "usb-ohci",			.data = &ws_info[2] },
 	{ .compatible = "atmel,at91sam9g45-ehci",	.data = &ws_info[2] },
 	{ .compatible = "usb-ehci",			.data = &ws_info[2] },
+	{ .compatible = "microchip,sama7d65-sdhci",	.data = &ws_info[3] },
 	{ .compatible = "microchip,sama7g5-sdhci",	.data = &ws_info[3] },
 	{ .compatible = "microchip,sama7g5-rtt",	.data = &ws_info[4] },
 	{ /* sentinel */ }
@@ -1379,6 +1381,7 @@ static const struct of_device_id atmel_pmc_ids[] __initconst = {
 	{ .compatible = "atmel,sama5d2-pmc", .data = &pmc_infos[1] },
 	{ .compatible = "microchip,sam9x60-pmc", .data = &pmc_infos[4] },
 	{ .compatible = "microchip,sam9x7-pmc", .data = &pmc_infos[4] },
+	{ .compatible = "microchip,sama7d65-pmc", .data = &pmc_infos[4] },
 	{ .compatible = "microchip,sama7g5-pmc", .data = &pmc_infos[5] },
 	{ /* sentinel */ },
 };
@@ -1672,7 +1675,7 @@ void __init sama7_pm_init(void)
 	at91_pm_modes_init(iomaps, ARRAY_SIZE(iomaps));
 	at91_pm_init(NULL);
 
-	soc_pm.ws_ids = sama7g5_ws_ids;
+	soc_pm.ws_ids = sama7_ws_ids;
 	soc_pm.config_pmc_ws = at91_sam9x60_config_pmc_ws;
 
 	soc_pm.sfrbu_regs.pswbu.key = (0x4BD20C << 8);
Signature · 1 line
2.43.0
#20 lore raw

PATCH 12/16 ARM: at91: PM: Add Backup mode for SAMA7D65

In reply to [email protected]

From: Ryan Wanner <[email protected]>

Add config check that enables Backup mode for SAMA7D65 SoC.

Add SHDWC_SR read to clear the status bits once finished exiting low power modes. This is only for SAMA7D65 SoCs.

---
 arch/arm/mach-at91/pm.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
arch/arm/mach-at91/pm.c +5 -1
index a8cd1300a8f33..5e458254e1f1c 100644
@@ -706,6 +706,9 @@ static int at91_pm_enter(suspend_state_t state)
 static void at91_pm_end(void)
 {
 	at91_pm_config_ws(soc_pm.data.mode, false);
+
+	if (IS_ENABLED(CONFIG_SOC_SAMA7D65))
+		readl(soc_pm.data.shdwc + 0x08);
 }
 
 
@@ -1064,7 +1067,8 @@ static int __init at91_pm_backup_init(void)
 	int ret = -ENODEV, located = 0;
 
 	if (!IS_ENABLED(CONFIG_SOC_SAMA5D2) &&
-	    !IS_ENABLED(CONFIG_SOC_SAMA7G5))
+	    !IS_ENABLED(CONFIG_SOC_SAMA7G5) &&
+	    !IS_ENABLED(CONFIG_SOC_SAMA7D65))
 		return -EPERM;
 
 	if (!at91_is_pm_mode_active(AT91_PM_BACKUP))
Signature · 1 line
2.43.0
#21 lore raw

PATCH 13/16 ARM: at91: pm: Enable ULP0 for SAMA7D65

In reply to [email protected]

From: Ryan Wanner <[email protected]>

New clocks are saved to enable ULP0 for SAMA7D65 because this SoC has a total of 10 main clocks that need to be saved for ULP0 mode.

Add mck_count member to at91_pm_data, this will be used to determine how many mcks need to be saved. In the mck_count member will also make sure that no unnecessary clock settings are written during mck_ps_restore.

Add SHDWC to ULP0 mapping to clear the SHDWC status after exiting low power modes.

---
 arch/arm/mach-at91/pm.c              | 19 +++++-
 arch/arm/mach-at91/pm.h              |  1 +
 arch/arm/mach-at91/pm_data-offsets.c |  2 +
 arch/arm/mach-at91/pm_suspend.S      | 97 ++++++++++++++++++++++++++--
 4 files changed, 110 insertions(+), 9 deletions(-)
arch/arm/mach-at91/pm.c +17 -2
index 5e458254e1f1c..e29c44924ac22 100644
@@ -1336,6 +1336,7 @@ struct pmc_info {
 	unsigned long uhp_udp_mask;
 	unsigned long mckr;
 	unsigned long version;
+	unsigned long mck_count;
 };
 
 static const struct pmc_info pmc_infos[] __initconst = {
@@ -1343,30 +1344,42 @@ static const struct pmc_info pmc_infos[] __initconst = {
 		.uhp_udp_mask = AT91RM9200_PMC_UHP | AT91RM9200_PMC_UDP,
 		.mckr = 0x30,
 		.version = AT91_PMC_V1,
+		.mck_count = 1,
 	},
 
 	{
 		.uhp_udp_mask = AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP,
 		.mckr = 0x30,
 		.version = AT91_PMC_V1,
+		.mck_count = 1,
 	},
 	{
 		.uhp_udp_mask = AT91SAM926x_PMC_UHP,
 		.mckr = 0x30,
 		.version = AT91_PMC_V1,
+		.mck_count = 1,
 	},
 	{	.uhp_udp_mask = 0,
 		.mckr = 0x30,
 		.version = AT91_PMC_V1,
+		.mck_count = 1,
 	},
 	{
 		.uhp_udp_mask = AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP,
 		.mckr = 0x28,
 		.version = AT91_PMC_V2,
+		.mck_count = 1,
 	},
 	{
 		.mckr = 0x28,
 		.version = AT91_PMC_V2,
+		.mck_count = 5,
+	},
+	{
+		.uhp_udp_mask = AT91SAM926x_PMC_UHP,
+		.mckr = 0x28,
+		.version = AT91_PMC_V2,
+		.mck_count = 10,
 	},
 
 };
@@ -1385,7 +1398,7 @@ static const struct of_device_id atmel_pmc_ids[] __initconst = {
 	{ .compatible = "atmel,sama5d2-pmc", .data = &pmc_infos[1] },
 	{ .compatible = "microchip,sam9x60-pmc", .data = &pmc_infos[4] },
 	{ .compatible = "microchip,sam9x7-pmc", .data = &pmc_infos[4] },
-	{ .compatible = "microchip,sama7d65-pmc", .data = &pmc_infos[4] },
+	{ .compatible = "microchip,sama7d65-pmc", .data = &pmc_infos[6] },
 	{ .compatible = "microchip,sama7g5-pmc", .data = &pmc_infos[5] },
 	{ /* sentinel */ },
 };
@@ -1456,6 +1469,7 @@ static void __init at91_pm_init(void (*pm_idle)(void))
 	soc_pm.data.uhp_udp_mask = pmc->uhp_udp_mask;
 	soc_pm.data.pmc_mckr_offset = pmc->mckr;
 	soc_pm.data.pmc_version = pmc->version;
+	soc_pm.data.pmc_mck_count = pmc->mck_count;
 
 	if (pm_idle)
 		arm_pm_idle = pm_idle;
@@ -1658,7 +1672,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 53bdc9000e447..ccde9c8728c27 100644
@@ -39,6 +39,7 @@ struct at91_pm_data {
 	unsigned int suspend_mode;
 	unsigned int pmc_mckr_offset;
 	unsigned int pmc_version;
+	unsigned int pmc_mck_count;
 };
 #endif
 
arch/arm/mach-at91/pm_data-offsets.c +2 -0
index 40bd4e8fe40a5..59a4838038381 100644
@@ -18,6 +18,8 @@ int main(void)
 						 pmc_mckr_offset));
 	DEFINE(PM_DATA_PMC_VERSION,	offsetof(struct at91_pm_data,
 						 pmc_version));
+	DEFINE(PM_DATA_PMC_MCK_COUNT,	offsetof(struct at91_pm_data,
+						 pmc_mck_count));
 
 	return 0;
 }
arch/arm/mach-at91/pm_suspend.S +90 -7

162 lines not on this page · raw message

Signature · 1 line
2.43.0
#22 lore raw

PATCH 14/16 power: reset: at91-sama5d2_shdwc: Add sama7d65 PMC

In reply to [email protected]

From: Ryan Wanner <[email protected]>

Add sama7d65-pmc compatible string to the list of valid PMC IDs.

---
 drivers/power/reset/at91-sama5d2_shdwc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/power/reset/at91-sama5d2_shdwc.c +1 -0
index edb0df86aff45..0cb7fe9f25a07 100644
@@ -326,6 +326,7 @@ static const struct of_device_id at91_pmc_ids[] = {
 	{ .compatible = "atmel,sama5d2-pmc" },
 	{ .compatible = "microchip,sam9x60-pmc" },
 	{ .compatible = "microchip,sama7g5-pmc" },
+	{ .compatible = "microchip,sama7d65-pmc" },
 	{ /* Sentinel. */ }
 };
 
Signature · 1 line
2.43.0
#23 lore raw

PATCH 15/16 ARM: dts: microchip: sama7d65: Add Reset and Shutdown and PM support

In reply to [email protected]

From: Ryan Wanner <[email protected]>

Add support for reset controller, wake up alarm timers, and shutdown controller.

Add SRAM, SFR, secumod, UDDRC, and DDR3phy to enable support for low power modes.

---
 arch/arm/boot/dts/microchip/sama7d65.dtsi | 77 +++++++++++++++++++++++
 1 file changed, 77 insertions(+)
arch/arm/boot/dts/microchip/sama7d65.dtsi +77 -0
index 854b30d15dcd4..8e117586e5902 100644
@@ -46,12 +46,42 @@ slow_xtal: clock-slowxtal {
 		};
 	};
 
+	ns_sram: sram@100000 {
+		compatible = "mmio-sram";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		reg = <0x100000 0x20000>;
+		ranges;
+	};
+
 	soc {
 		compatible = "simple-bus";
 		ranges;
 		#address-cells = <1>;
 		#size-cells = <1>;
 
+		securam: sram@e0000800 {
+			compatible = "microchip,sama7d65-securam", "atmel,sama5d2-securam", "mmio-sram";
+			reg = <0xe0000800 0x4000>;
+			clocks = <&pmc PMC_TYPE_PERIPHERAL 17>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges = <0 0xe0000800 0x4000>;
+			no-memory-wc;
+		};
+
+		secumod: secumod@e0004000 {
+			compatible = "microchip,sama7d65-secumod", "atmel,sama5d2-secumod", "syscon";
+			reg = <0xe0004000 0x4000>;
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
+		sfrbu: sfr@e0008000 {
+			compatible ="microchip,sama7d65-sfrbu", "atmel,sama5d2-sfrbu", "syscon";
+			reg = <0xe0008000 0x20>;
+		};
+
 		pioa: pinctrl@e0014000 {
 			compatible = "microchip,sama7d65-pinctrl", "microchip,sama7g5-pinctrl";
 			reg = <0xe0014000 0x800>;
@@ -76,6 +106,31 @@ pmc: clock-controller@e0018000 {
 			clock-names = "td_slck", "md_slck", "main_xtal";
 		};
 
+		reset_controller: reset-controller@e001d100 {
+			compatible = "microchip,sama7d65-rstc", "microchip,sama7g5-rstc";
+			reg = <0xe001d100 0xc>, <0xe001d1e4 0x4>;
+			#reset-cells = <1>;
+			clocks = <&clk32k 0>;
+		};
+
+		shdwc: poweroff@e001d200 {
+			compatible = "microchip,sama7d65-shdwc", "microchip,sama7g5-shdwc", "syscon";
+			reg = <0xe001d200 0x20>;
+			clocks = <&clk32k 0>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			atmel,wakeup-rtc-timer;
+			atmel,wakeup-rtt-timer;
+			status = "disabled";
+		};
+
+		rtt: rtc@e001d300 {
+			compatible = "microchip,sama7d65-rtt", "microchip,sama7g5-rtt", "atmel,at91sam9260-rtt";
+			reg = <0xe001d300 0x30>;
+			interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&clk32k 0>;
+		};
+
 		clk32k: clock-controller@e001d500 {
 			compatible = "microchip,sama7d65-sckc", "microchip,sam9x60-sckc";
 			reg = <0xe001d500 0x4>;
@@ -83,6 +138,18 @@ clk32k: clock-controller@e001d500 {
 			#clock-cells = <1>;
 		};
 
+		gpbr: gpbr@e001d700 {
+			compatible = "microchip,sama7d65-gpbr", "syscon";
+			reg = <0xe001d700 0x48>;
+		};
+
+		rtc: rtc@e001d800 {
+			compatible = "microchip,sama7d65-rtc", "microchip,sam9x60-rtc";
+			reg = <0xe001d800 0x30>;
+			interrupts = <GIC_SPI 6 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&clk32k 1>;
+		};
+
 		sdmmc1: mmc@e1208000 {
 			compatible = "microchip,sama7d65-sdhci", "microchip,sam9x60-sdhci";
 			reg = <0xe1208000 0x400>;
@@ -132,6 +199,16 @@ uart6: serial@200 {
 			};
 		};
 
+		uddrc: uddrc@e3800000 {
+			compatible = "microchip,sama7d65-uddrc", "microchip,sama7g5-uddrc";
+			reg = <0xe3800000 0x4000>;
+		};
+
+		ddr3phy: ddr3phy@e3804000 {
+			compatible = "microchip,sama7d65-ddr3phy", "microchip,sama7g5-ddr3phy";
+			reg = <0xe3804000 0x1000>;
+		};
+
 		gic: interrupt-controller@e8c11000 {
 			compatible = "arm,cortex-a7-gic";
 			reg = <0xe8c11000 0x1000>,
Signature · 1 line
2.43.0
#24 lore raw

PATCH 16/16 ARM: dts: microchip: add shutdown controller and rtt timer

In reply to [email protected]

From: Ryan Wanner <[email protected]>

Add shutdown controller and rtt timer to support shutdown and wake up.

---
 .../boot/dts/microchip/at91-sama7d65_curiosity.dts | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
arch/arm/boot/dts/microchip/at91-sama7d65_curiosity.dts +14 -0
index 0f86360fb733a..d1d0b06fbfc43 100644
@@ -77,6 +77,11 @@ pinctrl_uart6_default: uart6-default {
 	};
 };
 
+&rtt {
+	atmel,rtt-rtc-time-reg = <&gpbr 0x0>;
+	status = "disabled";
+};
+
 &sdmmc1 {
 	bus-width = <4>;
 	pinctrl-names = "default";
@@ -84,6 +89,15 @@ &sdmmc1 {
 	status = "okay";
 };
 
+&shdwc {
+	debounce-delay-us = <976>;
+	status = "okay";
+
+	input@0 {
+		reg = <0>;
+	};
+};
+
 &slow_xtal {
 	clock-frequency = <32768>;
 };
Signature · 1 line
2.43.0