mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2026-11-20 02:22:19 +00:00
lib: utils/mpxy: Introduce get_attribute_group() for MPXY RPMI data
Fully emulated MPXY channels need a custom way to provide RPMI attributes so introduce optional get_attribute_group() callback in MPXY RPMI data for this purpose. Signed-off-by: Anup Patel <anup.patel@oss.qualcomm.com> Reviewed-by: Pawandeep Oza <pawandeep.oza@oss.qualcomm.com> Tested-by: Pawandeep Oza <pawandeep.oza@oss.qualcomm.com> Link: https://lore.kernel.org/r/20260923032359.4041876-4-anup.patel@oss.qualcomm.com Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
1 parent
fa2bbaf349
commit
db877c0908
2 files changed
+29
-10
No files matched your search
@@ -67,6 +67,11 @@ struct mpxy_rpmi_data {
|
|||||||
u32 num_services;
|
u32 num_services;
|
||||||
struct mpxy_rpmi_service_data *service_data;
|
struct mpxy_rpmi_service_data *service_data;
|
||||||
|
|
||||||
|
/** Get RPMI service group attribute */
|
||||||
|
int (*get_attribute_group)(void *context, struct mbox_chan *chan,
|
||||||
|
enum rpmi_channel_attribute_id attr_id,
|
||||||
|
u32 *out_value);
|
||||||
|
|
||||||
/** Transfer RPMI service group message */
|
/** Transfer RPMI service group message */
|
||||||
int (*xfer_group)(void *context, struct mbox_chan *chan,
|
int (*xfer_group)(void *context, struct mbox_chan *chan,
|
||||||
struct mbox_xfer *xfer);
|
struct mbox_xfer *xfer);
|
||||||
|
|||||||
@@ -204,6 +204,21 @@ static int mpxy_send_message_withoutresp(struct sbi_mpxy_channel *channel,
|
|||||||
NULL, 0, NULL);
|
NULL, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int mpxy_rpmi_get_attribute(struct mpxy_rpmi *rmb,
|
||||||
|
enum rpmi_channel_attribute_id attr_id,
|
||||||
|
u32 *out_value)
|
||||||
|
{
|
||||||
|
const struct mpxy_rpmi_data *data = rmb->data;
|
||||||
|
struct mbox_chan *chan = rmb->chan;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
if (data->get_attribute_group)
|
||||||
|
rc = data->get_attribute_group(rmb->group_context, chan, attr_id, out_value);
|
||||||
|
else
|
||||||
|
rc = mbox_chan_get_attribute(chan, attr_id, out_value);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
int fdt_mpxy_rpmi_init(const void *fdt, int nodeoff, const struct fdt_match *match)
|
int fdt_mpxy_rpmi_init(const void *fdt, int nodeoff, const struct fdt_match *match)
|
||||||
{
|
{
|
||||||
u32 channel_id, servicegrp_ver, pro_ver, max_data_len, tx_tout, rx_tout;
|
u32 channel_id, servicegrp_ver, pro_ver, max_data_len, tx_tout, rx_tout;
|
||||||
@@ -218,6 +233,7 @@ int fdt_mpxy_rpmi_init(const void *fdt, int nodeoff, const struct fdt_match *mat
|
|||||||
rmb = sbi_zalloc(sizeof(*rmb));
|
rmb = sbi_zalloc(sizeof(*rmb));
|
||||||
if (!rmb)
|
if (!rmb)
|
||||||
return SBI_ENOMEM;
|
return SBI_ENOMEM;
|
||||||
|
rmb->data = data;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If channel request failed then other end does not support
|
* If channel request failed then other end does not support
|
||||||
@@ -228,6 +244,7 @@ int fdt_mpxy_rpmi_init(const void *fdt, int nodeoff, const struct fdt_match *mat
|
|||||||
rc = SBI_ENODEV;
|
rc = SBI_ENODEV;
|
||||||
goto fail_free_client;
|
goto fail_free_client;
|
||||||
}
|
}
|
||||||
|
rmb->chan = chan;
|
||||||
|
|
||||||
/* Match channel service group id */
|
/* Match channel service group id */
|
||||||
if (data->servicegrp_id != chan->chan_args[0]) {
|
if (data->servicegrp_id != chan->chan_args[0]) {
|
||||||
@@ -243,43 +260,43 @@ int fdt_mpxy_rpmi_init(const void *fdt, int nodeoff, const struct fdt_match *mat
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Get channel protocol version */
|
/* Get channel protocol version */
|
||||||
rc = mbox_chan_get_attribute(chan, RPMI_CHANNEL_ATTR_PROTOCOL_VERSION,
|
rc = mpxy_rpmi_get_attribute(rmb, RPMI_CHANNEL_ATTR_PROTOCOL_VERSION,
|
||||||
&pro_ver);
|
&pro_ver);
|
||||||
if (rc)
|
if (rc)
|
||||||
goto fail_cleanup_group;
|
goto fail_cleanup_group;
|
||||||
|
|
||||||
/* Get channel maximum data length */
|
/* Get channel maximum data length */
|
||||||
rc = mbox_chan_get_attribute(chan, RPMI_CHANNEL_ATTR_MAX_DATA_LEN,
|
rc = mpxy_rpmi_get_attribute(rmb, RPMI_CHANNEL_ATTR_MAX_DATA_LEN,
|
||||||
&max_data_len);
|
&max_data_len);
|
||||||
if (rc)
|
if (rc)
|
||||||
goto fail_cleanup_group;
|
goto fail_cleanup_group;
|
||||||
|
|
||||||
/* Get channel Tx timeout */
|
/* Get channel Tx timeout */
|
||||||
rc = mbox_chan_get_attribute(chan, RPMI_CHANNEL_ATTR_TX_TIMEOUT,
|
rc = mpxy_rpmi_get_attribute(rmb, RPMI_CHANNEL_ATTR_TX_TIMEOUT,
|
||||||
&tx_tout);
|
&tx_tout);
|
||||||
if (rc)
|
if (rc)
|
||||||
goto fail_cleanup_group;
|
goto fail_cleanup_group;
|
||||||
|
|
||||||
/* Get channel Rx timeout */
|
/* Get channel Rx timeout */
|
||||||
rc = mbox_chan_get_attribute(chan, RPMI_CHANNEL_ATTR_RX_TIMEOUT,
|
rc = mpxy_rpmi_get_attribute(rmb, RPMI_CHANNEL_ATTR_RX_TIMEOUT,
|
||||||
&rx_tout);
|
&rx_tout);
|
||||||
if (rc)
|
if (rc)
|
||||||
goto fail_cleanup_group;
|
goto fail_cleanup_group;
|
||||||
|
|
||||||
/* Get channel service group version */
|
/* Get channel service group version */
|
||||||
rc = mbox_chan_get_attribute(chan, RPMI_CHANNEL_ATTR_SERVICEGROUP_VERSION,
|
rc = mpxy_rpmi_get_attribute(rmb, RPMI_CHANNEL_ATTR_SERVICEGROUP_VERSION,
|
||||||
&servicegrp_ver);
|
&servicegrp_ver);
|
||||||
if (rc)
|
if (rc)
|
||||||
goto fail_cleanup_group;
|
goto fail_cleanup_group;
|
||||||
|
|
||||||
/* Get channel implementation id */
|
/* Get channel implementation id */
|
||||||
rc = mbox_chan_get_attribute(chan, RPMI_CHANNEL_ATTR_IMPL_ID,
|
rc = mpxy_rpmi_get_attribute(rmb, RPMI_CHANNEL_ATTR_IMPL_ID,
|
||||||
&impl_id);
|
&impl_id);
|
||||||
if (rc)
|
if (rc)
|
||||||
goto fail_cleanup_group;
|
goto fail_cleanup_group;
|
||||||
|
|
||||||
/* Get channel implementation version */
|
/* Get channel implementation version */
|
||||||
rc = mbox_chan_get_attribute(chan, RPMI_CHANNEL_ATTR_IMPL_VERSION,
|
rc = mpxy_rpmi_get_attribute(rmb, RPMI_CHANNEL_ATTR_IMPL_VERSION,
|
||||||
&impl_ver);
|
&impl_ver);
|
||||||
if (rc)
|
if (rc)
|
||||||
goto fail_cleanup_group;
|
goto fail_cleanup_group;
|
||||||
@@ -333,9 +350,6 @@ int fdt_mpxy_rpmi_init(const void *fdt, int nodeoff, const struct fdt_match *mat
|
|||||||
rmb->msgprot_attrs.impl_id = impl_id;
|
rmb->msgprot_attrs.impl_id = impl_id;
|
||||||
rmb->msgprot_attrs.impl_ver = impl_ver;
|
rmb->msgprot_attrs.impl_ver = impl_ver;
|
||||||
|
|
||||||
rmb->data = data;
|
|
||||||
rmb->chan = chan;
|
|
||||||
|
|
||||||
/* Register RPMI service group */
|
/* Register RPMI service group */
|
||||||
rc = sbi_mpxy_register_channel(&rmb->channel);
|
rc = sbi_mpxy_register_channel(&rmb->channel);
|
||||||
if (rc)
|
if (rc)
|
||||||
|
|||||||
Reference in new issue
Block a user