firmware: scmi: Conditionally compile protocol support
authorPeng Fan <peng.fan@nxp.com>
Fri, 17 Oct 2025 09:32:30 +0000 (17:32 +0800)
committerTom Rini <trini@konsulko.com>
Fri, 24 Oct 2025 19:47:50 +0000 (13:47 -0600)
Add conditional compilation for SCMI protocol support in scmi_get_protocol()
and scmi_add_protocol() based on corresponding Kconfig options. This ensures
that only the enabled protocols are compiled and accessed, and reducing binary
size.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Alice Guo <alice.guo@nxp.com>
drivers/firmware/scmi/scmi_agent-uclass.c
include/scmi_agent-uclass.h

index 69a277e..f48c2fd 100644 (file)
@@ -86,21 +86,31 @@ struct udevice *scmi_get_protocol(struct udevice *dev,
        case SCMI_PROTOCOL_ID_BASE:
                proto = priv->base_dev;
                break;
+#if IS_ENABLED(CONFIG_SCMI_POWER_DOMAIN)
        case SCMI_PROTOCOL_ID_POWER_DOMAIN:
                proto = priv->pwdom_dev;
                break;
+#endif
+#if IS_ENABLED(CONFIG_CLK_SCMI)
        case SCMI_PROTOCOL_ID_CLOCK:
                proto = priv->clock_dev;
                break;
+#endif
+#if IS_ENABLED(CONFIG_RESET_SCMI)
        case SCMI_PROTOCOL_ID_RESET_DOMAIN:
                proto = priv->resetdom_dev;
                break;
+#endif
+#if IS_ENABLED(CONFIG_DM_REGULATOR_SCMI)
        case SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN:
                proto = priv->voltagedom_dev;
                break;
+#endif
+#if IS_ENABLED(CONFIG_PINCTRL_IMX_SCMI)
        case SCMI_PROTOCOL_ID_PINCTRL:
                proto = priv->pinctrl_dev;
                break;
+#endif
        default:
                dev_err(dev, "Protocol not supported\n");
                proto = NULL;
@@ -139,21 +149,31 @@ static int scmi_add_protocol(struct udevice *dev,
        case SCMI_PROTOCOL_ID_BASE:
                priv->base_dev = proto;
                break;
+#if IS_ENABLED(CONFIG_SCMI_POWER_DOMAIN)
        case SCMI_PROTOCOL_ID_POWER_DOMAIN:
                priv->pwdom_dev = proto;
                break;
+#endif
+#if IS_ENABLED(CONFIG_CLK_SCMI)
        case SCMI_PROTOCOL_ID_CLOCK:
                priv->clock_dev = proto;
                break;
+#endif
+#if IS_ENABLED(CONFIG_RESET_SCMI)
        case SCMI_PROTOCOL_ID_RESET_DOMAIN:
                priv->resetdom_dev = proto;
                break;
+#endif
+#if IS_ENABLED(CONFIG_DM_REGULATOR_SCMI)
        case SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN:
                priv->voltagedom_dev = proto;
                break;
+#endif
+#if IS_ENABLED(CONFIG_PINCTRL_IMX_SCMI)
        case SCMI_PROTOCOL_ID_PINCTRL:
                priv->pinctrl_dev = proto;
                break;
+#endif
        default:
                dev_err(dev, "Protocol not supported\n");
                return -EPROTO;
index d6586eb..ccedd42 100644 (file)
@@ -40,11 +40,21 @@ struct scmi_agent_priv {
        u8 *agent_name;
        u32 agent_id;
        struct udevice *base_dev;
+#if IS_ENABLED(CONFIG_SCMI_POWER_DOMAIN)
        struct udevice *pwdom_dev;
+#endif
+#if IS_ENABLED(CONFIG_CLK_SCMI)
        struct udevice *clock_dev;
+#endif
+#if IS_ENABLED(CONFIG_RESET_SCMI)
        struct udevice *resetdom_dev;
+#endif
+#if IS_ENABLED(CONFIG_DM_REGULATOR_SCMI)
        struct udevice *voltagedom_dev;
+#endif
+#if IS_ENABLED(CONFIG_PINCTRL_IMX_SCMI)
        struct udevice *pinctrl_dev;
+#endif
 };
 
 static inline u32 scmi_version(struct udevice *dev)