From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9FABE2FFF99 for ; Wed, 25 Feb 2026 06:43:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772001832; cv=none; b=Mr3kTs1Asxd1PteEh5/AuFomlqt8ZsDVxHZJZK2l+9KFKiYOVcS3RMBik57il0kXaTjPWGrCdgg5q0JwJGXQ1rdFTTriuMuWovuK1BDRD/PDnTMrEnI36DvipLWDBNaBQkKuFIkURWacfIRQEGq8kPrJ4L/4ynYRL3r7R5Ybr+E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772001832; c=relaxed/simple; bh=2/6Degxp7ls2d8D8xPc26dEqc+84ZT2Bgm76mBX3ZCc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=t2iQ9PPw670ffVKHJr9aXbVLtcO45uP34OngJAPSx510EnD0P6brdLZKcsH7RsNsHZG/+fbpK1f1UPu5gau0YKd4lAi1K5w+2fvyKZ9DxAjyxuH7kS7tLt56G8jqXyAnxHaMWE/xduetEPD16rSZRL3O2KxJZm6x0UzlHzb9WeI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=UhYxMXq5; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=UW2mwXKL; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="UhYxMXq5"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="UW2mwXKL" Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 61ONIWDN4044554 for ; Wed, 25 Feb 2026 06:43:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= HRprrDZrnbfgMS9tr7mTH+TkKXh96VfAvqJuPeXhuvE=; b=UhYxMXq54foXaa0c IoyfudS6PKi+dZctDirpG27k3eVKN6Lscitoe6imYp8PhUyy5nvVEifBS1lQUtpc 3KXrxTTkEPpH8j65xNV/7iRiwUX/IHEEGGLyEs+xYJNrQVYr0k6Qh0r6+VdrsiUi +F0As6lwq6LHg+YCF1p/7TSzjUmlFuBz6OMcZlqmQWSdblsYdu9nuV21w1YiOPNe dRiSjVfrFEhgDM+PQXheBgwrFXUqHWDnCC7NSb0M46AMrGk2A/vAt+tpyjPZsxkP tjSTxKr0MrhhSqlVjgFrfOUc4QrX1mRnR72X2kYqDrr5O/+Eo2rN+Fb/bO6IB25j 9aw46w== Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4chexejfta-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 25 Feb 2026 06:43:49 +0000 (GMT) Received: by mail-pg1-f199.google.com with SMTP id 41be03b00d2f7-c70eb09daefso146443a12.0 for ; Tue, 24 Feb 2026 22:43:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1772001829; x=1772606629; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=HRprrDZrnbfgMS9tr7mTH+TkKXh96VfAvqJuPeXhuvE=; b=UW2mwXKLycG6WmQF/YCEaXWIU/NqNe4v8+ff2e2dAu4fUzQ9WMOPkeUIsU7///7hbJ KnN74T6kdsVlgIFujInJwonQ6tW3cjLc6RuOUJq96aG6YGuvfQq2Rvsxwt3yP8iZoSXb Se9hqHIWr2Ua37UKe62rTGU0yP2TeZOclfVpIRmIXE2vhljwBAETPNSL0UiV9BYZjsrv L3ODhKm9d1hIHIcSIK4yk0lp90BvhkSiMf/whNziNn+chhIuL8C2bxDhSIlDyrIHdCNN 9Tt9LHsScU3cecY/I8AF2an6fMOaI1ZM412i3rrp8hJLj8gBotVdvF2jAqLGBFUD8Kw7 fh5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772001829; x=1772606629; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=HRprrDZrnbfgMS9tr7mTH+TkKXh96VfAvqJuPeXhuvE=; b=Vn0AM2IJhUoGO2Wk+uedGhQmtazIPmBKD100lqbll8ap+AhY4JwcCOwq3Nlj3vgkfS T4ovHkBsP9Hz2Tq8dcZyLPEeI+2Fq3aUXVAcB215dJpdpxgWWmYSlHvPTRlC5JYVtb5L IxSL++OnflW4e2VaDqbikoKa1FKussb7z/BXWdmbFgouyHg1zyLiro+ZXsE/L0ifWEXd frY++XIjC21yP9JTCQrXGbn8cIPkalCaeUfd1poIg1VUcRwJH1bi3OHpGo6Q6SfWEdTn CU08F34FqH+ig+erWJnpH5T4JhR/swdglXdmDPYxlPtfXQDc0T/h1vhZyA/Lv/LwjJRI 0LSw== X-Forwarded-Encrypted: i=1; AJvYcCXwIkvskQ1Bkz4mfgpvt/KiLixs2+96fAPuu42i8BvYLjE0mv+yxsq2eYsGzpax5g7KfWPdCYgYmfINGkw=@vger.kernel.org X-Gm-Message-State: AOJu0YxwNCuQ4yv1O2OjieJPno5GtYFyd97ZZGayS+4neiMNWvK1op70 5de4jJRNa43KRE1CPZGWTg04EKt4AHWvWHfB+QMaua1jVkz90cLQgKhzRKC0ArMMWJvxmEKC16E NAITJamJug/vATa00BfOW7hw3zBII1/xJO/YvB5Ps8pVRbbNiBIA/nKWudM+A2Hf88Zc= X-Gm-Gg: ATEYQzygQXT/s+HZ9YX2FsxY3FcPz6nAvw+iRxH2tz07gc3A0rmltmCysmVFPPIZGnX f4nNmpBhIeljH78UAnrGkOmrb/QIFVCAOBuCltRyzCVpKlKAKmNyjxY7rA9WHpqroOKTcHiuT5f GRP0ARr1yCSNUAtuDufpDGH7bEKTi3m6shDwTq2QrvZGzh/7hdV4sqwk4/unCwmIOZf5UimU/cC S4b/vJaj2JuhyHd2FAkhJp+JqAiTEuOmLWglZ7oSF2dzc9/Ag2tY9YiNXIHH8hXYIlyxbw+HcZM MNd2c6K5+ipPCB5SrmIjLHQfulQJLbBMJ7rP7O8IFQfmVXDGSBZr8ISvls7uZciFAAv2mbbuWdq 2TGFeDa1Wbik8k4T5T/SBzcPO/H9WpVua2DUMQnSDE+6qRiCuxaYMtsmZzeBI8FBT9n5ATCCx+T h3vAj4lf8R4dIPkvWlrNiOs7Vrg0dhHS0NjJPFH59oaGgkTea4uD75I+my X-Received: by 2002:a05:6a00:3a14:b0:81f:48d4:a979 with SMTP id d2e1a72fcca58-82724aef59amr1164971b3a.49.1772001828559; Tue, 24 Feb 2026 22:43:48 -0800 (PST) X-Received: by 2002:a05:6a00:3a14:b0:81f:48d4:a979 with SMTP id d2e1a72fcca58-82724aef59amr1164950b3a.49.1772001828091; Tue, 24 Feb 2026 22:43:48 -0800 (PST) Received: from hu-kathirav-blr.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-826dd692b99sm12856570b3a.24.2026.02.24.22.43.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Feb 2026 22:43:47 -0800 (PST) From: Kathiravan Thirumoorthy Date: Wed, 25 Feb 2026 12:13:13 +0530 Subject: [PATCH v7 4/5] watchdog: qcom: add support to get the bootstatus from IMEM Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260225-wdt_reset_reason-v7-4-65d5b7e3e1eb@oss.qualcomm.com> References: <20260225-wdt_reset_reason-v7-0-65d5b7e3e1eb@oss.qualcomm.com> In-Reply-To: <20260225-wdt_reset_reason-v7-0-65d5b7e3e1eb@oss.qualcomm.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bjorn Andersson , Konrad Dybcio , Wim Van Sebroeck , Guenter Roeck , Rajendra Nayak Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org, Kathiravan Thirumoorthy X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1772001806; l=4138; i=kathiravan.thirumoorthy@oss.qualcomm.com; s=20230906; h=from:subject:message-id; bh=2/6Degxp7ls2d8D8xPc26dEqc+84ZT2Bgm76mBX3ZCc=; b=GSUHP2MXZT7g9xlSvOjgIR+Uox5ha4fkv4Jp5Vah3qDHUN4xADELEBnGTDciblqr/1Kyy5Wll XqQvb5NtzvEDxsKcbX+yt5RgTkKoiqiV66M0S9PsxHZwgRz9DmwJ2Y4 X-Developer-Key: i=kathiravan.thirumoorthy@oss.qualcomm.com; a=ed25519; pk=xWsR7pL6ch+vdZ9MoFGEaP61JUaRf0XaZYWztbQsIiM= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMjI1MDA2MiBTYWx0ZWRfXzieuEcppBrSs oN57SRo5IAeQeUxkJ7bZhOcE2oVfDsZ1iogzxUVIwylLFRJSS61+6mVZMF45IFD2fcZPjrG6Est fPhl8ZEoS50TAUUm5gNRc7+LcHFMBKVdbgsgDRsut/VwozmMHsLjwJbMLrCGGUU4L/QWgrEiO00 KCrYabLxM2x4QmrwwvzREckPclZN0b6gcHZklK+AxZhGPwF39kcHnC6Agket5VS7Ra4ODJVPd8F OCiiIWT2JFanmete85duB4qNrU6z5eqUY3TCyK5b0Qq9ci2jqjP8Zsv/VlRB4fCoVT9Ylhgfai6 9NNGXhLnTEPlptGNWaV0Omd9X6raG0SAViWGm//DDgEN3VgQO94TgwvUG/1W1LEJFj4le9+P4Kk i71PlESarbj6S9koK8PACzZxzSq0IUsRQp3PK6lt9lipeFp5C87i4gjV8DAuFbZWlj4MQtOVbgQ W0cAL2YkH6XnFxC9Siw== X-Authority-Analysis: v=2.4 cv=V85wEOni c=1 sm=1 tr=0 ts=699e9a25 cx=c_pps a=Oh5Dbbf/trHjhBongsHeRQ==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=IkcTkHD0fZMA:10 a=HzLeVaNsDn8A:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=gowsoOTTUOVcmtlkKump:22 a=EUspDBNiAAAA:8 a=sA5c4iyB6yEouCyTFbQA:9 a=QEXdDO2ut3YA:10 a=_Vgx9l1VpLgwpw_dHYaR:22 X-Proofpoint-GUID: TTmJxyBJxrPifKgtqIkIKXE0aDOWDzib X-Proofpoint-ORIG-GUID: TTmJxyBJxrPifKgtqIkIKXE0aDOWDzib X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-02-24_03,2026-02-23_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 bulkscore=0 malwarescore=0 priorityscore=1501 spamscore=0 suspectscore=0 phishscore=0 adultscore=0 lowpriorityscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2602130000 definitions=main-2602250062 When the system boots up after a watchdog reset, the EXPIRED_STATUS bit in the WDT_STS register is cleared. To identify if the system was restarted due to WDT expiry, XBL update the information in the IMEM region. Update the driver to read the restart reason from IMEM and populate the bootstatus accordingly. With the CONFIG_WATCHDOG_SYSFS enabled, user can extract the information as below: cat /sys/devices/platform/soc@0/f410000.watchdog/watchdog/watchdog0/bootstatus 32 For backward compatibility, keep the EXPIRED_STATUS bit check. Add a new function qcom_wdt_get_bootstatus() to read the restart reason from IMEM. Signed-off-by: Kathiravan Thirumoorthy --- Changes in v7: - no changes Changes in v6: - Reworked to get the restart reason code from SRAM region Changes in v5: - Use dev_err_probe instead of dev_err Changes in v4: - Kept only WDIOF_CARDRESET and dropped other codes - Renamed qcom_wdt_get_reason_reason() to qcom_wdt_get_bootstatus() - Moved the existing check inside qcom_wdt_get_bootstatus() - Dropped the device data and put all the details in the DT node Changes in v3: - Split the introduction of device data into separate patch - s/bootloaders/XBL - for clarity of which bootloader is involved - Mention the sysfs path on to extract this information - s/compatible/imem_compatible in the device data structure to avoid the confusion / better naming Changes in v2: - Use the syscon API to access the IMEM region - Handle the error cases returned by qcom_wdt_get_restart_reason - Define device specific data to retrieve the IMEM compatible, offset and the value for non secure WDT, which allows to extend the support for other SoCs --- drivers/watchdog/qcom-wdt.c | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/drivers/watchdog/qcom-wdt.c b/drivers/watchdog/qcom-wdt.c index dfaac5995c84c1f377023e6e62770c5548528a4c..14853162d57ccae3092fb1c01616fdfca0108e74 100644 --- a/drivers/watchdog/qcom-wdt.c +++ b/drivers/watchdog/qcom-wdt.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -42,6 +43,7 @@ struct qcom_wdt_match_data { const u32 *offset; bool pretimeout; u32 max_tick_count; + u32 wdt_reason_val; }; struct qcom_wdt { @@ -185,6 +187,7 @@ static const struct qcom_wdt_match_data match_data_ipq5424 = { .offset = reg_offset_data_kpss, .pretimeout = true, .max_tick_count = 0xFFFFFU, + .wdt_reason_val = 5, }; static const struct qcom_wdt_match_data match_data_kpss = { @@ -193,6 +196,41 @@ static const struct qcom_wdt_match_data match_data_kpss = { .max_tick_count = 0xFFFFFU, }; +static int qcom_wdt_get_bootstatus(struct device *dev, struct qcom_wdt *wdt, + u32 val) +{ + struct device_node *imem; + struct resource res; + void __iomem *addr; + int ret; + + imem = of_parse_phandle(dev->of_node, "sram", 0); + if (!imem) { + + /* Fallback to the existing check */ + if (readl(wdt_addr(wdt, WDT_STS)) & 1) + wdt->wdd.bootstatus = WDIOF_CARDRESET; + + return 0; + } + + ret = of_address_to_resource(imem, 0, &res); + of_node_put(imem); + if (ret) + return ret; + + addr = ioremap(res.start, resource_size(&res)); + if (!addr) + return -ENOMEM; + + if (readl(addr) == val) + wdt->wdd.bootstatus = WDIOF_CARDRESET; + + iounmap(addr); + + return 0; +} + static int qcom_wdt_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -273,8 +311,9 @@ static int qcom_wdt_probe(struct platform_device *pdev) wdt->wdd.parent = dev; wdt->layout = data->offset; - if (readl(wdt_addr(wdt, WDT_STS)) & 1) - wdt->wdd.bootstatus = WDIOF_CARDRESET; + ret = qcom_wdt_get_bootstatus(dev, wdt, data->wdt_reason_val); + if (ret) + return ret; /* * If 'timeout-sec' unspecified in devicetree, assume a 30 second -- 2.34.1