]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
firmware: qcom: scm: Register gunyah watchdog device
authorHrishabh Rajput <hrishabh.rajput@oss.qualcomm.com>
Wed, 11 Mar 2026 05:46:30 +0000 (11:16 +0530)
committerBjorn Andersson <andersson@kernel.org>
Mon, 30 Mar 2026 14:10:24 +0000 (09:10 -0500)
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>
Signed-off-by: Pavankumar Kondeti <pavan.kondeti@oss.qualcomm.com>
Tested-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20260311-gunyah_watchdog-v8-1-4c1c0689de22@oss.qualcomm.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
drivers/firmware/qcom/qcom_scm.c

index a5a2c25f463b15e2d78207928f384d6197938b60..9292af4a76d215f35c2fac28acfecbd199296daf 100644 (file)
@@ -2470,6 +2470,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;
@@ -2814,6 +2864,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;
 }