From: Peng Fan <peng.fan@nxp.com>
To: Sudeep Holla <sudeep.holla@arm.com>,
Cristian Marussi <cristian.marussi@arm.com>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>
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>
Subject: [PATCH v2 6/6] firmware: imx: sm-misc: Dump syslog info
Date: Thu, 10 Jul 2025 16:33:31 +0800 [thread overview]
Message-ID: <20250710-sm-misc-api-v1-v2-6-c3e953e34be6@nxp.com> (raw)
In-Reply-To: <20250710-sm-misc-api-v1-v2-0-c3e953e34be6@nxp.com>
Add sysfs interface to read System Manager syslog info
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/firmware/imx/sm-misc.c | 178 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 178 insertions(+)
diff --git a/drivers/firmware/imx/sm-misc.c b/drivers/firmware/imx/sm-misc.c
index fc3ee12c2be878e0285183e3381c9514a63d5142..10aab5b127f65ecc57db9ab6c0c2c2b84d1dd864 100644
--- a/drivers/firmware/imx/sm-misc.c
+++ b/drivers/firmware/imx/sm-misc.c
@@ -3,6 +3,7 @@
* Copyright 2024 NXP
*/
+#include <linux/device/devres.h>
#include <linux/firmware/imx/sm.h>
#include <linux/module.h>
#include <linux/of.h>
@@ -44,10 +45,178 @@ static int scmi_imx_misc_ctrl_notifier(struct notifier_block *nb,
return 0;
}
+static ssize_t
+wakevector_show(struct device *device, struct device_attribute *attr, char *buf)
+{
+ struct scmi_imx_misc_syslog *syslog = dev_get_drvdata(device);
+ int ret;
+
+ if (!ph)
+ return 0;
+
+ ret = imx_misc_ctrl_ops->misc_syslog(ph, sizeof(*syslog), syslog);
+ if (ret)
+ return ret;
+
+ return sysfs_emit(buf, "%u\n", syslog->syssleeprecord.wakesource);
+}
+static DEVICE_ATTR_RO(wakevector);
+
+static ssize_t
+syssleepmode_show(struct device *device, struct device_attribute *attr, char *buf)
+{
+ struct scmi_imx_misc_syslog *syslog = dev_get_drvdata(device);
+ int ret;
+
+ if (!ph)
+ return 0;
+
+ ret = imx_misc_ctrl_ops->misc_syslog(ph, sizeof(*syslog), syslog);
+ if (ret)
+ return ret;
+
+ return sysfs_emit(buf, "%u\n", syslog->syssleeprecord.syssleepmode);
+}
+static DEVICE_ATTR_RO(syssleepmode);
+
+static ssize_t
+syssleepflags_show(struct device *device, struct device_attribute *attr, char *buf)
+{
+ struct scmi_imx_misc_syslog *syslog = dev_get_drvdata(device);
+ int ret;
+
+ if (!ph)
+ return 0;
+
+ ret = imx_misc_ctrl_ops->misc_syslog(ph, sizeof(*syslog), syslog);
+ if (ret)
+ return ret;
+
+ return sysfs_emit(buf, "0x%08x\n", syslog->syssleeprecord.syssleepflags);
+}
+static DEVICE_ATTR_RO(syssleepflags);
+
+static ssize_t
+mixpwrstat_show(struct device *device, struct device_attribute *attr, char *buf)
+{
+ struct scmi_imx_misc_syslog *syslog = dev_get_drvdata(device);
+ int ret;
+
+ if (!ph)
+ return 0;
+
+ ret = imx_misc_ctrl_ops->misc_syslog(ph, sizeof(*syslog), syslog);
+ if (ret)
+ return ret;
+
+ return sysfs_emit(buf, "0x%08x\n", syslog->syssleeprecord.mixpwrstat);
+}
+static DEVICE_ATTR_RO(mixpwrstat);
+
+static ssize_t
+mempwrstat_show(struct device *device, struct device_attribute *attr, char *buf)
+{
+ struct scmi_imx_misc_syslog *syslog = dev_get_drvdata(device);
+ int ret;
+
+ if (!ph)
+ return 0;
+
+ ret = imx_misc_ctrl_ops->misc_syslog(ph, sizeof(*syslog), syslog);
+ if (ret)
+ return ret;
+
+ return sysfs_emit(buf, "0x%08x\n", syslog->syssleeprecord.mempwrstat);
+}
+static DEVICE_ATTR_RO(mempwrstat);
+
+static ssize_t
+pllpwrstat_show(struct device *device, struct device_attribute *attr, char *buf)
+{
+ struct scmi_imx_misc_syslog *syslog = dev_get_drvdata(device);
+ int ret;
+
+ if (!ph)
+ return 0;
+
+ ret = imx_misc_ctrl_ops->misc_syslog(ph, sizeof(*syslog), syslog);
+ if (ret)
+ return ret;
+
+ return sysfs_emit(buf, "0x%08x\n", syslog->syssleeprecord.pllpwrstat);
+}
+static DEVICE_ATTR_RO(pllpwrstat);
+
+static ssize_t
+sleepentryusec_show(struct device *device, struct device_attribute *attr, char *buf)
+{
+ struct scmi_imx_misc_syslog *syslog = dev_get_drvdata(device);
+ int ret;
+
+ if (!ph)
+ return 0;
+
+ ret = imx_misc_ctrl_ops->misc_syslog(ph, sizeof(*syslog), syslog);
+ if (ret)
+ return ret;
+
+ return sysfs_emit(buf, "%u\n", syslog->syssleeprecord.sleepentryusec);
+}
+static DEVICE_ATTR_RO(sleepentryusec);
+
+static ssize_t
+sleepexitusec_show(struct device *device, struct device_attribute *attr, char *buf)
+{
+ struct scmi_imx_misc_syslog *syslog = dev_get_drvdata(device);
+ int ret;
+
+ if (!ph)
+ return 0;
+
+ ret = imx_misc_ctrl_ops->misc_syslog(ph, sizeof(*syslog), syslog);
+ if (ret)
+ return ret;
+
+ return sysfs_emit(buf, "%u\n", syslog->syssleeprecord.sleepexitusec);
+}
+static DEVICE_ATTR_RO(sleepexitusec);
+
+static ssize_t
+sleepcnt_show(struct device *device, struct device_attribute *attr, char *buf)
+{
+ struct scmi_imx_misc_syslog *syslog = dev_get_drvdata(device);
+ int ret;
+
+ if (!ph)
+ return 0;
+
+ ret = imx_misc_ctrl_ops->misc_syslog(ph, sizeof(*syslog), syslog);
+ if (ret)
+ return ret;
+
+ return sysfs_emit(buf, "%u\n", syslog->syssleeprecord.sleepcnt);
+}
+static DEVICE_ATTR_RO(sleepcnt);
+
+static struct attribute *sm_misc_attrs[] = {
+ &dev_attr_wakevector.attr,
+ &dev_attr_syssleepmode.attr,
+ &dev_attr_syssleepflags.attr,
+ &dev_attr_mixpwrstat.attr,
+ &dev_attr_mempwrstat.attr,
+ &dev_attr_pllpwrstat.attr,
+ &dev_attr_sleepentryusec.attr,
+ &dev_attr_sleepexitusec.attr,
+ &dev_attr_sleepcnt.attr,
+ NULL,
+};
+ATTRIBUTE_GROUPS(sm_misc);
+
static int scmi_imx_misc_ctrl_probe(struct scmi_device *sdev)
{
const struct scmi_handle *handle = sdev->handle;
struct device_node *np = sdev->dev.of_node;
+ struct scmi_imx_misc_syslog *syslog;
u32 src_id, flags;
int ret, i, num;
@@ -63,6 +232,12 @@ static int scmi_imx_misc_ctrl_probe(struct scmi_device *sdev)
if (IS_ERR(imx_misc_ctrl_ops))
return PTR_ERR(imx_misc_ctrl_ops);
+ syslog = devm_kzalloc(&sdev->dev, sizeof(*syslog), GFP_KERNEL);
+ if (!syslog)
+ return -ENOMEM;
+
+ dev_set_drvdata(&sdev->dev, syslog);
+
num = of_property_count_u32_elems(np, "nxp,ctrl-ids");
if (num % 2) {
dev_err(&sdev->dev, "Invalid wakeup-sources\n");
@@ -108,6 +283,9 @@ static const struct scmi_device_id scmi_id_table[] = {
MODULE_DEVICE_TABLE(scmi, scmi_id_table);
static struct scmi_driver scmi_imx_misc_ctrl_driver = {
+ .driver = {
+ .dev_groups = sm_misc_groups,
+ },
.name = "scmi-imx-misc-ctrl",
.probe = scmi_imx_misc_ctrl_probe,
.id_table = scmi_id_table,
--
2.37.1
next prev parent reply other threads:[~2025-07-10 8:35 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-10 8:33 [PATCH v2 0/6] firmware: arm_scmi: imx: Dump syslog and system_info Peng Fan
2025-07-10 8:33 ` [PATCH v2 1/6] firmware: arm_scmi: imx: Add documentation for MISC_BOARD_INFO Peng Fan
2025-07-10 8:33 ` [PATCH v2 2/6] firmware: arm_scmi: imx: Support discovering buildinfo of MISC protocol Peng Fan
2025-08-19 15:57 ` Cristian Marussi
2025-07-10 8:33 ` [PATCH v2 3/6] firmware: arm_scmi: imx: Support getting cfg info " Peng Fan
2025-08-19 15:59 ` Cristian Marussi
2025-07-10 8:33 ` [PATCH v2 4/6] firmware: arm_scmi: imx: Support getting board " Peng Fan
2025-08-19 16:28 ` Cristian Marussi
2025-07-10 8:33 ` [PATCH v2 5/6] firmware: arm_scmi: imx: Support getting syslog " Peng Fan
2025-08-19 17:09 ` Cristian Marussi
2025-08-21 9:05 ` Peng Fan
2025-07-10 8:33 ` Peng Fan [this message]
2025-08-19 17:28 ` [PATCH v2 6/6] firmware: imx: sm-misc: Dump syslog info Cristian Marussi
2025-08-18 2:25 ` [PATCH v2 0/6] firmware: arm_scmi: imx: Dump syslog and system_info Peng Fan
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=20250710-sm-misc-api-v1-v2-6-c3e953e34be6@nxp.com \
--to=peng.fan@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=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=sudeep.holla@arm.com \
/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
all inboxes | Powered by JetHome®