瀏覽代碼

ARM: EXYNOS: add exynos_get_boot_addr() helper

Add get_cpu_boot_addr() firmware operation and then
exynos_get_boot_addr() helper.

This is a preparation for adding coupled cpuidle support
for Exynos3250 SoC.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Kukjin Kim <kgene@kernel.org>
Bartlomiej Zolnierkiewicz 10 年之前
父節點
當前提交
1225ad7286
共有 3 個文件被更改,包括 46 次插入0 次删除
  1. 4 0
      arch/arm/include/asm/firmware.h
  2. 17 0
      arch/arm/mach-exynos/firmware.c
  3. 25 0
      arch/arm/mach-exynos/platsmp.c

+ 4 - 0
arch/arm/include/asm/firmware.h

@@ -33,6 +33,10 @@ struct firmware_ops {
 	 * Sets boot address of specified physical CPU
 	 * Sets boot address of specified physical CPU
 	 */
 	 */
 	int (*set_cpu_boot_addr)(int cpu, unsigned long boot_addr);
 	int (*set_cpu_boot_addr)(int cpu, unsigned long boot_addr);
+	/*
+	 * Gets boot address of specified physical CPU
+	 */
+	int (*get_cpu_boot_addr)(int cpu, unsigned long *boot_addr);
 	/*
 	/*
 	 * Boots specified physical CPU
 	 * Boots specified physical CPU
 	 */
 	 */

+ 17 - 0
arch/arm/mach-exynos/firmware.c

@@ -104,6 +104,22 @@ static int exynos_set_cpu_boot_addr(int cpu, unsigned long boot_addr)
 	return 0;
 	return 0;
 }
 }
 
 
+static int exynos_get_cpu_boot_addr(int cpu, unsigned long *boot_addr)
+{
+	void __iomem *boot_reg;
+
+	if (!sysram_ns_base_addr)
+		return -ENODEV;
+
+	boot_reg = sysram_ns_base_addr + 0x1c;
+
+	if (soc_is_exynos4412())
+		boot_reg += 4 * cpu;
+
+	*boot_addr = __raw_readl(boot_reg);
+	return 0;
+}
+
 static int exynos_cpu_suspend(unsigned long arg)
 static int exynos_cpu_suspend(unsigned long arg)
 {
 {
 	flush_cache_all();
 	flush_cache_all();
@@ -138,6 +154,7 @@ static int exynos_resume(void)
 static const struct firmware_ops exynos_firmware_ops = {
 static const struct firmware_ops exynos_firmware_ops = {
 	.do_idle		= IS_ENABLED(CONFIG_EXYNOS_CPU_SUSPEND) ? exynos_do_idle : NULL,
 	.do_idle		= IS_ENABLED(CONFIG_EXYNOS_CPU_SUSPEND) ? exynos_do_idle : NULL,
 	.set_cpu_boot_addr	= exynos_set_cpu_boot_addr,
 	.set_cpu_boot_addr	= exynos_set_cpu_boot_addr,
+	.get_cpu_boot_addr	= exynos_get_cpu_boot_addr,
 	.cpu_boot		= exynos_cpu_boot,
 	.cpu_boot		= exynos_cpu_boot,
 	.suspend		= IS_ENABLED(CONFIG_PM_SLEEP) ? exynos_suspend : NULL,
 	.suspend		= IS_ENABLED(CONFIG_PM_SLEEP) ? exynos_suspend : NULL,
 	.resume			= IS_ENABLED(CONFIG_EXYNOS_CPU_SUSPEND) ? exynos_resume : NULL,
 	.resume			= IS_ENABLED(CONFIG_EXYNOS_CPU_SUSPEND) ? exynos_resume : NULL,

+ 25 - 0
arch/arm/mach-exynos/platsmp.c

@@ -272,6 +272,31 @@ fail:
 	return ret;
 	return ret;
 }
 }
 
 
+static int exynos_get_boot_addr(u32 core_id, unsigned long *boot_addr)
+{
+	int ret;
+
+	/*
+	 * Try to get boot address using firmware first
+	 * and fall back to boot register if it fails.
+	 */
+	ret = call_firmware_op(get_cpu_boot_addr, core_id, boot_addr);
+	if (ret && ret != -ENOSYS)
+		goto fail;
+	if (ret == -ENOSYS) {
+		void __iomem *boot_reg = cpu_boot_reg(core_id);
+
+		if (IS_ERR(boot_reg)) {
+			ret = PTR_ERR(boot_reg);
+			goto fail;
+		}
+		*boot_addr = __raw_readl(boot_reg);
+		ret = 0;
+	}
+fail:
+	return ret;
+}
+
 static int exynos_boot_secondary(unsigned int cpu, struct task_struct *idle)
 static int exynos_boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
 {
 	unsigned long timeout;
 	unsigned long timeout;