Add basic SMP support for Amlogic Meson8b
Subsystems (6)
cover Add basic SMP support for Amlogic Meson8b
From: Carlo Caione <[email protected]>
This patchset adds SMP support for Amlogic Meson8b SoCs.
Patch 1 fix some paramater for L2 cache needed for SMP.
Patches 2-4 add a small reset controller used to reset the CPU cores at boot. Patches 5-7 deal with the SMP code itself.
Carlo Caione (7):
ARM: DTS: meson8b: Extend L2 cache controller node
Documentation: bindings: Define CPU reset controller
clk: meson8b: Add reset controller for CPU cores
ARM: DTS: meson8b: Enable reset controller
Documentation: bindings: Add SMP related documentation
ARM: meson8b: Add SMP bringup code
ARM: DTS: meson8b: Add SMP related nodes
.../devicetree/bindings/arm/amlogic/pmu.txt | 16 ++ .../devicetree/bindings/arm/amlogic/smp-sram.txt | 32 +++ .../arm/cpu-enable-method/amlogic,meson8b-smp | 53 +++++ .../bindings/clock/amlogic,meson8b-clkc.txt | 6 +- arch/arm/boot/dts/meson8b.dtsi | 32 +++ arch/arm/mach-meson/Kconfig | 1 + arch/arm/mach-meson/Makefile | 1 + arch/arm/mach-meson/platsmp.c | 228 +++++++++++++++++++++ drivers/clk/meson/clk-cpu.c | 60 +++++- drivers/clk/meson/clkc.c | 5 +- drivers/clk/meson/clkc.h | 6 +- drivers/clk/meson/meson8b-clkc.c | 4 +- include/dt-bindings/clock/meson8b-clkc.h | 5 + 13 files changed, 441 insertions(+), 8 deletions(-) create mode 100644 Documentation/devicetree/bindings/arm/amlogic/pmu.txt create mode 100644 Documentation/devicetree/bindings/arm/amlogic/smp-sram.txt create mode 100644 Documentation/devicetree/bindings/arm/cpu-enable-method/amlogic,meson8b-smp create mode 100644 arch/arm/mach-meson/platsmp.c
Signature · 1 line
2.5.0
PATCH 1/7 ARM: DTS: meson8b: Extend L2 cache controller node
From: Carlo Caione <[email protected]>
This patch extends the L2 cache controller node for Amlogic Meson8b SoCs with some missing parameters.
--- arch/arm/boot/dts/meson8b.dtsi | 3 +++ 1 file changed, 3 insertions(+)
arch/arm/boot/dts/meson8b.dtsi +3 -0
@@ -93,6 +93,9 @@ L2: l2-cache-controller at c4200000 { compatible = "arm,pl310-cache"; reg = <0xc4200000 0x1000>; + arm,data-latency = <3 3 3>; + arm,tag-latency = <2 2 2>; + arm,filter-ranges = <0x100000 0xc0000000>; cache-unified; cache-level = <2>; };
Signature · 1 line
2.5.0
PATCH 2/7 Documentation: bindings: Define CPU reset controller
In reply to Carlo CaioneFrom: Carlo Caione <[email protected]>
The clock controller on Amlogic Meson8b SoCs has been extended with a reset controller used to reset the CPU cores. It is used during SMP bringup.
With this patch we extend the clock controller documentation.
--- Documentation/devicetree/bindings/clock/amlogic,meson8b-clkc.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/clock/amlogic,meson8b-clkc.txt +5 -1
@@ -1,7 +1,8 @@ * Amlogic Meson8b Clock and Reset Unit The Amlogic Meson8b clock controller generates and supplies clock to various -controllers within the SoC. +controllers within the SoC and also implements a reset controller for the CPU +cores. Required Properties:
@@ -13,16 +14,19 @@ Required Properties: mapped region. - #clock-cells: should be 1. +- #reset-cells: should be 1. Each clock is assigned an identifier and client nodes can use this identifier to specify the clock which they consume. All available clocks are defined as preprocessor macros in the dt-bindings/clock/meson8b-clkc.h header and can be used in device tree sources. +Similar identifiers exist for the CPU core reset lines. Example: Clock controller node: clkc: clock-controller at c1104000 { #clock-cells = <1>; + #reset-cells = <1>; compatible = "amlogic,meson8b-clkc"; reg = <0xc1108000 0x4>, <0xc1104000 0x460>; };
Signature · 1 line
2.5.0
Rob Herring
maintainerPATCH 2/7 Documentation: bindings: Define CPU reset controller
Quoted 1 line · Carlo Caione
From: Carlo Caione <[email protected]>
Same here, a more specific subject please.
Otherwise, looks fine.
Quoted 49 lines
The clock controller on Amlogic Meson8b SoCs has been extended with a reset controller used to reset the CPU cores. It is used during SMP bringup.
With this patch we extend the clock controller documentation.
Signed-off-by Carlo Caione <[email protected]>--- Documentation/devicetree/bindings/clock/amlogic,meson8b-clkc.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/clock/amlogic,meson8b-clkc.txt +5
-1@@ -1,7 +1,8 @@ * Amlogic Meson8b Clock and Reset Unit The Amlogic Meson8b clock controller generates and supplies clock to various -controllers within the SoC. +controllers within the SoC and also implements a reset controller for the CPU +cores. Required Properties:@@ -13,16 +14,19 @@ Required Properties: mapped region. - #clock-cells: should be 1. +- #reset-cells: should be 1. Each clock is assigned an identifier and client nodes can use this identifier to specify the clock which they consume. All available clocks are defined as preprocessor macros in the dt-bindings/clock/meson8b-clkc.h header and can be used in device tree sources. +Similar identifiers exist for the CPU core reset lines. Example: Clock controller node: clkc: clock-controller at c1104000 { #clock-cells = <1>; + #reset-cells = <1>; compatible = "amlogic,meson8b-clkc"; reg = <0xc1108000 0x4>, <0xc1104000 0x460>; };Signature · 1 line
2.5.0
PATCH 3/7 clk: meson8b: Add reset controller for CPU cores
In reply to Carlo CaioneFrom: Carlo Caione <[email protected]>
In the Amlogic Meson8b SoC we need to soft reset the CPU cores during the boot to enable the SMP support. With this patch we extend the clock controller adding a small reset controller in charge of resetting the cores.
--- drivers/clk/meson/clk-cpu.c | 60 +++++++++++++++++++++++++++++++- drivers/clk/meson/clkc.c | 5 +-- drivers/clk/meson/clkc.h | 6 ++-- drivers/clk/meson/meson8b-clkc.c | 4 +-- include/dt-bindings/clock/meson8b-clkc.h | 5 +++ 5 files changed, 73 insertions(+), 7 deletions(-)
drivers/clk/meson/clk-cpu.c +59 -1
@@ -37,9 +37,14 @@#include <linux/slab.h> #include <linux/clk.h> #include <linux/clk-provider.h> +#include <linux/reset.h> +#include <linux/reset-controller.h> #define MESON_CPU_CLK_CNTL1 0x00#define MESON_CPU_CLK_CNTL 0x40 +#define MESON_CPU_CLK_CNTL_CPU 0x19c + +#define MESON_MAX_CPU_RST 4#define MESON_CPU_CLK_MUX1 BIT(7)#define MESON_CPU_CLK_MUX2 BIT(0)
@@ -51,6 +56,11 @@#include "clkc.h" +struct meson_reset_cpu { +void __iomem *reset_base; +struct reset_controller_dev rcdev; +}; +struct meson_clk_cpu {struct notifier_block clk_nb;const struct clk_div_table *div_table;
@@ -182,13 +192,50 @@ static const struct clk_ops meson_clk_cpu_ops = { .set_rate = meson_clk_cpu_set_rate, }; -struct clk *meson_clk_register_cpu (const struct clk_conf *clk_conf, +static int meson_reset_cpu_assert (struct reset_controller_dev *rcdev, +unsigned long id) +{ +u32 reg; +struct meson_reset_cpu *reset_cpu =container_of (rcdev, + struct meson_reset_cpu, + rcdev); + + reg =readl (reset_cpu->reset_base); + reg |=BIT (id +24 ); +writel (reg, reset_cpu->reset_base); + +return 0 ; +} + +static int meson_reset_cpu_deassert (struct reset_controller_dev *rcdev, +unsigned long id) +{ +u32 reg; +struct meson_reset_cpu *reset_cpu =container_of (rcdev, + struct meson_reset_cpu, + rcdev); + + reg =readl (reset_cpu->reset_base); + reg &= ~BIT (id +24 ); +writel (reg, reset_cpu->reset_base); + +return 0 ; +} + +static struct reset_control_ops meson_cpu_reset_ops = { + .assert = meson_reset_cpu_assert, + .deassert = meson_reset_cpu_deassert, +}; + +struct clk *meson_clk_register_cpu (struct device_node *np, +const struct clk_conf *clk_conf,void __iomem *reg_base,spinlock_t *lock) {struct clk *clk;struct clk *pclk;struct meson_clk_cpu *clk_cpu; +struct meson_reset_cpu *reset_cpu;struct clk_init_data init;int ret;
@@ -231,6 +278,17 @@ struct clk *meson_clk_register_cpu(const struct clk_conf *clk_conf, goto unregister_clk_nb; } + reset_cpu =kzalloc (sizeof (*reset_cpu),GFP_KERNEL ); +if (!reset_cpu) + goto out; + + reset_cpu->reset_base = reg_base +MESON_CPU_CLK_CNTL_CPU ; + reset_cpu->rcdev.nr_resets =MESON_MAX_CPU_RST ; + reset_cpu->rcdev.ops = &meson_cpu_reset_ops; + reset_cpu->rcdev.of_node = np; +reset_controller_register (&reset_cpu->rcdev); + +out:return clk; unregister_clk_nb:
drivers/clk/meson/clkc.c +3 -2
@@ -197,7 +197,8 @@ meson_clk_register_fixed_rate(const struct clk_conf *clk_conf,return clk; } -void __init meson_clk_register_clks (const struct clk_conf *clk_confs, +void __init meson_clk_register_clks (struct device_node *np, +const struct clk_conf *clk_confs,size_t nr_confs,void __iomem *clk_base) {
@@ -221,7 +222,7 @@ void __init meson_clk_register_clks(const struct clk_conf *clk_confs, clk_base);break ;case CLK_CPU : - clk =meson_clk_register_cpu (clk_conf, clk_base, + clk =meson_clk_register_cpu (np, clk_conf, clk_base, &clk_lock);break ;case CLK_PLL :
drivers/clk/meson/clkc.h +4 -2
@@ -177,9 +177,11 @@ struct clk_conf { } \struct clk **meson_clk_init (struct device_node *np,unsigned long nr_clks); -void meson_clk_register_clks (const struct clk_conf *clk_confs, +void meson_clk_register_clks (struct device_node *np, +const struct clk_conf *clk_confs,unsigned int nr_confs,void __iomem *clk_base); -struct clk *meson_clk_register_cpu (const struct clk_conf *clk_conf, +struct clk *meson_clk_register_cpu (struct device_node *np, +const struct clk_conf *clk_conf,void __iomem *reg_base,spinlock_t *lock);struct clk *meson_clk_register_pll (const struct clk_conf *clk_conf,void __iomem *reg_base,spinlock_t *lock);
drivers/clk/meson/meson8b-clkc.c +2 -2
@@ -179,7 +179,7 @@ static void __init meson8b_clkc_init(struct device_node *np)return ; } -meson_clk_register_clks (&meson8b_xtal_conf,1 , clk_base); +meson_clk_register_clks (np, &meson8b_xtal_conf,1 , clk_base);iounmap (clk_base);/* Generic clocks and PLLs */
@@ -189,7 +189,7 @@ static void __init meson8b_clkc_init(struct device_node *np)return ; } -meson_clk_register_clks (meson8b_clk_confs, +meson_clk_register_clks (np, meson8b_clk_confs,ARRAY_SIZE (meson8b_clk_confs), clk_base); }
include/dt-bindings/clock/meson8b-clkc.h +5 -0
@@ -5,6 +5,11 @@#ifndef __MESON8B_CLKC_H#define __MESON8B_CLKC_H +#define RST_CORE0 0 +#define RST_CORE1 1 +#define RST_CORE2 2 +#define RST_CORE3 3 +#define CLKID_UNUSED 0#define CLKID_XTAL 1#define CLKID_PLL_FIXED 2
Signature · 1 line
2.5.0
PATCH 4/7 ARM: DTS: meson8b: Enable reset controller
In reply to Carlo CaioneFrom: Carlo Caione <[email protected]>
Extend the CPU nodes to use the reset controller.
--- arch/arm/boot/dts/meson8b.dtsi | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm/boot/dts/meson8b.dtsi +5 -0
@@ -60,6 +60,7 @@ compatible = "arm,cortex-a5"; next-level-cache = <&L2>; reg = <0x200>; + resets = <&clkc RST_CORE0>; }; cpu at 201 {
@@ -67,6 +68,7 @@ compatible = "arm,cortex-a5"; next-level-cache = <&L2>; reg = <0x201>; + resets = <&clkc RST_CORE1>; }; cpu at 202 {
@@ -74,6 +76,7 @@ compatible = "arm,cortex-a5"; next-level-cache = <&L2>; reg = <0x202>; + resets = <&clkc RST_CORE2>; }; cpu at 203 {
@@ -81,6 +84,7 @@ compatible = "arm,cortex-a5"; next-level-cache = <&L2>; reg = <0x203>; + resets = <&clkc RST_CORE3>; }; };
@@ -153,6 +157,7 @@ }; clkc: clock-controller at c1104000 { + #reset-cells = <1>; #clock-cells = <1>; compatible = "amlogic,meson8b-clkc"; reg = <0xc1108000 0x4>, <0xc1104000 0x460>;
Signature · 1 line
2.5.0
PATCH 5/7 Documentation: bindings: Add SMP related documentation
In reply to Carlo CaioneFrom: Carlo Caione <[email protected]>
With this patch we add documentation for:
* power-management-unit: the PMU is used to bring up the cores during SMP operations
* sram: among other things the sram is used to store the first code executed by the core when it is powered up
* cpu-enable-method: the CPU enable method used by Amlogic Meson8b SoCs
--- .../devicetree/bindings/arm/amlogic/pmu.txt | 16 +++++++ .../devicetree/bindings/arm/amlogic/smp-sram.txt | 32 +++++++++++++ .../arm/cpu-enable-method/amlogic,meson8b-smp | 53 ++++++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/amlogic/pmu.txt create mode 100644 Documentation/devicetree/bindings/arm/amlogic/smp-sram.txt create mode 100644 Documentation/devicetree/bindings/arm/cpu-enable-method/amlogic,meson8b-smp
Documentation/devicetree/bindings/arm/amlogic/pmu.txt new file +16 -0
@@ -0,0 +1,16 @@ +Amlogic 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 : = "amlogic,meson8b-pmu"; +- reg : physical base address and the size of the registers window + +Example: + + pmu at c81000e4 { + compatible = "amlogic,meson8b-pmu", "syscon"; + reg = <0xc81000e0 0x18>; + };
Documentation/devicetree/bindings/arm/amlogic/smp-sram.txt new file +32 -0
@@ -0,0 +1,32 @@ +Amlogic SRAM for smp bringup: +------------------------------ + +Amlogic's smp-capable SoCs use part of the sram for the bringup of the cores. +Once the core gets powered up it executes the code that is residing at a +specific location. + +Therefore a reserved section sub-node has to be added to the mmio-sram +declaration. + +Required sub-node properties: +- compatible : should be "amlogic,meson8b-smp-sram" + +The rest of the properties should follow the generic mmio-sram discription +found in ../../misc/sram.txt + +Example: + + sram: sram at d9000000 { + compatible = "mmio-sram"; + reg = <0xd9000000 0x20000>; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0 0xd9000000 0x20000>; + + smp-sram at 1ff80 { + compatible = "amlogic,meson8b-smp-sram"; + reg = <0x1ff80 0x8>; + }; + }; + +
Documentation/devicetree/bindings/arm/cpu-enable-method/amlogic,meson8b-smp new file +53 -0
53 lines not on this page · raw message
Signature · 1 line
2.5.0
Rob Herring
maintainerPATCH 5/7 Documentation: bindings: Add SMP related documentation
Quoted 1 line · Carlo Caione
From: Carlo Caione <[email protected]>
Please give some indication in the subject what platform this change is for:
dt-bindings: amlogic: ...
Quoted 22 lines
With this patch we add documentation for:
* power-management-unit: the PMU is used to bring up the cores during SMP operations
* sram: among other things the sram is used to store the first code executed by the core when it is powered up
* cpu-enable-method: the CPU enable method used by Amlogic Meson8b SoCsSigned-off-by Carlo Caione <[email protected]>--- .../devicetree/bindings/arm/amlogic/pmu.txt | 16 +++++++ .../devicetree/bindings/arm/amlogic/smp-sram.txt | 32 +++++++++++++ .../arm/cpu-enable-method/amlogic,meson8b-smp | 53 ++++++++++++++++++++++Documentation/devicetree/bindings/arm/cpu-enable-method/amlogic,meson8b-smp new file +0
-0
Documentation/devicetree/bindings/arm/cpu-enable-method/amlogic,meson8b-smp line 9
Quoted 9 lines
Documentation/devicetree/bindings/arm/cpu-enable-method/amlogic,meson8b-smp new file +9
-0@@ -0,0 +1,53 @@ +========================================================= +Secondary CPU enable-method "amlogic,meson8b-smp" binding +========================================================= + +This document describes the "amlogic,meson8b-smp" method for enabling secondary +CPUs. To apply to all CPUs, a single "amlogic,meson8b-smp" enable method should +be defined in the "cpus" node. + +Enable method name: "amlogic,meson8b-smp"
Just add this to Documentation/devicetree/bindings/arm/cpus.txt and remove this file.
Quoted 47 lines
Documentation/devicetree/bindings/arm/cpu-enable-method/amlogic,meson8b-smp new file +44
-0+Compatible machines: "amlogic,meson8b" +Compatible CPUs: "arm,cortex-a5" +Related properties: (none) + +Example: + + cpus { + #address-cells = <1>; + #size-cells = <0>; + enable-method = "amlogic,meson8b-smp"; + + cpu at 200 { + device_type = "cpu"; + compatible = "arm,cortex-a5"; + next-level-cache = <&L2>; + reg = <0x200>; + resets = <&clkc RST_CORE0>; + }; + + cpu at 201 { + device_type = "cpu"; + compatible = "arm,cortex-a5"; + next-level-cache = <&L2>; + reg = <0x201>; + resets = <&clkc RST_CORE1>; + }; + + cpu at 202 { + device_type = "cpu"; + compatible = "arm,cortex-a5"; + next-level-cache = <&L2>; + reg = <0x202>; + resets = <&clkc RST_CORE2>; + }; + + cpu at 203 { + device_type = "cpu"; + compatible = "arm,cortex-a5"; + next-level-cache = <&L2>; + reg = <0x203>; + resets = <&clkc RST_CORE3>; + }; + }; +Signature · 1 line
2.5.0
PATCH 6/7 ARM: meson8b: Add SMP bringup code
In reply to Carlo CaioneFrom: Carlo Caione <[email protected]>
This adds the necessary SMP-operations and startup code to use the additional cores on the Amlogic Meson8b SoCs.
--- arch/arm/mach-meson/Kconfig | 1 + arch/arm/mach-meson/Makefile | 1 + arch/arm/mach-meson/platsmp.c | 228 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 230 insertions(+) create mode 100644 arch/arm/mach-meson/platsmp.c
arch/arm/mach-meson/Kconfig +1 -0
@@ -6,6 +6,7 @@ menuconfig ARCH_MESON select CACHE_L2X0 select PINCTRL select PINCTRL_MESON + select HAVE_ARM_SCU if SMP if ARCH_MESON
arch/arm/mach-meson/Makefile +1 -0
@@ -1 +1,2 @@ obj-$(CONFIG_ARCH_MESON) += meson.o +obj-$(CONFIG_SMP) += platsmp.o
arch/arm/mach-meson/platsmp.c new file +228 -0
228 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH 7/7 ARM: DTS: meson8b: Add SMP related nodes
In reply to Carlo CaioneFrom: Carlo Caione <[email protected]>
Add nodes for: SCU, PMU and SRAM. Set also the enable-method for SMP bringup.
--- arch/arm/boot/dts/meson8b.dtsi | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
arch/arm/boot/dts/meson8b.dtsi +24 -0
@@ -51,9 +51,20 @@ / { interrupt-parent = <&gic>; + scu at c4300000 { + compatible = "arm,cortex-a5-scu"; + reg = <0xc4300000 0x100>; + }; + + pmu at c81000e4 { + compatible = "amlogic,meson8b-pmu", "syscon"; + reg = <0xc81000e0 0x18>; + }; + cpus { #address-cells = <1>; #size-cells = <0>; + enable-method = "amlogic,meson8b-smp"; cpu at 200 { device_type = "cpu";
@@ -88,6 +99,19 @@ }; }; + sram: sram at d9000000 { + compatible = "mmio-sram"; + reg = <0xd9000000 0x20000>; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0 0xd9000000 0x20000>; + + smp-sram at 1ff80 { + compatible = "amlogic,meson8b-smp-sram"; + reg = <0x1ff80 0x8>; + }; + }; + soc { compatible = "simple-bus"; #address-cells = <1>;
Signature · 1 line
2.5.0