diff mbox series

[v6,14/48] mfd: ti_am335x_tscadc: Don't search the tree for our clock

Message ID 20211015081506.933180-15-miquel.raynal@bootlin.com (mailing list archive)
State New, archived
Headers show
Series TI AM437X ADC1 | expand

Commit Message

Miquel Raynal Oct. 15, 2021, 8:14 a.m. UTC
There is a single clock available in our node, which is named
"fck". The clock handler then points to adc_tsc_fck but no need to point
directly to it and do a full tree search.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mfd/ti_am335x_tscadc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

H. Nikolaus Schaller March 4, 2022, 10:38 p.m. UTC | #1
Hi Miquel,
I recently found that our BeagleBoneBlack with external touch screen stopped
to find it.

A git bisect revealed this patch (merged into v5.16-rc1) as the first bad:

> Am 15.10.2021 um 10:14 schrieb Miquel Raynal <miquel.raynal@bootlin.com>:
> 
> There is a single clock available in our node, which is named
> "fck". The clock handler then points to adc_tsc_fck but no need to point
> directly to it and do a full tree search.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
> drivers/mfd/ti_am335x_tscadc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> index e2c4416f192d..8af44c08d925 100644
> --- a/drivers/mfd/ti_am335x_tscadc.c
> +++ b/drivers/mfd/ti_am335x_tscadc.c
> @@ -206,7 +206,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
> 	 * This frequency is valid since TSC_ADC_SS controller design
> 	 * assumes the OCP clock is at least 6x faster than the ADC clock.
> 	 */
> -	clk = devm_clk_get(&pdev->dev, "adc_tsc_fck");
> +	clk = devm_clk_get(&pdev->dev, NULL);
> 	if (IS_ERR(clk)) {
> 		dev_err(&pdev->dev, "failed to get TSC fck\n");
> 		err = PTR_ERR(clk);
> -- 
> 2.27.0
> 

While I understand the reasons for this change there seems to be something
missing now in the device tree because the clock isn't found any more.

After knowing about the problem I could also locate the log entry:

[    4.456680] ti_am3359-tscadc 44e0d000.tscadc: failed to get TSC fck

Reverting your patch makes it work again.

Is there missing a change in the am335x-boneblack or am335x DTS?

Our (private) DTS looks like this, i.e. we don't play with clocks inherited
from mainline tree:

#include "am335x-boneblack.dts"

...

&tscadc {
        status = "okay";

        tsc {
                ti,wires = <4>;
                ti,x-plate-resistance = <600>;
                ti,coordinate-readouts = <5>;
                ti,wire-config = <0x00 0x11 0x22 0x33>;
        };

        adc {
                ti,adc-channels = <4 5 6 7>;
        };
};

BR and thanks,
Nikolaus
Miquel Raynal March 7, 2022, 11:10 a.m. UTC | #2
Hi Nikolaus,

hns@goldelico.com wrote on Fri, 4 Mar 2022 23:38:25 +0100:

> Hi Miquel,
> I recently found that our BeagleBoneBlack with external touch screen stopped
> to find it.
> 
> A git bisect revealed this patch (merged into v5.16-rc1) as the first bad:
> 
> > Am 15.10.2021 um 10:14 schrieb Miquel Raynal <miquel.raynal@bootlin.com>:
> > 
> > There is a single clock available in our node, which is named
> > "fck". The clock handler then points to adc_tsc_fck but no need to point
> > directly to it and do a full tree search.
> > 
> > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> > ---
> > drivers/mfd/ti_am335x_tscadc.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> > index e2c4416f192d..8af44c08d925 100644
> > --- a/drivers/mfd/ti_am335x_tscadc.c
> > +++ b/drivers/mfd/ti_am335x_tscadc.c
> > @@ -206,7 +206,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
> > 	 * This frequency is valid since TSC_ADC_SS controller design
> > 	 * assumes the OCP clock is at least 6x faster than the ADC clock.
> > 	 */
> > -	clk = devm_clk_get(&pdev->dev, "adc_tsc_fck");
> > +	clk = devm_clk_get(&pdev->dev, NULL);
> > 	if (IS_ERR(clk)) {
> > 		dev_err(&pdev->dev, "failed to get TSC fck\n");
> > 		err = PTR_ERR(clk);
> > -- 
> > 2.27.0
> >   
> 
> While I understand the reasons for this change there seems to be something
> missing now in the device tree because the clock isn't found any more.
> 
> After knowing about the problem I could also locate the log entry:
> 
> [    4.456680] ti_am3359-tscadc 44e0d000.tscadc: failed to get TSC fck
> 
> Reverting your patch makes it work again.

Sorry for the wrong behavior on your side and thanks for the
investigation.

> Is there missing a change in the am335x-boneblack or am335x DTS?

I've looked at the code and indeed the am33xx-clock.dtsi file defines
the touchscreen clock, but unfortunately the am33xx-l4.dtsi file which
defines the touchscreen node does not reference the clock. The bindings
clearly require the clocks to be referenced but I believe this was not
noticed until now because the clock exist and clk_get() did a lookup
across the tree.

On my side I tested it with an am437x SoC which uses another base
device tree, which properly references the touchscreen clock where it's
needed.

I will send a patch (untested), can you give it a try and report if it
fixes your issue?

> 
> Our (private) DTS looks like this, i.e. we don't play with clocks inherited
> from mainline tree:
> 
> #include "am335x-boneblack.dts"
> 
> ...
> 
> &tscadc {
>         status = "okay";
> 
>         tsc {
>                 ti,wires = <4>;
>                 ti,x-plate-resistance = <600>;
>                 ti,coordinate-readouts = <5>;
>                 ti,wire-config = <0x00 0x11 0x22 0x33>;
>         };
> 
>         adc {
>                 ti,adc-channels = <4 5 6 7>;
>         };
> };
> 
> BR and thanks,
> Nikolaus

Thanks,
Miquèl
H. Nikolaus Schaller March 7, 2022, 11:15 a.m. UTC | #3
Hi Miquel,

> Am 07.03.2022 um 12:10 schrieb Miquel Raynal <miquel.raynal@bootlin.com>:
> 
> Hi Nikolaus,
> 
> hns@goldelico.com wrote on Fri, 4 Mar 2022 23:38:25 +0100:
> 
>> Hi Miquel,
>> I recently found that our BeagleBoneBlack with external touch screen stopped
>> to find it.
>> 
>> A git bisect revealed this patch (merged into v5.16-rc1) as the first bad:
>> 
>>> Am 15.10.2021 um 10:14 schrieb Miquel Raynal <miquel.raynal@bootlin.com>:
>>> 
>>> There is a single clock available in our node, which is named
>>> "fck". The clock handler then points to adc_tsc_fck but no need to point
>>> directly to it and do a full tree search.
>>> 
>>> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
>>> ---
>>> drivers/mfd/ti_am335x_tscadc.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>> 
>>> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
>>> index e2c4416f192d..8af44c08d925 100644
>>> --- a/drivers/mfd/ti_am335x_tscadc.c
>>> +++ b/drivers/mfd/ti_am335x_tscadc.c
>>> @@ -206,7 +206,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>>> 	 * This frequency is valid since TSC_ADC_SS controller design
>>> 	 * assumes the OCP clock is at least 6x faster than the ADC clock.
>>> 	 */
>>> -	clk = devm_clk_get(&pdev->dev, "adc_tsc_fck");
>>> +	clk = devm_clk_get(&pdev->dev, NULL);
>>> 	if (IS_ERR(clk)) {
>>> 		dev_err(&pdev->dev, "failed to get TSC fck\n");
>>> 		err = PTR_ERR(clk);
>>> -- 
>>> 2.27.0
>>> 
>> 
>> While I understand the reasons for this change there seems to be something
>> missing now in the device tree because the clock isn't found any more.
>> 
>> After knowing about the problem I could also locate the log entry:
>> 
>> [    4.456680] ti_am3359-tscadc 44e0d000.tscadc: failed to get TSC fck
>> 
>> Reverting your patch makes it work again.
> 
> Sorry for the wrong behavior on your side and thanks for the
> investigation.
> 
>> Is there missing a change in the am335x-boneblack or am335x DTS?
> 
> I've looked at the code and indeed the am33xx-clock.dtsi file defines
> the touchscreen clock, but unfortunately the am33xx-l4.dtsi file which
> defines the touchscreen node does not reference the clock. The bindings
> clearly require the clocks to be referenced but I believe this was not
> noticed until now because the clock exist and clk_get() did a lookup
> across the tree.

I had expected something like this.

> 
> On my side I tested it with an am437x SoC which uses another base
> device tree, which properly references the touchscreen clock where it's
> needed.
> 
> I will send a patch (untested), can you give it a try and report if it
> fixes your issue?

Yes, please.

BR and thanks,
Nikolaus
diff mbox series

Patch

diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index e2c4416f192d..8af44c08d925 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -206,7 +206,7 @@  static	int ti_tscadc_probe(struct platform_device *pdev)
 	 * This frequency is valid since TSC_ADC_SS controller design
 	 * assumes the OCP clock is at least 6x faster than the ADC clock.
 	 */
-	clk = devm_clk_get(&pdev->dev, "adc_tsc_fck");
+	clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(clk)) {
 		dev_err(&pdev->dev, "failed to get TSC fck\n");
 		err = PTR_ERR(clk);