Message ID | 20200519233144.2426-1-agust@denx.de |
---|---|
State | Accepted |
Commit | 74e8fb03bdafd096bcfaa36268376874dfb5c7d4 |
Headers | show |
Series | cpu: imx8: use intended cpu-thermal device when getting temp value | expand |
> Subject: [PATCH] cpu: imx8: use intended cpu-thermal device when getting > temp value > > This fixes getting DT alert and critical pdata values in imx_scu_thermal driver. > On i.MX8QXP using not initialized alert pdata value resulted in boot hang and > endless loop outputting: > CPU Temperature (47200C) has beyond alert (0C), close to critical (0C) > waiting... > > While at it, preset CPU type values once to avoid multiple calls of > device_is_compatible() for same property. > > Fixes: 3ee6ea443eb4 ("cpu: imx_cpu: Print the CPU temperature for iMX8QM > A72") > Signed-off-by: Anatolij Gustschin <agust at denx.de> > --- > This one supersedes the older patch here: > > https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatchw > ork.ozlabs.org%2Fproject%2Fuboot%2Fpatch%2F20200516203420.24409-2-a > gust%40denx.de&data=02%7C01%7Cpeng.fan%40nxp.com%7C3a05de6 > b676d4479832a08d7fc4ccc4d%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C > 0%7C0%7C637255279084654887&sdata=W7kv5XqeSrcxcOHNgE0TgcR8 > POPyt3VR4EsWszlFXLI%3D&reserved=0 > > drivers/cpu/imx8_cpu.c | 50 +++++++++++++++++++++--------------------- > 1 file changed, 25 insertions(+), 25 deletions(-) > > diff --git a/drivers/cpu/imx8_cpu.c b/drivers/cpu/imx8_cpu.c index > 896e1ac776..adc4919d9e 100644 > --- a/drivers/cpu/imx8_cpu.c > +++ b/drivers/cpu/imx8_cpu.c > @@ -18,6 +18,7 @@ struct cpu_imx_platdata { > const char *name; > const char *rev; > const char *type; > + u32 cpu_rsrc; > u32 cpurev; > u32 freq_mhz; > u32 mpidr; > @@ -50,16 +51,23 @@ const char *get_imx8_rev(u32 rev) > } > } > > -const char *get_core_name(struct udevice *dev) > +static void set_core_data(struct udevice *dev) > { > - if (device_is_compatible(dev, "arm,cortex-a35")) > - return "A35"; > - else if (device_is_compatible(dev, "arm,cortex-a53")) > - return "A53"; > - else if (device_is_compatible(dev, "arm,cortex-a72")) > - return "A72"; > - else > - return "?"; > + struct cpu_imx_platdata *plat = dev_get_platdata(dev); > + > + if (device_is_compatible(dev, "arm,cortex-a35")) { > + plat->cpu_rsrc = SC_R_A35; > + plat->name = "A35"; > + } else if (device_is_compatible(dev, "arm,cortex-a53")) { > + plat->cpu_rsrc = SC_R_A53; > + plat->name = "A53"; > + } else if (device_is_compatible(dev, "arm,cortex-a72")) { > + plat->cpu_rsrc = SC_R_A72; > + plat->name = "A72"; > + } else { > + plat->cpu_rsrc = SC_R_A53; > + plat->name = "?"; > + } > } > > #if IS_ENABLED(CONFIG_IMX_SCU_THERMAL) > @@ -67,12 +75,12 @@ static int cpu_imx_get_temp(struct cpu_imx_platdata > *plat) { > struct udevice *thermal_dev; > int cpu_tmp, ret; > + int idx = 1; /* use "cpu-thermal0" device */ > > - if (!strcmp(plat->name, "A72")) > - ret = uclass_get_device(UCLASS_THERMAL, 1, &thermal_dev); > - else > - ret = uclass_get_device(UCLASS_THERMAL, 0, &thermal_dev); > + if (plat->cpu_rsrc == SC_R_A72) > + idx = 2; /* use "cpu-thermal1" device */ > > + ret = uclass_get_device(UCLASS_THERMAL, idx, &thermal_dev); > if (!ret) { > ret = thermal_get_temp(thermal_dev, &cpu_tmp); > if (ret) > @@ -180,19 +188,11 @@ static const struct udevice_id cpu_imx8_ids[] = { > > static ulong imx8_get_cpu_rate(struct udevice *dev) { > + struct cpu_imx_platdata *plat = dev_get_platdata(dev); > ulong rate; > - int ret, type; > - > - if (device_is_compatible(dev, "arm,cortex-a35")) > - type = SC_R_A35; > - else if (device_is_compatible(dev, "arm,cortex-a53")) > - type = SC_R_A53; > - else if (device_is_compatible(dev, "arm,cortex-a72")) > - type = SC_R_A72; > - else > - return 0; > + int ret; > > - ret = sc_pm_get_clock_rate(-1, type, SC_PM_CLK_CPU, > + ret = sc_pm_get_clock_rate(-1, plat->cpu_rsrc, SC_PM_CLK_CPU, > (sc_pm_clock_rate_t *)&rate); > if (ret) { > printf("Could not read CPU frequency: %d\n", ret); @@ -207,9 > +207,9 @@ static int imx8_cpu_probe(struct udevice *dev) > struct cpu_imx_platdata *plat = dev_get_platdata(dev); > u32 cpurev; > > + set_core_data(dev); > cpurev = get_cpu_rev(); > plat->cpurev = cpurev; > - plat->name = get_core_name(dev); > plat->rev = get_imx8_rev(cpurev & 0xFFF); > plat->type = get_imx8_type((cpurev & 0xFF000) >> 12); > plat->freq_mhz = imx8_get_cpu_rate(dev) / 1000000; > -- > 2.17.1 Reviewed-by: Peng Fan <peng.fan at nxp.com>
On Wed, 20 May 2020 01:31:44 +0200 Anatolij Gustschin agust at denx.de wrote: > This fixes getting DT alert and critical pdata values in imx_scu_thermal > driver. On i.MX8QXP using not initialized alert pdata value resulted in > boot hang and endless loop outputting: > CPU Temperature (47200C) has beyond alert (0C), close to critical (0C) waiting... > > While at it, preset CPU type values once to avoid multiple calls > of device_is_compatible() for same property. > > Fixes: 3ee6ea443eb4 ("cpu: imx_cpu: Print the CPU temperature for iMX8QM A72") > Signed-off-by: Anatolij Gustschin <agust at denx.de> > --- > This one supersedes the older patch here: > http://patchwork.ozlabs.org/project/uboot/patch/20200516203420.24409-2-agust at denx.de > > drivers/cpu/imx8_cpu.c | 50 +++++++++++++++++++++--------------------- > 1 file changed, 25 insertions(+), 25 deletions(-) Applied. -- Anatolij
diff --git a/drivers/cpu/imx8_cpu.c b/drivers/cpu/imx8_cpu.c index 896e1ac776..adc4919d9e 100644 --- a/drivers/cpu/imx8_cpu.c +++ b/drivers/cpu/imx8_cpu.c @@ -18,6 +18,7 @@ struct cpu_imx_platdata { const char *name; const char *rev; const char *type; + u32 cpu_rsrc; u32 cpurev; u32 freq_mhz; u32 mpidr; @@ -50,16 +51,23 @@ const char *get_imx8_rev(u32 rev) } } -const char *get_core_name(struct udevice *dev) +static void set_core_data(struct udevice *dev) { - if (device_is_compatible(dev, "arm,cortex-a35")) - return "A35"; - else if (device_is_compatible(dev, "arm,cortex-a53")) - return "A53"; - else if (device_is_compatible(dev, "arm,cortex-a72")) - return "A72"; - else - return "?"; + struct cpu_imx_platdata *plat = dev_get_platdata(dev); + + if (device_is_compatible(dev, "arm,cortex-a35")) { + plat->cpu_rsrc = SC_R_A35; + plat->name = "A35"; + } else if (device_is_compatible(dev, "arm,cortex-a53")) { + plat->cpu_rsrc = SC_R_A53; + plat->name = "A53"; + } else if (device_is_compatible(dev, "arm,cortex-a72")) { + plat->cpu_rsrc = SC_R_A72; + plat->name = "A72"; + } else { + plat->cpu_rsrc = SC_R_A53; + plat->name = "?"; + } } #if IS_ENABLED(CONFIG_IMX_SCU_THERMAL) @@ -67,12 +75,12 @@ static int cpu_imx_get_temp(struct cpu_imx_platdata *plat) { struct udevice *thermal_dev; int cpu_tmp, ret; + int idx = 1; /* use "cpu-thermal0" device */ - if (!strcmp(plat->name, "A72")) - ret = uclass_get_device(UCLASS_THERMAL, 1, &thermal_dev); - else - ret = uclass_get_device(UCLASS_THERMAL, 0, &thermal_dev); + if (plat->cpu_rsrc == SC_R_A72) + idx = 2; /* use "cpu-thermal1" device */ + ret = uclass_get_device(UCLASS_THERMAL, idx, &thermal_dev); if (!ret) { ret = thermal_get_temp(thermal_dev, &cpu_tmp); if (ret) @@ -180,19 +188,11 @@ static const struct udevice_id cpu_imx8_ids[] = { static ulong imx8_get_cpu_rate(struct udevice *dev) { + struct cpu_imx_platdata *plat = dev_get_platdata(dev); ulong rate; - int ret, type; - - if (device_is_compatible(dev, "arm,cortex-a35")) - type = SC_R_A35; - else if (device_is_compatible(dev, "arm,cortex-a53")) - type = SC_R_A53; - else if (device_is_compatible(dev, "arm,cortex-a72")) - type = SC_R_A72; - else - return 0; + int ret; - ret = sc_pm_get_clock_rate(-1, type, SC_PM_CLK_CPU, + ret = sc_pm_get_clock_rate(-1, plat->cpu_rsrc, SC_PM_CLK_CPU, (sc_pm_clock_rate_t *)&rate); if (ret) { printf("Could not read CPU frequency: %d\n", ret); @@ -207,9 +207,9 @@ static int imx8_cpu_probe(struct udevice *dev) struct cpu_imx_platdata *plat = dev_get_platdata(dev); u32 cpurev; + set_core_data(dev); cpurev = get_cpu_rev(); plat->cpurev = cpurev; - plat->name = get_core_name(dev); plat->rev = get_imx8_rev(cpurev & 0xFFF); plat->type = get_imx8_type((cpurev & 0xFF000) >> 12); plat->freq_mhz = imx8_get_cpu_rate(dev) / 1000000;
This fixes getting DT alert and critical pdata values in imx_scu_thermal driver. On i.MX8QXP using not initialized alert pdata value resulted in boot hang and endless loop outputting: CPU Temperature (47200C) has beyond alert (0C), close to critical (0C) waiting... While at it, preset CPU type values once to avoid multiple calls of device_is_compatible() for same property. Fixes: 3ee6ea443eb4 ("cpu: imx_cpu: Print the CPU temperature for iMX8QM A72") Signed-off-by: Anatolij Gustschin <agust at denx.de> --- This one supersedes the older patch here: http://patchwork.ozlabs.org/project/uboot/patch/20200516203420.24409-2-agust at denx.de drivers/cpu/imx8_cpu.c | 50 +++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 25 deletions(-)