aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Vizzarro <Luca.Vizzarro@arm.com>2020-09-30 16:24:43 +0100
committernicola-mazzucato-arm <42373140+nicola-mazzucato-arm@users.noreply.github.com>2020-10-22 14:39:59 +0100
commitcfac6b8b386756d95c33264e22deb15b26294004 (patch)
treee7246084137a5d6b6697d1345f82ceeddb54c757
parent05f3a4cbeacfc9f0a5a3f9da571b11b659530e09 (diff)
mod_scmi_clock: Fix config set default values
At startup all clocks may be running by default. Nonetheless, the mod_scmi_clock_config_set_policy function, which is the API the CLOCK_CONFIG_SET command refers to, sets its clocks state to be stopped by default. This commit fixes this behaviour, by giving the option per platform through its configuration to set the state of the clocks at startup (running/stopped). Change-Id: If39a2d710e4d778b10b649d07f05cfe17ad29e54 Signed-off-by: Luca Vizzarro <Luca.Vizzarro@arm.com>
-rw-r--r--module/scmi_clock/include/mod_scmi_clock.h9
-rw-r--r--module/scmi_clock/src/mod_scmi_clock.c20
2 files changed, 28 insertions, 1 deletions
diff --git a/module/scmi_clock/include/mod_scmi_clock.h b/module/scmi_clock/include/mod_scmi_clock.h
index 55804dbf..37d475a5 100644
--- a/module/scmi_clock/include/mod_scmi_clock.h
+++ b/module/scmi_clock/include/mod_scmi_clock.h
@@ -69,6 +69,15 @@ struct mod_scmi_clock_device {
* that is defined by the \c clock module.
*/
fwk_id_t element_id;
+
+ /*! \brief Startup clock status flag.
+ *
+ * \details State of the clock at startup. If set, it specifies that
+ * this clock starts running. This flag does not affect the actual
+ * state of the clock, but it provides an indication for the initial
+ * internal state map.
+ */
+ bool starts_enabled;
};
/*!
diff --git a/module/scmi_clock/src/mod_scmi_clock.c b/module/scmi_clock/src/mod_scmi_clock.c
index e277d74f..7093c234 100644
--- a/module/scmi_clock/src/mod_scmi_clock.c
+++ b/module/scmi_clock/src/mod_scmi_clock.c
@@ -411,7 +411,9 @@ FWK_WEAK int mod_scmi_clock_config_set_policy(
/* Pointer to a table of agent:clock states */
static uint8_t *agent_clock_state = NULL;
- unsigned int agent_id;
+ const struct mod_scmi_clock_agent *agent;
+
+ unsigned int agent_id, clock_id, idx;
int status = FWK_SUCCESS;
uint8_t clock_state;
@@ -427,6 +429,22 @@ FWK_WEAK int mod_scmi_clock_config_set_policy(
/* Allocate table of clock reference counts */
clock_count = fwk_mm_calloc(
(unsigned int)scmi_clock_ctx.clock_devices, sizeof(uint32_t));
+
+ /* Set all clocks as running if required */
+ for (agent_id = 0;
+ agent_id < (unsigned int)scmi_clock_ctx.config->agent_count;
+ agent_id++) {
+ agent = &scmi_clock_ctx.agent_table[agent_id];
+ for (clock_id = 0; clock_id < (unsigned int)agent->device_count;
+ clock_id++) {
+ if (agent->device_table[clock_id].starts_enabled) {
+ idx = (agent_id * scmi_clock_ctx.clock_devices) + clock_id;
+ agent_clock_state[idx] = MOD_CLOCK_STATE_RUNNING;
+
+ clock_count[clock_id]++;
+ }
+ }
+ }
}
/*