From: Hrishabh Rajput via B4 Relay <devnull+hrishabh.rajput.oss.qualcomm.com@kernel.org>
To: Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
Wim Van Sebroeck <wim@linux-watchdog.org>,
Guenter Roeck <linux@roeck-us.net>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>
Cc: linux-arm-msm@vger.kernel.org, linux-watchdog@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
Pavan Kondeti <pavan.kondeti@oss.qualcomm.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,
Hrishabh Rajput <hrishabh.rajput@oss.qualcomm.com>,
Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
Subject: [PATCH v8 1/2] firmware: qcom: scm: Register gunyah watchdog device
Date: Tue, 18 Nov 2025 10:40:56 +0000 [thread overview]
Message-ID: <20251118-gunyah_watchdog-v8-1-e5de12e2eef5@oss.qualcomm.com> (raw)
In-Reply-To: <20251118-gunyah_watchdog-v8-0-e5de12e2eef5@oss.qualcomm.com>
From: Hrishabh Rajput <hrishabh.rajput@oss.qualcomm.com>
To restrict Gunyah watchdog initialization to Qualcomm platforms running
under the Gunyah Hypervisor, register the watchdog device in the QCOM
SCM driver.
When Gunyah is not present or Gunyah emulates MMIO-based watchdog, we
expect Qualcomm watchdog or ARM SBSA watchdog device to be present in
the devicetree. First, we make sure we're running under the Gunyah
Hypervisor. Then we move to check if any of the above mentioned
watchdog device nodes are present, if not then we proceed to register
the SMC-based Gunyah watchdog device.
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Tested-by: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Hrishabh Rajput <hrishabh.rajput@oss.qualcomm.com>
---
drivers/firmware/qcom/qcom_scm.c | 53 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c
index e777b7cb9b12..14d0663316e6 100644
--- a/drivers/firmware/qcom/qcom_scm.c
+++ b/drivers/firmware/qcom/qcom_scm.c
@@ -2182,6 +2182,56 @@ int qcom_scm_qtee_callback_response(phys_addr_t buf, size_t buf_size,
}
EXPORT_SYMBOL(qcom_scm_qtee_callback_response);
+static void qcom_scm_gunyah_wdt_free(void *data)
+{
+ struct platform_device *gunyah_wdt_dev = data;
+
+ platform_device_unregister(gunyah_wdt_dev);
+}
+
+static void qcom_scm_gunyah_wdt_init(struct qcom_scm *scm)
+{
+ struct platform_device *gunyah_wdt_dev;
+ struct device_node *np;
+ bool of_wdt_available;
+ int i;
+ static const uuid_t gunyah_uuid = UUID_INIT(0xc1d58fcd, 0xa453, 0x5fdb,
+ 0x92, 0x65, 0xce, 0x36,
+ 0x67, 0x3d, 0x5f, 0x14);
+ static const char * const of_wdt_compatible[] = {
+ "qcom,kpss-wdt",
+ "arm,sbsa-gwdt",
+ };
+
+ /* Bail out if we are not running under Gunyah */
+ if (!IS_ENABLED(CONFIG_HAVE_ARM_SMCCC_DISCOVERY) ||
+ !arm_smccc_hypervisor_has_uuid(&gunyah_uuid))
+ return;
+
+ /*
+ * Gunyah emulates either of Qualcomm watchdog or ARM SBSA watchdog on
+ * newer platforms. Bail out if we find them in the devicetree.
+ */
+ for (i = 0; i < ARRAY_SIZE(of_wdt_compatible); i++) {
+ np = of_find_compatible_node(NULL, NULL, of_wdt_compatible[i]);
+ of_wdt_available = of_device_is_available(np);
+ of_node_put(np);
+ if (of_wdt_available)
+ return;
+ }
+
+ gunyah_wdt_dev = platform_device_register_simple("gunyah-wdt", -1,
+ NULL, 0);
+ if (IS_ERR(gunyah_wdt_dev)) {
+ dev_err(scm->dev, "Failed to register Gunyah watchdog device: %ld\n",
+ PTR_ERR(gunyah_wdt_dev));
+ return;
+ }
+
+ devm_add_action_or_reset(scm->dev, qcom_scm_gunyah_wdt_free,
+ gunyah_wdt_dev);
+}
+
static void qcom_scm_qtee_free(void *data)
{
struct platform_device *qtee_dev = data;
@@ -2448,6 +2498,9 @@ static int qcom_scm_probe(struct platform_device *pdev)
/* Initialize the QTEE object interface. */
qcom_scm_qtee_init(scm);
+ /* Initialize the Gunyah watchdog platform device. */
+ qcom_scm_gunyah_wdt_init(scm);
+
return 0;
}
--
2.43.0
next prev parent reply other threads:[~2025-11-18 10:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-18 10:40 [PATCH v8 0/2] Add support for Gunyah Watchdog Hrishabh Rajput via B4 Relay
2025-11-18 10:40 ` Hrishabh Rajput via B4 Relay [this message]
2025-11-18 11:18 ` [PATCH v8 1/2] firmware: qcom: scm: Register gunyah watchdog device Kathiravan Thirumoorthy
2025-11-18 11:32 ` Krzysztof Kozlowski
2025-11-18 11:46 ` Krzysztof Kozlowski
2025-11-18 10:40 ` [PATCH v8 2/2] watchdog: Add driver for Gunyah Watchdog Hrishabh Rajput via B4 Relay
2025-11-18 12:24 ` Dmitry Baryshkov
2025-11-19 5:18 ` Guenter Roeck
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=20251118-gunyah_watchdog-v8-1-e5de12e2eef5@oss.qualcomm.com \
--to=devnull+hrishabh.rajput.oss.qualcomm.com@kernel.org \
--cc=andersson@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=hrishabh.rajput@oss.qualcomm.com \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=neil.armstrong@linaro.org \
--cc=pavan.kondeti@oss.qualcomm.com \
--cc=robh@kernel.org \
--cc=shivendra.pratap@oss.qualcomm.com \
--cc=wim@linux-watchdog.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;
as well as URLs for NNTP newsgroup(s).