Exynos 5410 Dual cluster support
Subsystems (7)
v4 cover Exynos 5410 Dual cluster support
The series of patches represent support of Exynos 5410 SoC
The Exynos 5410 is the first Samsung SoC based on bigLITTLE architecture Patches allow all 8 CPU cores (4 x A7 and 4 x A15) to run at the same time
Patches add new platform description, support of clock controller, dual cluster support and device tree for Exynos 5410
Has been build on v3.13-rc1.
Has been tested on Exynos 5410 reference board (exynos_defconfig).
Thanks for all your comments to Tomasz Figa, Dave Martin and Nicolas Pitre.
Vyacheslav.
Changelog:
v4:
In arch/arm/mach-exynos/edcs.c
1. Renamed all exynos_ prefixes to edcs_.
2. Reworked edcs_core_power_up/down functions.
3. Removed exynos_core_power_control function.
4. Added this_core_to_pcpu function.
5. Added core_power_state function which detects if cpu is being reset.
6. Replaced cache flush sequences with v7_exit_coherency_flush().
7. exynos_core_power_down moved to lock protected area.
8. edcs_power_down_finish implemented.
In Documentation/devicetree/bindings/clock/exynos5410-clock.txt
1. External clocks documented.
In arch/arm/boot/dts/exynos5410-smdk5410.dts
1. oscclk node corrected according to ePAPR recommendation. In arch/arm/boot/dts/exynos5410.dtsi
1. mct at 101C0000 node renamed to timer at 101C0000.
2. "interrupt-controller" line removed from mct node.
3. mct_map renamed to interrupt_map.
In arch/arm/mach-exynos/Kconfig
1. some cosmetic corrections.
In include/dt-bindings/clock/exynos5410.h
1. Unnecessary defines removed.
v3:
In drivers/clk/samsung/clk-exynos5410.c
1. Fixed rate clock "samsung,clock-oscclk" removed.
In arch/arm/boot/dts/exynos5410.dtsi
1. In mct node clock CLK_FIN_PLL replaced with generic fixed rate oscclk.
In arch/arm/boot/dts/exynos5410-smdk5410.dts
1. Fixed rate oscclk clock added.
In arch/arm/mach-exynos/edcs.c
1. Added write memory barrier in exynos_core_power_control function.
2. __raw_readl/__raw_writel replaced with readl_relaxed/writel_relaxed.
3. #define added for some magic constants.
4. Disabled the GIC CPU interface in exynos_power_down function.
v2:
In drivers/clk/samsung/clk-exynos5410.c
1. Clock driver converted to use preprocessor macros instead of enums. Clock IDs now defined in include/dt-bindings/clock/exynos5410.h.
2. Unused spinlock removed.
3. Function exynos5410_clk_init defined as static.
Struct exynos5410_fixed_rate_ext_clks defined as static. Struct exynos5410_mux_clks defined as static.
Struct exynos5410_div_clks defined as static.
Struct exynos5410_gate_clks defined as static.
4. Removed aliases.
5. Pll's magic register offsets defined as preprocessor macros.
6. Redundant check of device_node pointer removed.
In arch/arm/boot/dts/exynos5410.dtsi
1. dwmmcX nodes renamed to mmc.
dwmmc_X renamed to mmc_X.
dwmmc status="disabled" field added.
fifo-depth field moved from arch/arm/boot/dts/exynos5410-smdk5410.dts
2. Blank lines added where necessary.
3. cpu@ suffixes corrected.
4. edcs node removed.
5. Hexadecimal characters case corrected.
6. Clock IDs replaced with preprocessor macros.
In arch/arm/boot/dts/exynos5410-smdk5410.dts
1. status = "okay" field added to mmc nodes.
In arch/arm/mach-exynos/edcs.c
1. "kfs_" prefix replaced with "edcs_"
2. EDCS_CPUS_PER_CLUSTER and EDCS_CLUSTERS defined instead of MCPM's values.
3. Cache handling sequence borrowed from arch/arm/mach-vexpress/tc2_pm.c
4. mcpm_sync_init() call added.
5. power management functions reworked.
Other
1. Documentation/devicetree/bindings/clock/exynos5410-clock.txt corrected.
2. Removed smdk5410_defconfig. Instead SOC_EXYNOS5410 now selects MCPM and ARM_CCI in arch/arm/mach-exynos/Kconfig.
3. edcs_status driver removed.
Tarek Dakhran (4):
ARM: EXYNOS: Add support for EXYNOS5410 SoC
clk: exynos5410: register clocks using common clock framework
ARM: dts: Add initial device tree support for EXYNOS5410
ARM: EXYNOS: add Exynos Dual Cluster Support
.../devicetree/bindings/clock/exynos5410-clock.txt | 54 ++++ arch/arm/boot/dts/Makefile | 1 + arch/arm/boot/dts/exynos5410-smdk5410.dts | 72 +++++ arch/arm/boot/dts/exynos5410.dtsi | 207 ++++++++++++++ arch/arm/mach-exynos/Kconfig | 12 + arch/arm/mach-exynos/Makefile | 2 + arch/arm/mach-exynos/common.c | 18 ++ arch/arm/mach-exynos/edcs.c | 297 +++++++++++++++++++++ arch/arm/mach-exynos/include/mach/map.h | 1 + arch/arm/mach-exynos/mach-exynos5-dt.c | 1 + arch/arm/plat-samsung/include/plat/cpu.h | 8 + drivers/clk/samsung/Makefile | 1 + drivers/clk/samsung/clk-exynos5410.c | 239 +++++++++++++++++ include/dt-bindings/clock/exynos5410.h | 32 +++ 14 files changed, 945 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/exynos5410-clock.txt create mode 100644 arch/arm/boot/dts/exynos5410-smdk5410.dts create mode 100644 arch/arm/boot/dts/exynos5410.dtsi create mode 100644 arch/arm/mach-exynos/edcs.c create mode 100644 drivers/clk/samsung/clk-exynos5410.c create mode 100644 include/dt-bindings/clock/exynos5410.h
Signature · 1 line
1.8.1.5
PATCH v4 1/4 ARM: EXYNOS: Add support for EXYNOS5410 SoC
From: Tarek Dakhran <[email protected]>
EXYNOS5410 is SoC in Samsung's Exynos5 SoC series. Add initial support for this SoC.
--- arch/arm/mach-exynos/Kconfig | 12 ++++++++++++ arch/arm/mach-exynos/common.c | 18 ++++++++++++++++++ arch/arm/mach-exynos/include/mach/map.h | 1 + arch/arm/mach-exynos/mach-exynos5-dt.c | 1 + arch/arm/plat-samsung/include/plat/cpu.h | 8 ++++++++ 5 files changed, 40 insertions(+)
arch/arm/mach-exynos/Kconfig +12 -0
@@ -93,6 +93,18 @@ config SOC_EXYNOS5250 help Enable EXYNOS5250 SoC support +config SOC_EXYNOS5410 + bool "SAMSUNG EXYNOS5410" + default y + depends on ARCH_EXYNOS5 + select ARM_CCI + select MCPM + select PM_GENERIC_DOMAINS if PM_RUNTIME + select S5P_PM if PM_SLEEP + select S5P_SLEEP if PM_SLEEP + help + Enable EXYNOS5410 SoC support + config SOC_EXYNOS5420 bool "SAMSUNG EXYNOS5420" default y
arch/arm/mach-exynos/common.c +18 -0
@@ -52,6 +52,7 @@ static const char name_exynos4210[] = "EXYNOS4210";static const char name_exynos4212[] ="EXYNOS4212" ;static const char name_exynos4412[] ="EXYNOS4412" ;static const char name_exynos5250[] ="EXYNOS5250" ; +static const char name_exynos5410[] ="EXYNOS5410" ;static const char name_exynos5420[] ="EXYNOS5420" ;static const char name_exynos5440[] ="EXYNOS5440" ;
@@ -85,6 +86,12 @@ static struct cpu_table cpu_ids[] __initdata = { .init = exynos_init, .name = name_exynos5250, }, { + .idcode = EXYNOS5410_SOC_ID, + .idmask = EXYNOS5_SOC_MASK, + .map_io = exynos5_map_io, + .init = exynos_init, + .name = name_exynos5410, + }, { .idcode = EXYNOS5420_SOC_ID, .idmask = EXYNOS5_SOC_MASK, .map_io = exynos5_map_io,
@@ -215,6 +222,15 @@ static struct map_desc exynos4x12_iodesc[] __initdata = { }, }; +static struct map_desc exynos5410_iodesc[]__initdata = { + { + .virtual = (unsigned long )S5P_VA_SYSRAM_NS , + .pfn =__phys_to_pfn (EXYNOS5410_PA_SYSRAM_NS ), + .length =SZ_4K , + .type =MT_DEVICE , + }, +}; +static struct map_desc exynos5250_iodesc[]__initdata = { { .virtual = (unsigned long )S5P_VA_SYSRAM_NS ,
@@ -374,6 +390,8 @@ static void __init exynos5_map_io(void)if (soc_is_exynos5250 ())iotable_init (exynos5250_iodesc,ARRAY_SIZE (exynos5250_iodesc)); +if (soc_is_exynos5410 ()) +iotable_init (exynos5410_iodesc,ARRAY_SIZE (exynos5410_iodesc)); }struct bus_type exynos_subsys = {
arch/arm/mach-exynos/include/mach/map.h +1 -0
@@ -29,6 +29,7 @@#define EXYNOS4210_PA_SYSRAM_NS 0x0203F000#define EXYNOS4x12_PA_SYSRAM_NS 0x0204F000#define EXYNOS5250_PA_SYSRAM_NS 0x0204F000 +#define EXYNOS5410_PA_SYSRAM_NS 0x02073000#define EXYNOS_PA_CHIPID 0x10000000
arch/arm/mach-exynos/mach-exynos5-dt.c +1 -0
@@ -50,6 +50,7 @@ static void __init exynos5_dt_machine_init(void)static char const *exynos5_dt_compat[]__initdata = {"samsung,exynos5250" , +"samsung,exynos5410" ,"samsung,exynos5420" ,"samsung,exynos5440" ,NULL
arch/arm/plat-samsung/include/plat/cpu.h +8 -0
@@ -46,6 +46,7 @@ extern unsigned long samsung_cpu_id;#define EXYNOS4_CPU_MASK 0xFFFE0000#define EXYNOS5250_SOC_ID 0x43520000 +#define EXYNOS5410_SOC_ID 0xE5410000#define EXYNOS5420_SOC_ID 0xE5420000#define EXYNOS5440_SOC_ID 0xE5440000#define EXYNOS5_SOC_MASK 0xFFFFF000
@@ -68,6 +69,7 @@ IS_SAMSUNG_CPU(exynos4210, EXYNOS4210_CPU_ID, EXYNOS4_CPU_MASK) IS_SAMSUNG_CPU(exynos4212, EXYNOS4212_CPU_ID, EXYNOS4_CPU_MASK) IS_SAMSUNG_CPU(exynos4412, EXYNOS4412_CPU_ID, EXYNOS4_CPU_MASK) IS_SAMSUNG_CPU(exynos5250, EXYNOS5250_SOC_ID, EXYNOS5_SOC_MASK) +IS_SAMSUNG_CPU(exynos5410, EXYNOS5410_SOC_ID, EXYNOS5_SOC_MASK) IS_SAMSUNG_CPU(exynos5420, EXYNOS5420_SOC_ID, EXYNOS5_SOC_MASK)IS_SAMSUNG_CPU (exynos5440,EXYNOS5440_SOC_ID ,EXYNOS5_SOC_MASK )
@@ -148,6 +150,12 @@ IS_SAMSUNG_CPU(exynos5440, EXYNOS5440_SOC_ID, EXYNOS5_SOC_MASK)# define soc_is_exynos5250 () 0#endif +#if defined(CONFIG_SOC_EXYNOS5410 ) +# define soc_is_exynos5410 () is_samsung_exynos5410() +#else +# define soc_is_exynos5410 () 0 +#endif +#if defined(CONFIG_SOC_EXYNOS5420 )# define soc_is_exynos5420 () is_samsung_exynos5420()#else
Signature · 1 line
1.8.1.5
PATCH v4 2/4 clk: exynos5410: register clocks using common clock framework
In reply to Vyacheslav TyrtovFrom: Tarek Dakhran <[email protected]>
The EXYNOS5410 clocks are statically listed and registered using the Samsung specific common clock helper functions.
--- .../devicetree/bindings/clock/exynos5410-clock.txt | 54 +++++ drivers/clk/samsung/Makefile | 1 + drivers/clk/samsung/clk-exynos5410.c | 239 +++++++++++++++++++++ include/dt-bindings/clock/exynos5410.h | 32 +++ 4 files changed, 326 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/exynos5410-clock.txt create mode 100644 drivers/clk/samsung/clk-exynos5410.c create mode 100644 include/dt-bindings/clock/exynos5410.h
Documentation/devicetree/bindings/clock/exynos5410-clock.txt new file +54 -0
@@ -0,0 +1,54 @@ +* Samsung Exynos5410 Clock Controller + +The Exynos5410 clock controller generates and supplies clock to various +controllers within the Exynos5410 SoC. + +Required Properties: + +- compatible: should be "samsung,exynos5410-clock" + +- reg: physical base address of the controller and length of memory mapped + region. + +- #clock-cells: should be 1. + +All available clocks are defined as preprocessor macros in +dt-bindings/clock/exynos5410.h header and can be used in device +tree sources. + +External clock: + +There is clock that is generated outside the SoC. It is expected +that it is defined using standard clock bindings with following +clock-output-name: + - "fin_pll" - PLL input clock - required. + +Example 1: An example of a clock controller node is listed below. + + clock: clock-controller at 0x10010000 { + compatible = "samsung,exynos5410-clock"; + reg = <0x10010000 0x30000>; + #clock-cells = <1>; + }; + +Example 2: Required external clock. + + fin_pll: clock-fin-pll { + compatible = "fixed-clock"; + reg = <0>; + #clock-cells = <0>; + clock-frequency = <24000000>; + clock-output-names = "fin_pll"; + }; + +Example 3: UART controller node that consumes the clock generated by the clock + controller. Refer to the standard clock bindings for information + about 'clocks' and 'clock-names' property. + + serial at 12C20000 { + compatible = "samsung,exynos4210-uart"; + reg = <0x12C00000 0x100>; + interrupts = <0 51 0>; + clocks = <&clock CLK_UART0>, <&clock CLK_SCLK_UART0>; + clock-names = "uart", "clk_uart_baud0"; + };
drivers/clk/samsung/Makefile +1 -0
@@ -5,6 +5,7 @@ obj-$(CONFIG_COMMON_CLK) += clk.o clk-pll.o obj-$(CONFIG_ARCH_EXYNOS4) += clk-exynos4.o obj-$(CONFIG_SOC_EXYNOS5250) += clk-exynos5250.o +obj-$(CONFIG_SOC_EXYNOS5410) += clk-exynos5410.o obj-$(CONFIG_SOC_EXYNOS5420) += clk-exynos5420.o obj-$(CONFIG_SOC_EXYNOS5440) += clk-exynos5440.o obj-$(CONFIG_ARCH_EXYNOS) += clk-exynos-audss.o
drivers/clk/samsung/clk-exynos5410.c new file +239 -0
239 lines not on this page · raw message
include/dt-bindings/clock/exynos5410.h new file +32 -0
@@ -0,0 +1,32 @@ +#ifndef _DT_BINDINGS_CLOCK_EXYNOS_5410_H +#define _DT_BINDINGS_CLOCK_EXYNOS_5410_H + +/* core clocks */ +#define CLK_FOUT_APLL 1 +#define CLK_FOUT_CPLL 2 +#define CLK_FOUT_MPLL 3 +#define CLK_FOUT_BPLL 4 +#define CLK_FOUT_KPLL 5 + +/* gate for special clocks (sclk) */ +#define CLK_SCLK_UART0 128 +#define CLK_SCLK_UART1 129 +#define CLK_SCLK_UART2 130 +#define CLK_SCLK_UART3 131 +#define CLK_SCLK_MMC0 132 +#define CLK_SCLK_MMC1 133 +#define CLK_SCLK_MMC2 134 + +/* gate clocks */ +#define CLK_UART0 257 +#define CLK_UART1 258 +#define CLK_UART2 259 +#define CLK_UART3 260 +#define CLK_MCT 315 +#define CLK_MMC0 351 +#define CLK_MMC1 352 +#define CLK_MMC2 353 + +#define CLK_NR_CLKS 512 + +#endif /* _DT_BINDINGS_CLOCK_EXYNOS_5410_H */
Signature · 1 line
1.8.1.5
Re: [PATCH v4 2/4] clk: exynos5410: register clocks using common clock framework
Hi Vyacheslav, Tarek,
Quoted 7 lines · On Tuesday 26 of November 2013 12:58:06 Vyacheslav Tyrtov wrote:
From: Tarek Dakhran <[email protected]>
The EXYNOS5410 clocks are statically listed and registered using the Samsung specific common clock helper functions.
Signed-off-by Tarek Dakhran <[email protected]>Signed-off-by Vyacheslav Tyrtov <[email protected]>
Quoted 9 lines
--- .../devicetree/bindings/clock/exynos5410-clock.txt | 54 +++++ drivers/clk/samsung/Makefile | 1 + drivers/clk/samsung/clk-exynos5410.c | 239 +++++++++++++++++++++ include/dt-bindings/clock/exynos5410.h | 32 +++ 4 files changed, 326 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/exynos5410-clock.txt create mode 100644 drivers/clk/samsung/clk-exynos5410.c create mode 100644 include/dt-bindings/clock/exynos5410.h
This should go through Samsung tree, I guess, since it's a dependency of other patches in this series and doesn't depend on any things from clock tree. Mike, Kukjin, are you okay with this?
Best regards,
Tomasz
Re: [PATCH v4 2/4] clk: exynos5410: register clocks using common clock framework
Quoted 20 lines · Tomasz Figa
Hi Vyacheslav, Tarek,
Quoted 13 lines · On Tuesday 26 of November 2013 12:58:06 Vyacheslav Tyrtov wrote:
From: Tarek Dakhran<[email protected]>
The EXYNOS5410 clocks are statically listed and registered using the Samsung specific common clock helper functions.
Signed-off-by Tarek Dakhran<[email protected]>Signed-off-by Vyacheslav Tyrtov<[email protected]>--- .../devicetree/bindings/clock/exynos5410-clock.txt | 54 +++++ drivers/clk/samsung/Makefile | 1 + drivers/clk/samsung/clk-exynos5410.c | 239 +++++++++++++++++++++ include/dt-bindings/clock/exynos5410.h | 32 +++ 4 files changed, 326 insertions(+)Quoted 3 lines
create mode 100644
Documentation/devicetree/bindings/clock/exynos5410-clock.txtcreate mode 100644drivers/clk/samsung/clk-exynos5410.c
create mode 100644include/dt-bindings/clock/exynos5410.h
Quoted 2 lines
Acked-by Tomasz Figa<[email protected]>
Tomasz, thanks for your ack on clk stuff.
Quoted 4 lines
This should go through Samsung tree, I guess, since it's a dependency of other patches in this series and doesn't depend on any things from clock tree. Mike, Kukjin, are you okay with this?
Yeah, I'm fine on this series but 4th patch for supporting dual cluster.
Let me take 1 to 3 patches firstly. Thanks.
- Kukjin
Re: [PATCH v4 2/4] clk: exynos5410: register clocks using common clock framework
Quoted 27 lines · Kukjin Kim
Quoted 22 lines · Tomasz Figa
Hi Vyacheslav, Tarek,
Quoted 14 lines · On Tuesday 26 of November 2013 12:58:06 Vyacheslav Tyrtov wrote:
From: Tarek Dakhran<[email protected]>
The EXYNOS5410 clocks are statically listed and registered using the Samsung specific common clock helper functions.
Signed-off-by Tarek Dakhran<[email protected]>Signed-off-by Vyacheslav Tyrtov<[email protected]>--- .../devicetree/bindings/clock/exynos5410-clock.txt | 54 +++++ drivers/clk/samsung/Makefile | 1 + drivers/clk/samsung/clk-exynos5410.c | 239 +++++++++++++++++++++ include/dt-bindings/clock/exynos5410.h | 32 +++ 4 files changed, 326 insertions(+)Quoted 4 lines
create mode 100644
Documentation/devicetree/bindings/clock/exynos5410-clock.txt
create mode 100644drivers/clk/samsung/clk-exynos5410.ccreate mode 100644include/dt-bindings/clock/exynos5410.hQuoted 2 lines
Acked-by Tomasz Figa<[email protected]>Tomasz, thanks for your ack on clk stuff.
Quoted 9 lines
Quoted 4 lines
This should go through Samsung tree, I guess, since it's a dependency of other patches in this series and doesn't depend on any things from clock tree. Mike, Kukjin, are you okay with this?
Yeah, I'm fine on this series but 4th patch for supporting dual cluster.
Let me take 1 to 3 patches firstly. Thanks.
- Kukjin
Hi,
Today (10/12/2013) I will release [PATCH v5] without dual cluster support. EDCS (exynos dual cluster support) will be moved to separate patch.
Best regards,
Tarek Dakhran.
PATCH v4 3/4 ARM: dts: Add initial device tree support for EXYNOS5410
In reply to Vyacheslav TyrtovFrom: Tarek Dakhran <[email protected]>
Add initial device tree nodes for EXYNOS5410 SoC and SMDK5410 board.
--- arch/arm/boot/dts/Makefile | 1 + arch/arm/boot/dts/exynos5410-smdk5410.dts | 72 +++++++++++ arch/arm/boot/dts/exynos5410.dtsi | 207 ++++++++++++++++++++++++++++++ 3 files changed, 280 insertions(+) create mode 100644 arch/arm/boot/dts/exynos5410-smdk5410.dts create mode 100644 arch/arm/boot/dts/exynos5410.dtsi
arch/arm/boot/dts/Makefile +1 -0
@@ -63,6 +63,7 @@ dtb-$(CONFIG_ARCH_EXYNOS) += exynos4210-origen.dtb \ exynos5250-arndale.dtb \ exynos5250-smdk5250.dtb \ exynos5250-snow.dtb \ + exynos5410-smdk5410.dtb \ exynos5420-smdk5420.dtb \ exynos5440-sd5v1.dtb \ exynos5440-ssdk5440.dtb
arch/arm/boot/dts/exynos5410-smdk5410.dts new file +72 -0
72 lines not on this page · raw message
arch/arm/boot/dts/exynos5410.dtsi new file +207 -0
207 lines not on this page · raw message
Signature · 1 line
1.8.1.5
PATCH v4 4/4 ARM: EXYNOS: add Exynos Dual Cluster Support
In reply to Vyacheslav TyrtovFrom: Tarek Dakhran <[email protected]>
Add EDCS(Exynos Dual Cluster Support) for Samsung Exynos5410 SoC. This enables all 8 cores, 4 x A7 and 4 x A15 run at the same time.
--- arch/arm/mach-exynos/Makefile | 2 + arch/arm/mach-exynos/edcs.c | 297 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 299 insertions(+) create mode 100644 arch/arm/mach-exynos/edcs.c
arch/arm/mach-exynos/Makefile +2 -0
@@ -34,3 +34,5 @@ AFLAGS_exynos-smc.o :=-Wa,-march=armv7-a$(plus_sec) obj-$(CONFIG_ARCH_EXYNOS4) += mach-exynos4-dt.o obj-$(CONFIG_ARCH_EXYNOS5) += mach-exynos5-dt.o + +obj-$(CONFIG_SOC_EXYNOS5410) += edcs.o
arch/arm/mach-exynos/edcs.c new file +297 -0
297 lines not on this page · raw message
Signature · 1 line
1.8.1.5
PATCH v4 4/4 ARM: EXYNOS: add Exynos Dual Cluster Support
[Resending to to a mail snafu on my end -- apologies for any duplicates of this message received]
Quoted 107 lines · Vyacheslav Tyrtov
From: Tarek Dakhran <[email protected]>
Add EDCS(Exynos Dual Cluster Support) for Samsung Exynos5410 SoC. This enables all 8 cores, 4 x A7 and 4 x A15 run at the same time.
Signed-off-by Tarek Dakhran <[email protected]>Signed-off-by Vyacheslav Tyrtov <[email protected]>--- arch/arm/mach-exynos/Makefile | 2 + arch/arm/mach-exynos/edcs.c | 297 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 299 insertions(+) create mode 100644 arch/arm/mach-exynos/edcs.carch/arm/mach-exynos/Makefile +2
-0@@ -34,3 +34,5 @@ AFLAGS_exynos-smc.o :=-Wa,-march=armv7-a$(plus_sec) obj-$(CONFIG_ARCH_EXYNOS4) += mach-exynos4-dt.o obj-$(CONFIG_ARCH_EXYNOS5) += mach-exynos5-dt.o + +obj-$(CONFIG_SOC_EXYNOS5410) += edcs.oarch/arm/mach-exynos/edcs.c new file +78
-0@@ -0,0 +1,297 @@ +/* +* arch/arm/mach-exynos/edcs.c - exynos dual cluster power management support +* +* Copyright (c) 2013 Samsung Electronics Co., Ltd. +* Author: Tarek Dakhran <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* EDCS(exynos dual cluster support) for Exynos5410 SoC. +*/ + +#define pr_fmt (fmt) "%s: " fmt, __func__ + +#include <linux/init.h> +#include <linux/io.h> +#include <linux/of_address.h> +#include <linux/spinlock.h> +#include <linux/errno.h> +#include <linux/irqchip/arm-gic.h> +#include <linux/delay.h> + +#include <asm/mcpm.h> +#include <asm/proc-fns.h> +#include <asm/cacheflush.h> +#include <asm/cputype.h> +#include <asm/cp15.h> + +#include <linux/arm-cci.h> +#include <mach/regs-pmu.h> + +#define EDCS_CPUS_PER_CLUSTER 4 +#define EDCS_CLUSTERS 2 + +/* Exynos5410 power management registers */ +#define EDCS_CORE_CONFIGURATION (_nr) (S5P_ARM_CORE0_CONFIGURATION \ + + ((_nr) * 0x80)) +#define EDCS_CORE_STATUS (_nr) (EDCS_CORE_CONFIGURATION(_nr) + 0x4) +#define EDCS_CORE_OPTION (_nr) (EDCS_CORE_CONFIGURATION(_nr) + 0x8) + +#define REG_CPU_STATE_ADDR0 (S5P_VA_SYSRAM_NS + 0x28) +#define REG_CPU_STATE_ADDR (_nr) (REG_CPU_STATE_ADDR0 + \ + (_nr) * EDCS_CPUS_PER_CLUSTER) + +#define SECONDARY_RESET (1 << 1) +#define REG_ENTRY_ADDR (S5P_VA_SYSRAM_NS + 0x1c) + +#define EDCS_CORE_PWR_ON 0x3 +#define EDCS_CORE_PWR_OFF 0x0 +#define CORE_PWR_STATE_MASK 0x3 + +static arch_spinlock_t edcs_lock = __ARCH_SPIN_LOCK_UNLOCKED; + +static int edcs_use_count[EDCS_CPUS_PER_CLUSTER ][EDCS_CLUSTERS ]; +static int core_count[EDCS_CLUSTERS ]; + +/* +* this_core_to_pcpu reads mpidr and defines cluster and cpu. +*/ +static void this_core_to_pcpu (unsigned int *pcpu,unsigned int *pcluster) +{ +unsigned int mpidr; + + mpidr =read_cpuid_mpidr (); + *pcpu =MPIDR_AFFINITY_LEVEL (mpidr,0 ); + *pcluster =MPIDR_AFFINITY_LEVEL (mpidr,1 ); +} + +/* +* core_power_state is used to get core power state. +* returns: +* 0x0 - powered off; +* 0x3 - powered on; +* other values - in process; +*/ +static int core_power_state (unsigned int cpu,unsigned int cluster) +{
arch/arm/mach-exynos/edcs.c line 88
Quoted 10 lines
arch/arm/mach-exynos/edcs.c new file +10
-0+unsigned int offset = cluster *EDCS_CPUS_PER_CLUSTER + cpu; +int status =readl_relaxed (EDCS_CORE_STATUS (offset)); + +return status &CORE_PWR_STATE_MASK ; +} + +static void edcs_core_power_up (unsigned int cpu,unsigned int cluster) +{ +unsigned int offset = cluster *EDCS_CPUS_PER_CLUSTER + cpu; +if (core_power_state (cpu, cluster) ==EDCS_CORE_PWR_OFF ) {
This still looks racy.
edcs_core_power_up and edcs_core_power_down are both called with edcs_lock held, and cluster/cpu ref counting is done before we get here. So we know that the power state *change* is really supposed to happen.
*If* my assumption is correct that there is a delay between requesting a new power state, and the change being reported as completed in EDCS_CORE_STATUS:
For edcs_core_power_up(), there may be a pending power-down request which is not visible in the EDCS_CORE_STATUS registers yet.
I think this may mean that a power-up request will simply be missed if the core status does not read as EDCS_CORE_PWR_OFF yet. If that can happen, then you need to wait -- calling the power_down_finish method may be the right thing to do.
However, we cannot sleep here because edcs_lock is held and IRQs are masked. It may make sense to factor the status check out of power_down_finish and make it a separate function, then make edcs_core_power_up() return an error code to edcs_power_up() to indicate success or failure.
edcs_power_up() can respond to the error code by temporarily releasing edcs_lock and re-enabling interrupts while it sleeps.
edcs_power_up() should return an appropriate error code if you time out.
Maybe my assumptions are wrong, but if the above is not required, it would be good to see an explanation of why.
arch/arm/mach-exynos/edcs.c line 99
Quoted 11 lines
arch/arm/mach-exynos/edcs.c new file +11
-0+/* boot flag should be written before powering up */ +wmb (); +writel_relaxed (EDCS_CORE_PWR_ON , +EDCS_CORE_CONFIGURATION (offset)); + } +} + +static void edcs_core_power_down (unsigned int cpu,unsigned int cluster) +{ +unsigned int offset = cluster *EDCS_CPUS_PER_CLUSTER + cpu; +if (core_power_state (cpu, cluster) ==EDCS_CORE_PWR_ON )
This check doesn't seem to make sense. edcs_core_power_down() should only ever be called on the CPU being powered down.
So, if the above if() condition is false, then the CPU executing it is actually powered off?? That's a pretty neat trick for power-saving, but it sounds unlikely...
This check should perhaps be a BUG_ON( ... != EDCS_CORE_PWR_ON), or removed completely.
Quoted 88 lines
arch/arm/mach-exynos/edcs.c new file +88
-0+writel_relaxed (EDCS_CORE_PWR_OFF , +EDCS_CORE_CONFIGURATION (offset)); +} + +void set_boot_flag (unsigned int cpu,unsigned int mode) +{ +writel_relaxed (mode,REG_CPU_STATE_ADDR (cpu)); +} + +static int edcs_power_up (unsigned int cpu,unsigned int cluster) +{ +pr_debug ("cpu %u cluster %u\n" , cpu, cluster); +BUG_ON (cpu >=EDCS_CPUS_PER_CLUSTER || cluster >=EDCS_CLUSTERS ); + +local_irq_disable (); +arch_spin_lock (&edcs_lock); + + edcs_use_count[cpu][cluster]++; +if (edcs_use_count[cpu][cluster] ==1 ) { + ++core_count[cluster]; +set_boot_flag (cpu,SECONDARY_RESET ); +edcs_core_power_up (cpu, cluster); + }else if (edcs_use_count[cpu][cluster] !=2 ) { +/* +* The only possible values are: +* 0 = CPU down +* 1 = CPU (still) up +* 2 = CPU requested to be up before it had a chance +* to actually make itself down. +* Any other value is a bug. +*/ +BUG (); + } + +arch_spin_unlock (&edcs_lock); +local_irq_enable (); + +return 0 ; +} +static void edcs_power_down (void ) +{ +unsigned int mpidr, cpu, cluster; +bool last_man = false, skip_wfi = false; + +this_core_to_pcpu (&cpu, &cluster); + mpidr =read_cpuid_mpidr (); + +pr_debug ("cpu %u cluster %u\n" , cpu, cluster); +BUG_ON (cpu >=EDCS_CPUS_PER_CLUSTER || cluster >=EDCS_CLUSTERS ); + +__mcpm_cpu_going_down (cpu, cluster); + +arch_spin_lock (&edcs_lock); +BUG_ON (__mcpm_cluster_state (cluster) !=CLUSTER_UP ); + edcs_use_count[cpu][cluster]--; +if (edcs_use_count[cpu][cluster] ==0 ) { + --core_count[cluster]; +edcs_core_power_down (cpu, cluster); +if (core_count[cluster] ==0 ) + last_man = true; + }else if (edcs_use_count[cpu][cluster] ==1 ) { +/* +* A power_up request went ahead of us. +* Even if we do not want to shut this CPU down, +* the caller expects a certain state as if the WFI +* was aborted. So let's continue with cache cleaning. +*/ + skip_wfi = true; + }else +BUG (); + +if (!skip_wfi) +gic_cpu_if_down (); + +if (last_man &&__mcpm_outbound_enter_critical (cpu, cluster)) { +arch_spin_unlock (&edcs_lock); + +if (read_cpuid_part_number () ==ARM_CPU_PART_CORTEX_A15 ) { +/* +* On the Cortex-A15 we need to disable +* L2 prefetching before flushing the cache. +*/ + asmvolatile ( +"mcr p15, 1, %0, c15, c0, 3\n\t" +"isb\n\t" +"dsb" + : :"r" (0x400 )); + }
arch/arm/mach-exynos/edcs.c line 197
Quoted 10 lines
arch/arm/mach-exynos/edcs.c new file +10
-0+ +/* +* We need to disable and flush the whole (L1 and L2) cache. +* Let's do it in the safest possible way i.e. with +* no memory access within the following sequence +* including the stack. +* +* Note: fp is preserved to the stack explicitly prior doing +* this since adding it to the clobber list is incompatible +* with having CONFIG_FRAME_POINTER=y.
The above comments are not necessary now. They are replaced by the comments for v7_exit_coherency_flush() in cacheflush.h.
Quoted 29 lines
arch/arm/mach-exynos/edcs.c new file +29
-0+*/ +v7_exit_coherency_flush (all); + +cci_disable_port_by_cpu (mpidr); + +__mcpm_outbound_leave_critical (cluster,CLUSTER_DOWN ); + + }else { +arch_spin_unlock (&edcs_lock); +/* +* We need to disable and flush only the L1 cache. +* Let's do it in the safest possible way as above. +*/ +v7_exit_coherency_flush (louis); + + } +__mcpm_cpu_down (cpu, cluster); + +if (!skip_wfi) +wfi (); +} + +static int edcs_power_down_finish (unsigned int cpu,unsigned int cluster) +{ +unsigned int timeout =1000 ; +unsigned int sleep_time =10 ; + +pr_debug ("cpu %u cluster %u\n" , cpu, cluster); +BUG_ON (cpu >=EDCS_CPUS_PER_CLUSTER || cluster >=EDCS_CLUSTERS );
arch/arm/mach-exynos/edcs.c line 236
Quoted 10 lines
arch/arm/mach-exynos/edcs.c new file +10
-0+ +do { +if (ACCESS_ONCE (edcs_use_count[cpu][cluster]) ==0 ) { +/* checking if core powered down */ +if (core_power_state (cpu, cluster) ==EDCS_CORE_PWR_OFF ) +return 0 ; + } +msleep (sleep_time); + timeout -= sleep_time; + }while (timeout);
This looks OK. Note that if timeout % sleep_time != 0, the loop may not terminate. This is not really a problem unless someone breaks that assumption during maintenance in the future.
This is a minor nit, but the risk can be avoided by making sleep_time *and* timeout of type int (not unsigned int), and ending the loop with:
} while (timeout > 0);
Cheers
---Dave
Quoted 69 lines
arch/arm/mach-exynos/edcs.c new file +61
-0+ +return -ETIMEDOUT ;/* timeout */ +} + +static const struct mcpm_platform_ops edcs_power_ops = { + .power_up = edcs_power_up, + .power_down = edcs_power_down, + .power_down_finish = edcs_power_down_finish, +}; + +static void __init edcs_data_init (void ) +{ +unsigned int cpu, cluster; + +this_core_to_pcpu (&cpu, &cluster); + +pr_debug ("cpu %u cluster %u\n" , cpu, cluster); +BUG_ON (cpu >=EDCS_CPUS_PER_CLUSTER || cluster >=EDCS_CLUSTERS ); + edcs_use_count[cpu][cluster] =1 ; + ++core_count[cluster]; +} + +/* +* Enable cluster-level coherency, in preparation for turning on the MMU. +*/ +static void __naked edcs_power_up_setup (unsigned int affinity_level) +{ + asmvolatile ("\n" +"b cci_enable_port_for_self" ); +} + +static int __init edcs_init (void ) +{ +int ret; +struct device_node *node; + + node =of_find_compatible_node (NULL ,NULL ,"samsung,exynos5410" ); +if (!node) +return -ENODEV ; + +if (!cci_probed ()) +return -ENODEV ; + +/* +* Future entries into the kernel can now go +* through the cluster entry vectors. +*/ +writel_relaxed (virt_to_phys (mcpm_entry_point),REG_ENTRY_ADDR ); + +edcs_data_init (); +mcpm_smp_set_ops (); + + ret =mcpm_platform_register (&edcs_power_ops); +if (!ret) { +mcpm_sync_init (edcs_power_up_setup); +pr_info ("EDCS power management initialized\n" ); + } +return ret; +} + +early_initcall (edcs_init);Signature · 7 lines
1.8.1.5 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v4 4/4 ARM: EXYNOS: add Exynos Dual Cluster Support
Quoted 134 lines · Dave Martin
[Resending to to a mail snafu on my end -- apologies for any duplicates of this message received]
Quoted 107 lines · Vyacheslav Tyrtov
From: Tarek Dakhran <[email protected]>
Add EDCS(Exynos Dual Cluster Support) for Samsung Exynos5410 SoC. This enables all 8 cores, 4 x A7 and 4 x A15 run at the same time.
Signed-off-by Tarek Dakhran <[email protected]>Signed-off-by Vyacheslav Tyrtov <[email protected]>--- arch/arm/mach-exynos/Makefile | 2 + arch/arm/mach-exynos/edcs.c | 297 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 299 insertions(+) create mode 100644 arch/arm/mach-exynos/edcs.carch/arm/mach-exynos/Makefile +2
-0@@ -34,3 +34,5 @@ AFLAGS_exynos-smc.o :=-Wa,-march=armv7-a$(plus_sec) obj-$(CONFIG_ARCH_EXYNOS4) += mach-exynos4-dt.o obj-$(CONFIG_ARCH_EXYNOS5) += mach-exynos5-dt.o + +obj-$(CONFIG_SOC_EXYNOS5410) += edcs.oarch/arm/mach-exynos/edcs.c new file +78
-0@@ -0,0 +1,297 @@ +/* +* arch/arm/mach-exynos/edcs.c - exynos dual cluster power management support +* +* Copyright (c) 2013 Samsung Electronics Co., Ltd. +* Author: Tarek Dakhran <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* EDCS(exynos dual cluster support) for Exynos5410 SoC. +*/ + +#define pr_fmt (fmt) "%s: " fmt, __func__ + +#include <linux/init.h> +#include <linux/io.h> +#include <linux/of_address.h> +#include <linux/spinlock.h> +#include <linux/errno.h> +#include <linux/irqchip/arm-gic.h> +#include <linux/delay.h> + +#include <asm/mcpm.h> +#include <asm/proc-fns.h> +#include <asm/cacheflush.h> +#include <asm/cputype.h> +#include <asm/cp15.h> + +#include <linux/arm-cci.h> +#include <mach/regs-pmu.h> + +#define EDCS_CPUS_PER_CLUSTER 4 +#define EDCS_CLUSTERS 2 + +/* Exynos5410 power management registers */ +#define EDCS_CORE_CONFIGURATION (_nr) (S5P_ARM_CORE0_CONFIGURATION \ + + ((_nr) * 0x80)) +#define EDCS_CORE_STATUS (_nr) (EDCS_CORE_CONFIGURATION(_nr) + 0x4) +#define EDCS_CORE_OPTION (_nr) (EDCS_CORE_CONFIGURATION(_nr) + 0x8) + +#define REG_CPU_STATE_ADDR0 (S5P_VA_SYSRAM_NS + 0x28) +#define REG_CPU_STATE_ADDR (_nr) (REG_CPU_STATE_ADDR0 + \ + (_nr) * EDCS_CPUS_PER_CLUSTER) + +#define SECONDARY_RESET (1 << 1) +#define REG_ENTRY_ADDR (S5P_VA_SYSRAM_NS + 0x1c) + +#define EDCS_CORE_PWR_ON 0x3 +#define EDCS_CORE_PWR_OFF 0x0 +#define CORE_PWR_STATE_MASK 0x3 + +static arch_spinlock_t edcs_lock = __ARCH_SPIN_LOCK_UNLOCKED; + +static int edcs_use_count[EDCS_CPUS_PER_CLUSTER ][EDCS_CLUSTERS ]; +static int core_count[EDCS_CLUSTERS ]; + +/* +* this_core_to_pcpu reads mpidr and defines cluster and cpu. +*/ +static void this_core_to_pcpu (unsigned int *pcpu,unsigned int *pcluster) +{ +unsigned int mpidr; + + mpidr =read_cpuid_mpidr (); + *pcpu =MPIDR_AFFINITY_LEVEL (mpidr,0 ); + *pcluster =MPIDR_AFFINITY_LEVEL (mpidr,1 ); +} + +/* +* core_power_state is used to get core power state. +* returns: +* 0x0 - powered off; +* 0x3 - powered on; +* other values - in process; +*/ +static int core_power_state (unsigned int cpu,unsigned int cluster) +{arch/arm/mach-exynos/edcs.c line 88
Quoted 10 lines
arch/arm/mach-exynos/edcs.c new file +10
-0+unsigned int offset = cluster *EDCS_CPUS_PER_CLUSTER + cpu; +int status =readl_relaxed (EDCS_CORE_STATUS (offset)); + +return status &CORE_PWR_STATE_MASK ; +} + +static void edcs_core_power_up (unsigned int cpu,unsigned int cluster) +{ +unsigned int offset = cluster *EDCS_CPUS_PER_CLUSTER + cpu; +if (core_power_state (cpu, cluster) ==EDCS_CORE_PWR_OFF ) {This still looks racy.
edcs_core_power_upandedcs_core_power_downare both called withedcs_lockheld, and cluster/cpu ref counting is done before we get here. So we know that the power state *change* is really supposed to happen.*If* my assumption is correct that there is a delay between requesting a new power state, and the change being reported as completed in
EDCS_CORE_STATUS:
Quoted 7 lines
For
edcs_core_power_up(), there may be a pending power-down request which is not visible in theEDCS_CORE_STATUSregisters yet.I think this may mean that a power-up request will simply be missed if the core status does not read as
EDCS_CORE_PWR_OFFyet. If that can happen, then you need to wait -- calling thepower_down_finishmethod may be the right thing to do.
I agree with your analysis so far. However there is a fundamental question that the hardware designers need to answer:
What happens if EDCS_CORE_PWR_OFF and then EDCS_CORE_PWR_ON is written to the EDCS_CORE_CONFIGURATION register without waiting for the status to become EDCS_CORE_PWR_OFF in between the two writes? In other words, will the PWR_ON be lost or will it be honored even if the PWR_OFF request has not yet completed?
If the PWR_ON request is always honored then there is no need for a status check here. Otherwise this is a bit more complicated as outlined by Dave.
Nicolas
Re: [PATCH v4 4/4] ARM: EXYNOS: add Exynos Dual Cluster Support
In reply to Vyacheslav TyrtovQuoted 7 lines · Vyacheslav Tyrtov
From: Tarek Dakhran <[email protected]>
Add EDCS(Exynos Dual Cluster Support) for Samsung Exynos5410 SoC. This enables all 8 cores, 4 x A7 and 4 x A15 run at the same time.
Signed-off-by Tarek Dakhran <[email protected]>Signed-off-by Vyacheslav Tyrtov <[email protected]>
Just some minor comments in addition to those Dave already provided.
[...]
arch/arm/mach-exynos/edcs.c line 266
Quoted 8 lines
arch/arm/mach-exynos/edcs.c new file +8
-0+/* +* Enable cluster-level coherency, in preparation for turning on the MMU. +*/ +static void __naked edcs_power_up_setup (unsigned int affinity_level) +{ + asmvolatile ("\n" +"b cci_enable_port_for_self" ); +}
You should need to turn on the CCI port only for the first CPU to power up a cluster. This is indicated by the affinity level passed into r0. See tc2_pm_power_up_setup for example.
Quoted 18 lines
arch/arm/mach-exynos/edcs.c new file +18
-0+static int __init edcs_init (void ) +{ +int ret; +struct device_node *node; + + node =of_find_compatible_node (NULL ,NULL ,"samsung,exynos5410" ); +if (!node) +return -ENODEV ; + +if (!cci_probed ()) +return -ENODEV ; + +/* +* Future entries into the kernel can now go +* through the cluster entry vectors. +*/ +writel_relaxed (virt_to_phys (mcpm_entry_point),REG_ENTRY_ADDR ); +
arch/arm/mach-exynos/edcs.c line 295
Quoted 10 lines
arch/arm/mach-exynos/edcs.c new file +10
-0+edcs_data_init (); +mcpm_smp_set_ops (); + + ret =mcpm_platform_register (&edcs_power_ops); +if (!ret) { +mcpm_sync_init (edcs_power_up_setup); +pr_info ("EDCS power management initialized\n" ); + } +return ret; +}
Here I'd suggest initializing EG_ENTRY_ADDR only after mcpm_sync_init() is done. If ever a secondary CPU, seeing that the address is no longer zero, decides to enter the kernel while the state machine is not initialized yet, might lead to all sorts of funny behaviors.
Nicolas