ARM: imx: enable smp for i.MX7D
PATCH v2 1/2 ARM: imx: enable smp for i.MX7D
From: Frank Li <[email protected]>
i.MX7D have two cores.
enable multicore support.
enable cpu hotplug support.
---
This patch is based on Russel king's
ARM: v7 setup function should invalidate L1 cache
Change from V1 to V2
- base on ARM: v7 setup function should invalidate L1 cache
- remove unused define in gpcv2.c
- change name imx_gpcv2_set_core1_pdn_pup_by_software to imx_gpcv2_set_core1_power
- add timeout check.
- Change to BUG_ON
- Change use enable-method
arch/arm/mach-imx/Kconfig | 6 ++++ arch/arm/mach-imx/Makefile | 1 + arch/arm/mach-imx/common.h | 4 +++ arch/arm/mach-imx/gpcv2.c | 67 ++++++++++++++++++++++++++++++++++++++++++ arch/arm/mach-imx/hotplug.c | 18 ++++++++++++ arch/arm/mach-imx/mach-imx7d.c | 1 + arch/arm/mach-imx/platsmp.c | 18 ++++++++++++ arch/arm/mach-imx/src.c | 35 ++++++++++++++++++++-- 8 files changed, 147 insertions(+), 3 deletions(-) create mode 100644 arch/arm/mach-imx/gpcv2.c
arch/arm/mach-imx/Kconfig +6 -0
@@ -53,6 +53,10 @@ config HAVE_IMX_GPC bool select PM_GENERIC_DOMAINS if PM +config HAVE_IMX_GPCV2 + bool + select PM_GENERIC_DOMAINS if PM + config HAVE_IMX_MMDC bool
@@ -552,6 +556,8 @@ config SOC_IMX7D bool "i.MX7 Dual support" select PINCTRL_IMX7D select ARM_GIC + select ARM_ARCH_TIMER + select HAVE_IMX_GPCV2 help This enables support for Freescale i.MX7 Dual processor.
arch/arm/mach-imx/Makefile +1 -0
@@ -73,6 +73,7 @@ obj-$(CONFIG_MACH_IMX35_DT) += imx35-dt.o obj-$(CONFIG_HAVE_IMX_ANATOP) += anatop.o obj-$(CONFIG_HAVE_IMX_GPC) += gpc.o +obj-$(CONFIG_HAVE_IMX_GPCV2) += gpcv2.o obj-$(CONFIG_HAVE_IMX_MMDC) += mmdc.o obj-$(CONFIG_HAVE_IMX_SRC) += src.o ifneq ($(CONFIG_SOC_IMX6)$(CONFIG_SOC_LS1021A),)
arch/arm/mach-imx/common.h +4 -0
@@ -66,6 +66,7 @@ void imx_gpc_check_dt(void);void imx_gpc_set_arm_power_in_lpm (bool power_off);void imx_gpc_set_arm_power_up_timing (u32 sw2iso,u32 sw);void imx_gpc_set_arm_power_down_timing (u32 sw2iso,u32 sw); +void imx_gpcv2_set_core1_power (bool on);enum mxc_cpu_pwr_mode {WAIT_CLOCKED ,/* wfi only */
@@ -85,6 +86,7 @@ enum mx3_cpu_pwr_mode {void mx3_cpu_lp_set (enum mx3_cpu_pwr_mode mode);void imx_enable_cpu (int cpu,bool enable); +void imx_enable_cpu_ca7 (int cpu,bool enable);void imx_set_cpu_jump (int cpu,void *jump_addr);u32 imx_get_cpu_arg (int cpu);void imx_set_cpu_arg (int cpu,u32 arg);
@@ -110,9 +112,11 @@ int imx6_set_lpm(enum mxc_cpu_pwr_mode mode);void imx6q_set_int_mem_clk_lpm (bool enable);void imx6sl_set_wait_clk (bool enter);int imx_mmdc_get_ddr_type (void ); +int imx_gpcv2_init (const char *gpc_compat);void imx_cpu_die (unsigned int cpu);int imx_cpu_kill (unsigned int cpu); +int imx_cpu_ca7_kill (unsigned int cpu);#ifdef CONFIG_SUSPEND void v7_cpu_resume (void );
arch/arm/mach-imx/gpcv2.c new file +67 -0
67 lines not on this page · raw message
arch/arm/mach-imx/hotplug.c +18 -0
@@ -68,3 +68,21 @@ int imx_cpu_kill(unsigned int cpu)imx_set_cpu_arg (cpu,0 );return 1 ; } + +/* +* imx7 cortex a7 can power down each core. +* added power off operation after disable core 1. +*/ +int imx_cpu_ca7_kill (unsigned int cpu) +{ +unsigned long timeout = jiffies +msecs_to_jiffies (50 ); + +while (imx_get_cpu_arg (cpu) ==0 ) +if (time_after (jiffies, timeout)) +return 0 ; + +imx_enable_cpu_ca7 (cpu, false); +imx_gpcv2_set_core1_power (false); +imx_set_cpu_arg (cpu,0 ); +return 1 ; +}
arch/arm/mach-imx/mach-imx7d.c +1 -0
@@ -27,6 +27,7 @@ static void __init imx7d_init_machine(void)static void __init imx7d_init_irq (void ) {imx_init_revision_from_anatop (); +imx_gpcv2_init ("fsl,imx7d-gpc" );imx_src_init ();irqchip_init (); }
arch/arm/mach-imx/platsmp.c +18 -0
@@ -98,6 +98,24 @@ struct smp_operations imx_smp_ops __initdata = {#endif }; +static int imx_ca7_boot_secondary (unsigned int cpu,struct task_struct *idle) +{ +imx_set_cpu_jump (cpu, secondary_startup); +imx_gpcv2_set_core1_power (true); +imx_enable_cpu_ca7 (cpu, true); +return 0 ; +} + +struct smp_operations imx_smp_ca7_ops__initdata = { + .smp_boot_secondary = imx_ca7_boot_secondary, +#ifdef CONFIG_HOTPLUG_CPU + .cpu_die = imx_cpu_die, + .cpu_kill = imx_cpu_ca7_kill, +#endif +}; + +CPU_METHOD_OF_DECLARE (imx_smp_ca7,"fsl,imx7d-smp" , &imx_smp_ca7_ops); +#define DCFG_CCSR_SCRATCHRW1 0x200static int ls1021a_boot_secondary (unsigned int cpu,struct task_struct *idle)
arch/arm/mach-imx/src.c +32 -3
@@ -30,8 +30,17 @@#define BP_SRC_SCR_CORE1_RST 14#define BP_SRC_SCR_CORE1_ENABLE 22 +/* below is for i.MX7D */ +#define SRC_GPR1_MX7D 0x074 +#define SRC_A7RCR0 0x004 +#define SRC_A7RCR1 0x008 + +#define BP_SRC_A7RCR0_A7_CORE_RESET0 0 +#define BP_SRC_A7RCR1_A7_CORE1_ENABLE 1 +static void __iomem *src_base;static DEFINE_SPINLOCK (scr_lock); +static int src_gpr_offset;static const int sw_reset_bits[5 ] = {BP_SRC_SCR_SW_GPU_RST ,
@@ -96,23 +105,36 @@ void imx_enable_cpu(int cpu, bool enable)spin_unlock (&scr_lock); } +void imx_enable_cpu_ca7 (int cpu,bool enable) +{ +u32 mask, val; + + cpu =cpu_logical_map (cpu); +spin_lock (&scr_lock); + mask =1 << (BP_SRC_A7RCR1_A7_CORE1_ENABLE + cpu -1 ); + val =readl_relaxed (src_base +SRC_A7RCR1 ); + val = enable ? val | mask : val & ~mask; +writel_relaxed (val, src_base +SRC_A7RCR1 ); +spin_unlock (&scr_lock); +} +void imx_set_cpu_jump (int cpu,void *jump_addr) { cpu =cpu_logical_map (cpu);writel_relaxed (virt_to_phys (jump_addr), - src_base +SRC_GPR1 + cpu *8 ); + src_base + src_gpr_offset + cpu *8 ); }u32 imx_get_cpu_arg (int cpu) { cpu =cpu_logical_map (cpu); -return readl_relaxed (src_base +SRC_GPR1 + cpu *8 +4 ); +return readl_relaxed (src_base + src_gpr_offset + cpu *8 +4 ); }void imx_set_cpu_arg (int cpu,u32 arg) { cpu =cpu_logical_map (cpu); -writel_relaxed (arg, src_base +SRC_GPR1 + cpu *8 +4 ); +writel_relaxed (arg, src_base + src_gpr_offset + cpu *8 +4 ); }void __init imx_src_init (void )
@@ -120,6 +142,8 @@ void __init imx_src_init(void)struct device_node *np;u32 val; + src_gpr_offset =SRC_GPR1 ; + np =of_find_compatible_node (NULL ,NULL ,"fsl,imx51-src" );if (!np)return ;
@@ -127,6 +151,11 @@ void __init imx_src_init(void)WARN_ON (!src_base); imx_reset_controller.of_node = np; + + np =of_find_compatible_node (NULL ,NULL ,"fsl,imx7d-src" ); +if (np) + src_gpr_offset =SRC_GPR1_MX7D ; +if (IS_ENABLED (CONFIG_RESET_CONTROLLER ))reset_controller_register (&imx_reset_controller);
Signature · 1 line
1.9.1
PATCH v2 2/2 ARM: dts: imx7d: added arch timer and gpc
From: Frank Li <[email protected]>
add cortex a7 arch timer and gpc to enable smp uboot need clear virtual timer offset.
if not, need add "arm,cpu-registers-not-fw-configured" in arch timer section to boot up.
--- arch/arm/boot/dts/imx7d.dtsi | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
arch/arm/boot/dts/imx7d.dtsi +16 -0
@@ -74,6 +74,7 @@ cpus { #address-cells = <1>; #size-cells = <0>; + enable-method = "fsl,imx7d-smp"; cpu0: cpu at 0 { compatible = "arm,cortex-a7";
@@ -121,6 +122,15 @@ clock-output-names = "osc"; }; + timer { + compatible = "arm,armv7-timer"; + interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>, + <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>, + <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>, + <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>; + interrupt-parent = <&intc>; + }; + soc { #address-cells = <1>; #size-cells = <1>;
@@ -320,6 +330,12 @@ interrupts = <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>; #reset-cells = <1>; }; + + gpc: gpc at 303a0000 { + compatible = "fsl,imx7d-gpc"; + reg = <0x303a0000 0x10000>; + interrupts = <GIC_SPI 87 IRQ_TYPE_LEVEL_HIGH>; + }; }; aips3: aips-bus at 30800000 {
Signature · 1 line
1.9.1
PATCH v2 1/2 ARM: imx: enable smp for i.MX7D
In reply to Frank.Li at freescale.comQuoted 6 lines · Frank.Li at freescale.com
From: Frank Li <[email protected]>
i.MX7D have two cores.
enable multicore support.
enable cpu hotplug support.
Quoted 6 lines
Signed-off-by Frank Li <[email protected]>Signed-off-by Anson Huang <[email protected]>---
This patch is based on Russel king's
ARM: v7 setup function should invalidate L1 cache
So we will need to wait for Russell's patch to land on mainline first.
Quoted 9 lines
Change from V1 to V2
- base on ARM: v7 setup function should invalidate L1 cache
- remove unused define ingpcv2.c
- change nameimx_gpcv2_set_core1_pdn_pup_by_softwaretoimx_gpcv2_set_core1_power
- add timeout check.
- Change toBUG_ON
- Change use enable-method
Quoted 10 lines
arch/arm/mach-imx/Kconfig | 6 ++++ arch/arm/mach-imx/Makefile | 1 + arch/arm/mach-imx/common.h | 4 +++ arch/arm/mach-imx/gpcv2.c | 67 ++++++++++++++++++++++++++++++++++++++++++ arch/arm/mach-imx/hotplug.c | 18 ++++++++++++ arch/arm/mach-imx/mach-imx7d.c | 1 + arch/arm/mach-imx/platsmp.c | 18 ++++++++++++ arch/arm/mach-imx/src.c | 35 ++++++++++++++++++++-- 8 files changed, 147 insertions(+), 3 deletions(-) create mode 100644 arch/arm/mach-imx/gpcv2.c
Honestly, I do not like the software version numbering which is quite arbitrary and may conflict with hardware one some day.
More importantly, is i.MX7 GPC block really so different from i.MX6 one and worth a new driver for it? If you check the latest GPC driver, you will find that it evolves a lot recently and becomes a driver handles not only core power but also PU power domains, and also we have
implemented stacked IRQ domain for it. Are you going to redo all these
for this gpcv2 driver?
Shawn
PATCH v2 1/2 ARM: imx: enable smp for i.MX7D
Quoted 36 lines · Shawn Guo
Quoted 6 lines · Frank.Li at freescale.com
From: Frank Li <[email protected]>
i.MX7D have two cores.
enable multicore support.
enable cpu hotplug support.Quoted 6 lines
Signed-off-by Frank Li <[email protected]>Signed-off-by Anson Huang <[email protected]>---
This patch is based on Russel king's
ARM: v7 setup function should invalidate L1 cacheSo we will need to wait for Russell's patch to land on mainline first.
Quoted 9 lines
Change from V1 to V2
- base on ARM: v7 setup function should invalidate L1 cache
- remove unused define ingpcv2.c
- change nameimx_gpcv2_set_core1_pdn_pup_by_softwaretoimx_gpcv2_set_core1_power
- add timeout check.
- Change toBUG_ON
- Change use enable-methodQuoted 10 lines
arch/arm/mach-imx/Kconfig | 6 ++++ arch/arm/mach-imx/Makefile | 1 + arch/arm/mach-imx/common.h | 4 +++ arch/arm/mach-imx/gpcv2.c | 67 ++++++++++++++++++++++++++++++++++++++++++ arch/arm/mach-imx/hotplug.c | 18 ++++++++++++ arch/arm/mach-imx/mach-imx7d.c | 1 + arch/arm/mach-imx/platsmp.c | 18 ++++++++++++ arch/arm/mach-imx/src.c | 35 ++++++++++++++++++++-- 8 files changed, 147 insertions(+), 3 deletions(-) create mode 100644 arch/arm/mach-imx/gpcv2.c
Quoted 2 lines
Honestly, I do not like the software version numbering which is quite arbitrary and may conflict with hardware one some day.
what's name do you prefer?
Quoted 7 lines
More importantly, is i.MX7 GPC block really so different from i.MX6 one and worth a new driver for it? If you check the latest GPC driver, you will find that it evolves a lot recently and becomes a driver handles not only core power but also PU power domains, and also we have
implemented stacked IRQ domain for it. Are you going to redo all these
for this gpcv2 driver?
Totally difference.
Only simular part is that GPC irq mask, which only bit possition and register offfset change.
Suspend/Resume flow also changed.
shenwei is working on that.
best regards
Frank Li
Quoted 2 lines
Shawn
PATCH v2 1/2 ARM: imx: enable smp for i.MX7D
Quoted 1 line · Zhi Li
what's name do you prefer?
If we have to create a new driver, I prefer to name it after imx7.
Quoted 6 lines
Totally difference.
Only simular part is that GPC irq mask, which only bit possition and register offfset change.
So at least GPC needs to be initialized as stacked IRQ domain. Please check out commit b923ff6af0d5 (ARM: imx6: convert GPC to stacked domains) for how it should be done.
Shawn
PATCH v2 1/2 ARM: imx: enable smp for i.MX7D
Quoted 7 lines · Shawn Guo
Quoted 1 line · Zhi Li
what's name do you prefer?
If we have to create a new driver, I prefer to name it after imx7.
Quoted 2 lines
Totally difference.
Quoted 8 lines
Quoted 4 lines
Only simular part is that GPC irq mask, which only bit possition and register offfset change.
So at least GPC needs to be initialized as stacked IRQ domain. Please check out commit
b923ff6af0d5(ARM: imx6: convert GPC to stacked domains) for how it should be done.
Yes!. Shenwei is working this.
Stacked IRQ is mainly for suspend/resume. Plan move to irqchip. Register define also changed.
ARM power ON/OFF should be like regulator. but I have not any other platform use regulator interface to control
ARM core power.
Quoted 2 lines
Shawn