2023-06-25 19:35:48

by Frank Wunderlich

[permalink] [raw]
Subject: [PATCH v1 0/2] Fix emmc hs400 mode on mt7986

From: Frank Wunderlich <[email protected]>

Eric boots linux directly from ATF without using uboot. In this corner
case clocks for emmc hs400 mode are not correctly setup.

Fix this by adding assigned-clocks and assigned.clock-parents to mmc node.

Eric Woudstra (1):
arm64: dts: mt7986: fix emmc hs400 mode without uboot initialization

Frank Wunderlich (1):
dt-bindings: mmc: mtk-sd: update assigned-clocks/clock-parents for
mt7986

Documentation/devicetree/bindings/mmc/mtk-sd.yaml | 4 ++++
arch/arm64/boot/dts/mediatek/mt7986a.dtsi | 4 ++++
2 files changed, 8 insertions(+)

--
2.34.1



2023-06-25 19:39:57

by Frank Wunderlich

[permalink] [raw]
Subject: [PATCH v1 1/2] dt-bindings: mmc: mtk-sd: update assigned-clocks/clock-parents for mt7986

From: Frank Wunderlich <[email protected]>

MT7986 has 2 clock-parents so update the binding for it.

Signed-off-by: Frank Wunderlich <[email protected]>
---
Documentation/devicetree/bindings/mmc/mtk-sd.yaml | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/mmc/mtk-sd.yaml b/Documentation/devicetree/bindings/mmc/mtk-sd.yaml
index 46eefdd19a2c..485516dcc759 100644
--- a/Documentation/devicetree/bindings/mmc/mtk-sd.yaml
+++ b/Documentation/devicetree/bindings/mmc/mtk-sd.yaml
@@ -247,6 +247,10 @@ allOf:
- mediatek,mt7986-mmc
then:
properties:
+ assigned-clocks:
+ maxItems: 2
+ assigned-clock-parents:
+ maxItems: 2
clocks:
minItems: 3
items:
--
2.34.1


2023-06-25 19:43:49

by Frank Wunderlich

[permalink] [raw]
Subject: [PATCH v1 2/2] arm64: dts: mt7986: fix emmc hs400 mode without uboot initialization

From: Eric Woudstra <[email protected]>

Eric reports errors on emmc with hs400 mode when booting linux on bpi-r3
without uboot [1]. Booting with uboot does not show this because clocks
seem to be initialized by uboot.

Fix this by adding assigned-clocks and assigned-clock-parents like it's
done in uboot [2].

[1] https://forum.banana-pi.org/t/bpi-r3-kernel-fails-setting-emmc-clock-to-416m-depends-on-u-boot/15170
[2] https://github.com/u-boot/u-boot/blob/master/arch/arm/dts/mt7986.dtsi#L287

Cc: [email protected]
Fixes: 513b49d19b34 ("arm64: dts: mt7986: add mmc related device nodes")
Signed-off-by: Eric Woudstra <[email protected]>
Signed-off-by: Frank Wunderlich <[email protected]>
---
arch/arm64/boot/dts/mediatek/mt7986a.dtsi | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt7986a.dtsi b/arch/arm64/boot/dts/mediatek/mt7986a.dtsi
index 68539ea788df..207510abda89 100644
--- a/arch/arm64/boot/dts/mediatek/mt7986a.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt7986a.dtsi
@@ -374,6 +374,10 @@ mmc0: mmc@11230000 {
reg = <0 0x11230000 0 0x1000>,
<0 0x11c20000 0 0x1000>;
interrupts = <GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH>;
+ assigned-clocks = <&topckgen CLK_TOP_EMMC_416M_SEL>,
+ <&topckgen CLK_TOP_EMMC_250M_SEL>;
+ assigned-clock-parents = <&apmixedsys CLK_APMIXED_MPLL>,
+ <&topckgen CLK_TOP_NET1PLL_D5_D2>;
clocks = <&topckgen CLK_TOP_EMMC_416M_SEL>,
<&infracfg CLK_INFRA_MSDC_HCK_CK>,
<&infracfg CLK_INFRA_MSDC_CK>,
--
2.34.1


2023-06-27 11:51:01

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] dt-bindings: mmc: mtk-sd: update assigned-clocks/clock-parents for mt7986

On 25/06/2023 21:11, Frank Wunderlich wrote:
> From: Frank Wunderlich <[email protected]>
>
> MT7986 has 2 clock-parents so update the binding for it.

You didn't test it, I think. If you do, then you will see errors from
other trees.

Anyway, I don't understand why defining it in the first place. Just drop
the assigned-clock* from the binding.

Best regards,
Krzysztof


2023-06-27 12:28:15

by Frank Wunderlich

[permalink] [raw]
Subject: Aw: Re: [PATCH v1 1/2] dt-bindings: mmc: mtk-sd: update assigned-clocks/clock-parents for mt7986

> Gesendet: Dienstag, 27. Juni 2023 um 12:44 Uhr
> Von: "Krzysztof Kozlowski" <[email protected]>
> Betreff: Re: [PATCH v1 1/2] dt-bindings: mmc: mtk-sd: update assigned-clocks/clock-parents for mt7986
>
> On 25/06/2023 21:11, Frank Wunderlich wrote:
> > From: Frank Wunderlich <[email protected]>
> >
> > MT7986 has 2 clock-parents so update the binding for it.
>
> You didn't test it, I think. If you do, then you will see errors from
> other trees.

Hi,

i tested it of course...which errors do you see?

this is basicly how i tested it (in case anything has changed):

logfile=dtbs_arm64.log
exec 3> >(tee $logfile)
ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make DT_CHECKER_FLAGS=-m dt_binding_check 2>&3
if [[ $? -ne 0 ]];then echo "arm64 binding check failed!";cat $logfile;exit 1;fi
ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make defconfig #dtbs_check need kernel-config
ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make -j8 DT_CHECKER_FLAGS=-m dtbs_check 2>&3
if [[ $? -ne 0 ]];then echo "arm64 dtbs_check failed!";cat $logfile;exit 1;fi

and looked into the resulting logfile for keywords like mmc like mtk-sd

i tried running dtbs_check with passing the yaml-file, but of course all compatibles not matching this file were reported.

ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make -j6 DT_CHECKER_FLAGS=-m dtbs_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/mmc/mtk-sd.yaml

but this spits out many errors "failed to match any schema with compatible" because i defined only the changed one...

maybe there is another way to check only one yaml file against all dtbs without these unrelated errors.

pipeline in dt-bindings-patchwork is clean too
https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]/

> Anyway, I don't understand why defining it in the first place. Just drop
> the assigned-clock* from the binding.

as it was defined (not looked where it was used) i only used the soc-specific branch to update the MaxItems...just to not break anything. After that the message i got before was fixed

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtb: mmc@11230000: assigned-clocks: [[4, 35], [4, 34]] is too long
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtb: mmc@11230000: assigned-clock-parents: [[5, 6], [4, 18]] is too long

but if the right way is to drop the MaxItems from generic (or the property itself - where is it taken from then?). The only
include i see is Documentation/devicetree/bindings/mmc/mmc-controller.yaml and there the assigned-clock* is not defined. And the

unevaluatedProperties: false

tells me that removing the generic one will result in unevaluated propety error.

regards Frank


> Best regards,
> Krzysztof
>
>

2023-06-27 14:06:31

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: Aw: Re: [PATCH v1 1/2] dt-bindings: mmc: mtk-sd: update assigned-clocks/clock-parents for mt7986

On 27/06/2023 14:09, Frank Wunderlich wrote:
>> Gesendet: Dienstag, 27. Juni 2023 um 12:44 Uhr
>> Von: "Krzysztof Kozlowski" <[email protected]>
>> Betreff: Re: [PATCH v1 1/2] dt-bindings: mmc: mtk-sd: update assigned-clocks/clock-parents for mt7986
>>
>> On 25/06/2023 21:11, Frank Wunderlich wrote:
>>> From: Frank Wunderlich <[email protected]>
>>>
>>> MT7986 has 2 clock-parents so update the binding for it.
>>
>> You didn't test it, I think. If you do, then you will see errors from
>> other trees.
>
> Hi,
>
> i tested it of course...which errors do you see?

The top-level said it can be maximum 1, so raising it in allOf:if:then:
should not be enough

> 11
> this is basicly how i tested it (in case anything has changed):
>
> logfile=dtbs_arm64.log
> exec 3> >(tee $logfile)
> ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make DT_CHECKER_FLAGS=-m dt_binding_check 2>&3
> if [[ $? -ne 0 ]];then echo "arm64 binding check failed!";cat $logfile;exit 1;fi
> ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make defconfig #dtbs_check need kernel-config
> ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make -j8 DT_CHECKER_FLAGS=-m dtbs_check 2>&3
> if [[ $? -ne 0 ]];then echo "arm64 dtbs_check failed!";cat $logfile;exit 1;fi

A bit over-complicated... why not running dtbs_check against the schema
you changed?

>
> and looked into the resulting logfile for keywords like mmc like mtk-sd
>
> i tried running dtbs_check with passing the yaml-file, but of course all compatibles not matching this file were reported.
>
> ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make -j6 DT_CHECKER_FLAGS=-m dtbs_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/mmc/mtk-sd.yaml
>
> but this spits out many errors "failed to match any schema with compatible" because i defined only the changed one...
>
> maybe there is another way to check only one yaml file against all dtbs without these unrelated errors.
>
> pipeline in dt-bindings-patchwork is clean too
> https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]/

Maybe that binding just fails to apply to DTS because of missing or not
correct compatibles.

>
>> Anyway, I don't understand why defining it in the first place. Just drop
>> the assigned-clock* from the binding.
>
> as it was defined (not looked where it was used) i only used the soc-specific branch to update the MaxItems...just to not break anything. After that the message i got before was fixed
>
> arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtb: mmc@11230000: assigned-clocks: [[4, 35], [4, 34]] is too long
> arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtb: mmc@11230000: assigned-clock-parents: [[5, 6], [4, 18]] is too long
>
> but if the right way is to drop the MaxItems from generic (or the property itself - where is it taken from then?). The only
> include i see is Documentation/devicetree/bindings/mmc/mmc-controller.yaml and there the assigned-clock* is not defined. And the

The way is to entirely drop assigned-clocks. I don't think there are
much benefits of having them in the bindings. Maybe if specific rates
are required, then yes - device cannot work with other rates and you can
verify it with dtbs_check. But otherwise it is like adding values of
'reg' or 'interrupts'. Plus some board might require third item and then
what?

Best regards,
Krzysztof


2023-06-27 14:33:33

by Frank Wunderlich

[permalink] [raw]
Subject: Aw: Re: Re: [PATCH v1 1/2] dt-bindings: mmc: mtk-sd: update assigned-clocks/clock-parents for mt7986

Hi


> Gesendet: Dienstag, 27. Juni 2023 um 15:37 Uhr
> Von: "Krzysztof Kozlowski" <[email protected]>
> On 27/06/2023 14:09, Frank Wunderlich wrote:
> >> Gesendet: Dienstag, 27. Juni 2023 um 12:44 Uhr
> >> Von: "Krzysztof Kozlowski" <[email protected]>
> >> Betreff: Re: [PATCH v1 1/2] dt-bindings: mmc: mtk-sd: update assigned-clocks/clock-parents for mt7986
> >>
> >> On 25/06/2023 21:11, Frank Wunderlich wrote:
> >>> From: Frank Wunderlich <[email protected]>
> >>>
> >>> MT7986 has 2 clock-parents so update the binding for it.
> >>
> >> You didn't test it, I think. If you do, then you will see errors from
> >> other trees.
> >
> > Hi,
> >
> > i tested it of course...which errors do you see?
>
> The top-level said it can be maximum 1, so raising it in allOf:if:then:
> should not be enough

but the previous error with too long list wasn't there after the change...so it seems to work...if it right, i don't know,
but other properties are overriddedn the same way.

> > 11
> > this is basicly how i tested it (in case anything has changed):
> >
> > logfile=dtbs_arm64.log
> > exec 3> >(tee $logfile)
> > ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make DT_CHECKER_FLAGS=-m dt_binding_check 2>&3
> > if [[ $? -ne 0 ]];then echo "arm64 binding check failed!";cat $logfile;exit 1;fi
> > ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make defconfig #dtbs_check need kernel-config
> > ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make -j8 DT_CHECKER_FLAGS=-m dtbs_check 2>&3
> > if [[ $? -ne 0 ]];then echo "arm64 dtbs_check failed!";cat $logfile;exit 1;fi
>
> A bit over-complicated... why not running dtbs_check against the schema
> you changed?

it is a script i only start ;) and having a logfile (with all messages - stdin+stdout) makes it easier to find something.
i had always the problem, that second run does not show the errors again without changing the yaml or dts.

as you see below i tried the run against the yaml too, but there are many many unrelated compatibles which seem to be not
documented or still in txt bindings.

> > and looked into the resulting logfile for keywords like mmc like mtk-sd
> >
> > i tried running dtbs_check with passing the yaml-file, but of course all compatibles not matching this file were reported.
> >
> > ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make -j6 DT_CHECKER_FLAGS=-m dtbs_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/mmc/mtk-sd.yaml
> >
> > but this spits out many errors "failed to match any schema with compatible" because i defined only the changed one...
> >
> > maybe there is another way to check only one yaml file against all dtbs without these unrelated errors.
> >
> > pipeline in dt-bindings-patchwork is clean too
> > https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]/
>
> Maybe that binding just fails to apply to DTS because of missing or not
> correct compatibles.

the messages are unrelated to current yaml file i passed with the DT_SCHEMA_FILES parameter, e.g. the last messages:

From schema: Documentation/devicetree/bindings/display/mediatek/mediatek,dsi.yaml
arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-burnet.dtb:0:0: /soc/syscon@15020000: failed to match any schema with compatible: ['mediatek,mt8183-imgsys', 'syscon']
arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-burnet.dtb:0:0: /soc/syscon@16000000: failed to match any schema with compatible: ['mediatek,mt8183-vdecsys', 'syscon']
arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-burnet.dtb:0:0: /soc/syscon@17000000: failed to match any schema with compatible: ['mediatek,mt8183-vencsys', 'syscon']
arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-burnet.dtb:0:0: /soc/syscon@19000000: failed to match any schema with compatible: ['mediatek,mt8183-ipu_conn', 'syscon']
arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-burnet.dtb:0:0: /soc/syscon@19010000: failed to match any schema with compatible: ['mediatek,mt8183-ipu_adl', 'syscon']
arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-burnet.dtb:0:0: /soc/syscon@19180000: failed to match any schema with compatible: ['mediatek,mt8183-ipu_core0', 'syscon']
arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-burnet.dtb:0:0: /soc/syscon@19280000: failed to match any schema with compatible: ['mediatek,mt8183-ipu_core1', 'syscon']
arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-burnet.dtb:0:0: /soc/syscon@1a000000: failed to match any schema with compatible: ['mediatek,mt8183-camsys', 'syscon']
arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-burnet.dtb:0:0: /mt8183-sound: failed to match any schema with compatible: ['mediatek,mt8183_mt6358_ts3a227_max98357']
arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-burnet.dtb: bt-sco: '#sound-dai-cells' is a required property

> >> Anyway, I don't understand why defining it in the first place. Just drop
> >> the assigned-clock* from the binding.
> >
> > as it was defined (not looked where it was used) i only used the soc-specific branch to update the MaxItems...just to not break anything. After that the message i got before was fixed
> >
> > arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtb: mmc@11230000: assigned-clocks: [[4, 35], [4, 34]] is too long
> > arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtb: mmc@11230000: assigned-clock-parents: [[5, 6], [4, 18]] is too long
> >
> > but if the right way is to drop the MaxItems from generic (or the property itself - where is it taken from then?). The only
> > include i see is Documentation/devicetree/bindings/mmc/mmc-controller.yaml and there the assigned-clock* is not defined. And the
>
> The way is to entirely drop assigned-clocks. I don't think there are
> much benefits of having them in the bindings. Maybe if specific rates
> are required, then yes - device cannot work with other rates and you can
> verify it with dtbs_check. But otherwise it is like adding values of
> 'reg' or 'interrupts'. Plus some board might require third item and then
> what?

mhm, disabled all assigned-clock* properties and do not get any messages about this (don't know why because of "unevaluatedProperties: false", but looks like it works)

there are only some syscon-nodes in mt8173-*.dtb where these properties used are reported

btw. need binding also be backported to stable? so do i need to add the tag there?

regards Frank