Skip to contentSkip to conversation

Remove static mapping of SCU from mach-exynos

PATCH Superseded Pankaj Dubey 1 participant 4 messages Nov 8, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover Remove static mapping of SCU from mach-exynos

This patch series is part of patch series [1], which adds support of SCU device node for Cortex-A9 based Exynos4 SoC. First two patches of the same has been accepted and hence not included them in v2.

This patch series does some cleanup for Exynos4 SoC based boards. We are currently statically mapping SCU SFRs in mach-exynos/exynos.c which can be avoided if map this from device node of SCU.

This patch introduces exynos_scu_enable in firmware.c file, which will be called from exynos_resume, which in turn called by pm.c and suspend.c as firmware_ops.

[1]: https://www.spinics.net/lists/arm-kernel/msg540498.html

This patch series is prepared on Krzysztof's for-next (SHA_ID: b33c7bb9d59c3f4100d4)

I have tested these patches on Exynos4210 based on Origen board for SMP boot. Patchset v1 was tested by Marek Szyprowski on Exynos4412-based Odroid U3 for SMP boot and S2R.

To confirm concern raised by Alim, I intentionally removed SCU device node from exynos4.dtsi and tested on Origen board, I can see code handles this case gracefully without any crash and system boot was fine. Of-course in such case only single core will be able to boot.

Following boot message observed on Origen in case of missing SCU node
-------------

[    0.000864] CPU: Testing write buffer coherency: ok
[    0.001068] CPU0: thread -1, cpu 0, socket 9, mpidr 80000900
[    0.001456] exynos_smp_prepare_cpus failed to map scu_base
[    0.001477] Setting up static identity map for 0x40100000 - 0x40100058
[    1.120003] CPU1: failed to come online
[    1.120059] Brought up 1 CPUs
[    1.120068] SMP: Total of 1 processors activated (48.00 BogoMIPS).
[    1.120076] CPU: All CPU(s) started in SVC mode.

-------------

Changes since v1:
- Address review comments from Krzysztof
- Moved scu_enable from pm.c and suspend.c to single place in firmware.c, as both pm.c and suspend.c needs scu_enable during exynos_resume call.
- Added error handling during scu_enable in platsmp.c.
- Added Reviewed-by tag from Alim.

This patch series is tested on Exynos4210 based Origen board for SMP boot.

Pankaj Dubey (2):
ARM: EXYNOS: Remove static mapping of SCU SFR
ARM: EXYNOS: Remove unused soc_is_exynos{4,5}

 arch/arm/mach-exynos/common.h                |  5 -----
 arch/arm/mach-exynos/exynos.c                | 22 ----------------------
 arch/arm/mach-exynos/firmware.c              | 17 +++++++++++++++++
 arch/arm/mach-exynos/include/mach/map.h      |  2 --
 arch/arm/mach-exynos/platsmp.c               | 20 +++++++++++++-------
 arch/arm/mach-exynos/pm.c                    |  4 +---
 arch/arm/mach-exynos/suspend.c               |  5 -----
 arch/arm/plat-samsung/include/plat/map-s5p.h |  4 ----
 8 files changed, 31 insertions(+), 48 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/2 ARM: EXYNOS: Remove static mapping of SCU SFR

Lets remove static mapping of SCU SFR mainly used in CORTEX-A9 SoC based boards. Instead use mapping from device tree node of SCU.

---
 arch/arm/mach-exynos/exynos.c                | 22 ----------------------
 arch/arm/mach-exynos/firmware.c              | 17 +++++++++++++++++
 arch/arm/mach-exynos/include/mach/map.h      |  2 --
 arch/arm/mach-exynos/platsmp.c               | 20 +++++++++++++-------
 arch/arm/mach-exynos/pm.c                    |  4 +---
 arch/arm/mach-exynos/suspend.c               |  5 -----
 arch/arm/plat-samsung/include/plat/map-s5p.h |  4 ----
 7 files changed, 31 insertions(+), 43 deletions(-)
arch/arm/mach-exynos/exynos.c +0 -22
index 757fc11..fa08ef9 100644
@@ -28,15 +28,6 @@
 
 #include "common.h"
 
-static struct map_desc exynos4_iodesc[] __initdata = {
-	{
-		.virtual	= (unsigned long)S5P_VA_COREPERI_BASE,
-		.pfn		= __phys_to_pfn(EXYNOS4_PA_COREPERI),
-		.length		= SZ_8K,
-		.type		= MT_DEVICE,
-	},
-};
-
 static struct platform_device exynos_cpuidle = {
 	.name              = "exynos_cpuidle",
 #ifdef CONFIG_ARM_EXYNOS_CPUIDLE
@@ -99,17 +90,6 @@ static int __init exynos_fdt_map_chipid(unsigned long node, const char *uname,
 	return 1;
 }
 
-/*
- * exynos_map_io
- *
- * register the standard cpu IO areas
- */
-static void __init exynos_map_io(void)
-{
-	if (soc_is_exynos4())
-		iotable_init(exynos4_iodesc, ARRAY_SIZE(exynos4_iodesc));
-}
-
 static void __init exynos_init_io(void)
 {
 	debug_ll_io_init();
@@ -118,8 +98,6 @@ static void __init exynos_init_io(void)
 
 	/* detect cpu id and rev. */
 	s5p_init_cpu(S5P_VA_CHIPID);
-
-	exynos_map_io();
 }
 
 /*
arch/arm/mach-exynos/firmware.c +17 -0
index fd6da54..f33558e 100644
@@ -18,6 +18,7 @@
 #include <asm/cputype.h>
 #include <asm/firmware.h>
 #include <asm/hardware/cache-l2x0.h>
+#include <asm/smp_scu.h>
 #include <asm/suspend.h>
 
 #include "common.h"
@@ -141,8 +142,24 @@ static int exynos_suspend(void)
 	return cpu_suspend(0, exynos_cpu_suspend);
 }
 
+static void exynos_scu_enable(void)
+{
+	struct device_node *np;
+	void __iomem *scu_base;
+
+	np = of_find_compatible_node(NULL, NULL, "arm,cortex-a9-scu");
+	scu_base = of_iomap(np, 0);
+	of_node_put(np);
+	if (!scu_base) {
+		pr_err("%s failed to map scu_base\n", __func__);
+		return;
+	}
+}
+
 static int exynos_resume(void)
 {
+	exynos_scu_enable();
+
 	writel(0, sysram_ns_base_addr + EXYNOS_BOOT_FLAG);
 
 	return 0;
arch/arm/mach-exynos/include/mach/map.h +0 -2
index 5fb0040..0eef407 100644
@@ -18,6 +18,4 @@
 
 #define EXYNOS_PA_CHIPID		0x10000000
 
-#define EXYNOS4_PA_COREPERI		0x10500000
-
 #endif /* __ASM_ARCH_MAP_H */
arch/arm/mach-exynos/platsmp.c +13 -7
index a5d6841..a0afa4b 100644
@@ -224,11 +224,6 @@ static void write_pen_release(int val)
 	sync_cache_w(&pen_release);
 }
 
-static void __iomem *scu_base_addr(void)
-{
-	return (void __iomem *)(S5P_VA_SCU);
-}
-
 static DEFINE_SPINLOCK(boot_lock);
 
 static void exynos_secondary_init(unsigned int cpu)
@@ -387,14 +382,25 @@ static int exynos_boot_secondary(unsigned int cpu, struct task_struct *idle)
 
 static void __init exynos_smp_prepare_cpus(unsigned int max_cpus)
 {
+	struct device_node *np;
+	void __iomem *scu_base;
 	int i;
 
 	exynos_sysram_init();
 
 	exynos_set_delayed_reset_assertion(true);
 
-	if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9)
-		scu_enable(scu_base_addr());
+	if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9) {
+		np = of_find_compatible_node(NULL, NULL, "arm,cortex-a9-scu");
+		scu_base = of_iomap(np, 0);
+		of_node_put(np);
+		if (!scu_base) {
+			pr_err("%s failed to map scu_base\n", __func__);
+			return;
+		}
+		scu_enable(scu_base);
+		iounmap(scu_base);
+	}
 
 	/*
 	 * Write the address of secondary startup into the
arch/arm/mach-exynos/pm.c +1 -3
index 487295f..b8c5565 100644
@@ -18,6 +18,7 @@
 #include <linux/cpu_pm.h>
 #include <linux/io.h>
 #include <linux/of.h>
+#include <linux/of_address.h>
 #include <linux/soc/samsung/exynos-regs-pmu.h>
 #include <linux/soc/samsung/exynos-pmu.h>
 
@@ -26,8 +27,6 @@
 #include <asm/suspend.h>
 #include <asm/cacheflush.h>
 
-#include <mach/map.h>
-
 #include "common.h"
 
 static inline void __iomem *exynos_boot_vector_addr(void)
@@ -177,7 +176,6 @@ void exynos_enter_aftr(void)
 	cpu_suspend(0, exynos_aftr_finisher);
 
 	if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9) {
-		scu_enable(S5P_VA_SCU);
 		if (call_firmware_op(resume) == -ENOSYS)
 			exynos_cpu_restore_register();
 	}
arch/arm/mach-exynos/suspend.c +0 -5
index 06332f6..6ccd466 100644
@@ -34,8 +34,6 @@
 #include <asm/smp_scu.h>
 #include <asm/suspend.h>
 
-#include <mach/map.h>
-
 #include <plat/pm-common.h>
 
 #include "common.h"
@@ -461,9 +459,6 @@ static void exynos_pm_resume(void)
 	/* For release retention */
 	exynos_pm_release_retention();
 
-	if (cpuid == ARM_CPU_PART_CORTEX_A9)
-		scu_enable(S5P_VA_SCU);
-
 	if (call_firmware_op(resume) == -ENOSYS
 	    && cpuid == ARM_CPU_PART_CORTEX_A9)
 		exynos_cpu_restore_register();
arch/arm/plat-samsung/include/plat/map-s5p.h +0 -4
index 0fe2828..512ed1f 100644
@@ -15,10 +15,6 @@
 
 #define S5P_VA_CHIPID		S3C_ADDR(0x02000000)
 
-#define S5P_VA_COREPERI_BASE	S3C_ADDR(0x02800000)
-#define S5P_VA_COREPERI(x)	(S5P_VA_COREPERI_BASE + (x))
-#define S5P_VA_SCU		S5P_VA_COREPERI(0x0)
-
 #define VA_VIC(x)		(S3C_VA_IRQ + ((x) * 0x10000))
 #define VA_VIC0			VA_VIC(0)
 #define VA_VIC1			VA_VIC(1)
Signature · 1 line
2.7.4
#2 lore raw

PATCH v2 2/2 ARM: EXYNOS: Remove unused soc_is_exynos{4,5}

In reply to Pankaj Dubey

As no more user of soc_is_exynos{4,5} we can safely remove them.

---
 arch/arm/mach-exynos/common.h | 5 -----
 1 file changed, 5 deletions(-)
arch/arm/mach-exynos/common.h +0 -5
index 9424a8a..d19064b 100644
@@ -105,11 +105,6 @@ IS_SAMSUNG_CPU(exynos5800, EXYNOS5800_SOC_ID, EXYNOS5_SOC_MASK)
 # define soc_is_exynos5800()	0
 #endif
 
-#define soc_is_exynos4() (soc_is_exynos4210() || soc_is_exynos4212() || \
-			  soc_is_exynos4412())
-#define soc_is_exynos5() (soc_is_exynos5250() || soc_is_exynos5410() || \
-			  soc_is_exynos5420() || soc_is_exynos5800())
-
 extern u32 cp15_save_diag;
 extern u32 cp15_save_power;
 
Signature · 1 line
2.7.4
#3 lore raw

v2 cover Remove static mapping of SCU from mach-exynos

In reply to Pankaj Dubey

Hi,

Quoted 4 lines · Pankaj Dubey

This patch series is part of patch series [1], which adds support of SCU device node for Cortex-A9 based Exynos4 SoC. First two patches of the same has been accepted and hence not included them in v2.

Quoted 8 lines

This patch series does some cleanup for Exynos4 SoC based boards. We are currently statically mapping SCU SFRs in mach-exynos/exynos.c which can be avoided if map this from device node of SCU.

This patch introduces exynos_scu_enable in firmware.c file, which will be called from exynos_resume, which in turn called by pm.c and suspend.c as firmware_ops.

Please ignore this patchset as just noticed that firmware_ops needs not be present for all boards, in that case exynos_resume ops won't be defined in some of Exynos4 based boards and scu_enable won't be called. I will think about some other approach and submit again.

Sorry for noise.

Thanks,
Pankaj Dubey