From: Alice Guo Date: Mon, 28 Apr 2025 10:37:25 +0000 (+0800) Subject: firmware: scmi: use scmi_proto_driver_get() function to get SCMI protocol driver X-Git-Tag: v2025.07-rc2~36^2~22 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=adff089cd4d5e45399348bc92c98d035ed7cc801;p=pandora-u-boot.git firmware: scmi: use scmi_proto_driver_get() function to get SCMI protocol driver If there is a SoC specific SCMI protocol driver, using scmi_proto_driver_get() function can avoid to add SoC specific code to scmi_agent-uclass.c. Signed-off-by: Alice Guo --- diff --git a/drivers/clk/clk_scmi.c b/drivers/clk/clk_scmi.c index e42d2032d45..b8d40cc9653 100644 --- a/drivers/clk/clk_scmi.c +++ b/drivers/clk/clk_scmi.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -191,3 +192,10 @@ U_BOOT_DRIVER(scmi_clock) = { .ops = &scmi_clk_ops, .probe = scmi_clk_probe, }; + +static struct scmi_proto_match match[] = { + { .proto_id = SCMI_PROTOCOL_ID_CLOCK }, + { /* Sentinel */ } +}; + +U_BOOT_SCMI_PROTO_DRIVER(scmi_clock, match); diff --git a/drivers/firmware/scmi/scmi_agent-uclass.c b/drivers/firmware/scmi/scmi_agent-uclass.c index ea79cfa0cf2..cc3f31d881e 100644 --- a/drivers/firmware/scmi/scmi_agent-uclass.c +++ b/drivers/firmware/scmi/scmi_agent-uclass.c @@ -425,31 +425,11 @@ static int scmi_bind_protocols(struct udevice *dev) drv = NULL; name = ofnode_get_name(node); - switch (protocol_id) { - case SCMI_PROTOCOL_ID_POWER_DOMAIN: - if (CONFIG_IS_ENABLED(SCMI_POWER_DOMAIN) && - scmi_protocol_is_supported(dev, protocol_id)) - drv = DM_DRIVER_GET(scmi_power_domain); - break; - case SCMI_PROTOCOL_ID_CLOCK: - if (CONFIG_IS_ENABLED(CLK_SCMI) && - scmi_protocol_is_supported(dev, protocol_id)) - drv = DM_DRIVER_GET(scmi_clock); - break; - case SCMI_PROTOCOL_ID_RESET_DOMAIN: - if (IS_ENABLED(CONFIG_RESET_SCMI) && - scmi_protocol_is_supported(dev, protocol_id)) - drv = DM_DRIVER_GET(scmi_reset_domain); - break; - case SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN: - if (IS_ENABLED(CONFIG_DM_REGULATOR_SCMI) && - scmi_protocol_is_supported(dev, protocol_id)) - drv = DM_DRIVER_GET(scmi_voltage_domain); - break; - default: - break; - } + if (!scmi_protocol_is_supported(dev, protocol_id)) + continue; + + drv = scmi_proto_driver_get(protocol_id); if (!drv) { dev_dbg(dev, "Ignore unsupported SCMI protocol %#x\n", protocol_id); diff --git a/drivers/power/domain/scmi-power-domain.c b/drivers/power/domain/scmi-power-domain.c index 3cd0f075d95..e8c0ba8878e 100644 --- a/drivers/power/domain/scmi-power-domain.c +++ b/drivers/power/domain/scmi-power-domain.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -190,3 +191,10 @@ U_BOOT_DRIVER(scmi_power_domain) = { .probe = scmi_power_domain_probe, .priv_auto = sizeof(struct scmi_power_domain_priv), }; + +static struct scmi_proto_match match[] = { + { .proto_id = SCMI_PROTOCOL_ID_POWER_DOMAIN }, + { /* Sentinel */ } +}; + +U_BOOT_SCMI_PROTO_DRIVER(scmi_power_domain, match); diff --git a/drivers/power/regulator/scmi_regulator.c b/drivers/power/regulator/scmi_regulator.c index 79db1a6a8aa..7d2db1e2bee 100644 --- a/drivers/power/regulator/scmi_regulator.c +++ b/drivers/power/regulator/scmi_regulator.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -202,3 +203,10 @@ U_BOOT_DRIVER(scmi_voltage_domain) = { .id = UCLASS_NOP, .bind = scmi_regulator_bind, }; + +static struct scmi_proto_match match[] = { + { .proto_id = SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN }, + { /* Sentinel */ } +}; + +U_BOOT_SCMI_PROTO_DRIVER(scmi_voltage_domain, match); diff --git a/drivers/reset/reset-scmi.c b/drivers/reset/reset-scmi.c index 6dc1fcb3365..f92a9e35579 100644 --- a/drivers/reset/reset-scmi.c +++ b/drivers/reset/reset-scmi.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -81,3 +82,10 @@ U_BOOT_DRIVER(scmi_reset_domain) = { .ops = &scmi_reset_domain_ops, .probe = scmi_reset_probe, }; + +static struct scmi_proto_match match[] = { + { .proto_id = SCMI_PROTOCOL_ID_RESET_DOMAIN }, + { /* Sentinel */ } +}; + +U_BOOT_SCMI_PROTO_DRIVER(scmi_reset_domain, match);