Skip to contentSkip to conversation

socfpga: support suspend to ram*

PATCH Applied Alan Tull 4 participants 8 messages Jun 2, 2015 – Jun 9, 2015

Subsystems (6)
lore
Share & tools
lore

Alan Tull

author
#0 lore raw

v6 cover socfpga: support suspend to ram*

Support suspend to ram on socfpga.
* allocate space in ocram using sram driver.
* Add a function in ocram to place DDR in self-refresh and suspend.
* Prevent suspend if EDAC is enabled.
* Add a device tree binding document for the Altera SOCFPGA SDRAM controller that is used to put DDR in self-refresh mode.

Alan Tull (2):
ARM: socfpga: support suspend to ram
ARM: socfpga: dts: add sdram controller dt binding doc

 .../arm/altera/socfpga-sdram-controller.txt        |   12 ++
 arch/arm/mach-socfpga/Kconfig                      |   10 +-
 arch/arm/mach-socfpga/Makefile                     |    1 +
 arch/arm/mach-socfpga/core.h                       |    6 +-
 arch/arm/mach-socfpga/pm.c                         |  149 ++++++++++++++++++++
 arch/arm/mach-socfpga/self-refresh.S               |  136 ++++++++++++++++++
 arch/arm/mach-socfpga/socfpga.c                    |    6 +-
 drivers/edac/altera_edac.c                         |   20 +++
 8 files changed, 337 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/altera/socfpga-sdram-controller.txt
 create mode 100644 arch/arm/mach-socfpga/pm.c
 create mode 100644 arch/arm/mach-socfpga/self-refresh.S
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH v6 1/2 ARM: socfpga: support suspend to ram

Add code that requests that the sdr controller go into self-refresh mode. This code is run from ocram.

Suspend-to-RAM and EDAC support are mutually exclusive on SOCFPGA. If the EDAC is enabled, it will prevent the platform from going into suspend.

Example of how to request to suspend to ram:

 $ echo enabled > \
/sys/devices/soc/ffc02000.serial0/tty/ttyS0/power/wakeup
 $ echo -n mem > /sys/power/state
Cc Pavel Machek <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Steffen Trumtrar <[email protected]>

---
v2: use Generic on-chip SRAM driver to allocate ocram
rm fncpy_align since generic allocator handles alignment check __arm_ioremap_exec return code
check for NULL pointers
add a comment regarding sdram controller configuration
v3: fix renamed #define
propagate socfpga_setup_ocram_self_refresh error code
v4: Kconfig: don't need to select GENERIC_ALLOCATER
add CONFIG_SOCFPGA_SUSPEND
make s2r and EDAC support mutually exclusive socfpga.c: add sdr_ctl_base_addr
return error if ocram not available in device tree update copyright years
v5: remove compile time dependency
edac driver will prevent suspend
don't configure scu standby mode; done in enable_scu(). fix comments about required sdram controller configuration
v6: needed a static declaration

---
 arch/arm/mach-socfpga/Kconfig        |   10 ++-
 arch/arm/mach-socfpga/Makefile       |    1 +
 arch/arm/mach-socfpga/core.h         |    6 +-
 arch/arm/mach-socfpga/pm.c           |  149 ++++++++++++++++++++++++++++++++++
 arch/arm/mach-socfpga/self-refresh.S |  136 +++++++++++++++++++++++++++++++
 arch/arm/mach-socfpga/socfpga.c      |    6 +-
 drivers/edac/altera_edac.c           |   20 +++++
 7 files changed, 325 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/pm.c
 create mode 100644 arch/arm/mach-socfpga/self-refresh.S
arch/arm/mach-socfpga/Kconfig +9 -1
index b5f8d75..b26a684 100644
@@ -1,4 +1,4 @@
-config ARCH_SOCFPGA
+menuconfig ARCH_SOCFPGA
 	bool "Altera SOCFPGA family" if ARCH_MULTI_V7
 	select ARM_AMBA
 	select ARM_GIC
@@ -8,3 +8,11 @@ config ARCH_SOCFPGA
 	select HAVE_ARM_SCU
 	select HAVE_ARM_TWD if SMP
 	select MFD_SYSCON
+
+if ARCH_SOCFPGA
+config SOCFPGA_SUSPEND
+	bool "Suspend to RAM on SOCFPGA"
+	help
+	  Select this if you want to enable Suspend-to-RAM on SOCFPGA
+	  platforms.
+endif
arch/arm/mach-socfpga/Makefile +1 -0
index 6dd7a93..b8f9e23 100644
@@ -4,3 +4,4 @@
 
 obj-y					:= socfpga.o
 obj-$(CONFIG_SMP)	+= headsmp.o platsmp.o
+obj-$(CONFIG_SOCFPGA_SUSPEND)	+= pm.o self-refresh.o
arch/arm/mach-socfpga/core.h +5 -1
index 7637b7f..35472f2 100644
@@ -1,6 +1,6 @@
 /*
  * Copyright 2012 Pavel Machek <[email protected]>
- * Copyright (C) 2012 Altera Corporation
+ * Copyright (C) 2012-2015 Altera Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -40,6 +40,10 @@ extern void socfpga_sysmgr_init(void);
 
 extern void __iomem *sys_manager_base_addr;
 extern void __iomem *rst_manager_base_addr;
+extern void __iomem *sdr_ctl_base_addr;
+
+u32 socfpga_sdram_self_refresh(u32 sdr_base);
+extern unsigned int socfpga_sdram_self_refresh_sz;
 
 extern struct smp_operations socfpga_smp_ops;
 extern char secondary_trampoline, secondary_trampoline_end;
arch/arm/mach-socfpga/pm.c new file +149 -0

149 lines not on this page · raw message

arch/arm/mach-socfpga/self-refresh.S new file +136 -0

136 lines not on this page · raw message

arch/arm/mach-socfpga/socfpga.c +5 -1
index a154920..19643a7 100644
@@ -1,5 +1,5 @@
 /*
- *  Copyright (C) 2012 Altera Corporation
+ *  Copyright (C) 2012-2015 Altera Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -29,6 +29,7 @@
 
 void __iomem *sys_manager_base_addr;
 void __iomem *rst_manager_base_addr;
+void __iomem *sdr_ctl_base_addr;
 unsigned long socfpga_cpu1start_addr;
 
 void __init socfpga_sysmgr_init(void)
@@ -49,6 +50,9 @@ void __init socfpga_sysmgr_init(void)
 
 	np = of_find_compatible_node(NULL, NULL, "altr,rst-mgr");
 	rst_manager_base_addr = of_iomap(np, 0);
+
+	np = of_find_compatible_node(NULL, NULL, "altr,sdr-ctl");
+	sdr_ctl_base_addr = of_iomap(np, 0);
 }
 
 static void __init socfpga_init_irq(void)
drivers/edac/altera_edac.c +20 -0
index 3c4929f..e6490c7 100644
@@ -388,6 +388,23 @@ static int altr_sdram_remove(struct platform_device *pdev)
 	return 0;
 }
 
+/*
+ * If you want to suspend, need to disable EDAC by removing it
+ * from the device tree or defconfig.
+ */
+#ifdef CONFIG_PM
+static int altr_sdram_prepare(struct device *dev)
+{
+	pr_err("Suspend not allowed when EDAC is enabled.\n");
+
+	return -EPERM;
+}
+
+static const struct dev_pm_ops altr_sdram_pm_ops = {
+	.prepare = altr_sdram_prepare,
+};
+#endif
+
 static const struct of_device_id altr_sdram_ctrl_of_match[] = {
 	{ .compatible = "altr,sdram-edac", },
 	{},
@@ -399,6 +416,9 @@ static struct platform_driver altr_sdram_edac_driver = {
 	.remove = altr_sdram_remove,
 	.driver = {
 		.name = "altr_sdram_edac",
+#ifdef CONFIG_PM
+		.pm = &altr_sdram_pm_ops,
+#endif
 		.of_match_table = altr_sdram_ctrl_of_match,
 	},
 };
Signature · 1 line
1.7.9.5
author
#3 lore raw

PATCH v6 2/2 ARM: socfpga: dts: add sdram controller dt binding doc

In reply to Alan Tull

Add binding doc for Altera SOCFPGA SDRAM controller.

---
v4: Add bindings doc
v5: No change for v5
v6: No change for v6

---
 .../arm/altera/socfpga-sdram-controller.txt        |   12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/altera/socfpga-sdram-controller.txt
Documentation/devicetree/bindings/arm/altera/socfpga-sdram-controller.txt new file +12 -0
new file mode 100644
index 0000000..77ca635
@@ -0,0 +1,12 @@
+Altera SOCFPGA SDRAM Controller
+
+Required properties:
+- compatible : Should contain "altr,sdr-ctl" and "syscon".
+  syscon is required by the Altera SOCFPGA SDRAM EDAC.
+- reg : Should contain 1 register range (address and length)
+
+Example:
+	sdr: sdr at ffc25000 {
+		compatible = "altr,sdr-ctl", "syscon";
+		reg = <0xffc25000 0x1000>;
+	};
Signature · 1 line
1.7.9.5
Applied
#4 lore raw
In reply to Alan Tull
Quoted 13 lines · Alan Tull

Support suspend to ram on socfpga.
* allocate space in ocram using sram driver.
* Add a function in ocram to place DDR in self-refresh and suspend.
* Prevent suspend if EDAC is enabled.
* Add a device tree binding document for the Altera SOCFPGA SDRAM controller that is used to put DDR in self-refresh mode.

Alan Tull (2):
ARM: socfpga: support suspend to ram
ARM: socfpga: dts: add sdram controller dt binding doc

Quoted 13 lines
 .../arm/altera/socfpga-sdram-controller.txt        |   12 ++
 arch/arm/mach-socfpga/Kconfig                      |   10 +-
 arch/arm/mach-socfpga/Makefile                     |    1 +
 arch/arm/mach-socfpga/core.h                       |    6 +-
 arch/arm/mach-socfpga/pm.c                         |  149 ++++++++++++++++++++
 arch/arm/mach-socfpga/self-refresh.S               |  136 ++++++++++++++++++
 arch/arm/mach-socfpga/socfpga.c                    |    6 +-
 drivers/edac/altera_edac.c                         |   20 +++
 8 files changed, 337 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/altera/socfpga-sdram-controller.txt
 create mode 100644 arch/arm/mach-socfpga/pm.c
 create mode 100644 arch/arm/mach-socfpga/self-refresh.S

Applied.

Thanks Alan!

Dinh

#5 lore raw

Hi Alan,

Quoted 29 lines · Dinh Nguyen
Quoted 13 lines · Alan Tull

Support suspend to ram on socfpga.
* allocate space in ocram using sram driver.
* Add a function in ocram to place DDR in self-refresh and suspend.
* Prevent suspend if EDAC is enabled.
* Add a device tree binding document for the Altera SOCFPGA SDRAM controller that is used to put DDR in self-refresh mode.

Alan Tull (2):
ARM: socfpga: support suspend to ram
ARM: socfpga: dts: add sdram controller dt binding doc

Quoted 13 lines
 .../arm/altera/socfpga-sdram-controller.txt        |   12 ++
 arch/arm/mach-socfpga/Kconfig                      |   10 +-
 arch/arm/mach-socfpga/Makefile                     |    1 +
 arch/arm/mach-socfpga/core.h                       |    6 +-
 arch/arm/mach-socfpga/pm.c                         |  149 ++++++++++++++++++++
 arch/arm/mach-socfpga/self-refresh.S               |  136 ++++++++++++++++++
 arch/arm/mach-socfpga/socfpga.c                    |    6 +-
 drivers/edac/altera_edac.c                         |   20 +++
 8 files changed, 337 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/altera/socfpga-sdram-controller.txt
 create mode 100644 arch/arm/mach-socfpga/pm.c
 create mode 100644 arch/arm/mach-socfpga/self-refresh.S
Quoted 2 lines

Applied.

I had to un-apply this patch because I noticed that it's touching drivers/edac/altera_edac.c. This part should be a separate patch and need to go through linux-edac.

Dinh

#6 lore raw
Quoted 32 lines · Dinh Nguyen

Hi Alan,

Quoted 29 lines · Dinh Nguyen
Quoted 26 lines · Alan Tull

Support suspend to ram on socfpga.
* allocate space in ocram using sram driver.
* Add a function in ocram to place DDR in self-refresh and suspend.
* Prevent suspend if EDAC is enabled.
* Add a device tree binding document for the Altera SOCFPGA SDRAM controller that is used to put DDR in self-refresh mode.

Alan Tull (2):
ARM: socfpga: support suspend to ram
ARM: socfpga: dts: add sdram controller dt binding doc

 .../arm/altera/socfpga-sdram-controller.txt        |   12 ++
 arch/arm/mach-socfpga/Kconfig                      |   10 +-
 arch/arm/mach-socfpga/Makefile                     |    1 +
 arch/arm/mach-socfpga/core.h                       |    6 +-
 arch/arm/mach-socfpga/pm.c                         |  149 ++++++++++++++++++++
 arch/arm/mach-socfpga/self-refresh.S               |  136 ++++++++++++++++++
 arch/arm/mach-socfpga/socfpga.c                    |    6 +-
 drivers/edac/altera_edac.c                         |   20 +++
 8 files changed, 337 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/altera/socfpga-sdram-controller.txt
 create mode 100644 arch/arm/mach-socfpga/pm.c
 create mode 100644 arch/arm/mach-socfpga/self-refresh.S
Quoted 7 lines
Quoted 2 lines

Applied.

I had to un-apply this patch because I noticed that it's touching drivers/edac/altera_edac.c. This part should be a separate patch and need to go through linux-edac.

Nevermind on this, I got an ack-by from Borislav Petkov for the edac part. No need to split the patch up.

Dinh

author
#7 lore raw
Quoted 42 lines · Dinh Nguyen
Quoted 32 lines · Dinh Nguyen

Hi Alan,

Quoted 29 lines · Dinh Nguyen
Quoted 26 lines · Alan Tull

Support suspend to ram on socfpga.
* allocate space in ocram using sram driver.
* Add a function in ocram to place DDR in self-refresh and suspend.
* Prevent suspend if EDAC is enabled.
* Add a device tree binding document for the Altera SOCFPGA SDRAM controller that is used to put DDR in self-refresh mode.

Alan Tull (2):
ARM: socfpga: support suspend to ram
ARM: socfpga: dts: add sdram controller dt binding doc

 .../arm/altera/socfpga-sdram-controller.txt        |   12 ++
 arch/arm/mach-socfpga/Kconfig                      |   10 +-
 arch/arm/mach-socfpga/Makefile                     |    1 +
 arch/arm/mach-socfpga/core.h                       |    6 +-
 arch/arm/mach-socfpga/pm.c                         |  149 ++++++++++++++++++++
 arch/arm/mach-socfpga/self-refresh.S               |  136 ++++++++++++++++++
 arch/arm/mach-socfpga/socfpga.c                    |    6 +-
 drivers/edac/altera_edac.c                         |   20 +++
 8 files changed, 337 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/altera/socfpga-sdram-controller.txt
 create mode 100644 arch/arm/mach-socfpga/pm.c
 create mode 100644 arch/arm/mach-socfpga/self-refresh.S
Quoted 7 lines
Quoted 2 lines

Applied.

I had to un-apply this patch because I noticed that it's touching drivers/edac/altera_edac.c. This part should be a separate patch and need to go through linux-edac.

Quoted 5 lines

Nevermind on this, I got an ack-by from Borislav Petkov for the edac part. No need to split the patch up.

Dinh

Sorry for the trouble and Thanks!

Alan

#2 lore raw

Re: [PATCHv6 1/2] ARM: socfpga: support suspend to ram

In reply to Alan Tull

Hi!

arch/arm/mach-socfpga/self-refresh.S line 29

Quoted 3 lines
arch/arm/mach-socfpga/self-refresh.S new file +3 -0
+/* Bitfield positions */
+#define SELFRSHREQ_POS                  3
+#define SELFRFSHACK_POS                 1

These two defines are unused and should be deleted.

Thanks,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html