* [PATCH v3 0/2] usb: misc: qcom_eud: add the QCM2290 Embedded USB Debugger
@ 2026-11-24 17:46 Igor Opaniuk
2026-11-24 17:46 ` [PATCH v3 1/2] usb: misc: qcom_eud: clear the enabled state on disable Igor Opaniuk
2026-11-24 17:46 ` [PATCH v3 2/2] usb: misc: qcom_eud: set the TCSR check register before enabling on QCM2290 Igor Opaniuk
0 siblings, 2 replies; 3+ messages in thread
From: Igor Opaniuk @ 2026-11-24 17:46 UTC (permalink / raw)
To: Souradeep Chowdhury, Bjorn Andersson, Konrad Dybcio, Abel Vesa,
Greg Kroah-Hartman
Cc: linux-arm-msm, linux-kernel, linux-usb, Elson Serrao,
Krzysztof Kozlowski, Mukesh Ojha, Igor Opaniuk
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.
W=1 and checkpatch are clean.
The binding (2/5 of v2) and the DTS patches (4/5 and 5/5) are now a
separate series, "arm64: dts: qcom: QCM2290: add the Embedded USB
Debugger", so that each series stays within one subsystem. It documents
the "qcom,tcsr-reg" property that patch 2 reads.
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 v3:
- Split by subsystem (Krzysztof): the binding and the DTS patches are
now a separate series; this one keeps the two USB driver patches,
both unchanged.
- Collected Reviewed-by from Mukesh (patch 1). Krzysztof's Reviewed-by
on the binding moved with it to the other series. No patch changed,
so no tags were dropped.
- Link to v2: https://lore.kernel.org/r/20261123-qcm2290-eud-v2-0-9bfc432dee07@oss.qualcomm.com
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/20261114-qcm2290-eud-v1-0-b6157b817377@oss.qualcomm.com
---
Igor Opaniuk (2):
usb: misc: qcom_eud: clear the enabled state on disable
usb: misc: qcom_eud: set the TCSR check register before enabling on QCM2290
drivers/usb/misc/qcom_eud.c | 57 ++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 56 insertions(+), 1 deletion(-)
---
base-commit: 84abb955b1015477aa11a96e2f3ac1b938b77f48
change-id: 20261114-qcm2290-eud-81e10f3a8e5f
Best regards,
--
Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH v3 1/2] usb: misc: qcom_eud: clear the enabled state on disable
2026-11-24 17:46 [PATCH v3 0/2] usb: misc: qcom_eud: add the QCM2290 Embedded USB Debugger Igor Opaniuk
@ 2026-11-24 17:46 ` Igor Opaniuk
2026-11-24 17:46 ` [PATCH v3 2/2] usb: misc: qcom_eud: set the TCSR check register before enabling on QCM2290 Igor Opaniuk
1 sibling, 0 replies; 3+ messages in thread
From: Igor Opaniuk @ 2026-11-24 17:46 UTC (permalink / raw)
To: Souradeep Chowdhury, Bjorn Andersson, Konrad Dybcio, Abel Vesa,
Greg Kroah-Hartman
Cc: linux-arm-msm, linux-kernel, linux-usb, Elson Serrao,
Krzysztof Kozlowski, Mukesh Ojha, Igor Opaniuk
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.
Fixes: 9a1bf58ccd44 ("usb: misc: eud: Add driver support for Embedded USB Debugger(EUD)")
Reviewed-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
---
drivers/usb/misc/qcom_eud.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/usb/misc/qcom_eud.c b/drivers/usb/misc/qcom_eud.c
index 73f9fac22e19..6743a1c7d717 100644
--- a/drivers/usb/misc/qcom_eud.c
+++ b/drivers/usb/misc/qcom_eud.c
@@ -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;
--
2.53.0
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH v3 2/2] usb: misc: qcom_eud: set the TCSR check register before enabling on QCM2290
2026-11-24 17:46 [PATCH v3 0/2] usb: misc: qcom_eud: add the QCM2290 Embedded USB Debugger Igor Opaniuk
2026-11-24 17:46 ` [PATCH v3 1/2] usb: misc: qcom_eud: clear the enabled state on disable Igor Opaniuk
@ 2026-11-24 17:46 ` Igor Opaniuk
1 sibling, 0 replies; 3+ messages in thread
From: Igor Opaniuk @ 2026-11-24 17:46 UTC (permalink / raw)
To: Souradeep Chowdhury, Bjorn Andersson, Konrad Dybcio, Abel Vesa,
Greg Kroah-Hartman
Cc: linux-arm-msm, linux-kernel, linux-usb, Elson Serrao,
Krzysztof Kozlowski, Mukesh Ojha, Igor Opaniuk
On 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.
Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
---
drivers/usb/misc/qcom_eud.c | 55 ++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 54 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/misc/qcom_eud.c b/drivers/usb/misc/qcom_eud.c
index 6743a1c7d717..30ca6ad564bf 100644
--- a/drivers/usb/misc/qcom_eud.c
+++ b/drivers/usb/misc/qcom_eud.c
@@ -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;
--
2.53.0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-24 17:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-24 17:46 [PATCH v3 0/2] usb: misc: qcom_eud: add the QCM2290 Embedded USB Debugger Igor Opaniuk
2026-11-24 17:46 ` [PATCH v3 1/2] usb: misc: qcom_eud: clear the enabled state on disable Igor Opaniuk
2026-11-24 17:46 ` [PATCH v3 2/2] usb: misc: qcom_eud: set the TCSR check register before enabling on QCM2290 Igor Opaniuk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®