Skip to content

Commit 07b9712

Browse files
qhrshbhandersson
authored andcommitted
firmware: qcom: scm: Register gunyah watchdog device
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 <[email protected]> Tested-by: Shivendra Pratap <[email protected]> Tested-by: Neil Armstrong <[email protected]> Signed-off-by: Hrishabh Rajput <[email protected]> Signed-off-by: Pavankumar Kondeti <[email protected]> Tested-by: Mukesh Ojha <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bjorn Andersson <[email protected]>
1 parent f55fa3e commit 07b9712

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

drivers/firmware/qcom/qcom_scm.c

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2470,6 +2470,56 @@ int qcom_scm_qtee_callback_response(phys_addr_t buf, size_t buf_size,
24702470
}
24712471
EXPORT_SYMBOL(qcom_scm_qtee_callback_response);
24722472

2473+
static void qcom_scm_gunyah_wdt_free(void *data)
2474+
{
2475+
struct platform_device *gunyah_wdt_dev = data;
2476+
2477+
platform_device_unregister(gunyah_wdt_dev);
2478+
}
2479+
2480+
static void qcom_scm_gunyah_wdt_init(struct qcom_scm *scm)
2481+
{
2482+
struct platform_device *gunyah_wdt_dev;
2483+
struct device_node *np;
2484+
bool of_wdt_available;
2485+
int i;
2486+
static const uuid_t gunyah_uuid = UUID_INIT(0xc1d58fcd, 0xa453, 0x5fdb,
2487+
0x92, 0x65, 0xce, 0x36,
2488+
0x67, 0x3d, 0x5f, 0x14);
2489+
static const char * const of_wdt_compatible[] = {
2490+
"qcom,kpss-wdt",
2491+
"arm,sbsa-gwdt",
2492+
};
2493+
2494+
/* Bail out if we are not running under Gunyah */
2495+
if (!IS_ENABLED(CONFIG_HAVE_ARM_SMCCC_DISCOVERY) ||
2496+
!arm_smccc_hypervisor_has_uuid(&gunyah_uuid))
2497+
return;
2498+
2499+
/*
2500+
* Gunyah emulates either of Qualcomm watchdog or ARM SBSA watchdog on
2501+
* newer platforms. Bail out if we find them in the devicetree.
2502+
*/
2503+
for (i = 0; i < ARRAY_SIZE(of_wdt_compatible); i++) {
2504+
np = of_find_compatible_node(NULL, NULL, of_wdt_compatible[i]);
2505+
of_wdt_available = of_device_is_available(np);
2506+
of_node_put(np);
2507+
if (of_wdt_available)
2508+
return;
2509+
}
2510+
2511+
gunyah_wdt_dev = platform_device_register_simple("gunyah-wdt", -1,
2512+
NULL, 0);
2513+
if (IS_ERR(gunyah_wdt_dev)) {
2514+
dev_err(scm->dev, "Failed to register Gunyah watchdog device: %ld\n",
2515+
PTR_ERR(gunyah_wdt_dev));
2516+
return;
2517+
}
2518+
2519+
devm_add_action_or_reset(scm->dev, qcom_scm_gunyah_wdt_free,
2520+
gunyah_wdt_dev);
2521+
}
2522+
24732523
static void qcom_scm_qtee_free(void *data)
24742524
{
24752525
struct platform_device *qtee_dev = data;
@@ -2814,6 +2864,9 @@ static int qcom_scm_probe(struct platform_device *pdev)
28142864
/* Initialize the QTEE object interface. */
28152865
qcom_scm_qtee_init(scm);
28162866

2867+
/* Initialize the Gunyah watchdog platform device. */
2868+
qcom_scm_gunyah_wdt_init(scm);
2869+
28172870
return 0;
28182871
}
28192872

0 commit comments

Comments
 (0)