Add SMP support for r8a7743
Subsystems (4)
cover Add SMP support for r8a7743
This patch series aims to add SMP support for r8a7743 SoC.
It is tested against linux-v4.4.112-cip18
Biju Das (4):
ARM: shmobile: Add pm support for r8a7743
dt-bindings: apmu: Document r8a7743 support
ARM: dts: r8a7743: Add APMU node and second CPU core
ARM: dts: r8a7743: Add OPP table for frequency scaling
Geert Uytterhoeven (4):
ARM: shmobile: apmu: Move #ifdef CONFIG_SMP to cover more functions
ARM: shmobile: apmu: Add debug resource reset for secondary CPU boot
ARM: shmobile: apmu: Allow booting secondary CPU cores in debug mode
ARM: dts: r8a7743: Add missing clock for secondary CA15 CPU core
Magnus Damm (2):
ARM: shmobile: apmu: Add APMU DT support via Enable method
devicetree: bindings: Renesas APMU and SMP Enable method
Documentation/devicetree/bindings/arm/cpus.txt | 1 + .../devicetree/bindings/power/renesas,apmu.txt | 29 +++++++ arch/arm/boot/dts/r8a7743.dtsi | 25 ++++++ arch/arm/mach-shmobile/platsmp-apmu.c | 94 +++++++++++++++++++++- arch/arm/mach-shmobile/pm-rcar-gen2.c | 3 + 5 files changed, 150 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/renesas,apmu.txt
Signature · 1 line
2.7.4
PATCH 1/10 ARM: shmobile: Add pm support for r8a7743
Adding pm support for r8a7743 SoC.
--- arch/arm/mach-shmobile/pm-rcar-gen2.c | 3 +++ 1 file changed, 3 insertions(+)
arch/arm/mach-shmobile/pm-rcar-gen2.c +3 -0
@@ -82,6 +82,9 @@ void __init rcar_gen2_pm_init(void) }else if (of_machine_is_compatible ("renesas,r8a7791" )) { boot_vector_addr =RAM ; syscier =0x00111003 ; + }else if (of_machine_is_compatible ("renesas,r8a7743" )) { + boot_vector_addr =RAM ; + syscier =0x00101003 ; }/* RAM for jump stub, because BAR requires 256KB aligned address */
Signature · 1 line
2.7.4
PATCH 2/10 ARM: shmobile: apmu: Move #ifdef CONFIG_SMP to cover more functions
In reply to Biju DasFrom: Geert Uytterhoeven <[email protected]>
shmobile_smp_apmu_prepare_cpus() is used only if CONFIG_SMP=y.
Hence move the #ifdef to cover shmobile_smp_apmu_prepare_cpus() and all functions only called by it (apmu_init_cpu() and apmu_parse_cfg()).
--- arch/arm/mach-shmobile/platsmp-apmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-shmobile/platsmp-apmu.c +1 -1
@@ -74,6 +74,7 @@ static int __maybe_unused apmu_wrap(int cpu, int (*fn)(void __iomem *p, int cpu)return p ?fn (p, apmu_cpus[cpu].bit) : -EINVAL ; } +#ifdef CONFIG_SMP static void apmu_init_cpu (struct resource *res,int cpu,int bit) {if ((cpu >=ARRAY_SIZE (apmu_cpus)) || apmu_cpus[cpu].iomem)
@@ -129,7 +130,6 @@ void __init shmobile_smp_apmu_prepare_cpus(unsigned int max_cpus,apmu_parse_cfg (apmu_init_cpu, apmu_config, num); } -#ifdef CONFIG_SMP int shmobile_smp_apmu_boot_secondary (unsigned int cpu,struct task_struct *idle) {/* For this particular CPU register boot vector */
Signature · 1 line
2.7.4
PATCH 3/10 ARM: shmobile: apmu: Add APMU DT support via Enable method
In reply to Biju DasFrom: Magnus Damm <[email protected]>
Allow DT configuration of the APMU hardware in the case when the APMU is pointed out in the DTB via the enable-method. The ability to configure the APMU via C code is still kept intact to prevent DTB breakage for older SoCs that do not rely on the enable-method for SMP support.
(cherry picked from commit 5f3bca0db8ac01a73622361f6062939638bf4730) (Backported APMU DT support via Enable method)
Conflicts:
arch/arm/mach-shmobile/platsmp-apmu.c
--- arch/arm/mach-shmobile/platsmp-apmu.c | 90 ++++++++++++++++++++++++++++++++++- 1 file changed, 89 insertions(+), 1 deletion(-)
arch/arm/mach-shmobile/platsmp-apmu.c +89 -1
@@ -24,6 +24,7 @@#include <asm/suspend.h> #include "common.h" #include "platsmp-apmu.h" +#include "rcar-gen2.h" static struct { void __iomem *iomem;
@@ -118,12 +119,68 @@ static void apmu_parse_cfg(void (*fn)(struct resource *res, int cpu, int bit), } } +static const struct of_device_id apmu_ids[] = { + { .compatible ="renesas,apmu" }, + {/*sentinel*/ } +}; + +static void apmu_parse_dt (void (*fn)(struct resource *res,int cpu,int bit)) +{ +struct device_node *np_apmu, *np_cpu; +struct resource res; +int bit, index; +u32 id; + +for_each_matching_node (np_apmu, apmu_ids) { +/* only enable the cluster that includes the boot CPU */ +bool is_allowed = false; + +for (bit =0 ; bit <CONFIG_NR_CPUS ; bit++) { + np_cpu =of_parse_phandle (np_apmu,"cpus" , bit); +if (np_cpu) { +if (!of_property_read_u32 (np_cpu,"reg" , &id)) { +if (id ==cpu_logical_map (0 )) { + is_allowed = true; +of_node_put (np_cpu); +break ; + } + + } +of_node_put (np_cpu); + } + } +if (!is_allowed) +continue ; + +for (bit =0 ; bit <CONFIG_NR_CPUS ; bit++) { + np_cpu =of_parse_phandle (np_apmu,"cpus" , bit); +if (np_cpu) { +if (!of_property_read_u32 (np_cpu,"reg" , &id)) { + index =get_logical_index (id); +if ((index >=0 ) && + !of_address_to_resource (np_apmu, +0 , &res)) +fn (&res, index, bit); + } +of_node_put (np_cpu); + } + } + } +} + +static void __init shmobile_smp_apmu_setup_boot (void ) +{ +/* install boot code shared by all CPUs */ + shmobile_boot_fn =virt_to_phys (shmobile_smp_boot); + shmobile_boot_arg =MPIDR_HWID_BITMASK ; +} +void __init shmobile_smp_apmu_prepare_cpus (unsigned int max_cpus,struct rcar_apmu_config *apmu_config,int num) {/* install boot code shared by all CPUs */ - shmobile_boot_fn =virt_to_phys (shmobile_smp_boot); +shmobile_smp_apmu_setup_boot (); shmobile_boot_arg =MPIDR_HWID_BITMASK ;/* perform per-cpu setup */
@@ -137,7 +194,38 @@ int shmobile_smp_apmu_boot_secondary(unsigned int cpu, struct task_struct *idle)return apmu_wrap (cpu, apmu_power_on); } + +static void __init shmobile_smp_apmu_prepare_cpus_dt (unsigned int max_cpus) +{ +shmobile_smp_apmu_setup_boot (); +apmu_parse_dt (apmu_init_cpu); +rcar_gen2_pm_init (); +} + +static int shmobile_smp_apmu_boot_secondary_md21 (unsigned int cpu, +struct task_struct *idle) +{ +/* Error out when hardware debug mode is enabled */ +if (rcar_gen2_read_mode_pins () &BIT (21 )) { +pr_warn ("Unable to boot CPU%u when MD21 is set\n" , cpu); +return -ENOTSUPP ; + } + +return shmobile_smp_apmu_boot_secondary (cpu, idle); +} + +static struct smp_operations apmu_smp_ops__initdata = { + .smp_prepare_cpus = shmobile_smp_apmu_prepare_cpus_dt, + .smp_boot_secondary = shmobile_smp_apmu_boot_secondary_md21, +#ifdef CONFIG_HOTPLUG_CPU + .cpu_can_disable = shmobile_smp_cpu_can_disable, + .cpu_die = shmobile_smp_apmu_cpu_die, + .cpu_kill = shmobile_smp_apmu_cpu_kill, #endif +}; + +CPU_METHOD_OF_DECLARE (shmobile_smp_apmu,"renesas,apmu" , &apmu_smp_ops); +#endif /* CONFIG_SMP */ #if defined(CONFIG_HOTPLUG_CPU ) || defined(CONFIG_SUSPEND )/* nicked from arch/arm/mach-exynos/hotplug.c */
Signature · 1 line
2.7.4
PATCH 4/10 ARM: shmobile: apmu: Add debug resource reset for secondary CPU boot
In reply to Biju DasFrom: Geert Uytterhoeven <[email protected]>
In debug mode (MD21=1), reset requests derived from power-shutoff to the AP-system CPU cores must be enabled before the AP-system CPU cores resume from power-shutoff for the first time. Else resume may fail, causing the system to hang during boot.
As setting these bits is a no-op in normal mode, there's no need to check the actual state of MD21 first.
Inspired by CPU-specific patches in the BSP by Hisashi Nakamura <[email protected]>.
Conflicts:
arch/arm/mach-shmobile/platsmp-apmu.c
--- arch/arm/mach-shmobile/platsmp-apmu.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
arch/arm/mach-shmobile/platsmp-apmu.c +14 -0
@@ -35,6 +35,13 @@ static struct {#define PSTR_OFFS 0x40#define CPUNCR_OFFS (n) (0x100 + (0x10 * (n))) +#define DBGRCR_OFFS 0x180/* Debug Resource Reset Control Reg. */ + +/* Debug Resource Reset Control Register */ +#define DBGCPUREN BIT(24)/* CPU Other Reset Request Enable */ +#define DBGCPUNREN (n) BIT((n) + 20)/* CPUn Reset Request Enable */ +#define DBGCPUPREN BIT(19)/* CPU Peripheral Reset Req. Enable */ +static int __maybe_unused apmu_power_on (void __iomem *p,int bit) {/* request power on */
@@ -78,6 +85,8 @@ static int __maybe_unused apmu_wrap(int cpu, int (*fn)(void __iomem *p, int cpu)#ifdef CONFIG_SMP static void apmu_init_cpu (struct resource *res,int cpu,int bit) { +u32 x; +if ((cpu >=ARRAY_SIZE (apmu_cpus)) || apmu_cpus[cpu].iomem)return ;
@@ -85,6 +94,11 @@ static void apmu_init_cpu(struct resource *res, int cpu, int bit) apmu_cpus[cpu].bit = bit;pr_debug ("apmu ioremap %d %d %pr\n" , cpu, bit, res); + +/* Setup for debug mode */ + x =readl (apmu_cpus[cpu].iomem +DBGRCR_OFFS ); + x |=DBGCPUREN |DBGCPUNREN (bit) |DBGCPUPREN ; +writel (x, apmu_cpus[cpu].iomem +DBGRCR_OFFS ); } static void apmu_parse_cfg(void (*fn)(struct resource *res, int cpu, int bit),
Signature · 1 line
2.7.4
PATCH 5/10 ARM: shmobile: apmu: Allow booting secondary CPU cores in debug mode
In reply to Biju DasFrom: Geert Uytterhoeven <[email protected]>
Now debug resource reset is handled properly, allow booting secondary CPU cores when hardware debug mode is enabled (MD21=1) on SoCs using the "renesas,apmu" enable method.
--- arch/arm/mach-shmobile/platsmp-apmu.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-)
arch/arm/mach-shmobile/platsmp-apmu.c +1 -13
@@ -216,21 +216,9 @@ static void __init shmobile_smp_apmu_prepare_cpus_dt(unsigned int max_cpus)rcar_gen2_pm_init (); } -static int shmobile_smp_apmu_boot_secondary_md21 (unsigned int cpu, -struct task_struct *idle) -{ -/* Error out when hardware debug mode is enabled */ -if (rcar_gen2_read_mode_pins () &BIT (21 )) { -pr_warn ("Unable to boot CPU%u when MD21 is set\n" , cpu); -return -ENOTSUPP ; - } - -return shmobile_smp_apmu_boot_secondary (cpu, idle); -} -static struct smp_operations apmu_smp_ops__initdata = { .smp_prepare_cpus = shmobile_smp_apmu_prepare_cpus_dt, - .smp_boot_secondary = shmobile_smp_apmu_boot_secondary_md21, + .smp_boot_secondary = shmobile_smp_apmu_boot_secondary, #ifdef CONFIG_HOTPLUG_CPU .cpu_can_disable = shmobile_smp_cpu_can_disable, .cpu_die = shmobile_smp_apmu_cpu_die,
Signature · 1 line
2.7.4
PATCH 6/10 devicetree: bindings: Renesas APMU and SMP Enable method
In reply to Biju DasFrom: Magnus Damm <[email protected]>
Add DT binding documentation for the APMU hardware and add "renesas,apmu" to the list of enable methods for the ARM cpus.
--- Documentation/devicetree/bindings/arm/cpus.txt | 1 + .../devicetree/bindings/power/renesas,apmu.txt | 28 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/renesas,apmu.txt
Documentation/devicetree/bindings/arm/cpus.txt +1 -0
@@ -200,6 +200,7 @@ nodes to be present and contain the properties described below. "qcom,gcc-msm8660" "qcom,kpss-acc-v1" "qcom,kpss-acc-v2" + "renesas,apmu" "rockchip,rk3066-smp" "ste,dbx500-smp"
Documentation/devicetree/bindings/power/renesas,apmu.txt new file +28 -0
@@ -0,0 +1,28 @@ +DT bindings for the Renesas Advanced Power Management Unit + +Renesas R-Car line of SoCs utilize one or more APMU hardware units +for CPU core power domain control including SMP boot and CPU Hotplug. + +Required properties: + +- compatible: Should be "renesas,<soctype>-apmu", "renesas,apmu" as fallback. + Examples with soctypes are: + - "renesas,r8a7790-apmu" (R-Car H2) + - "renesas,r8a7791-apmu" (R-Car M2-W) + +- reg: Base address and length of the I/O registers used by the APMU. + +- cpus: This node contains a list of CPU cores, which should match the order + of CPU cores used by the WUPCR and PSTR registers in the Advanced Power + Management Unit section of the device's datasheet. + + +Example: + +This shows the r8a7791 APMU that can control CPU0 and CPU1. + + apmu at e6152000 { + compatible = "renesas,r8a7791-apmu", "renesas,apmu"; + reg = <0 0xe6152000 0 0x188>; + cpus = <&cpu0 &cpu1>; + };
Signature · 1 line
2.7.4
PATCH 7/10 dt-bindings: apmu: Document r8a7743 support
In reply to Biju DasDocument APMU and SMP enable method for RZ/G1M
(also known as r8a7743) SoC.
--- Documentation/devicetree/bindings/power/renesas,apmu.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/power/renesas,apmu.txt +2 -1
@@ -1,12 +1,13 @@ DT bindings for the Renesas Advanced Power Management Unit -Renesas R-Car line of SoCs utilize one or more APMU hardware units +Renesas R-Car and RZ/G1 SoCs utilize one or more APMU hardware units for CPU core power domain control including SMP boot and CPU Hotplug. Required properties: - compatible: Should be "renesas,<soctype>-apmu", "renesas,apmu" as fallback. Examples with soctypes are: + - "renesas,r8a7743-apmu" (RZ/G1M) - "renesas,r8a7790-apmu" (R-Car H2) - "renesas,r8a7791-apmu" (R-Car M2-W)
Signature · 1 line
2.7.4
PATCH 8/10 ARM: dts: r8a7743: Add APMU node and second CPU core
In reply to Biju DasAdd DT nodes for the Advanced Power Management Unit (APMU) and the second CPU core. Use the enable-method to point out that the APMU should be used for SMP support.
(removed power domain property, since we don't have sysc driver in 4.4 kernel to support CA15-CPU1 and CA15-SCU power domains).
--- arch/arm/boot/dts/r8a7743.dtsi | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
arch/arm/boot/dts/r8a7743.dtsi +15 -0
@@ -21,6 +21,7 @@ cpus { #address-cells = <1>; #size-cells = <0>; + enable-method = "renesas,apmu"; cpu0: cpu at 0 { device_type = "cpu";
@@ -31,6 +32,14 @@ next-level-cache = <&L2_CA15>; }; + cpu1: cpu at 1 { + device_type = "cpu"; + compatible = "arm,cortex-a15"; + reg = <1>; + clock-frequency = <1500000000>; + next-level-cache = <&L2_CA15>; + }; + L2_CA15: cache-controller-0 { compatible = "cache"; cache-unified;
@@ -46,6 +55,12 @@ #size-cells = <2>; ranges; + apmu at e6152000 { + compatible = "renesas,r8a7743-apmu", "renesas,apmu"; + reg = <0 0xe6152000 0 0x188>; + cpus = <&cpu0 &cpu1>; + }; + gic: interrupt-controller at f1001000 { compatible = "arm,gic-400"; #interrupt-cells = <3>;
Signature · 1 line
2.7.4
PATCH 9/10 ARM: dts: r8a7743: Add OPP table for frequency scaling
In reply to Biju DasAdd needed information inside CPU0 for the generic cpufreq-cpu0 driver.
- clock-latency = 300 us
Approximate worst-case latency to do clock transition for every OPPs. Using an arbitrary safe value similar to r8a7791(R-Car M2) Soc.
- operating-points = < kHz - uV >
List of 6 operating points. All of them are using the same voltage since DVS is not supported in RZ/G1 Soc.
Note:This also fixes the below errors seen on kernel logs
[ 0.876877] cpu cpu0: dev_pm_opp_get_opp_count: OPP table not found (-19) [ 0.883727] cpu cpu1: cpufreq_init: failed to get clk: -2
Conflicts:
arch/arm/boot/dts/r8a7743.dtsi --- arch/arm/boot/dts/r8a7743.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/arm/boot/dts/r8a7743.dtsi +9 -0
@@ -29,7 +29,16 @@ reg = <0>; clock-frequency = <1500000000>; clocks = <&cpg_clocks R8A7743_CLK_Z>; + clock-latency = <300000>; /* 300 us */ next-level-cache = <&L2_CA15>; + + /* kHz - uV - OPPs unknown yet */ + operating-points = <1500000 1000000>, + <1312500 1000000>, + <1125000 1000000>, + < 937500 1000000>, + < 750000 1000000>, + < 375000 1000000>; }; cpu1: cpu at 1 {
Signature · 1 line
2.7.4
PATCH 10/10 ARM: dts: r8a7743: Add missing clock for secondary CA15 CPU core
In reply to Biju DasFrom: Geert Uytterhoeven <[email protected]>
Currently only the primary CPU in the CA15 cluster has a clocks property, while the secondary CPU core is driven by the same clock. Add the missing clocks property to fix this.
Conflicts:
arch/arm/boot/dts/r8a7743.dtsi --- arch/arm/boot/dts/r8a7743.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm/boot/dts/r8a7743.dtsi +1 -0
@@ -46,6 +46,7 @@ compatible = "arm,cortex-a15"; reg = <1>; clock-frequency = <1500000000>; + clocks = <&cpg_clocks R8A7743_CLK_Z>; next-level-cache = <&L2_CA15>; };
Signature · 1 line
2.7.4
cover Add SMP support for r8a7743
In reply to Biju DasQuoted 3 lines · Biju Das
This patch series aims to add SMP support for r8a7743 SoC.
It is tested against linux-v4.4.112-cip18
All looks good to me. I've applied and pushed these changes.
Ben.
Quoted 24 lines
Biju Das (4):
? ARM: shmobile: Add pm support for r8a7743
? dt-bindings: apmu: Document r8a7743 support
? ARM: dts: r8a7743: Add APMU node and second CPU core ? ARM: dts: r8a7743: Add OPP table for frequency scalingGeert Uytterhoeven (4):
? ARM: shmobile: apmu: Move #ifdefCONFIG_SMPto cover more functions ? ARM: shmobile: apmu: Add debug resource reset for secondary CPU boot ? ARM: shmobile: apmu: Allow booting secondary CPU cores in debug mode ? ARM: dts: r8a7743: Add missing clock for secondary CA15 CPU coreMagnus Damm (2):
? ARM: shmobile: apmu: Add APMU DT support via Enable method ? devicetree: bindings: Renesas APMU and SMP Enable method?Documentation/devicetree/bindings/arm/cpus.txt?????|??1 + ?.../devicetree/bindings/power/renesas,apmu.txt?????| 29 +++++++ ?arch/arm/boot/dts/r8a7743.dtsi?????????????????????| 25 ++++++ ?arch/arm/mach-shmobile/platsmp-apmu.c??????????????| 94 +++++++++++++++++++++- ?arch/arm/mach-shmobile/pm-rcar-gen2.c??????????????|??3 +?5 files changed, 150 insertions(+), 2 deletions(-)
?create mode 100644Documentation/devicetree/bindings/power/renesas,apmu.txt
Signature · 2 lines
Ben Hutchings Software Developer, Codethink Ltd.