diff options
-rw-r--r-- | module/scmi_clock/include/mod_scmi_clock.h | 9 | ||||
-rw-r--r-- | module/scmi_clock/src/mod_scmi_clock.c | 20 |
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]++; + } + } + } } /* |