[U-Boot] [PATCH 3/8] ARMv8/fsl-lsch3: Refactor spin-table code
Arnab Basu
arnab.basu at freescale.com
Wed Aug 27 22:29:56 CEST 2014
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 freescale.com>
Reviewed-by: 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} | 37 ++++++++++--------
arch/arm/cpu/armv8/fsl-lsch3/fdt.c | 46 ++++++++--------------
3 files changed, 38 insertions(+), 46 deletions(-)
copy arch/arm/cpu/armv8/{fsl-lsch3/fdt.c => cpu-dt.c} (62%)
diff --git a/arch/arm/cpu/armv8/Makefile b/arch/arm/cpu/armv8/Makefile
index 7d93f59..4f0ea87 100644
--- a/arch/arm/cpu/armv8/Makefile
+++ b/arch/arm/cpu/armv8/Makefile
@@ -14,3 +14,4 @@ obj-y += exceptions.o
obj-y += cache.o
obj-y += tlb.o
obj-y += transition.o
+obj-y += cpu-dt.o
diff --git a/arch/arm/cpu/armv8/fsl-lsch3/fdt.c b/arch/arm/cpu/armv8/cpu-dt.c
similarity index 62%
copy from arch/arm/cpu/armv8/fsl-lsch3/fdt.c
copy to arch/arm/cpu/armv8/cpu-dt.c
index 2dbcdcb..9792bc0 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_node_offset_by_prop_value(blob, -1, "device_type", "cpus", 4);
of_bus_default_count_cells(blob, off, &addr_cells, NULL);
@@ -26,31 +33,29 @@ 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;
-#ifndef CONFIG_FSL_SMP_RELEASE_ALL
- val += id_to_core(of_read_number(reg, addr_cells))
- * SPIN_TABLE_ELEM_SIZE;
-#endif
+ 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");
fdt_setprop(blob, off, "cpu-release-addr",
&val, sizeof(val));
} else {
- puts("cpu NULL\n");
+ puts("Unable to read 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,
- *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 2dbcdcb..bb35393 100644
--- a/arch/arm/cpu/armv8/fsl-lsch3/fdt.c
+++ b/arch/arm/cpu/armv8/fsl-lsch3/fdt.c
@@ -10,42 +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_node_offset_by_prop_value(blob, -1, "device_type", "cpus", 4);
- 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;
-#ifndef CONFIG_FSL_SMP_RELEASE_ALL
- val += id_to_core(of_read_number(reg, addr_cells))
- * SPIN_TABLE_ELEM_SIZE;
-#endif
- 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("cpu NULL\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.7.7.4
More information about the U-Boot
mailing list