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 <alice.guo@nxp.com>
This commit is contained in:
Alice Guo
2025-04-28 18:37:25 +08:00
committed by Fabio Estevam
parent b4f3fab643
commit adff089cd4
5 changed files with 36 additions and 24 deletions

View File

@@ -8,6 +8,7 @@
#include <clk-uclass.h>
#include <dm.h>
#include <scmi_agent.h>
#include <scmi_agent-uclass.h>
#include <scmi_protocols.h>
#include <asm/types.h>
#include <linux/clk-provider.h>
@@ -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);

View File

@@ -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);

View File

@@ -11,6 +11,7 @@
#include <power-domain.h>
#include <power-domain-uclass.h>
#include <scmi_agent.h>
#include <scmi_agent-uclass.h>
#include <scmi_protocols.h>
#include <dm/device_compat.h>
@@ -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);

View File

@@ -8,6 +8,7 @@
#include <dm.h>
#include <errno.h>
#include <scmi_agent.h>
#include <scmi_agent-uclass.h>
#include <scmi_protocols.h>
#include <asm/types.h>
#include <dm/device.h>
@@ -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);

View File

@@ -9,6 +9,7 @@
#include <errno.h>
#include <reset-uclass.h>
#include <scmi_agent.h>
#include <scmi_agent-uclass.h>
#include <scmi_protocols.h>
#include <asm/types.h>
@@ -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);