[U-Boot] [PATCH v2 3/9] ARMv8/fsl-lsch3: Refactor spin-table code

Arnab Basu arnab_basu at rocketmail.com
Mon Jan 12 21:55:27 CET 2015


This creates the function cpu_update_dt for ARMv8 which currently patches
the cpu node in the device table and sets enable-method to spin-table.

Signed-off-by: Arnab Basu <arnab_basu at rocketmail.com>
Cc: Bhupesh Sharma <bhupesh.sharma at freescale.com>
Cc: York Sun <yorksun at freescale.com>
---
 arch/arm/cpu/armv8/Makefile                      |  1 +
 arch/arm/cpu/armv8/{fsl-lsch3/fdt.c => cpu-dt.c} | 32 +++++++++-------
 arch/arm/cpu/armv8/fsl-lsch3/fdt.c               | 48 ++++++++----------------
 3 files changed, 36 insertions(+), 45 deletions(-)
 copy arch/arm/cpu/armv8/{fsl-lsch3/fdt.c => cpu-dt.c} (68%)

diff --git a/arch/arm/cpu/armv8/Makefile b/arch/arm/cpu/armv8/Makefile
index 0c10223..74c32b2 100644
--- a/arch/arm/cpu/armv8/Makefile
+++ b/arch/arm/cpu/armv8/Makefile
@@ -14,5 +14,6 @@ obj-y	+= exceptions.o
 obj-y	+= cache.o
 obj-y	+= tlb.o
 obj-y	+= transition.o
+obj-y	+= cpu-dt.o
 
 obj-$(CONFIG_FSL_LSCH3) += fsl-lsch3/
diff --git a/arch/arm/cpu/armv8/fsl-lsch3/fdt.c b/arch/arm/cpu/armv8/cpu-dt.c
similarity index 68%
copy from arch/arm/cpu/armv8/fsl-lsch3/fdt.c
copy to arch/arm/cpu/armv8/cpu-dt.c
index e392eb9..8833e6a 100644
--- a/arch/arm/cpu/armv8/fsl-lsch3/fdt.c
+++ b/arch/arm/cpu/armv8/cpu-dt.c
@@ -7,17 +7,24 @@
 #include <common.h>
 #include <libfdt.h>
 #include <fdt_support.h>
-#include "mp.h"
 
 #ifdef CONFIG_MP
-void ft_fixup_cpu(void *blob)
+
+__weak u64 arch_get_release_addr(u64 cpu_id)
+{
+	return 0;
+}
+
+__weak void arch_spin_table_reserve_mem(void *fdt)
+{
+}
+
+static void cpu_update_dt_spin_table(void *blob)
 {
 	int off;
-	__maybe_unused u64 spin_tbl_addr = (u64)get_spin_tbl_addr();
-	fdt32_t *reg;
+	__maybe_unused u64 val;
 	int addr_cells;
-	u64 val;
-	size_t *boot_code_size = &(__secondary_boot_code_size);
+	__maybe_unused fdt32_t *reg;
 
 	off = fdt_path_offset(blob, "/cpus");
 	if (off < 0) {
@@ -30,9 +37,8 @@ void ft_fixup_cpu(void *blob)
 	while (off != -FDT_ERR_NOTFOUND) {
 		reg = (fdt32_t *)fdt_getprop(blob, off, "reg", 0);
 		if (reg) {
-			val = spin_tbl_addr;
-			val += id_to_core(of_read_number(reg, addr_cells))
-				* SPIN_TABLE_ELEM_SIZE;
+			val = arch_get_release_addr(
+					of_read_number(reg, addr_cells));
 			val = cpu_to_fdt64(val);
 			fdt_setprop_string(blob, off, "enable-method",
 					   "spin-table");
@@ -45,14 +51,14 @@ void ft_fixup_cpu(void *blob)
 						    "cpu", 4);
 	}
 
-	fdt_add_mem_rsv(blob, (uintptr_t)&secondary_boot_code,
-			*boot_code_size);
+	arch_spin_table_reserve_mem(blob);
 }
 #endif
 
-void ft_cpu_setup(void *blob, bd_t *bd)
+int cpu_update_dt(void *fdt)
 {
 #ifdef CONFIG_MP
-	ft_fixup_cpu(blob);
+	cpu_update_dt_spin_table(fdt);
 #endif
+	return 0;
 }
diff --git a/arch/arm/cpu/armv8/fsl-lsch3/fdt.c b/arch/arm/cpu/armv8/fsl-lsch3/fdt.c
index e392eb9..bb35393 100644
--- a/arch/arm/cpu/armv8/fsl-lsch3/fdt.c
+++ b/arch/arm/cpu/armv8/fsl-lsch3/fdt.c
@@ -10,44 +10,28 @@
 #include "mp.h"
 
 #ifdef CONFIG_MP
-void ft_fixup_cpu(void *blob)
+u64 arch_get_release_addr(u64 cpu_id)
 {
-	int off;
-	__maybe_unused u64 spin_tbl_addr = (u64)get_spin_tbl_addr();
-	fdt32_t *reg;
-	int addr_cells;
 	u64 val;
+
+	val = (u64)get_spin_tbl_addr();
+	val += id_to_core(cpu_id) * SPIN_TABLE_ELEM_SIZE;
+
+	return val;
+}
+
+void arch_spin_table_reserve_mem(void *fdt)
+{
 	size_t *boot_code_size = &(__secondary_boot_code_size);
 
-	off = fdt_path_offset(blob, "/cpus");
-	if (off < 0) {
-		puts("couldn't find /cpus node\n");
-		return;
-	}
-	of_bus_default_count_cells(blob, off, &addr_cells, NULL);
-
-	off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4);
-	while (off != -FDT_ERR_NOTFOUND) {
-		reg = (fdt32_t *)fdt_getprop(blob, off, "reg", 0);
-		if (reg) {
-			val = spin_tbl_addr;
-			val += id_to_core(of_read_number(reg, addr_cells))
-				* SPIN_TABLE_ELEM_SIZE;
-			val = cpu_to_fdt64(val);
-			fdt_setprop_string(blob, off, "enable-method",
-					   "spin-table");
-			fdt_setprop(blob, off, "cpu-release-addr",
-				    &val, sizeof(val));
-		} else {
-			puts("Warning: found cpu node without reg property\n");
-		}
-		off = fdt_node_offset_by_prop_value(blob, off, "device_type",
-						    "cpu", 4);
-	}
-
-	fdt_add_mem_rsv(blob, (uintptr_t)&secondary_boot_code,
+	fdt_add_mem_rsv(fdt, (uintptr_t)&secondary_boot_code,
 			*boot_code_size);
 }
+
+static void ft_fixup_cpu(void *blob)
+{
+}
+
 #endif
 
 void ft_cpu_setup(void *blob, bd_t *bd)
-- 
1.9.1



More information about the U-Boot mailing list