QCN3018: Fix num present cpus
For QCN3018, as the device tree states that there are 4 cpus,
the kernel thinks it has 4 present cpus (2 offline), it shows
2 cpus in places such as cpufreq. To avoid this, dynamically
patch the fdt and remove core2 and core3
Change-Id: Ie11dfd35ed9d9983252884b0f5aa08c993150ed5
Signed-off-by: Sumit Gaur <gaur@codeaurora.org>
diff --git a/board/qca/arm/common/cmd_bootqca.c b/board/qca/arm/common/cmd_bootqca.c
index e35a0fb..4149384 100644
--- a/board/qca/arm/common/cmd_bootqca.c
+++ b/board/qca/arm/common/cmd_bootqca.c
@@ -415,35 +415,6 @@
#endif
#endif
-static int set_num_cpus(void)
-{
- char *arg;
- char *p;
- char bootarg_buf[50];
- int numcpus;
-
- numcpus = smem_read_cpu_count();
-
- if (numcpus != -1) { /* QCN3018 */
- /* check if nosmp is set in bootargs */
- arg = getenv("bootargs");
- if (arg) {
- p = strstr(arg, "nosmp");
- if (p) {
- if ((p[strlen("nosmp")] == ' ')
- || (p[strlen("nosmp")] == '\0'))
- if ((p == arg) || (*(p - 1) == ' '))
- return 0;
- }
- }
- snprintf(bootarg_buf, sizeof(bootarg_buf),
- "setenv bootargs ${booargs} maxcpus=%d\n",
- numcpus);
-
- return run_command(bootarg_buf, 0);
- }
- return 0;
-}
static int do_boot_signedimg(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
{
@@ -465,9 +436,6 @@
if (argc == 2 && strncmp(argv[1], "debug", 5) == 0)
debug = 1;
- if ((ret = set_num_cpus()))
- return ret;
-
if ((ret = set_fs_bootargs(&ipq_fs_on_nand)))
return ret;
@@ -715,9 +683,6 @@
if (argc == 2 && strncmp(argv[1], "debug", 5) == 0)
debug = 1;
- if ((ret = set_num_cpus()))
- return ret;
-
if ((ret = set_fs_bootargs(&ipq_fs_on_nand)))
return ret;
diff --git a/board/qca/arm/common/fdt_fixup.c b/board/qca/arm/common/fdt_fixup.c
index 13703b0..9538acd 100644
--- a/board/qca/arm/common/fdt_fixup.c
+++ b/board/qca/arm/common/fdt_fixup.c
@@ -496,6 +496,10 @@
return;
}
+__weak void fdt_fixup_cpus_node(void * blob)
+{
+ return;
+}
__weak void fdt_fixup_set_dload_warm_reset(void *blob)
{
return;
@@ -601,6 +605,7 @@
fdt_fixup_auto_restart(blob);
fdt_fixup_sd_ldo_gpios_toggle(blob);
fdt_fixup_cpr(blob);
+ fdt_fixup_cpus_node(blob);
fdt_low_memory_fixup(blob);
s = getenv("dload_warm_reset");
if (s)
diff --git a/board/qca/arm/ipq40xx/ipq40xx.c b/board/qca/arm/ipq40xx/ipq40xx.c
index 4a38de6..0853211 100644
--- a/board/qca/arm/ipq40xx/ipq40xx.c
+++ b/board/qca/arm/ipq40xx/ipq40xx.c
@@ -708,3 +708,53 @@
}
return -1;
}
+
+void fdt_fixup_cpus_node(void *blob)
+{
+ int numcpus;
+ int nodeoff;
+
+ numcpus = smem_read_cpu_count();
+
+ if (numcpus == 2)
+ {
+ nodeoff = fdt_path_offset(blob, "/cpus/cpu@2");
+
+ if (nodeoff >= 0)
+ fdt_del_node((void *)blob, nodeoff);
+ else
+ printf("fixup_cpus_node: can't disable cpu2\n");
+
+ nodeoff = fdt_path_offset(blob, "/cpus/cpu@3");
+
+ if (nodeoff >= 0)
+ fdt_del_node((void *)blob, nodeoff);
+ else
+ printf("fixup_cpus_node: can't disable cpu3\n");
+ }
+
+ else if (numcpus == 1)
+ {
+ nodeoff = fdt_path_offset(blob, "/cpus/cpu@1");
+
+ if (nodeoff >= 0)
+ fdt_del_node((void *)blob, nodeoff);
+ else
+ printf("fixup_cpus_node: can't disable cpu1\n");
+
+ nodeoff = fdt_path_offset(blob, "/cpus/cpu@2");
+
+ if (nodeoff >= 0)
+ fdt_del_node((void *)blob, nodeoff);
+ else
+ printf("fixup_cpus_node: can't disable cpu2\n");
+
+ nodeoff = fdt_path_offset(blob, "/cpus/cpu@3");
+
+ if (nodeoff >= 0)
+ fdt_del_node((void *)blob, nodeoff);
+ else
+ printf("fixup_cpus_node: can't disable cpu3\n");
+ }
+ return;
+}