All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Stein <alexander.stein@ew.tq-group.com>
To: Sudeep Holla <sudeep.holla@kernel.org>,
	Cristian Marussi <cristian.marussi@arm.com>,
	Frank Li <Frank.Li@nxp.com>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	linux-arm-kernel@lists.infradead.org
Cc: arm-scmi@vger.kernel.org, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Peng Fan <peng.fan@nxp.com>,
	"Peng Fan (OSS)" <peng.fan@oss.nxp.com>
Subject: Re: [PATCH 2/2] firmware: imx: sm-misc: Print boot/shutdown reasons
Date: Thu, 05 Mar 2026 08:44:26 +0100	[thread overview]
Message-ID: <24409695.EfDdHjke4D@steina-w> (raw)
In-Reply-To: <20260305-scmi-imx-reset-v1-2-18de78978ba9@nxp.com>

Hi,

Am Donnerstag, 5. März 2026, 02:56:45 CET schrieb Peng Fan (OSS):
> From: Peng Fan <peng.fan@nxp.com>
> 
> Add reset reason string table for i.MX95 and introduce a helper
> (scmi_imx_misc_get_reason) to query and print both system and LM
> (Logical Machine) reset reasons via the SCMI MISC protocol.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/firmware/imx/sm-misc.c | 73 ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 73 insertions(+)
> 
> diff --git a/drivers/firmware/imx/sm-misc.c b/drivers/firmware/imx/sm-misc.c
> index 0a8ada329c9de3c1627da241bf142fa91a8085d7..16b5ff833d21274403a4c55abe2fa1f49fce3e73 100644
> --- a/drivers/firmware/imx/sm-misc.c
> +++ b/drivers/firmware/imx/sm-misc.c
> @@ -18,6 +18,29 @@ static const struct scmi_imx_misc_proto_ops *imx_misc_ctrl_ops;
>  static struct scmi_protocol_handle *ph;
>  struct notifier_block scmi_imx_misc_ctrl_nb;
>  
> +static const char * const rst_imx95[] = {
> +	"cm33_lockup", "cm33_swreq", "cm7_lockup", "cm7_swreq", "fccu",
> +	"jtag_sw", "ele", "tempsense", "wdog1", "wdog2", "wdog3", "wdog4",
> +	"wdog5", "jtag", "cm33_exc", "bbm", "sw", "sm_err", "fusa_sreco",
> +	"pmic", "unused", "unused", "unused", "unused", "unused", "unused",
> +	"unused", "unused", "unused", "unused", "unused", "por",
> +};
> +
> +static const char * const rst_imx94[] = {
> +	"cm33_lockup", "cm33_swreq", "cm70_lockup", "cm70_swreq", "fccu",
> +	"jtag_sw", "ele", "tempsense", "wdog1", "wdog2", "wdog3", "wdog4",
> +	"wdog5", "jtag", "wdog6", "wdog7", "wdog8", "wo_netc", "cm33s_lockup",
> +	"cm33s_swreq", "cm71_lockup", "cm71_swreq", "cm33_exc", "bbm", "sw",
> +	"sm_err", "fusa_sreco", "pmic", "unused", "unused", "unused", "por",
> +};
> +
> +static const struct of_device_id allowlist[] = {
> +	{ .compatible = "fsl,imx952", .data = rst_imx95 },
> +	{ .compatible = "fsl,imx95", .data = rst_imx95 },
> +	{ .compatible = "fsl,imx94", .data = rst_imx94 },
> +	{ /* Sentinel */ }
> +};
> +
>  int scmi_imx_misc_ctrl_set(u32 id, u32 val)
>  {
>  	if (!ph)
> @@ -75,6 +98,54 @@ static void scmi_imx_misc_put(void *p)
>  	debugfs_remove((struct dentry *)p);
>  }
>  
> +static int scmi_imx_misc_get_reason(struct scmi_device *sdev)
> +{
> +	struct scmi_imx_misc_reset_reason boot, shutdown;
> +	const char **rst;
> +	bool system = true;
> +	int ret;
> +
> +	if (!of_machine_device_match(allowlist))
> +		return 0;
> +
> +	rst = (const char **)of_machine_get_match_data(allowlist);
> +
> +	ret = imx_misc_ctrl_ops->misc_reset_reason(ph, system, &boot, &shutdown, NULL);
> +	if (!ret) {
> +		if (boot.valid)
> +			dev_info(&sdev->dev, "%s Boot reason: %s, origin: %d, errid: %d\n",
> +				 system ? "SYS" : "LM", rst[boot.reason],
> +				 boot.orig_valid ? boot.origin : -1,
> +				 boot.err_valid ? boot.errid : -1);
> +		if (shutdown.valid)
> +			dev_info(&sdev->dev, "%s shutdown reason: %s, origin: %d, errid: %d\n",
> +				 system ? "SYS" : "LM", rst[shutdown.reason],
> +				 shutdown.orig_valid ? shutdown.origin : -1,
> +				 shutdown.err_valid ? shutdown.errid : -1);
> +	} else {
> +		dev_err(&sdev->dev, "Failed to get system reset reason: %d\n", ret);
> +	}
> +
> +	system = false;
> +	ret = imx_misc_ctrl_ops->misc_reset_reason(ph, system, &boot, &shutdown, NULL);
> +	if (!ret) {
> +		if (boot.valid)
> +			dev_info(&sdev->dev, "%s Boot reason: %s, origin: %d, errid: %d\n",
> +				 system ? "SYS" : "LM", rst[boot.reason],
> +				 boot.orig_valid ? boot.origin : -1,
> +				 boot.err_valid ? boot.errid : -1);
> +		if (shutdown.valid)
> +			dev_info(&sdev->dev, "%s shutdown reason: %s, origin: %d, errid: %d\n",
> +				 system ? "SYS" : "LM", rst[shutdown.reason],
> +				 shutdown.orig_valid ? shutdown.origin : -1,
> +				 shutdown.err_valid ? shutdown.errid : -1);

Is there a way to query this from userspace programs instead of printing into kernel log?

Best regards,
Alexander

> +	} else {
> +		dev_err(&sdev->dev, "Failed to get lm reset reason: %d\n", ret);
> +	}
> +
> +	return 0;
> +}
> +
>  static int scmi_imx_misc_ctrl_probe(struct scmi_device *sdev)
>  {
>  	const struct scmi_handle *handle = sdev->handle;
> @@ -133,6 +204,8 @@ static int scmi_imx_misc_ctrl_probe(struct scmi_device *sdev)
>  	scmi_imx_dentry = debugfs_create_dir("scmi_imx", NULL);
>  	debugfs_create_file("syslog", 0444, scmi_imx_dentry, &sdev->dev, &syslog_fops);
>  
> +	scmi_imx_misc_get_reason(sdev);
> +
>  	return devm_add_action_or_reset(&sdev->dev, scmi_imx_misc_put, scmi_imx_dentry);
>  }
>  
> 
> 


-- 
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/



  reply	other threads:[~2026-03-05  7:45 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-05  1:56 [PATCH 0/2] firmware: arm_scmi: imx: Support getting reset reason Peng Fan (OSS)
2026-03-05  1:56 ` [PATCH 1/2] firmware: arm_scmi: imx: Support getting reset reason of MISC protocol Peng Fan (OSS)
2026-03-05  6:52   ` Daniel Baluta
2026-03-05 10:18     ` Peng Fan
2026-03-18 15:25   ` Sudeep Holla
2026-04-30  9:13     ` Sudeep Holla
2026-05-01 11:57       ` Peng Fan
2026-05-02  4:41       ` Frank Li
2026-03-18 16:09   ` Daniel Baluta
2026-03-05  1:56 ` [PATCH 2/2] firmware: imx: sm-misc: Print boot/shutdown reasons Peng Fan (OSS)
2026-03-05  7:44   ` Alexander Stein [this message]
2026-03-05 10:22     ` Peng Fan
2026-03-05 10:48       ` Oleksij Rempel
2026-03-10  5:10         ` Peng Fan
2026-05-05 15:35 ` [PATCH 0/2] firmware: arm_scmi: imx: Support getting reset reason Sudeep Holla

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=24409695.EfDdHjke4D@steina-w \
    --to=alexander.stein@ew.tq-group.com \
    --cc=Frank.Li@nxp.com \
    --cc=arm-scmi@vger.kernel.org \
    --cc=cristian.marussi@arm.com \
    --cc=festevam@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peng.fan@nxp.com \
    --cc=peng.fan@oss.nxp.com \
    --cc=s.hauer@pengutronix.de \
    --cc=sudeep.holla@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.