Skip to contentSkip to conversation

Broadcom STB S2/S3/S5 support for ARM and MIPS

PATCH Superseded Florian Fainelli 3 participants 16 messages Jun 26, 2017 – Jun 28, 2017

Subsystems (6)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Broadcom STB S2/S3/S5 support for ARM and MIPS

Hi,

This patch series adds support for S2/S3/S5 suspend/resume states on ARM and MIPS based Broadcom STB SoCs.

This was submitted a long time ago by Brian, and I am now picking this up and trying to get this included with support for our latest chips.

Provided that I can collect the necessary Acks from Rob (DT) and other people (Rafael?) I would probably take this via the Broadcom ARM SoC pull requests.

Thank you!

Changes in v2:

- clarify the first patch's subject (Rob)
- removed patch #2 which was creating a bisectability problem (kbuild)
- added proper AFLAGS to get s2-arm.S to build properly (kbuild)
- improved MIPS power management binding document (Rob)

Brian Norris (1):
soc: bcm: brcmstb: Add support for S2/S3/S5 suspend states (ARM)

Florian Fainelli (2):
dt-bindings: ARM: brcmstb: Update Broadcom STB Power Management
binding
dt-bindings: Document MIPS Broadcom STB power management nodes

Justin Chen (1):
soc bcm: brcmstb: Add support for S2/S3/S5 suspend states (MIPS)

 .../devicetree/bindings/arm/bcm/brcm,brcmstb.txt   |   6 +-
 .../devicetree/bindings/mips/brcm/soc.txt          | 153 ++++
 drivers/soc/bcm/Kconfig                            |   2 +
 drivers/soc/bcm/brcmstb/Kconfig                    |   9 +
 drivers/soc/bcm/brcmstb/Makefile                   |   1 +
 drivers/soc/bcm/brcmstb/pm/Makefile                |   3 +
 drivers/soc/bcm/brcmstb/pm/aon_defs.h              | 113 +++
 drivers/soc/bcm/brcmstb/pm/pm-arm.c                | 836 +++++++++++++++++++++
 drivers/soc/bcm/brcmstb/pm/pm-mips.c               | 461 ++++++++++++
 drivers/soc/bcm/brcmstb/pm/pm.h                    |  89 +++
 drivers/soc/bcm/brcmstb/pm/s2-arm.S                |  76 ++
 drivers/soc/bcm/brcmstb/pm/s2-mips.S               | 200 +++++
 drivers/soc/bcm/brcmstb/pm/s3-mips.S               | 146 ++++
 13 files changed, 2094 insertions(+), 1 deletion(-)
 create mode 100644 drivers/soc/bcm/brcmstb/Kconfig
 create mode 100644 drivers/soc/bcm/brcmstb/pm/Makefile
 create mode 100644 drivers/soc/bcm/brcmstb/pm/aon_defs.h
 create mode 100644 drivers/soc/bcm/brcmstb/pm/pm-arm.c
 create mode 100644 drivers/soc/bcm/brcmstb/pm/pm-mips.c
 create mode 100644 drivers/soc/bcm/brcmstb/pm/pm.h
 create mode 100644 drivers/soc/bcm/brcmstb/pm/s2-arm.S
 create mode 100644 drivers/soc/bcm/brcmstb/pm/s2-mips.S
 create mode 100644 drivers/soc/bcm/brcmstb/pm/s3-mips.S
Signature · 1 line
2.9.3
#1 lore raw

PATCH v2 1/4 dt-bindings: ARM: brcmstb: Update Broadcom STB Power Management binding

Update the Broadcom STB Power Management binding document with new compatible strings for the DDR PHY and memory controller found on newer chips.

---
 Documentation/devicetree/bindings/arm/bcm/brcm,brcmstb.txt | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/arm/bcm/brcm,brcmstb.txt +5 -1
index 0d0c1ae81bed..790e6b0b8306 100644
@@ -164,6 +164,8 @@ Control registers for this memory controller's DDR PHY.
 
 Required properties:
 - compatible     : should contain one of these
+	"brcm,brcmstb-ddr-phy-v71.1"
+	"brcm,brcmstb-ddr-phy-v72.0"
 	"brcm,brcmstb-ddr-phy-v225.1"
 	"brcm,brcmstb-ddr-phy-v240.1"
 	"brcm,brcmstb-ddr-phy-v240.2"
@@ -184,7 +186,9 @@ Sequencer DRAM parameters and control registers. Used for Self-Refresh
 Power-Down (SRPD), among other things.
 
 Required properties:
-- compatible     : should contain "brcm,brcmstb-memc-ddr"
+- compatible     : should contain one of these
+	"brcm,brcmstb-memc-ddr-rev-b.2.2"
+	"brcm,brcmstb-memc-ddr"
 - reg            : the MEMC DDR register range
 
 Example:
Signature · 1 line
2.9.3
maintainer Acked-by on v2 1/4
#2 lore raw

Re: [PATCH v2 1/4] dt-bindings: ARM: brcmstb: Update Broadcom STB Power Management binding

Quoted 8 lines · Florian Fainelli

Update the Broadcom STB Power Management binding document with new compatible strings for the DDR PHY and memory controller found on newer chips.

---
 Documentation/devicetree/bindings/arm/bcm/brcm,brcmstb.txt | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
#3 lore raw

PATCH v2 1/4 misc: sram: Allow ARM64 to select SRAM_EXEC

In reply to Florian Fainelli

Now that ARM64 also has a fncpy() implementation, allow selection SRAM_EXEC for ARM64 as well.

---
 drivers/misc/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/Kconfig +1 -1
index 07bbd4cc1852..ac8779278c0c 100644
@@ -464,7 +464,7 @@ config SRAM
 	bool "Generic on-chip SRAM driver"
 	depends on HAS_IOMEM
 	select GENERIC_ALLOCATOR
-	select SRAM_EXEC if ARM
+	select SRAM_EXEC if ARM || ARM64
 	help
 	  This driver allows you to declare a memory region to be managed by
 	  the genalloc API. It is supposed to be used for small on-chip SRAM
Signature · 1 line
2.9.3
#4 lore raw

Re: [PATCH 1/4] misc: sram: Allow ARM64 to select SRAM_EXEC

Quoted 4 lines · Florian Fainelli

Now that ARM64 also has a fncpy() implementation, allow selection SRAM_EXEC for ARM64 as well.

Sorr,y but I must NAK this patch.

As mentioned on prior threads regarding fncpy, I do not think it makes sense to enable this for arm64. The only use-cases that have been described so far for this are power-management stuff that should live in PSCI or other secure FW, and have no place in the kernel on arm64.

There are no other users of this functionality, and until there are, I see no reason to enable this, and risk a proliferation of unnecessary platform-specific code.

It should be possible to #ifdef-ise the relevant callers of this such that they can be built on arm64 without using fncpy or sram_exec functionality. AFAICT, there are no users on arm64 introduced by this series.

Thanks,
Mark.

Quoted 20 lines
---
 drivers/misc/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/Kconfig +1 -1
index 07bbd4cc1852..ac8779278c0c 100644
@@ -464,7 +464,7 @@ config SRAM
 	bool "Generic on-chip SRAM driver"
 	depends on HAS_IOMEM
 	select GENERIC_ALLOCATOR
-	select SRAM_EXEC if ARM
+	select SRAM_EXEC if ARM || ARM64
 	help
 	  This driver allows you to declare a memory region to be managed by
 	  the genalloc API. It is supposed to be used for small on-chip SRAM
Signature · 1 line
2.9.3
#5 lore raw

Re: [PATCH 1/4] misc: sram: Allow ARM64 to select SRAM_EXEC

Quoted 4 lines · Mark Rutland
Quoted 3 lines · Florian Fainelli

Now that ARM64 also has a fncpy() implementation, allow selection SRAM_EXEC for ARM64 as well.

Quoted 8 lines
Quoted 1 line

Sorr,y but I must NAK this patch.

As mentioned on prior threads regarding fncpy, I do not think it makes sense to enable this for arm64. The only use-cases that have been described so far for this are power-management stuff that should live in PSCI or other secure FW, and have no place in the kernel on arm64

This is a valid reason, but this is only one use case presented, the only thing is that we need to make sure, as patch reviewers and you guys as architecture maintainers, that this is not used as a means to bypass PSCI for suspend/resume operation, which I now agree with.

Still, the general use case remains: you have a piece of addressable memory which can be used to allocate space from and relocate code to be it for security, performance, predictability, isolation, or anything, and that should be possible given standard kernel facilities offered by the SRAM driver.

Quoted 8 lines
Quoted 1 line

There are no other users of this functionality, and until there are, I

see no reason to enable this, and risk a proliferation of unnecessary platform-specific code.

It should be possible to #ifdef-ise the relevant callers of this such that they can be built on arm64 without using fncpy or sram_exec functionality. AFAICT, there are no users on arm64 introduced by this series.

I sent this patch accidentally as part of this patch series anyway, so if you want to keep the discussion alive, reply here:

https://patchwork.kernel.org/patch/9793745/

Quoted 24 lines

Thanks,
Mark.

Quoted 20 lines
---
 drivers/misc/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/Kconfig +1 -1
index 07bbd4cc1852..ac8779278c0c 100644
@@ -464,7 +464,7 @@ config SRAM
 	bool "Generic on-chip SRAM driver"
 	depends on HAS_IOMEM
 	select GENERIC_ALLOCATOR
-	select SRAM_EXEC if ARM
+	select SRAM_EXEC if ARM || ARM64
 	help
 	  This driver allows you to declare a memory region to be managed by
 	  the genalloc API. It is supposed to be used for small on-chip SRAM
Signature · 1 line
2.9.3
Signature · 1 line
Florian
#6 lore raw

Re: [PATCH 1/4] misc: sram: Allow ARM64 to select SRAM_EXEC

Quoted 19 lines · Florian Fainelli
Quoted 4 lines · Mark Rutland
Quoted 3 lines · Florian Fainelli

Now that ARM64 also has a fncpy() implementation, allow selection SRAM_EXEC for ARM64 as well.

Quoted 8 lines
Quoted 1 line

Sorr,y but I must NAK this patch.

As mentioned on prior threads regarding fncpy, I do not think it makes sense to enable this for arm64. The only use-cases that have been described so far for this are power-management stuff that should live in PSCI or other secure FW, and have no place in the kernel on arm64

This is a valid reason, but this is only one use case presented, the only thing is that we need to make sure, as patch reviewers and you guys as architecture maintainers, that this is not used as a means to bypass PSCI for suspend/resume operation, which I now agree with.

Quoted 5 lines

Still, the general use case remains: you have a piece of addressable memory which can be used to allocate space from and relocate code to be it for security, performance, predictability, isolation, or anything, and that should be possible given standard kernel facilities offered by the SRAM driver.

While I agree that these are *theoretically* possible use cases, they aren't *real* cases today.

If someone comes by with code that needs this (which doesn't fall into one of those NAK'd cases above), then I'm happy for this to be enabled for that feature.

Until such time, I see no reason to enable this. Given it comes with strong the potential for abuse, I'd rather it remained disabled.

Quoted 9 lines
Quoted 8 lines
Quoted 1 line

There are no other users of this functionality, and until there are, I

see no reason to enable this, and risk a proliferation of unnecessary platform-specific code.

It should be possible to #ifdef-ise the relevant callers of this such that they can be built on arm64 without using fncpy or sram_exec functionality. AFAICT, there are no users on arm64 introduced by this series.

Quoted 4 lines

I sent this patch accidentally as part of this patch series anyway, so if you want to keep the discussion alive, reply here:

https://patchwork.kernel.org/patch/9793745/

That appears to be v2 of the series, and there's a v3 afterwards, so I've replied on v3.

Thanks,
Mark.

#7 lore raw

PATCH v2 2/4 misc: sram-exec: Use aligned fncpy instead of memcpy

In reply to Florian Fainelli

From: Dave Gerlach <[email protected]>

Currently the sram-exec functionality, which allows allocation of executable memory and provides an API to move code to it, is only selected in configs for the ARM architecture. Based on commit 5756e9dd0de6 ("ARM: 6640/1: Thumb-2: Symbol manipulation macros for function body copying") simply copying a C function pointer address using memcpy without consideration of alignment and Thumb is unsafe on ARM platforms.

The aforementioned patch introduces the fncpy macro which is a safe way to copy executable code on ARM platforms, so let's make use of that here rather than the unsafe plain memcpy that was previously used by sram_exec_copy. Now sram_exec_copy will move the code to "dst" and return an address that is guaranteed to be safely callable.

In the future, architectures hoping to make use of the sram-exec functionality must define an fncpy macro just as ARM has done to guarantee or check for safe copying to executable memory before allowing the arch to select CONFIG_SRAM_EXEC.

---
 drivers/misc/sram-exec.c | 27 ++++++++++++++++++++-------
 include/linux/sram.h     |  8 ++++----
 2 files changed, 24 insertions(+), 11 deletions(-)
drivers/misc/sram-exec.c +20 -7
index 3d528a13b8fc..426ad912b441 100644
@@ -19,6 +19,7 @@
 #include <linux/mm.h>
 #include <linux/sram.h>
 
+#include <asm/fncpy.h>
 #include <asm/set_memory.h>
 
 #include "sram.h"
@@ -58,20 +59,32 @@ int sram_add_protect_exec(struct sram_partition *part)
  * @src: Source address for the data to copy
  * @size: Size of copy to perform, which starting from dst, must reside in pool
  *
+ * Return: Address for copied data that can safely be called through function
+ *	   pointer, or NULL if problem.
+ *
  * This helper function allows sram driver to act as central control location
  * of 'protect-exec' pools which are normal sram pools but are always set
  * read-only and executable except when copying data to them, at which point
  * they are set to read-write non-executable, to make sure no memory is
  * writeable and executable at the same time. This region must be page-aligned
  * and is checked during probe, otherwise page attribute manipulation would
- * not be possible.
+ * not be possible. Care must be taken to only call the returned address as
+ * dst address is not guaranteed to be safely callable.
+ *
+ * NOTE: This function uses the fncpy macro to move code to the executable
+ * region. Some architectures have strict requirements for relocating
+ * executable code, so fncpy is a macro that must be defined by any arch
+ * making use of this functionality that guarantees a safe copy of exec
+ * data and returns a safe address that can be called as a C function
+ * pointer.
  */
-int sram_exec_copy(struct gen_pool *pool, void *dst, void *src,
-		   size_t size)
+void *sram_exec_copy(struct gen_pool *pool, void *dst, void *src,
+		     size_t size)
 {
 	struct sram_partition *part = NULL, *p;
 	unsigned long base;
 	int pages;
+	void *dst_cpy;
 
 	mutex_lock(&exec_pool_list_mutex);
 	list_for_each_entry(p, &exec_pool_list, list) {
@@ -81,10 +94,10 @@ int sram_exec_copy(struct gen_pool *pool, void *dst, void *src,
 	mutex_unlock(&exec_pool_list_mutex);
 
 	if (!part)
-		return -EINVAL;
+		return NULL;
 
 	if (!addr_in_gen_pool(pool, (unsigned long)dst, size))
-		return -EINVAL;
+		return NULL;
 
 	base = (unsigned long)part->base;
 	pages = PAGE_ALIGN(size) / PAGE_SIZE;
@@ -94,13 +107,13 @@ int sram_exec_copy(struct gen_pool *pool, void *dst, void *src,
 	set_memory_nx((unsigned long)base, pages);
 	set_memory_rw((unsigned long)base, pages);
 
-	memcpy(dst, src, size);
+	dst_cpy = fncpy(dst, src, size);
 
 	set_memory_ro((unsigned long)base, pages);
 	set_memory_x((unsigned long)base, pages);
 
 	mutex_unlock(&part->lock);
 
-	return 0;
+	return dst_cpy;
 }
 EXPORT_SYMBOL_GPL(sram_exec_copy);
include/linux/sram.h +4 -4
index c97dcbe8ce25..4fb405fb0480 100644
@@ -16,12 +16,12 @@
 struct gen_pool;
 
 #ifdef CONFIG_SRAM_EXEC
-int sram_exec_copy(struct gen_pool *pool, void *dst, void *src, size_t size);
+void *sram_exec_copy(struct gen_pool *pool, void *dst, void *src, size_t size);
 #else
-static inline int sram_exec_copy(struct gen_pool *pool, void *dst, void *src,
-				 size_t size)
+static inline void *sram_exec_copy(struct gen_pool *pool, void *dst, void *src,
+				   size_t size)
 {
-	return -ENODEV;
+	return NULL;
 }
 #endif /* CONFIG_SRAM_EXEC */
 #endif /* __LINUX_SRAM_H__ */
Signature · 1 line
2.9.3
#8 lore raw

PATCH v2 2/4 soc: bcm: brcmstb: Add support for S2/S3/S5 suspend states (ARM)

In reply to Florian Fainelli

From: Brian Norris <[email protected]>

This commit adds support for the Broadcom STB S2/S3/S5 suspend states on ARM based SoCs.

This requires quite a lot of code in order to deal with the different HW blocks that need to be quiesced during suspend:

- DDR PHY SHIM
- DDR memory controller and sequencer
- control processor

The final steps of the suspend execute in an on-chip SRAM and there is a little bit of assembly code in order to shut down the DDR PHY PLL and then go into a wfi loop until a wake-up even occurs. Conversely the resume part involves waiting for the DDR PHY PLL to come back up and resume executions where we left.

For S3, because of our memory hashing (actual hashing code not included for simplicity, and is bypassed) we need to relocate the writable variables (stack) into SRAM shortly before suspending in order to leave the DRAM untouched and create a reliable hash of its contents.

This code has been contributed by Brian Norris initially and has been incrementally fixed and updated to support new chips by a lot of people.

---
 drivers/soc/bcm/Kconfig               |   2 +
 drivers/soc/bcm/brcmstb/Kconfig       |   9 +
 drivers/soc/bcm/brcmstb/Makefile      |   1 +
 drivers/soc/bcm/brcmstb/pm/Makefile   |   2 +
 drivers/soc/bcm/brcmstb/pm/aon_defs.h | 113 +++++
 drivers/soc/bcm/brcmstb/pm/pm-arm.c   | 836 ++++++++++++++++++++++++++++++++++
 drivers/soc/bcm/brcmstb/pm/pm.h       |  78 ++++
 drivers/soc/bcm/brcmstb/pm/s2-arm.S   |  76 ++++
 8 files changed, 1117 insertions(+)
 create mode 100644 drivers/soc/bcm/brcmstb/Kconfig
 create mode 100644 drivers/soc/bcm/brcmstb/pm/Makefile
 create mode 100644 drivers/soc/bcm/brcmstb/pm/aon_defs.h
 create mode 100644 drivers/soc/bcm/brcmstb/pm/pm-arm.c
 create mode 100644 drivers/soc/bcm/brcmstb/pm/pm.h
 create mode 100644 drivers/soc/bcm/brcmstb/pm/s2-arm.S
drivers/soc/bcm/Kconfig +2 -0
index a39b0d58ddd0..528f9509cdc0 100644
@@ -20,4 +20,6 @@ config SOC_BRCMSTB
 
 	  If unsure, say N.
 
+source "drivers/soc/bcm/brcmstb/Kconfig"
+
 endmenu
drivers/soc/bcm/brcmstb/Kconfig new file +9 -0
new file mode 100644
index 000000000000..9b1cc7f86ea2
@@ -0,0 +1,9 @@
+if SOC_BRCMSTB
+
+config BRCMSTB_PM
+	bool "Support suspend/resume for STB platforms"
+	default y
+	depends on PM
+	depends on ARM
+
+endif # SOC_BRCMSTB
drivers/soc/bcm/brcmstb/Makefile +1 -0
index 9120b2715d3e..ee5b4de741b8 100644
@@ -1 +1,2 @@
 obj-y				+= common.o biuctrl.o
+obj-y				+= pm/
drivers/soc/bcm/brcmstb/pm/Makefile new file +2 -0
new file mode 100644
index 000000000000..7c3d20135b7c
@@ -0,0 +1,2 @@
+obj-$(CONFIG_ARM)		+= s2-arm.o pm-arm.o
+AFLAGS_s2-arm.o			:= -march=armv7-a
drivers/soc/bcm/brcmstb/pm/aon_defs.h new file +113 -0

113 lines not on this page · raw message

drivers/soc/bcm/brcmstb/pm/pm-arm.c new file +836 -0

836 lines not on this page · raw message

drivers/soc/bcm/brcmstb/pm/pm.h new file +78 -0

78 lines not on this page · raw message

drivers/soc/bcm/brcmstb/pm/s2-arm.S new file +76 -0

76 lines not on this page · raw message

Signature · 1 line
2.9.3
#9 lore raw

Re: [PATCH v2 2/4] soc: bcm: brcmstb: Add support for S2/S3/S5 suspend states (ARM)

Quoted 25 lines · Florian Fainelli

From: Brian Norris <[email protected]>

This commit adds support for the Broadcom STB S2/S3/S5 suspend states on ARM based SoCs.

This requires quite a lot of code in order to deal with the different HW blocks that need to be quiesced during suspend:

- DDR PHY SHIM
- DDR memory controller and sequencer
- control processor

The final steps of the suspend execute in an on-chip SRAM and there is a little bit of assembly code in order to shut down the DDR PHY PLL and then go into a wfi loop until a wake-up even occurs. Conversely the resume part involves waiting for the DDR PHY PLL to come back up and resume executions where we left.

For S3, because of our memory hashing (actual hashing code not included for simplicity, and is bypassed) we need to relocate the writable variables (stack) into SRAM shortly before suspending in order to leave the DRAM untouched and create a reliable hash of its contents.

This code has been contributed by Brian Norris initially and has been incrementally fixed and updated to support new chips by a lot of people.

[...]

Quoted 9 lines
drivers/soc/bcm/brcmstb/pm/pm-arm.c new file +9 -0
+static int (*brcmstb_pm_do_s2_sram)(void __iomem *aon_ctrl_base,
+		void __iomem *ddr_phy_pll_status);
+
+static int brcmstb_init_sram(struct device_node *dn)
+{
+	void __iomem *sram;
+	struct resource res;
+	int ret;
+

drivers/soc/bcm/brcmstb/pm/pm-arm.c line 140

Quoted 10 lines
drivers/soc/bcm/brcmstb/pm/pm-arm.c new file +10 -0
+	ret = of_address_to_resource(dn, 0, &res);
+	if (ret)
+		return ret;
+
+	/* Cached, executable remapping of SRAM */
+#ifdef CONFIG_ARM
+	sram = __arm_ioremap_exec(res.start, resource_size(&res), true);
+#else
+	sram = __ioremap(res.start, resource_size(&res), PAGE_KERNEL_EXEC);
+#endif

... so we're mapping the SRAM as executable via the page tables (which themselves live in memory, and are accessed asynchronously by the MMU) ...

Quoted 25 lines
drivers/soc/bcm/brcmstb/pm/pm-arm.c new file +25 -0
+static void *brcmstb_pm_copy_to_sram(void *fn, size_t len)
+{
+	unsigned int size = ALIGN(len, FNCPY_ALIGN);
+
+	if (ctrl.boot_sram_len < size) {
+		pr_err("standby code will not fit in SRAM\n");
+		return NULL;
+	}
+
+	return fncpy(ctrl.boot_sram, fn, size);
+}
+
+/*
+ * S2 suspend/resume picks up where we left off, so we must execute carefully
+ * from SRAM, in order to allow DDR to come back up safely before we continue.
+ */
+static int brcmstb_pm_s2(void)
+{
+	/* A previous S3 can set a value hazardous to S2, so make sure. */
+	if (ctrl.s3entry_method == 1) {
+		shimphy_set((PWRDWN_SEQ_NO_SEQUENCING <<
+			    SHIMPHY_PAD_S3_PWRDWN_SEQ_SHIFT),
+			    ~SHIMPHY_PAD_S3_PWRDWN_SEQ_MASK);
+		ddr_ctrl_set(false);
+	}

drivers/soc/bcm/brcmstb/pm/pm-arm.c line 400

Quoted 10 lines
drivers/soc/bcm/brcmstb/pm/pm-arm.c new file +10 -0
+
+	brcmstb_pm_do_s2_sram = brcmstb_pm_copy_to_sram(&brcmstb_pm_do_s2,
+			brcmstb_pm_do_s2_sz);
+	if (!brcmstb_pm_do_s2_sram)
+		return -EINVAL;
+
+	return brcmstb_pm_do_s2_sram(ctrl.aon_ctrl_base,
+			ctrl.memcs[0].ddr_phy_base +
+			ctrl.pll_status_offset);
+}

... here we copy the function into that executable SRAM, and then try to execute it, with the MMU on ...

Quoted 19 lines
drivers/soc/bcm/brcmstb/pm/pm-arm.c new file +19 -0
+#define SWAP_STACK(new_sp, saved_sp) \
+	__asm__ __volatile__ ( \
+		 "mov	%[save], sp\n" \
+		 "mov	sp, %[new]\n" \
+		 : [save] "=&r" (saved_sp) \
+		 : [new] "r" (new_sp) \
+		)
+
+/*
+ * S3 mode resume to the bootloader before jumping back to Linux, so we can be
+ * a little less careful about running from DRAM.
+ */
+static int brcmstb_pm_do_s3(unsigned long sp)
+{
+	unsigned long save_sp;
+	int ret;
+
+	/* Move to a new stack */
+	SWAP_STACK(sp, save_sp);

drivers/soc/bcm/brcmstb/pm/pm-arm.c line 496

Quoted 10 lines
drivers/soc/bcm/brcmstb/pm/pm-arm.c new file +10 -0
+
+	/* should not return */
+	ret = brcmstb_pm_s3_finish();
+
+	SWAP_STACK(save_sp, sp);
+
+	pr_err("Could not enter S3\n");
+
+	return ret;
+}

The compiler can, and almost certainly will spill stack variables. You cannot swap the stack safely with inline asm like this. If you need to do this, you need to perform the whole swap-call-swap sequence in a single inline asm block.

[...]

Quoted 32 lines
drivers/soc/bcm/brcmstb/pm/s2-arm.S new file +32 -0
+ENTRY(brcmstb_pm_do_s2)
+	stmfd	sp!, {r4-r11, lr}
+	mov	AON_CTRL_REG, r0
+	mov	DDR_PHY_STATUS_REG, r1
+
+	/* Flush memory transactions */
+	dsb
+
+	/* Cache DDR_PHY_STATUS_REG translation */
+	ldr	r0, [DDR_PHY_STATUS_REG]
+
+	/* power down request */
+	ldr	r0, =PM_S2_COMMAND
+	ldr	r1, =0
+	str	r1, [AON_CTRL_REG, #AON_CTRL_PM_CTRL]
+	ldr	r1, [AON_CTRL_REG, #AON_CTRL_PM_CTRL]
+	str	r0, [AON_CTRL_REG, #AON_CTRL_PM_CTRL]
+	ldr	r0, [AON_CTRL_REG, #AON_CTRL_PM_CTRL]
+
+	/* Wait for interrupt */
+	wfi
+	nop
+
+	/* Bring MEMC back up */
+1:	ldr	r0, [DDR_PHY_STATUS_REG]
+	ands	r0, #1
+	beq	1b
+
+	/* Power-up handshake */
+	ldr	r0, =1
+	str	r0, [AON_CTRL_REG, #AON_CTRL_HOST_MISC_CMDS]
+	ldr	r0, [AON_CTRL_REG, #AON_CTRL_HOST_MISC_CMDS]

drivers/soc/bcm/brcmstb/pm/s2-arm.S line 70

Quoted 10 lines
drivers/soc/bcm/brcmstb/pm/s2-arm.S new file +10 -0
+
+	ldr	r0, =0
+	str	r0, [AON_CTRL_REG, #AON_CTRL_PM_CTRL]
+	ldr	r0, [AON_CTRL_REG, #AON_CTRL_PM_CTRL]
+
+	/* Return to caller */
+	ldr	r0, =0
+	ldmfd	sp!, {r4-r11, pc}
+
+	ENDPROC(brcmstb_pm_do_s2)

What happens to any page table walks or speculative fetches that occur in the window where the DDR is off?

If the former can be stalled, the CPU can deadlock. If you can any sort of external abort as a result of either, the core will go into nowhere land trying to handle it.

I do not think this is safe.

Thanks,
Mark.

#10 lore raw

Re: [PATCH v2 2/4] soc: bcm: brcmstb: Add support for S2/S3/S5 suspend states (ARM)

Quoted 117 lines · Mark Rutland
Quoted 25 lines · Florian Fainelli

From: Brian Norris <[email protected]>

This commit adds support for the Broadcom STB S2/S3/S5 suspend states on ARM based SoCs.

This requires quite a lot of code in order to deal with the different HW blocks that need to be quiesced during suspend:

- DDR PHY SHIM
- DDR memory controller and sequencer
- control processor

The final steps of the suspend execute in an on-chip SRAM and there is a little bit of assembly code in order to shut down the DDR PHY PLL and then go into a wfi loop until a wake-up even occurs. Conversely the resume part involves waiting for the DDR PHY PLL to come back up and resume executions where we left.

For S3, because of our memory hashing (actual hashing code not included for simplicity, and is bypassed) we need to relocate the writable variables (stack) into SRAM shortly before suspending in order to leave the DRAM untouched and create a reliable hash of its contents.

This code has been contributed by Brian Norris initially and has been incrementally fixed and updated to support new chips by a lot of people.

[...]

Quoted 9 lines
drivers/soc/bcm/brcmstb/pm/pm-arm.c new file +9 -0
+static int (*brcmstb_pm_do_s2_sram)(void __iomem *aon_ctrl_base,
+		void __iomem *ddr_phy_pll_status);
+
+static int brcmstb_init_sram(struct device_node *dn)
+{
+	void __iomem *sram;
+	struct resource res;
+	int ret;
+

drivers/soc/bcm/brcmstb/pm/pm-arm.c line 140

Quoted 10 lines
drivers/soc/bcm/brcmstb/pm/pm-arm.c new file +10 -0
+	ret = of_address_to_resource(dn, 0, &res);
+	if (ret)
+		return ret;
+
+	/* Cached, executable remapping of SRAM */
+#ifdef CONFIG_ARM
+	sram = __arm_ioremap_exec(res.start, resource_size(&res), true);
+#else
+	sram = __ioremap(res.start, resource_size(&res), PAGE_KERNEL_EXEC);
+#endif

... so we're mapping the SRAM as executable via the page tables (which themselves live in memory, and are accessed asynchronously by the MMU) ...

Quoted 25 lines
drivers/soc/bcm/brcmstb/pm/pm-arm.c new file +25 -0
+static void *brcmstb_pm_copy_to_sram(void *fn, size_t len)
+{
+	unsigned int size = ALIGN(len, FNCPY_ALIGN);
+
+	if (ctrl.boot_sram_len < size) {
+		pr_err("standby code will not fit in SRAM\n");
+		return NULL;
+	}
+
+	return fncpy(ctrl.boot_sram, fn, size);
+}
+
+/*
+ * S2 suspend/resume picks up where we left off, so we must execute carefully
+ * from SRAM, in order to allow DDR to come back up safely before we continue.
+ */
+static int brcmstb_pm_s2(void)
+{
+	/* A previous S3 can set a value hazardous to S2, so make sure. */
+	if (ctrl.s3entry_method == 1) {
+		shimphy_set((PWRDWN_SEQ_NO_SEQUENCING <<
+			    SHIMPHY_PAD_S3_PWRDWN_SEQ_SHIFT),
+			    ~SHIMPHY_PAD_S3_PWRDWN_SEQ_MASK);
+		ddr_ctrl_set(false);
+	}

drivers/soc/bcm/brcmstb/pm/pm-arm.c line 400

Quoted 10 lines
drivers/soc/bcm/brcmstb/pm/pm-arm.c new file +10 -0
+
+	brcmstb_pm_do_s2_sram = brcmstb_pm_copy_to_sram(&brcmstb_pm_do_s2,
+			brcmstb_pm_do_s2_sz);
+	if (!brcmstb_pm_do_s2_sram)
+		return -EINVAL;
+
+	return brcmstb_pm_do_s2_sram(ctrl.aon_ctrl_base,
+			ctrl.memcs[0].ddr_phy_base +
+			ctrl.pll_status_offset);
+}

... here we copy the function into that executable SRAM, and then try to execute it, with the MMU on ...

Quoted 26 lines
drivers/soc/bcm/brcmstb/pm/pm-arm.c new file +26 -0
+#define SWAP_STACK(new_sp, saved_sp) \
+	__asm__ __volatile__ ( \
+		 "mov	%[save], sp\n" \
+		 "mov	sp, %[new]\n" \
+		 : [save] "=&r" (saved_sp) \
+		 : [new] "r" (new_sp) \
+		)
+
+/*
+ * S3 mode resume to the bootloader before jumping back to Linux, so we can be
+ * a little less careful about running from DRAM.
+ */
+static int brcmstb_pm_do_s3(unsigned long sp)
+{
+	unsigned long save_sp;
+	int ret;
+
+	/* Move to a new stack */
+	SWAP_STACK(sp, save_sp);
+
+	/* should not return */
+	ret = brcmstb_pm_s3_finish();
+
+	SWAP_STACK(save_sp, sp);
+
+	pr_err("Could not enter S3\n");
Quoted 8 lines

drivers/soc/bcm/brcmstb/pm/pm-arm.c line 148

Quoted 3 lines
drivers/soc/bcm/brcmstb/pm/pm-arm.c new file +3 -0
+
+	return ret;
+}

The compiler can, and almost certainly will spill stack variables. You cannot swap the stack safely with inline asm like this. If you need to do this, you need to perform the whole swap-call-swap sequence in a single inline asm block.

Makes sense, I don't think we saw problems with that, but you are right, better safe than sorry.

Quoted 40 lines

[...]

Quoted 37 lines
drivers/soc/bcm/brcmstb/pm/s2-arm.S new file +37 -0
+ENTRY(brcmstb_pm_do_s2)
+	stmfd	sp!, {r4-r11, lr}
+	mov	AON_CTRL_REG, r0
+	mov	DDR_PHY_STATUS_REG, r1
+
+	/* Flush memory transactions */
+	dsb
+
+	/* Cache DDR_PHY_STATUS_REG translation */
+	ldr	r0, [DDR_PHY_STATUS_REG]
+
+	/* power down request */
+	ldr	r0, =PM_S2_COMMAND
+	ldr	r1, =0
+	str	r1, [AON_CTRL_REG, #AON_CTRL_PM_CTRL]
+	ldr	r1, [AON_CTRL_REG, #AON_CTRL_PM_CTRL]
+	str	r0, [AON_CTRL_REG, #AON_CTRL_PM_CTRL]
+	ldr	r0, [AON_CTRL_REG, #AON_CTRL_PM_CTRL]
+
+	/* Wait for interrupt */
+	wfi
+	nop
+
+	/* Bring MEMC back up */
+1:	ldr	r0, [DDR_PHY_STATUS_REG]
+	ands	r0, #1
+	beq	1b
+
+	/* Power-up handshake */
+	ldr	r0, =1
+	str	r0, [AON_CTRL_REG, #AON_CTRL_HOST_MISC_CMDS]
+	ldr	r0, [AON_CTRL_REG, #AON_CTRL_HOST_MISC_CMDS]
+
+	ldr	r0, =0
+	str	r0, [AON_CTRL_REG, #AON_CTRL_PM_CTRL]
+	ldr	r0, [AON_CTRL_REG, #AON_CTRL_PM_CTRL]
+
Quoted 8 lines

drivers/soc/bcm/brcmstb/pm/s2-arm.S line 70

Quoted 5 lines
drivers/soc/bcm/brcmstb/pm/s2-arm.S new file +5 -0
+	/* Return to caller */
+	ldr	r0, =0
+	ldmfd	sp!, {r4-r11, pc}
+
+	ENDPROC(brcmstb_pm_do_s2)

What happens to any page table walks or speculative fetches that occur in the window where the DDR is off?

We actually saw a page table walk miss, which is why we cache the DDR_PHY_STATUS_REG translation by accessing it prior to suspending (confirmed by seeing a TLB miss using the PMU). In practice this resulted in an abnormally longer resume delay (200ms vs. several microseconds) but no crashes. Other than that, I recall now that Russell suggested making the SRAM __arm_ioremap_exec() non-cacheable for safety, I will do that in v3.

Quoted 6 lines

If the former can be stalled, the CPU can deadlock. If you can any sort of external abort as a result of either, the core will go into nowhere land trying to handle it.

I do not think this is safe.

Well, this code has been used in production for millions of suspend/resume cycles and has proven to be robust enough, I don't object the scenario you are describing could exist, but I am not sure we could come up with an alternative which is not incredibly complex.

A possibly different approach I suppose could be to relocate this code into an identify mapping and do a late MMU off, suspend, followed by DDR bring-up and MMU on, that sounds much more complex, and we would have to run this through our regression test suite for several thousands of cycles to confirm the validity of this approach.

Thanks for the feedback!

Signature · 1 line
Florian
#11 lore raw

PATCH v2 3/4 dt-bindings: Document MIPS Broadcom STB power management nodes

In reply to Florian Fainelli

Document the different nodes required for supporting S2/S3/S5 suspend states on MIPS-based Broadcom STB SoCs.

---
 .../devicetree/bindings/mips/brcm/soc.txt          | 153 +++++++++++++++++++++
 1 file changed, 153 insertions(+)
Documentation/devicetree/bindings/mips/brcm/soc.txt +153 -0
index e4e1cd91fb1f..6bfe217668d6 100644
@@ -11,3 +11,156 @@ Required properties:
 
 The experimental -viper variants are for running Linux on the 3384's
 BMIPS4355 cable modem CPU instead of the BMIPS5000 application processor.
+
+Power management
+----------------
+
+For power management (particularly, S2/S3/S5 system suspend), the following SoC
+components are needed:
+
+= Always-On control block (AON CTRL)
+
+This hardware provides control registers for the "always-on" (even in low-power
+modes) hardware, such as the Power Management State Machine (PMSM).
+
+Required properties:
+- compatible     : should be one of
+		   "brcm,bcm7425-aon-ctrl"
+		   "brcm,bcm7429-aon-ctrl"
+		   "brcm,bcm7435-aon-ctrl" and
+		   "brcm,brcmstb-aon-ctrl"
+- reg            : the register start and length for the AON CTRL block
+
+Example:
+
+syscon at 410000 {
+	compatible = "brcm,bcm7425-aon-ctrl", "brcm,brcmstb-aon-ctrl";
+	reg = <0x410000 0x400>;
+};
+
+= Memory controllers
+
+A Broadcom STB SoC typically has a number of independent memory controllers,
+each of which may have several associated hardware blocks, which are versioned
+independently (control registers, DDR PHYs, etc.). One might consider
+describing these controllers as a parent "memory controllers" block, which
+contains N sub-nodes (one for each controller in the system), each of which is
+associated with a number of hardware register resources (e.g., its PHY.
+
+== MEMC (MEMory Controller)
+
+Represents a single memory controller instance.
+
+Required properties:
+- compatible     : should contain "brcm,brcmstb-memc" and "simple-bus"
+- ranges	 : should contain the child address in the parent address
+		   space, must be 0 here, and the register start and length of
+		   the entire memory controller (including all sub nodes: DDR PHY,
+		   arbiter, etc.)
+- #address-cells : must be 1
+- #size-cells	 : must be 1
+
+Example:
+
+	memory-controller: memc at 0 {
+		compatible = "brcm,brcmstb-memc", "simple-bus";
+		ranges = <0x0 0x0 0xa000>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		memc-arb at 1000 {
+			...
+		};
+
+		memc-ddr at 2000 {
+			...
+		};
+
+		ddr-phy at 6000 {
+			...
+		};
+	};
+
+Should contain subnodes for any of the following relevant hardware resources:
+
+== DDR PHY control
+
+Control registers for this memory controller's DDR PHY.
+
+Required properties:
+- compatible     : should contain one of these
+		   "brcm,brcmstb-ddr-phy-v64.5"
+		   "brcm,brcmstb-ddr-phy"
+
+- reg            : the DDR PHY register range and length
+
+Example:
+
+	ddr-phy at 6000 {
+		compatible = "brcm,brcmstb-ddr-phy-v64.5";
+		reg = <0x6000 0xc8>;
+	};
+
+== DDR memory controller sequencer
+
+Control registers for this memory controller's DDR memory sequencer
+
+Required properties:
+- compatible     : should contain one of these
+		   "brcm,bcm7425-memc-ddr"
+		   "brcm,bcm7429-memc-ddr"
+		   "brcm,bcm7435-memc-ddr" and
+		   "brcm,brcmstb-memc-ddr"
+
+- reg            : the DDR sequencer register range and length
+
+Example:
+
+	memc-ddr at 2000 {
+		compatible = "brcm,bcm7425-memc-ddr", "brcm,brcmstb-memc-ddr";
+		reg = <0x2000 0x300>;
+	};
+
+== MEMC Arbiter
+
+The memory controller arbiter is responsible for memory clients allocation
+(bandwidth, priorities etc.) and needs to have its contents restored during
+deep sleep states (S3).
+
+Required properties:
+
+- compatible	: should contain one of these
+		  "brcm,brcmstb-memc-arb-v10.0.0.0"
+		  "brcm,brcmstb-memc-arb"
+
+- reg		: the DDR Arbiter register range and length
+
+Example:
+
+	memc-arb at 1000 {
+		compatible = "brcm,brcmstb-memc-arb-v10.0.0.0";
+		reg = <0x1000 0x248>;
+	};
+
+== Timers
+
+The Broadcom STB chips contain a timer block with several general purpose
+timers that can be used.
+
+Required properties:
+
+- compatible	: should contain one of:
+		  "brcm,bcm7425-timers"
+		  "brcm,bcm7429-timers"
+		  "brcm,bcm7435-timers and
+		  "brcm,brcmstb-timers"
+- reg		: the timers register range
+- interrupts	: the interrupt line for this timer block
+
+Example:
+
+	timers: timers at 4067c0 {
+		compatible = "brcm,bcm7425-timers", "brcm,brcmstb-timers";
+		reg = <0x4067c0 0x40>;
+		interrupts = <&periph_intc 19>;
+	};
Signature · 1 line
2.9.3
#12 lore raw

PATCH v2 3/4 dt-bindings: Document the Broadcom STB wake-up timer node

In reply to Florian Fainelli

Document the binding for the Broadcom STB SoCs wake-up timer node allowing the system to generate alarms and exit low power states.

---
 .../bindings/rtc/brcm,brcmstb-waketimer.txt        | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rtc/brcm,brcmstb-waketimer.txt
Documentation/devicetree/bindings/rtc/brcm,brcmstb-waketimer.txt new file +22 -0
new file mode 100644
index 000000000000..1d990bcc0baf
@@ -0,0 +1,22 @@
+Broadcom STB wake-up Timer
+
+The Broadcom STB wake-up timer provides a 27Mhz resolution timer, with the
+ability to wake up the system from low-power suspend/standby modes.
+
+Required properties:
+- compatible     : should contain "brcm,brcmstb-waketimer"
+- reg            : the register start and length for the WKTMR block
+- interrupts     : The TIMER interrupt
+- interrupt-parent: The phandle to the Always-On (AON) Power Management (PM) L2
+                    interrupt controller node
+- clocks	 : The phandle to the UPG fixed clock (27Mhz domain)
+
+Example:
+
+waketimer at f0411580 {
+	compatible = "brcm,brcmstb-waketimer";
+	reg = <0xf0411580 0x14>;
+	interrupts = <0x3>;
+	interrupt-parent = <&aon_pm_l2_intc>;
+	clocks = <&upg_fixed>;
+};
Signature · 1 line
2.9.3
#13 lore raw

PATCH v2 4/4 rtc: brcmstb-waketimer: Add Broadcom STB wake-timer

In reply to Florian Fainelli

From: Brian Norris <[email protected]>

This adds support for the Broadcom STB wake-timer which is a timer in the chip's 27Mhz clock domain that offers the ability to wake the system (wake-up source) from suspend states (S2, S3, S5). It is supported using the rtc framework allowing us to configure alarms for system wake-up.

---
 drivers/rtc/Kconfig                 |  11 ++
 drivers/rtc/Makefile                |   1 +
 drivers/rtc/rtc-brcmstb-waketimer.c | 325 ++++++++++++++++++++++++++++++++++++
 3 files changed, 337 insertions(+)
 create mode 100644 drivers/rtc/rtc-brcmstb-waketimer.c
drivers/rtc/Kconfig +11 -0
index 8d3b95728326..8e1aa67fe533 100644
@@ -197,6 +197,17 @@ config RTC_DRV_AC100
 	  This driver can also be built as a module. If so, the module
 	  will be called rtc-ac100.
 
+config RTC_DRV_BRCMSTB
+	tristate "Broadcom STB wake-timer"
+	depends on ARCH_BRCMSTB || BMIPS_GENERIC || COMPILE_TEST
+	default ARCH_BRCMSTB || BMIPS_GENERIC
+	help
+	  If you say yes here you get support for the wake-timer found on
+	  Broadcom STB SoCs (BCM7xxx).
+
+	  This driver can also be built as a module. If so, the module will
+	  be called rtc-brcmstb-waketimer.
+
 config RTC_DRV_AS3722
 	tristate "ams AS3722 RTC driver"
 	depends on MFD_AS3722
drivers/rtc/Makefile +1 -0
index 13857d2fce09..df89cac1f9ae 100644
@@ -36,6 +36,7 @@ obj-$(CONFIG_RTC_DRV_AT91RM9200)+= rtc-at91rm9200.o
 obj-$(CONFIG_RTC_DRV_AT91SAM9)	+= rtc-at91sam9.o
 obj-$(CONFIG_RTC_DRV_AU1XXX)	+= rtc-au1xxx.o
 obj-$(CONFIG_RTC_DRV_BFIN)	+= rtc-bfin.o
+obj-$(CONFIG_RTC_DRV_BRCMSTB)	+= rtc-brcmstb-waketimer.o
 obj-$(CONFIG_RTC_DRV_BQ32K)	+= rtc-bq32k.o
 obj-$(CONFIG_RTC_DRV_BQ4802)	+= rtc-bq4802.o
 obj-$(CONFIG_RTC_DRV_CMOS)	+= rtc-cmos.o
drivers/rtc/rtc-brcmstb-waketimer.c new file +325 -0

325 lines not on this page · raw message

Signature · 1 line
2.9.3
#14 lore raw

PATCH v2 4/4 soc bcm: brcmstb: Add support for S2/S3/S5 suspend states (MIPS)

In reply to Florian Fainelli

From: Justin Chen <[email protected]>

This commit adds support for the Broadcom STB S2/S3/S5 suspend states on MIPS based SoCs.

This requires quite a lot of code in order to deal with the different HW blocks that need to be quiesced during suspend:

- DDR PHY
- DDR memory controller and arbiter
- control processor

The final steps of the suspend execute in cache and there is is a little bit of assembly code in order to shut down the DDR PHY PLL and then go into a wait loop until a wake-up even occurs. Conversely the resume part involves waiting for the DDR PHY PLL to come back up and resume executions where we left.

---
 drivers/soc/bcm/brcmstb/Kconfig      |   2 +-
 drivers/soc/bcm/brcmstb/pm/Makefile  |   1 +
 drivers/soc/bcm/brcmstb/pm/pm-mips.c | 461 +++++++++++++++++++++++++++++++++++
 drivers/soc/bcm/brcmstb/pm/pm.h      |  13 +-
 drivers/soc/bcm/brcmstb/pm/s2-mips.S | 200 +++++++++++++++
 drivers/soc/bcm/brcmstb/pm/s3-mips.S | 146 +++++++++++
 6 files changed, 821 insertions(+), 2 deletions(-)
 create mode 100644 drivers/soc/bcm/brcmstb/pm/pm-mips.c
 create mode 100644 drivers/soc/bcm/brcmstb/pm/s2-mips.S
 create mode 100644 drivers/soc/bcm/brcmstb/pm/s3-mips.S
drivers/soc/bcm/brcmstb/Kconfig +1 -1
index 9b1cc7f86ea2..d05bfce82e71 100644
@@ -4,6 +4,6 @@ config BRCMSTB_PM
 	bool "Support suspend/resume for STB platforms"
 	default y
 	depends on PM
-	depends on ARM
+	depends on ARM || BMIPS_GENERIC
 
 endif # SOC_BRCMSTB
drivers/soc/bcm/brcmstb/pm/Makefile +1 -0
index 7c3d20135b7c..08bbd244ef11 100644
@@ -1,2 +1,3 @@
 obj-$(CONFIG_ARM)		+= s2-arm.o pm-arm.o
 AFLAGS_s2-arm.o			:= -march=armv7-a
+obj-$(CONFIG_BMIPS_GENERIC)	+= s2-mips.o s3-mips.o pm-mips.o
drivers/soc/bcm/brcmstb/pm/pm-mips.c new file +461 -0

461 lines not on this page · raw message

drivers/soc/bcm/brcmstb/pm/pm.h +12 -1
index 142519fdb8f8..b7d35ac70e60 100644
@@ -70,9 +70,20 @@
 
 #ifndef __ASSEMBLY__
 
+#ifndef CONFIG_MIPS
 extern const unsigned long brcmstb_pm_do_s2_sz;
 extern asmlinkage int brcmstb_pm_do_s2(void __iomem *aon_ctrl_base,
 		void __iomem *ddr_phy_pll_status);
-#endif
+#else
+/* s2 asm */
+extern asmlinkage int brcm_pm_do_s2(u32 *s2_params);
+
+/* s3 asm */
+extern asmlinkage int brcm_pm_do_s3(void __iomem *aon_ctrl_base,
+		int dcache_linesz);
+extern int s3_reentry;
+#endif /* CONFIG_MIPS */
+
+#endif 
 
 #endif /* __BRCMSTB_PM_H__ */
drivers/soc/bcm/brcmstb/pm/s2-mips.S new file +200 -0

200 lines not on this page · raw message

drivers/soc/bcm/brcmstb/pm/s3-mips.S new file +146 -0

146 lines not on this page · raw message

Signature · 1 line
2.9.3
#15 lore raw
In reply to Florian Fainelli
Quoted 5 lines · Florian Fainelli

Hi,

This patch series adds support for S2/S3/S5 suspend/resume states on ARM and MIPS based Broadcom STB SoCs.

Quoted 8 lines

This was submitted a long time ago by Brian, and I am now picking this up and trying to get this included with support for our latest chips.

Provided that I can collect the necessary Acks from Rob (DT) and other people (Rafael?) I would probably take this via the Broadcom ARM SoC pull requests.

Thank you!

I managed to get other patches submitted from a related series, please disregard those for now.

Quoted 43 lines

Changes in v2:

- clarify the first patch's subject (Rob)
- removed patch #2 which was creating a bisectability problem (kbuild)
- added proper AFLAGS to get s2-arm.S to build properly (kbuild)
- improved MIPS power management binding document (Rob)

Brian Norris (1):
soc: bcm: brcmstb: Add support for S2/S3/S5 suspend states (ARM)

Florian Fainelli (2):
dt-bindings: ARM: brcmstb: Update Broadcom STB Power Management
binding
dt-bindings: Document MIPS Broadcom STB power management nodes

Justin Chen (1):
soc bcm: brcmstb: Add support for S2/S3/S5 suspend states (MIPS)

 .../devicetree/bindings/arm/bcm/brcm,brcmstb.txt   |   6 +-
 .../devicetree/bindings/mips/brcm/soc.txt          | 153 ++++
 drivers/soc/bcm/Kconfig                            |   2 +
 drivers/soc/bcm/brcmstb/Kconfig                    |   9 +
 drivers/soc/bcm/brcmstb/Makefile                   |   1 +
 drivers/soc/bcm/brcmstb/pm/Makefile                |   3 +
 drivers/soc/bcm/brcmstb/pm/aon_defs.h              | 113 +++
 drivers/soc/bcm/brcmstb/pm/pm-arm.c                | 836 +++++++++++++++++++++
 drivers/soc/bcm/brcmstb/pm/pm-mips.c               | 461 ++++++++++++
 drivers/soc/bcm/brcmstb/pm/pm.h                    |  89 +++
 drivers/soc/bcm/brcmstb/pm/s2-arm.S                |  76 ++
 drivers/soc/bcm/brcmstb/pm/s2-mips.S               | 200 +++++
 drivers/soc/bcm/brcmstb/pm/s3-mips.S               | 146 ++++
 13 files changed, 2094 insertions(+), 1 deletion(-)
 create mode 100644 drivers/soc/bcm/brcmstb/Kconfig
 create mode 100644 drivers/soc/bcm/brcmstb/pm/Makefile
 create mode 100644 drivers/soc/bcm/brcmstb/pm/aon_defs.h
 create mode 100644 drivers/soc/bcm/brcmstb/pm/pm-arm.c
 create mode 100644 drivers/soc/bcm/brcmstb/pm/pm-mips.c
 create mode 100644 drivers/soc/bcm/brcmstb/pm/pm.h
 create mode 100644 drivers/soc/bcm/brcmstb/pm/s2-arm.S
 create mode 100644 drivers/soc/bcm/brcmstb/pm/s2-mips.S
 create mode 100644 drivers/soc/bcm/brcmstb/pm/s3-mips.S
Signature · 1 line
Florian