回复: [PATCH] firmware: scmi: support to manage SCMI protocol drivers with a linker-genetated array
Alice Guo (OSS)
alice.guo at oss.nxp.com
Wed Apr 2 06:37:28 CEST 2025
+ Marek Vasut
> -----邮件原件-----
> 发件人: Alice Guo (OSS)
> 发送时间: 2025年4月2日 12:36
> 收件人: trini at konsulko.com; festevam at gmail.com
> 抄送: u-boot at lists.denx.de
> 主题: [PATCH] firmware: scmi: support to manage SCMI protocol drivers with a
> linker-genetated array
>
> From: Alice Guo <alice.guo at nxp.com>
>
> U_BOOT_SCMI_PROTO_DRIVER macro is used to add a SCMI protocol driver to
> scmi_proto_driver list. scmi_proto_driver_get() function can be used to match a
> SCMI protocol id and its driver.
>
> Signed-off-by: Alice Guo <alice.guo at nxp.com>
> ---
> drivers/firmware/scmi/scmi_agent-uclass.c | 16 ++++++++++++++++
> include/scmi_agent-uclass.h | 15 +++++++++++++++
> 2 files changed, 31 insertions(+)
>
> diff --git a/drivers/firmware/scmi/scmi_agent-uclass.c
> b/drivers/firmware/scmi/scmi_agent-uclass.c
> index e6e43ae936a..ea79cfa0cf2 100644
> --- a/drivers/firmware/scmi/scmi_agent-uclass.c
> +++ b/drivers/firmware/scmi/scmi_agent-uclass.c
> @@ -352,6 +352,22 @@ static int scmi_fill_base_info(struct udevice *agent,
> struct udevice *dev)
> return 0;
> }
>
> +static struct driver *scmi_proto_driver_get(unsigned int proto_id) {
> + struct scmi_proto_driver *start, *entry;
> + int n_ents;
> +
> + start = ll_entry_start(struct scmi_proto_driver, scmi_proto_driver);
> + n_ents = ll_entry_count(struct scmi_proto_driver, scmi_proto_driver);
> +
> + for (entry = start; entry != start + n_ents; entry++) {
> + if (entry->match->proto_id == proto_id)
> + return entry->driver;
> + }
> +
> + return NULL;
> +}
> +
> /*
> * SCMI agent devices binds devices of various uclasses depending on
> * the FDT description. scmi_bind_protocol() is a generic bind sequence diff
> --git a/include/scmi_agent-uclass.h b/include/scmi_agent-uclass.h index
> 33e0e18c30d..842c56858af 100644
> --- a/include/scmi_agent-uclass.h
> +++ b/include/scmi_agent-uclass.h
> @@ -115,4 +115,19 @@ struct scmi_agent_ops {
> struct scmi_msg *msg);
> };
>
> +struct scmi_proto_match {
> + unsigned int proto_id;
> +};
> +
> +struct scmi_proto_driver {
> + struct driver *driver;
> + const struct scmi_proto_match *match;
> +};
> +
> +#define U_BOOT_SCMI_PROTO_DRIVER(__name, __match) \
> + ll_entry_declare(struct scmi_proto_driver, __name, scmi_proto_driver) =
> { \
> + .driver = llsym(struct driver, __name, driver), \
> + .match = __match, \
> + }
> +
> #endif /* _SCMI_TRANSPORT_UCLASS_H */
> --
> 2.43.0
More information about the U-Boot
mailing list