sandbox: add SCMI clock control permissions to sandbox
This patch is used to add SCMI clock control permissions to sandbox for testing. Signed-off-by: Alice Guo <alice.guo@nxp.com>
This commit is contained in:
@@ -27,10 +27,12 @@ struct sandbox_scmi_pwd {
|
||||
* @id: Identifier of the clock used in the SCMI protocol
|
||||
* @enabled: Clock state: true if enabled, false if disabled
|
||||
* @rate: Clock rate in Hertz
|
||||
* @perm: Indicating state/parent/rate permission
|
||||
*/
|
||||
struct sandbox_scmi_clk {
|
||||
bool enabled;
|
||||
ulong rate;
|
||||
u32 perm;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -80,9 +80,9 @@ static struct sandbox_scmi_pwd scmi_pwdom[] = {
|
||||
};
|
||||
|
||||
static struct sandbox_scmi_clk scmi_clk[] = {
|
||||
{ .rate = 333 },
|
||||
{ .rate = 200 },
|
||||
{ .rate = 1000 },
|
||||
{ .rate = 333, .perm = 0xE0000000 },
|
||||
{ .rate = 200, .perm = 0xE0000000 },
|
||||
{ .rate = 1000, .perm = 0xE0000000 },
|
||||
};
|
||||
|
||||
static struct sandbox_scmi_reset scmi_reset[] = {
|
||||
@@ -700,6 +700,21 @@ static int sandbox_scmi_pwd_name_get(struct udevice *dev, struct scmi_msg *msg)
|
||||
|
||||
/* Clock Protocol */
|
||||
|
||||
static int sandbox_scmi_clock_protocol_version(struct udevice *dev,
|
||||
struct scmi_msg *msg)
|
||||
{
|
||||
struct scmi_protocol_version_out *out = NULL;
|
||||
|
||||
if (!msg->out_msg || msg->out_msg_sz < sizeof(*out))
|
||||
return -EINVAL;
|
||||
|
||||
out = (struct scmi_protocol_version_out *)msg->out_msg;
|
||||
out->version = 0x30000;
|
||||
out->status = SCMI_SUCCESS;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sandbox_scmi_clock_protocol_attribs(struct udevice *dev,
|
||||
struct scmi_msg *msg)
|
||||
{
|
||||
@@ -740,6 +755,9 @@ static int sandbox_scmi_clock_attribs(struct udevice *dev, struct scmi_msg *msg)
|
||||
if (clk_state->enabled)
|
||||
out->attributes = 1;
|
||||
|
||||
/* Restricted clock */
|
||||
out->attributes |= BIT(1);
|
||||
|
||||
ret = snprintf(out->clock_name, sizeof(out->clock_name),
|
||||
"clk%u", in->clock_id);
|
||||
assert(ret > 0 && ret < sizeof(out->clock_name));
|
||||
@@ -837,6 +855,34 @@ static int sandbox_scmi_clock_gate(struct udevice *dev, struct scmi_msg *msg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sandbox_scmi_clock_permissions_get(struct udevice *dev,
|
||||
struct scmi_msg *msg)
|
||||
{
|
||||
struct scmi_clk_get_permissions_in *in = NULL;
|
||||
struct scmi_clk_get_permissions_out *out = NULL;
|
||||
struct sandbox_scmi_clk *clk_state = NULL;
|
||||
|
||||
if (!msg->in_msg || msg->in_msg_sz < sizeof(*in) ||
|
||||
!msg->out_msg || msg->out_msg_sz < sizeof(*out))
|
||||
return -EINVAL;
|
||||
|
||||
in = (struct scmi_clk_get_permissions_in *)msg->in_msg;
|
||||
out = (struct scmi_clk_get_permissions_out *)msg->out_msg;
|
||||
|
||||
clk_state = get_scmi_clk_state(in->clock_id);
|
||||
if (!clk_state) {
|
||||
dev_err(dev, "Unexpected clock ID %u\n", in->clock_id);
|
||||
|
||||
out->status = SCMI_NOT_FOUND;
|
||||
} else {
|
||||
out->permissions = clk_state->perm;
|
||||
|
||||
out->status = SCMI_SUCCESS;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sandbox_scmi_rd_attribs(struct udevice *dev, struct scmi_msg *msg)
|
||||
{
|
||||
struct scmi_rd_attr_in *in = NULL;
|
||||
@@ -1193,6 +1239,8 @@ static int sandbox_scmi_test_process_msg(struct udevice *dev,
|
||||
return sandbox_proto_not_supported(msg);
|
||||
|
||||
switch (msg->message_id) {
|
||||
case SCMI_PROTOCOL_VERSION:
|
||||
return sandbox_scmi_clock_protocol_version(dev, msg);
|
||||
case SCMI_PROTOCOL_ATTRIBUTES:
|
||||
return sandbox_scmi_clock_protocol_attribs(dev, msg);
|
||||
case SCMI_CLOCK_ATTRIBUTES:
|
||||
@@ -1203,6 +1251,8 @@ static int sandbox_scmi_test_process_msg(struct udevice *dev,
|
||||
return sandbox_scmi_clock_rate_get(dev, msg);
|
||||
case SCMI_CLOCK_CONFIG_SET:
|
||||
return sandbox_scmi_clock_gate(dev, msg);
|
||||
case SCMI_CLOCK_GET_PERMISSIONS:
|
||||
return sandbox_scmi_clock_permissions_get(dev, msg);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user