Skip to contentSkip to conversation

ARM: rockchip: add smp functionality

PATCH RESEND Superseded Heiko Stübner 2 participants 7 messages Oct 22, 2013 – Oct 25, 2013

Subsystems (5)

v5 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Heiko Stübner

author maintainer
#0 lore raw

v5 cover ARM: rockchip: add smp functionality

This series enables the use of the additional cores on Rockchip Cortex-A9 SoCs.

To achieve this, add the scu, the needed sram and power-management-unit.

Tested on both a BQ Curie2 (rk3066a / dual core) and on a Radxa Rock (rk3188 / quad core).

changes since v4:
- rebase on top of the recent rk3188 board support
- implement suggestion from Matt Sealey in moving the sram-limit from marking reserved regions to marking available regions - hopefully I got the usage right :-)
- remove __CPUINIT as suggested by Fabio Estevam

changes since v3:
- address comments from Rob Herring:
- split the gathering of the reserve-data into a separate loop
- spelling and style fixes
- first patch only included for reference, already part of the char-misc git tree

changes since v2:
- rework the sram allocation following the suggestion from Philipp Zabel

changes since v1:
- add reserved block feature for mmio-sram, to not use two logical sram nodes
- the sram content is kept intact while the device is running, so copying the trampoline is only needed once

Heiko Stuebner (5):
misc: sram: add ability to limit used sram areas
ARM: rockchip: add snoop-control-unit
ARM: rockchip: add sram dt nodes and documentation
ARM: rockchip: add power-management-unit dt node
ARM: rockchip: add smp bringup code

 .../devicetree/bindings/arm/rockchip/pmu.txt       |   16 ++
 .../devicetree/bindings/arm/rockchip/smp-sram.txt  |   24 +++
 Documentation/devicetree/bindings/misc/sram.txt    |    8 +
 arch/arm/boot/dts/rk3066a.dtsi                     |    6 +
 arch/arm/boot/dts/rk3188.dtsi                      |    6 +
 arch/arm/boot/dts/rk3xxx.dtsi                      |   10 +
 arch/arm/mach-rockchip/Kconfig                     |    1 +
 arch/arm/mach-rockchip/Makefile                    |    1 +
 arch/arm/mach-rockchip/core.h                      |   22 +++
 arch/arm/mach-rockchip/headsmp.S                   |   30 ++++
 arch/arm/mach-rockchip/platsmp.c                   |  195 ++++++++++++++++++++
 arch/arm/mach-rockchip/rockchip.c                  |    2 +
 drivers/misc/sram.c                                |   51 ++++-
 13 files changed, 368 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/rockchip/pmu.txt
 create mode 100644 Documentation/devicetree/bindings/arm/rockchip/smp-sram.txt
 create mode 100644 arch/arm/mach-rockchip/core.h
 create mode 100644 arch/arm/mach-rockchip/headsmp.S
 create mode 100644 arch/arm/mach-rockchip/platsmp.c
Signature · 1 line
1.7.10.4
author maintainer
#1 lore raw

PATCH RESEND v5 1/5 misc: sram: add ability to limit used sram areas

Some SoCs need parts of their sram for special purposes. So while being part of the peripheral, it should not be part of the genpool controlling the sram.

Therefore add an option available to keep arbitrary portions of the sram from being part of the pool. If available is not present, all sram is used.

move from marking reserved space to available space

---
 Documentation/devicetree/bindings/misc/sram.txt |    8 ++++
 drivers/misc/sram.c                             |   51 ++++++++++++++++++++---
 2 files changed, 53 insertions(+), 6 deletions(-)
Documentation/devicetree/bindings/misc/sram.txt +8 -0
index 4d0a00e..8be552f 100644
@@ -8,9 +8,17 @@ Required properties:
 
 - reg : SRAM iomem address range
 
+Optional properties:
+
+- available: optional list of available chunks inside the sram that the
+  OS can use. Without available, the whole range is usable for the OS.
+  Format is <base size>, <base size>, ...; with base being relative to the
+  reg property base.
+
 Example:
 
 sram: sram at 5c000000 {
 	compatible = "mmio-sram";
 	reg = <0x5c000000 0x40000>; /* 256 KiB SRAM at address 0x5c000000 */
+	available = <0x100 0x3ff00>;
 };
drivers/misc/sram.c +45 -6

63 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#2 lore raw

PATCH RESEND v5 1/5 misc: sram: add ability to limit used sram areas

Quoted 22 lines · Heiko St??bner

Some SoCs need parts of their sram for special purposes. So while being part of the peripheral, it should not be part of the genpool controlling the sram.

Therefore add an option available to keep arbitrary portions of the sram from being part of the pool. If available is not present, all sram is used.

move from marking reserved space to available space

---
 Documentation/devicetree/bindings/misc/sram.txt |    8 ++++
 drivers/misc/sram.c                             |   51 ++++++++++++++++++++---
 2 files changed, 53 insertions(+), 6 deletions(-)
Documentation/devicetree/bindings/misc/sram.txt +0 -0
index 4d0a00e..8be552f 100644

Documentation/devicetree/bindings/misc/sram.txt Required properties: · line 16

Quoted 9 lines
Documentation/devicetree/bindings/misc/sram.txt +6 -0
@@ -8,9 +8,17 @@ Required properties:
 
 - reg : SRAM iomem address range
 
+Optional properties:
+
+- available: optional list of available chunks inside the sram that the
+  OS can use. Without available, the whole range is usable for the OS.
+  Format is <base size>, <base size>, ...; with base being relative to the
+  reg property base.

I think it would make more sense to specify reserved regions of the memory instead of the valid ranges. Carving out reserved regions is closer to the patterns for reserved memory that we'll be using elsewhere.

g.

Quoted 80 lines
Documentation/devicetree/bindings/misc/sram.txt +2 -0
+
 Example:
 
 sram: sram at 5c000000 {
 	compatible = "mmio-sram";
 	reg = <0x5c000000 0x40000>; /* 256 KiB SRAM at address 0x5c000000 */
+	available = <0x100 0x3ff00>;
 };
drivers/misc/sram.c +45 -6
index afe66571..755e640 100644
@@ -42,6 +42,8 @@ static int sram_probe(struct platform_device *pdev)
 	struct sram_dev *sram;
 	struct resource *res;
 	unsigned long size;
+	const __be32 *avail_list = NULL;
+	int avail_size = 0;
 	int ret;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -65,12 +67,49 @@ static int sram_probe(struct platform_device *pdev)
 	if (!sram->pool)
 		return -ENOMEM;
 
-	ret = gen_pool_add_virt(sram->pool, (unsigned long)virt_base,
-				res->start, size, -1);
-	if (ret < 0) {
-		if (sram->clk)
-			clk_disable_unprepare(sram->clk);
-		return ret;
+	if (pdev->dev.of_node) {
+		avail_list = of_get_property(pdev->dev.of_node,
+						"available",
+						&avail_size);
+		if (avail_list) {
+			avail_size /= sizeof(*avail_list);
+			if (!avail_size || avail_size % 2) {
+				dev_warn(&pdev->dev, "wrong number of arguments in available property\n");
+				avail_list = NULL;
+			}
+		}
+	}
+
+	if (!avail_list) {
+		ret = gen_pool_add_virt(sram->pool, (unsigned long)virt_base,
+					res->start, size, -1);
+		if (ret < 0) {
+			if (sram->clk)
+				clk_disable_unprepare(sram->clk);
+			return ret;
+		}
+	} else {
+		unsigned int astart;
+		unsigned int asize;
+		int i;
+
+		for (i = 0; i < avail_size; i += 2) {
+			/* get the next available block */
+			astart = be32_to_cpu(*avail_list++);
+			asize = be32_to_cpu(*avail_list++);
+
+			dev_dbg(&pdev->dev, "found available block 0x%x-0x%x\n",
+				 astart, astart + asize);
+
+			ret = gen_pool_add_virt(sram->pool,
+					(unsigned long)virt_base + astart,
+					res->start + astart, asize, -1);
+			if (ret < 0) {
+				if (sram->clk)
+					clk_disable_unprepare(sram->clk);
+				return ret;
+			}
+		}
 	}
 
 	platform_set_drvdata(pdev, sram);
Signature · 1 line
1.7.10.4
author maintainer
#3 lore raw

PATCH RESEND v5 2/5 ARM: rockchip: add snoop-control-unit

In reply to Heiko Stübner

This adds the device-node and config select to enable the scu in all Rockchip Cortex-A9 SoCs.

---
 arch/arm/boot/dts/rk3xxx.dtsi  |    5 +++++
 arch/arm/mach-rockchip/Kconfig |    1 +
 2 files changed, 6 insertions(+)
arch/arm/boot/dts/rk3xxx.dtsi +5 -0
index 0fcbcfd..0a3d5b1 100644
@@ -26,6 +26,11 @@
 		compatible = "simple-bus";
 		ranges;
 
+		scu at 1013c000 {
+			compatible = "arm,cortex-a9-scu";
+			reg = <0x1013c000 0x100>;
+		};
+
 		gic: interrupt-controller at 1013d000 {
 			compatible = "arm,cortex-a9-gic";
 			interrupt-controller;
arch/arm/mach-rockchip/Kconfig +1 -0
index 6fef464..8700395 100644
@@ -5,6 +5,7 @@ config ARCH_ROCKCHIP
 	select ARCH_REQUIRE_GPIOLIB
 	select ARM_GIC
 	select CACHE_L2X0
+	select HAVE_ARM_SCU
 	select HAVE_ARM_TWD if LOCAL_TIMERS
 	select HAVE_SMP
 	select LOCAL_TIMERS if SMP
Signature · 1 line
1.7.10.4
author maintainer
#4 lore raw

PATCH RESEND v5 3/5 ARM: rockchip: add sram dt nodes and documentation

In reply to Heiko Stübner

The Rockchip SoCs need a special part of their sram for bringup of additional cores. Therefore also limit the public area when adding the mmio-sram node to keep the sram driver from using this space.

---
 .../devicetree/bindings/arm/rockchip/smp-sram.txt  |   24 ++++++++++++++++++++
 arch/arm/boot/dts/rk3066a.dtsi                     |    6 +++++
 arch/arm/boot/dts/rk3188.dtsi                      |    6 +++++
 3 files changed, 36 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/rockchip/smp-sram.txt
Documentation/devicetree/bindings/arm/rockchip/smp-sram.txt new file +24 -0
new file mode 100644
index 0000000..0c88d06
@@ -0,0 +1,24 @@
+Rockchip SRAM for smp bringup:
+------------------------------
+
+Rockchip's smp-capable SoCs use the first part of the sram for the bringup
+of the cores. Once the core gets powered up it executes the code that is
+residing at the very beginning of the sram.
+
+Therefore the available space has to be limited to exclude this area using
+the available property of the sram node.
+
+Required node properties:
+- compatible : should contain both "rockchip,rk3066-sram", "mmio-sram"
+  so that the smp code can select the correct sram node.
+
+The rest of the properties should follow the generic mmio-sram discription
+found in ../../misc/sram.txt
+
+Example:
+
+	sram: sram at 10080000 {
+		compatible = "rockchip,rk3066-sram", "mmio-sram";
+		reg = <0x10080000 0x10000>;
+		available = <0x50 0xffb0>;
+	};
arch/arm/boot/dts/rk3066a.dtsi +6 -0
index 2218c64..e91048b 100644
@@ -64,6 +64,12 @@
 			clock-names = "timer", "pclk";
 		};
 
+		sram: sram at 10080000 {
+			compatible = "rockchip,rk3066-sram", "mmio-sram";
+			reg = <0x10080000 0x10000>;
+			available = <0x50 0xffb0>;
+		};
+
 		pinctrl at 20008000 {
 			compatible = "rockchip,rk3066a-pinctrl";
 			reg = <0x20008000 0x150>;
arch/arm/boot/dts/rk3188.dtsi +6 -0
index 1a26b03..a9885df 100644
@@ -60,6 +60,12 @@
 			interrupts = <GIC_PPI 13 0xf04>;
 		};
 
+		sram: sram at 10080000 {
+			compatible = "rockchip,rk3066-sram", "mmio-sram";
+			reg = <0x10080000 0x8000>;
+			available = <0x50 0x7fb0>;
+		};
+
 		pinctrl at 20008000 {
 			compatible = "rockchip,rk3188-pinctrl";
 			reg = <0x20008000 0xa0>,
Signature · 1 line
1.7.10.4
author maintainer
#5 lore raw

PATCH RESEND v5 4/5 ARM: rockchip: add power-management-unit dt node

In reply to Heiko Stübner

The pmu is needed to bring up the cores during smp operations. Therefore add a node and documentation for it.

---
 Documentation/devicetree/bindings/arm/rockchip/pmu.txt |   16 ++++++++++++++++
 arch/arm/boot/dts/rk3xxx.dtsi                          |    5 +++++
 2 files changed, 21 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/rockchip/pmu.txt
Documentation/devicetree/bindings/arm/rockchip/pmu.txt new file +16 -0
new file mode 100644
index 0000000..3ee9b42
@@ -0,0 +1,16 @@
+Rockchip power-management-unit:
+-------------------------------
+
+The pmu is used to turn off and on different power domains of the SoCs
+This includes the power to the CPU cores.
+
+Required node properties:
+- compatible value : = "rockchip,rk3066-pmu";
+- reg : physical base address and the size of the registers window
+
+Example:
+
+	pmu at 20004000 {
+		compatible = "rockchip,rk3066-pmu";
+		reg = <0x20004000 0x100>;
+	};
arch/arm/boot/dts/rk3xxx.dtsi +5 -0
index 0a3d5b1..26e5a96 100644
@@ -31,6 +31,11 @@
 			reg = <0x1013c000 0x100>;
 		};
 
+		pmu at 20004000 {
+			compatible = "rockchip,rk3066-pmu";
+			reg = <0x20004000 0x100>;
+		};
+
 		gic: interrupt-controller at 1013d000 {
 			compatible = "arm,cortex-a9-gic";
 			interrupt-controller;
Signature · 1 line
1.7.10.4
author maintainer
#6 lore raw

PATCH RESEND v5 5/5 ARM: rockchip: add smp bringup code

In reply to Heiko Stübner

This adds the necessary smp-operations and startup code to use additional cores on Rockchip SoCs.

We currently hog the power management unit in the smp code, as it is necessary to control the power to the cpu core and nothing else is currently using it, so a generic implementation can be done later.

---
 arch/arm/mach-rockchip/Makefile   |    1 +
 arch/arm/mach-rockchip/core.h     |   22 +++++
 arch/arm/mach-rockchip/headsmp.S  |   30 ++++++
 arch/arm/mach-rockchip/platsmp.c  |  195 +++++++++++++++++++++++++++++++++++++
 arch/arm/mach-rockchip/rockchip.c |    2 +
 5 files changed, 252 insertions(+)
 create mode 100644 arch/arm/mach-rockchip/core.h
 create mode 100644 arch/arm/mach-rockchip/headsmp.S
 create mode 100644 arch/arm/mach-rockchip/platsmp.c
arch/arm/mach-rockchip/Makefile +1 -0
index 1547d4f..4377a14 100644
@@ -1 +1,2 @@
 obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip.o
+obj-$(CONFIG_SMP) += headsmp.o platsmp.o
arch/arm/mach-rockchip/core.h new file +22 -0
new file mode 100644
index 0000000..e2e7c9d
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2013 MundoReader S.L.
+ * Author: Heiko Stuebner <[email protected]>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+extern char rockchip_secondary_trampoline;
+extern char rockchip_secondary_trampoline_end;
+
+extern unsigned long rockchip_boot_fn;
+extern void rockchip_secondary_startup(void);
+
+extern struct smp_operations rockchip_smp_ops;
arch/arm/mach-rockchip/headsmp.S new file +30 -0
new file mode 100644
index 0000000..3dd72f7
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2013 MundoReader S.L.
+ * Author: Heiko Stuebner <[email protected]>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#include <linux/linkage.h>
+#include <linux/init.h>
+
+ENTRY(rockchip_secondary_startup)
+	bl	v7_invalidate_l1
+	b	secondary_startup
+ENDPROC(rockchip_secondary_startup)
+
+ENTRY(rockchip_secondary_trampoline)
+	ldr	pc, 1f
+ENDPROC(rockchip_secondary_trampoline)
+	.globl	rockchip_boot_fn
+rockchip_boot_fn:
+1:	.space	4
+
+ENTRY(rockchip_secondary_trampoline_end)
arch/arm/mach-rockchip/platsmp.c new file +195 -0

195 lines not on this page · raw message

arch/arm/mach-rockchip/rockchip.c +2 -0
index 724d2d8..a0c1f19 100644
@@ -24,6 +24,7 @@
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 #include <asm/hardware/cache-l2x0.h>
+#include "core.h"
 
 static void __init rockchip_timer_init(void)
 {
@@ -46,6 +47,7 @@ static const char * const rockchip_board_dt_compat[] = {
 };
 
 DT_MACHINE_START(ROCKCHIP_DT, "Rockchip Cortex-A9 (Device Tree)")
+	.smp		= smp_ops(rockchip_smp_ops),
 	.init_machine	= rockchip_dt_init,
 	.init_time	= rockchip_timer_init,
 	.dt_compat	= rockchip_board_dt_compat,
Signature · 1 line
1.7.10.4