From: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
To: Souradeep Chowdhury <quic_schowdhu@quicinc.com>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
Abel Vesa <abelvesa@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
Elson Serrao <elson.serrao@oss.qualcomm.com>,
Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
Subject: [PATCH v2 3/5] usb: misc: qcom_eud: set the TCSR check register before enabling on QCM2290
Date: Mon, 23 Nov 2026 17:42:58 +0100 [thread overview]
Message-ID: <20261123-qcm2290-eud-v2-3-9bfc432dee07@oss.qualcomm.com> (raw)
In-Reply-To: <20261123-qcm2290-eud-v2-0-9bfc432dee07@oss.qualcomm.com>
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
next prev parent reply other threads:[~2026-11-23 16:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 16:42 [PATCH v2 0/5] arm64: qcom: QCM2290: add the Embedded USB Debugger Igor Opaniuk
2026-11-23 16:42 ` [PATCH v2 1/5] usb: misc: qcom_eud: clear the enabled state on disable Igor Opaniuk
2026-11-23 16:42 ` [PATCH v2 2/5] dt-bindings: soc: qcom: eud: add the QCM2290 EUD Igor Opaniuk
2026-11-23 16:42 ` Igor Opaniuk [this message]
2026-11-23 16:42 ` [PATCH v2 4/5] arm64: dts: qcom: agatti: add the Embedded USB Debugger Igor Opaniuk
2026-11-23 19:49 ` Abel Vesa
2026-11-23 16:43 ` [PATCH v2 5/5] arm64: dts: qcom: qrb2210-arduino-imola: enable the EUD Igor Opaniuk
2026-11-23 19:49 ` Abel Vesa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261123-qcm2290-eud-v2-3-9bfc432dee07@oss.qualcomm.com \
--to=igor.opaniuk@oss.qualcomm.com \
--cc=abelvesa@kernel.org \
--cc=andersson@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=elson.serrao@oss.qualcomm.com \
--cc=gregkh@linuxfoundation.org \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=quic_schowdhu@quicinc.com \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®