diff mbox series

[2/2] thermal: imx_scu_thermal: fix getting DT alert property value

Message ID DB6PR0402MB2760DD2B1FDCFEBEAF9D6FBB88B90@DB6PR0402MB2760.eurprd04.prod.outlook.com
State New
Headers show
Series None | expand

Commit Message

Peng Fan May 19, 2020, 10:05 a.m. UTC
> Subject: Re: [PATCH 2/2] thermal: imx_scu_thermal: fix getting DT alert
> property value
> 
> Hi Peng,
> 
> On Sun, 17 May 2020 16:53:17 +0200
> Anatolij Gustschin agust at denx.de wrote:
> ...
> > Will try to bisect later.
> 
> bisecting leads to:
> # first bad commit: [3ee6ea443eb466399ab325a58b377326ac5c57b5]
> cpu: imx_cpu: Print the CPU temperature for iMX8QM A72

Would this help?


Thanks,
Peng.
> 
> --
> Anatolij

Comments

Anatolij Gustschin May 19, 2020, 10:26 a.m. UTC | #1
On Tue, 19 May 2020 10:05:21 +0000
Peng Fan peng.fan at nxp.com wrote:
...
> Would this help?
> 
> diff --git a/drivers/cpu/imx8_cpu.c b/drivers/cpu/imx8_cpu.c
> index 95c14c98d8..6c949ccbd4 100644
> --- a/drivers/cpu/imx8_cpu.c
> +++ b/drivers/cpu/imx8_cpu.c
> @@ -68,10 +68,13 @@ static int cpu_imx_get_temp(struct cpu_imx_platdata *plat)
>         struct udevice *thermal_dev;
>         int cpu_tmp, ret;
> 
> -       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 (!strcmp(plat->name, "A72")) {
> +               ret = uclass_get_device_by_name(UCLASS_THERMAL, "cpu-thermal1",
> +                                               &thermal_dev);
> +       } else {
> +               ret = uclass_get_device_by_name(UCLASS_THERMAL, "cpu-thermal0",
> +                                               &thermal_dev);
> +       }
> 
>         if (!ret) {
>                 ret = thermal_get_temp(thermal_dev, &cpu_tmp);

Yes, this fixes the problem, thanks!

--
Anatolij
Peng Fan May 19, 2020, 11:45 a.m. UTC | #2
+Simon

> -----Original Message-----
> From: Anatolij Gustschin <agust at denx.de>
> Sent: 2020?5?19? 18:27
> To: Peng Fan <peng.fan at nxp.com>
> Cc: u-boot at lists.denx.de; Ye Li <ye.li at nxp.com>; Frank Li
> <frank.li at nxp.com>; sbabic at denx.de
> Subject: Re: [PATCH 2/2] thermal: imx_scu_thermal: fix getting DT alert
> property value
> 
> On Tue, 19 May 2020 10:05:21 +0000
> Peng Fan peng.fan at nxp.com wrote:
> ...
> > Would this help?
> >
> > diff --git a/drivers/cpu/imx8_cpu.c b/drivers/cpu/imx8_cpu.c index
> > 95c14c98d8..6c949ccbd4 100644
> > --- a/drivers/cpu/imx8_cpu.c
> > +++ b/drivers/cpu/imx8_cpu.c
> > @@ -68,10 +68,13 @@ static int cpu_imx_get_temp(struct
> cpu_imx_platdata *plat)
> >         struct udevice *thermal_dev;
> >         int cpu_tmp, ret;
> >
> > -       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 (!strcmp(plat->name, "A72")) {
> > +               ret = uclass_get_device_by_name(UCLASS_THERMAL,
> "cpu-thermal1",
> > +                                               &thermal_dev);
> > +       } else {
> > +               ret = uclass_get_device_by_name(UCLASS_THERMAL,
> "cpu-thermal0",
> > +                                               &thermal_dev);
> > +       }
> >
> >         if (!ret) {
> >                 ret = thermal_get_temp(thermal_dev, &cpu_tmp);
> 
> Yes, this fixes the problem, thanks!

Do you have more insights about uclass_get_device and uclass_get_device_byname?
uclass_get_device not work, but uclass_get_device_byname work.

Thanks,
Peng.

> 
> --
> Anatolij
Anatolij Gustschin May 19, 2020, 10:05 p.m. UTC | #3
On Tue, 19 May 2020 11:45:55 +0000
Peng Fan peng.fan at nxp.com wrote:
...
> Do you have more insights about uclass_get_device and uclass_get_device_byname?
> uclass_get_device not work, but uclass_get_device_byname work.

well, we have three thermal uclass devices on i.MX8QXP:
 thermal       0  [   ]   imx_sc_thermal        |-- thermal-sensor
 thermal       1  [   ]   imx_sc_thermal        |   |-- cpu-thermal0
 thermal       2  [   ]   imx_sc_thermal        |   `-- drc-thermal0

when using uclass_get_device(UCLASS_THERMAL, 0, &thermal_dev), the
first device ("thermal-sensor") is matching and for this device
imx_sc_thermal_ofdata_to_platdata() will be called, it then tries to
get the "thermal-sensors" list in the node of "thermal-sensor" device
(dev_of_offset(dev)), but this is wrong, since this list is a property
of the "cpu-thermal0" node according to bindings.

Therefore ofdata_to_platdata() can't find the "thermal-sensors" list
and does not initialize alert/critical pdata values.

When uclass_get_device_by_name() is used, then imx_sc_thermal_ofdata_to_platdata()
is called for "cpu-thermal0" device, here getting the list works
and alert/critical pdata values are initialized properly.

--
Anatolij
Anatolij Gustschin May 19, 2020, 11:37 p.m. UTC | #4
On Wed, 20 May 2020 00:05:01 +0200
Anatolij Gustschin agust at denx.de wrote:
...
> When uclass_get_device_by_name() is used, then imx_sc_thermal_ofdata_to_platdata()
> is called for "cpu-thermal0" device, here getting the list works
> and alert/critical pdata values are initialized properly.

This 2/2 patch can be superseded by patch:
 http://patchwork.ozlabs.org/project/uboot/patch/20200519233144.2426-1-agust at denx.de

--
Anatolij
diff mbox series

Patch

diff --git a/drivers/cpu/imx8_cpu.c b/drivers/cpu/imx8_cpu.c
index 95c14c98d8..6c949ccbd4 100644
--- a/drivers/cpu/imx8_cpu.c
+++ b/drivers/cpu/imx8_cpu.c
@@ -68,10 +68,13 @@  static int cpu_imx_get_temp(struct cpu_imx_platdata *plat)
        struct udevice *thermal_dev;
        int cpu_tmp, ret;

-       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 (!strcmp(plat->name, "A72")) {
+               ret = uclass_get_device_by_name(UCLASS_THERMAL, "cpu-thermal1",
+                                               &thermal_dev);
+       } else {
+               ret = uclass_get_device_by_name(UCLASS_THERMAL, "cpu-thermal0",
+                                               &thermal_dev);
+       }

        if (!ret) {
                ret = thermal_get_temp(thermal_dev, &cpu_tmp);