Patchwork [U-Boot] powerpc/85xx: fix broken cpu "clock-frequency" property

login
register
mail settings
Submitter Laurentiu TUDOR
Date Oct. 23, 2013, 12:20 p.m.
Message ID <1382530845-14077-1-git-send-email-Laurentiu.Tudor@freescale.com>
Download mbox | patch
Permalink /patch/285686/
State Accepted
Delegated to: York Sun
Headers show

Comments

Laurentiu TUDOR - Oct. 23, 2013, 12:20 p.m.
When indexing freqProcessor[] we use the first
value in the cpu's "reg" property, which on
new e6500 cores IDs the threads.
But freqProcessor[] should be indexed with a
core index so, when fixing "the clock-frequency"
cpu node property, access the freqProcessor[]
with the core index derived from the "reg' property.
If we don't do this, last half of the "cpu" nodes
will have broken "clock-frequency" values.

Signed-off-by: Laurentiu Tudor <Laurentiu.Tudor@freescale.com>
Cc: York Sun <yorksun@freescale.com>
---
Based on: git://git.denx.de/u-boot-mpc85xx.git master

 arch/powerpc/cpu/mpc85xx/fdt.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
York Sun - Nov. 13, 2013, 10:46 p.m.
On Oct 23, 2013, at 5:20 AM, Laurentiu Tudor wrote:

> When indexing freqProcessor[] we use the first
> value in the cpu's "reg" property, which on
> new e6500 cores IDs the threads.
> But freqProcessor[] should be indexed with a
> core index so, when fixing "the clock-frequency"
> cpu node property, access the freqProcessor[]
> with the core index derived from the "reg' property.
> If we don't do this, last half of the "cpu" nodes
> will have broken "clock-frequency" values.
> 
> Signed-off-by: Laurentiu Tudor <Laurentiu.Tudor@freescale.com>
> Cc: York Sun <yorksun@freescale.com>
> ---
> Based on: git://git.denx.de/u-boot-mpc85xx.git master
> 

Applied to u-boot-mpc85xx/master.

York

Patch

diff --git a/arch/powerpc/cpu/mpc85xx/fdt.c b/arch/powerpc/cpu/mpc85xx/fdt.c
index 2ccd9c7..33bc900 100644
--- a/arch/powerpc/cpu/mpc85xx/fdt.c
+++ b/arch/powerpc/cpu/mpc85xx/fdt.c
@@ -586,6 +586,7 @@  void ft_cpu_setup(void *blob, bd_t *bd)
 {
 	int off;
 	int val;
+	int len;
 	sys_info_t sysinfo;
 
 	/* delete crypto node if not on an E-processor */
@@ -615,8 +616,8 @@  void ft_cpu_setup(void *blob, bd_t *bd)
 	get_sys_info(&sysinfo);
 	off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4);
 	while (off != -FDT_ERR_NOTFOUND) {
-		u32 *reg = (u32 *)fdt_getprop(blob, off, "reg", 0);
-		val = cpu_to_fdt32(sysinfo.freq_processor[*reg]);
+		u32 *reg = (u32 *)fdt_getprop(blob, off, "reg", &len);
+		val = cpu_to_fdt32(sysinfo.freq_processor[(*reg) / (len / 4)]);
 		fdt_setprop(blob, off, "clock-frequency", &val, 4);
 		off = fdt_node_offset_by_prop_value(blob, off, "device_type",
 							"cpu", 4);