]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
firmware: arm_scmi: imx: Support retrieving MISC protocol configuration info
authorPeng Fan <peng.fan@nxp.com>
Thu, 4 Sep 2025 10:40:44 +0000 (18:40 +0800)
committerSudeep Holla <sudeep.holla@arm.com>
Mon, 8 Sep 2025 10:52:30 +0000 (11:52 +0100)
The MISC protocol can provide System Manager (SM) configuration
information, including platform identifiers and board-specific
attributes. Add support to retrieve this information during protocol
initialization.

If the firmware does not implement the CFG_INFO command, handle
-EOPNOTSUPP gracefully and continue without failing init.

Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Message-Id: <20250904-sm-misc-api-v1-v4-3-0bf10eaabdf1@nxp.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c

index be34e4a8d738b999b12898d2f8ca75e46e93bdbc..a6d516182425b0b128269cd97f9adf5f32515b44 100644 (file)
@@ -27,6 +27,7 @@ enum scmi_imx_misc_protocol_cmd {
        SCMI_IMX_MISC_CTRL_GET  = 0x4,
        SCMI_IMX_MISC_DISCOVER_BUILD_INFO = 0x6,
        SCMI_IMX_MISC_CTRL_NOTIFY = 0x8,
+       SCMI_IMX_MISC_CFG_INFO_GET = 0xC,
 };
 
 struct scmi_imx_misc_info {
@@ -75,6 +76,12 @@ struct scmi_imx_misc_buildinfo_out {
        u8 buildtime[MISC_MAX_BUILDTIME];
 };
 
+struct scmi_imx_misc_cfg_info_out {
+       __le32 msel;
+#define MISC_MAX_CFGNAME       16
+       u8 cfgname[MISC_MAX_CFGNAME];
+};
+
 static int scmi_imx_misc_attributes_get(const struct scmi_protocol_handle *ph,
                                        struct scmi_imx_misc_info *mi)
 {
@@ -309,6 +316,30 @@ static int scmi_imx_misc_build_info_discover(const struct scmi_protocol_handle *
        return ret;
 }
 
+static int scmi_imx_misc_cfg_info_get(const struct scmi_protocol_handle *ph)
+{
+       struct scmi_imx_misc_cfg_info_out *out;
+       char name[MISC_MAX_CFGNAME];
+       struct scmi_xfer *t;
+       int ret;
+
+       ret = ph->xops->xfer_get_init(ph, SCMI_IMX_MISC_CFG_INFO_GET, 0, sizeof(*out), &t);
+       if (ret)
+               return ret;
+
+       ret = ph->xops->do_xfer(ph, t);
+       if (!ret) {
+               out = t->rx.buf;
+               strscpy(name, out->cfgname, MISC_MAX_CFGNAME);
+               dev_info(ph->dev, "SM Config\t= %s, mSel = %u\n",
+                        name, le32_to_cpu(out->msel));
+       }
+
+       ph->xops->xfer_put(ph, t);
+
+       return ret;
+}
+
 static const struct scmi_imx_misc_proto_ops scmi_imx_misc_proto_ops = {
        .misc_ctrl_set = scmi_imx_misc_ctrl_set,
        .misc_ctrl_get = scmi_imx_misc_ctrl_get,
@@ -340,6 +371,10 @@ static int scmi_imx_misc_protocol_init(const struct scmi_protocol_handle *ph)
        if (ret && ret != -EOPNOTSUPP)
                return ret;
 
+       ret = scmi_imx_misc_cfg_info_get(ph);
+       if (ret && ret != -EOPNOTSUPP)
+               return ret;
+
        return ph->set_priv(ph, minfo, version);
 }