mbox series

[v8,0/4] Add Qualcomm SM6115 / SM4250 EUD dt-bindings & driver support

Message ID 20230717103236.1246771-1-bhupesh.sharma@linaro.org
Headers show
Series Add Qualcomm SM6115 / SM4250 EUD dt-bindings & driver support | expand

Message

Bhupesh Sharma July 17, 2023, 10:32 a.m. UTC
Changes since v6/v7:
-------------------
- v6 can be viewed here: https://lore.kernel.org/linux-arm-msm/20230517211756.2483552-1-bhupesh.sharma@linaro.org/
- Konrad and Krzysztof had different suggestions on how to tackle
  different SoCs inside the eud driver which require access to secure mode
  manager register space. While Konrad's suggestion was to use a dt property,
  other comments suggested using optional platform data for determining
  the same. Modified [PATCH 2/4] accordingly to use the optional
  platform data for now.
- Added Krzysztof's RB for [PATCH 1/4] and also addressed his review comments
  received on v5.
- Dropped eud cleanup patches (which were sent a v7) as they have been accepted in linux-next.
- Rebased on latest linux-next/master.

Changes since v5:
----------------
- v5 can be viewed here: https://lore.kernel.org/linux-arm-msm/20230516213308.2432018-1-bhupesh.sharma@linaro.org/
- Addressed Mani's comment and added Fixes tag for [PATCH 1/6].
  Also collected his Ack for this patch.
- Fixed [PATCH 4/6] as per Greg's comments and added a separate patch
  for identation issues -> [PATCH 3/6].

Changes since v4:
----------------
- v4 can be viewed here: https://lore.kernel.org/linux-arm-msm/20230505064039.1630025-1-bhupesh.sharma@linaro.org/
- Addressed Konrad's review comments regarding EUD driver code.
- Also collected his R-B for [PATCH 4/5 and 5/5].
- Fixed the dt-bindings as per Krzysztof's comments.

Changes since v3:
----------------
- v3 can be viewed here: https://www.spinics.net/lists/linux-arm-msm/msg137025.html 
- Addressed Konrad's review comments regarding mainly the driver code.
  Also fixed the .dtsi as per his comments.
- Also collected his R-B for [PATCH 1/5].

Changes since v2:
----------------
- v2 can be viewed here: https://www.spinics.net/lists/linux-arm-msm/msg137025.html 
- Addressed Bjorn and Krzysztof's comments.
- Added [PATCH 1/5] which fixes the 'qcom_eud' sysfs path. 
- Added [PATCH 5/5] to enable EUD for Qualcomm QRB4210-RB2 boards.

Changes since v1:
----------------
- v1 can be viewed here: https://lore.kernel.org/linux-arm-msm/20221231130743.3285664-1-bhupesh.sharma@linaro.org
- Added Krzysztof in Cc list.
- Fixed the following issue reported by kernel test bot:
  >> ERROR: modpost: "qcom_scm_io_writel" [drivers/usb/misc/qcom_eud.ko] undefined!

This series adds the dt-binding and driver support for SM6115 / SM4250
EUD (Embedded USB Debugger) block available on Qualcomm SoCs.

It also enables the same for QRB4210-RB2 boards by default (the user
still needs to enable the same via sysfs).

The EUD is a mini-USB hub implemented on chip to support the USB-based debug
and trace capabilities.

EUD driver listens to events like USB attach or detach and then
informs the USB about these events via ROLE-SWITCH.

Bhupesh Sharma (4):
  dt-bindings: soc: qcom: eud: Add SM6115 / SM4250 support
  usb: misc: eud: Add driver support for SM6115 / SM4250
  arm64: dts: qcom: sm6115: Add EUD dt node and dwc3 connector
  arm64: dts: qcom: qrb4210-rb2: Enable EUD debug peripheral

 .../bindings/soc/qcom/qcom,eud.yaml           | 42 ++++++++++++-
 arch/arm64/boot/dts/qcom/qrb4210-rb2.dts      | 27 +++++++-
 arch/arm64/boot/dts/qcom/sm6115.dtsi          | 50 +++++++++++++++
 drivers/usb/misc/Kconfig                      |  2 +-
 drivers/usb/misc/qcom_eud.c                   | 62 +++++++++++++++++--
 5 files changed, 173 insertions(+), 10 deletions(-)

Comments

Bhupesh Sharma July 17, 2023, 6:03 p.m. UTC | #1
On Mon, 17 Jul 2023 at 16:15, Stephan Gerhold <stephan@gerhold.net> wrote:
>
> On Mon, Jul 17, 2023 at 04:02:35PM +0530, Bhupesh Sharma wrote:
> > Add the Embedded USB Debugger(EUD) device tree node for
> > SM6115 / SM4250 SoC.
> >
> > The node contains EUD base register region, EUD mode manager
> > register region and TCSR Base register region along with the
> > interrupt entry.
> >
> > [...]
> >
> > Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
> > Signed-off-by: Bhupesh Sharma <bhupesh.sharma@linaro.org>
> > ---
> >  arch/arm64/boot/dts/qcom/sm6115.dtsi | 50 ++++++++++++++++++++++++++++
> >  1 file changed, 50 insertions(+)
> >
> > diff --git a/arch/arm64/boot/dts/qcom/sm6115.dtsi b/arch/arm64/boot/dts/qcom/sm6115.dtsi
> > index 839c603512403..db45337c1082c 100644
> > --- a/arch/arm64/boot/dts/qcom/sm6115.dtsi
> > +++ b/arch/arm64/boot/dts/qcom/sm6115.dtsi
> > [...]
> > @@ -789,6 +801,37 @@ gcc: clock-controller@1400000 {
> >                       #power-domain-cells = <1>;
> >               };
> >
> > +             eud: eud@1610000 {
> > +                     compatible = "qcom,sm6115-eud", "qcom,eud";
> > +                     reg = <0x0 0x01610000 0x0 0x2000>,
> > +                           <0x0 0x01612000 0x0 0x1000>,
> > +                           <0x0 0x003c0000 0x0 0x40000>;
> > +                     reg-names = "eud-base", "eud-mode-mgr", "tcsr-base";
>
> TCSR is a separate hardware block unrelated to the EUD. IMHO it
> shouldn't be listed as "reg" here.
>
> Typically we describe it as syscon and then reference it from other
> nodes. See e.g. sm8450.dtsi "tcsr: syscon@1fc0000" referenced in &scm
> "qcom,dload-mode = <&tcsr 0x13000>". This is pretty much exactly the
> same use case as you have. It also uses this to write something with
> qcom_scm_io_writel() at the end.

That was discussed a bit during v1 patchset review. Basically, if we
use a tcsr syscon approach here, we will need to define a 'qcom,xx'
vendor specific dt-property and use something like this in the eud
node:

qcom,eud-sec-reg = <&tcsr_reg yyyy>

which would be then used by the eud driver (via
syscon_regmap_lookup_by_phandle()).

But for sm6115 / qcm2290 this would be an over complicated solution as
normally the eud driver (say sc7280) doesn't need tcsr based secure
mode manager access. So defining a new soc / vendor specific
dt-property might be an overkill.

Thanks,
Bhupesh
Stephan Gerhold July 17, 2023, 6:26 p.m. UTC | #2
On Mon, Jul 17, 2023 at 11:33:40PM +0530, Bhupesh Sharma wrote:
> On Mon, 17 Jul 2023 at 16:15, Stephan Gerhold <stephan@gerhold.net> wrote:
> >
> > On Mon, Jul 17, 2023 at 04:02:35PM +0530, Bhupesh Sharma wrote:
> > > Add the Embedded USB Debugger(EUD) device tree node for
> > > SM6115 / SM4250 SoC.
> > >
> > > The node contains EUD base register region, EUD mode manager
> > > register region and TCSR Base register region along with the
> > > interrupt entry.
> > >
> > > [...]
> > >
> > > Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
> > > Signed-off-by: Bhupesh Sharma <bhupesh.sharma@linaro.org>
> > > ---
> > >  arch/arm64/boot/dts/qcom/sm6115.dtsi | 50 ++++++++++++++++++++++++++++
> > >  1 file changed, 50 insertions(+)
> > >
> > > diff --git a/arch/arm64/boot/dts/qcom/sm6115.dtsi b/arch/arm64/boot/dts/qcom/sm6115.dtsi
> > > index 839c603512403..db45337c1082c 100644
> > > --- a/arch/arm64/boot/dts/qcom/sm6115.dtsi
> > > +++ b/arch/arm64/boot/dts/qcom/sm6115.dtsi
> > > [...]
> > > @@ -789,6 +801,37 @@ gcc: clock-controller@1400000 {
> > >                       #power-domain-cells = <1>;
> > >               };
> > >
> > > +             eud: eud@1610000 {
> > > +                     compatible = "qcom,sm6115-eud", "qcom,eud";
> > > +                     reg = <0x0 0x01610000 0x0 0x2000>,
> > > +                           <0x0 0x01612000 0x0 0x1000>,
> > > +                           <0x0 0x003c0000 0x0 0x40000>;
> > > +                     reg-names = "eud-base", "eud-mode-mgr", "tcsr-base";
> >
> > TCSR is a separate hardware block unrelated to the EUD. IMHO it
> > shouldn't be listed as "reg" here.
> >
> > Typically we describe it as syscon and then reference it from other
> > nodes. See e.g. sm8450.dtsi "tcsr: syscon@1fc0000" referenced in &scm
> > "qcom,dload-mode = <&tcsr 0x13000>". This is pretty much exactly the
> > same use case as you have. It also uses this to write something with
> > qcom_scm_io_writel() at the end.
> 
> That was discussed a bit during v1 patchset review. Basically, if we
> use a tcsr syscon approach here, we will need to define a 'qcom,xx'
> vendor specific dt-property and use something like this in the eud
> node:
> 
> qcom,eud-sec-reg = <&tcsr_reg yyyy>
> 
> which would be then used by the eud driver (via
> syscon_regmap_lookup_by_phandle()).
> 
> But for sm6115 / qcm2290 this would be an over complicated solution as
> normally the eud driver (say sc7280) doesn't need tcsr based secure
> mode manager access. So defining a new soc / vendor specific
> dt-property might be an overkill.
> 

IMO a vendor-specific DT property is still better than messing up the
device separation in the device tree. The same "tcsr-base" reg would
also appear on the actual tcsr syscon device tree node. Having two
device tree nodes with the same reg region is generally not valid.

Something like qcom,eud-sec-reg = <&tcsr_reg yyyy> would at least make
clear that this points into a region that is shared between multiple
different devices, while adding it as reg suggests that TCSR belongs
exclusively to EUD.

Thanks,
Stephan
Bhupesh Sharma July 17, 2023, 8:09 p.m. UTC | #3
On Mon, 17 Jul 2023 at 23:58, Stephan Gerhold <stephan@gerhold.net> wrote:
>
> On Mon, Jul 17, 2023 at 11:33:40PM +0530, Bhupesh Sharma wrote:
> > On Mon, 17 Jul 2023 at 16:15, Stephan Gerhold <stephan@gerhold.net> wrote:
> > >
> > > On Mon, Jul 17, 2023 at 04:02:35PM +0530, Bhupesh Sharma wrote:
> > > > Add the Embedded USB Debugger(EUD) device tree node for
> > > > SM6115 / SM4250 SoC.
> > > >
> > > > The node contains EUD base register region, EUD mode manager
> > > > register region and TCSR Base register region along with the
> > > > interrupt entry.
> > > >
> > > > [...]
> > > >
> > > > Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
> > > > Signed-off-by: Bhupesh Sharma <bhupesh.sharma@linaro.org>
> > > > ---
> > > >  arch/arm64/boot/dts/qcom/sm6115.dtsi | 50 ++++++++++++++++++++++++++++
> > > >  1 file changed, 50 insertions(+)
> > > >
> > > > diff --git a/arch/arm64/boot/dts/qcom/sm6115.dtsi b/arch/arm64/boot/dts/qcom/sm6115.dtsi
> > > > index 839c603512403..db45337c1082c 100644
> > > > --- a/arch/arm64/boot/dts/qcom/sm6115.dtsi
> > > > +++ b/arch/arm64/boot/dts/qcom/sm6115.dtsi
> > > > [...]
> > > > @@ -789,6 +801,37 @@ gcc: clock-controller@1400000 {
> > > >                       #power-domain-cells = <1>;
> > > >               };
> > > >
> > > > +             eud: eud@1610000 {
> > > > +                     compatible = "qcom,sm6115-eud", "qcom,eud";
> > > > +                     reg = <0x0 0x01610000 0x0 0x2000>,
> > > > +                           <0x0 0x01612000 0x0 0x1000>,
> > > > +                           <0x0 0x003c0000 0x0 0x40000>;
> > > > +                     reg-names = "eud-base", "eud-mode-mgr", "tcsr-base";
> > >
> > > TCSR is a separate hardware block unrelated to the EUD. IMHO it
> > > shouldn't be listed as "reg" here.
> > >
> > > Typically we describe it as syscon and then reference it from other
> > > nodes. See e.g. sm8450.dtsi "tcsr: syscon@1fc0000" referenced in &scm
> > > "qcom,dload-mode = <&tcsr 0x13000>". This is pretty much exactly the
> > > same use case as you have. It also uses this to write something with
> > > qcom_scm_io_writel() at the end.
> >
> > That was discussed a bit during v1 patchset review. Basically, if we
> > use a tcsr syscon approach here, we will need to define a 'qcom,xx'
> > vendor specific dt-property and use something like this in the eud
> > node:
> >
> > qcom,eud-sec-reg = <&tcsr_reg yyyy>
> >
> > which would be then used by the eud driver (via
> > syscon_regmap_lookup_by_phandle()).
> >
> > But for sm6115 / qcm2290 this would be an over complicated solution as
> > normally the eud driver (say sc7280) doesn't need tcsr based secure
> > mode manager access. So defining a new soc / vendor specific
> > dt-property might be an overkill.
> >
>
> IMO a vendor-specific DT property is still better than messing up the
> device separation in the device tree. The same "tcsr-base" reg would
> also appear on the actual tcsr syscon device tree node. Having two
> device tree nodes with the same reg region is generally not valid.
>
> Something like qcom,eud-sec-reg = <&tcsr_reg yyyy> would at least make
> clear that this points into a region that is shared between multiple
> different devices, while adding it as reg suggests that TCSR belongs
> exclusively to EUD.

I understand your point but since for sm6115 / qcm2290 devices TCSR is
not used for any other purpose than EUD, I still think introducing a
new soc / vendor specific dt-property might be an overkill for this
changeset.

Thanks,
Bhupesh
Konrad Dybcio July 17, 2023, 8:19 p.m. UTC | #4
On 17.07.2023 22:09, Bhupesh Sharma wrote:
> On Mon, 17 Jul 2023 at 23:58, Stephan Gerhold <stephan@gerhold.net> wrote:
>>
>> On Mon, Jul 17, 2023 at 11:33:40PM +0530, Bhupesh Sharma wrote:
>>> On Mon, 17 Jul 2023 at 16:15, Stephan Gerhold <stephan@gerhold.net> wrote:
>>>>
>>>> On Mon, Jul 17, 2023 at 04:02:35PM +0530, Bhupesh Sharma wrote:
>>>>> Add the Embedded USB Debugger(EUD) device tree node for
>>>>> SM6115 / SM4250 SoC.
>>>>>
>>>>> The node contains EUD base register region, EUD mode manager
>>>>> register region and TCSR Base register region along with the
>>>>> interrupt entry.
>>>>>
>>>>> [...]
>>>>>
>>>>> Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
>>>>> Signed-off-by: Bhupesh Sharma <bhupesh.sharma@linaro.org>
>>>>> ---
>>>>>  arch/arm64/boot/dts/qcom/sm6115.dtsi | 50 ++++++++++++++++++++++++++++
>>>>>  1 file changed, 50 insertions(+)
>>>>>
>>>>> diff --git a/arch/arm64/boot/dts/qcom/sm6115.dtsi b/arch/arm64/boot/dts/qcom/sm6115.dtsi
>>>>> index 839c603512403..db45337c1082c 100644
>>>>> --- a/arch/arm64/boot/dts/qcom/sm6115.dtsi
>>>>> +++ b/arch/arm64/boot/dts/qcom/sm6115.dtsi
>>>>> [...]
>>>>> @@ -789,6 +801,37 @@ gcc: clock-controller@1400000 {
>>>>>                       #power-domain-cells = <1>;
>>>>>               };
>>>>>
>>>>> +             eud: eud@1610000 {
>>>>> +                     compatible = "qcom,sm6115-eud", "qcom,eud";
>>>>> +                     reg = <0x0 0x01610000 0x0 0x2000>,
>>>>> +                           <0x0 0x01612000 0x0 0x1000>,
>>>>> +                           <0x0 0x003c0000 0x0 0x40000>;
>>>>> +                     reg-names = "eud-base", "eud-mode-mgr", "tcsr-base";
>>>>
>>>> TCSR is a separate hardware block unrelated to the EUD. IMHO it
>>>> shouldn't be listed as "reg" here.
>>>>
>>>> Typically we describe it as syscon and then reference it from other
>>>> nodes. See e.g. sm8450.dtsi "tcsr: syscon@1fc0000" referenced in &scm
>>>> "qcom,dload-mode = <&tcsr 0x13000>". This is pretty much exactly the
>>>> same use case as you have. It also uses this to write something with
>>>> qcom_scm_io_writel() at the end.
>>>
>>> That was discussed a bit during v1 patchset review. Basically, if we
>>> use a tcsr syscon approach here, we will need to define a 'qcom,xx'
>>> vendor specific dt-property and use something like this in the eud
>>> node:
>>>
>>> qcom,eud-sec-reg = <&tcsr_reg yyyy>
>>>
>>> which would be then used by the eud driver (via
>>> syscon_regmap_lookup_by_phandle()).
>>>
>>> But for sm6115 / qcm2290 this would be an over complicated solution as
>>> normally the eud driver (say sc7280) doesn't need tcsr based secure
>>> mode manager access. So defining a new soc / vendor specific
>>> dt-property might be an overkill.
>>>
>>
>> IMO a vendor-specific DT property is still better than messing up the
>> device separation in the device tree. The same "tcsr-base" reg would
>> also appear on the actual tcsr syscon device tree node. Having two
>> device tree nodes with the same reg region is generally not valid.
>>
>> Something like qcom,eud-sec-reg = <&tcsr_reg yyyy> would at least make
>> clear that this points into a region that is shared between multiple
>> different devices, while adding it as reg suggests that TCSR belongs
>> exclusively to EUD.
> 
> I understand your point but since for sm6115 / qcm2290 devices TCSR is
> not used for any other purpose than EUD, I still think introducing a
> new soc / vendor specific dt-property might be an overkill for this
> changeset.
Untrue, there's some mumblings around the PHY properties and PSHOLD.
I think Stephan may be correct here.

Konrad
> 
> Thanks,
> Bhupesh
Bhupesh Sharma July 17, 2023, 8:22 p.m. UTC | #5
On Tue, 18 Jul 2023 at 01:49, Konrad Dybcio <konrad.dybcio@linaro.org> wrote:
>
> On 17.07.2023 22:09, Bhupesh Sharma wrote:
> > On Mon, 17 Jul 2023 at 23:58, Stephan Gerhold <stephan@gerhold.net> wrote:
> >>
> >> On Mon, Jul 17, 2023 at 11:33:40PM +0530, Bhupesh Sharma wrote:
> >>> On Mon, 17 Jul 2023 at 16:15, Stephan Gerhold <stephan@gerhold.net> wrote:
> >>>>
> >>>> On Mon, Jul 17, 2023 at 04:02:35PM +0530, Bhupesh Sharma wrote:
> >>>>> Add the Embedded USB Debugger(EUD) device tree node for
> >>>>> SM6115 / SM4250 SoC.
> >>>>>
> >>>>> The node contains EUD base register region, EUD mode manager
> >>>>> register region and TCSR Base register region along with the
> >>>>> interrupt entry.
> >>>>>
> >>>>> [...]
> >>>>>
> >>>>> Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
> >>>>> Signed-off-by: Bhupesh Sharma <bhupesh.sharma@linaro.org>
> >>>>> ---
> >>>>>  arch/arm64/boot/dts/qcom/sm6115.dtsi | 50 ++++++++++++++++++++++++++++
> >>>>>  1 file changed, 50 insertions(+)
> >>>>>
> >>>>> diff --git a/arch/arm64/boot/dts/qcom/sm6115.dtsi b/arch/arm64/boot/dts/qcom/sm6115.dtsi
> >>>>> index 839c603512403..db45337c1082c 100644
> >>>>> --- a/arch/arm64/boot/dts/qcom/sm6115.dtsi
> >>>>> +++ b/arch/arm64/boot/dts/qcom/sm6115.dtsi
> >>>>> [...]
> >>>>> @@ -789,6 +801,37 @@ gcc: clock-controller@1400000 {
> >>>>>                       #power-domain-cells = <1>;
> >>>>>               };
> >>>>>
> >>>>> +             eud: eud@1610000 {
> >>>>> +                     compatible = "qcom,sm6115-eud", "qcom,eud";
> >>>>> +                     reg = <0x0 0x01610000 0x0 0x2000>,
> >>>>> +                           <0x0 0x01612000 0x0 0x1000>,
> >>>>> +                           <0x0 0x003c0000 0x0 0x40000>;
> >>>>> +                     reg-names = "eud-base", "eud-mode-mgr", "tcsr-base";
> >>>>
> >>>> TCSR is a separate hardware block unrelated to the EUD. IMHO it
> >>>> shouldn't be listed as "reg" here.
> >>>>
> >>>> Typically we describe it as syscon and then reference it from other
> >>>> nodes. See e.g. sm8450.dtsi "tcsr: syscon@1fc0000" referenced in &scm
> >>>> "qcom,dload-mode = <&tcsr 0x13000>". This is pretty much exactly the
> >>>> same use case as you have. It also uses this to write something with
> >>>> qcom_scm_io_writel() at the end.
> >>>
> >>> That was discussed a bit during v1 patchset review. Basically, if we
> >>> use a tcsr syscon approach here, we will need to define a 'qcom,xx'
> >>> vendor specific dt-property and use something like this in the eud
> >>> node:
> >>>
> >>> qcom,eud-sec-reg = <&tcsr_reg yyyy>
> >>>
> >>> which would be then used by the eud driver (via
> >>> syscon_regmap_lookup_by_phandle()).
> >>>
> >>> But for sm6115 / qcm2290 this would be an over complicated solution as
> >>> normally the eud driver (say sc7280) doesn't need tcsr based secure
> >>> mode manager access. So defining a new soc / vendor specific
> >>> dt-property might be an overkill.
> >>>
> >>
> >> IMO a vendor-specific DT property is still better than messing up the
> >> device separation in the device tree. The same "tcsr-base" reg would
> >> also appear on the actual tcsr syscon device tree node. Having two
> >> device tree nodes with the same reg region is generally not valid.
> >>
> >> Something like qcom,eud-sec-reg = <&tcsr_reg yyyy> would at least make
> >> clear that this points into a region that is shared between multiple
> >> different devices, while adding it as reg suggests that TCSR belongs
> >> exclusively to EUD.
> >
> > I understand your point but since for sm6115 / qcm2290 devices TCSR is
> > not used for any other purpose than EUD, I still think introducing a
> > new soc / vendor specific dt-property might be an overkill for this
> > changeset.
> Untrue, there's some mumblings around the PHY properties and PSHOLD.
> I think Stephan may be correct here.

Can you share the links to those discussions?

Thanks,
Bhupesh
Konrad Dybcio July 17, 2023, 8:24 p.m. UTC | #6
On 17.07.2023 22:22, Bhupesh Sharma wrote:
> On Tue, 18 Jul 2023 at 01:49, Konrad Dybcio <konrad.dybcio@linaro.org> wrote:
>>
>> On 17.07.2023 22:09, Bhupesh Sharma wrote:
>>> On Mon, 17 Jul 2023 at 23:58, Stephan Gerhold <stephan@gerhold.net> wrote:
>>>>
>>>> On Mon, Jul 17, 2023 at 11:33:40PM +0530, Bhupesh Sharma wrote:
>>>>> On Mon, 17 Jul 2023 at 16:15, Stephan Gerhold <stephan@gerhold.net> wrote:
>>>>>>
>>>>>> On Mon, Jul 17, 2023 at 04:02:35PM +0530, Bhupesh Sharma wrote:
>>>>>>> Add the Embedded USB Debugger(EUD) device tree node for
>>>>>>> SM6115 / SM4250 SoC.
>>>>>>>
>>>>>>> The node contains EUD base register region, EUD mode manager
>>>>>>> register region and TCSR Base register region along with the
>>>>>>> interrupt entry.
>>>>>>>
>>>>>>> [...]
>>>>>>>
>>>>>>> Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
>>>>>>> Signed-off-by: Bhupesh Sharma <bhupesh.sharma@linaro.org>
>>>>>>> ---
>>>>>>>  arch/arm64/boot/dts/qcom/sm6115.dtsi | 50 ++++++++++++++++++++++++++++
>>>>>>>  1 file changed, 50 insertions(+)
>>>>>>>
>>>>>>> diff --git a/arch/arm64/boot/dts/qcom/sm6115.dtsi b/arch/arm64/boot/dts/qcom/sm6115.dtsi
>>>>>>> index 839c603512403..db45337c1082c 100644
>>>>>>> --- a/arch/arm64/boot/dts/qcom/sm6115.dtsi
>>>>>>> +++ b/arch/arm64/boot/dts/qcom/sm6115.dtsi
>>>>>>> [...]
>>>>>>> @@ -789,6 +801,37 @@ gcc: clock-controller@1400000 {
>>>>>>>                       #power-domain-cells = <1>;
>>>>>>>               };
>>>>>>>
>>>>>>> +             eud: eud@1610000 {
>>>>>>> +                     compatible = "qcom,sm6115-eud", "qcom,eud";
>>>>>>> +                     reg = <0x0 0x01610000 0x0 0x2000>,
>>>>>>> +                           <0x0 0x01612000 0x0 0x1000>,
>>>>>>> +                           <0x0 0x003c0000 0x0 0x40000>;
>>>>>>> +                     reg-names = "eud-base", "eud-mode-mgr", "tcsr-base";
>>>>>>
>>>>>> TCSR is a separate hardware block unrelated to the EUD. IMHO it
>>>>>> shouldn't be listed as "reg" here.
>>>>>>
>>>>>> Typically we describe it as syscon and then reference it from other
>>>>>> nodes. See e.g. sm8450.dtsi "tcsr: syscon@1fc0000" referenced in &scm
>>>>>> "qcom,dload-mode = <&tcsr 0x13000>". This is pretty much exactly the
>>>>>> same use case as you have. It also uses this to write something with
>>>>>> qcom_scm_io_writel() at the end.
>>>>>
>>>>> That was discussed a bit during v1 patchset review. Basically, if we
>>>>> use a tcsr syscon approach here, we will need to define a 'qcom,xx'
>>>>> vendor specific dt-property and use something like this in the eud
>>>>> node:
>>>>>
>>>>> qcom,eud-sec-reg = <&tcsr_reg yyyy>
>>>>>
>>>>> which would be then used by the eud driver (via
>>>>> syscon_regmap_lookup_by_phandle()).
>>>>>
>>>>> But for sm6115 / qcm2290 this would be an over complicated solution as
>>>>> normally the eud driver (say sc7280) doesn't need tcsr based secure
>>>>> mode manager access. So defining a new soc / vendor specific
>>>>> dt-property might be an overkill.
>>>>>
>>>>
>>>> IMO a vendor-specific DT property is still better than messing up the
>>>> device separation in the device tree. The same "tcsr-base" reg would
>>>> also appear on the actual tcsr syscon device tree node. Having two
>>>> device tree nodes with the same reg region is generally not valid.
>>>>
>>>> Something like qcom,eud-sec-reg = <&tcsr_reg yyyy> would at least make
>>>> clear that this points into a region that is shared between multiple
>>>> different devices, while adding it as reg suggests that TCSR belongs
>>>> exclusively to EUD.
>>>
>>> I understand your point but since for sm6115 / qcm2290 devices TCSR is
>>> not used for any other purpose than EUD, I still think introducing a
>>> new soc / vendor specific dt-property might be an overkill for this
>>> changeset.
>> Untrue, there's some mumblings around the PHY properties and PSHOLD.
>> I think Stephan may be correct here.
> 
> Can you share the links to those discussions?
It just seemed off to me that TCSR was not used by anything else (even
from Linux, it would obviously be used by something else higher up in
the boot chain as it contains various configuration registers), so I
took a glance at the downstream device tree and I noticed there are
more users.

Konrad
Bhupesh Sharma July 17, 2023, 8:41 p.m. UTC | #7
On Tue, 18 Jul 2023 at 01:54, Konrad Dybcio <konrad.dybcio@linaro.org> wrote:
>
> On 17.07.2023 22:22, Bhupesh Sharma wrote:
> > On Tue, 18 Jul 2023 at 01:49, Konrad Dybcio <konrad.dybcio@linaro.org> wrote:
> >>
> >> On 17.07.2023 22:09, Bhupesh Sharma wrote:
> >>> On Mon, 17 Jul 2023 at 23:58, Stephan Gerhold <stephan@gerhold.net> wrote:
> >>>>
> >>>> On Mon, Jul 17, 2023 at 11:33:40PM +0530, Bhupesh Sharma wrote:
> >>>>> On Mon, 17 Jul 2023 at 16:15, Stephan Gerhold <stephan@gerhold.net> wrote:
> >>>>>>
> >>>>>> On Mon, Jul 17, 2023 at 04:02:35PM +0530, Bhupesh Sharma wrote:
> >>>>>>> Add the Embedded USB Debugger(EUD) device tree node for
> >>>>>>> SM6115 / SM4250 SoC.
> >>>>>>>
> >>>>>>> The node contains EUD base register region, EUD mode manager
> >>>>>>> register region and TCSR Base register region along with the
> >>>>>>> interrupt entry.
> >>>>>>>
> >>>>>>> [...]
> >>>>>>>
> >>>>>>> Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
> >>>>>>> Signed-off-by: Bhupesh Sharma <bhupesh.sharma@linaro.org>
> >>>>>>> ---
> >>>>>>>  arch/arm64/boot/dts/qcom/sm6115.dtsi | 50 ++++++++++++++++++++++++++++
> >>>>>>>  1 file changed, 50 insertions(+)
> >>>>>>>
> >>>>>>> diff --git a/arch/arm64/boot/dts/qcom/sm6115.dtsi b/arch/arm64/boot/dts/qcom/sm6115.dtsi
> >>>>>>> index 839c603512403..db45337c1082c 100644
> >>>>>>> --- a/arch/arm64/boot/dts/qcom/sm6115.dtsi
> >>>>>>> +++ b/arch/arm64/boot/dts/qcom/sm6115.dtsi
> >>>>>>> [...]
> >>>>>>> @@ -789,6 +801,37 @@ gcc: clock-controller@1400000 {
> >>>>>>>                       #power-domain-cells = <1>;
> >>>>>>>               };
> >>>>>>>
> >>>>>>> +             eud: eud@1610000 {
> >>>>>>> +                     compatible = "qcom,sm6115-eud", "qcom,eud";
> >>>>>>> +                     reg = <0x0 0x01610000 0x0 0x2000>,
> >>>>>>> +                           <0x0 0x01612000 0x0 0x1000>,
> >>>>>>> +                           <0x0 0x003c0000 0x0 0x40000>;
> >>>>>>> +                     reg-names = "eud-base", "eud-mode-mgr", "tcsr-base";
> >>>>>>
> >>>>>> TCSR is a separate hardware block unrelated to the EUD. IMHO it
> >>>>>> shouldn't be listed as "reg" here.
> >>>>>>
> >>>>>> Typically we describe it as syscon and then reference it from other
> >>>>>> nodes. See e.g. sm8450.dtsi "tcsr: syscon@1fc0000" referenced in &scm
> >>>>>> "qcom,dload-mode = <&tcsr 0x13000>". This is pretty much exactly the
> >>>>>> same use case as you have. It also uses this to write something with
> >>>>>> qcom_scm_io_writel() at the end.
> >>>>>
> >>>>> That was discussed a bit during v1 patchset review. Basically, if we
> >>>>> use a tcsr syscon approach here, we will need to define a 'qcom,xx'
> >>>>> vendor specific dt-property and use something like this in the eud
> >>>>> node:
> >>>>>
> >>>>> qcom,eud-sec-reg = <&tcsr_reg yyyy>
> >>>>>
> >>>>> which would be then used by the eud driver (via
> >>>>> syscon_regmap_lookup_by_phandle()).
> >>>>>
> >>>>> But for sm6115 / qcm2290 this would be an over complicated solution as
> >>>>> normally the eud driver (say sc7280) doesn't need tcsr based secure
> >>>>> mode manager access. So defining a new soc / vendor specific
> >>>>> dt-property might be an overkill.
> >>>>>
> >>>>
> >>>> IMO a vendor-specific DT property is still better than messing up the
> >>>> device separation in the device tree. The same "tcsr-base" reg would
> >>>> also appear on the actual tcsr syscon device tree node. Having two
> >>>> device tree nodes with the same reg region is generally not valid.
> >>>>
> >>>> Something like qcom,eud-sec-reg = <&tcsr_reg yyyy> would at least make
> >>>> clear that this points into a region that is shared between multiple
> >>>> different devices, while adding it as reg suggests that TCSR belongs
> >>>> exclusively to EUD.
> >>>
> >>> I understand your point but since for sm6115 / qcm2290 devices TCSR is
> >>> not used for any other purpose than EUD, I still think introducing a
> >>> new soc / vendor specific dt-property might be an overkill for this
> >>> changeset.
> >> Untrue, there's some mumblings around the PHY properties and PSHOLD.
> >> I think Stephan may be correct here.
> >
> > Can you share the links to those discussions?
> It just seemed off to me that TCSR was not used by anything else (even
> from Linux, it would obviously be used by something else higher up in
> the boot chain as it contains various configuration registers), so I
> took a glance at the downstream device tree and I noticed there are
> more users.

Ok, let me recheck the downstream code and come back.

Thanks,
Bhupesh