Skip to contentSkip to conversation

Enable EUD on Qualcomm sm8450 SoC

PATCH NAK Elson Roy Serrao 8 participants 35 messages Jul 30, 2024 – Jan 27, 2025

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover Enable EUD on Qualcomm sm8450 SoC

The Embedded USB Debugger (EUD) is a mini High-Speed USB on-chip hub to support the USB-based debug and trace capabilities on Qualcomm devices. The current implementation lacks in below aspects that are needed for proper EUD functionality.

1.) HS-Phy control: EUD being a HS hub needs HS-Phy support for it's
operation. Hence EUD module should enable/disable HS-phy accordingly.

2.) Proper routing of USB role switch notifications: EUD hub is physically
present in between the USB connector and the USB controller. So the usb role switch notifications originating from the connector should route through EUD. EUD also relies on role switch notifications to communicate with the USB, regarding EUD attach/detach events.

This series aims at implementing the above aspects to enable EUD on Qualcomm sm8450 SoC.

Elson Roy Serrao (8):
dt-bindings: soc: qcom: eud: Add phy related bindings
dt-bindings: soc: qcom: eud: Add usb role switch property
dt-bindings: soc: qcom: eud: Add compatible for sm8450
arm64: dts: qcom: sm8450: Add EUD node
arm64: dts: qcom: Enable EUD on sm8450 hdk
usb: misc: eud: Add High-Speed Phy control for EUD operations
usb: misc: eud: Handle usb role switch notifications
usb: misc: eud: Add compatible for sm8450

 .../bindings/soc/qcom/qcom,eud.yaml           |  17 +++
 arch/arm64/boot/dts/qcom/sm8450-hdk.dts       |  15 ++-
 arch/arm64/boot/dts/qcom/sm8450.dtsi          |  29 ++++
 drivers/usb/misc/qcom_eud.c                   | 125 +++++++++++++++---
 4 files changed, 164 insertions(+), 22 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/8 dt-bindings: soc: qcom: eud: Add phy related bindings

Embedded USB Debugger(EUD) being a High-Speed USB hub needs HS-Phy support for it's operation. Hence document phy bindings to support this.

---
 .../devicetree/bindings/soc/qcom/qcom,eud.yaml       | 12 ++++++++++++
 1 file changed, 12 insertions(+)
Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml +12 -0
index f2c5ec7e6437..fca5b608ec63 100644
@@ -29,6 +29,14 @@ properties:
     description: EUD interrupt
     maxItems: 1
 
+  phys:
+    items:
+      - description: USB2/HS PHY needed for EUD functionality
+
+  phy-names:
+    items:
+      - const: usb2-phy
+
   ports:
     $ref: /schemas/graph.yaml#/properties/ports
     description:
@@ -48,6 +56,8 @@ properties:
 required:
   - compatible
   - reg
+  - phys
+  - phy-names
   - ports
 
 additionalProperties: false
@@ -58,6 +68,8 @@ examples:
            compatible = "qcom,sc7280-eud", "qcom,eud";
            reg = <0x88e0000 0x2000>,
                  <0x88e2000 0x1000>;
+           phys = <&usb_2_hsphy>;
+           phy-names = "usb2-phy";
 
            ports {
                    #address-cells = <1>;
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH 1/8] dt-bindings: soc: qcom: eud: Add phy related bindings

Quoted 5 lines · Elson Roy Serrao

Embedded USB Debugger(EUD) being a High-Speed USB hub needs HS-Phy support for it's operation. Hence document phy bindings to support this.

A nit, subject: drop second/last, redundant "bindings". The "dt-bindings" prefix is already stating that these are bindings. See also:
https://elixir.bootlin.com/linux/v6.7-rc8/source/Documentation/devicetree/bindings/submitting-patches.rst#L18

Quoted 24 lines
---
 .../devicetree/bindings/soc/qcom/qcom,eud.yaml       | 12 ++++++++++++
 1 file changed, 12 insertions(+)
Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml +8 -0
index f2c5ec7e6437..fca5b608ec63 100644
@@ -29,6 +29,14 @@ properties:
     description: EUD interrupt
     maxItems: 1
 
+  phys:
+    items:
+      - description: USB2/HS PHY needed for EUD functionality
+
+  phy-names:
+    items:
+      - const: usb2-phy
+
   ports:
     $ref: /schemas/graph.yaml#/properties/ports
     description:

Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml properties: · line 60

Quoted 5 lines
Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml +2 -0
@@ -48,6 +56,8 @@ properties:
 required:
   - compatible
   - reg
+  - phys
+  - phy-names

That's an ABI break and nothing in commit msg justified it.

Best regards,
Krzysztof

#3 lore raw

Re: [PATCH 1/8] dt-bindings: soc: qcom: eud: Add phy related bindings

Quoted 5 lines · Krzysztof Kozlowski
Quoted 4 lines · Elson Roy Serrao

Embedded USB Debugger(EUD) being a High-Speed USB hub needs HS-Phy support for it's operation. Hence document phy bindings to support this.

Quoted 7 lines
Quoted 1 line

A nit, subject: drop second/last, redundant "bindings". The "dt-bindings" prefix is already stating that these are bindings. See also:
https://elixir.bootlin.com/linux/v6.7-rc8/source/Documentation/devicetree/bindings/submitting-patches.rst#L18

Ack

Quoted 23 lines
Quoted 23 lines
---
 .../devicetree/bindings/soc/qcom/qcom,eud.yaml       | 12 ++++++++++++
 1 file changed, 12 insertions(+)
Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml +8 -0
index f2c5ec7e6437..fca5b608ec63 100644
@@ -29,6 +29,14 @@ properties:
     description: EUD interrupt
     maxItems: 1
 
+  phys:
+    items:
+      - description: USB2/HS PHY needed for EUD functionality
+
+  phy-names:
+    items:
+      - const: usb2-phy
+
   ports:
     $ref: /schemas/graph.yaml#/properties/ports
     description:
Quoted 9 lines

Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml properties: · line 60

Quoted 6 lines
Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml +2 -0
@@ -48,6 +56,8 @@ properties:
 required:
   - compatible
   - reg
+  - phys
+  - phy-names

That's an ABI break and nothing in commit msg justified it.

Hi Krzysztof

Thank you for the review.
I see that the only user for EUD as of now is QC sc7280 SoC where phy property is missing and EUD node is disabled. As described in my cover letter, HS phy support is needed for EUD functionality and this is applicable to all SoCs where EUD is to be enabled. Hence phy would be a required property.
Given that the changes in this series are directly applicable to sc7280 as well, I will re-enable/rectify EUD feature on sc7280 SoC first, by adhering it to this binding requirement. That would address the ABI break.
Once the base framework is set I shall extend it to sm8450 SoC.

Regards
Elson

#4 lore raw

Re: [PATCH 1/8] dt-bindings: soc: qcom: eud: Add phy related bindings

Quoted 49 lines · Elson Serrao
Quoted 5 lines · Krzysztof Kozlowski
Quoted 4 lines · Elson Roy Serrao

Embedded USB Debugger(EUD) being a High-Speed USB hub needs HS-Phy support for it's operation. Hence document phy bindings to support this.

Quoted 7 lines
Quoted 1 line

A nit, subject: drop second/last, redundant "bindings". The "dt-bindings" prefix is already stating that these are bindings. See also:
https://elixir.bootlin.com/linux/v6.7-rc8/source/Documentation/devicetree/bindings/submitting-patches.rst#L18

Ack

Quoted 23 lines
Quoted 23 lines
---
 .../devicetree/bindings/soc/qcom/qcom,eud.yaml       | 12 ++++++++++++
 1 file changed, 12 insertions(+)
Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml +8 -0
index f2c5ec7e6437..fca5b608ec63 100644
@@ -29,6 +29,14 @@ properties:
     description: EUD interrupt
     maxItems: 1
 
+  phys:
+    items:
+      - description: USB2/HS PHY needed for EUD functionality
+
+  phy-names:
+    items:
+      - const: usb2-phy
+
   ports:
     $ref: /schemas/graph.yaml#/properties/ports
     description:
Quoted 9 lines

Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml properties: · line 60

Quoted 6 lines
Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml +2 -0
@@ -48,6 +56,8 @@ properties:
 required:
   - compatible
   - reg
+  - phys
+  - phy-names

That's an ABI break and nothing in commit msg justified it.

Quoted 4 lines

Hi Krzysztof

Thank you for the review.
I see that the only user for EUD as of now is QC sc7280 SoC where phy property

Did you ask all customers and all users of Linux kernel?

Quoted 3 lines

is missing and EUD node is disabled. As described in my cover letter, HS phy support is needed for EUD functionality and this is applicable to all SoCs where EUD is to be enabled. Hence phy would be a required property.

Nothing in commit msg explained that, but I have a bit hard time to believe that this never worked. If that's the case, say it explicitly in commit msg - this was always broken.

Quoted 3 lines

Given that the changes in this series are directly applicable to sc7280 as well, I will re-enable/rectify EUD feature on sc7280 SoC first, by adhering it to this binding requirement. That would address the ABI break.

I don't understand what you are saying here.

Quoted 1 line

Once the base framework is set I shall extend it to sm8450 SoC.

Best regards,
Krzysztof

#5 lore raw

Re: [PATCH 1/8] dt-bindings: soc: qcom: eud: Add phy related bindings

Quoted 50 lines · Krzysztof Kozlowski
Quoted 49 lines · Elson Serrao
Quoted 5 lines · Krzysztof Kozlowski
Quoted 4 lines · Elson Roy Serrao

Embedded USB Debugger(EUD) being a High-Speed USB hub needs HS-Phy support for it's operation. Hence document phy bindings to support this.

Quoted 7 lines
Quoted 1 line

A nit, subject: drop second/last, redundant "bindings". The "dt-bindings" prefix is already stating that these are bindings. See also:
https://elixir.bootlin.com/linux/v6.7-rc8/source/Documentation/devicetree/bindings/submitting-patches.rst#L18

Ack

Quoted 32 lines
Quoted 24 lines
---
 .../devicetree/bindings/soc/qcom/qcom,eud.yaml       | 12 ++++++++++++
 1 file changed, 12 insertions(+)
Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml +8 -0
index f2c5ec7e6437..fca5b608ec63 100644
@@ -29,6 +29,14 @@ properties:
     description: EUD interrupt
     maxItems: 1
 
+  phys:
+    items:
+      - description: USB2/HS PHY needed for EUD functionality
+
+  phy-names:
+    items:
+      - const: usb2-phy
+
   ports:
     $ref: /schemas/graph.yaml#/properties/ports
     description:

Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml properties: · line 60

Quoted 5 lines
Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml +2 -0
@@ -48,6 +56,8 @@ properties:
 required:
   - compatible
   - reg
+  - phys
+  - phy-names

That's an ABI break and nothing in commit msg justified it.

Quoted 6 lines
Quoted 4 lines

Hi Krzysztof

Thank you for the review.
I see that the only user for EUD as of now is QC sc7280 SoC where phy property

Did you ask all customers and all users of Linux kernel?

Unfortunately, the PDF agrees - the current description is inherently incomplete and the driver seems to have been upstreamed in a rather "i need this specific part of it for my usecase" manner..

The driver must be aware of all USB state changes (as EUD is essentially a mux+hub sitting between the PHYs and the USB controllers).

Additionally, AFAICU, all device-mode-capable USB ports may potentially be used for debug purposes (one at a time), so it's not just a matter of a single controller here. Plug events / their suspend state must be monitored to program the EUD (which again, sits in the middle of all this) in a specific manner.

EUD is present on all non-ancient SoCs and by default it's on in bypass mode, so you can ignore its existence. That is, unless you want to use the features it provides, which we absolutely do.

Quoted 7 lines
Quoted 3 lines

is missing and EUD node is disabled. As described in my cover letter, HS phy support is needed for EUD functionality and this is applicable to all SoCs where EUD is to be enabled. Hence phy would be a required property.

Nothing in commit msg explained that, but I have a bit hard time to believe that this never worked. If that's the case, say it explicitly in commit msg - this was always broken.

Even if it does work, it does so on a specific class of boards, relying on specific setup from a previous stage bootloader.

Quoted 7 lines
Quoted 3 lines

Given that the changes in this series are directly applicable to sc7280 as well, I will re-enable/rectify EUD feature on sc7280 SoC first, by adhering it to this binding requirement. That would address the ABI break.

I don't understand what you are saying here.

Quoted 1 line

Once the base framework is set I shall extend it to sm8450 SoC.

tldr, we should fix both the bindings and the 7280 dt for it

Konrad

#6 lore raw

Re: [PATCH 1/8] dt-bindings: soc: qcom: eud: Add phy related bindings

Quoted 89 lines · Konrad Dybcio
Quoted 50 lines · Krzysztof Kozlowski
Quoted 49 lines · Elson Serrao
Quoted 5 lines · Krzysztof Kozlowski
Quoted 4 lines · Elson Roy Serrao

Embedded USB Debugger(EUD) being a High-Speed USB hub needs HS-Phy support for it's operation. Hence document phy bindings to support this.

Quoted 7 lines
Quoted 1 line

A nit, subject: drop second/last, redundant "bindings". The "dt-bindings" prefix is already stating that these are bindings. See also:
https://elixir.bootlin.com/linux/v6.7-rc8/source/Documentation/devicetree/bindings/submitting-patches.rst#L18

Ack

Quoted 32 lines
Quoted 24 lines
---
 .../devicetree/bindings/soc/qcom/qcom,eud.yaml       | 12 ++++++++++++
 1 file changed, 12 insertions(+)
Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml +8 -0
index f2c5ec7e6437..fca5b608ec63 100644
@@ -29,6 +29,14 @@ properties:
     description: EUD interrupt
     maxItems: 1
 
+  phys:
+    items:
+      - description: USB2/HS PHY needed for EUD functionality
+
+  phy-names:
+    items:
+      - const: usb2-phy
+
   ports:
     $ref: /schemas/graph.yaml#/properties/ports
     description:

Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml properties: · line 60

Quoted 5 lines
Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml +2 -0
@@ -48,6 +56,8 @@ properties:
 required:
   - compatible
   - reg
+  - phys
+  - phy-names

That's an ABI break and nothing in commit msg justified it.

Quoted 6 lines
Quoted 4 lines

Hi Krzysztof

Thank you for the review.
I see that the only user for EUD as of now is QC sc7280 SoC where phy property

Did you ask all customers and all users of Linux kernel?

Unfortunately, the PDF agrees - the current description is inherently incomplete and the driver seems to have been upstreamed in a rather "i need this specific part of it for my usecase" manner..

The driver must be aware of all USB state changes (as EUD is essentially a mux+hub sitting between the PHYs and the USB controllers).

Additionally, AFAICU, all device-mode-capable USB ports may potentially be used for debug purposes (one at a time), so it's not just a matter of a single controller here. Plug events / their suspend state must be monitored to program the EUD (which again, sits in the middle of all this) in a specific manner.

EUD is present on all non-ancient SoCs and by default it's on in bypass mode, so you can ignore its existence. That is, unless you want to use the features it provides, which we absolutely do.

Quoted 7 lines
Quoted 3 lines

is missing and EUD node is disabled. As described in my cover letter, HS phy support is needed for EUD functionality and this is applicable to all SoCs where EUD is to be enabled. Hence phy would be a required property.

Nothing in commit msg explained that, but I have a bit hard time to believe that this never worked. If that's the case, say it explicitly in commit msg - this was always broken.

Even if it does work, it does so on a specific class of boards, relying on specific setup from a previous stage bootloader.

Quoted 4 lines
Quoted 3 lines

Given that the changes in this series are directly applicable to sc7280 as well, I will re-enable/rectify EUD feature on sc7280 SoC first, by adhering it to this binding requirement. That would address the ABI break.

Quoted 5 lines
Quoted 3 lines

I don't understand what you are saying here.

Quoted 1 line

Once the base framework is set I shall extend it to sm8450 SoC.

tldr, we should fix both the bindings and the 7280 dt for it

On top of these comments, reg should be split up into three regions too, if we want to be docs-accurate..

Konrad

#7 lore raw

PATCH 2/8 dt-bindings: soc: qcom: eud: Add usb role switch property

In reply to Elson Roy Serrao

EUD hub is physically present in between the USB connector and the USB controller. So the role switch notifications originating from the connector should route through EUD. Hence to interpret the usb role assigned by the connector, role switch property is needed.

---
 Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml +4 -0
index fca5b608ec63..0fa4608568d0 100644
@@ -37,6 +37,10 @@ properties:
     items:
       - const: usb2-phy
 
+  usb-role-switch:
+    $ref: /schemas/types.yaml#/definitions/flag
+    description: Support role switch.
+
   ports:
     $ref: /schemas/graph.yaml#/properties/ports
     description:
Signature · 1 line
2.17.1
#8 lore raw

Re: [PATCH 2/8] dt-bindings: soc: qcom: eud: Add usb role switch property

Quoted 15 lines · Elson Roy Serrao

EUD hub is physically present in between the USB connector and the USB controller. So the role switch notifications originating from the connector should route through EUD. Hence to interpret the usb role assigned by the connector, role switch property is needed.

---
 Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml +0 -0
index fca5b608ec63..0fa4608568d0 100644

Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml properties: · line 42

Quoted 6 lines
Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml +3 -0
@@ -37,6 +37,10 @@ properties:
     items:
       - const: usb2-phy
 
+  usb-role-switch:
+    $ref: /schemas/types.yaml#/definitions/flag
+    description: Support role switch.

So both EUD and DWC3 controller (as this binding states) are role switching?

Best regards,
Krzysztof

#9 lore raw

Re: [PATCH 2/8] dt-bindings: soc: qcom: eud: Add usb role switch property

Quoted 19 lines · Krzysztof Kozlowski
Quoted 18 lines · Elson Roy Serrao

EUD hub is physically present in between the USB connector and the USB controller. So the role switch notifications originating from the connector should route through EUD. Hence to interpret the usb role assigned by the connector, role switch property is needed.

---
 Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml +0 -0
index fca5b608ec63..0fa4608568d0 100644
@@ -37,6 +37,10 @@ properties:
     items:
       - const: usb2-phy
 
Quoted 6 lines

Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml properties: · line 42

Quoted 3 lines
Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml +3 -0
+  usb-role-switch:
+    $ref: /schemas/types.yaml#/definitions/flag
+    description: Support role switch.

So both EUD and DWC3 controller (as this binding states) are role switching?

Yes. EUD would receive roles from the connector and relay it to the DWC3 controller. In addition to these roles, the DWC3 controller would also receive roles from EUD itself (related to USB attach/detach events).

Thanks
Elson

#10 lore raw

Re: [PATCH 2/8] dt-bindings: soc: qcom: eud: Add usb role switch property

Quoted 29 lines · Elson Serrao
Quoted 19 lines · Krzysztof Kozlowski
Quoted 18 lines · Elson Roy Serrao

EUD hub is physically present in between the USB connector and the USB controller. So the role switch notifications originating from the connector should route through EUD. Hence to interpret the usb role assigned by the connector, role switch property is needed.

---
 Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml +0 -0
index fca5b608ec63..0fa4608568d0 100644
@@ -37,6 +37,10 @@ properties:
     items:
       - const: usb2-phy
 
Quoted 6 lines

Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml properties: · line 42

Quoted 3 lines
Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml +3 -0
+  usb-role-switch:
+    $ref: /schemas/types.yaml#/definitions/flag
+    description: Support role switch.

So both EUD and DWC3 controller (as this binding states) are role switching?

Quoted 2 lines

Yes. EUD would receive roles from the connector and relay it to the DWC3 controller. In addition to these roles, the DWC3 controller would also receive roles from EUD itself (related to USB attach/detach events).

Does not look right. Seems like you add something because it is easier to code in drivers.

Best regards,
Krzysztof

#11 lore raw

Re: [PATCH 2/8] dt-bindings: soc: qcom: eud: Add usb role switch property

Quoted 30 lines · Krzysztof Kozlowski
Quoted 29 lines · Elson Serrao
Quoted 25 lines · Krzysztof Kozlowski
Quoted 15 lines · Elson Roy Serrao

EUD hub is physically present in between the USB connector and the USB controller. So the role switch notifications originating from the connector should route through EUD. Hence to interpret the usb role assigned by the connector, role switch property is needed.

---
 Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml +0 -0
index fca5b608ec63..0fa4608568d0 100644

Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml properties: · line 42

Quoted 6 lines
Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml +3 -0
@@ -37,6 +37,10 @@ properties:
     items:
       - const: usb2-phy
 
+  usb-role-switch:
+    $ref: /schemas/types.yaml#/definitions/flag
+    description: Support role switch.

So both EUD and DWC3 controller (as this binding states) are role switching?

Quoted 5 lines
Quoted 2 lines

Yes. EUD would receive roles from the connector and relay it to the DWC3 controller. In addition to these roles, the DWC3 controller would also receive roles from EUD itself (related to USB attach/detach events).

Does not look right. Seems like you add something because it is easier to code in drivers.

Perhaps that's semantics.. EUD can be thought of as something approximating USB-C (very loosely). If you program it right, it exposes a USB hub full of """altmodes""" (debug components visible as separate USB peripherals, really)

We need it to know when the device is connected in USB device mode (vs host), so that we don't accidentally undermine the rest of the USB hardware by de-muxing the usb controller from a direct connection to the PHY.

Konrad

#12 lore raw

PATCH 3/8 dt-bindings: soc: qcom: eud: Add compatible for sm8450

In reply to Elson Roy Serrao

Document the EUD compatible for sm8450 SoC.

---
 Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml +1 -0
index 0fa4608568d0..d7a913bd5edb 100644
@@ -18,6 +18,7 @@ properties:
     items:
       - enum:
           - qcom,sc7280-eud
+          - qcom,sm8450-eud
       - const: qcom,eud
 
   reg:
Signature · 1 line
2.17.1
#13 lore raw

Re: [PATCH 3/8] dt-bindings: soc: qcom: eud: Add compatible for sm8450

Quoted 5 lines · Elson Roy Serrao

Document the EUD compatible for sm8450 SoC.

---
 Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml | 1 +

This should be squashed with the previous patches or the previous patches should explain why the properties are missing in existing binding, but everything was fine.

You add new device with all its new quirks or properties. Adding "compatible" alone is not a change itself.

Best regards,
Krzysztof

#14 lore raw

PATCH 4/8 arm64: dts: qcom: sm8450: Add EUD node

In reply to Elson Roy Serrao

Add a DT node to describe Embedded USB Debugger(EUD) module on sm8450 SoC.

---
 arch/arm64/boot/dts/qcom/sm8450.dtsi | 29 ++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
arch/arm64/boot/dts/qcom/sm8450.dtsi +29 -0
index 9bafb3b350ff..bcdf61223ff3 100644
@@ -4693,6 +4693,35 @@
 			};
 		};
 
+		eud: eud@88e0000 {
+			compatible = "qcom,sm8450-eud", "qcom,eud";
+			reg = <0 0x88e0000 0 0x2000>,
+			      <0 0x88e2000 0 0x1000>;
+			interrupts-extended = <&pdc 11 IRQ_TYPE_LEVEL_HIGH>;
+
+			phys = <&usb_1_hsphy>;
+			phy-names = "usb2-phy";
+
+			status = "disabled";
+
+			ports {
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				port@0 {
+					reg = <0>;
+					eud_ep: endpoint {
+					};
+				};
+
+				port@1 {
+					reg = <1>;
+					eud_con: endpoint {
+					};
+				};
+			};
+		};
+
 		nsp_noc: interconnect@320c0000 {
 			compatible = "qcom,sm8450-nsp-noc";
 			reg = <0 0x320c0000 0 0x10000>;
Signature · 1 line
2.17.1
#15 lore raw

PATCH 5/8 arm64: dts: qcom: Enable EUD on sm8450 hdk

In reply to Elson Roy Serrao

Enable EUD on sm8450 hdk and route the role switch endpoints accordingly.

---
 arch/arm64/boot/dts/qcom/sm8450-hdk.dts | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/sm8450-hdk.dts +14 -1
index a754b8fe9167..21a63ad81aac 100644
@@ -111,7 +111,7 @@
 					reg = <0>;
 
 					pmic_glink_hs_in: endpoint {
-						remote-endpoint = <&usb_1_dwc3_hs>;
+						remote-endpoint = <&eud_con>;
 					};
 				};
 
@@ -1102,9 +1102,22 @@
 };
 
 &usb_1_dwc3_hs {
+	remote-endpoint = <&eud_ep>;
+};
+
+&eud {
+	status = "okay";
+	usb-role-switch;
+};
+
+&eud_con {
 	remote-endpoint = <&pmic_glink_hs_in>;
 };
 
+&eud_ep {
+	remote-endpoint = <&usb_1_dwc3_hs>;
+};
+
 &usb_1_hsphy {
 	status = "okay";
 
Signature · 1 line
2.17.1
#16 lore raw

PATCH 6/8 usb: misc: eud: Add High-Speed Phy control for EUD operations

In reply to Elson Roy Serrao

The Embedded USB Debugger(EUD) is a HS-USB on-chip hub to support the debug and trace capabilities on Qualcomm devices. It is physically present in between the usb connector and the usb controller. Being a HS USB hub, it relies on HS Phy for its functionality. Add HS phy support in the eud driver and control the phy during eud enable/disable operations.

---
 drivers/usb/misc/qcom_eud.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
drivers/usb/misc/qcom_eud.c +35 -0
index 26e9b8749d8a..3de7d465912c 100644
@@ -11,6 +11,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/phy/phy.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/sysfs.h>
@@ -33,6 +34,7 @@
 struct eud_chip {
 	struct device			*dev;
 	struct usb_role_switch		*role_sw;
+	struct phy			*usb2_phy;
 	void __iomem			*base;
 	void __iomem			*mode_mgr;
 	unsigned int			int_status;
@@ -41,8 +43,35 @@ struct eud_chip {
 	bool				usb_attached;
 };
 
+static int eud_phy_enable(struct eud_chip *chip)
+{
+	int ret;
+
+	ret = phy_init(chip->usb2_phy);
+	if (ret)
+		return ret;
+
+	ret = phy_power_on(chip->usb2_phy);
+	if (ret)
+		phy_exit(chip->usb2_phy);
+
+	return ret;
+}
+
+static void eud_phy_disable(struct eud_chip *chip)
+{
+	phy_power_off(chip->usb2_phy);
+	phy_exit(chip->usb2_phy);
+}
+
 static int enable_eud(struct eud_chip *priv)
 {
+	int ret;
+
+	ret = eud_phy_enable(priv);
+	if (ret)
+		return ret;
+
 	writel(EUD_ENABLE, priv->base + EUD_REG_CSR_EUD_EN);
 	writel(EUD_INT_VBUS | EUD_INT_SAFE_MODE,
 			priv->base + EUD_REG_INT1_EN_MASK);
@@ -55,6 +84,7 @@ static void disable_eud(struct eud_chip *priv)
 {
 	writel(0, priv->base + EUD_REG_CSR_EUD_EN);
 	writel(0, priv->mode_mgr + EUD_REG_EUD_EN2);
+	eud_phy_disable(priv);
 }
 
 static ssize_t enable_show(struct device *dev,
@@ -186,6 +216,11 @@ static int eud_probe(struct platform_device *pdev)
 
 	chip->dev = &pdev->dev;
 
+	chip->usb2_phy = devm_phy_get(chip->dev, "usb2-phy");
+	if (IS_ERR(chip->usb2_phy))
+		return dev_err_probe(chip->dev, PTR_ERR(chip->usb2_phy),
+				     "no usb2 phy configured\n");
+
 	chip->role_sw = usb_role_switch_get(&pdev->dev);
 	if (IS_ERR(chip->role_sw))
 		return dev_err_probe(chip->dev, PTR_ERR(chip->role_sw),
Signature · 1 line
2.17.1
#17 lore raw

Re: [PATCH 6/8] usb: misc: eud: Add High-Speed Phy control for EUD operations

Quoted 7 lines · Elson Roy Serrao

The Embedded USB Debugger(EUD) is a HS-USB on-chip hub to support the debug and trace capabilities on Qualcomm devices. It is physically present in between the usb connector and the usb controller. Being a HS USB hub, it relies on HS Phy for its functionality. Add HS phy support in the eud driver and control the phy during eud enable/disable operations.

...

drivers/usb/misc/qcom_eud.c static int eud_probe(struct platform_device *pdev) · line 222

Quoted 9 lines

static ssize_t enable_show(struct device *dev,

drivers/usb/misc/qcom_eud.c +4 -0
@@ -186,6 +216,11 @@ static int eud_probe(struct platform_device *pdev)
 
 	chip->dev = &pdev->dev;
 
+	chip->usb2_phy = devm_phy_get(chip->dev, "usb2-phy");
+	if (IS_ERR(chip->usb2_phy))
+		return dev_err_probe(chip->dev, PTR_ERR(chip->usb2_phy),
+				     "no usb2 phy configured\n");

This nicely breaks all users.

NAK

Best regards,
Krzysztof

#18 lore raw

Re: [PATCH 6/8] usb: misc: eud: Add High-Speed Phy control for EUD operations

Quoted 15 lines · Krzysztof Kozlowski
Quoted 7 lines · Elson Roy Serrao

The Embedded USB Debugger(EUD) is a HS-USB on-chip hub to support the debug and trace capabilities on Qualcomm devices. It is physically present in between the usb connector and the usb controller. Being a HS USB hub, it relies on HS Phy for its functionality. Add HS phy support in the eud driver and control the phy during eud enable/disable operations.

...

Quoted 5 lines

static ssize_t enable_show(struct device *dev,

drivers/usb/misc/qcom_eud.c +0 -0
@@ -186,6 +216,11 @@ static int eud_probe(struct platform_device *pdev)
 
 	chip->dev = &pdev->dev;
 
Quoted 9 lines

drivers/usb/misc/qcom_eud.c static int eud_probe(struct platform_device *pdev) · line 222

Quoted 4 lines
drivers/usb/misc/qcom_eud.c +4 -0
+	chip->usb2_phy = devm_phy_get(chip->dev, "usb2-phy");
+	if (IS_ERR(chip->usb2_phy))
+		return dev_err_probe(chip->dev, PTR_ERR(chip->usb2_phy),
+				     "no usb2 phy configured\n");

This nicely breaks all users.

NAK

As per my comment in [patch 1/8], phy would be a required property and hence I will first modify and enable EUD on the existing user (sc7280 SoC) and then extend this to other users.

Thanks
Elson

#19 lore raw

Re: [PATCH 6/8] usb: misc: eud: Add High-Speed Phy control for EUD operations

Quoted 25 lines · Elson Serrao
Quoted 22 lines · Krzysztof Kozlowski
Quoted 7 lines · Elson Roy Serrao

The Embedded USB Debugger(EUD) is a HS-USB on-chip hub to support the debug and trace capabilities on Qualcomm devices. It is physically present in between the usb connector and the usb controller. Being a HS USB hub, it relies on HS Phy for its functionality. Add HS phy support in the eud driver and control the phy during eud enable/disable operations.

...

drivers/usb/misc/qcom_eud.c static int eud_probe(struct platform_device *pdev) · line 222

Quoted 9 lines

static ssize_t enable_show(struct device *dev,

drivers/usb/misc/qcom_eud.c +4 -0
@@ -186,6 +216,11 @@ static int eud_probe(struct platform_device *pdev)
 
 	chip->dev = &pdev->dev;
 
+	chip->usb2_phy = devm_phy_get(chip->dev, "usb2-phy");
+	if (IS_ERR(chip->usb2_phy))
+		return dev_err_probe(chip->dev, PTR_ERR(chip->usb2_phy),
+				     "no usb2 phy configured\n");

This nicely breaks all users.

Quoted 5 lines
Quoted 2 lines

NAK

As per my comment in [patch 1/8], phy would be a required property and hence I will first modify and enable EUD on the existing user (sc7280 SoC) and then extend this to other users.

NAK, you break existing users without clear reason.

Best regards,
Krzysztof

#20 lore raw

PATCH 7/8 usb: misc: eud: Handle usb role switch notifications

In reply to Elson Roy Serrao

Since EUD is physically present between the USB connector and the USB controller, it should relay the usb role notifications from the connector. Hence register a role switch handler to process and relay these roles to the USB controller. This results in a common framework to send both connector related events and eud attach/detach events to the USB controller.

---
 drivers/usb/misc/qcom_eud.c | 91 ++++++++++++++++++++++++++++---------
 1 file changed, 69 insertions(+), 22 deletions(-)
drivers/usb/misc/qcom_eud.c +69 -22
index 3de7d465912c..9a49c934e8cf 100644
@@ -10,6 +10,7 @@
 #include <linux/iopoll.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/mutex.h>
 #include <linux/of.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
@@ -35,12 +36,16 @@ struct eud_chip {
 	struct device			*dev;
 	struct usb_role_switch		*role_sw;
 	struct phy			*usb2_phy;
+
+	/* mode lock */
+	struct mutex			mutex;
 	void __iomem			*base;
 	void __iomem			*mode_mgr;
 	unsigned int			int_status;
 	int				irq;
 	bool				enabled;
 	bool				usb_attached;
+	enum usb_role			current_role;
 };
 
 static int eud_phy_enable(struct eud_chip *chip)
@@ -64,6 +69,38 @@ static void eud_phy_disable(struct eud_chip *chip)
 	phy_exit(chip->usb2_phy);
 }
 
+static int eud_usb_role_set(struct eud_chip *chip, enum usb_role role)
+{
+	struct usb_role_switch *sw;
+	int ret = 0;
+
+	mutex_lock(&chip->mutex);
+
+	/* Avoid duplicate role handling */
+	if (role == chip->current_role)
+		goto err;
+
+	sw = usb_role_switch_get(chip->dev);
+	if (IS_ERR_OR_NULL(sw)) {
+		dev_err(chip->dev, "failed to get usb switch\n");
+		ret = -EINVAL;
+		goto err;
+	}
+
+	ret = usb_role_switch_set_role(sw, role);
+	usb_role_switch_put(sw);
+
+	if (ret) {
+		dev_err(chip->dev, "failed to set role\n");
+		goto err;
+	}
+	chip->current_role = role;
+err:
+	mutex_unlock(&chip->mutex);
+
+	return ret;
+}
+
 static int enable_eud(struct eud_chip *priv)
 {
 	int ret;
@@ -77,7 +114,7 @@ static int enable_eud(struct eud_chip *priv)
 			priv->base + EUD_REG_INT1_EN_MASK);
 	writel(1, priv->mode_mgr + EUD_REG_EUD_EN2);
 
-	return usb_role_switch_set_role(priv->role_sw, USB_ROLE_DEVICE);
+	return ret;
 }
 
 static void disable_eud(struct eud_chip *priv)
@@ -106,15 +143,20 @@ static ssize_t enable_store(struct device *dev,
 	if (kstrtobool(buf, &enable))
 		return -EINVAL;
 
+	/* EUD enable is applicable only in DEVICE mode */
+	if (enable && chip->current_role != USB_ROLE_DEVICE)
+		return -EINVAL;
+
 	if (enable) {
 		ret = enable_eud(chip);
-		if (!ret)
-			chip->enabled = enable;
-		else
-			disable_eud(chip);
+		if (ret) {
+			dev_err(chip->dev, "failed to enable eud\n");
+			return count;
+		}
 	} else {
 		disable_eud(chip);
 	}
+	chip->enabled = enable;
 
 	return count;
 }
@@ -185,11 +227,9 @@ static irqreturn_t handle_eud_irq_thread(int irq, void *data)
 	int ret;
 
 	if (chip->usb_attached)
-		ret = usb_role_switch_set_role(chip->role_sw, USB_ROLE_DEVICE);
+		ret = eud_usb_role_set(chip, USB_ROLE_DEVICE);
 	else
-		ret = usb_role_switch_set_role(chip->role_sw, USB_ROLE_HOST);
-	if (ret)
-		dev_err(chip->dev, "failed to set role switch\n");
+		ret = eud_usb_role_set(chip, USB_ROLE_HOST);
 
 	/* set and clear vbus_int_clr[0] to clear interrupt */
 	writel(BIT(0), chip->base + EUD_REG_VBUS_INT_CLR);
@@ -198,16 +238,18 @@ static irqreturn_t handle_eud_irq_thread(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
-static void eud_role_switch_release(void *data)
+static int eud_usb_role_switch_set(struct usb_role_switch *sw,
+				   enum usb_role role)
 {
-	struct eud_chip *chip = data;
+	struct eud_chip *chip = usb_role_switch_get_drvdata(sw);
 
-	usb_role_switch_put(chip->role_sw);
+	return eud_usb_role_set(chip, role);
 }
 
 static int eud_probe(struct platform_device *pdev)
 {
 	struct eud_chip *chip;
+	struct usb_role_switch_desc eud_role_switch = {NULL};
 	int ret;
 
 	chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
@@ -221,16 +263,6 @@ static int eud_probe(struct platform_device *pdev)
 		return dev_err_probe(chip->dev, PTR_ERR(chip->usb2_phy),
 				     "no usb2 phy configured\n");
 
-	chip->role_sw = usb_role_switch_get(&pdev->dev);
-	if (IS_ERR(chip->role_sw))
-		return dev_err_probe(chip->dev, PTR_ERR(chip->role_sw),
-					"failed to get role switch\n");
-
-	ret = devm_add_action_or_reset(chip->dev, eud_role_switch_release, chip);
-	if (ret)
-		return dev_err_probe(chip->dev, ret,
-				"failed to add role switch release action\n");
-
 	chip->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(chip->base))
 		return PTR_ERR(chip->base);
@@ -248,6 +280,18 @@ static int eud_probe(struct platform_device *pdev)
 	if (ret)
 		return dev_err_probe(chip->dev, ret, "failed to allocate irq\n");
 
+	eud_role_switch.fwnode = dev_fwnode(chip->dev);
+	eud_role_switch.set = eud_usb_role_switch_set;
+	eud_role_switch.get = NULL;
+	eud_role_switch.driver_data = chip;
+	chip->role_sw = usb_role_switch_register(chip->dev, &eud_role_switch);
+
+	if (IS_ERR(chip->role_sw))
+		return dev_err_probe(chip->dev, PTR_ERR(chip->role_sw),
+				"failed to register role switch\n");
+
+	mutex_init(&chip->mutex);
+
 	enable_irq_wake(chip->irq);
 
 	platform_set_drvdata(pdev, chip);
@@ -262,6 +306,9 @@ static void eud_remove(struct platform_device *pdev)
 	if (chip->enabled)
 		disable_eud(chip);
 
+	if (chip->role_sw)
+		usb_role_switch_unregister(chip->role_sw);
+
 	device_init_wakeup(&pdev->dev, false);
 	disable_irq_wake(chip->irq);
 }
Signature · 1 line
2.17.1
#21 lore raw

Re: [PATCH 7/8] usb: misc: eud: Handle usb role switch notifications

Quoted 47 lines · Elson Roy Serrao

Since EUD is physically present between the USB connector and the USB controller, it should relay the usb role notifications from the connector. Hence register a role switch handler to process and relay these roles to the USB controller. This results in a common framework to send both connector related events and eud attach/detach events to the USB controller.

---
 drivers/usb/misc/qcom_eud.c | 91 ++++++++++++++++++++++++++++---------
 1 file changed, 69 insertions(+), 22 deletions(-)
drivers/usb/misc/qcom_eud.c +7 -0
index 3de7d465912c..9a49c934e8cf 100644
@@ -10,6 +10,7 @@
 #include <linux/iopoll.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/mutex.h>
 #include <linux/of.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
@@ -35,12 +36,16 @@ struct eud_chip {
 	struct device			*dev;
 	struct usb_role_switch		*role_sw;
 	struct phy			*usb2_phy;
+
+	/* mode lock */
+	struct mutex			mutex;
 	void __iomem			*base;
 	void __iomem			*mode_mgr;
 	unsigned int			int_status;
 	int				irq;
 	bool				enabled;
 	bool				usb_attached;
+	enum usb_role			current_role;
 };
 
 static int eud_phy_enable(struct eud_chip *chip)
@@ -64,6 +69,38 @@ static void eud_phy_disable(struct eud_chip *chip)
 	phy_exit(chip->usb2_phy);
 }
 
+static int eud_usb_role_set(struct eud_chip *chip, enum usb_role role)
+{

drivers/usb/misc/qcom_eud.c static void eud_phy_disable(struct eud_chip *chip) · line 83

Quoted 10 lines
drivers/usb/misc/qcom_eud.c +10 -0
+	struct usb_role_switch *sw;
+	int ret = 0;
+
+	mutex_lock(&chip->mutex);
+
+	/* Avoid duplicate role handling */
+	if (role == chip->current_role)
+		goto err;
+
+	sw = usb_role_switch_get(chip->dev);

Why isn't chip->role_sw good enough? Why do you need to get it each time?

Quoted 115 lines
drivers/usb/misc/qcom_eud.c +38 -22
+	if (IS_ERR_OR_NULL(sw)) {
+		dev_err(chip->dev, "failed to get usb switch\n");
+		ret = -EINVAL;
+		goto err;
+	}
+
+	ret = usb_role_switch_set_role(sw, role);
+	usb_role_switch_put(sw);
+
+	if (ret) {
+		dev_err(chip->dev, "failed to set role\n");
+		goto err;
+	}
+	chip->current_role = role;
+err:
+	mutex_unlock(&chip->mutex);
+
+	return ret;
+}
+
 static int enable_eud(struct eud_chip *priv)
 {
 	int ret;
@@ -77,7 +114,7 @@ static int enable_eud(struct eud_chip *priv)
 			priv->base + EUD_REG_INT1_EN_MASK);
 	writel(1, priv->mode_mgr + EUD_REG_EUD_EN2);
 
-	return usb_role_switch_set_role(priv->role_sw, USB_ROLE_DEVICE);
+	return ret;
 }
 
 static void disable_eud(struct eud_chip *priv)
@@ -106,15 +143,20 @@ static ssize_t enable_store(struct device *dev,
 	if (kstrtobool(buf, &enable))
 		return -EINVAL;
 
+	/* EUD enable is applicable only in DEVICE mode */
+	if (enable && chip->current_role != USB_ROLE_DEVICE)
+		return -EINVAL;
+
 	if (enable) {
 		ret = enable_eud(chip);
-		if (!ret)
-			chip->enabled = enable;
-		else
-			disable_eud(chip);
+		if (ret) {
+			dev_err(chip->dev, "failed to enable eud\n");
+			return count;
+		}
 	} else {
 		disable_eud(chip);
 	}
+	chip->enabled = enable;
 
 	return count;
 }
@@ -185,11 +227,9 @@ static irqreturn_t handle_eud_irq_thread(int irq, void *data)
 	int ret;
 
 	if (chip->usb_attached)
-		ret = usb_role_switch_set_role(chip->role_sw, USB_ROLE_DEVICE);
+		ret = eud_usb_role_set(chip, USB_ROLE_DEVICE);
 	else
-		ret = usb_role_switch_set_role(chip->role_sw, USB_ROLE_HOST);
-	if (ret)
-		dev_err(chip->dev, "failed to set role switch\n");
+		ret = eud_usb_role_set(chip, USB_ROLE_HOST);
 
 	/* set and clear vbus_int_clr[0] to clear interrupt */
 	writel(BIT(0), chip->base + EUD_REG_VBUS_INT_CLR);
@@ -198,16 +238,18 @@ static irqreturn_t handle_eud_irq_thread(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
-static void eud_role_switch_release(void *data)
+static int eud_usb_role_switch_set(struct usb_role_switch *sw,
+				   enum usb_role role)
 {
-	struct eud_chip *chip = data;
+	struct eud_chip *chip = usb_role_switch_get_drvdata(sw);
 
-	usb_role_switch_put(chip->role_sw);
+	return eud_usb_role_set(chip, role);
 }
 
 static int eud_probe(struct platform_device *pdev)
 {
 	struct eud_chip *chip;
+	struct usb_role_switch_desc eud_role_switch = {NULL};
 	int ret;
 
 	chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
@@ -221,16 +263,6 @@ static int eud_probe(struct platform_device *pdev)
 		return dev_err_probe(chip->dev, PTR_ERR(chip->usb2_phy),
 				     "no usb2 phy configured\n");
 
-	chip->role_sw = usb_role_switch_get(&pdev->dev);
-	if (IS_ERR(chip->role_sw))
-		return dev_err_probe(chip->dev, PTR_ERR(chip->role_sw),
-					"failed to get role switch\n");
-
-	ret = devm_add_action_or_reset(chip->dev, eud_role_switch_release, chip);
-	if (ret)
-		return dev_err_probe(chip->dev, ret,
-				"failed to add role switch release action\n");
-
 	chip->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(chip->base))
 		return PTR_ERR(chip->base);
@@ -248,6 +280,18 @@ static int eud_probe(struct platform_device *pdev)
 	if (ret)
 		return dev_err_probe(chip->dev, ret, "failed to allocate irq\n");
 
+	eud_role_switch.fwnode = dev_fwnode(chip->dev);

drivers/usb/misc/qcom_eud.c static int eud_probe(struct platform_device *pdev) · line 293

Quoted 10 lines
drivers/usb/misc/qcom_eud.c +10 -0
+	eud_role_switch.set = eud_usb_role_switch_set;
+	eud_role_switch.get = NULL;
+	eud_role_switch.driver_data = chip;
+	chip->role_sw = usb_role_switch_register(chip->dev, &eud_role_switch);
+
+	if (IS_ERR(chip->role_sw))
+		return dev_err_probe(chip->dev, PTR_ERR(chip->role_sw),
+				"failed to register role switch\n");
+
+	mutex_init(&chip->mutex);

please move mutex_init earlier.

Quoted 17 lines
drivers/usb/misc/qcom_eud.c +4 -0
+
 	enable_irq_wake(chip->irq);
 
 	platform_set_drvdata(pdev, chip);
@@ -262,6 +306,9 @@ static void eud_remove(struct platform_device *pdev)
 	if (chip->enabled)
 		disable_eud(chip);
 
+	if (chip->role_sw)
+		usb_role_switch_unregister(chip->role_sw);
+
 	device_init_wakeup(&pdev->dev, false);
 	disable_irq_wake(chip->irq);
 }
Signature · 1 line
2.17.1
Signature · 2 lines
With best wishes
Dmitry
#22 lore raw

Re: [PATCH 7/8] usb: misc: eud: Handle usb role switch notifications

Quoted 46 lines · Dmitry Baryshkov
Quoted 45 lines · Elson Roy Serrao

Since EUD is physically present between the USB connector and the USB controller, it should relay the usb role notifications from the connector. Hence register a role switch handler to process and relay these roles to the USB controller. This results in a common framework to send both connector related events and eud attach/detach events to the USB controller.

---
 drivers/usb/misc/qcom_eud.c | 91 ++++++++++++++++++++++++++++---------
 1 file changed, 69 insertions(+), 22 deletions(-)
drivers/usb/misc/qcom_eud.c +5 -0
index 3de7d465912c..9a49c934e8cf 100644
@@ -10,6 +10,7 @@
 #include <linux/iopoll.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/mutex.h>
 #include <linux/of.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
@@ -35,12 +36,16 @@ struct eud_chip {
 	struct device			*dev;
 	struct usb_role_switch		*role_sw;
 	struct phy			*usb2_phy;
+
+	/* mode lock */
+	struct mutex			mutex;
 	void __iomem			*base;
 	void __iomem			*mode_mgr;
 	unsigned int			int_status;
 	int				irq;
 	bool				enabled;
 	bool				usb_attached;
+	enum usb_role			current_role;
 };
 
 static int eud_phy_enable(struct eud_chip *chip)
@@ -64,6 +69,38 @@ static void eud_phy_disable(struct eud_chip *chip)
 	phy_exit(chip->usb2_phy);
 }
 
Quoted 16 lines

drivers/usb/misc/qcom_eud.c static void eud_phy_disable(struct eud_chip *chip) · line 83

Quoted 12 lines
drivers/usb/misc/qcom_eud.c +12 -0
+static int eud_usb_role_set(struct eud_chip *chip, enum usb_role role)
+{
+	struct usb_role_switch *sw;
+	int ret = 0;
+
+	mutex_lock(&chip->mutex);
+
+	/* Avoid duplicate role handling */
+	if (role == chip->current_role)
+		goto err;
+
+	sw = usb_role_switch_get(chip->dev);

Why isn't chip->role_sw good enough? Why do you need to get it each time?

Hi Dmitry

chip->role_sw is the eud role switch handler to receive role switch notifications from the USB connector. The 'sw' I am getting above is the role switch handler of the USB controller. As per this design, EUD receives role switch notification from the connector (via chip->role_sw) and then relays it to the 'sw' switch handler of the USB controller.

Thanks
Elson

Quoted 114 lines
Quoted 114 lines
drivers/usb/misc/qcom_eud.c +37 -22
+	if (IS_ERR_OR_NULL(sw)) {
+		dev_err(chip->dev, "failed to get usb switch\n");
+		ret = -EINVAL;
+		goto err;
+	}
+
+	ret = usb_role_switch_set_role(sw, role);
+	usb_role_switch_put(sw);
+
+	if (ret) {
+		dev_err(chip->dev, "failed to set role\n");
+		goto err;
+	}
+	chip->current_role = role;
+err:
+	mutex_unlock(&chip->mutex);
+
+	return ret;
+}
+
 static int enable_eud(struct eud_chip *priv)
 {
 	int ret;
@@ -77,7 +114,7 @@ static int enable_eud(struct eud_chip *priv)
 			priv->base + EUD_REG_INT1_EN_MASK);
 	writel(1, priv->mode_mgr + EUD_REG_EUD_EN2);
 
-	return usb_role_switch_set_role(priv->role_sw, USB_ROLE_DEVICE);
+	return ret;
 }
 
 static void disable_eud(struct eud_chip *priv)
@@ -106,15 +143,20 @@ static ssize_t enable_store(struct device *dev,
 	if (kstrtobool(buf, &enable))
 		return -EINVAL;
 
+	/* EUD enable is applicable only in DEVICE mode */
+	if (enable && chip->current_role != USB_ROLE_DEVICE)
+		return -EINVAL;
+
 	if (enable) {
 		ret = enable_eud(chip);
-		if (!ret)
-			chip->enabled = enable;
-		else
-			disable_eud(chip);
+		if (ret) {
+			dev_err(chip->dev, "failed to enable eud\n");
+			return count;
+		}
 	} else {
 		disable_eud(chip);
 	}
+	chip->enabled = enable;
 
 	return count;
 }
@@ -185,11 +227,9 @@ static irqreturn_t handle_eud_irq_thread(int irq, void *data)
 	int ret;
 
 	if (chip->usb_attached)
-		ret = usb_role_switch_set_role(chip->role_sw, USB_ROLE_DEVICE);
+		ret = eud_usb_role_set(chip, USB_ROLE_DEVICE);
 	else
-		ret = usb_role_switch_set_role(chip->role_sw, USB_ROLE_HOST);
-	if (ret)
-		dev_err(chip->dev, "failed to set role switch\n");
+		ret = eud_usb_role_set(chip, USB_ROLE_HOST);
 
 	/* set and clear vbus_int_clr[0] to clear interrupt */
 	writel(BIT(0), chip->base + EUD_REG_VBUS_INT_CLR);
@@ -198,16 +238,18 @@ static irqreturn_t handle_eud_irq_thread(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
-static void eud_role_switch_release(void *data)
+static int eud_usb_role_switch_set(struct usb_role_switch *sw,
+				   enum usb_role role)
 {
-	struct eud_chip *chip = data;
+	struct eud_chip *chip = usb_role_switch_get_drvdata(sw);
 
-	usb_role_switch_put(chip->role_sw);
+	return eud_usb_role_set(chip, role);
 }
 
 static int eud_probe(struct platform_device *pdev)
 {
 	struct eud_chip *chip;
+	struct usb_role_switch_desc eud_role_switch = {NULL};
 	int ret;
 
 	chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
@@ -221,16 +263,6 @@ static int eud_probe(struct platform_device *pdev)
 		return dev_err_probe(chip->dev, PTR_ERR(chip->usb2_phy),
 				     "no usb2 phy configured\n");
 
-	chip->role_sw = usb_role_switch_get(&pdev->dev);
-	if (IS_ERR(chip->role_sw))
-		return dev_err_probe(chip->dev, PTR_ERR(chip->role_sw),
-					"failed to get role switch\n");
-
-	ret = devm_add_action_or_reset(chip->dev, eud_role_switch_release, chip);
-	if (ret)
-		return dev_err_probe(chip->dev, ret,
-				"failed to add role switch release action\n");
-
 	chip->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(chip->base))
 		return PTR_ERR(chip->base);
@@ -248,6 +280,18 @@ static int eud_probe(struct platform_device *pdev)
 	if (ret)
 		return dev_err_probe(chip->dev, ret, "failed to allocate irq\n");
 
Quoted 14 lines

drivers/usb/misc/qcom_eud.c static int eud_probe(struct platform_device *pdev) · line 293

Quoted 11 lines
drivers/usb/misc/qcom_eud.c +11 -0
+	eud_role_switch.fwnode = dev_fwnode(chip->dev);
+	eud_role_switch.set = eud_usb_role_switch_set;
+	eud_role_switch.get = NULL;
+	eud_role_switch.driver_data = chip;
+	chip->role_sw = usb_role_switch_register(chip->dev, &eud_role_switch);
+
+	if (IS_ERR(chip->role_sw))
+		return dev_err_probe(chip->dev, PTR_ERR(chip->role_sw),
+				"failed to register role switch\n");
+
+	mutex_init(&chip->mutex);

please move mutex_init earlier.

Ack

Quoted 18 lines
Quoted 17 lines
drivers/usb/misc/qcom_eud.c +4 -0
+
 	enable_irq_wake(chip->irq);
 
 	platform_set_drvdata(pdev, chip);
@@ -262,6 +306,9 @@ static void eud_remove(struct platform_device *pdev)
 	if (chip->enabled)
 		disable_eud(chip);
 
+	if (chip->role_sw)
+		usb_role_switch_unregister(chip->role_sw);
+
 	device_init_wakeup(&pdev->dev, false);
 	disable_irq_wake(chip->irq);
 }
Signature · 1 line
2.17.1
#23 lore raw

Re: [PATCH 7/8] usb: misc: eud: Handle usb role switch notifications

Quoted 66 lines · Elson Serrao
Quoted 46 lines · Dmitry Baryshkov
Quoted 45 lines · Elson Roy Serrao

Since EUD is physically present between the USB connector and the USB controller, it should relay the usb role notifications from the connector. Hence register a role switch handler to process and relay these roles to the USB controller. This results in a common framework to send both connector related events and eud attach/detach events to the USB controller.

---
 drivers/usb/misc/qcom_eud.c | 91 ++++++++++++++++++++++++++++---------
 1 file changed, 69 insertions(+), 22 deletions(-)
drivers/usb/misc/qcom_eud.c +5 -0
index 3de7d465912c..9a49c934e8cf 100644
@@ -10,6 +10,7 @@
 #include <linux/iopoll.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/mutex.h>
 #include <linux/of.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
@@ -35,12 +36,16 @@ struct eud_chip {
 	struct device			*dev;
 	struct usb_role_switch		*role_sw;
 	struct phy			*usb2_phy;
+
+	/* mode lock */
+	struct mutex			mutex;
 	void __iomem			*base;
 	void __iomem			*mode_mgr;
 	unsigned int			int_status;
 	int				irq;
 	bool				enabled;
 	bool				usb_attached;
+	enum usb_role			current_role;
 };
 
 static int eud_phy_enable(struct eud_chip *chip)
@@ -64,6 +69,38 @@ static void eud_phy_disable(struct eud_chip *chip)
 	phy_exit(chip->usb2_phy);
 }
 
Quoted 16 lines

drivers/usb/misc/qcom_eud.c static void eud_phy_disable(struct eud_chip *chip) · line 83

Quoted 12 lines
drivers/usb/misc/qcom_eud.c +12 -0
+static int eud_usb_role_set(struct eud_chip *chip, enum usb_role role)
+{
+	struct usb_role_switch *sw;
+	int ret = 0;
+
+	mutex_lock(&chip->mutex);
+
+	/* Avoid duplicate role handling */
+	if (role == chip->current_role)
+		goto err;
+
+	sw = usb_role_switch_get(chip->dev);

Why isn't chip->role_sw good enough? Why do you need to get it each time?

Quoted 6 lines

Hi Dmitry

chip->role_sw is the eud role switch handler to receive role switch notifications from the USB connector. The 'sw' I am getting above is the role switch handler of the USB controller. As per this design, EUD receives role switch notification from the connector (via chip->role_sw) and then relays it to the 'sw' switch handler of the USB controller.

The fact that you have repurposed existing structure field is not a waiver for the inefficiency.

So what about keeping chip->role_sw as is and adding _new_ field for the self-provided role switch?

Signature · 2 lines
With best wishes
Dmitry
#24 lore raw

Re: [PATCH 7/8] usb: misc: eud: Handle usb role switch notifications

In reply to Elson Roy Serrao
kernel test robot noticed the following build warnings:

Hi Elson,

kernel test robot noticed the following build warnings:

[auto build test WARNING on robh/for-next]
[also build test WARNING on usb/usb-testing usb/usb-next usb/usb-linus linus/master v6.11-rc1 next-20240801] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Elson-Roy-Serrao/dt-bindings-soc-qcom-eud-Add-phy-related-bindings/20240801-210521
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
patch link:    https://lore.kernel.org/r/20240730222439.3469-8-quic_eserrao%40quicinc.com
patch subject: [PATCH 7/8] usb: misc: eud: Handle usb role switch notifications
config: m68k-allmodconfig (https://download.01.org/0day-ci/archive/20240802/[email protected]/config)
compiler: m68k-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240802/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

drivers/usb/misc/qcom_eud.c: In function 'handle_eud_irq_thread':

>> drivers/usb/misc/qcom_eud.c:227:13: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
     227 |         int ret;
         |             ^~~

vim +/ret +227 drivers/usb/misc/qcom_eud.c

9a1bf58ccd4432 Souradeep Chowdhury 2022-02-08  223  
9a1bf58ccd4432 Souradeep Chowdhury 2022-02-08  224  static irqreturn_t handle_eud_irq_thread(int irq, void *data)
9a1bf58ccd4432 Souradeep Chowdhury 2022-02-08  225  {
9a1bf58ccd4432 Souradeep Chowdhury 2022-02-08  226  	struct eud_chip *chip = data;
9a1bf58ccd4432 Souradeep Chowdhury 2022-02-08 @227  	int ret;
9a1bf58ccd4432 Souradeep Chowdhury 2022-02-08  228  
9a1bf58ccd4432 Souradeep Chowdhury 2022-02-08  229  	if (chip->usb_attached)
c007e96bfd0471 Elson Roy Serrao    2024-07-30  230  		ret = eud_usb_role_set(chip, USB_ROLE_DEVICE);
9a1bf58ccd4432 Souradeep Chowdhury 2022-02-08  231  	else
c007e96bfd0471 Elson Roy Serrao    2024-07-30  232  		ret = eud_usb_role_set(chip, USB_ROLE_HOST);
9a1bf58ccd4432 Souradeep Chowdhury 2022-02-08  233  
9a1bf58ccd4432 Souradeep Chowdhury 2022-02-08  234  	/* set and clear vbus_int_clr[0] to clear interrupt */
9a1bf58ccd4432 Souradeep Chowdhury 2022-02-08  235  	writel(BIT(0), chip->base + EUD_REG_VBUS_INT_CLR);
9a1bf58ccd4432 Souradeep Chowdhury 2022-02-08  236  	writel(0, chip->base + EUD_REG_VBUS_INT_CLR);
9a1bf58ccd4432 Souradeep Chowdhury 2022-02-08  237  
9a1bf58ccd4432 Souradeep Chowdhury 2022-02-08  238  	return IRQ_HANDLED;
9a1bf58ccd4432 Souradeep Chowdhury 2022-02-08  239  }
9a1bf58ccd4432 Souradeep Chowdhury 2022-02-08  240  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#25 lore raw

PATCH 8/8 usb: misc: eud: Add compatible for sm8450

In reply to Elson Roy Serrao

Add compatible string to enable EUD on sm8450 SoC.

---
 drivers/usb/misc/qcom_eud.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/misc/qcom_eud.c +1 -0
index 9a49c934e8cf..465d57c05c3c 100644
@@ -315,6 +315,7 @@ static void eud_remove(struct platform_device *pdev)
 
 static const struct of_device_id eud_dt_match[] = {
 	{ .compatible = "qcom,sc7280-eud" },
+	{ .compatible = "qcom,sm8450-eud" },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, eud_dt_match);
Signature · 1 line
2.17.1
#26 lore raw

Re: [PATCH 8/8] usb: misc: eud: Add compatible for sm8450

Quoted 12 lines · Elson Roy Serrao

Add compatible string to enable EUD on sm8450 SoC.

---
 drivers/usb/misc/qcom_eud.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/misc/qcom_eud.c +0 -0
index 9a49c934e8cf..465d57c05c3c 100644

drivers/usb/misc/qcom_eud.c static void eud_remove(struct platform_device *pdev) · line 318

Quoted 4 lines
drivers/usb/misc/qcom_eud.c +1 -0
@@ -315,6 +315,7 @@ static void eud_remove(struct platform_device *pdev)
 
 static const struct of_device_id eud_dt_match[] = {
 	{ .compatible = "qcom,sc7280-eud" },
+	{ .compatible = "qcom,sm8450-eud" },

No, let's don't.

I'll fix the existing file.

Best regards,
Krzysztof

#27 lore raw
In reply to Elson Roy Serrao

Hi,

Quoted 9 lines · Elson Roy Serrao

The Embedded USB Debugger (EUD) is a mini High-Speed USB on-chip hub to support the USB-based debug and trace capabilities on Qualcomm devices. The current implementation lacks in below aspects that are needed for proper EUD functionality.

1.) HS-Phy control: EUD being a HS hub needs HS-Phy support for it's
operation. Hence EUD module should enable/disable HS-phy accordingly.

Quoted 8 lines

2.) Proper routing of USB role switch notifications: EUD hub is physically
present in between the USB connector and the USB controller. So the usb role switch notifications originating from the connector should route through EUD. EUD also relies on role switch notifications to communicate with the USB, regarding EUD attach/detach events.

This series aims at implementing the above aspects to enable EUD on Qualcomm sm8450 SoC.

Are there any plans to make this feature available for folks outside of Qualcomm / an NDA?

There is an openOCD fork on CodeLinaro but it still requires some proprietary library which is only available to folks with a quicinc email as I understand it.

Kind regards,

~ someone eager for JTAG access

Quoted 17 lines

Elson Roy Serrao (8):
dt-bindings: soc: qcom: eud: Add phy related bindings
dt-bindings: soc: qcom: eud: Add usb role switch property
dt-bindings: soc: qcom: eud: Add compatible for sm8450
arm64: dts: qcom: sm8450: Add EUD node
arm64: dts: qcom: Enable EUD on sm8450 hdk
usb: misc: eud: Add High-Speed Phy control for EUD operations
usb: misc: eud: Handle usb role switch notifications
usb: misc: eud: Add compatible for sm8450

  .../bindings/soc/qcom/qcom,eud.yaml           |  17 +++
  arch/arm64/boot/dts/qcom/sm8450-hdk.dts       |  15 ++-
  arch/arm64/boot/dts/qcom/sm8450.dtsi          |  29 ++++
  drivers/usb/misc/qcom_eud.c                   | 125 +++++++++++++++---
  4 files changed, 164 insertions(+), 22 deletions(-)
Signature · 1 line
// Caleb (they/them)
#28 lore raw
Quoted 7 lines · Caleb Connolly
Quoted 7 lines


2.) Proper routing of USB role switch notifications: EUD hub is physically present in between the USB connector and the USB controller. So the usb role switch notifications originating from the connector should route through EUD. EUD also relies on role switch notifications to communicate with the USB, regarding EUD attach/detach events.

Quoted 7 lines
Quoted 2 lines

This series aims at implementing the above aspects to enable EUD on Qualcomm sm8450 SoC.

Are there any plans to make this feature available for folks outside of Qualcomm / an NDA?

There is an openOCD fork on CodeLinaro but it still requires some proprietary library which is only available to folks with a quicinc email as I understand it.

Which codelinaro link are you referring here?

Signature · 1 line
---Trilok Soni
#29 lore raw

Hi Trilok,

Quoted 11 lines · Trilok Soni
Quoted 10 lines · Caleb Connolly
Quoted 9 lines

2.) Proper routing of USB role switch notifications: EUD hub is physically
     present in between the USB connector and the USB controller. So the usb role switch notifications originating from the connector should route through EUD. EUD also relies on role switch notifications to communicate with the USB, regarding EUD attach/detach events.

This series aims at implementing the above aspects to enable EUD on Qualcomm sm8450 SoC.

Quoted 6 lines
Quoted 4 lines

Are there any plans to make this feature available for folks outside of Qualcomm / an NDA?

There is an openOCD fork on CodeLinaro but it still requires some proprietary library which is only available to folks with a quicinc email as I understand it.

Which codelinaro link are you referring here?

That would be https://git.codelinaro.org/clo/la/openocd-org/openocd/-/blob/qcom_changes/README_QCOM?ref_type=heads

Which says:

Qualcomm specific tools:
- Login to qpm.qualcomm.com
- QUTS: 1.64.1.39 (version & above)
- Qualcomm Host USB Product Suite - QUD QC only : 1.00.63 (supported version)
- EUD QC : 2.1.1 (supported version)

I believe the specific versions of QUD and EUD are only available to Qualcomm engineers and not even to OEMs, though I might be mistaken.

Kind regards,

Quoted 2 lines
Signature · 1 line
// Caleb (they/them)
#30 lore raw
Quoted 24 lines · Caleb Connolly

Hi Trilok,

Quoted 10 lines · Trilok Soni
Quoted 9 lines · Caleb Connolly
Quoted 8 lines

     2.) Proper routing of USB role switch notifications: EUD hub is physically present in between the USB connector and the USB controller. So the usb role switch notifications originating from the connector should route through EUD. EUD also relies on role switch notifications to communicate with the USB, regarding EUD attach/detach events.

This series aims at implementing the above aspects to enable EUD on Qualcomm sm8450 SoC.

Quoted 6 lines
Quoted 4 lines

Are there any plans to make this feature available for folks outside of Qualcomm / an NDA?

There is an openOCD fork on CodeLinaro but it still requires some proprietary library which is only available to folks with a quicinc email as I understand it.

Which codelinaro link are you referring here?

That would be https://git.codelinaro.org/clo/la/openocd-org/openocd/-/blob/qcom_changes/README_QCOM?ref_type=heads

Which says:

Quoted 7 lines

Qualcomm specific tools:
- Login to qpm.qualcomm.com
- QUTS: 1.64.1.39 (version & above)
- Qualcomm Host USB Product Suite - QUD QC only : 1.00.63 (supported version)
- EUD QC : 2.1.1 (supported version)

I believe the specific versions of QUD and EUD are only available to Qualcomm engineers and not even to OEMs, though I might be mistaken.

Thanks. So are we okay w/ one of the following option? (trying to understand the need here properly before I relay it internally).

Options:

(1) Provide EUD library and tools - proprietary w/o any login requirement.
(2) Provide open-source EUD library and tools w/o any login requirement.

Is Option (1) fine to begin with or option 2 is must?

Signature · 1 line
---Trilok Soni
#31 lore raw
Quoted 33 lines · Trilok Soni
Quoted 24 lines · Caleb Connolly

Hi Trilok,

Quoted 10 lines · Trilok Soni
Quoted 9 lines · Caleb Connolly
Quoted 8 lines

     2.) Proper routing of USB role switch notifications: EUD hub is physically present in between the USB connector and the USB controller. So the usb role switch notifications originating from the connector should route through EUD. EUD also relies on role switch notifications to communicate with the USB, regarding EUD attach/detach events.

This series aims at implementing the above aspects to enable EUD on Qualcomm sm8450 SoC.

Quoted 6 lines
Quoted 4 lines

Are there any plans to make this feature available for folks outside of Qualcomm / an NDA?

There is an openOCD fork on CodeLinaro but it still requires some proprietary library which is only available to folks with a quicinc email as I understand it.

Which codelinaro link are you referring here?

That would be https://git.codelinaro.org/clo/la/openocd-org/openocd/-/blob/qcom_changes/README_QCOM?ref_type=heads

Which says:

Quoted 7 lines

Qualcomm specific tools:
- Login to qpm.qualcomm.com
- QUTS: 1.64.1.39 (version & above)
- Qualcomm Host USB Product Suite - QUD QC only : 1.00.63 (supported version)
- EUD QC : 2.1.1 (supported version)

I believe the specific versions of QUD and EUD are only available to Qualcomm engineers and not even to OEMs, though I might be mistaken.

Quoted 8 lines

Thanks. So are we okay w/ one of the following option? (trying to understand the need here properly before I relay it internally).

Options:

(1) Provide EUD library and tools - proprietary w/o any login requirement.
(2) Provide open-source EUD library and tools w/o any login requirement.

Is Option (1) fine to begin with or option 2 is must?

The usual problem of (1) is future compatibility guarantees. What system libraries will it depend upon? When the open-source world and openocd update to the next libusb ABI, will it break the EUD library?

Next, which interfaces are going to be used and/or provided by the lib and tools? In other words, will it be really useful?

Last, if is prorietary, then under which licence? Will it allow reverse engineering or not? Will it allow redistributing? Also note that OpenOCD is licenced under GPL-2.0-or-later, so while one can link it with a proprietary software, they can not further distribute the resulting binaries. Also there might be different questions on whether the lib itself is a derivative work (and as such it must be covered by the GPL).

Signature · 2 lines
With best wishes
Dmitry
#32 lore raw
In reply to Caleb Connolly
Quoted 21 lines · Caleb Connolly

Hi,

Quoted 9 lines · Elson Roy Serrao

The Embedded USB Debugger (EUD) is a mini High-Speed USB on-chip hub to support the USB-based debug and trace capabilities on Qualcomm devices. The current implementation lacks in below aspects that are needed for proper EUD functionality.

1.) HS-Phy control: EUD being a HS hub needs HS-Phy support for it's
operation. Hence EUD module should enable/disable HS-phy accordingly.

Quoted 8 lines

2.) Proper routing of USB role switch notifications: EUD hub is physically
present in between the USB connector and the USB controller. So the usb role switch notifications originating from the connector should route through EUD. EUD also relies on role switch notifications to communicate with the USB, regarding EUD attach/detach events.

This series aims at implementing the above aspects to enable EUD on Qualcomm sm8450 SoC.

Quoted 6 lines

Are there any plans to make this feature available for folks outside of Qualcomm / an NDA?

There is an openOCD fork on CodeLinaro but it still requires some proprietary library which is only available to folks with a quicinc email as I understand it.

Are you saying that there is no fully open and available user-space which is necessary to use EUD?

Best regards,
Krzysztof

#33 lore raw
Quoted 25 lines · Krzysztof Kozlowski
Quoted 24 lines · Caleb Connolly

Hi,

Quoted 9 lines · Elson Roy Serrao

The Embedded USB Debugger (EUD) is a mini High-Speed USB on-chip hub to support the USB-based debug and trace capabilities on Qualcomm devices. The current implementation lacks in below aspects that are needed for proper EUD functionality.

1.) HS-Phy control: EUD being a HS hub needs HS-Phy support for it's
operation. Hence EUD module should enable/disable HS-phy accordingly.

Quoted 8 lines

2.) Proper routing of USB role switch notifications: EUD hub is physically
present in between the USB connector and the USB controller. So the usb role switch notifications originating from the connector should route through EUD. EUD also relies on role switch notifications to communicate with the USB, regarding EUD attach/detach events.

This series aims at implementing the above aspects to enable EUD on Qualcomm sm8450 SoC.

Are there any plans to make this feature available for folks outside of Qualcomm / an NDA?

Quoted 6 lines
Quoted 3 lines

There is an openOCD fork on CodeLinaro but it still requires some proprietary library which is only available to folks with a quicinc email as I understand it.

Are you saying that there is no fully open and available user-space which is necessary to use EUD?

Yes, exactly. Tools must be obtained via the Qualcomm Package Manager which are not available by default after making an account and signing and NDA.

Kind regards,

Quoted 4 lines

Best regards,
Krzysztof

Signature · 1 line
// Caleb (they/them)
Nacked-by on the v1 series NAK
#34 lore raw
In reply to Elson Roy Serrao
Quoted 9 lines · Elson Roy Serrao

The Embedded USB Debugger (EUD) is a mini High-Speed USB on-chip hub to support the USB-based debug and trace capabilities on Qualcomm devices. The current implementation lacks in below aspects that are needed for proper EUD functionality.

1.) HS-Phy control: EUD being a HS hub needs HS-Phy support for it's
operation. Hence EUD module should enable/disable HS-phy accordingly.

Quoted 9 lines

2.) Proper routing of USB role switch notifications: EUD hub is physically
present in between the USB connector and the USB controller. So the usb role switch notifications originating from the connector should route through EUD. EUD also relies on role switch notifications to communicate with the USB, regarding EUD attach/detach events.

This series aims at implementing the above aspects to enable EUD on Qualcomm sm8450 SoC.

For the open source community, EUD enablement means they will only get EUD ports enumerated on the host and nothing else. There is no public info on how to use EUD nor are there any tools to make use of it. So what is the purpose of upstreaming it in the first place?

If the goal is to use EUD only by Qcom employees or customers who have signed NDA, then you can just supply them the out-of-tree EUD patches and tools to work with. There is absolutely no need to upstream the driver support.

So for this series and any other future EUD patches,

I'm really tempted to send a patch to remove the EUD driver altogether, but I'll just wait for the response before doing so.

- Mani

Signature · 1 line
மணிவண்ணன் சதாசிவம்