arm64: qcom: QCM2290: add the Embedded USB Debugger
Subsystems (5)
v2 cover arm64: qcom: QCM2290: add the Embedded USB Debugger
The Embedded USB Debugger of the QCM2290 is the block the SC7280 has, with one difference: its mode manager ignores the enable (EUD_EN2) unless the TCSR register TCSR_APSS_SPARE_REG1 is set first. XBL_SEC, the secure part of the boot loader, does exactly that when it enables the EUD itself.
Why Linux sets the bit and not the firmware:
- XBL_SEC runs the sequence only when the device's debug policy (an optional signed image that enables JTAG) asks for it. Without one, as on the Arduino UNO Q, the board boots with both registers clear.
- The stock TEE (QTEE) does not set the bit either. It allow-lists TCSR_APSS_SPARE_REG1 for the HLOS secure IO calls next to EUD_EN2, with the same policy (write allowed when secure boot is off or debug is not disabled).
- TF-A does the same on Agatti [1][2]: TCSR_APSS_SPARE_REG1 is open to the normal world in all builds, EUD_EN2 in debug builds only.
So with either TEE only the driver can complete the sequence, while the secure firmware keeps deciding whether the EUD may be enabled at all. Where EUD_EN2 is refused, enabling fails with -EINVAL as before.
Arduino UNO Q (QRB2210) was used for testing, next-20261112 plus the board support it needs and this series. The registers were read back through qcom_scm_io_readl() with a debug patch.
TF-A built to allow EUD_EN2, three enable/disable cycles:
write "enable" TCSR EUD_EN2 host enumerates enable ok 1 1 0x01010101 05c6:9500, 05c6:9501 disable ok 0 0 0 nothing
TF-A release build, which refuses EUD_EN2:
write "enable" TCSR afterwards
enable, clear skipped (as in v1) -EINVAL 0 1 enable, this series -EINVAL 0 0
Stock QTEE + Gunyah (secure boot off), two fresh boots, two enable/disable cycles each:
write "enable" host enumerates enable ok 1 05c6:9500, 05c6:9501 disable ok 0 nothing
With v1 only the first enable per boot attached there; now every one does.
OpenOCD master with its EUD adapter plus the SWD fixes in [3], TF-A built to allow EUD_EN2: attaches over SWD (DPIDR 0x5ba02477), halts and resumes cpu0. Without [3] the EUD's SWD function returns USB errors on my host, with the kernel that worked in October as well, so this is not related to the series.
Not tested: RB1.
dt_binding_check, dtbs_check (qrb2210-arduino-imola, qrb2210-rb1), W=1 and checkpatch are clean.
Elson Serrao's pending EUD rework touches the same binding and driver; this series does not depend on it, whichever lands second needs a small rebase.
[1] https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/55733
[2] https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/55964
[3] https://review.openocd.org/q/topic:eud-swd-fixes
---
Changes in v2, all from the Sashiko review of v1:
- Binding, driver, dtsi: the TCSR register is no longer a third reg
entry of the EUD node. It is a "qcom,tcsr-reg" phandle + offset to
the TCSR syscon, which already covers it.
- Driver: clear the TCSR register again when EUD_EN2 is refused; it
stayed set before.
- New patch 1: clear the enabled state on disable (existing bug).
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Igor Opaniuk (5):
usb: misc: qcom_eud: clear the enabled state on disable
dt-bindings: soc: qcom: eud: add the QCM2290 EUD
usb: misc: qcom_eud: set the TCSR check register before enabling on QCM2290
arm64: dts: qcom: agatti: add the Embedded USB Debugger
arm64: dts: qcom: qrb2210-arduino-imola: enable the EUD
.../devicetree/bindings/soc/qcom/qcom,eud.yaml | 25 ++++++++++ arch/arm64/boot/dts/qcom/agatti.dtsi | 34 ++++++++++++- arch/arm64/boot/dts/qcom/qrb2210-arduino-imola.dts | 4 ++ drivers/usb/misc/qcom_eud.c | 57 +++++++++++++++++++++- 4 files changed, 118 insertions(+), 2 deletions(-)
---
base-commit: 84abb955b1015477aa11a96e2f3ac1b938b77f48
change-id: 20261114-qcm2290-eud-81e10f3a8e5f
Best regards,
Signature · 1 line
Igor Opaniuk <[email protected]>
PATCH v2 1/5 usb: misc: qcom_eud: clear the enabled state on disable
enable_store() sets chip->enabled when the EUD is enabled but never clears it. After a disable the "enable" attribute keeps reading 1, and eud_remove() disables the EUD once more.
Clear it when disable_eud() succeeds.
--- drivers/usb/misc/qcom_eud.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/misc/qcom_eud.c +2 -0
@@ -97,6 +97,8 @@ static ssize_t enable_store(struct device *dev, }else { ret =disable_eud (chip); +if (!ret) + chip->enabled = false; }return ret <0 ? ret : count;
Signature · 1 line
2.53.0
Re: [PATCH v2 1/5] usb: misc: qcom_eud: clear the enabled state on disable
Quoted 8 lines · Igor Opaniuk
enable_store()setschip->enabledwhen the EUD is enabled but never clears it. After a disable the "enable" attribute keeps reading 1, andeud_remove()disables the EUD once more.Clear it when
disable_eud()succeeds.Fixes 9a1bf58ccd44 ("usb: misc: eud: Add driver support for Embedded USB Debugger(EUD)")Signed-off-by Igor Opaniuk <[email protected]>
Signature · 1 line
-Mukesh Ojha
PATCH v2 2/5 dt-bindings: soc: qcom: eud: add the QCM2290 EUD
In reply to Igor OpaniukThe QCM2290 has the same Embedded USB Debugger as the SC7280: the EUD CSRs and the mode manager register that the secure world writes on behalf of the driver.
On QCM2290 the mode manager additionally ignores the enable unless the TCSR register TCSR_APSS_SPARE_REG1 is set first. The boot firmware does the same before it enables the EUD, and the register is written through the same secure IO service.
Add the compatible and a "qcom,tcsr-reg" property that points to that register in the TCSR syscon. It is required on QCM2290 and not allowed on the other EUDs.
--- .../devicetree/bindings/soc/qcom/qcom,eud.yaml | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+)
Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml +25 -0
@@ -17,6 +17,7 @@ properties: compatible: items: - enum: + - qcom,qcm2290-eud - qcom,sc7280-eud - const: qcom,eud
@@ -29,6 +30,17 @@ properties: description: EUD interrupt maxItems: 1 + qcom,tcsr-reg: + $ref: /schemas/types.yaml#/definitions/phandle-array + items: + - items: + - description: phandle to the TCSR syscon + - description: offset of the register that has to be set before + the mode manager accepts the enable + description: + TCSR register that gates the EUD enable. It is written through the + secure world, like the mode manager register. + ports: $ref: /schemas/graph.yaml#/properties/ports description:
@@ -50,6 +62,19 @@ required: - reg - ports +allOf: + - if: + properties: + compatible: + contains: + const: qcom,qcm2290-eud + then: + required: + - qcom,tcsr-reg + else: + properties: + qcom,tcsr-reg: false + additionalProperties: false examples:
Signature · 1 line
2.53.0
Re: [PATCH v2 2/5] dt-bindings: soc: qcom: eud: add the QCM2290 EUD
Quoted 9 lines · Igor Opaniuk
The QCM2290 has the same Embedded USB Debugger as the SC7280: the EUD CSRs and the mode manager register that the secure world writes on behalf of the driver.
On QCM2290 the mode manager additionally ignores the enable unless the TCSR register
TCSR_APSS_SPARE_REG1is set first. The boot firmware does the same before it enables the EUD, and the register is written through the same secure IO service.
Quoted 5 lines
Add the compatible and a "qcom,tcsr-reg" property that points to that register in the TCSR syscon. It is required on QCM2290 and not allowed on the other EUDs.
Signed-off-by Igor Opaniuk <[email protected]>
Best regards,
Krzysztof
PATCH v2 3/5 usb: misc: qcom_eud: set the TCSR check register before enabling on QCM2290
In reply to Igor OpaniukOn QCM2290 the EUD mode manager ignores EUD_EN2 unless the TCSR register TCSR_APSS_SPARE_REG1 is set first. Without it EUD_EN2 is accepted, the driver reports success, and the EUD stays in bypass.
The boot firmware sets that register itself (TCSR_APSS_SPARE_REG1 = 1, then EUD_EN2 = 1), but only when the device's debug policy asks for the EUD.
Take the register from the optional "qcom,tcsr-reg" property and write it through qcom_scm_io_writel(), like EUD_EN2:
- on enable, set it right before EUD_EN2, and clear it again if EUD_EN2 is refused;
- on disable, clear it after EUD_EN2.
Whether the writes are allowed stays the secure firmware's decision.
--- drivers/usb/misc/qcom_eud.c | 55 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-)
drivers/usb/misc/qcom_eud.c +54 -1
@@ -11,6 +11,7 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/of_address.h> #include <linux/platform_device.h> #include <linux/slab.h> #include <linux/sysfs.h>
@@ -36,6 +37,7 @@ struct eud_chip {struct usb_role_switch *role_sw;void __iomem *base;phys_addr_t mode_mgr; +phys_addr_t tcsr_check;unsigned int int_status;int irq;bool enabled;
@@ -46,9 +48,23 @@ static int enable_eud(struct eud_chip *priv) {int ret; +/* +* On QCM2290 the boot firmware sets the TCSR check register before +* EUD_EN2; without it the mode manager ignores the enable. +*/ +if (priv->tcsr_check) { + ret =qcom_scm_io_writel (priv->tcsr_check,1 ); +if (ret) +return ret; + } + ret =qcom_scm_io_writel (priv->mode_mgr +EUD_REG_EUD_EN2 ,1 ); -if (ret) +if (ret) { +/* The enable was refused: do not leave the check register set */ +if (priv->tcsr_check) +qcom_scm_io_writel (priv->tcsr_check,0 );return ret; + }writel (EUD_ENABLE , priv->base +EUD_REG_CSR_EUD_EN ); writel(EUD_INT_VBUS | EUD_INT_SAFE_MODE,
@@ -65,6 +81,9 @@ static int disable_eud(struct eud_chip *priv)if (ret)return ret; +if (priv->tcsr_check) +qcom_scm_io_writel (priv->tcsr_check,0 ); +writel (0 , priv->base +EUD_REG_CSR_EUD_EN );return 0 ; }
@@ -190,6 +209,36 @@ static void eud_role_switch_release(void *data)usb_role_switch_put (chip->role_sw); } +/* +* Optional TCSR check register, given as a TCSR syscon phandle and an offset. +* It is written through the secure IO SMC, so only its address is needed. +*/ +static int eud_find_tcsr_check (struct eud_chip *chip) +{ +struct device_node *np = chip->dev->of_node; +struct of_phandle_args args; +struct resource res; +int ret; + + ret =of_parse_phandle_with_fixed_args (np,"qcom,tcsr-reg" ,1 ,0 , &args); +if (ret == -ENOENT ) +return 0 ; +if (ret) +return ret; + + ret =of_address_to_resource (args.np,0 , &res); +of_node_put (args.np); +if (ret) +return ret; + +if (args.args[0 ] >resource_size (&res) -sizeof (u32)) +return -EINVAL ; + + chip->tcsr_check = res.start + args.args[0 ]; + +return 0 ; +} +static int eud_probe (struct platform_device *pdev) {struct eud_chip *chip;
@@ -220,6 +269,10 @@ static int eud_probe(struct platform_device *pdev)return -ENODEV ; chip->mode_mgr = res->start; + ret =eud_find_tcsr_check (chip); +if (ret) +return ret; + chip->irq =platform_get_irq (pdev,0 );if (chip->irq <0 )return chip->irq;
Signature · 1 line
2.53.0
PATCH v2 4/5 arm64: dts: qcom: agatti: add the Embedded USB Debugger
In reply to Igor OpaniukDescribe the EUD:
- its CSRs at 0x1610000 and the mode manager register at 0x1612000;
- TCSR_APSS_SPARE_REG1 (0x3e5018), as offset 0x25018 into the TCSR syscon;
- its interrupt (eud_int[1], GIC SPI 189).
Hook its port to a second endpoint of the dwc3 high-speed port so the driver finds the role switch, while the board keeps the first endpoint for its connector.
--- arch/arm64/boot/dts/qcom/agatti.dtsi | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/agatti.dtsi +33 -1
@@ -826,6 +826,30 @@ gcc: clock-controller@1400000 { #power-domain-cells = <1>; }; + eud: eud@1610000 { + compatible = "qcom,qcm2290-eud", "qcom,eud"; + reg = <0x0 0x01610000 0x0 0x2000>, + <0x0 0x01612000 0x0 0x1000>; + interrupts = <GIC_SPI 189 IRQ_TYPE_LEVEL_HIGH>; + + qcom,tcsr-reg = <&tcsr_regs 0x25018>; + + status = "disabled"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + + eud_ep: endpoint { + remote-endpoint = <&usb_dwc3_hs_eud>; + }; + }; + }; + }; + usb_hsphy: phy@1613000 { compatible = "qcom,qcm2290-qusb2-phy"; reg = <0x0 0x01613000 0x0 0x180>;
@@ -1680,8 +1704,16 @@ ports { port@0 { reg = <0>; + #address-cells = <1>; + #size-cells = <0>; - usb_dwc3_hs: endpoint { + usb_dwc3_hs: endpoint@0 { + reg = <0>; + }; + + usb_dwc3_hs_eud: endpoint@1 { + reg = <1>; + remote-endpoint = <&eud_ep>; }; };
Signature · 1 line
2.53.0
Re: [PATCH v2 4/5] arm64: dts: qcom: agatti: add the Embedded USB Debugger
Quoted 7 lines · Igor Opaniuk
Describe the EUD:
- its CSRs at
0x1610000and the mode manager register at0x1612000;
-TCSR_APSS_SPARE_REG1(0x3e5018), as offset0x25018into the TCSR syscon;
- its interrupt (eud_int[1], GIC SPI 189).
Quoted 5 lines
Hook its port to a second endpoint of the dwc3 high-speed port so the driver finds the role switch, while the board keeps the first endpoint for its connector.
Signed-off-by Igor Opaniuk <[email protected]>
LGTM, so:
Re: [PATCH v2 4/5] arm64: dts: qcom: agatti: add the Embedded USB Debugger
In reply to Igor OpaniukQuoted 7 lines · Igor Opaniuk
Describe the EUD:
- its CSRs at
0x1610000and the mode manager register at0x1612000;
-TCSR_APSS_SPARE_REG1(0x3e5018), as offset0x25018into the TCSR syscon;
- its interrupt (eud_int[1], GIC SPI 189).
Quoted 6 lines
Hook its port to a second endpoint of the dwc3 high-speed port so the driver finds the role switch, while the board keeps the first endpoint for its connector.
Signed-off-by Igor Opaniuk <[email protected]>---
USB parts in this patchset grew here, so now DTS must be split:
DTS cannot be combined in this patchset and must be split. Don't mix patches from independent subsystems when you send something explicitly targeting only one subsystem.
See also: Documentation/devicetree/bindings/submitting-patches.rst
Best regards,
Krzysztof
Re: [PATCH v2 4/5] arm64: dts: qcom: agatti: add the Embedded USB Debugger
Hi Krzysztof,
Quoted 9 lines · Krzysztof Kozlowski
Quoted 7 lines · Igor Opaniuk
Describe the EUD:
- its CSRs at
0x1610000and the mode manager register at0x1612000;
-TCSR_APSS_SPARE_REG1(0x3e5018), as offset0x25018into the TCSR syscon;
- its interrupt (eud_int[1], GIC SPI 189).
Quoted 8 lines
Quoted 6 lines
Hook its port to a second endpoint of the dwc3 high-speed port so the driver finds the role switch, while the board keeps the first endpoint for its connector.
Signed-off-by Igor Opaniuk <[email protected]>---
USB parts in this patchset grew here, so now DTS must be split:
Will do in v3, thanks!
Quoted 9 lines
DTS cannot be combined in this patchset and must be split. Don't mix patches from independent subsystems when you send something explicitly targeting only one subsystem.
See also:Documentation/devicetree/bindings/submitting-patches.rstBest regards,
Krzysztof
Best regards,
Igor
PATCH v2 5/5 arm64: dts: qcom: qrb2210-arduino-imola: enable the EUD
In reply to Igor OpaniukThe UNO Q exposes the EUD on its USB-C port: with it enabled, a host sees the EUD hub and its SWD/trace functions, which OpenOCD's EUD adapter uses to debug the SoC.
--- arch/arm64/boot/dts/qcom/qrb2210-arduino-imola.dts | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm64/boot/dts/qcom/qrb2210-arduino-imola.dts +4 -0
@@ -226,6 +226,10 @@ vph_pwr: regulator-vph-pwr { }; }; +&eud { + status = "okay"; +}; + &gpi_dma0 { status = "okay"; };
Signature · 1 line
2.53.0
Re: [PATCH v2 5/5] arm64: dts: qcom: qrb2210-arduino-imola: enable the EUD
Quoted 5 lines · Igor Opaniuk
The UNO Q exposes the EUD on its USB-C port: with it enabled, a host sees the EUD hub and its SWD/trace functions, which OpenOCD's EUD adapter uses to debug the SoC.
Signed-off-by Igor Opaniuk <[email protected]>
[email protected]
AI reviewSashiko has reviewed this 5-patch series and found no issues.
Sashiko has reviewed this 5-patch series and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]