[U-Boot] [PATCH 1/2] armv8: ls1043a: modify the detecting way to cover all variants

There are many variants for ls1043a. Modify the detecting way to make that the below fixup apply to all variants of ls1043a. - Fix GIC offset for rev1.1 - Fix msi node for rev1.1 - erratum_a010151
Signed-off-by: Wenbin Song wenbin.song@nxp.com --- arch/arm/cpu/armv8/fsl-layerscape/fdt.c | 4 ++-- arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S | 5 ++--- arch/arm/include/asm/arch-fsl-layerscape/soc.h | 3 +++ drivers/usb/common/fsl-errata.c | 7 +++++-- 4 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c index d6794708c9..33f3e64848 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c +++ b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c @@ -147,7 +147,7 @@ static void fdt_fixup_gic(void *blob)
val = gur_in32(&gur->svr);
- if (SVR_SOC_VER(val) != SVR_LS1043A) { + if (!IS_SVR_DEV(val, SVR_DEV_LS1043A)) { align_64k = 1; } else if (SVR_REV(val) != REV1_0) { val = scfg_in32(&scfg->gic_align) & (0x01 << GIC_ADDR_BIT); @@ -329,7 +329,7 @@ static void fdt_fixup_msi(void *blob)
rev = gur_in32(&gur->svr);
- if (SVR_SOC_VER(rev) != SVR_LS1043A) + if (!IS_SVR_DEV(rev, SVR_DEV_LS1043A)) return;
rev = SVR_REV(rev); diff --git a/arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S b/arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S index 28a31b21a9..666e842b99 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S +++ b/arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S @@ -37,9 +37,8 @@ ENTRY(get_gic_offset) ldr x2, =DCFG_CCSR_SVR ldr w2, [x2] rev w2, w2 - mov w3, w2 - ands w3, w3, #SVR_WO_E << 8 - mov w4, #SVR_LS1043A << 8 + lsr w3, w2, #16 + ldr w4, =SVR_DEV_LS1043A cmp w3, w4 b.ne 1f ands w2, w2, #0xff diff --git a/arch/arm/include/asm/arch-fsl-layerscape/soc.h b/arch/arm/include/asm/arch-fsl-layerscape/soc.h index 08a42b9c9e..7c189530c1 100644 --- a/arch/arm/include/asm/arch-fsl-layerscape/soc.h +++ b/arch/arm/include/asm/arch-fsl-layerscape/soc.h @@ -73,6 +73,7 @@ struct cpu_type { #define SVR_LS2041A 0x870914
#define SVR_DEV_LS2080A 0x8701 +#define SVR_DEV_LS1043A 0x8792
#define SVR_MAJ(svr) (((svr) >> 4) & 0xf) #define SVR_MIN(svr) (((svr) >> 0) & 0xf) @@ -81,6 +82,8 @@ struct cpu_type { #define IS_E_PROCESSOR(svr) (!((svr >> 8) & 0x1)) #define IS_SVR_REV(svr, maj, min) \ ((SVR_MAJ(svr) == (maj)) && (SVR_MIN(svr) == (min))) +#define IS_SVR_DEV(svr, dev) \ + (((svr) >> 16) == (dev))
/* ahci port register default value */ #define AHCI_PORT_PHY_1_CFG 0xa003fffe diff --git a/drivers/usb/common/fsl-errata.c b/drivers/usb/common/fsl-errata.c index 823beb32f6..c20c9a3567 100644 --- a/drivers/usb/common/fsl-errata.c +++ b/drivers/usb/common/fsl-errata.c @@ -198,6 +198,11 @@ bool has_erratum_a010151(void) u32 svr = get_svr(); u32 soc = SVR_SOC_VER(svr);
+#ifdef CONFIG_ARM64 + if (IS_SVR_DEV(svr, SVR_DEV_LS1043A)) + return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 1, 1); +#endif + switch (soc) { #ifdef CONFIG_ARM64 case SVR_LS2080A: @@ -209,8 +214,6 @@ bool has_erratum_a010151(void) case SVR_LS1046A: case SVR_LS1012A: return IS_SVR_REV(svr, 1, 0); - case SVR_LS1043A: - return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 1, 1); #endif #ifdef CONFIG_ARCH_LS1021A case SOC_VER_LS1020:

Using "cpu_pos_mask()" function to detect the real online cpus, and discard the needless cpu nodes on kernel dft.
Signed-off-by: Wenbin Song wenbin.song@nxp.com --- arch/arm/cpu/armv8/fsl-layerscape/Kconfig | 4 ++++ arch/arm/cpu/armv8/fsl-layerscape/fdt.c | 32 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig index 47145a2432..971a98c6cc 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig +++ b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig @@ -176,6 +176,10 @@ config HAS_FEATURE_ENHANCED_MSI bool default y if ARCH_LS1043A
+config DISCARD_OFFLINE_CPU_NODES + bool + default y if ARCH_LS1043A + menu "Layerscape PPA" config FSL_LS_PPA bool "FSL Layerscape PPA firmware support" diff --git a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c index 33f3e64848..241f0abe18 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c +++ b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c @@ -44,6 +44,38 @@ void ft_fixup_cpu(void *blob) int addr_cells; u64 val, core_id; size_t *boot_code_size = &(__secondary_boot_code_size); + +#if defined(CONFIG_DISCARD_OFFLINE_CPU_NODES) + u32 mask = cpu_pos_mask(); + int off_prev = -1; + int pos; + + off = fdt_path_offset(blob, "/cpus"); + if (off < 0) { + puts("couldn't find /cpus node\n"); + return; + } + + fdt_support_default_count_cells(blob, off, &addr_cells, NULL); + + off = fdt_node_offset_by_prop_value(blob, off_prev, "device_type", + "cpu", 4); + while (off != -FDT_ERR_NOTFOUND) { + reg = (fdt32_t *)fdt_getprop(blob, off, "reg", 0); + if (reg) { + core_id = fdt_read_number(reg, addr_cells); + pos = ((core_id & 0xff00) >> 5) + (core_id & 0xff); + if (!test_bit(pos, &mask)) { + fdt_del_node(blob, off); + off = off_prev; + } + } + off_prev = off; + off = fdt_node_offset_by_prop_value(blob, off_prev, + "device_type", "cpu", 4); + } +#endif + #if defined(CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT) && \ defined(CONFIG_SEC_FIRMWARE_ARMV8_PSCI) int node;

-----Original Message----- From: Wenbin song [mailto:wenbin.song@nxp.com] Sent: Thursday, November 30, 2017 8:27 AM To: York Sun york.sun@nxp.com; Prabhakar Kushwaha prabhakar.kushwaha@nxp.com; Ran Wang ran.wang_1@nxp.com; Mingkai Hu mingkai.hu@nxp.com; u-boot@lists.denx.de Cc: Wenbin Song wenbin.song@nxp.com Subject: [PATCH 2/2] armv8: ls1043a: Discard the needless cpu nodes
Using "cpu_pos_mask()" function to detect the real online cpus, and discard the needless cpu nodes on kernel dft.
Signed-off-by: Wenbin Song wenbin.song@nxp.com
arch/arm/cpu/armv8/fsl-layerscape/Kconfig | 4 ++++ arch/arm/cpu/armv8/fsl-layerscape/fdt.c | 32 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig index 47145a2432..971a98c6cc 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig +++ b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig @@ -176,6 +176,10 @@ config HAS_FEATURE_ENHANCED_MSI bool default y if ARCH_LS1043A
+config DISCARD_OFFLINE_CPU_NODES
- bool
- default y if ARCH_LS1043A
As per understanding this feature is for taking care of SoC personalities with reduced cores.
Why a new config is required? Why cannot this be taken care at run time by reading SVR.
-pk

Hi Prabhakar,
In my opinion, this is a common feature for all Layerscapes. As I know, all chips belonged to Layerscape have the capacity to disable some cores, just like ls1043a /ls1023a. If we will support another variant in the future, for example: ls1046a/ls1026a, just configure it rather than modify the codes. Am I correct?
Best Regards Wenbin Song
-----Original Message----- From: Prabhakar Kushwaha Sent: Thursday, November 30, 2017 12:56 PM To: Wenbin Song wenbin.song@nxp.com; York Sun york.sun@nxp.com; Ran Wang ran.wang_1@nxp.com; Mingkai Hu mingkai.hu@nxp.com; u-boot@lists.denx.de Cc: Wenbin Song wenbin.song@nxp.com Subject: RE: [PATCH 2/2] armv8: ls1043a: Discard the needless cpu nodes
-----Original Message----- From: Wenbin song [mailto:wenbin.song@nxp.com] Sent: Thursday, November 30, 2017 8:27 AM To: York Sun york.sun@nxp.com; Prabhakar Kushwaha prabhakar.kushwaha@nxp.com; Ran Wang ran.wang_1@nxp.com; Mingkai Hu mingkai.hu@nxp.com; u-boot@lists.denx.de Cc: Wenbin Song wenbin.song@nxp.com Subject: [PATCH 2/2] armv8: ls1043a: Discard the needless cpu nodes
Using "cpu_pos_mask()" function to detect the real online cpus, and discard the needless cpu nodes on kernel dft.
Signed-off-by: Wenbin Song wenbin.song@nxp.com
arch/arm/cpu/armv8/fsl-layerscape/Kconfig | 4 ++++ arch/arm/cpu/armv8/fsl-layerscape/fdt.c | 32 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig index 47145a2432..971a98c6cc 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig +++ b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig @@ -176,6 +176,10 @@ config HAS_FEATURE_ENHANCED_MSI bool default y if ARCH_LS1043A
+config DISCARD_OFFLINE_CPU_NODES
- bool
- default y if ARCH_LS1043A
As per understanding this feature is for taking care of SoC personalities with reduced cores.
Why a new config is required? Why cannot this be taken care at run time by reading SVR.
-pk

On 11/29/2017 07:16 PM, Wenbin song wrote:
Using "cpu_pos_mask()" function to detect the real online cpus, and discard the needless cpu nodes on kernel dft.
Signed-off-by: Wenbin Song wenbin.song@nxp.com
arch/arm/cpu/armv8/fsl-layerscape/Kconfig | 4 ++++ arch/arm/cpu/armv8/fsl-layerscape/fdt.c | 32 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig index 47145a2432..971a98c6cc 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig +++ b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig @@ -176,6 +176,10 @@ config HAS_FEATURE_ENHANCED_MSI bool default y if ARCH_LS1043A
+config DISCARD_OFFLINE_CPU_NODES
- bool
- default y if ARCH_LS1043A
menu "Layerscape PPA" config FSL_LS_PPA bool "FSL Layerscape PPA firmware support" diff --git a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c index 33f3e64848..241f0abe18 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c +++ b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c @@ -44,6 +44,38 @@ void ft_fixup_cpu(void *blob) int addr_cells; u64 val, core_id; size_t *boot_code_size = &(__secondary_boot_code_size);
+#if defined(CONFIG_DISCARD_OFFLINE_CPU_NODES)
- u32 mask = cpu_pos_mask();
- int off_prev = -1;
- int pos;
- off = fdt_path_offset(blob, "/cpus");
- if (off < 0) {
puts("couldn't find /cpus node\n");
return;
- }
- fdt_support_default_count_cells(blob, off, &addr_cells, NULL);
- off = fdt_node_offset_by_prop_value(blob, off_prev, "device_type",
"cpu", 4);
- while (off != -FDT_ERR_NOTFOUND) {
reg = (fdt32_t *)fdt_getprop(blob, off, "reg", 0);
if (reg) {
core_id = fdt_read_number(reg, addr_cells);
pos = ((core_id & 0xff00) >> 5) + (core_id & 0xff);
if (!test_bit(pos, &mask)) {
fdt_del_node(blob, off);
off = off_prev;
}
}
off_prev = off;
off = fdt_node_offset_by_prop_value(blob, off_prev,
"device_type", "cpu", 4);
- }
+#endif
#if defined(CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT) && \ defined(CONFIG_SEC_FIRMWARE_ARMV8_PSCI) int node;
Wenbin,
Using topology registers to identify the existence of cores is correct. Do you need the new config option to gate the code? It is a correct operation for all SoCs, isn't it?
York

Hi York, Yes, you are right. I have tested it on others SoCs (LS1043a/LS1023a, LS2088a/LS2048a). It works fine.
So, I will remove the config and the #if condition.
Thank you and Prabhakar for the advice.
Best Regards Wenbin Song
-----Original Message----- From: York Sun Sent: Friday, December 01, 2017 1:41 AM To: Wenbin Song wenbin.song@nxp.com; Prabhakar Kushwaha prabhakar.kushwaha@nxp.com; Ran Wang ran.wang_1@nxp.com; Mingkai Hu mingkai.hu@nxp.com; u-boot@lists.denx.de Subject: Re: [PATCH 2/2] armv8: ls1043a: Discard the needless cpu nodes
On 11/29/2017 07:16 PM, Wenbin song wrote:
Using "cpu_pos_mask()" function to detect the real online cpus, and discard the needless cpu nodes on kernel dft.
Signed-off-by: Wenbin Song wenbin.song@nxp.com
arch/arm/cpu/armv8/fsl-layerscape/Kconfig | 4 ++++ arch/arm/cpu/armv8/fsl-layerscape/fdt.c | 32 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig index 47145a2432..971a98c6cc 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig +++ b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig @@ -176,6 +176,10 @@ config HAS_FEATURE_ENHANCED_MSI bool default y if ARCH_LS1043A
+config DISCARD_OFFLINE_CPU_NODES
- bool
- default y if ARCH_LS1043A
menu "Layerscape PPA" config FSL_LS_PPA bool "FSL Layerscape PPA firmware support" diff --git a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c index 33f3e64848..241f0abe18 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c +++ b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c @@ -44,6 +44,38 @@ void ft_fixup_cpu(void *blob) int addr_cells; u64 val, core_id; size_t *boot_code_size = &(__secondary_boot_code_size);
+#if defined(CONFIG_DISCARD_OFFLINE_CPU_NODES)
- u32 mask = cpu_pos_mask();
- int off_prev = -1;
- int pos;
- off = fdt_path_offset(blob, "/cpus");
- if (off < 0) {
puts("couldn't find /cpus node\n");
return;
- }
- fdt_support_default_count_cells(blob, off, &addr_cells, NULL);
- off = fdt_node_offset_by_prop_value(blob, off_prev, "device_type",
"cpu", 4);
- while (off != -FDT_ERR_NOTFOUND) {
reg = (fdt32_t *)fdt_getprop(blob, off, "reg", 0);
if (reg) {
core_id = fdt_read_number(reg, addr_cells);
pos = ((core_id & 0xff00) >> 5) + (core_id & 0xff);
if (!test_bit(pos, &mask)) {
fdt_del_node(blob, off);
off = off_prev;
}
}
off_prev = off;
off = fdt_node_offset_by_prop_value(blob, off_prev,
"device_type", "cpu", 4);
- }
+#endif
#if defined(CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT) && \ defined(CONFIG_SEC_FIRMWARE_ARMV8_PSCI) int node;
Wenbin,
Using topology registers to identify the existence of cores is correct. Do you need the new config option to gate the code? It is a correct operation for all SoCs, isn't it?
York
participants (4)
-
Prabhakar Kushwaha
-
Wenbin Song
-
Wenbin song
-
York Sun