[PATCH v2 3/5] usb: misc: qcom_eud: set the TCSR check register before enabling on QCM2290

From: Igor Opaniuk

Date: Mon Nov 23 2026 - 11:43:29 EST


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@xxxxxxxxxxxxxxxx>
---
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