From 25e312281f21a23a393b29e8fb3532dd8adf24cb Mon Sep 17 00:00:00 2001 From: Tarek El-Sherbiny Date: Sat, 9 May 2020 02:11:52 +0100 Subject: [PATCH 1/6] power_domain: Add optional configuration for composite state mask Extending the composite state is required to support device implementation defined composite state. This patch adds a new configuration option to provide composite state mask table for each power domain element. The configuration is optional. If the table is not provided then composite state is not supported. The core power domain is a special case. If the table is not provided for the core the default table is used. Change-Id: I7b20c02414f8d11d3606a7829470af15d18af6ff Signed-off-by: Tarek El-Sherbiny --- .../power_domain/include/mod_power_domain.h | 14 +- module/power_domain/src/mod_power_domain.c | 167 +++++++++++++++--- 2 files changed, 158 insertions(+), 23 deletions(-) diff --git a/module/power_domain/include/mod_power_domain.h b/module/power_domain/include/mod_power_domain.h index bf2e1f571..0c951920a 100644 --- a/module/power_domain/include/mod_power_domain.h +++ b/module/power_domain/include/mod_power_domain.h @@ -238,6 +238,17 @@ struct mod_power_domain_element_config { */ const char **state_name_table; + /*! Composite state number of levels mask */ + const uint32_t composite_state_levels_mask; + + /*! + * Composite state mask table. This table provides the mask for each level + */ + const uint32_t *composite_state_mask_table; + + /*! Size of the composite state mask table */ + size_t composite_state_mask_table_size; + /*! Size of the table of allowed state masks */ size_t allowed_state_mask_table_size; @@ -321,9 +332,6 @@ enum { MOD_PD_LEVEL_3 * MOD_PD_CS_STATE_BITS_PER_LEVEL, MOD_PD_CS_LEVEL_SHIFT = MOD_PD_LEVEL_COUNT * MOD_PD_CS_STATE_BITS_PER_LEVEL, - - MOD_PD_CS_VALID_BITS = (1 << - (MOD_PD_CS_LEVEL_SHIFT + MOD_PD_CS_STATE_BITS_PER_LEVEL)) - 1 }; /*! diff --git a/module/power_domain/src/mod_power_domain.c b/module/power_domain/src/mod_power_domain.c index 6628ab404..d19edd1c7 100644 --- a/module/power_domain/src/mod_power_domain.c +++ b/module/power_domain/src/mod_power_domain.c @@ -108,6 +108,21 @@ struct pd_ctx { /* Size of the table of allowed state masks */ size_t allowed_state_mask_table_size; + /* Composite state is supported */ + bool cs_support; + + /* + * Composite state mask table. This table provides the mask for each level + */ + const uint32_t *composite_state_mask_table; + + /* Size of the composite state mask table */ + size_t composite_state_mask_table_size; + + /* Composite state number of levels mask */ + uint32_t composite_state_levels_mask; + + /* Pointer to the power domain's parent context */ struct pd_ctx *parent; @@ -278,6 +293,14 @@ static const unsigned int mod_pd_cs_level_state_shift[MOD_PD_LEVEL_COUNT] = { MOD_PD_CS_LEVEL_3_STATE_SHIFT }; +/* Mask of the core composite states */ +static const uint32_t core_composite_state_mask_table[] = { + MOD_PD_CS_STATE_MASK << MOD_PD_CS_LEVEL_0_STATE_SHIFT, + MOD_PD_CS_STATE_MASK << MOD_PD_CS_LEVEL_1_STATE_SHIFT, + MOD_PD_CS_STATE_MASK << MOD_PD_CS_LEVEL_2_STATE_SHIFT, + MOD_PD_CS_STATE_MASK << MOD_PD_CS_LEVEL_3_STATE_SHIFT, +}; + /* * Internal variables */ @@ -426,19 +449,67 @@ static const char *get_state_name(const struct pd_ctx *pd, unsigned int state) return unknown_name; } +static unsigned int number_of_bits_to_shift(uint32_t mask) +{ + unsigned int num_bits = 0; + + if (!mask) + return 0; + + while (!(mask & 1)) { + mask = mask >> 1; + num_bits++; + } + + return num_bits; +} + /* Functions related to a composite state */ static unsigned int get_level_state_from_composite_state( - uint32_t composite_state, enum mod_pd_level level) + const uint32_t* table, + uint32_t composite_state, + int level) { - return (composite_state >> mod_pd_cs_level_state_shift[level]) - & MOD_PD_CS_STATE_MASK; + uint32_t mask = table[level]; + unsigned int shift = number_of_bits_to_shift(mask); + + return (composite_state & mask) >> shift; + } -static enum mod_pd_level get_highest_level_from_composite_state( +static int get_highest_level_from_composite_state(const struct pd_ctx *pd, uint32_t composite_state) { - return (enum mod_pd_level)((composite_state >> MOD_PD_CS_LEVEL_SHIFT) & - MOD_PD_CS_STATE_MASK); + uint32_t state; + unsigned int shift, level; + const uint32_t *state_mask_table; + unsigned int table_size; + + if (!pd->cs_support) + return 0; + + if (pd->composite_state_levels_mask) { + shift = number_of_bits_to_shift(pd->composite_state_levels_mask); + level = (pd->composite_state_levels_mask + & composite_state) >> shift; + } else { + state_mask_table = pd->composite_state_mask_table; + table_size = pd->composite_state_mask_table_size; + + for (level = 0; + ((level < table_size) && (pd != NULL)); + level++, pd = pd->parent) { + + state = get_level_state_from_composite_state(state_mask_table, + composite_state, + level); + if (!is_valid_state(pd, state)) + break; + } + level--; + } + + return level; } static bool is_valid_composite_state(struct pd_ctx *target_pd, @@ -449,22 +520,31 @@ static bool is_valid_composite_state(struct pd_ctx *target_pd, unsigned int state, child_state = MOD_PD_STATE_OFF; struct pd_ctx *pd = target_pd; struct pd_ctx *child = NULL; + const uint32_t *state_mask_table; + unsigned int table_size; - if (composite_state & (~MOD_PD_CS_VALID_BITS)) - goto error; + assert(target_pd != NULL); level = get_level_from_tree_pos(pd->config->tree_pos); - highest_level = get_highest_level_from_composite_state(composite_state); + highest_level = get_highest_level_from_composite_state(pd, composite_state); if ((highest_level < level) || (highest_level >= MOD_PD_LEVEL_COUNT)) goto error; - for (; level <= highest_level; level++) { + if (!pd->cs_support) + goto error; + + state_mask_table = pd->composite_state_mask_table; + table_size = pd->composite_state_mask_table_size; + + for (; level <= highest_level && level < (table_size) ; level++) { if (pd == NULL) goto error; - state = get_level_state_from_composite_state(composite_state, level); + state = get_level_state_from_composite_state(state_mask_table, + composite_state, level); + if (!is_valid_state(pd, state)) goto error; @@ -498,17 +578,25 @@ error: static bool is_upwards_transition_propagation(const struct pd_ctx *lowest_pd, uint32_t composite_state) { - enum mod_pd_level lowest_level, highest_level, level; + int lowest_level, highest_level, level; const struct pd_ctx *pd; unsigned int state; + const uint32_t *state_mask_table; lowest_level = get_level_from_tree_pos(lowest_pd->config->tree_pos); - highest_level = get_highest_level_from_composite_state(composite_state); + highest_level = get_highest_level_from_composite_state(lowest_pd, + composite_state); + + if (!lowest_pd->cs_support) + return is_deeper_state(composite_state, lowest_pd->requested_state); + + state_mask_table = lowest_pd->allowed_state_mask_table; for (level = lowest_level, pd = lowest_pd; level <= highest_level; level++, pd = pd->parent) { - state = get_level_state_from_composite_state(composite_state, level); + state = get_level_state_from_composite_state(state_mask_table, + composite_state, level); if (state == pd->requested_state) continue; @@ -769,6 +857,8 @@ static void process_set_state_request( unsigned int nb_pds, pd_index, state; struct pd_ctx *pd, *pd_in_charge_of_response; const struct pd_ctx *parent; + const uint32_t *state_mask_table; + req_params = (struct pd_set_state_request *)event->params; resp_params = (struct pd_set_state_response *)resp_event->params; @@ -787,11 +877,14 @@ static void process_set_state_request( * than the highest power level. */ lowest_level = get_level_from_tree_pos(lowest_pd->config->tree_pos); - highest_level = get_highest_level_from_composite_state(composite_state); + highest_level = get_highest_level_from_composite_state(lowest_pd, + composite_state); nb_pds = highest_level - lowest_level + 1; status = FWK_SUCCESS; pd = lowest_pd; + state_mask_table = pd->composite_state_mask_table; + for (pd_index = 0; pd_index < nb_pds; pd_index++, pd = pd->parent) { if (up) level = lowest_level + pd_index; @@ -806,7 +899,8 @@ static void process_set_state_request( pd = pd->parent; } - state = get_level_state_from_composite_state(composite_state, level); + state = get_level_state_from_composite_state(state_mask_table, + composite_state, level); if (state == pd->requested_state) continue; @@ -911,14 +1005,21 @@ static void process_set_state_request( static int complete_system_suspend(struct pd_ctx *target_pd) { enum mod_pd_level level; - unsigned int composite_state = 0; + unsigned int shift, composite_state = 0; struct pd_ctx *pd = target_pd; struct fwk_event event, resp_event; struct pd_set_state_request *event_params = (struct pd_set_state_request *)event.params; struct pd_set_state_response *resp_params = (struct pd_set_state_response *)(&resp_event.params); + const uint32_t *state_mask_table; + int table_size; + if (!pd->cs_support) + return FWK_E_PARAM; + + state_mask_table = pd->composite_state_mask_table; + table_size = pd->composite_state_mask_table_size; /* * Traverse the PD tree bottom-up from current power domain to the top * to build the composite state with MOD_PD_STATE_OFF power state for all @@ -926,11 +1027,12 @@ static int complete_system_suspend(struct pd_ctx *target_pd) */ level = get_level_from_tree_pos(target_pd->config->tree_pos); do { + shift = number_of_bits_to_shift(state_mask_table[level]); composite_state |= ((pd->parent != NULL) ? MOD_PD_STATE_OFF : - mod_pd_ctx.system_suspend.state) - << mod_pd_cs_level_state_shift[level++]; + mod_pd_ctx.system_suspend.state) << shift; pd = pd->parent; - } while (pd != NULL); + level++; + } while ((pd != NULL) && (level < table_size)); /* * Finally, we need to update the highest valid level in the composite @@ -1778,6 +1880,31 @@ static int pd_power_domain_init(fwk_id_t pd_id, unsigned int unused, for (state = 0; state < pd->allowed_state_mask_table_size; state++) pd->valid_state_mask |= pd->allowed_state_mask_table[state]; + if ((pd_config->composite_state_mask_table != NULL) && + (pd_config->composite_state_mask_table_size > 0)) { + + pd->composite_state_mask_table = + pd_config->composite_state_mask_table; + pd->composite_state_mask_table_size = + pd_config->composite_state_mask_table_size; + pd->composite_state_levels_mask = + pd_config->composite_state_levels_mask; + pd->cs_support = true; + + } else if (pd_config->attributes.pd_type == MOD_PD_TYPE_CORE) { + + pd->composite_state_mask_table = + core_composite_state_mask_table; + pd->composite_state_mask_table_size = + FWK_ARRAY_SIZE(core_composite_state_mask_table); + pd->composite_state_levels_mask = + MOD_PD_CS_STATE_MASK << MOD_PD_CS_LEVEL_SHIFT; + pd->cs_support = true; + + } else + pd->cs_support = false; + + pd->id = pd_id; pd->config = pd_config; -- GitLab From 0bff2e46200b3b346b82f87bcc6fc66eaa77b99f Mon Sep 17 00:00:00 2001 From: Tarek El-Sherbiny Date: Sun, 26 Apr 2020 17:02:32 +0100 Subject: [PATCH 2/6] mod_scmi_power_domain: Allow implementation-defined power state If the requested power state is not defined by the SCMI spec. pass the value to the lower layers to process. Change-Id: Iece42a11ed12f9f3ce2e12073cb92e1a8a28f4e5 Signed-off-by: Tarek El-Sherbiny --- .../include/internal/scmi_power_domain.h | 1 + .../src/mod_scmi_power_domain.c | 31 +++++++------------ 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/module/scmi_power_domain/include/internal/scmi_power_domain.h b/module/scmi_power_domain/include/internal/scmi_power_domain.h index 279845cc1..b7f044a2b 100644 --- a/module/scmi_power_domain/include/internal/scmi_power_domain.h +++ b/module/scmi_power_domain/include/internal/scmi_power_domain.h @@ -27,6 +27,7 @@ #define SCMI_PD_DEVICE_STATE_ID_OFF 0 #define SCMI_PD_DEVICE_STATE_ID_ON 0 +#define SCMI_PD_DEVICE_STATE_ID 0 #define SCMI_PD_DEVICE_STATE_ID_MASK 0xFFFFFFF #define SCMI_PD_DEVICE_STATE_TYPE (1 << 30) diff --git a/module/scmi_power_domain/src/mod_scmi_power_domain.c b/module/scmi_power_domain/src/mod_scmi_power_domain.c index 220596f44..87b83bf50 100644 --- a/module/scmi_power_domain/src/mod_scmi_power_domain.c +++ b/module/scmi_power_domain/src/mod_scmi_power_domain.c @@ -130,14 +130,6 @@ static unsigned int payload_size_table[] = { [MOD_SCMI_PD_POWER_STATE_GET] = sizeof(struct scmi_pd_power_state_get_a2p), }; -static unsigned int scmi_dev_state_id_lost_ctx_to_pd_state[] = { - [SCMI_PD_DEVICE_STATE_ID_OFF] = MOD_PD_STATE_OFF, -}; - -static unsigned int scmi_dev_state_id_preserved_ctx_to_pd_state[] = { - [SCMI_PD_DEVICE_STATE_ID_ON] = MOD_PD_STATE_ON, -}; - static uint32_t pd_state_to_scmi_dev_state[] = { [MOD_PD_STATE_OFF] = SCMI_PD_DEVICE_STATE_ID_OFF | SCMI_PD_DEVICE_STATE_TYPE, @@ -192,18 +184,14 @@ static int scmi_device_state_to_pd_state(uint32_t scmi_state, ctx_lost = !!(scmi_state & SCMI_PD_DEVICE_STATE_TYPE); scmi_state_id = scmi_state & SCMI_PD_DEVICE_STATE_ID_MASK; - if (ctx_lost) { - if (scmi_state_id >= - FWK_ARRAY_SIZE(scmi_dev_state_id_lost_ctx_to_pd_state)) - return FWK_E_PWRSTATE; - - *pd_state = scmi_dev_state_id_lost_ctx_to_pd_state[scmi_state_id]; + if (scmi_state_id == SCMI_PD_DEVICE_STATE_ID) { + if (ctx_lost) + *pd_state = MOD_PD_STATE_OFF; + else + *pd_state = MOD_PD_STATE_ON; } else { - if (scmi_state_id >= - FWK_ARRAY_SIZE(scmi_dev_state_id_preserved_ctx_to_pd_state)) - return FWK_E_PWRSTATE; - - *pd_state = scmi_dev_state_id_preserved_ctx_to_pd_state[scmi_state_id]; + /* Implementation Defined state */ + *pd_state = scmi_state; } return FWK_SUCCESS; @@ -521,7 +509,10 @@ static int scmi_pd_power_state_set_handler(fwk_id_t service_id, goto exit; } - status = scmi_pd_ctx.pd_api->set_state(pd_id, pd_power_state); + status = scmi_pd_ctx.pd_api->set_composite_state_async( + pd_id, + false, + pd_power_state); break; case MOD_PD_TYPE_SYSTEM: -- GitLab From c20e555da371baa394f7d7e68780ab1e195b01c6 Mon Sep 17 00:00:00 2001 From: Tarek El-Sherbiny Date: Wed, 13 May 2020 16:23:41 +0100 Subject: [PATCH 3/6] power_domain: Merge set composite and set simple state api This patch simplifies the power domain api. The power_domain user should only call set_state. Each domain recognizes if it supports composite state or not and acts accordingly. Change-Id: I260e06712dbbf2863ab36ecd6506e24625228fae Signed-off-by: Tarek El-Sherbiny --- .../power_domain/include/mod_power_domain.h | 72 ++--------- module/power_domain/src/mod_power_domain.c | 120 +++++------------- .../src/mod_scmi_power_domain.c | 11 +- .../src/mod_scmi_system_power.c | 2 +- module/system_power/src/mod_system_power.c | 2 +- .../juno/module/juno_ppu/src/mod_juno_ppu.c | 2 +- .../module/n1sdp_c2c/src/mod_n1sdp_c2c_i2c.c | 12 +- .../n1sdp_system/src/mod_n1sdp_system.c | 4 +- .../rddaniel_system/src/mod_rddaniel_system.c | 4 +- .../src/mod_rddanielxlr_system.c | 4 +- .../rdn1e1_system/src/mod_rdn1e1_system.c | 4 +- .../sgi575_system/src/mod_sgi575_system.c | 4 +- .../synquacer_system/src/synquacer_main.c | 2 +- .../module/tc0_system/src/mod_tc0_system.c | 2 +- 14 files changed, 68 insertions(+), 177 deletions(-) diff --git a/module/power_domain/include/mod_power_domain.h b/module/power_domain/include/mod_power_domain.h index 0c951920a..b2fbc26b1 100644 --- a/module/power_domain/include/mod_power_domain.h +++ b/module/power_domain/include/mod_power_domain.h @@ -558,39 +558,6 @@ struct mod_pd_restricted_api { */ int (*get_domain_parent_id)(fwk_id_t pd_id, fwk_id_t *parent_pd_id); - /*! - * \brief Set the state of a power domain. - * - * \note The function sets the state of the power domain identified by - * 'pd_id' synchronously from the point of view of the caller. - * - * \param pd_id Identifier of the power domain whose state has to be set. - * \param state State of the power domain. - * - * \retval FWK_SUCCESS The power state was set. - * \retval FWK_E_ACCESS Invalid access, the framework has rejected the - * call to the API. - * \retval FWK_E_PARAM The power domain identifier is unknown. - * \retval FWK_E_PARAM The 'state' is not valid. - */ - int (*set_state)(fwk_id_t pd_id, unsigned int state); - - /*! - * \brief Request an asynchronous power state transition. - * - * \param pd_id Identifier of the power domain whose state has to be set. - * \param resp_requested True if the caller wants to be notified with an - * event response at the end of the request processing. - * \param state State of the power domain. - * - * \retval FWK_PENDING The power state transition request was submitted. - * \retval FWK_E_ACCESS Invalid access, the framework has rejected the - * call to the API. - * \retval FWK_E_PARAM One or more parameters were invalid. - */ - int (*set_state_async)(fwk_id_t pd_id, bool resp_requested, - unsigned int state); - /*! * \brief Set the state of a power domain and possibly of one or several of * its ancestors. @@ -601,22 +568,22 @@ struct mod_pd_restricted_api { * * \param pd_id Identifier of the power domain whose state has to be set. * - * \param composite_state State the power domain has to be put into and + * \param state State the power domain has to be put into and * possibly the state(s) its ancestor(s) has(have) to be put into. The * module will ensure that, for each power state transition, the parent * and the children of the power domain involved are in a state where * the transition can be completed. * - * \retval FWK_SUCCESS The composite power state transition was completed. + * \retval FWK_SUCCESS The power state transition was completed. * \retval FWK_E_ACCESS Invalid access, the framework has rejected the * call to the API. * \retval FWK_E_HANDLER The function is not called from a thread. * \retval FWK_E_PARAM One or more parameters were invalid. */ - int (*set_composite_state)(fwk_id_t pd_id, uint32_t composite_state); + int (*set_state)(fwk_id_t pd_id, uint32_t state); /*! - * \brief Request an asynchronous composite power state transition. + * \brief Request an asynchronous power state transition. * * \warning Successful completion of this function does not indicate * completion of a transition, but instead that a request has been @@ -627,19 +594,18 @@ struct mod_pd_restricted_api { * \param resp_requested True if the caller wants to be notified with an * event response at the end of the request processing. * - * \param composite_state State the power domain has to be put into and + * \param composite State the power domain has to be put into and * possibly the state(s) its ancestor(s) has(have) to be put into. The * module will ensure that, for each power state transition, the parent * and the children of the power domain involved are in a state where * the transition can be completed. * - * \retval FWK_SUCCESS The composite power state transition was submitted. + * \retval FWK_SUCCESS The power state transition was submitted. * \retval FWK_E_ACCESS Invalid access, the framework has rejected the * call to the API. * \retval FWK_E_PARAM One or more parameters were invalid. */ - int (*set_composite_state_async)(fwk_id_t pd_id, bool resp_requested, - uint32_t composite_state); + int (*set_state_async)(fwk_id_t pd_id, bool resp_requested, uint32_t state); /*! * \brief Get the state of a given power domain. @@ -742,26 +708,6 @@ struct mod_pd_restricted_api { * transitions following the occurrence of interrupts. */ struct mod_pd_driver_input_api { - /*! - * \brief Request an asynchronous power state transition. - * - * \warning Successful completion of this function does not indicate - * completion of a transition, but instead that a request has been - * submitted. - * - * \param pd_id Identifier of the power domain whose state has to be set. - * \param resp_requested True if the caller wants to be notified with an - * event response at the end of the request processing. - * \param state State of the power domain. - * - * \retval FWK_SUCCESS The power state transition request was submitted. - * \retval FWK_E_ACCESS Invalid access, the framework has rejected the - * call to the API. - * \retval FWK_E_PARAM One or more parameters were invalid. - */ - int (*set_state_async)(fwk_id_t pd_id, bool resp_requested, - unsigned int state); - /*! * \brief Request an asynchronous composite power state transition. * @@ -785,8 +731,8 @@ struct mod_pd_driver_input_api { * call to the API. * \retval FWK_E_PARAM One or more parameters were invalid. */ - int (*set_composite_state_async)(fwk_id_t pd_id, bool resp_requested, - uint32_t composite_state); + int (*set_state_async)(fwk_id_t pd_id, bool resp_requested, + uint32_t composite_state); /*! * \brief Request for a power domain to be reset. diff --git a/module/power_domain/src/mod_power_domain.c b/module/power_domain/src/mod_power_domain.c index d19edd1c7..b8b4d693d 100644 --- a/module/power_domain/src/mod_power_domain.c +++ b/module/power_domain/src/mod_power_domain.c @@ -852,7 +852,7 @@ static void process_set_state_request( struct pd_set_state_request *req_params; struct pd_set_state_response *resp_params; uint32_t composite_state; - bool up, first_power_state_transition_initiated; + bool up, first_power_state_transition_initiated, composite_state_operation; enum mod_pd_level lowest_level, highest_level, level; unsigned int nb_pds, pd_index, state; struct pd_ctx *pd, *pd_in_charge_of_response; @@ -883,7 +883,10 @@ static void process_set_state_request( status = FWK_SUCCESS; pd = lowest_pd; - state_mask_table = pd->composite_state_mask_table; + + composite_state_operation = pd->cs_support; + if (composite_state_operation) + state_mask_table = pd->composite_state_mask_table; for (pd_index = 0; pd_index < nb_pds; pd_index++, pd = pd->parent) { if (up) @@ -899,8 +902,14 @@ static void process_set_state_request( pd = pd->parent; } - state = get_level_state_from_composite_state(state_mask_table, - composite_state, level); + + if (composite_state_operation) + state = get_level_state_from_composite_state(state_mask_table, + composite_state, + level); + else + state = composite_state; + if (state == pd->requested_state) continue; @@ -1473,77 +1482,7 @@ static int pd_get_domain_parent_id(fwk_id_t pd_id, fwk_id_t *parent_pd_id) /* Functions specific to the restricted API */ -static int pd_set_state(fwk_id_t pd_id, unsigned int state) -{ - int status; - struct pd_ctx *pd; - enum mod_pd_level level; - struct fwk_event req; - struct fwk_event resp; - struct pd_set_state_request *req_params = - (struct pd_set_state_request *)(&req.params); - struct pd_set_state_response *resp_params = - (struct pd_set_state_response *)(&resp.params); - - pd = &mod_pd_ctx.pd_ctx_table[fwk_id_get_element_idx(pd_id)]; - - if (!is_valid_state(pd, state)) - return FWK_E_PARAM; - - level = get_level_from_tree_pos(pd->config->tree_pos); - - req = (struct fwk_event) { - .id = FWK_ID_EVENT(FWK_MODULE_IDX_POWER_DOMAIN, - MOD_PD_PUBLIC_EVENT_IDX_SET_STATE), - .target_id = pd_id, - }; - - req_params->composite_state = (level << MOD_PD_CS_LEVEL_SHIFT) | - (state << mod_pd_cs_level_state_shift[level]); - - status = fwk_thread_put_event_and_wait(&req, &resp); - if (status != FWK_SUCCESS) - return status; - - return resp_params->status; -} - -static int pd_set_state_async(fwk_id_t pd_id, - bool response_requested, unsigned int state) -{ - struct pd_ctx *pd; - enum mod_pd_level level; - struct fwk_event req; - struct pd_set_state_request *req_params = - (struct pd_set_state_request *)(&req.params); - int status; - - pd = &mod_pd_ctx.pd_ctx_table[fwk_id_get_element_idx(pd_id)]; - - if (!is_valid_state(pd, state)) - return FWK_E_PARAM; - - level = get_level_from_tree_pos(pd->config->tree_pos); - - req = (struct fwk_event) { - .id = FWK_ID_EVENT(FWK_MODULE_IDX_POWER_DOMAIN, - MOD_PD_PUBLIC_EVENT_IDX_SET_STATE), - .source_id = pd->driver_id, - .target_id = pd_id, - .response_requested = response_requested, - }; - - req_params->composite_state = (level << MOD_PD_CS_LEVEL_SHIFT) | - (state << mod_pd_cs_level_state_shift[level]); - - status = fwk_thread_put_event(&req); - if (status == FWK_SUCCESS) - return FWK_PENDING; - - return status; -} - -static int pd_set_composite_state(fwk_id_t pd_id, uint32_t composite_state) +static int pd_set_state(fwk_id_t pd_id, uint32_t state) { int status; struct pd_ctx *pd; @@ -1556,8 +1495,13 @@ static int pd_set_composite_state(fwk_id_t pd_id, uint32_t composite_state) pd = &mod_pd_ctx.pd_ctx_table[fwk_id_get_element_idx(pd_id)]; - if (!is_valid_composite_state(pd, composite_state)) - return FWK_E_PARAM; + if (pd->cs_support) { + if (!is_valid_composite_state(pd, state)) + return FWK_E_PARAM; + } else { + if (!is_valid_state(pd, state)) + return FWK_E_PARAM; + } req = (struct fwk_event) { .id = FWK_ID_EVENT(FWK_MODULE_IDX_POWER_DOMAIN, @@ -1566,7 +1510,7 @@ static int pd_set_composite_state(fwk_id_t pd_id, uint32_t composite_state) .target_id = pd_id, }; - req_params->composite_state = composite_state; + req_params->composite_state = state; status = fwk_thread_put_event_and_wait(&req, &resp); if (status != FWK_SUCCESS) @@ -1575,9 +1519,9 @@ static int pd_set_composite_state(fwk_id_t pd_id, uint32_t composite_state) return resp_params->status; } -static int pd_set_composite_state_async(fwk_id_t pd_id, - bool response_requested, - uint32_t composite_state) +static int pd_set_state_async(fwk_id_t pd_id, + bool response_requested, + uint32_t state) { struct pd_ctx *pd; struct fwk_event req; @@ -1586,8 +1530,13 @@ static int pd_set_composite_state_async(fwk_id_t pd_id, pd = &mod_pd_ctx.pd_ctx_table[fwk_id_get_element_idx(pd_id)]; - if (!is_valid_composite_state(pd, composite_state)) - return FWK_E_PARAM; + if (pd->cs_support) { + if (!is_valid_composite_state(pd, state)) + return FWK_E_PARAM; + } else { + if (!is_valid_state(pd, state)) + return FWK_E_PARAM; + } req = (struct fwk_event) { .id = FWK_ID_EVENT(FWK_MODULE_IDX_POWER_DOMAIN, @@ -1597,7 +1546,7 @@ static int pd_set_composite_state_async(fwk_id_t pd_id, .response_requested = response_requested, }; - req_params->composite_state = composite_state; + req_params->composite_state = state; return fwk_thread_put_event(&req); } @@ -1801,8 +1750,6 @@ static const struct mod_pd_restricted_api pd_restricted_api = { .set_state = pd_set_state, .set_state_async = pd_set_state_async, - .set_composite_state = pd_set_composite_state, - .set_composite_state_async = pd_set_composite_state_async, .get_state = pd_get_state, .get_composite_state = pd_get_composite_state, .reset = pd_reset, @@ -1812,7 +1759,6 @@ static const struct mod_pd_restricted_api pd_restricted_api = { static const struct mod_pd_driver_input_api pd_driver_input_api = { .set_state_async = pd_set_state_async, - .set_composite_state_async = pd_set_composite_state_async, .reset_async = pd_reset_async, .report_power_state_transition = pd_report_power_state_transition, .get_last_core_pd_id = pd_get_last_core_pd_id, diff --git a/module/scmi_power_domain/src/mod_scmi_power_domain.c b/module/scmi_power_domain/src/mod_scmi_power_domain.c index 87b83bf50..eebd94ff9 100644 --- a/module/scmi_power_domain/src/mod_scmi_power_domain.c +++ b/module/scmi_power_domain/src/mod_scmi_power_domain.c @@ -355,8 +355,8 @@ static int scmi_power_scp_set_core_state(fwk_id_t pd_id, { int status; - status = scmi_pd_ctx.pd_api->set_composite_state_async(pd_id, false, - composite_state); + status = scmi_pd_ctx.pd_api->set_state_async(pd_id, false, + composite_state); if (status != FWK_SUCCESS) { FWK_LOG_ERR( "[SCMI:power] Failed to send core set request (error %s (%d))", @@ -509,10 +509,9 @@ static int scmi_pd_power_state_set_handler(fwk_id_t service_id, goto exit; } - status = scmi_pd_ctx.pd_api->set_composite_state_async( - pd_id, - false, - pd_power_state); + + status = scmi_pd_ctx.pd_api->set_state_async(pd_id, false, + pd_power_state); break; case MOD_PD_TYPE_SYSTEM: diff --git a/module/scmi_system_power/src/mod_scmi_system_power.c b/module/scmi_system_power/src/mod_scmi_system_power.c index b60813a46..9add1395e 100644 --- a/module/scmi_system_power/src/mod_scmi_system_power.c +++ b/module/scmi_system_power/src/mod_scmi_system_power.c @@ -327,7 +327,7 @@ static int scmi_sys_power_state_set_handler(fwk_id_t service_id, goto exit; } - status = scmi_sys_power_ctx.pd_api->set_composite_state( + status = scmi_sys_power_ctx.pd_api->set_state( scmi_sys_power_ctx.config->wakeup_power_domain_id, scmi_sys_power_ctx.config->wakeup_composite_state); if (status != FWK_SUCCESS) diff --git a/module/system_power/src/mod_system_power.c b/module/system_power/src/mod_system_power.c index 3e9304fa7..d021d305f 100644 --- a/module/system_power/src/mod_system_power.c +++ b/module/system_power/src/mod_system_power.c @@ -322,7 +322,7 @@ static void soc_wakeup_handler(void) fwk_trap(); status = - system_power_ctx.mod_pd_restricted_api->set_composite_state_async( + system_power_ctx.mod_pd_restricted_api->set_state_async( system_power_ctx.last_core_pd_id, false, state); fwk_check(status == FWK_SUCCESS); } diff --git a/product/juno/module/juno_ppu/src/mod_juno_ppu.c b/product/juno/module/juno_ppu/src/mod_juno_ppu.c index 8885c0897..ce489b4b8 100644 --- a/product/juno/module/juno_ppu/src/mod_juno_ppu.c +++ b/product/juno/module/juno_ppu/src/mod_juno_ppu.c @@ -732,7 +732,7 @@ static void core_wakeup_handler(uintptr_t param) status = disable_wakeup_irq(dev_config); fwk_assert(status == FWK_SUCCESS); - status = ppu_ctx->pd_api->set_composite_state_async(ppu_ctx->bound_id, + status = ppu_ctx->pd_api->set_state_async(ppu_ctx->bound_id, false, CPU_WAKEUP_COMPOSITE_STATE); fwk_assert(status == FWK_SUCCESS); } diff --git a/product/n1sdp/module/n1sdp_c2c/src/mod_n1sdp_c2c_i2c.c b/product/n1sdp/module/n1sdp_c2c/src/mod_n1sdp_c2c_i2c.c index 15f56f18e..79e1c0319 100644 --- a/product/n1sdp/module/n1sdp_c2c/src/mod_n1sdp_c2c_i2c.c +++ b/product/n1sdp/module/n1sdp_c2c/src/mod_n1sdp_c2c_i2c.c @@ -685,7 +685,7 @@ static int n1sdp_c2c_process_command(void) */ switch (rx_data[2]) { case MOD_PD_TYPE_CORE: - status = n1sdp_c2c_ctx.pd_api->set_composite_state( + status = n1sdp_c2c_ctx.pd_api->set_state( FWK_ID_ELEMENT(FWK_MODULE_IDX_POWER_DOMAIN, rx_data[1]), MOD_PD_COMPOSITE_STATE(MOD_PD_LEVEL_2, 0, MOD_PD_STATE_ON, MOD_PD_STATE_ON, MOD_PD_STATE_OFF)); @@ -695,7 +695,7 @@ static int n1sdp_c2c_process_command(void) case MOD_PD_TYPE_CLUSTER: case MOD_PD_TYPE_DEVICE_DEBUG: - status = n1sdp_c2c_ctx.pd_api->set_composite_state( + status = n1sdp_c2c_ctx.pd_api->set_state( FWK_ID_ELEMENT(FWK_MODULE_IDX_POWER_DOMAIN, rx_data[1]), MOD_PD_COMPOSITE_STATE(MOD_PD_LEVEL_2, 0, MOD_PD_STATE_ON, MOD_PD_STATE_OFF, MOD_PD_STATE_OFF)); @@ -704,7 +704,7 @@ static int n1sdp_c2c_process_command(void) break; case MOD_PD_TYPE_SYSTEM: - status = n1sdp_c2c_ctx.pd_api->set_composite_state( + status = n1sdp_c2c_ctx.pd_api->set_state( FWK_ID_ELEMENT(FWK_MODULE_IDX_POWER_DOMAIN, rx_data[1]), MOD_PD_COMPOSITE_STATE(MOD_PD_LEVEL_2, 0, MOD_PD_STATE_ON, MOD_PD_STATE_OFF, MOD_PD_STATE_OFF)); @@ -726,7 +726,7 @@ static int n1sdp_c2c_process_command(void) */ switch (rx_data[2]) { case MOD_PD_TYPE_CORE: - status = n1sdp_c2c_ctx.pd_api->set_composite_state( + status = n1sdp_c2c_ctx.pd_api->set_state( FWK_ID_ELEMENT(FWK_MODULE_IDX_POWER_DOMAIN, rx_data[1]), MOD_PD_COMPOSITE_STATE(MOD_PD_LEVEL_2, 0, MOD_PD_STATE_ON, MOD_PD_STATE_ON, MOD_PD_STATE_ON)); @@ -736,7 +736,7 @@ static int n1sdp_c2c_process_command(void) case MOD_PD_TYPE_CLUSTER: case MOD_PD_TYPE_DEVICE_DEBUG: - status = n1sdp_c2c_ctx.pd_api->set_composite_state( + status = n1sdp_c2c_ctx.pd_api->set_state( FWK_ID_ELEMENT(FWK_MODULE_IDX_POWER_DOMAIN, rx_data[1]), MOD_PD_COMPOSITE_STATE(MOD_PD_LEVEL_2, 0, MOD_PD_STATE_ON, MOD_PD_STATE_ON, MOD_PD_STATE_OFF)); @@ -745,7 +745,7 @@ static int n1sdp_c2c_process_command(void) break; case MOD_PD_TYPE_SYSTEM: - status = n1sdp_c2c_ctx.pd_api->set_composite_state( + status = n1sdp_c2c_ctx.pd_api->set_state( FWK_ID_ELEMENT(FWK_MODULE_IDX_POWER_DOMAIN, rx_data[1]), MOD_PD_COMPOSITE_STATE(MOD_PD_LEVEL_2, 0, MOD_PD_STATE_ON, MOD_PD_STATE_OFF, MOD_PD_STATE_OFF)); diff --git a/product/n1sdp/module/n1sdp_system/src/mod_n1sdp_system.c b/product/n1sdp/module/n1sdp_system/src/mod_n1sdp_system.c index 17bec9394..27cbf9928 100644 --- a/product/n1sdp/module/n1sdp_system/src/mod_n1sdp_system.c +++ b/product/n1sdp/module/n1sdp_system/src/mod_n1sdp_system.c @@ -450,7 +450,7 @@ static int n1sdp_system_init_primary_core(void) "[N1SDP SYSTEM] Booting primary core at %lu MHz...", PIK_CLK_RATE_CLUS0_CPU / FWK_MHZ); - status = mod_pd_restricted_api->set_composite_state_async( + status = mod_pd_restricted_api->set_state_async( FWK_ID_ELEMENT(FWK_MODULE_IDX_POWER_DOMAIN, 0), false, MOD_PD_COMPOSITE_STATE(MOD_PD_LEVEL_2, 0, MOD_PD_STATE_ON, @@ -644,7 +644,7 @@ static int n1sdp_system_start(fwk_id_t id) MOD_PD_STATE_OFF); } - return n1sdp_system_ctx.mod_pd_restricted_api->set_composite_state_async( + return n1sdp_system_ctx.mod_pd_restricted_api->set_state_async( FWK_ID_ELEMENT(FWK_MODULE_IDX_POWER_DOMAIN, 0), false, composite_state); } diff --git a/product/rddaniel/module/rddaniel_system/src/mod_rddaniel_system.c b/product/rddaniel/module/rddaniel_system/src/mod_rddaniel_system.c index 5910986c2..036e11a3f 100644 --- a/product/rddaniel/module/rddaniel_system/src/mod_rddaniel_system.c +++ b/product/rddaniel/module/rddaniel_system/src/mod_rddaniel_system.c @@ -281,7 +281,7 @@ static int rddaniel_system_start(fwk_id_t id) return status; return - rddaniel_system_ctx.mod_pd_restricted_api->set_composite_state_async( + rddaniel_system_ctx.mod_pd_restricted_api->set_state_async( FWK_ID_ELEMENT(FWK_MODULE_IDX_POWER_DOMAIN, 0), false, MOD_PD_COMPOSITE_STATE(MOD_PD_LEVEL_2, 0, MOD_PD_STATE_ON, MOD_PD_STATE_OFF, MOD_PD_STATE_OFF)); @@ -310,7 +310,7 @@ int rddaniel_system_process_notification(const struct fwk_event *event, mod_pd_restricted_api = rddaniel_system_ctx.mod_pd_restricted_api; - status = mod_pd_restricted_api->set_composite_state_async( + status = mod_pd_restricted_api->set_state_async( FWK_ID_ELEMENT(FWK_MODULE_IDX_POWER_DOMAIN, 0), false, MOD_PD_COMPOSITE_STATE(MOD_PD_LEVEL_2, 0, MOD_PD_STATE_ON, diff --git a/product/rddanielxlr/module/rddanielxlr_system/src/mod_rddanielxlr_system.c b/product/rddanielxlr/module/rddanielxlr_system/src/mod_rddanielxlr_system.c index 162307643..fdd2f3c06 100644 --- a/product/rddanielxlr/module/rddanielxlr_system/src/mod_rddanielxlr_system.c +++ b/product/rddanielxlr/module/rddanielxlr_system/src/mod_rddanielxlr_system.c @@ -300,7 +300,7 @@ static int rddanielxlr_system_start(fwk_id_t id) return status; return - rddanielxlr_system_ctx.mod_pd_restricted_api->set_composite_state_async( + rddanielxlr_system_ctx.mod_pd_restricted_api->set_state_async( FWK_ID_ELEMENT(FWK_MODULE_IDX_POWER_DOMAIN, 0), false, MOD_PD_COMPOSITE_STATE(MOD_PD_LEVEL_2, 0, MOD_PD_STATE_ON, MOD_PD_STATE_OFF, MOD_PD_STATE_OFF)); @@ -338,7 +338,7 @@ int rddanielxlr_system_process_notification(const struct fwk_event *event, mod_pd_restricted_api = rddanielxlr_system_ctx.mod_pd_restricted_api; - status = mod_pd_restricted_api->set_composite_state_async( + status = mod_pd_restricted_api->set_state_async( FWK_ID_ELEMENT(FWK_MODULE_IDX_POWER_DOMAIN, 0), false, MOD_PD_COMPOSITE_STATE(MOD_PD_LEVEL_2, 0, MOD_PD_STATE_ON, diff --git a/product/rdn1e1/module/rdn1e1_system/src/mod_rdn1e1_system.c b/product/rdn1e1/module/rdn1e1_system/src/mod_rdn1e1_system.c index f38508d14..f99e76382 100644 --- a/product/rdn1e1/module/rdn1e1_system/src/mod_rdn1e1_system.c +++ b/product/rdn1e1/module/rdn1e1_system/src/mod_rdn1e1_system.c @@ -304,7 +304,7 @@ static int rdn1e1_system_start(fwk_id_t id) return status; return - rdn1e1_system_ctx.mod_pd_restricted_api->set_composite_state_async( + rdn1e1_system_ctx.mod_pd_restricted_api->set_state_async( FWK_ID_ELEMENT(FWK_MODULE_IDX_POWER_DOMAIN, 0), false, MOD_PD_COMPOSITE_STATE(MOD_PD_LEVEL_2, 0, MOD_PD_STATE_ON, MOD_PD_STATE_OFF, MOD_PD_STATE_OFF)); @@ -373,7 +373,7 @@ int rdn1e1_system_process_notification(const struct fwk_event *event, mod_pd_restricted_api = rdn1e1_system_ctx.mod_pd_restricted_api; - status = mod_pd_restricted_api->set_composite_state_async( + status = mod_pd_restricted_api->set_state_async( FWK_ID_ELEMENT(FWK_MODULE_IDX_POWER_DOMAIN, 0), false, MOD_PD_COMPOSITE_STATE(MOD_PD_LEVEL_2, 0, MOD_PD_STATE_ON, diff --git a/product/sgi575/module/sgi575_system/src/mod_sgi575_system.c b/product/sgi575/module/sgi575_system/src/mod_sgi575_system.c index 76d8b00f1..d7b0818a3 100644 --- a/product/sgi575/module/sgi575_system/src/mod_sgi575_system.c +++ b/product/sgi575/module/sgi575_system/src/mod_sgi575_system.c @@ -278,7 +278,7 @@ static int sgi575_system_start(fwk_id_t id) return status; return - sgi575_system_ctx.mod_pd_restricted_api->set_composite_state_async( + sgi575_system_ctx.mod_pd_restricted_api->set_state_async( FWK_ID_ELEMENT(FWK_MODULE_IDX_POWER_DOMAIN, 0), false, MOD_PD_COMPOSITE_STATE(MOD_PD_LEVEL_2, 0, MOD_PD_STATE_ON, MOD_PD_STATE_OFF, MOD_PD_STATE_OFF)); @@ -307,7 +307,7 @@ int sgi575_system_process_notification(const struct fwk_event *event, mod_pd_restricted_api = sgi575_system_ctx.mod_pd_restricted_api; - status = mod_pd_restricted_api->set_composite_state_async( + status = mod_pd_restricted_api->set_state_async( FWK_ID_ELEMENT(FWK_MODULE_IDX_POWER_DOMAIN, 0), false, MOD_PD_COMPOSITE_STATE(MOD_PD_LEVEL_2, 0, MOD_PD_STATE_ON, diff --git a/product/synquacer/module/synquacer_system/src/synquacer_main.c b/product/synquacer/module/synquacer_system/src/synquacer_main.c index 893690b72..d871a5315 100644 --- a/product/synquacer/module/synquacer_system/src/synquacer_main.c +++ b/product/synquacer/module/synquacer_system/src/synquacer_main.c @@ -349,7 +349,7 @@ int synquacer_main(void) FWK_LOG_INFO("[SYNQUACER SYSTEM] powering up AP"); status = - synquacer_system_ctx.mod_pd_restricted_api->set_composite_state_async( + synquacer_system_ctx.mod_pd_restricted_api->set_state_async( FWK_ID_ELEMENT(FWK_MODULE_IDX_POWER_DOMAIN, 0), false, MOD_PD_COMPOSITE_STATE( diff --git a/product/tc0/module/tc0_system/src/mod_tc0_system.c b/product/tc0/module/tc0_system/src/mod_tc0_system.c index 1036e8ae2..be593c9cd 100644 --- a/product/tc0/module/tc0_system/src/mod_tc0_system.c +++ b/product/tc0/module/tc0_system/src/mod_tc0_system.c @@ -282,7 +282,7 @@ static int tc0_system_start(fwk_id_t id) return tc0_system_ctx.mod_pd_restricted_api - ->set_composite_state_async( + ->set_state_async( FWK_ID_ELEMENT(FWK_MODULE_IDX_POWER_DOMAIN, 0), false, MOD_PD_COMPOSITE_STATE(MOD_PD_LEVEL_2, 0, MOD_PD_STATE_ON, MOD_PD_STATE_OFF, MOD_PD_STATE_OFF)); -- GitLab From e4868256a3e67c6ea66b89e144128cf5663b71a4 Mon Sep 17 00:00:00 2001 From: Tarek El-Sherbiny Date: Mon, 8 Jun 2020 00:24:49 +0100 Subject: [PATCH 4/6] power_domain: Get implementation-defined power state This patch adds the support to get-state for device power domain implementation-defined composite state. It also simplifies the power domain get_state api by merging get_state and get_composite_state. Change-Id: Ice2f0771ceb92cac608bd573f559133da36c939d Signed-off-by: Tarek El-Sherbiny --- .../power_domain/include/mod_power_domain.h | 21 ------ module/power_domain/src/mod_power_domain.c | 66 +++++-------------- .../src/mod_scmi_power_domain.c | 10 ++- 3 files changed, 20 insertions(+), 77 deletions(-) diff --git a/module/power_domain/include/mod_power_domain.h b/module/power_domain/include/mod_power_domain.h index b2fbc26b1..e43a1c73e 100644 --- a/module/power_domain/include/mod_power_domain.h +++ b/module/power_domain/include/mod_power_domain.h @@ -623,27 +623,6 @@ struct mod_pd_restricted_api { */ int (*get_state)(fwk_id_t pd_id, unsigned int *state); - /*! - * \brief Get the composite state of a power domain and its ancestors (if - * any) in the power domain tree. - * - * \note The function gets the composite state of the power domain - * identified by 'pd_id' and its ancestors (if any) synchronously from - * the point of view of the calling thread. - * - * \param pd_id Identifier of the power domain whose composite state has to - * be retrieved. - * \param[out] composite_state The power domain composite state. - * - * \retval FWK_SUCCESS The composite state was returned. - * \retval FWK_E_ACCESS Invalid access, the framework has rejected the - * call to the API. - * \retval FWK_E_HANDLER The function is not called from a thread. - * \retval FWK_E_PARAM The power domain identifier is unknown. - * \retval FWK_E_PARAM The pointer 'composite state' is equal to NULL. - */ - int (*get_composite_state)(fwk_id_t pd_id, unsigned int *composite_state); - /*! * \brief Reset of a power domain. * diff --git a/module/power_domain/src/mod_power_domain.c b/module/power_domain/src/mod_power_domain.c index b8b4d693d..816a32add 100644 --- a/module/power_domain/src/mod_power_domain.c +++ b/module/power_domain/src/mod_power_domain.c @@ -282,17 +282,6 @@ struct pd_system_shutdown_request { enum mod_pd_system_shutdown system_shutdown; }; -/* - * For each power level, shift in a composite state of the state for the power - * level. - */ -static const unsigned int mod_pd_cs_level_state_shift[MOD_PD_LEVEL_COUNT] = { - MOD_PD_CS_LEVEL_0_STATE_SHIFT, - MOD_PD_CS_LEVEL_1_STATE_SHIFT, - MOD_PD_CS_LEVEL_2_STATE_SHIFT, - MOD_PD_CS_LEVEL_3_STATE_SHIFT -}; - /* Mask of the core composite states */ static const uint32_t core_composite_state_mask_table[] = { MOD_PD_CS_STATE_MASK << MOD_PD_CS_LEVEL_0_STATE_SHIFT, @@ -1072,26 +1061,37 @@ static void process_get_state_request(struct pd_ctx *pd, { enum mod_pd_level level = get_level_from_tree_pos(pd->config->tree_pos); unsigned int composite_state = 0; + uint32_t shift; + const uint32_t *state_mask_table; + int table_size, cs_idx = 0; - if (!req_params->composite) + if (!pd->cs_support) resp_params->state = pd->current_state; else { + state_mask_table = pd->composite_state_mask_table; + table_size = pd->composite_state_mask_table_size; + /* * Traverse the PD tree bottom-up from current power domain to the top, * collecting node's states and placing them in the correct position in * the composite state. */ do { - composite_state |= pd->current_state << - mod_pd_cs_level_state_shift[level++]; + shift = number_of_bits_to_shift(state_mask_table[cs_idx]); + composite_state |= pd->current_state << shift; pd = pd->parent; - } while (pd != NULL); + cs_idx++; + level++; + } while (pd != NULL && cs_idx < table_size); /* * Finally, we need to update the highest valid level in * the composite state. */ - composite_state |= (--level) << MOD_PD_CS_LEVEL_SHIFT; + if (pd->composite_state_levels_mask) { + shift = number_of_bits_to_shift(pd->composite_state_levels_mask); + composite_state |= (--level) << shift; + } resp_params->state = composite_state; } @@ -1584,39 +1584,6 @@ static int pd_get_state(fwk_id_t pd_id, unsigned int *state) return FWK_SUCCESS; } -static int pd_get_composite_state(fwk_id_t pd_id, unsigned int *composite_state) -{ - int status; - struct fwk_event req; - struct fwk_event resp; - struct pd_get_state_request *req_params = - (struct pd_get_state_request *)(&req.params); - struct pd_get_state_response *resp_params = - (struct pd_get_state_response *)(&resp.params); - - if (composite_state == NULL) - return FWK_E_PARAM; - - req = (struct fwk_event) { - .id = FWK_ID_EVENT(FWK_MODULE_IDX_POWER_DOMAIN, - MOD_PD_PUBLIC_EVENT_IDX_GET_STATE), - .target_id = pd_id, - }; - - req_params->composite = true; - - status = fwk_thread_put_event_and_wait(&req, &resp); - if (status != FWK_SUCCESS) - return status; - - if (resp_params->status != FWK_SUCCESS) - return resp_params->status; - - *composite_state = resp_params->state; - - return FWK_SUCCESS; -} - static int pd_reset(fwk_id_t pd_id) { int status; @@ -1751,7 +1718,6 @@ static const struct mod_pd_restricted_api pd_restricted_api = { .set_state = pd_set_state, .set_state_async = pd_set_state_async, .get_state = pd_get_state, - .get_composite_state = pd_get_composite_state, .reset = pd_reset, .system_suspend = pd_system_suspend, .system_shutdown = pd_system_shutdown diff --git a/module/scmi_power_domain/src/mod_scmi_power_domain.c b/module/scmi_power_domain/src/mod_scmi_power_domain.c index eebd94ff9..a0b122fef 100644 --- a/module/scmi_power_domain/src/mod_scmi_power_domain.c +++ b/module/scmi_power_domain/src/mod_scmi_power_domain.c @@ -200,10 +200,11 @@ static int scmi_device_state_to_pd_state(uint32_t scmi_state, static int pd_state_to_scmi_device_state(unsigned int pd_state, uint32_t *scmi_state) { - if (pd_state >= FWK_ARRAY_SIZE(pd_state_to_scmi_dev_state)) - return FWK_E_PWRSTATE; + if (pd_state == MOD_PD_STATE_OFF || pd_state == MOD_PD_STATE_ON) + *scmi_state = pd_state_to_scmi_dev_state[pd_state]; + else + *scmi_state = pd_state; - *scmi_state = pd_state_to_scmi_dev_state[pd_state]; return FWK_SUCCESS; } @@ -571,9 +572,6 @@ static int scmi_pd_power_state_get_handler(fwk_id_t service_id, switch (pd_type) { case MOD_PD_TYPE_CORE: - status = scmi_pd_ctx.pd_api->get_composite_state(pd_id, &power_state); - break; - case MOD_PD_TYPE_CLUSTER: status = scmi_pd_ctx.pd_api->get_state(pd_id, &power_state); break; -- GitLab From 8e0443c6153fa19fafc8f778e9fa397e3e367175 Mon Sep 17 00:00:00 2001 From: Tarek El-Sherbiny Date: Mon, 4 May 2020 18:12:25 +0100 Subject: [PATCH 5/6] power_domain: Simplify power domain tree handling Each power domain will have a linked list of children and a pointer to the parent. The configuration will provide the index of the parent. The parent pointer is populated based on this index. Change-Id: I55d476989a581ea70286001728c2200bcc2866f4 Signed-off-by: Tarek El-Sherbiny --- .../power_domain/include/mod_power_domain.h | 84 +---- module/power_domain/src/mod_power_domain.c | 204 +++---------- product/juno/scp_ramfw/config_power_domain.c | 77 +---- product/juno/scp_ramfw/config_power_domain.h | 4 + product/n1sdp/scp_ramfw/config_power_domain.c | 75 ++--- product/n1sdp/scp_ramfw/config_power_domain.h | 4 + .../rddaniel/include/config_power_domain.h | 20 +- .../rddaniel/scp_ramfw/config_power_domain.c | 289 +++--------------- .../rddanielxlr/include/config_power_domain.h | 4 +- .../scp_ramfw/config_power_domain.c | 44 ++- .../rdn1e1/scp_ramfw/config_power_domain.c | 44 +-- .../rdn1e1/scp_ramfw/config_power_domain.h | 3 +- product/sgi575/scp_ramfw/config_clock.c | 4 +- .../sgi575/scp_ramfw/config_power_domain.c | 99 +++--- .../sgi575/scp_ramfw/config_power_domain.h | 5 +- product/sgi575/scp_ramfw/config_ppu_v1.c | 2 +- product/sgi575/scp_ramfw/config_smt.c | 4 +- product/sgm775/scp_ramfw/config_clock.c | 2 +- .../sgm775/scp_ramfw/config_power_domain.c | 73 ++--- .../sgm775/scp_ramfw/config_power_domain.h | 5 +- product/sgm775/scp_ramfw/config_ppu_v1.c | 2 +- product/sgm775/scp_ramfw/config_smt.c | 2 +- product/sgm776/scp_ramfw/config_clock.c | 2 +- .../sgm776/scp_ramfw/config_power_domain.c | 67 ++-- .../sgm776/scp_ramfw/config_power_domain.h | 5 +- product/sgm776/scp_ramfw/config_ppu_v1.c | 2 +- product/sgm776/scp_ramfw/config_smt.c | 2 +- .../synquacer/scp_ramfw/config_power_domain.c | 58 ++-- .../synquacer/scp_ramfw/config_power_domain.h | 3 +- product/tc0/include/config_power_domain.h | 5 +- product/tc0/scp_ramfw/config_power_domain.c | 40 +-- 31 files changed, 365 insertions(+), 869 deletions(-) diff --git a/module/power_domain/include/mod_power_domain.h b/module/power_domain/include/mod_power_domain.h index e43a1c73e..13daf8c00 100644 --- a/module/power_domain/include/mod_power_domain.h +++ b/module/power_domain/include/mod_power_domain.h @@ -91,58 +91,6 @@ enum mod_pd_level { MOD_PD_LEVEL_COUNT }; -/*! - * \brief Number of bits used for each level within a power domain tree - * position. - */ -#define MOD_PD_TREE_POS_BITS_PER_LEVEL 8 - -/*! - * \brief Shifts for the power level fields within a power domain tree position. - */ -enum { - /*! Number of bits to shift for the power level 0 field. */ - MOD_PD_TREE_POS_LEVEL_0_SHIFT = - MOD_PD_LEVEL_0 * MOD_PD_TREE_POS_BITS_PER_LEVEL, - /*! Number of bits to shift for the power level 1 field. */ - MOD_PD_TREE_POS_LEVEL_1_SHIFT = - MOD_PD_LEVEL_1 * MOD_PD_TREE_POS_BITS_PER_LEVEL, - /*! Number of bits to shift for the power level 2 field. */ - MOD_PD_TREE_POS_LEVEL_2_SHIFT = - MOD_PD_LEVEL_2 * MOD_PD_TREE_POS_BITS_PER_LEVEL, - /*! Number of bits to shift for the power level 3 field. */ - MOD_PD_TREE_POS_LEVEL_3_SHIFT = - MOD_PD_LEVEL_3 * MOD_PD_TREE_POS_BITS_PER_LEVEL, - MOD_PD_TREE_POS_LEVEL_SHIFT = - MOD_PD_LEVEL_COUNT * MOD_PD_TREE_POS_BITS_PER_LEVEL, -}; - -/*! - * \brief Mask for the power level fields within a power domain tree position. - */ -#define MOD_PD_TREE_POS_LEVEL_MASK UINT64_C(0xFF) - -/*! - * \brief Build the power domain tree position of a power domain. - */ -#define MOD_PD_TREE_POS(LEVEL, LEVEL_3, LEVEL_2, LEVEL_1, LEVEL_0) \ - ((((uint64_t)((LEVEL) & MOD_PD_TREE_POS_LEVEL_MASK)) << \ - MOD_PD_TREE_POS_LEVEL_SHIFT) | \ - (((uint64_t)((LEVEL_3) & MOD_PD_TREE_POS_LEVEL_MASK)) << \ - MOD_PD_TREE_POS_LEVEL_3_SHIFT) | \ - (((uint64_t)((LEVEL_2) & MOD_PD_TREE_POS_LEVEL_MASK)) << \ - MOD_PD_TREE_POS_LEVEL_2_SHIFT) | \ - (((uint64_t)((LEVEL_1) & MOD_PD_TREE_POS_LEVEL_MASK)) << \ - MOD_PD_TREE_POS_LEVEL_1_SHIFT) | \ - (((uint64_t)((LEVEL_0) & MOD_PD_TREE_POS_LEVEL_MASK)) << \ - MOD_PD_TREE_POS_LEVEL_0_SHIFT)) - -/*! - * \brief Representation of the invalid tree position. Used when checking that - * power domains are declared in increasing order of their tree position. - */ -#define MOD_PD_INVALID_TREE_POS MOD_PD_TREE_POS(MOD_PD_LEVEL_COUNT, 0, 0, 0, 0) - /*! * \brief Power domain module configuration. */ @@ -176,37 +124,9 @@ struct mod_power_domain_config { */ struct mod_power_domain_element_config { /*! - * \brief Defines the position of the power domain within the power domain - * tree. - * - * \details Each child of a power domain is assigned a number ranging from 0 - * to 255. Compute the position of a power domain from the position of - * its parent 'parent_pos' (the number assigned to the power domain as - * a child of its parent is 'child_pos') as follows: - * - * tree_pos = (parent_pos - (1 << MOD_PD_TREE_POS_LEVEL_SHIFT)) + - * (child_pos << (8*pd_level)) - * - * The position of the top-level domain is defined as: - * (level of the top-level domain) << MOD_PD_TREE_POS_LEVEL_SHIFT - * - * If the power domain hierarchy maps to the core hierarchy (based on - * MPIDR levels of affinity), derive the position of the core power - * domains from the Aff0, Aff1, Aff2 and Aff3 fields of the MPIDR - * registers of the cores as follows: - * - * core power domain position = (Aff3 << MOD_PD_TREE_LEVEL_3_SHIFT) + - * (Aff2 << MOD_PD_TREE_LEVEL_2_SHIFT) + - * (Aff1 << MOD_PD_TREE_LEVEL_1_SHIFT) + - * (Aff0 << MOD_PD_TREE_LEVEL_0_SHIFT) - * - * In the module configuration data, the power domains have to be in - * increasing order of their power domain position. Thus, the power - * domains with the lowest power level have to be first and the system - * power domain has to be last. This table must contain at least one - * element, the system power domain. + * brief Power domain parent index */ - uint64_t tree_pos; + uint32_t parent_idx; /*! * Identifier of the module or element providing the driver for the power diff --git a/module/power_domain/src/mod_power_domain.c b/module/power_domain/src/mod_power_domain.c index 816a32add..ae68a732b 100644 --- a/module/power_domain/src/mod_power_domain.c +++ b/module/power_domain/src/mod_power_domain.c @@ -127,16 +127,14 @@ struct pd_ctx { struct pd_ctx *parent; /* - * Pointer to the context of the power domain's first child. This - * field is equal to NULL if the power domain does not have any children. + * List if all power domain children if any. */ - struct pd_ctx *first_child; + struct fwk_slist children_list; /* - * Pointer to the context of the power domain sibling in the chain of the - * children power domains of their parent. + * Node in the parent list if not the root */ - struct pd_ctx *sibling; + struct fwk_slist_node child_node; /* Requested power state for the power domain */ unsigned int requested_state; @@ -305,72 +303,6 @@ static const char * const default_state_name_table[] = { * Utility functions */ -/* Functions related to power domain positions in the power domain tree */ -static bool is_valid_tree_pos(uint64_t tree_pos) -{ - return (tree_pos < MOD_PD_TREE_POS(MOD_PD_LEVEL_COUNT, 0, 0, 0, 0)); -} - -static enum mod_pd_level get_level_from_tree_pos(uint64_t tree_pos) -{ - return (enum mod_pd_level)((tree_pos >> MOD_PD_TREE_POS_LEVEL_SHIFT) & - MOD_PD_TREE_POS_LEVEL_MASK); -} - -static uint64_t compute_parent_tree_pos_from_tree_pos(uint64_t tree_pos) -{ - unsigned int parent_level; - uint64_t tree_pos_mask; - uint64_t parent_tree_pos; - - parent_level = get_level_from_tree_pos(tree_pos) + 1; - - /* - * Create a mask of bits for levels strictly lower than 'parent_level'. We - * use this mask below for clearing off in 'tree_pos' the levels strictly - * lower than 'parent_level'. - */ - tree_pos_mask = (UINT64_C(1) << - (parent_level * MOD_PD_TREE_POS_BITS_PER_LEVEL)) - 1; - - parent_tree_pos = (tree_pos & (~tree_pos_mask)) + - (UINT64_C(1) << MOD_PD_TREE_POS_LEVEL_SHIFT); - - return parent_tree_pos; -} - -/* - * Get a pointer to the descriptor of a power domain given its position in the - * power domain tree. - * - * \param tree_pos The power domain position in the power domain tree. - * - * \retval NULL The tree position of the power domain is invalid. - * \return Pointer to the descriptor of the power domain. - */ -static struct pd_ctx *get_ctx_from_tree_pos(uint64_t tree_pos) -{ - unsigned int min_idx = 0; - unsigned int max_idx_plus_one = mod_pd_ctx.pd_count; - unsigned int middle_idx; - struct pd_ctx *pd; - - while (min_idx < max_idx_plus_one) { - middle_idx = (min_idx + max_idx_plus_one) / 2; - pd = &mod_pd_ctx.pd_ctx_table[middle_idx]; - if (pd->config->tree_pos == tree_pos) - return pd; - else { - if (pd->config->tree_pos > tree_pos) - max_idx_plus_one = middle_idx; - else - min_idx = middle_idx + 1; - } - } - - return NULL; -} - /* State related utility functions */ static bool is_valid_state(const struct pd_ctx *pd, unsigned int state) { @@ -416,9 +348,11 @@ static bool is_allowed_by_child(const struct pd_ctx *child, static bool is_allowed_by_children(const struct pd_ctx *pd, unsigned int state) { - const struct pd_ctx *child; + const struct pd_ctx *child = NULL; + struct fwk_slist *c_node = NULL; - for (child = pd->first_child; child != NULL; child = child->sibling) { + FWK_LIST_FOR_EACH(&pd->children_list, c_node, struct pd_ctx, child_node, + child) { if (!is_allowed_by_child(child, state, child->requested_state)) return false; } @@ -514,20 +448,18 @@ static bool is_valid_composite_state(struct pd_ctx *target_pd, assert(target_pd != NULL); - level = get_level_from_tree_pos(pd->config->tree_pos); - highest_level = get_highest_level_from_composite_state(pd, composite_state); - - if ((highest_level < level) || - (highest_level >= MOD_PD_LEVEL_COUNT)) - goto error; - if (!pd->cs_support) goto error; + highest_level = get_highest_level_from_composite_state(pd, composite_state); + state_mask_table = pd->composite_state_mask_table; table_size = pd->composite_state_mask_table_size; - for (; level <= highest_level && level < (table_size) ; level++) { + if (highest_level >= table_size) + goto error; + + for (level = 0; level <= highest_level; level++) { if (pd == NULL) goto error; @@ -567,21 +499,20 @@ error: static bool is_upwards_transition_propagation(const struct pd_ctx *lowest_pd, uint32_t composite_state) { - int lowest_level, highest_level, level; + int highest_level, level; const struct pd_ctx *pd; unsigned int state; const uint32_t *state_mask_table; - lowest_level = get_level_from_tree_pos(lowest_pd->config->tree_pos); highest_level = get_highest_level_from_composite_state(lowest_pd, composite_state); if (!lowest_pd->cs_support) return is_deeper_state(composite_state, lowest_pd->requested_state); - state_mask_table = lowest_pd->allowed_state_mask_table; + state_mask_table = lowest_pd->composite_state_mask_table; - for (level = lowest_level, pd = lowest_pd; level <= highest_level; + for (level = 0, pd = lowest_pd; (level <= highest_level) && (pd != NULL); level++, pd = pd->parent) { state = get_level_state_from_composite_state(state_mask_table, @@ -596,54 +527,22 @@ static bool is_upwards_transition_propagation(const struct pd_ctx *lowest_pd, } /* Sub-routine of 'pd_post_init()', to build the power domain tree */ -static int build_pd_tree(void) +static int connect_pd_tree(void) { unsigned int index; - struct pd_ctx *pd; - uint64_t tree_pos; - uint64_t parent_tree_pos; - uint64_t last_parent_tree_pos; - struct pd_ctx *parent = NULL; - struct pd_ctx *child; - struct pd_ctx *prev_sibling; - - last_parent_tree_pos = 0; /* Impossible value for a parent position */ + struct pd_ctx *pd, *parent; + for (index = 0; index < mod_pd_ctx.pd_count; index++) { pd = &mod_pd_ctx.pd_ctx_table[index]; - tree_pos = pd->config->tree_pos; - parent_tree_pos = compute_parent_tree_pos_from_tree_pos(tree_pos); - if (parent_tree_pos != last_parent_tree_pos) { - parent = get_ctx_from_tree_pos(parent_tree_pos); - last_parent_tree_pos = parent_tree_pos; - } - pd->parent = parent; - - if (parent == NULL) { - if (index == (mod_pd_ctx.pd_count - 1)) - break; - else - return FWK_E_PARAM; - } - - /* - * Update the list of children of the power domain parent. The children - * are in increasing order of their identifier in the chain of children. - */ - child = parent->first_child; - prev_sibling = NULL; - - while ((child != NULL) && (child->config->tree_pos < tree_pos)) { - prev_sibling = child; - child = child->sibling; + if (pd->config->parent_idx >= mod_pd_ctx.pd_count) { + pd->parent = NULL; + continue; } - if (prev_sibling == NULL) { - pd->sibling = parent->first_child; - parent->first_child = pd; - } else { - pd->sibling = prev_sibling->sibling; - prev_sibling->sibling = pd; - } + parent = pd->parent = &mod_pd_ctx.pd_ctx_table[pd->config->parent_idx]; + if (parent == NULL) + return FWK_E_DATA; + fwk_list_push_tail(&parent->children_list, &pd->child_node); } return FWK_SUCCESS; @@ -660,7 +559,8 @@ static int build_pd_tree(void) static bool is_allowed_by_parent_and_children(struct pd_ctx *pd, unsigned int state) { - struct pd_ctx *parent, *child; + struct pd_ctx *parent, *child = NULL; + struct fwk_slist *c_node = NULL; parent = pd->parent; if (parent != NULL) { @@ -668,11 +568,10 @@ static bool is_allowed_by_parent_and_children(struct pd_ctx *pd, return false; } - child = pd->first_child; - while (child != NULL) { + FWK_LIST_FOR_EACH(&pd->children_list, c_node, struct pd_ctx, child_node, + child) { if (!is_allowed_by_child(child, state, child->current_state)) return false; - child = child->sibling; } return true; @@ -865,10 +764,10 @@ static void process_set_state_request( * 'highest_level >= lowest_level' and 'highest_level' is lower * than the highest power level. */ - lowest_level = get_level_from_tree_pos(lowest_pd->config->tree_pos); + lowest_level = 0; highest_level = get_highest_level_from_composite_state(lowest_pd, composite_state); - nb_pds = highest_level - lowest_level + 1; + nb_pds = highest_level + 1; status = FWK_SUCCESS; pd = lowest_pd; @@ -879,7 +778,7 @@ static void process_set_state_request( for (pd_index = 0; pd_index < nb_pds; pd_index++, pd = pd->parent) { if (up) - level = lowest_level + pd_index; + level = pd_index; else { /* * When walking down the power domain tree, get the context of the @@ -1023,7 +922,7 @@ static int complete_system_suspend(struct pd_ctx *target_pd) * to build the composite state with MOD_PD_STATE_OFF power state for all * levels but the last one. */ - level = get_level_from_tree_pos(target_pd->config->tree_pos); + level = 0; do { shift = number_of_bits_to_shift(state_mask_table[level]); composite_state |= ((pd->parent != NULL) ? MOD_PD_STATE_OFF : @@ -1059,7 +958,7 @@ static void process_get_state_request(struct pd_ctx *pd, const struct pd_get_state_request *req_params, struct pd_get_state_response *resp_params) { - enum mod_pd_level level = get_level_from_tree_pos(pd->config->tree_pos); + enum mod_pd_level level = 0; unsigned int composite_state = 0; uint32_t shift; const uint32_t *state_mask_table; @@ -1109,18 +1008,19 @@ static void process_reset_request(struct pd_ctx *pd, struct pd_response *resp_params) { int status; - struct pd_ctx *child; + struct pd_ctx *child = NULL; + struct fwk_slist *c_node = NULL; status = FWK_E_PWRSTATE; if (pd->requested_state == MOD_PD_STATE_OFF) goto exit; - child = pd->first_child; - while (child != NULL) { + + FWK_LIST_FOR_EACH(&pd->children_list, c_node, struct pd_ctx, child_node, + child) { if ((child->requested_state != MOD_PD_STATE_OFF) || (child->current_state != MOD_PD_STATE_OFF)) goto exit; - child = child->sibling; } status = pd->driver_api->reset(pd->driver_id); @@ -1165,10 +1065,12 @@ static void process_power_state_transition_report_deeper_state( static void process_power_state_transition_report_shallower_state( struct pd_ctx *pd) { - struct pd_ctx *child; + struct pd_ctx *child = NULL; unsigned int requested_state; + struct fwk_slist *c_node = NULL; - for (child = pd->first_child; child != NULL; child = child->sibling) { + FWK_LIST_FOR_EACH(&pd->children_list, c_node, struct pd_ctx, child_node, + child) { requested_state = child->requested_state; if (child->state_requested_to_driver == requested_state) continue; @@ -1756,8 +1658,6 @@ static int pd_init(fwk_id_t module_id, unsigned int dev_count, static int pd_power_domain_init(fwk_id_t pd_id, unsigned int unused, const void *config) { - static uint64_t max_tree_pos = MOD_PD_INVALID_TREE_POS; - const struct mod_power_domain_element_config *pd_config = (const struct mod_power_domain_element_config *)config; struct pd_ctx *pd; @@ -1765,22 +1665,12 @@ static int pd_power_domain_init(fwk_id_t pd_id, unsigned int unused, pd = &mod_pd_ctx.pd_ctx_table[fwk_id_get_element_idx(pd_id)]; - if (!is_valid_tree_pos(pd_config->tree_pos)) - return FWK_E_PARAM; + fwk_list_init(&pd->children_list); if (pd_config->attributes.pd_type >= MOD_PD_TYPE_COUNT) return FWK_E_PARAM; - /* - * Check that the power domains are declared by increasing order of their - * tree position. - */ - if ((max_tree_pos != MOD_PD_INVALID_TREE_POS) && - (pd_config->tree_pos <= max_tree_pos)) - return FWK_E_PARAM; - max_tree_pos = pd_config->tree_pos; - if ((pd_config->allowed_state_mask_table == NULL) || (pd_config->allowed_state_mask_table_size == 0)) return FWK_E_PARAM; @@ -1827,7 +1717,7 @@ static int pd_post_init(fwk_id_t module_id) { int status; - status = build_pd_tree(); + status = connect_pd_tree(); if (status != FWK_SUCCESS) return status; diff --git a/product/juno/scp_ramfw/config_power_domain.c b/product/juno/scp_ramfw/config_power_domain.c index 291a27124..af2bc650d 100644 --- a/product/juno/scp_ramfw/config_power_domain.c +++ b/product/juno/scp_ramfw/config_power_domain.c @@ -74,12 +74,7 @@ static struct fwk_element element_table[] = { .name = "BIG_CPU0", .data = &(struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CORE, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_0, - 0, - 0, - TREE_IDX_SYSTOP_CHILD_BIG, - TREE_IDX_CLUSTER_CHILD_CPU0), + .parent_idx = POWER_DOMAIN_IDX_BIG_SSTOP, .driver_id = FWK_ID_ELEMENT_INIT( FWK_MODULE_IDX_JUNO_PPU, JUNO_PPU_DEV_IDX_BIG_CPU0), @@ -95,12 +90,7 @@ static struct fwk_element element_table[] = { .name = "BIG_CPU1", .data = &(struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CORE, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_0, - 0, - 0, - TREE_IDX_SYSTOP_CHILD_BIG, - TREE_IDX_CLUSTER_CHILD_CPU1), + .parent_idx = POWER_DOMAIN_IDX_BIG_SSTOP, .driver_id = FWK_ID_ELEMENT_INIT( FWK_MODULE_IDX_JUNO_PPU, JUNO_PPU_DEV_IDX_BIG_CPU1), @@ -116,12 +106,7 @@ static struct fwk_element element_table[] = { .name = "LITTLE_CPU0", .data = &(struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CORE, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_0, - 0, - 0, - TREE_IDX_SYSTOP_CHILD_LITTLE, - TREE_IDX_CLUSTER_CHILD_CPU0), + .parent_idx = POWER_DOMAIN_IDX_LITTLE_SSTOP, .driver_id = FWK_ID_ELEMENT_INIT( FWK_MODULE_IDX_JUNO_PPU, JUNO_PPU_DEV_IDX_LITTLE_CPU0), @@ -137,12 +122,7 @@ static struct fwk_element element_table[] = { .name = "LITTLE_CPU1", .data = &(struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CORE, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_0, - 0, - 0, - TREE_IDX_SYSTOP_CHILD_LITTLE, - TREE_IDX_CLUSTER_CHILD_CPU1), + .parent_idx = POWER_DOMAIN_IDX_LITTLE_SSTOP, .driver_id = FWK_ID_ELEMENT_INIT( FWK_MODULE_IDX_JUNO_PPU, JUNO_PPU_DEV_IDX_LITTLE_CPU1), @@ -158,12 +138,7 @@ static struct fwk_element element_table[] = { .name = "LITTLE_CPU2", .data = &(struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CORE, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_0, - 0, - 0, - TREE_IDX_SYSTOP_CHILD_LITTLE, - TREE_IDX_CLUSTER_CHILD_CPU2), + .parent_idx = POWER_DOMAIN_IDX_LITTLE_SSTOP, .driver_id = FWK_ID_ELEMENT_INIT( FWK_MODULE_IDX_JUNO_PPU, JUNO_PPU_DEV_IDX_LITTLE_CPU2), @@ -179,12 +154,7 @@ static struct fwk_element element_table[] = { .name = "LITTLE_CPU3", .data = &(struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CORE, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_0, - 0, - 0, - TREE_IDX_SYSTOP_CHILD_LITTLE, - TREE_IDX_CLUSTER_CHILD_CPU3), + .parent_idx = POWER_DOMAIN_IDX_LITTLE_SSTOP, .driver_id = FWK_ID_ELEMENT_INIT( FWK_MODULE_IDX_JUNO_PPU, JUNO_PPU_DEV_IDX_LITTLE_CPU3), @@ -200,12 +170,7 @@ static struct fwk_element element_table[] = { .name = "BIG_SSTOP", .data = &(struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, - 0, - 0, - TREE_IDX_SYSTOP_CHILD_BIG, - 0), + .parent_idx = POWER_DOMAIN_IDX_SYSTOP, .driver_id = FWK_ID_ELEMENT_INIT( FWK_MODULE_IDX_JUNO_PPU, JUNO_PPU_DEV_IDX_BIG_SSTOP), @@ -221,12 +186,7 @@ static struct fwk_element element_table[] = { .name = "LITTLE_SSTOP", .data = &(struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, - 0, - 0, - TREE_IDX_SYSTOP_CHILD_LITTLE, - 0), + .parent_idx = POWER_DOMAIN_IDX_SYSTOP, .driver_id = FWK_ID_ELEMENT_INIT( FWK_MODULE_IDX_JUNO_PPU, JUNO_PPU_DEV_IDX_LITTLE_SSTOP), @@ -242,12 +202,7 @@ static struct fwk_element element_table[] = { .name = "GPUTOP", .data = &(struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_DEVICE, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, - 0, - 0, - TREE_IDX_SYSTOP_CHILD_GPU, - 0), + .parent_idx = POWER_DOMAIN_IDX_SYSTOP, .driver_id = FWK_ID_ELEMENT_INIT( FWK_MODULE_IDX_JUNO_PPU, JUNO_PPU_DEV_IDX_GPUTOP), @@ -263,12 +218,7 @@ static struct fwk_element element_table[] = { .name = "DBGSYS", .data = &(struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_DEVICE_DEBUG, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, - 0, - 0, - TREE_IDX_SYSTOP_CHILD_DBG, - 0), + .parent_idx = POWER_DOMAIN_IDX_SYSTOP, .driver_id = FWK_ID_ELEMENT_INIT( FWK_MODULE_IDX_JUNO_PPU, JUNO_PPU_DEV_IDX_DBGSYS), @@ -284,12 +234,7 @@ static struct fwk_element element_table[] = { .name = "SYSTOP", .data = &(struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_SYSTEM, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_2, - 0, - 0, - 0, - 0), + .parent_idx = POWER_DOMAIN_IDX_NONE, .driver_id = FWK_ID_MODULE_INIT(FWK_MODULE_IDX_SYSTEM_POWER), .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_SYSTEM_POWER, MOD_SYSTEM_POWER_API_IDX_PD_DRIVER), diff --git a/product/juno/scp_ramfw/config_power_domain.h b/product/juno/scp_ramfw/config_power_domain.h index 7ef130fc5..80875818b 100644 --- a/product/juno/scp_ramfw/config_power_domain.h +++ b/product/juno/scp_ramfw/config_power_domain.h @@ -8,6 +8,8 @@ #ifndef CONFIG_POWER_DOMAIN_H #define CONFIG_POWER_DOMAIN_H +#include + /* * Power domain element indexes defined in increasing order of power domain * level. @@ -33,6 +35,8 @@ enum power_domain_idx { /* Number of defined elements */ POWER_DOMAIN_IDX_COUNT, + + POWER_DOMAIN_IDX_NONE = UINT32_MAX }; #endif /* CONFIG_POWER_DOMAIN_H */ diff --git a/product/n1sdp/scp_ramfw/config_power_domain.c b/product/n1sdp/scp_ramfw/config_power_domain.c index 21aa763d9..a0eb552de 100644 --- a/product/n1sdp/scp_ramfw/config_power_domain.c +++ b/product/n1sdp/scp_ramfw/config_power_domain.c @@ -117,8 +117,7 @@ static struct fwk_element n1sdp_pd_single_chip_element_table[] = { .name = "CLUS0CORE0", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CORE, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_0, 0, 0, 0, 0), + .parent_idx = PD_SINGLE_CHIP_IDX_CLUSTER0, .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PPU_V1, 0), .api_id = FWK_ID_API_INIT( FWK_MODULE_IDX_PPU_V1, @@ -132,8 +131,7 @@ static struct fwk_element n1sdp_pd_single_chip_element_table[] = { .name = "CLUS0CORE1", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CORE, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_0, 0, 0, 0, 1), + .parent_idx = PD_SINGLE_CHIP_IDX_CLUSTER0, .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PPU_V1, 1), .api_id = FWK_ID_API_INIT( FWK_MODULE_IDX_PPU_V1, @@ -147,8 +145,7 @@ static struct fwk_element n1sdp_pd_single_chip_element_table[] = { .name = "CLUS1CORE0", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CORE, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_0, 0, 0, 1, 0), + .parent_idx = PD_SINGLE_CHIP_IDX_CLUSTER1, .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PPU_V1, 2), .api_id = FWK_ID_API_INIT( FWK_MODULE_IDX_PPU_V1, @@ -162,8 +159,7 @@ static struct fwk_element n1sdp_pd_single_chip_element_table[] = { .name = "CLUS1CORE1", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CORE, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_0, 0, 0, 1, 1), + .parent_idx = PD_SINGLE_CHIP_IDX_CLUSTER1, .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PPU_V1, 3), .api_id = FWK_ID_API_INIT( FWK_MODULE_IDX_PPU_V1, @@ -177,8 +173,7 @@ static struct fwk_element n1sdp_pd_single_chip_element_table[] = { .name = "CLUS0", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, 0, 0), + .parent_idx = PD_SINGLE_CHIP_IDX_SYSTOP0, .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PPU_V1, 4), .api_id = FWK_ID_API_INIT( FWK_MODULE_IDX_PPU_V1, @@ -192,8 +187,7 @@ static struct fwk_element n1sdp_pd_single_chip_element_table[] = { .name = "CLUS1", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, 1, 0), + .parent_idx = PD_SINGLE_CHIP_IDX_SYSTOP0, .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PPU_V1, 5), .api_id = FWK_ID_API_INIT( FWK_MODULE_IDX_PPU_V1, @@ -207,8 +201,7 @@ static struct fwk_element n1sdp_pd_single_chip_element_table[] = { .name = "DBGTOP0", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_DEVICE_DEBUG, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, 2, 0), + .parent_idx = PD_SINGLE_CHIP_IDX_SYSTOP0, .driver_id = FWK_ID_ELEMENT_INIT( FWK_MODULE_IDX_PPU_V0, PPU_V0_ELEMENT_IDX_DBGTOP), .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_PPU_V0, 0), @@ -221,8 +214,7 @@ static struct fwk_element n1sdp_pd_single_chip_element_table[] = { .name = "SYSTOP0", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_SYSTEM, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_2, 0, 0, 0, 0), + .parent_idx = PD_SINGLE_CHIP_IDX_NONE, .driver_id = FWK_ID_MODULE_INIT(FWK_MODULE_IDX_SYSTEM_POWER), .api_id = FWK_ID_API_INIT( FWK_MODULE_IDX_SYSTEM_POWER, @@ -240,8 +232,7 @@ static struct fwk_element n1sdp_pd_multi_chip_element_table[] = { .name = "CLUS0CORE0", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CORE, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_0, 0, 0, 0, 0), + .parent_idx = PD_MULTI_CHIP_IDX_CLUSTER0, .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PPU_V1, 0), .api_id = FWK_ID_API_INIT( FWK_MODULE_IDX_PPU_V1, @@ -255,8 +246,7 @@ static struct fwk_element n1sdp_pd_multi_chip_element_table[] = { .name = "CLUS0CORE1", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CORE, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_0, 0, 0, 0, 1), + .parent_idx = PD_MULTI_CHIP_IDX_CLUSTER0, .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PPU_V1, 1), .api_id = FWK_ID_API_INIT( FWK_MODULE_IDX_PPU_V1, @@ -270,8 +260,7 @@ static struct fwk_element n1sdp_pd_multi_chip_element_table[] = { .name = "CLUS1CORE0", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CORE, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_0, 0, 0, 1, 0), + .parent_idx = PD_MULTI_CHIP_IDX_CLUSTER1, .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PPU_V1, 2), .api_id = FWK_ID_API_INIT( FWK_MODULE_IDX_PPU_V1, @@ -285,8 +274,7 @@ static struct fwk_element n1sdp_pd_multi_chip_element_table[] = { .name = "CLUS1CORE1", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CORE, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_0, 0, 0, 1, 1), + .parent_idx = PD_MULTI_CHIP_IDX_CLUSTER1, .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PPU_V1, 3), .api_id = FWK_ID_API_INIT( FWK_MODULE_IDX_PPU_V1, @@ -300,8 +288,7 @@ static struct fwk_element n1sdp_pd_multi_chip_element_table[] = { .name = "SLV-CLUS0CORE0", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CORE, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_0, 0, 1, 0, 0), + .parent_idx = PD_MULTI_CHIP_IDX_CLUSTER2, .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_N1SDP_REMOTE_PD, 0), .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_N1SDP_REMOTE_PD, @@ -315,8 +302,7 @@ static struct fwk_element n1sdp_pd_multi_chip_element_table[] = { .name = "SLV-CLUS0CORE1", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CORE, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_0, 0, 1, 0, 1), + .parent_idx = PD_MULTI_CHIP_IDX_CLUSTER2, .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_N1SDP_REMOTE_PD, 1), .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_N1SDP_REMOTE_PD, @@ -330,8 +316,7 @@ static struct fwk_element n1sdp_pd_multi_chip_element_table[] = { .name = "SLV-CLUS1CORE0", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CORE, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_0, 0, 1, 1, 0), + .parent_idx = PD_MULTI_CHIP_IDX_CLUSTER3, .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_N1SDP_REMOTE_PD, 2), .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_N1SDP_REMOTE_PD, @@ -345,8 +330,7 @@ static struct fwk_element n1sdp_pd_multi_chip_element_table[] = { .name = "SLV-CLUS1CORE1", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CORE, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_0, 0, 1, 1, 1), + .parent_idx = PD_MULTI_CHIP_IDX_CLUSTER3, .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_N1SDP_REMOTE_PD, 3), .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_N1SDP_REMOTE_PD, @@ -360,8 +344,7 @@ static struct fwk_element n1sdp_pd_multi_chip_element_table[] = { .name = "CLUS0", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, 0, 0), + .parent_idx = PD_MULTI_CHIP_IDX_SYSTOP0, .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PPU_V1, 4), .api_id = FWK_ID_API_INIT( FWK_MODULE_IDX_PPU_V1, @@ -375,8 +358,7 @@ static struct fwk_element n1sdp_pd_multi_chip_element_table[] = { .name = "CLUS1", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, 1, 0), + .parent_idx = PD_MULTI_CHIP_IDX_SYSTOP0, .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PPU_V1, 5), .api_id = FWK_ID_API_INIT( FWK_MODULE_IDX_PPU_V1, @@ -390,8 +372,7 @@ static struct fwk_element n1sdp_pd_multi_chip_element_table[] = { .name = "DBGTOP", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_DEVICE_DEBUG, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, 2, 0), + .parent_idx = PD_MULTI_CHIP_IDX_SYSTOP0, .driver_id = FWK_ID_ELEMENT_INIT( FWK_MODULE_IDX_PPU_V0, PPU_V0_ELEMENT_IDX_DBGTOP), .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_PPU_V0, 0), @@ -404,8 +385,7 @@ static struct fwk_element n1sdp_pd_multi_chip_element_table[] = { .name = "SLV-CLUS0", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 1, 0, 0), + .parent_idx = PD_MULTI_CHIP_IDX_SYSTOP1, .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_N1SDP_REMOTE_PD, 4), .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_N1SDP_REMOTE_PD, @@ -419,8 +399,7 @@ static struct fwk_element n1sdp_pd_multi_chip_element_table[] = { .name = "SLV-CLUS1", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 1, 1, 0), + .parent_idx = PD_MULTI_CHIP_IDX_SYSTOP1, .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_N1SDP_REMOTE_PD, 5), .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_N1SDP_REMOTE_PD, @@ -434,8 +413,7 @@ static struct fwk_element n1sdp_pd_multi_chip_element_table[] = { .name = "SLV-DBGTOP", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_DEVICE_DEBUG, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 1, 2, 0), + .parent_idx = PD_MULTI_CHIP_IDX_SYSTOP1, .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_N1SDP_REMOTE_PD, 6), .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_N1SDP_REMOTE_PD, @@ -449,8 +427,7 @@ static struct fwk_element n1sdp_pd_multi_chip_element_table[] = { .name = "SYSTOP0", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_SYSTEM, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_2, 0, 0, 0, 0), + .parent_idx = PD_MULTI_CHIP_IDX_SYSTOP_LOGICAL, .driver_id = FWK_ID_MODULE_INIT(FWK_MODULE_IDX_SYSTEM_POWER), .api_id = FWK_ID_API_INIT( FWK_MODULE_IDX_SYSTEM_POWER, @@ -464,8 +441,7 @@ static struct fwk_element n1sdp_pd_multi_chip_element_table[] = { .name = "SLV-SYSTOP", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_SYSTEM, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_2, 0, 1, 0, 0), + .parent_idx = PD_MULTI_CHIP_IDX_SYSTOP_LOGICAL, .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_N1SDP_REMOTE_PD, 7), .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_N1SDP_REMOTE_PD, @@ -479,8 +455,7 @@ static struct fwk_element n1sdp_pd_multi_chip_element_table[] = { .name = "SYSTOP-LOGICAL", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_SYSTEM, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_3, 0, 0, 0, 0), + .parent_idx = PD_MULTI_CHIP_IDX_NONE, .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_N1SDP_REMOTE_PD, 8), .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_N1SDP_REMOTE_PD, diff --git a/product/n1sdp/scp_ramfw/config_power_domain.h b/product/n1sdp/scp_ramfw/config_power_domain.h index 8d24c56ae..cf3948200 100644 --- a/product/n1sdp/scp_ramfw/config_power_domain.h +++ b/product/n1sdp/scp_ramfw/config_power_domain.h @@ -8,6 +8,8 @@ #ifndef CONFIG_POWER_DOMAIN_H #define CONFIG_POWER_DOMAIN_H +#include + /* * Total supported chips in multichip use case */ @@ -26,6 +28,7 @@ enum pd_single_chip_idx { PD_SINGLE_CHIP_IDX_DBGTOP0, PD_SINGLE_CHIP_IDX_SYSTOP0, PD_SINGLE_CHIP_IDX_COUNT, + PD_SINGLE_CHIP_IDX_NONE = UINT32_MAX }; /* @@ -54,6 +57,7 @@ enum pd_multi_chip_idx { /* PD Level 3 */ PD_MULTI_CHIP_IDX_SYSTOP_LOGICAL, PD_MULTI_CHIP_IDX_COUNT, + PD_MULTI_CHIP_IDX_NONE = UINT32_MAX }; #endif /* CONFIG_POWER_DOMAIN_H */ diff --git a/product/rddaniel/include/config_power_domain.h b/product/rddaniel/include/config_power_domain.h index 4cdfd64b8..f41666896 100644 --- a/product/rddaniel/include/config_power_domain.h +++ b/product/rddaniel/include/config_power_domain.h @@ -8,6 +8,8 @@ #ifndef CONFIG_POWER_DOMAIN_H #define CONFIG_POWER_DOMAIN_H +#include + /* * Power domain indices for the statically defined domains used for: * - Indexing the domains in the rddaniel_power_domain_static_element_table @@ -17,24 +19,8 @@ * core_count + pd_static_dev_idx */ enum pd_static_dev_idx { - PD_STATIC_DEV_IDX_CLUSTER0, - PD_STATIC_DEV_IDX_CLUSTER1, - PD_STATIC_DEV_IDX_CLUSTER2, - PD_STATIC_DEV_IDX_CLUSTER3, - PD_STATIC_DEV_IDX_CLUSTER4, - PD_STATIC_DEV_IDX_CLUSTER5, - PD_STATIC_DEV_IDX_CLUSTER6, - PD_STATIC_DEV_IDX_CLUSTER7, - PD_STATIC_DEV_IDX_CLUSTER8, - PD_STATIC_DEV_IDX_CLUSTER9, - PD_STATIC_DEV_IDX_CLUSTER10, - PD_STATIC_DEV_IDX_CLUSTER11, - PD_STATIC_DEV_IDX_CLUSTER12, - PD_STATIC_DEV_IDX_CLUSTER13, - PD_STATIC_DEV_IDX_CLUSTER14, - PD_STATIC_DEV_IDX_CLUSTER15, PD_STATIC_DEV_IDX_SYSTOP, - PD_STATIC_DEV_IDX_COUNT + PD_STATIC_DEV_IDX_NONE = UINT32_MAX }; #endif /* CONFIG_POWER_DOMAIN_H */ diff --git a/product/rddaniel/scp_ramfw/config_power_domain.c b/product/rddaniel/scp_ramfw/config_power_domain.c index b62b6eabd..c27de1561 100644 --- a/product/rddaniel/scp_ramfw/config_power_domain.c +++ b/product/rddaniel/scp_ramfw/config_power_domain.c @@ -52,236 +52,11 @@ static const struct mod_power_domain_config rddaniel_power_domain_config = { 0 }; static struct fwk_element rddaniel_power_domain_static_element_table[] = { - [PD_STATIC_DEV_IDX_CLUSTER0] = { - .name = "CLUS0", - .data = &((struct mod_power_domain_element_config) { - .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, PD_STATIC_DEV_IDX_CLUSTER0, 0), - .api_id = FWK_ID_API_INIT( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), - .allowed_state_mask_table = cluster_pd_allowed_state_mask_table, - .allowed_state_mask_table_size = - FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table) - }), - }, - [PD_STATIC_DEV_IDX_CLUSTER1] = { - .name = "CLUS1", - .data = &((struct mod_power_domain_element_config) { - .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, PD_STATIC_DEV_IDX_CLUSTER1, 0), - .api_id = FWK_ID_API_INIT( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), - .allowed_state_mask_table = cluster_pd_allowed_state_mask_table, - .allowed_state_mask_table_size = - FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table) - }), - }, - [PD_STATIC_DEV_IDX_CLUSTER2] = { - .name = "CLUS2", - .data = &((struct mod_power_domain_element_config) { - .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, PD_STATIC_DEV_IDX_CLUSTER2, 0), - .api_id = FWK_ID_API_INIT( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), - .allowed_state_mask_table = cluster_pd_allowed_state_mask_table, - .allowed_state_mask_table_size = - FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table) - }), - }, - [PD_STATIC_DEV_IDX_CLUSTER3] = { - .name = "CLUS3", - .data = &((struct mod_power_domain_element_config) { - .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, PD_STATIC_DEV_IDX_CLUSTER3, 0), - .api_id = FWK_ID_API_INIT( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), - .allowed_state_mask_table = cluster_pd_allowed_state_mask_table, - .allowed_state_mask_table_size = - FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table) - }), - }, - [PD_STATIC_DEV_IDX_CLUSTER4] = { - .name = "CLUS4", - .data = &((struct mod_power_domain_element_config) { - .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, PD_STATIC_DEV_IDX_CLUSTER4, 0), - .api_id = FWK_ID_API_INIT( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), - .allowed_state_mask_table = cluster_pd_allowed_state_mask_table, - .allowed_state_mask_table_size = - FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table) - }), - }, - [PD_STATIC_DEV_IDX_CLUSTER5] = { - .name = "CLUS5", - .data = &((struct mod_power_domain_element_config) { - .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, PD_STATIC_DEV_IDX_CLUSTER5, 0), - .api_id = FWK_ID_API_INIT( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), - .allowed_state_mask_table = cluster_pd_allowed_state_mask_table, - .allowed_state_mask_table_size = - FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table) - }), - }, - [PD_STATIC_DEV_IDX_CLUSTER6] = { - .name = "CLUS6", - .data = &((struct mod_power_domain_element_config) { - .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, PD_STATIC_DEV_IDX_CLUSTER6, 0), - .api_id = FWK_ID_API_INIT( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), - .allowed_state_mask_table = cluster_pd_allowed_state_mask_table, - .allowed_state_mask_table_size = - FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table) - }), - }, - [PD_STATIC_DEV_IDX_CLUSTER7] = { - .name = "CLUS7", - .data = &((struct mod_power_domain_element_config) { - .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, PD_STATIC_DEV_IDX_CLUSTER7, 0), - .api_id = FWK_ID_API_INIT( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), - .allowed_state_mask_table = cluster_pd_allowed_state_mask_table, - .allowed_state_mask_table_size = - FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table) - }), - }, - [PD_STATIC_DEV_IDX_CLUSTER8] = { - .name = "CLUS8", - .data = &((struct mod_power_domain_element_config) { - .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, PD_STATIC_DEV_IDX_CLUSTER8, 0), - .api_id = FWK_ID_API_INIT( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), - .allowed_state_mask_table = cluster_pd_allowed_state_mask_table, - .allowed_state_mask_table_size = - FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table) - }), - }, - [PD_STATIC_DEV_IDX_CLUSTER9] = { - .name = "CLUS9", - .data = &((struct mod_power_domain_element_config) { - .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, PD_STATIC_DEV_IDX_CLUSTER9, 0), - .api_id = FWK_ID_API_INIT( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), - .allowed_state_mask_table = cluster_pd_allowed_state_mask_table, - .allowed_state_mask_table_size = - FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table) - }), - }, - [PD_STATIC_DEV_IDX_CLUSTER10] = { - .name = "CLUS10", - .data = &((struct mod_power_domain_element_config) { - .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, PD_STATIC_DEV_IDX_CLUSTER10, 0), - .api_id = FWK_ID_API_INIT( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), - .allowed_state_mask_table = cluster_pd_allowed_state_mask_table, - .allowed_state_mask_table_size = - FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table) - }), - }, - [PD_STATIC_DEV_IDX_CLUSTER11] = { - .name = "CLUS11", - .data = &((struct mod_power_domain_element_config) { - .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, PD_STATIC_DEV_IDX_CLUSTER11, 0), - .api_id = FWK_ID_API_INIT( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), - .allowed_state_mask_table = cluster_pd_allowed_state_mask_table, - .allowed_state_mask_table_size = - FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table) - }), - }, - [PD_STATIC_DEV_IDX_CLUSTER12] = { - .name = "CLUS12", - .data = &((struct mod_power_domain_element_config) { - .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, PD_STATIC_DEV_IDX_CLUSTER12, 0), - .api_id = FWK_ID_API_INIT( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), - .allowed_state_mask_table = cluster_pd_allowed_state_mask_table, - .allowed_state_mask_table_size = - FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table) - }), - }, - [PD_STATIC_DEV_IDX_CLUSTER13] = { - .name = "CLUS13", - .data = &((struct mod_power_domain_element_config) { - .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, PD_STATIC_DEV_IDX_CLUSTER13, 0), - .api_id = FWK_ID_API_INIT( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), - .allowed_state_mask_table = cluster_pd_allowed_state_mask_table, - .allowed_state_mask_table_size = - FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table) - }), - }, - [PD_STATIC_DEV_IDX_CLUSTER14] = { - .name = "CLUS14", - .data = &((struct mod_power_domain_element_config) { - .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, PD_STATIC_DEV_IDX_CLUSTER14, 0), - .api_id = FWK_ID_API_INIT( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), - .allowed_state_mask_table = cluster_pd_allowed_state_mask_table, - .allowed_state_mask_table_size = - FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table) - }), - }, - [PD_STATIC_DEV_IDX_CLUSTER15] = { - .name = "CLUS15", - .data = &((struct mod_power_domain_element_config) { - .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, PD_STATIC_DEV_IDX_CLUSTER15, 0), - .api_id = FWK_ID_API_INIT( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), - .allowed_state_mask_table = cluster_pd_allowed_state_mask_table, - .allowed_state_mask_table_size = - FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table) - }), - }, [PD_STATIC_DEV_IDX_SYSTOP] = { .name = "SYSTOP", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_SYSTEM, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_2, 0, 0, 0, 0), + .parent_idx = PD_STATIC_DEV_IDX_NONE, .driver_id = FWK_ID_MODULE_INIT(FWK_MODULE_IDX_SYSTEM_POWER), .api_id = FWK_ID_API_INIT( FWK_MODULE_IDX_SYSTEM_POWER, @@ -305,27 +80,35 @@ static const struct fwk_element *rddaniel_power_domain_get_element_table unsigned int cluster_idx; unsigned int core_count; unsigned int cluster_count; - unsigned int core_element_count = 0; + unsigned int cluster_offset; + unsigned int core_element_counter = 0; + unsigned int elements_count; + unsigned int systop_idx; + const size_t config_size = sizeof(struct mod_power_domain_element_config); core_count = rddaniel_core_get_core_count(); cluster_count = rddaniel_core_get_cluster_count(); - element_table = fwk_mm_calloc( - core_count - + FWK_ARRAY_SIZE(rddaniel_power_domain_static_element_table) - + 1, /* Terminator */ - sizeof(struct fwk_element)); + elements_count = core_count + cluster_count + + FWK_ARRAY_SIZE(rddaniel_power_domain_static_element_table); + systop_idx = elements_count - 1; - pd_config_table = fwk_mm_calloc(core_count, - sizeof(struct mod_power_domain_element_config)); + cluster_offset = core_count; + + element_table = fwk_mm_calloc(elements_count + 1, /* Terminator */ + sizeof(struct fwk_element)); + if (element_table == NULL) + return NULL; + + pd_config_table = fwk_mm_calloc(core_count + cluster_count, config_size); for (cluster_idx = 0; cluster_idx < cluster_count; cluster_idx++) { for (core_idx = 0; core_idx < rddaniel_core_get_core_per_cluster_count(cluster_idx); core_idx++) { - element = &element_table[core_element_count]; - pd_config = &pd_config_table[core_element_count]; + element = &element_table[core_element_counter]; + pd_config = &pd_config_table[core_element_counter]; element->name = fwk_mm_alloc(PD_NAME_SIZE, 1); @@ -335,11 +118,9 @@ static const struct fwk_element *rddaniel_power_domain_get_element_table element->data = pd_config; pd_config->attributes.pd_type = MOD_PD_TYPE_CORE; - pd_config->tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_0, 0, 0, cluster_idx, core_idx); + pd_config->parent_idx = cluster_idx + cluster_offset; pd_config->driver_id = - FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, - core_element_count); + FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, core_element_counter); pd_config->api_id = FWK_ID_API( FWK_MODULE_IDX_PPU_V1, MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER); @@ -347,18 +128,34 @@ static const struct fwk_element *rddaniel_power_domain_get_element_table core_pd_allowed_state_mask_table; pd_config->allowed_state_mask_table_size = FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table); - core_element_count++; + core_element_counter++; } - /* Define the driver id for the cluster */ - pd_config = (struct mod_power_domain_element_config *) - rddaniel_power_domain_static_element_table[cluster_idx].data; + /* Define the cluster configuration */ + element = &element_table[cluster_idx + cluster_offset]; + pd_config = &pd_config_table[cluster_idx + cluster_offset]; + + element->name = fwk_mm_alloc(PD_NAME_SIZE, 1); + + snprintf((char *)element->name, PD_NAME_SIZE, "CLUS%u", cluster_idx); + + element->data = pd_config; + + pd_config->attributes.pd_type = MOD_PD_TYPE_CLUSTER; + pd_config->parent_idx = systop_idx; pd_config->driver_id = FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, - (core_count + cluster_idx)); + cluster_idx + cluster_offset); + pd_config->api_id = FWK_ID_API( + FWK_MODULE_IDX_PPU_V1, + MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER); + pd_config->allowed_state_mask_table = + cluster_pd_allowed_state_mask_table; + pd_config->allowed_state_mask_table_size = + FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table); } - memcpy(element_table + core_count, + memcpy(element_table + core_count + cluster_count, rddaniel_power_domain_static_element_table, sizeof(rddaniel_power_domain_static_element_table)); diff --git a/product/rddanielxlr/include/config_power_domain.h b/product/rddanielxlr/include/config_power_domain.h index 720abdb1a..4ac34231b 100644 --- a/product/rddanielxlr/include/config_power_domain.h +++ b/product/rddanielxlr/include/config_power_domain.h @@ -8,6 +8,8 @@ #ifndef CONFIG_POWER_DOMAIN_H #define CONFIG_POWER_DOMAIN_H +#include + /* * Power domain indices for the statically defined domains used for: * - Indexing the domains in the rddanielxlr_power_domain_static_element_table @@ -22,7 +24,7 @@ enum pd_static_dev_idx { PD_STATIC_DEV_IDX_CLUSTER2, PD_STATIC_DEV_IDX_CLUSTER3, PD_STATIC_DEV_IDX_SYSTOP, - PD_STATIC_DEV_IDX_COUNT + PD_STATIC_DEV_IDX_NONE = UINT32_MAX }; #endif /* CONFIG_POWER_DOMAIN_H */ diff --git a/product/rddanielxlr/scp_ramfw/config_power_domain.c b/product/rddanielxlr/scp_ramfw/config_power_domain.c index 54c68a80a..f1e9c8588 100644 --- a/product/rddanielxlr/scp_ramfw/config_power_domain.c +++ b/product/rddanielxlr/scp_ramfw/config_power_domain.c @@ -56,8 +56,6 @@ static struct fwk_element rddanielxlr_power_domain_static_element_table[] = { .name = "CLUS0", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, PD_STATIC_DEV_IDX_CLUSTER0, 0), .api_id = FWK_ID_API_INIT( FWK_MODULE_IDX_PPU_V1, MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), @@ -70,8 +68,6 @@ static struct fwk_element rddanielxlr_power_domain_static_element_table[] = { .name = "CLUS1", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, PD_STATIC_DEV_IDX_CLUSTER1, 0), .api_id = FWK_ID_API_INIT( FWK_MODULE_IDX_PPU_V1, MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), @@ -84,8 +80,6 @@ static struct fwk_element rddanielxlr_power_domain_static_element_table[] = { .name = "CLUS2", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, PD_STATIC_DEV_IDX_CLUSTER2, 0), .api_id = FWK_ID_API_INIT( FWK_MODULE_IDX_PPU_V1, MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), @@ -98,8 +92,6 @@ static struct fwk_element rddanielxlr_power_domain_static_element_table[] = { .name = "CLUS3", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, PD_STATIC_DEV_IDX_CLUSTER3, 0), .api_id = FWK_ID_API_INIT( FWK_MODULE_IDX_PPU_V1, MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), @@ -112,8 +104,7 @@ static struct fwk_element rddanielxlr_power_domain_static_element_table[] = { .name = "SYSTOP", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_SYSTEM, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_2, 0, 0, 0, 0), + .parent_idx = PD_STATIC_DEV_IDX_NONE, .driver_id = FWK_ID_MODULE_INIT(FWK_MODULE_IDX_SYSTEM_POWER), .api_id = FWK_ID_API_INIT( FWK_MODULE_IDX_SYSTEM_POWER, @@ -135,23 +126,28 @@ static const struct fwk_element *rddanielxlr_power_domain_get_element_table struct mod_power_domain_element_config *pd_config_table, *pd_config; unsigned int core_idx; unsigned int cluster_idx; + unsigned int cluster_offset = rddanielxlr_core_get_core_count(); unsigned int core_count; unsigned int cluster_count; - unsigned int core_element_count = 0; + unsigned int core_element_counter = 0; + unsigned int elements_count; + unsigned int systop_idx; core_count = rddanielxlr_core_get_core_count(); cluster_count = rddanielxlr_core_get_cluster_count(); - element_table = fwk_mm_calloc( - core_count - + FWK_ARRAY_SIZE(rddanielxlr_power_domain_static_element_table) - + 1, /* Terminator */ - sizeof(struct fwk_element)); + elements_count = core_count + FWK_ARRAY_SIZE( + rddanielxlr_power_domain_static_element_table); + + systop_idx = elements_count - 1; + + element_table = fwk_mm_calloc(elements_count + 1, /* Terminator */ + sizeof(struct fwk_element)); if (element_table == NULL) return NULL; - pd_config_table = fwk_mm_calloc(core_count, - sizeof(struct mod_power_domain_element_config)); + pd_config_table = fwk_mm_calloc(core_count, sizeof( + struct mod_power_domain_element_config)); if (pd_config_table == NULL) return NULL; @@ -160,8 +156,8 @@ static const struct fwk_element *rddanielxlr_power_domain_get_element_table core_idx < rddanielxlr_core_get_core_per_cluster_count(cluster_idx); core_idx++) { - element = &element_table[core_element_count]; - pd_config = &pd_config_table[core_element_count]; + element = &element_table[core_element_counter]; + pd_config = &pd_config_table[core_element_counter]; element->name = fwk_mm_alloc(PD_NAME_SIZE, 1); if (element->name == NULL) @@ -173,11 +169,10 @@ static const struct fwk_element *rddanielxlr_power_domain_get_element_table element->data = pd_config; pd_config->attributes.pd_type = MOD_PD_TYPE_CORE; - pd_config->tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_0, 0, 0, cluster_idx, core_idx); + pd_config->parent_idx = cluster_offset + cluster_idx; pd_config->driver_id = FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, - core_element_count); + core_element_counter); pd_config->api_id = FWK_ID_API( FWK_MODULE_IDX_PPU_V1, MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER); @@ -185,12 +180,13 @@ static const struct fwk_element *rddanielxlr_power_domain_get_element_table core_pd_allowed_state_mask_table; pd_config->allowed_state_mask_table_size = FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table); - core_element_count++; + core_element_counter++; } /* Define the driver id for the cluster */ pd_config = (struct mod_power_domain_element_config *) rddanielxlr_power_domain_static_element_table[cluster_idx].data; + pd_config->parent_idx = systop_idx; pd_config->driver_id = FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, (core_count + cluster_idx)); diff --git a/product/rdn1e1/scp_ramfw/config_power_domain.c b/product/rdn1e1/scp_ramfw/config_power_domain.c index 7e62817bd..49534b3f2 100644 --- a/product/rdn1e1/scp_ramfw/config_power_domain.c +++ b/product/rdn1e1/scp_ramfw/config_power_domain.c @@ -80,8 +80,6 @@ static struct fwk_element rdn1e1_power_domain_static_element_table[] = { .name = "CLUS0", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, PD_STATIC_DEV_IDX_CLUSTER0, 0), .api_id = FWK_ID_API_INIT( FWK_MODULE_IDX_PPU_V1, MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), @@ -94,8 +92,6 @@ static struct fwk_element rdn1e1_power_domain_static_element_table[] = { .name = "CLUS1", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, PD_STATIC_DEV_IDX_CLUSTER1, 0), .api_id = FWK_ID_API_INIT( FWK_MODULE_IDX_PPU_V1, MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), @@ -108,8 +104,6 @@ static struct fwk_element rdn1e1_power_domain_static_element_table[] = { .name = "DBGTOP", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_DEVICE_DEBUG, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, PD_STATIC_DEV_IDX_DBGTOP, 0), .driver_id = FWK_ID_ELEMENT_INIT( FWK_MODULE_IDX_PPU_V0, PPU_V0_ELEMENT_IDX_DBGTOP), .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_PPU_V0, 0), @@ -122,8 +116,7 @@ static struct fwk_element rdn1e1_power_domain_static_element_table[] = { .name = "SYSTOP", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_SYSTEM, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_2, 0, 0, 0, 0), + .parent_idx = PD_STATIC_DEV_IDX_NONE, .driver_id = FWK_ID_MODULE_INIT(FWK_MODULE_IDX_SYSTEM_POWER), .api_id = FWK_ID_API_INIT( FWK_MODULE_IDX_SYSTEM_POWER, @@ -145,29 +138,37 @@ static const struct fwk_element *rdn1e1_power_domain_get_element_table struct mod_power_domain_element_config *pd_config_table, *pd_config; unsigned int core_idx; unsigned int cluster_idx; + unsigned int cluster_offset = rdn1e1_core_get_core_count(); unsigned int core_count; unsigned int cluster_count; - unsigned int core_element_count = 0; + unsigned int core_element_counter = 0; + unsigned int elements_count; + unsigned int systop_idx; core_count = rdn1e1_core_get_core_count(); cluster_count = rdn1e1_core_get_cluster_count(); - element_table = fwk_mm_calloc( - core_count - + FWK_ARRAY_SIZE(rdn1e1_power_domain_static_element_table) - + 1, /* Terminator */ + elements_count = core_count + + FWK_ARRAY_SIZE(rdn1e1_power_domain_static_element_table); + systop_idx = elements_count - 1; + + element_table = fwk_mm_calloc(elements_count + 1, /* Terminator */ sizeof(struct fwk_element)); + if (element_table == NULL) + return NULL; pd_config_table = fwk_mm_calloc(core_count, sizeof(struct mod_power_domain_element_config)); + if (pd_config_table == NULL) + return NULL; for (cluster_idx = 0; cluster_idx < cluster_count; cluster_idx++) { for (core_idx = 0; core_idx < rdn1e1_core_get_core_per_cluster_count(cluster_idx); core_idx++) { - element = &element_table[core_element_count]; - pd_config = &pd_config_table[core_element_count]; + element = &element_table[core_element_counter]; + pd_config = &pd_config_table[core_element_counter]; element->name = fwk_mm_alloc(PD_NAME_SIZE, 1); @@ -177,11 +178,10 @@ static const struct fwk_element *rdn1e1_power_domain_get_element_table element->data = pd_config; pd_config->attributes.pd_type = MOD_PD_TYPE_CORE; - pd_config->tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_0, 0, 0, cluster_idx, core_idx); + pd_config->parent_idx = cluster_idx + cluster_offset; pd_config->driver_id = FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, - core_element_count); + core_element_counter); pd_config->api_id = FWK_ID_API( FWK_MODULE_IDX_PPU_V1, MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER); @@ -189,17 +189,23 @@ static const struct fwk_element *rdn1e1_power_domain_get_element_table core_pd_allowed_state_mask_table; pd_config->allowed_state_mask_table_size = FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table); - core_element_count++; + core_element_counter++; } /* Define the driver id for the cluster */ pd_config = (struct mod_power_domain_element_config *) rdn1e1_power_domain_static_element_table[cluster_idx].data; + pd_config->parent_idx = systop_idx; pd_config->driver_id = FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, (core_count + cluster_idx)); } + /* Set debug config */ + pd_config = (struct mod_power_domain_element_config *) + rdn1e1_power_domain_static_element_table[PD_STATIC_DEV_IDX_DBGTOP].data; + pd_config->parent_idx = systop_idx; + memcpy(element_table + core_count, rdn1e1_power_domain_static_element_table, sizeof(rdn1e1_power_domain_static_element_table)); diff --git a/product/rdn1e1/scp_ramfw/config_power_domain.h b/product/rdn1e1/scp_ramfw/config_power_domain.h index dfaf8ca27..a47d6fd05 100644 --- a/product/rdn1e1/scp_ramfw/config_power_domain.h +++ b/product/rdn1e1/scp_ramfw/config_power_domain.h @@ -8,6 +8,7 @@ #ifndef CONFIG_POWER_DOMAIN_H #define CONFIG_POWER_DOMAIN_H +#include /* * Power domain indices for the statically defined domains used for: * - Indexing the domains in the rdn1e1_power_domain_static_element_table @@ -21,7 +22,7 @@ enum pd_static_dev_idx { PD_STATIC_DEV_IDX_CLUSTER1, PD_STATIC_DEV_IDX_DBGTOP, PD_STATIC_DEV_IDX_SYSTOP, - PD_STATIC_DEV_IDX_COUNT + PD_STATIC_DEV_IDX_NONE = UINT32_MAX }; #endif /* CONFIG_POWER_DOMAIN_H */ diff --git a/product/sgi575/scp_ramfw/config_clock.c b/product/sgi575/scp_ramfw/config_clock.c index 916446b53..ee7ca8cf3 100644 --- a/product/sgi575/scp_ramfw/config_clock.c +++ b/product/sgi575/scp_ramfw/config_clock.c @@ -60,7 +60,9 @@ static const struct fwk_element *clock_get_dev_desc_table(fwk_id_t module_id) (struct mod_clock_dev_config *)clock_dev_desc_table[i].data; dev_config->pd_source_id = fwk_id_build_element_id( fwk_module_id_power_domain, - sgi575_core_get_core_count() + PD_STATIC_DEV_IDX_SYSTOP); + sgi575_core_get_core_count() + + sgi575_core_get_cluster_count() + + PD_STATIC_DEV_IDX_SYSTOP); } return clock_dev_desc_table; diff --git a/product/sgi575/scp_ramfw/config_power_domain.c b/product/sgi575/scp_ramfw/config_power_domain.c index 51c53bc40..7b86d62c4 100644 --- a/product/sgi575/scp_ramfw/config_power_domain.c +++ b/product/sgi575/scp_ramfw/config_power_domain.c @@ -75,40 +75,10 @@ static const uint32_t core_pd_allowed_state_mask_table[] = { static const struct mod_power_domain_config sgi575_power_domain_config = { 0 }; static struct fwk_element sgi575_power_domain_static_element_table[] = { - [PD_STATIC_DEV_IDX_CLUSTER0] = { - .name = "CLUS0", - .data = &((struct mod_power_domain_element_config) { - .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, PD_STATIC_DEV_IDX_CLUSTER0, 0), - .api_id = FWK_ID_API_INIT( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), - .allowed_state_mask_table = cluster_pd_allowed_state_mask_table, - .allowed_state_mask_table_size = - FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table) - }), - }, - [PD_STATIC_DEV_IDX_CLUSTER1] = { - .name = "CLUS1", - .data = &((struct mod_power_domain_element_config) { - .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, PD_STATIC_DEV_IDX_CLUSTER1, 0), - .api_id = FWK_ID_API_INIT( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), - .allowed_state_mask_table = cluster_pd_allowed_state_mask_table, - .allowed_state_mask_table_size = - FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table) - }), - }, [PD_STATIC_DEV_IDX_DBGTOP] = { .name = "DBGTOP", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_DEVICE_DEBUG, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, PD_STATIC_DEV_IDX_DBGTOP, 0), .driver_id = FWK_ID_ELEMENT_INIT( FWK_MODULE_IDX_PPU_V0, PPU_V0_ELEMENT_IDX_DBGTOP), .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_PPU_V0, 0), @@ -121,8 +91,7 @@ static struct fwk_element sgi575_power_domain_static_element_table[] = { .name = "SYSTOP", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_SYSTEM, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_2, 0, 0, 0, 0), + .parent_idx = PD_STATIC_DEV_IDX_NONE, .driver_id = FWK_ID_MODULE_INIT(FWK_MODULE_IDX_SYSTEM_POWER), .api_id = FWK_ID_API_INIT( FWK_MODULE_IDX_SYSTEM_POWER, @@ -146,29 +115,36 @@ static const struct fwk_element *sgi575_power_domain_get_element_table unsigned int cluster_idx; unsigned int core_count; unsigned int cluster_count; - unsigned int core_element_count = 0; + unsigned int cluster_offset; + unsigned int core_element_counter = 0; + unsigned int elements_count; + unsigned int systop_idx; core_count = sgi575_core_get_core_count(); cluster_count = sgi575_core_get_cluster_count(); - element_table = fwk_mm_calloc( - core_count - + FWK_ARRAY_SIZE(sgi575_power_domain_static_element_table) - + 1, /* Terminator */ - sizeof(struct fwk_element)); + elements_count = core_count + cluster_count + + FWK_ARRAY_SIZE(sgi575_power_domain_static_element_table); + + systop_idx = elements_count - 1; + + cluster_offset = core_count; + + element_table = fwk_mm_calloc(elements_count + 1, /* Terminator */ + sizeof(struct fwk_element)); if (element_table == NULL) return NULL; - pd_config_table = fwk_mm_calloc(core_count, - sizeof(struct mod_power_domain_element_config)); + pd_config_table = fwk_mm_calloc(core_count + cluster_count, + sizeof(struct mod_power_domain_element_config)); for (cluster_idx = 0; cluster_idx < cluster_count; cluster_idx++) { for (core_idx = 0; core_idx < sgi575_core_get_core_per_cluster_count(cluster_idx); core_idx++) { - element = &element_table[core_element_count]; - pd_config = &pd_config_table[core_element_count]; + element = &element_table[core_element_counter]; + pd_config = &pd_config_table[core_element_counter]; element->name = fwk_mm_alloc(PD_NAME_SIZE, 1); @@ -178,11 +154,10 @@ static const struct fwk_element *sgi575_power_domain_get_element_table element->data = pd_config; pd_config->attributes.pd_type = MOD_PD_TYPE_CORE; - pd_config->tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_0, 0, 0, cluster_idx, core_idx); + pd_config->parent_idx = cluster_idx + cluster_offset; pd_config->driver_id = FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, - core_element_count); + core_element_counter); pd_config->api_id = FWK_ID_API( FWK_MODULE_IDX_PPU_V1, MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER); @@ -190,18 +165,40 @@ static const struct fwk_element *sgi575_power_domain_get_element_table core_pd_allowed_state_mask_table; pd_config->allowed_state_mask_table_size = FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table); - core_element_count++; + core_element_counter++; } - /* Define the driver id for the cluster */ - pd_config = (struct mod_power_domain_element_config *) - sgi575_power_domain_static_element_table[cluster_idx].data; + /* Define the cluster configuration */ + element = &element_table[cluster_idx + cluster_offset]; + pd_config = &pd_config_table[cluster_idx + cluster_offset]; + + element->name = fwk_mm_alloc(PD_NAME_SIZE, 1); + + snprintf((char *)element->name, PD_NAME_SIZE, "CLUS%u", cluster_idx); + + element->data = pd_config; + + pd_config->attributes.pd_type = MOD_PD_TYPE_CLUSTER; + pd_config->parent_idx = systop_idx; pd_config->driver_id = FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, - (core_count + cluster_idx)); + cluster_idx + cluster_offset); + pd_config->api_id = FWK_ID_API( + FWK_MODULE_IDX_PPU_V1, + MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER); + pd_config->allowed_state_mask_table = + cluster_pd_allowed_state_mask_table; + pd_config->allowed_state_mask_table_size = + FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table); } - memcpy(element_table + core_count, + /* Set debug config */ + pd_config = (struct mod_power_domain_element_config *) + sgi575_power_domain_static_element_table[PD_STATIC_DEV_IDX_DBGTOP] + .data; + pd_config->parent_idx = systop_idx; + + memcpy(element_table + core_count + cluster_count, sgi575_power_domain_static_element_table, sizeof(sgi575_power_domain_static_element_table)); diff --git a/product/sgi575/scp_ramfw/config_power_domain.h b/product/sgi575/scp_ramfw/config_power_domain.h index e65be28ce..e6de52bd7 100644 --- a/product/sgi575/scp_ramfw/config_power_domain.h +++ b/product/sgi575/scp_ramfw/config_power_domain.h @@ -8,6 +8,7 @@ #ifndef CONFIG_POWER_DOMAIN_H #define CONFIG_POWER_DOMAIN_H +#include /* * Power domain indices for the statically defined domains used for: * - Indexing the domains in the sgi575_power_domain_static_element_table @@ -17,11 +18,9 @@ * core_count + pd_static_dev_idx */ enum pd_static_dev_idx { - PD_STATIC_DEV_IDX_CLUSTER0, - PD_STATIC_DEV_IDX_CLUSTER1, PD_STATIC_DEV_IDX_DBGTOP, PD_STATIC_DEV_IDX_SYSTOP, - PD_STATIC_DEV_IDX_COUNT + PD_STATIC_DEV_IDX_NONE = UINT32_MAX }; #endif /* CONFIG_POWER_DOMAIN_H */ diff --git a/product/sgi575/scp_ramfw/config_ppu_v1.c b/product/sgi575/scp_ramfw/config_ppu_v1.c index d6419853a..211f88fdf 100644 --- a/product/sgi575/scp_ramfw/config_ppu_v1.c +++ b/product/sgi575/scp_ramfw/config_ppu_v1.c @@ -143,7 +143,7 @@ static const struct fwk_element *ppu_v1_get_element_table(fwk_id_t module_id) */ ppu_v1_config_data.pd_source_id = fwk_id_build_element_id( fwk_module_id_power_domain, - core_count + PD_STATIC_DEV_IDX_SYSTOP); + core_count + cluster_count + PD_STATIC_DEV_IDX_SYSTOP); return element_table; } diff --git a/product/sgi575/scp_ramfw/config_smt.c b/product/sgi575/scp_ramfw/config_smt.c index cc3f16f4e..91b3e7c73 100644 --- a/product/sgi575/scp_ramfw/config_smt.c +++ b/product/sgi575/scp_ramfw/config_smt.c @@ -56,7 +56,9 @@ static const struct fwk_element *smt_get_element_table(fwk_id_t module_id) for (idx = 0; idx < SCP_SGI575_SCMI_SERVICE_IDX_COUNT; idx++) { config = (struct mod_smt_channel_config *)(smt_element_table[idx].data); config->pd_source_id = FWK_ID_ELEMENT(FWK_MODULE_IDX_POWER_DOMAIN, - sgi575_core_get_core_count() + PD_STATIC_DEV_IDX_SYSTOP); + sgi575_core_get_core_count() + + sgi575_core_get_cluster_count() + + PD_STATIC_DEV_IDX_SYSTOP); } return smt_element_table; diff --git a/product/sgm775/scp_ramfw/config_clock.c b/product/sgm775/scp_ramfw/config_clock.c index 84d3b29ae..8665bc506 100644 --- a/product/sgm775/scp_ramfw/config_clock.c +++ b/product/sgm775/scp_ramfw/config_clock.c @@ -102,7 +102,7 @@ static const struct fwk_element *clock_get_dev_desc_table(fwk_id_t module_id) (struct mod_clock_dev_config *)clock_dev_desc_table[i].data; dev_config->pd_source_id = FWK_ID_ELEMENT( FWK_MODULE_IDX_POWER_DOMAIN, - CONFIG_POWER_DOMAIN_SYSTOP_CHILD_COUNT + core_count); + CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM + core_count); } return clock_dev_desc_table; diff --git a/product/sgm775/scp_ramfw/config_power_domain.c b/product/sgm775/scp_ramfw/config_power_domain.c index 4aa040a5b..f56d178d5 100644 --- a/product/sgm775/scp_ramfw/config_power_domain.c +++ b/product/sgm775/scp_ramfw/config_power_domain.c @@ -77,12 +77,6 @@ static struct fwk_element sgm775_power_domain_static_element_table[] = { .name = "CLUS0", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, - 0, - 0, - CONFIG_POWER_DOMAIN_SYSTOP_CHILD_CLUSTER0, - 0), .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_PPU_V1, MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), .allowed_state_mask_table = cluster_pd_allowed_state_mask_table, @@ -94,12 +88,6 @@ static struct fwk_element sgm775_power_domain_static_element_table[] = { .name = "DBGTOP", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_DEVICE_DEBUG, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, - 0, - 0, - CONFIG_POWER_DOMAIN_SYSTOP_CHILD_DBGTOP, - 0), .driver_id = FWK_ID_ELEMENT_INIT( FWK_MODULE_IDX_PPU_V0, PPU_V0_ELEMENT_IDX_DBGTOP), .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_PPU_V0, 0), @@ -112,12 +100,6 @@ static struct fwk_element sgm775_power_domain_static_element_table[] = { .name = "DPU0TOP", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_DEVICE, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, - 0, - 0, - CONFIG_POWER_DOMAIN_SYSTOP_CHILD_DPU0TOP, - 0), .driver_id = FWK_ID_ELEMENT_INIT( FWK_MODULE_IDX_PPU_V0, PPU_V0_ELEMENT_IDX_DPU0TOP), .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_PPU_V0, 0), @@ -130,12 +112,6 @@ static struct fwk_element sgm775_power_domain_static_element_table[] = { .name = "DPU1TOP", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_DEVICE, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, - 0, - 0, - CONFIG_POWER_DOMAIN_SYSTOP_CHILD_DPU1TOP, - 0), .driver_id = FWK_ID_ELEMENT_INIT( FWK_MODULE_IDX_PPU_V0, PPU_V0_ELEMENT_IDX_DPU1TOP), .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_PPU_V0, 0), @@ -148,12 +124,6 @@ static struct fwk_element sgm775_power_domain_static_element_table[] = { .name = "GPUTOP", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_DEVICE, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, - 0, - 0, - CONFIG_POWER_DOMAIN_SYSTOP_CHILD_GPUTOP, - 0), .driver_id = FWK_ID_ELEMENT_INIT( FWK_MODULE_IDX_PPU_V0, PPU_V0_ELEMENT_IDX_GPUTOP), .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_PPU_V0, 0), @@ -166,12 +136,6 @@ static struct fwk_element sgm775_power_domain_static_element_table[] = { .name = "VPUTOP", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_DEVICE, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, - 0, - 0, - CONFIG_POWER_DOMAIN_SYSTOP_CHILD_VPUTOP, - 0), .driver_id = FWK_ID_ELEMENT_INIT( FWK_MODULE_IDX_PPU_V0, PPU_V0_ELEMENT_IDX_VPUTOP), .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_PPU_V0, 0), @@ -180,12 +144,11 @@ static struct fwk_element sgm775_power_domain_static_element_table[] = { FWK_ARRAY_SIZE(toplevel_allowed_state_mask_table) }), }, - [CONFIG_POWER_DOMAIN_SYSTOP_CHILD_COUNT] = { + [CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM] = { .name = "SYSTOP", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_SYSTEM, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_2, 0, 0, 0, 0), + .parent_idx = CONFIG_POWER_DOMAIN_NONE, .driver_id = FWK_ID_MODULE_INIT(FWK_MODULE_IDX_SYSTEM_POWER), .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_SYSTEM_POWER, MOD_SYSTEM_POWER_API_IDX_PD_DRIVER), @@ -205,12 +168,17 @@ static const struct fwk_element *sgm775_power_domain_get_element_table { struct fwk_element *element_table, *element; struct mod_power_domain_element_config *pd_config_table, *pd_config; - unsigned int core_idx; + unsigned int core_idx, i; + unsigned int cluster_offset = sgm775_core_get_count(); + unsigned int systop_idx; + unsigned int elements_count; - element_table = fwk_mm_calloc( - sgm775_core_get_count() - + FWK_ARRAY_SIZE(sgm775_power_domain_static_element_table) - + 1, /* Terminator */ + elements_count = sgm775_core_get_count() + + FWK_ARRAY_SIZE(sgm775_power_domain_static_element_table); + + systop_idx = elements_count - 1; + + element_table = fwk_mm_calloc(elements_count + 1, /* Terminator */ sizeof(struct fwk_element)); pd_config_table = fwk_mm_calloc(sgm775_core_get_count(), @@ -224,12 +192,7 @@ static const struct fwk_element *sgm775_power_domain_get_element_table element->data = pd_config; pd_config->attributes.pd_type = MOD_PD_TYPE_CORE, - pd_config->tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_0, - 0, - 0, - CONFIG_POWER_DOMAIN_SYSTOP_CHILD_CLUSTER0, - core_idx), + pd_config->parent_idx = cluster_offset, pd_config->driver_id = FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, core_idx), pd_config->api_id = FWK_ID_API( FWK_MODULE_IDX_PPU_V1, MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), @@ -245,6 +208,16 @@ static const struct fwk_element *sgm775_power_domain_get_element_table pd_config->driver_id = FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, sgm775_core_get_count()); + /* Set the parent for all level one domains */ + for (i = 0; + i < (FWK_ARRAY_SIZE(sgm775_power_domain_static_element_table) - 1); + i++) { + + pd_config = (struct mod_power_domain_element_config *) + sgm775_power_domain_static_element_table[i].data; + pd_config->parent_idx = systop_idx; + } + memcpy(element_table + sgm775_core_get_count(), sgm775_power_domain_static_element_table, sizeof(sgm775_power_domain_static_element_table)); diff --git a/product/sgm775/scp_ramfw/config_power_domain.h b/product/sgm775/scp_ramfw/config_power_domain.h index fc0738674..c8926e10e 100644 --- a/product/sgm775/scp_ramfw/config_power_domain.h +++ b/product/sgm775/scp_ramfw/config_power_domain.h @@ -8,6 +8,8 @@ #ifndef CONFIG_POWER_DOMAIN_H #define CONFIG_POWER_DOMAIN_H +#include + enum systop_child_index { CONFIG_POWER_DOMAIN_SYSTOP_CHILD_CLUSTER0, CONFIG_POWER_DOMAIN_SYSTOP_CHILD_DBGTOP, @@ -15,7 +17,8 @@ enum systop_child_index { CONFIG_POWER_DOMAIN_SYSTOP_CHILD_DPU1TOP, CONFIG_POWER_DOMAIN_SYSTOP_CHILD_GPUTOP, CONFIG_POWER_DOMAIN_SYSTOP_CHILD_VPUTOP, - CONFIG_POWER_DOMAIN_SYSTOP_CHILD_COUNT + CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM, + CONFIG_POWER_DOMAIN_NONE = UINT32_MAX }; #endif /* CONFIG_POWER_DOMAIN_H */ diff --git a/product/sgm775/scp_ramfw/config_ppu_v1.c b/product/sgm775/scp_ramfw/config_ppu_v1.c index f13dc3f08..56ca96404 100644 --- a/product/sgm775/scp_ramfw/config_ppu_v1.c +++ b/product/sgm775/scp_ramfw/config_ppu_v1.c @@ -93,7 +93,7 @@ static const struct fwk_element *sgm775_ppu_v1_get_element_table sgm775_ppu_v1_notification_config.pd_source_id = FWK_ID_ELEMENT( FWK_MODULE_IDX_POWER_DOMAIN, - CONFIG_POWER_DOMAIN_SYSTOP_CHILD_COUNT + sgm775_core_get_count()); + CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM + sgm775_core_get_count()); return element_table; } diff --git a/product/sgm775/scp_ramfw/config_smt.c b/product/sgm775/scp_ramfw/config_smt.c index 67e646d2c..9d2369e35 100644 --- a/product/sgm775/scp_ramfw/config_smt.c +++ b/product/sgm775/scp_ramfw/config_smt.c @@ -68,7 +68,7 @@ static const struct fwk_element *smt_get_element_table(fwk_id_t module_id) for (idx = 0; idx < SGM775_SCMI_SERVICE_IDX_COUNT; idx++) { config = (struct mod_smt_channel_config *)(smt_element_table[idx].data); config->pd_source_id = FWK_ID_ELEMENT(FWK_MODULE_IDX_POWER_DOMAIN, - CONFIG_POWER_DOMAIN_SYSTOP_CHILD_COUNT + sgm775_core_get_count()); + CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM + sgm775_core_get_count()); } return smt_element_table; diff --git a/product/sgm776/scp_ramfw/config_clock.c b/product/sgm776/scp_ramfw/config_clock.c index b39763f89..f338acad2 100644 --- a/product/sgm776/scp_ramfw/config_clock.c +++ b/product/sgm776/scp_ramfw/config_clock.c @@ -102,7 +102,7 @@ static const struct fwk_element *clock_get_dev_desc_table(fwk_id_t module_id) (struct mod_clock_dev_config *)clock_dev_desc_table[i].data; dev_config->pd_source_id = FWK_ID_ELEMENT( FWK_MODULE_IDX_POWER_DOMAIN, - CONFIG_POWER_DOMAIN_SYSTOP_CHILD_COUNT + core_count); + CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM + core_count); } return clock_dev_desc_table; diff --git a/product/sgm776/scp_ramfw/config_power_domain.c b/product/sgm776/scp_ramfw/config_power_domain.c index df69d520e..846cfd01f 100644 --- a/product/sgm776/scp_ramfw/config_power_domain.c +++ b/product/sgm776/scp_ramfw/config_power_domain.c @@ -74,12 +74,6 @@ static struct fwk_element sgm776_power_domain_static_element_table[] = { .name = "CLUS0", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, - 0, - 0, - CONFIG_POWER_DOMAIN_SYSTOP_CHILD_CLUSTER0, - 0), .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_PPU_V1, MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), .allowed_state_mask_table = cluster_pd_allowed_state_mask_table, @@ -91,12 +85,6 @@ static struct fwk_element sgm776_power_domain_static_element_table[] = { .name = "DBGTOP", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_DEVICE_DEBUG, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, - 0, - 0, - CONFIG_POWER_DOMAIN_SYSTOP_CHILD_DBGTOP, - 0), .driver_id = FWK_ID_ELEMENT_INIT( FWK_MODULE_IDX_PPU_V1, PPU_V1_ELEMENT_IDX_DBGTOP), .api_id = FWK_ID_API_INIT( @@ -111,12 +99,6 @@ static struct fwk_element sgm776_power_domain_static_element_table[] = { .name = "DPUTOP", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_DEVICE, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, - 0, - 0, - CONFIG_POWER_DOMAIN_SYSTOP_CHILD_DPUTOP, - 0), .driver_id = FWK_ID_ELEMENT_INIT( FWK_MODULE_IDX_PPU_V1, PPU_V1_ELEMENT_IDX_DPUTOP), .api_id = FWK_ID_API_INIT( @@ -131,12 +113,6 @@ static struct fwk_element sgm776_power_domain_static_element_table[] = { .name = "GPUTOP", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_DEVICE, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, - 0, - 0, - CONFIG_POWER_DOMAIN_SYSTOP_CHILD_GPUTOP, - 0), .driver_id = FWK_ID_ELEMENT_INIT( FWK_MODULE_IDX_PPU_V1, PPU_V1_ELEMENT_IDX_GPUTOP), .api_id = FWK_ID_API_INIT( @@ -151,12 +127,6 @@ static struct fwk_element sgm776_power_domain_static_element_table[] = { .name = "VPUTOP", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_DEVICE, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, - 0, - 0, - CONFIG_POWER_DOMAIN_SYSTOP_CHILD_VPUTOP, - 0), .driver_id = FWK_ID_ELEMENT_INIT( FWK_MODULE_IDX_PPU_V1, PPU_V1_ELEMENT_IDX_VPUTOP), .api_id = FWK_ID_API_INIT( @@ -167,12 +137,11 @@ static struct fwk_element sgm776_power_domain_static_element_table[] = { FWK_ARRAY_SIZE(toplevel_allowed_state_mask_table) }), }, - [CONFIG_POWER_DOMAIN_SYSTOP_CHILD_COUNT] = { + [CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM] = { .name = "SYSTOP", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_SYSTEM, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_2, 0, 0, 0, 0), + .parent_idx = CONFIG_POWER_DOMAIN_NONE, .driver_id = FWK_ID_MODULE_INIT(FWK_MODULE_IDX_SYSTEM_POWER), .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_SYSTEM_POWER, MOD_SYSTEM_POWER_API_IDX_PD_DRIVER), @@ -192,12 +161,17 @@ static const struct fwk_element *sgm776_power_domain_get_element_table { struct fwk_element *element_table, *element; struct mod_power_domain_element_config *pd_config_table, *pd_config; - unsigned int core_idx; + unsigned int core_idx, i; + unsigned int cluster_offset = sgm776_core_get_count(); + unsigned int systop_idx; + unsigned int elements_count; - element_table = fwk_mm_calloc( - sgm776_core_get_count() - + FWK_ARRAY_SIZE(sgm776_power_domain_static_element_table) - + 1, /* Terminator */ + elements_count = sgm776_core_get_count() + + FWK_ARRAY_SIZE(sgm776_power_domain_static_element_table); + + systop_idx = elements_count - 1; + + element_table = fwk_mm_calloc(elements_count + 1, /* Terminator */ sizeof(struct fwk_element)); pd_config_table = fwk_mm_calloc(sgm776_core_get_count(), @@ -211,12 +185,7 @@ static const struct fwk_element *sgm776_power_domain_get_element_table element->data = pd_config; pd_config->attributes.pd_type = MOD_PD_TYPE_CORE, - pd_config->tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_0, - 0, - 0, - CONFIG_POWER_DOMAIN_SYSTOP_CHILD_CLUSTER0, - core_idx), + pd_config->parent_idx = cluster_offset, pd_config->driver_id = FWK_ID_ELEMENT( FWK_MODULE_IDX_PPU_V1, PPU_V1_ELEMENT_IDX_COUNT + core_idx), pd_config->api_id = FWK_ID_API( @@ -234,6 +203,16 @@ static const struct fwk_element *sgm776_power_domain_get_element_table FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, PPU_V1_ELEMENT_IDX_COUNT + sgm776_core_get_count()); + /* Set the parent for all level one domains */ + for (i = 0; + i < (FWK_ARRAY_SIZE(sgm776_power_domain_static_element_table) - 1); + i++) { + + pd_config = (struct mod_power_domain_element_config *) + sgm776_power_domain_static_element_table[i].data; + pd_config->parent_idx = systop_idx; + } + memcpy(element_table + sgm776_core_get_count(), sgm776_power_domain_static_element_table, sizeof(sgm776_power_domain_static_element_table)); diff --git a/product/sgm776/scp_ramfw/config_power_domain.h b/product/sgm776/scp_ramfw/config_power_domain.h index a510220b9..c75109ab0 100644 --- a/product/sgm776/scp_ramfw/config_power_domain.h +++ b/product/sgm776/scp_ramfw/config_power_domain.h @@ -8,13 +8,16 @@ #ifndef CONFIG_POWER_DOMAIN_H #define CONFIG_POWER_DOMAIN_H +#include + enum systop_child_index { CONFIG_POWER_DOMAIN_SYSTOP_CHILD_CLUSTER0, CONFIG_POWER_DOMAIN_SYSTOP_CHILD_DBGTOP, CONFIG_POWER_DOMAIN_SYSTOP_CHILD_DPUTOP, CONFIG_POWER_DOMAIN_SYSTOP_CHILD_GPUTOP, CONFIG_POWER_DOMAIN_SYSTOP_CHILD_VPUTOP, - CONFIG_POWER_DOMAIN_SYSTOP_CHILD_COUNT + CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM, + CONFIG_POWER_DOMAIN_NONE = UINT32_MAX }; #endif /* CONFIG_POWER_DOMAIN_H */ diff --git a/product/sgm776/scp_ramfw/config_ppu_v1.c b/product/sgm776/scp_ramfw/config_ppu_v1.c index 049d4a18b..225ae926d 100644 --- a/product/sgm776/scp_ramfw/config_ppu_v1.c +++ b/product/sgm776/scp_ramfw/config_ppu_v1.c @@ -163,7 +163,7 @@ static const struct fwk_element *sgm776_ppu_v1_get_element_table( sgm776_ppu_v1_notification_config.pd_source_id = FWK_ID_ELEMENT( FWK_MODULE_IDX_POWER_DOMAIN, - CONFIG_POWER_DOMAIN_SYSTOP_CHILD_COUNT + sgm776_core_get_count()); + CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM + sgm776_core_get_count()); return element_table; } diff --git a/product/sgm776/scp_ramfw/config_smt.c b/product/sgm776/scp_ramfw/config_smt.c index 8131cce43..b42eee446 100644 --- a/product/sgm776/scp_ramfw/config_smt.c +++ b/product/sgm776/scp_ramfw/config_smt.c @@ -72,7 +72,7 @@ static const struct fwk_element *smt_get_element_table(fwk_id_t module_id) for (idx = 0; idx < SGM776_SCMI_SERVICE_IDX_COUNT; idx++) { config = (struct mod_smt_channel_config *)(smt_element_table[idx].data); config->pd_source_id = FWK_ID_ELEMENT(FWK_MODULE_IDX_POWER_DOMAIN, - CONFIG_POWER_DOMAIN_SYSTOP_CHILD_COUNT + sgm776_core_get_count()); + CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM + sgm776_core_get_count()); } return smt_element_table; diff --git a/product/synquacer/scp_ramfw/config_power_domain.c b/product/synquacer/scp_ramfw/config_power_domain.c index fa7438155..cfc872d35 100644 --- a/product/synquacer/scp_ramfw/config_power_domain.c +++ b/product/synquacer/scp_ramfw/config_power_domain.c @@ -61,7 +61,6 @@ static struct fwk_element synquacer_power_domain_static_element_table[] = { .name = "SYS3", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_DEVICE, - .tree_pos = MOD_PD_TREE_POS(MOD_PD_LEVEL_1, 0, 0, 12, 0), .driver_id = FWK_ID_ELEMENT_INIT( FWK_MODULE_IDX_PPU_V0_SYNQUACER, PPU_V0_ELEMENT_IDX_SYS3), @@ -74,7 +73,6 @@ static struct fwk_element synquacer_power_domain_static_element_table[] = { .name = "SYS1", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_DEVICE, - .tree_pos = MOD_PD_TREE_POS(MOD_PD_LEVEL_1, 0, 0, 13, 0), .driver_id = FWK_ID_ELEMENT_INIT( FWK_MODULE_IDX_PPU_V0_SYNQUACER, PPU_V0_ELEMENT_IDX_SYS1), @@ -87,7 +85,6 @@ static struct fwk_element synquacer_power_domain_static_element_table[] = { .name = "SYS2", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_DEVICE, - .tree_pos = MOD_PD_TREE_POS(MOD_PD_LEVEL_1, 0, 0, 14, 0), .driver_id = FWK_ID_ELEMENT_INIT( FWK_MODULE_IDX_PPU_V0_SYNQUACER, PPU_V0_ELEMENT_IDX_SYS2), @@ -103,7 +100,6 @@ static struct fwk_element synquacer_power_domain_static_element_table[] = { .name = "DEBUG", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_DEVICE_DEBUG, - .tree_pos = MOD_PD_TREE_POS(MOD_PD_LEVEL_1, 0, 0, 16, 0), .driver_id = FWK_ID_ELEMENT_INIT( FWK_MODULE_IDX_PPU_V0_SYNQUACER, PPU_V0_ELEMENT_IDX_DEBUG), @@ -116,7 +112,7 @@ static struct fwk_element synquacer_power_domain_static_element_table[] = { .name = "SYSTOP", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_SYSTEM, - .tree_pos = MOD_PD_TREE_POS(MOD_PD_LEVEL_2, 0, 0, 0, 0), + .parent_idx = PD_STATIC_DEV_IDX_NONE, .driver_id = FWK_ID_MODULE_INIT(FWK_MODULE_IDX_SYSTEM_POWER), .api_id = FWK_ID_API_INIT( FWK_MODULE_IDX_SYSTEM_POWER, @@ -125,7 +121,6 @@ static struct fwk_element synquacer_power_domain_static_element_table[] = { .allowed_state_mask_table_size = FWK_ARRAY_SIZE(systop_allowed_state_mask_table) }), }, - [PD_STATIC_DEV_IDX_COUNT] = { 0 }, /* Termination entry */ }; static const struct fwk_element *synquacer_power_domain_get_element_table( @@ -133,21 +128,26 @@ static const struct fwk_element *synquacer_power_domain_get_element_table( { struct fwk_element *element_table, *element; struct mod_power_domain_element_config *pd_config_table, *pd_config; - unsigned int core_idx; + unsigned int core_idx, i; unsigned int cluster_idx; unsigned int core_count; unsigned int cluster_count; unsigned int core_per_cluster_count; - unsigned int element_count = 0; + unsigned int element_counter = 0; + unsigned int total_elements; + unsigned int systop_idx; core_count = synquacer_core_get_core_count(); cluster_count = synquacer_core_get_cluster_count(); core_per_cluster_count = synquacer_core_get_core_per_cluster_count(); - element_table = fwk_mm_calloc( - cluster_count + core_count + - FWK_ARRAY_SIZE(synquacer_power_domain_static_element_table) + - 1, /* Terminator */ + total_elements = cluster_count + core_count + + FWK_ARRAY_SIZE( + synquacer_power_domain_static_element_table); + + systop_idx = total_elements - 1; + + element_table = fwk_mm_calloc(total_elements + 1, /* Terminator */ sizeof(struct fwk_element)); pd_config_table = fwk_mm_calloc( @@ -163,8 +163,8 @@ static const struct fwk_element *synquacer_power_domain_get_element_table( /* prepare core config table */ for (cluster_idx = 0; cluster_idx < cluster_count; cluster_idx++) { for (core_idx = 0; core_idx < core_per_cluster_count; core_idx++) { - element = &element_table[element_count]; - pd_config = &pd_config_table[element_count]; + element = &element_table[element_counter]; + pd_config = &pd_config_table[element_counter]; element->name = fwk_mm_alloc(PD_NAME_SIZE, 1); @@ -178,23 +178,22 @@ static const struct fwk_element *synquacer_power_domain_get_element_table( element->data = pd_config; pd_config->attributes.pd_type = MOD_PD_TYPE_CORE; - pd_config->tree_pos = - MOD_PD_TREE_POS(MOD_PD_LEVEL_0, 0, 0, cluster_idx, core_idx); pd_config->driver_id = - FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V0_SYNQUACER, element_count); + FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V0_SYNQUACER, + element_counter); pd_config->api_id = FWK_ID_API(FWK_MODULE_IDX_PPU_V0_SYNQUACER, 0); pd_config->allowed_state_mask_table = core_pd_allowed_state_mask_table; pd_config->allowed_state_mask_table_size = FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table); - element_count++; + element_counter++; } } /* prepare cluster config table */ for (cluster_idx = 0; cluster_idx < cluster_count; cluster_idx++) { - element = &element_table[element_count]; - pd_config = &pd_config_table[element_count]; + element = &element_table[element_counter]; + pd_config = &pd_config_table[element_counter]; element->name = fwk_mm_alloc(PD_NAME_SIZE, 1); @@ -203,20 +202,29 @@ static const struct fwk_element *synquacer_power_domain_get_element_table( element->data = pd_config; pd_config->attributes.pd_type = MOD_PD_TYPE_CLUSTER; - pd_config->tree_pos = - MOD_PD_TREE_POS(MOD_PD_LEVEL_1, 0, 0, cluster_idx, 0); + pd_config->parent_idx = systop_idx; pd_config->driver_id = - FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V0_SYNQUACER, element_count); + FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V0_SYNQUACER, element_counter); pd_config->api_id = FWK_ID_API(FWK_MODULE_IDX_PPU_V0_SYNQUACER, 0); pd_config->allowed_state_mask_table = cluster_pd_allowed_state_mask_table; pd_config->allowed_state_mask_table_size = FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table); - element_count++; + element_counter++; + } + + /* Set the parent for all level one domains */ + for (i = 0; + i < (FWK_ARRAY_SIZE(synquacer_power_domain_static_element_table) - 1); + i++) { + + pd_config = (struct mod_power_domain_element_config *) + synquacer_power_domain_static_element_table[i].data; + pd_config->parent_idx = systop_idx; } memcpy( - element_table + element_count, + element_table + element_counter, synquacer_power_domain_static_element_table, sizeof(synquacer_power_domain_static_element_table)); diff --git a/product/synquacer/scp_ramfw/config_power_domain.h b/product/synquacer/scp_ramfw/config_power_domain.h index 152cc5a0c..235d290ab 100644 --- a/product/synquacer/scp_ramfw/config_power_domain.h +++ b/product/synquacer/scp_ramfw/config_power_domain.h @@ -8,6 +8,7 @@ #ifndef CONFIG_POWER_DOMAIN_H #define CONFIG_POWER_DOMAIN_H +#include /* * Power domain indices for the statically defined domains used for: * - Indexing the domains in the synquacer_power_domain_static_element_table @@ -24,7 +25,7 @@ enum pd_static_dev_idx { PD_STATIC_DEV_IDX_CHILD_DEBUG, PD_STATIC_DEV_IDX_SYSTOP, - PD_STATIC_DEV_IDX_COUNT + PD_STATIC_DEV_IDX_NONE = UINT32_MAX }; #endif /* CONFIG_POWER_DOMAIN_H */ diff --git a/product/tc0/include/config_power_domain.h b/product/tc0/include/config_power_domain.h index a85ea581f..ba381022a 100644 --- a/product/tc0/include/config_power_domain.h +++ b/product/tc0/include/config_power_domain.h @@ -8,6 +8,8 @@ #ifndef CONFIG_POWER_DOMAIN_H #define CONFIG_POWER_DOMAIN_H +#include + /* * Power domain indices for the statically defined domains used for: * - Indexing the domains in the tc0_power_domain_static_element_table @@ -19,7 +21,8 @@ enum pd_static_dev_idx { PD_STATIC_DEV_IDX_CLUSTER0, PD_STATIC_DEV_IDX_SYSTOP, - PD_STATIC_DEV_IDX_COUNT + PD_STATIC_DEV_IDX_COUNT, + PD_STATIC_DEV_IDX_NONE = UINT32_MAX }; #endif /* CONFIG_POWER_DOMAIN_H */ diff --git a/product/tc0/scp_ramfw/config_power_domain.c b/product/tc0/scp_ramfw/config_power_domain.c index bd0428836..29de334eb 100644 --- a/product/tc0/scp_ramfw/config_power_domain.c +++ b/product/tc0/scp_ramfw/config_power_domain.c @@ -56,8 +56,6 @@ static struct fwk_element tc0_power_domain_static_element_table[] = { .name = "CLUS0", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_1, 0, 0, PD_STATIC_DEV_IDX_CLUSTER0, 0), .api_id = FWK_ID_API_INIT( FWK_MODULE_IDX_PPU_V1, MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), @@ -70,8 +68,7 @@ static struct fwk_element tc0_power_domain_static_element_table[] = { .name = "SYSTOP", .data = &((struct mod_power_domain_element_config) { .attributes.pd_type = MOD_PD_TYPE_SYSTEM, - .tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_2, 0, 0, 0, 0), + .parent_idx = PD_STATIC_DEV_IDX_NONE, .driver_id = FWK_ID_MODULE_INIT(FWK_MODULE_IDX_SYSTEM_POWER), .api_id = FWK_ID_API_INIT( FWK_MODULE_IDX_SYSTEM_POWER, @@ -93,17 +90,22 @@ static const struct fwk_element *tc0_power_domain_get_element_table struct mod_power_domain_element_config *pd_config_table, *pd_config; unsigned int core_idx; unsigned int cluster_idx; + unsigned int cluster_offset; unsigned int core_count; unsigned int cluster_count; - unsigned int core_element_count = 0; + unsigned int core_element_counter = 0; + unsigned int elements_count; + unsigned int systop_idx; - core_count = tc0_core_get_core_count(); + core_count = cluster_offset = tc0_core_get_core_count(); cluster_count = tc0_core_get_cluster_count(); - element_table = fwk_mm_calloc( - core_count - + FWK_ARRAY_SIZE(tc0_power_domain_static_element_table) - + 1, /* Terminator */ + elements_count = core_count + + FWK_ARRAY_SIZE(tc0_power_domain_static_element_table); + + systop_idx = elements_count - 1; + + element_table = fwk_mm_calloc(elements_count + 1, /* Terminator */ sizeof(struct fwk_element)); if (element_table == NULL) return NULL; @@ -119,8 +121,8 @@ static const struct fwk_element *tc0_power_domain_get_element_table cluster_idx); core_idx++) { - element = &element_table[core_element_count]; - pd_config = &pd_config_table[core_element_count]; + element = &element_table[core_element_counter]; + pd_config = &pd_config_table[core_element_counter]; element->name = fwk_mm_alloc(PD_NAME_SIZE, 1); if (element->name == NULL) @@ -132,11 +134,9 @@ static const struct fwk_element *tc0_power_domain_get_element_table element->data = pd_config; pd_config->attributes.pd_type = MOD_PD_TYPE_CORE; - pd_config->tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_0, 0, 0, cluster_idx, core_idx); + pd_config->parent_idx = cluster_idx + cluster_offset; pd_config->driver_id = - FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, - core_element_count); + FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, core_element_counter); pd_config->api_id = FWK_ID_API( FWK_MODULE_IDX_PPU_V1, MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER); @@ -144,15 +144,15 @@ static const struct fwk_element *tc0_power_domain_get_element_table core_pd_allowed_state_mask_table; pd_config->allowed_state_mask_table_size = FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table); - core_element_count++; + core_element_counter++; } /* Define the driver id for the cluster */ pd_config = (struct mod_power_domain_element_config *) tc0_power_domain_static_element_table[cluster_idx].data; - pd_config->driver_id = - FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, - (core_count + cluster_idx)); + pd_config->parent_idx = systop_idx; + pd_config->driver_id = FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, + (core_count + cluster_idx)); } memcpy(element_table + core_count, -- GitLab From ffd9d3791e6e7b87969c7b701a25fbea9ec89bfe Mon Sep 17 00:00:00 2001 From: Tarek El-Sherbiny Date: Mon, 22 Jun 2020 12:20:58 +0100 Subject: [PATCH 6/6] power_domain: Refactor power domain configuration Move element table creation into a separate function to be used by multiple platforms. Change-Id: I410616b18af27bd7c99bdcb0315b1bffb6a805bc Signed-off-by: Tarek El-Sherbiny --- .../power_domain/include/power_domain_utils.h | 61 ++++++++ module/power_domain/src/Makefile | 4 +- module/power_domain/src/power_domain_utils.c | 143 ++++++++++++++++++ .../rddaniel/include/config_power_domain.h | 2 +- product/rddaniel/scp_ramfw/config_clock.c | 4 +- .../rddaniel/scp_ramfw/config_power_domain.c | 98 ++---------- product/rddaniel/scp_ramfw/config_ppu_v1.c | 2 +- product/rddaniel/scp_ramfw/config_smt.c | 4 +- .../rddanielxlr/include/config_power_domain.h | 6 +- product/rddanielxlr/scp_ramfw/config_clock.c | 4 +- .../scp_ramfw/config_power_domain.c | 135 ++--------------- product/rddanielxlr/scp_ramfw/config_ppu_v1.c | 2 +- product/rddanielxlr/scp_ramfw/config_smt.c | 4 +- product/rdn1e1/scp_ramfw/config_clock.c | 4 +- .../rdn1e1/scp_ramfw/config_power_domain.c | 113 ++------------ .../rdn1e1/scp_ramfw/config_power_domain.h | 4 +- product/rdn1e1/scp_ramfw/config_ppu_v1.c | 2 +- product/rdn1e1/scp_ramfw/config_smt.c | 4 +- .../sgi575/scp_ramfw/config_power_domain.c | 106 ++----------- .../sgi575/scp_ramfw/config_power_domain.h | 2 +- product/sgm775/include/sgm775_core.h | 2 + product/sgm775/scp_ramfw/config_clock.c | 5 +- .../sgm775/scp_ramfw/config_power_domain.c | 85 ++--------- .../sgm775/scp_ramfw/config_power_domain.h | 1 - product/sgm775/scp_ramfw/config_ppu_v1.c | 4 +- product/sgm775/scp_ramfw/config_smt.c | 4 +- product/sgm775/src/sgm775_core.c | 5 + product/sgm776/include/sgm776_core.h | 2 + product/sgm776/scp_ramfw/config_clock.c | 5 +- .../sgm776/scp_ramfw/config_power_domain.c | 92 +++-------- .../sgm776/scp_ramfw/config_power_domain.h | 1 - product/sgm776/scp_ramfw/config_ppu_v1.c | 32 ++-- product/sgm776/scp_ramfw/config_ppu_v1.h | 13 +- product/sgm776/scp_ramfw/config_smt.c | 4 +- product/sgm776/src/sgm776_core.c | 5 + .../synquacer/scp_ramfw/config_power_domain.c | 113 ++------------ product/tc0/include/config_power_domain.h | 3 +- product/tc0/scp_ramfw/config_clock.c | 4 +- product/tc0/scp_ramfw/config_power_domain.c | 98 ++---------- product/tc0/scp_ramfw/config_ppu_v1.c | 2 +- product/tc0/scp_ramfw/config_smt.c | 4 +- 41 files changed, 396 insertions(+), 792 deletions(-) create mode 100644 module/power_domain/include/power_domain_utils.h create mode 100644 module/power_domain/src/power_domain_utils.c diff --git a/module/power_domain/include/power_domain_utils.h b/module/power_domain/include/power_domain_utils.h new file mode 100644 index 000000000..a21603ed7 --- /dev/null +++ b/module/power_domain/include/power_domain_utils.h @@ -0,0 +1,61 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Description: + * Power domain utilities. + */ + +#ifndef POWER_DOMAIN_UTILS_H +#define POWER_DOMAIN_UTILS_H + +/*! + * \addtogroup GroupPowerDomain + * @{ + */ + +#include +#include + +/*! + * \brief Create power domain element table. + * + * \details This function will create power domain element table for an SoC + * that contains the same number of cores for each cluster. Also, all cores + * supports the same state table and all clusters support the same state + * table. Devices power domain configuration other than cores and clusters + * as well as systop should be provided in the static table. + * + * \param core_count Number of cores in the system. + * \param cluster_count Number of clusters in the system. + * \param driver_idx The index of the driver which controls the cores domain. + * \param api_idx The driver api index. + * \param core_state_table The cores state mask table. + * \param core_state_table_size The cores state table size. + * \param cluster_state_table The cluster state mask table. + * \param cluster_state_table_size The cluster state table size. + * \param static_table Power domain static elements for devices and systop. + * \param static_table_size Power domain static table size. + * + * \retval A pointer to the newly created power domain elements table. + * \retval NULL if the table creation failed. + */ +const struct fwk_element *create_power_domain_element_table( + unsigned int core_count, + unsigned int cluster_count, + unsigned int driver_idx, + unsigned int api_idx, + const uint32_t *core_state_table, + size_t core_state_table_size, + const uint32_t *cluster_state_table, + size_t cluster_state_table_size, + struct fwk_element *static_table, + size_t static_table_size); + +/*! + * @} + */ + +#endif /* POWER_DOMAIN_UTILS_H */ diff --git a/module/power_domain/src/Makefile b/module/power_domain/src/Makefile index 41c83cb37..d98b4986a 100644 --- a/module/power_domain/src/Makefile +++ b/module/power_domain/src/Makefile @@ -6,6 +6,8 @@ # BS_LIB_NAME := Power domain -BS_LIB_SOURCES := mod_power_domain.c +BS_LIB_SOURCES := \ + mod_power_domain.c \ + power_domain_utils.c include $(BS_DIR)/lib.mk diff --git a/module/power_domain/src/power_domain_utils.c b/module/power_domain/src/power_domain_utils.c new file mode 100644 index 000000000..ca1e1d44e --- /dev/null +++ b/module/power_domain/src/power_domain_utils.c @@ -0,0 +1,143 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Description: + * Power domain utilities. + */ + +#include +#include +#include +#include +#include + +#include +#include + +/* Maximum power domain name size including the null terminator */ +#define PD_NAME_SIZE 25 +/* Maximum number of cores */ +#define MAX_CORES_COUNT 64 +/* Maximum number of static table elements */ +#define MAX_STATIC_ELEMENTS_COUNT 32 + +static int create_core_cluster_pd_element_table( + struct fwk_element *element_table, + unsigned int core_count, + unsigned int cluster_count, + unsigned int driver_idx, + unsigned int api_idx, + const uint32_t *core_state_table, + size_t core_state_table_size, + const uint32_t *cluster_state_table, + size_t cluster_state_table_size) +{ + struct fwk_element *element; + struct mod_power_domain_element_config *pd_config, *pd_config_table = NULL; + unsigned int core_element_counter = 0; + unsigned int core_idx; + unsigned int cluster_idx; + unsigned int cores_per_clusters = core_count/cluster_count; + + pd_config_table = fwk_mm_calloc(core_count + cluster_count, + sizeof(struct mod_power_domain_element_config)); + if (pd_config_table == NULL) + return FWK_E_NOMEM; + + for (cluster_idx = 0; cluster_idx < cluster_count; cluster_idx++) { + for (core_idx = 0; core_idx < cores_per_clusters; core_idx++) { + element = &element_table[core_element_counter]; + pd_config = &pd_config_table[core_element_counter]; + element->name = fwk_mm_alloc(PD_NAME_SIZE, 1); + snprintf((char *)element->name, PD_NAME_SIZE, "CLUS%uCORE%u", + cluster_idx, core_idx); + element->data = pd_config; + pd_config->attributes.pd_type = MOD_PD_TYPE_CORE; + pd_config->parent_idx = cluster_idx + core_count; + pd_config->driver_id = FWK_ID_ELEMENT(driver_idx, + core_element_counter); + pd_config->api_id = FWK_ID_API(driver_idx, api_idx); + pd_config->allowed_state_mask_table = + core_state_table; + pd_config->allowed_state_mask_table_size = + core_state_table_size; + core_element_counter++; + } + /* Define the cluster configuration */ + element = &element_table[cluster_idx + core_count]; + pd_config = &pd_config_table[cluster_idx + core_count]; + element->name = fwk_mm_alloc(PD_NAME_SIZE, 1); + snprintf((char *)element->name, PD_NAME_SIZE, "CLUS%u", cluster_idx); + element->data = pd_config; + pd_config->attributes.pd_type = MOD_PD_TYPE_CLUSTER; + pd_config->driver_id = FWK_ID_ELEMENT(driver_idx, + cluster_idx + core_count); + pd_config->api_id = FWK_ID_API(driver_idx, api_idx); + pd_config->allowed_state_mask_table = cluster_state_table; + pd_config->allowed_state_mask_table_size = cluster_state_table_size; + } + + return FWK_SUCCESS; +} + +const struct fwk_element *create_power_domain_element_table( + unsigned int core_count, + unsigned int cluster_count, + unsigned int driver_idx, + unsigned int api_idx, + const uint32_t *core_state_table, + size_t core_state_table_size, + const uint32_t *cluster_state_table, + size_t cluster_state_table_size, + struct fwk_element *static_table, + size_t static_table_size) +{ + struct fwk_element *element_table = NULL; + struct mod_power_domain_element_config *pd_config; + unsigned int systop_idx, element_idx; + int status; + + if ((core_count % cluster_count != 0) || + (core_count > MAX_CORES_COUNT) || + (static_table_size > MAX_STATIC_ELEMENTS_COUNT)) + return NULL; + + element_table = fwk_mm_calloc( + core_count + cluster_count + static_table_size + 1, /* Terminator */ + sizeof(struct fwk_element)); + + if (element_table == NULL) + return element_table; + + status = create_core_cluster_pd_element_table( + element_table, + core_count, + cluster_count, + driver_idx, + api_idx, + core_state_table, + core_state_table_size, + cluster_state_table, + cluster_state_table_size); + + if (status != FWK_SUCCESS) + return NULL; + + memcpy(element_table + (core_count + cluster_count), static_table, + static_table_size * sizeof(struct fwk_element)); + + /* Calculate SYSTOP index */ + systop_idx = core_count + cluster_count + static_table_size - 1; + + /* Set Power Domain Parent for all SYSTOP children */ + for (element_idx = core_count; element_idx < systop_idx; element_idx++) { + pd_config = (struct mod_power_domain_element_config *) + element_table[element_idx].data; + pd_config->parent_idx = systop_idx; + } + + return element_table; +} diff --git a/product/rddaniel/include/config_power_domain.h b/product/rddaniel/include/config_power_domain.h index f41666896..ee27f973f 100644 --- a/product/rddaniel/include/config_power_domain.h +++ b/product/rddaniel/include/config_power_domain.h @@ -16,7 +16,7 @@ * - Indexing the SYSTOP children in the power domain tree * * When calculating a power domain element index, use the formula: - * core_count + pd_static_dev_idx + * core_count + cluster_count + pd_static_dev_idx */ enum pd_static_dev_idx { PD_STATIC_DEV_IDX_SYSTOP, diff --git a/product/rddaniel/scp_ramfw/config_clock.c b/product/rddaniel/scp_ramfw/config_clock.c index 628530fb2..fda0e8540 100644 --- a/product/rddaniel/scp_ramfw/config_clock.c +++ b/product/rddaniel/scp_ramfw/config_clock.c @@ -186,7 +186,9 @@ static const struct fwk_element *clock_get_dev_desc_table(fwk_id_t module_id) (struct mod_clock_dev_config *)clock_dev_desc_table[i].data; dev_config->pd_source_id = fwk_id_build_element_id( fwk_module_id_power_domain, - rddaniel_core_get_core_count() + PD_STATIC_DEV_IDX_SYSTOP); + rddaniel_core_get_core_count() + + rddaniel_core_get_cluster_count() + + PD_STATIC_DEV_IDX_SYSTOP); } return clock_dev_desc_table; diff --git a/product/rddaniel/scp_ramfw/config_power_domain.c b/product/rddaniel/scp_ramfw/config_power_domain.c index c27de1561..9d41b7131 100644 --- a/product/rddaniel/scp_ramfw/config_power_domain.c +++ b/product/rddaniel/scp_ramfw/config_power_domain.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -74,92 +75,17 @@ static struct fwk_element rddaniel_power_domain_static_element_table[] = { static const struct fwk_element *rddaniel_power_domain_get_element_table (fwk_id_t module_id) { - struct fwk_element *element_table, *element; - struct mod_power_domain_element_config *pd_config_table, *pd_config; - unsigned int core_idx; - unsigned int cluster_idx; - unsigned int core_count; - unsigned int cluster_count; - unsigned int cluster_offset; - unsigned int core_element_counter = 0; - unsigned int elements_count; - unsigned int systop_idx; - const size_t config_size = sizeof(struct mod_power_domain_element_config); - - core_count = rddaniel_core_get_core_count(); - cluster_count = rddaniel_core_get_cluster_count(); - - elements_count = core_count + cluster_count + - FWK_ARRAY_SIZE(rddaniel_power_domain_static_element_table); - systop_idx = elements_count - 1; - - cluster_offset = core_count; - - element_table = fwk_mm_calloc(elements_count + 1, /* Terminator */ - sizeof(struct fwk_element)); - if (element_table == NULL) - return NULL; - - pd_config_table = fwk_mm_calloc(core_count + cluster_count, config_size); - - for (cluster_idx = 0; cluster_idx < cluster_count; cluster_idx++) { - for (core_idx = 0; - core_idx < rddaniel_core_get_core_per_cluster_count(cluster_idx); - core_idx++) { - - element = &element_table[core_element_counter]; - pd_config = &pd_config_table[core_element_counter]; - - element->name = fwk_mm_alloc(PD_NAME_SIZE, 1); - - snprintf((char *)element->name, PD_NAME_SIZE, "CLUS%uCORE%u", - cluster_idx, core_idx); - - element->data = pd_config; - - pd_config->attributes.pd_type = MOD_PD_TYPE_CORE; - pd_config->parent_idx = cluster_idx + cluster_offset; - pd_config->driver_id = - FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, core_element_counter); - pd_config->api_id = FWK_ID_API( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER); - pd_config->allowed_state_mask_table = - core_pd_allowed_state_mask_table; - pd_config->allowed_state_mask_table_size = - FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table); - core_element_counter++; - } - - /* Define the cluster configuration */ - element = &element_table[cluster_idx + cluster_offset]; - pd_config = &pd_config_table[cluster_idx + cluster_offset]; - - element->name = fwk_mm_alloc(PD_NAME_SIZE, 1); - - snprintf((char *)element->name, PD_NAME_SIZE, "CLUS%u", cluster_idx); - - element->data = pd_config; - - pd_config->attributes.pd_type = MOD_PD_TYPE_CLUSTER; - pd_config->parent_idx = systop_idx; - pd_config->driver_id = - FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, - cluster_idx + cluster_offset); - pd_config->api_id = FWK_ID_API( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER); - pd_config->allowed_state_mask_table = - cluster_pd_allowed_state_mask_table; - pd_config->allowed_state_mask_table_size = - FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table); - } - - memcpy(element_table + core_count + cluster_count, - rddaniel_power_domain_static_element_table, - sizeof(rddaniel_power_domain_static_element_table)); - - return element_table; + return create_power_domain_element_table( + rddaniel_core_get_core_count(), + rddaniel_core_get_cluster_count(), + FWK_MODULE_IDX_PPU_V1, + MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER, + core_pd_allowed_state_mask_table, + FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table), + cluster_pd_allowed_state_mask_table, + FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table), + rddaniel_power_domain_static_element_table, + FWK_ARRAY_SIZE(rddaniel_power_domain_static_element_table)); } /* diff --git a/product/rddaniel/scp_ramfw/config_ppu_v1.c b/product/rddaniel/scp_ramfw/config_ppu_v1.c index a4d12d86e..499d62bd8 100644 --- a/product/rddaniel/scp_ramfw/config_ppu_v1.c +++ b/product/rddaniel/scp_ramfw/config_ppu_v1.c @@ -133,7 +133,7 @@ static const struct fwk_element *ppu_v1_get_element_table(fwk_id_t module_id) */ ppu_v1_config_data.pd_source_id = fwk_id_build_element_id( fwk_module_id_power_domain, - core_count + PD_STATIC_DEV_IDX_SYSTOP); + core_count + cluster_count + PD_STATIC_DEV_IDX_SYSTOP); return element_table; } diff --git a/product/rddaniel/scp_ramfw/config_smt.c b/product/rddaniel/scp_ramfw/config_smt.c index 309e55e56..b5646ed28 100644 --- a/product/rddaniel/scp_ramfw/config_smt.c +++ b/product/rddaniel/scp_ramfw/config_smt.c @@ -44,7 +44,9 @@ static const struct fwk_element *smt_get_element_table(fwk_id_t module_id) for (idx = 0; idx < SCP_RDDANIEL_SCMI_SERVICE_IDX_COUNT; idx++) { config = (struct mod_smt_channel_config *)(smt_element_table[idx].data); config->pd_source_id = FWK_ID_ELEMENT(FWK_MODULE_IDX_POWER_DOMAIN, - rddaniel_core_get_core_count() + PD_STATIC_DEV_IDX_SYSTOP); + rddaniel_core_get_core_count() + + rddaniel_core_get_cluster_count() + + PD_STATIC_DEV_IDX_SYSTOP); } return smt_element_table; diff --git a/product/rddanielxlr/include/config_power_domain.h b/product/rddanielxlr/include/config_power_domain.h index 4ac34231b..8d0775389 100644 --- a/product/rddanielxlr/include/config_power_domain.h +++ b/product/rddanielxlr/include/config_power_domain.h @@ -16,13 +16,9 @@ * - Indexing the SYSTOP children in the power domain tree * * When calculating a power domain element index, use the formula: - * core_count + pd_static_dev_idx + * core_count + cluster_count + pd_static_dev_idx */ enum pd_static_dev_idx { - PD_STATIC_DEV_IDX_CLUSTER0, - PD_STATIC_DEV_IDX_CLUSTER1, - PD_STATIC_DEV_IDX_CLUSTER2, - PD_STATIC_DEV_IDX_CLUSTER3, PD_STATIC_DEV_IDX_SYSTOP, PD_STATIC_DEV_IDX_NONE = UINT32_MAX }; diff --git a/product/rddanielxlr/scp_ramfw/config_clock.c b/product/rddanielxlr/scp_ramfw/config_clock.c index 8dc693912..7e76dafa0 100644 --- a/product/rddanielxlr/scp_ramfw/config_clock.c +++ b/product/rddanielxlr/scp_ramfw/config_clock.c @@ -78,7 +78,9 @@ static const struct fwk_element *clock_get_dev_desc_table(fwk_id_t module_id) (struct mod_clock_dev_config *)clock_dev_desc_table[i].data; dev_config->pd_source_id = fwk_id_build_element_id( fwk_module_id_power_domain, - rddanielxlr_core_get_core_count() + PD_STATIC_DEV_IDX_SYSTOP); + rddanielxlr_core_get_core_count() + + rddanielxlr_core_get_cluster_count() + + PD_STATIC_DEV_IDX_SYSTOP); } return clock_dev_desc_table; diff --git a/product/rddanielxlr/scp_ramfw/config_power_domain.c b/product/rddanielxlr/scp_ramfw/config_power_domain.c index f1e9c8588..2d0c73fde 100644 --- a/product/rddanielxlr/scp_ramfw/config_power_domain.c +++ b/product/rddanielxlr/scp_ramfw/config_power_domain.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -52,54 +53,6 @@ static const struct mod_power_domain_config rddanielxlr_power_domain_config = { 0 }; static struct fwk_element rddanielxlr_power_domain_static_element_table[] = { - [PD_STATIC_DEV_IDX_CLUSTER0] = { - .name = "CLUS0", - .data = &((struct mod_power_domain_element_config) { - .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .api_id = FWK_ID_API_INIT( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), - .allowed_state_mask_table = cluster_pd_allowed_state_mask_table, - .allowed_state_mask_table_size = - FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table) - }), - }, - [PD_STATIC_DEV_IDX_CLUSTER1] = { - .name = "CLUS1", - .data = &((struct mod_power_domain_element_config) { - .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .api_id = FWK_ID_API_INIT( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), - .allowed_state_mask_table = cluster_pd_allowed_state_mask_table, - .allowed_state_mask_table_size = - FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table) - }), - }, - [PD_STATIC_DEV_IDX_CLUSTER2] = { - .name = "CLUS2", - .data = &((struct mod_power_domain_element_config) { - .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .api_id = FWK_ID_API_INIT( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), - .allowed_state_mask_table = cluster_pd_allowed_state_mask_table, - .allowed_state_mask_table_size = - FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table) - }), - }, - [PD_STATIC_DEV_IDX_CLUSTER3] = { - .name = "CLUS3", - .data = &((struct mod_power_domain_element_config) { - .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .api_id = FWK_ID_API_INIT( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), - .allowed_state_mask_table = cluster_pd_allowed_state_mask_table, - .allowed_state_mask_table_size = - FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table) - }), - }, [PD_STATIC_DEV_IDX_SYSTOP] = { .name = "SYSTOP", .data = &((struct mod_power_domain_element_config) { @@ -122,81 +75,17 @@ static struct fwk_element rddanielxlr_power_domain_static_element_table[] = { static const struct fwk_element *rddanielxlr_power_domain_get_element_table (fwk_id_t module_id) { - struct fwk_element *element_table, *element; - struct mod_power_domain_element_config *pd_config_table, *pd_config; - unsigned int core_idx; - unsigned int cluster_idx; - unsigned int cluster_offset = rddanielxlr_core_get_core_count(); - unsigned int core_count; - unsigned int cluster_count; - unsigned int core_element_counter = 0; - unsigned int elements_count; - unsigned int systop_idx; - - core_count = rddanielxlr_core_get_core_count(); - cluster_count = rddanielxlr_core_get_cluster_count(); - - elements_count = core_count + FWK_ARRAY_SIZE( - rddanielxlr_power_domain_static_element_table); - - systop_idx = elements_count - 1; - - element_table = fwk_mm_calloc(elements_count + 1, /* Terminator */ - sizeof(struct fwk_element)); - if (element_table == NULL) - return NULL; - - pd_config_table = fwk_mm_calloc(core_count, sizeof( - struct mod_power_domain_element_config)); - if (pd_config_table == NULL) - return NULL; - - for (cluster_idx = 0; cluster_idx < cluster_count; cluster_idx++) { - for (core_idx = 0; - core_idx < rddanielxlr_core_get_core_per_cluster_count(cluster_idx); - core_idx++) { - - element = &element_table[core_element_counter]; - pd_config = &pd_config_table[core_element_counter]; - - element->name = fwk_mm_alloc(PD_NAME_SIZE, 1); - if (element->name == NULL) - return NULL; - - snprintf((char *)element->name, PD_NAME_SIZE, "CLUS%uCORE%u", - cluster_idx, core_idx); - - element->data = pd_config; - - pd_config->attributes.pd_type = MOD_PD_TYPE_CORE; - pd_config->parent_idx = cluster_offset + cluster_idx; - pd_config->driver_id = - FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, - core_element_counter); - pd_config->api_id = FWK_ID_API( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER); - pd_config->allowed_state_mask_table = - core_pd_allowed_state_mask_table; - pd_config->allowed_state_mask_table_size = - FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table); - core_element_counter++; - } - - /* Define the driver id for the cluster */ - pd_config = (struct mod_power_domain_element_config *) - rddanielxlr_power_domain_static_element_table[cluster_idx].data; - pd_config->parent_idx = systop_idx; - pd_config->driver_id = - FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, - (core_count + cluster_idx)); - } - - memcpy(element_table + core_count, - rddanielxlr_power_domain_static_element_table, - sizeof(rddanielxlr_power_domain_static_element_table)); - - return element_table; + return create_power_domain_element_table( + rddanielxlr_core_get_core_count(), + rddanielxlr_core_get_cluster_count(), + FWK_MODULE_IDX_PPU_V1, + MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER, + core_pd_allowed_state_mask_table, + FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table), + cluster_pd_allowed_state_mask_table, + FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table), + rddanielxlr_power_domain_static_element_table, + FWK_ARRAY_SIZE(rddanielxlr_power_domain_static_element_table)); } /* diff --git a/product/rddanielxlr/scp_ramfw/config_ppu_v1.c b/product/rddanielxlr/scp_ramfw/config_ppu_v1.c index 95f2f3eb4..720203d32 100644 --- a/product/rddanielxlr/scp_ramfw/config_ppu_v1.c +++ b/product/rddanielxlr/scp_ramfw/config_ppu_v1.c @@ -141,7 +141,7 @@ static const struct fwk_element *ppu_v1_get_element_table(fwk_id_t module_id) */ ppu_v1_config_data.pd_source_id = fwk_id_build_element_id( fwk_module_id_power_domain, - core_count + PD_STATIC_DEV_IDX_SYSTOP); + core_count + cluster_count + PD_STATIC_DEV_IDX_SYSTOP); return element_table; } diff --git a/product/rddanielxlr/scp_ramfw/config_smt.c b/product/rddanielxlr/scp_ramfw/config_smt.c index 443f4b1f9..c0aa13e72 100644 --- a/product/rddanielxlr/scp_ramfw/config_smt.c +++ b/product/rddanielxlr/scp_ramfw/config_smt.c @@ -44,7 +44,9 @@ static const struct fwk_element *smt_get_element_table(fwk_id_t module_id) for (idx = 0; idx < SCP_RDDANIELXLR_SCMI_SERVICE_IDX_COUNT; idx++) { config = (struct mod_smt_channel_config *)(smt_element_table[idx].data); config->pd_source_id = FWK_ID_ELEMENT(FWK_MODULE_IDX_POWER_DOMAIN, - rddanielxlr_core_get_core_count() + PD_STATIC_DEV_IDX_SYSTOP); + rddanielxlr_core_get_core_count() + + rddanielxlr_core_get_cluster_count() + + PD_STATIC_DEV_IDX_SYSTOP); } return smt_element_table; diff --git a/product/rdn1e1/scp_ramfw/config_clock.c b/product/rdn1e1/scp_ramfw/config_clock.c index 9daad5b33..1c4eba73c 100644 --- a/product/rdn1e1/scp_ramfw/config_clock.c +++ b/product/rdn1e1/scp_ramfw/config_clock.c @@ -60,7 +60,9 @@ static const struct fwk_element *clock_get_dev_desc_table(fwk_id_t module_id) (struct mod_clock_dev_config *)clock_dev_desc_table[i].data; dev_config->pd_source_id = fwk_id_build_element_id( fwk_module_id_power_domain, - rdn1e1_core_get_core_count() + PD_STATIC_DEV_IDX_SYSTOP); + rdn1e1_core_get_core_count() + + rdn1e1_core_get_cluster_count() + + PD_STATIC_DEV_IDX_SYSTOP); } return clock_dev_desc_table; diff --git a/product/rdn1e1/scp_ramfw/config_power_domain.c b/product/rdn1e1/scp_ramfw/config_power_domain.c index 49534b3f2..54cfb713c 100644 --- a/product/rdn1e1/scp_ramfw/config_power_domain.c +++ b/product/rdn1e1/scp_ramfw/config_power_domain.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -76,30 +77,6 @@ static const struct mod_power_domain_config rdn1e1_power_domain_config = { 0 }; static struct fwk_element rdn1e1_power_domain_static_element_table[] = { - [PD_STATIC_DEV_IDX_CLUSTER0] = { - .name = "CLUS0", - .data = &((struct mod_power_domain_element_config) { - .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .api_id = FWK_ID_API_INIT( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), - .allowed_state_mask_table = cluster_pd_allowed_state_mask_table, - .allowed_state_mask_table_size = - FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table) - }), - }, - [PD_STATIC_DEV_IDX_CLUSTER1] = { - .name = "CLUS1", - .data = &((struct mod_power_domain_element_config) { - .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .api_id = FWK_ID_API_INIT( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), - .allowed_state_mask_table = cluster_pd_allowed_state_mask_table, - .allowed_state_mask_table_size = - FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table) - }), - }, [PD_STATIC_DEV_IDX_DBGTOP] = { .name = "DBGTOP", .data = &((struct mod_power_domain_element_config) { @@ -134,83 +111,17 @@ static struct fwk_element rdn1e1_power_domain_static_element_table[] = { static const struct fwk_element *rdn1e1_power_domain_get_element_table (fwk_id_t module_id) { - struct fwk_element *element_table, *element; - struct mod_power_domain_element_config *pd_config_table, *pd_config; - unsigned int core_idx; - unsigned int cluster_idx; - unsigned int cluster_offset = rdn1e1_core_get_core_count(); - unsigned int core_count; - unsigned int cluster_count; - unsigned int core_element_counter = 0; - unsigned int elements_count; - unsigned int systop_idx; - - core_count = rdn1e1_core_get_core_count(); - cluster_count = rdn1e1_core_get_cluster_count(); - - elements_count = core_count + - FWK_ARRAY_SIZE(rdn1e1_power_domain_static_element_table); - systop_idx = elements_count - 1; - - element_table = fwk_mm_calloc(elements_count + 1, /* Terminator */ - sizeof(struct fwk_element)); - if (element_table == NULL) - return NULL; - - pd_config_table = fwk_mm_calloc(core_count, - sizeof(struct mod_power_domain_element_config)); - if (pd_config_table == NULL) - return NULL; - - for (cluster_idx = 0; cluster_idx < cluster_count; cluster_idx++) { - for (core_idx = 0; - core_idx < rdn1e1_core_get_core_per_cluster_count(cluster_idx); - core_idx++) { - - element = &element_table[core_element_counter]; - pd_config = &pd_config_table[core_element_counter]; - - element->name = fwk_mm_alloc(PD_NAME_SIZE, 1); - - snprintf((char *)element->name, PD_NAME_SIZE, "CLUS%uCORE%u", - cluster_idx, core_idx); - - element->data = pd_config; - - pd_config->attributes.pd_type = MOD_PD_TYPE_CORE; - pd_config->parent_idx = cluster_idx + cluster_offset; - pd_config->driver_id = - FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, - core_element_counter); - pd_config->api_id = FWK_ID_API( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER); - pd_config->allowed_state_mask_table = - core_pd_allowed_state_mask_table; - pd_config->allowed_state_mask_table_size = - FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table); - core_element_counter++; - } - - /* Define the driver id for the cluster */ - pd_config = (struct mod_power_domain_element_config *) - rdn1e1_power_domain_static_element_table[cluster_idx].data; - pd_config->parent_idx = systop_idx; - pd_config->driver_id = - FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, - (core_count + cluster_idx)); - } - - /* Set debug config */ - pd_config = (struct mod_power_domain_element_config *) - rdn1e1_power_domain_static_element_table[PD_STATIC_DEV_IDX_DBGTOP].data; - pd_config->parent_idx = systop_idx; - - memcpy(element_table + core_count, - rdn1e1_power_domain_static_element_table, - sizeof(rdn1e1_power_domain_static_element_table)); - - return element_table; + return create_power_domain_element_table( + rdn1e1_core_get_core_count(), + rdn1e1_core_get_cluster_count(), + FWK_MODULE_IDX_PPU_V1, + MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER, + core_pd_allowed_state_mask_table, + FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table), + cluster_pd_allowed_state_mask_table, + FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table), + rdn1e1_power_domain_static_element_table, + FWK_ARRAY_SIZE(rdn1e1_power_domain_static_element_table)); } /* diff --git a/product/rdn1e1/scp_ramfw/config_power_domain.h b/product/rdn1e1/scp_ramfw/config_power_domain.h index a47d6fd05..580e2fe5b 100644 --- a/product/rdn1e1/scp_ramfw/config_power_domain.h +++ b/product/rdn1e1/scp_ramfw/config_power_domain.h @@ -15,11 +15,9 @@ * - Indexing the SYSTOP children in the power domain tree * * When calculating a power domain element index, use the formula: - * core_count + pd_static_dev_idx + * core_count + cluster_count + pd_static_dev_idx */ enum pd_static_dev_idx { - PD_STATIC_DEV_IDX_CLUSTER0, - PD_STATIC_DEV_IDX_CLUSTER1, PD_STATIC_DEV_IDX_DBGTOP, PD_STATIC_DEV_IDX_SYSTOP, PD_STATIC_DEV_IDX_NONE = UINT32_MAX diff --git a/product/rdn1e1/scp_ramfw/config_ppu_v1.c b/product/rdn1e1/scp_ramfw/config_ppu_v1.c index 4aad1cce1..dbd8b4e3a 100644 --- a/product/rdn1e1/scp_ramfw/config_ppu_v1.c +++ b/product/rdn1e1/scp_ramfw/config_ppu_v1.c @@ -143,7 +143,7 @@ static const struct fwk_element *ppu_v1_get_element_table(fwk_id_t module_id) */ ppu_v1_config_data.pd_source_id = fwk_id_build_element_id( fwk_module_id_power_domain, - core_count + PD_STATIC_DEV_IDX_SYSTOP); + core_count + cluster_count + PD_STATIC_DEV_IDX_SYSTOP); return element_table; } diff --git a/product/rdn1e1/scp_ramfw/config_smt.c b/product/rdn1e1/scp_ramfw/config_smt.c index 4518a5371..279d40da3 100644 --- a/product/rdn1e1/scp_ramfw/config_smt.c +++ b/product/rdn1e1/scp_ramfw/config_smt.c @@ -56,7 +56,9 @@ static const struct fwk_element *smt_get_element_table(fwk_id_t module_id) for (idx = 0; idx < SCP_RDN1E1_SCMI_SERVICE_IDX_COUNT; idx++) { config = (struct mod_smt_channel_config *)(smt_element_table[idx].data); config->pd_source_id = FWK_ID_ELEMENT(FWK_MODULE_IDX_POWER_DOMAIN, - rdn1e1_core_get_core_count() + PD_STATIC_DEV_IDX_SYSTOP); + rdn1e1_core_get_core_count() + + rdn1e1_core_get_cluster_count() + + PD_STATIC_DEV_IDX_SYSTOP); } return smt_element_table; diff --git a/product/sgi575/scp_ramfw/config_power_domain.c b/product/sgi575/scp_ramfw/config_power_domain.c index 7b86d62c4..726645276 100644 --- a/product/sgi575/scp_ramfw/config_power_domain.c +++ b/product/sgi575/scp_ramfw/config_power_domain.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -109,100 +110,17 @@ static struct fwk_element sgi575_power_domain_static_element_table[] = { static const struct fwk_element *sgi575_power_domain_get_element_table (fwk_id_t module_id) { - struct fwk_element *element_table, *element; - struct mod_power_domain_element_config *pd_config_table, *pd_config; - unsigned int core_idx; - unsigned int cluster_idx; - unsigned int core_count; - unsigned int cluster_count; - unsigned int cluster_offset; - unsigned int core_element_counter = 0; - unsigned int elements_count; - unsigned int systop_idx; - - core_count = sgi575_core_get_core_count(); - cluster_count = sgi575_core_get_cluster_count(); - - elements_count = core_count + cluster_count + - FWK_ARRAY_SIZE(sgi575_power_domain_static_element_table); - - systop_idx = elements_count - 1; - - cluster_offset = core_count; - - element_table = fwk_mm_calloc(elements_count + 1, /* Terminator */ - sizeof(struct fwk_element)); - if (element_table == NULL) - return NULL; - - pd_config_table = fwk_mm_calloc(core_count + cluster_count, - sizeof(struct mod_power_domain_element_config)); - - for (cluster_idx = 0; cluster_idx < cluster_count; cluster_idx++) { - for (core_idx = 0; - core_idx < sgi575_core_get_core_per_cluster_count(cluster_idx); - core_idx++) { - - element = &element_table[core_element_counter]; - pd_config = &pd_config_table[core_element_counter]; - - element->name = fwk_mm_alloc(PD_NAME_SIZE, 1); - - snprintf((char *)element->name, PD_NAME_SIZE, "CLUS%uCORE%u", - cluster_idx, core_idx); - - element->data = pd_config; - - pd_config->attributes.pd_type = MOD_PD_TYPE_CORE; - pd_config->parent_idx = cluster_idx + cluster_offset; - pd_config->driver_id = - FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, - core_element_counter); - pd_config->api_id = FWK_ID_API( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER); - pd_config->allowed_state_mask_table = - core_pd_allowed_state_mask_table; - pd_config->allowed_state_mask_table_size = - FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table); - core_element_counter++; - } - - /* Define the cluster configuration */ - element = &element_table[cluster_idx + cluster_offset]; - pd_config = &pd_config_table[cluster_idx + cluster_offset]; - - element->name = fwk_mm_alloc(PD_NAME_SIZE, 1); - - snprintf((char *)element->name, PD_NAME_SIZE, "CLUS%u", cluster_idx); - - element->data = pd_config; - - pd_config->attributes.pd_type = MOD_PD_TYPE_CLUSTER; - pd_config->parent_idx = systop_idx; - pd_config->driver_id = - FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, - cluster_idx + cluster_offset); - pd_config->api_id = FWK_ID_API( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER); - pd_config->allowed_state_mask_table = - cluster_pd_allowed_state_mask_table; - pd_config->allowed_state_mask_table_size = - FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table); - } - - /* Set debug config */ - pd_config = (struct mod_power_domain_element_config *) - sgi575_power_domain_static_element_table[PD_STATIC_DEV_IDX_DBGTOP] - .data; - pd_config->parent_idx = systop_idx; - - memcpy(element_table + core_count + cluster_count, - sgi575_power_domain_static_element_table, - sizeof(sgi575_power_domain_static_element_table)); - - return element_table; + return create_power_domain_element_table( + sgi575_core_get_core_count(), + sgi575_core_get_cluster_count(), + FWK_MODULE_IDX_PPU_V1, + MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER, + core_pd_allowed_state_mask_table, + FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table), + cluster_pd_allowed_state_mask_table, + FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table), + sgi575_power_domain_static_element_table, + FWK_ARRAY_SIZE(sgi575_power_domain_static_element_table)); } /* diff --git a/product/sgi575/scp_ramfw/config_power_domain.h b/product/sgi575/scp_ramfw/config_power_domain.h index e6de52bd7..f18258623 100644 --- a/product/sgi575/scp_ramfw/config_power_domain.h +++ b/product/sgi575/scp_ramfw/config_power_domain.h @@ -15,7 +15,7 @@ * - Indexing the SYSTOP children in the power domain tree * * When calculating a power domain element index, use the formula: - * core_count + pd_static_dev_idx + * core_count + cluster_count + pd_static_dev_idx */ enum pd_static_dev_idx { PD_STATIC_DEV_IDX_DBGTOP, diff --git a/product/sgm775/include/sgm775_core.h b/product/sgm775/include/sgm775_core.h index 8984e1663..7ff3f44e9 100644 --- a/product/sgm775/include/sgm775_core.h +++ b/product/sgm775/include/sgm775_core.h @@ -9,7 +9,9 @@ #define SGM775_CORE_H #define SGM775_CORE_PER_CLUSTER_MAX 8 +#define SGM775_CLUSTER_COUNT 1 unsigned int sgm775_core_get_count(void); +unsigned int sgm775_cluster_get_count(void); #endif /* SGM775_CORE_H */ diff --git a/product/sgm775/scp_ramfw/config_clock.c b/product/sgm775/scp_ramfw/config_clock.c index 8665bc506..fe7cb2498 100644 --- a/product/sgm775/scp_ramfw/config_clock.c +++ b/product/sgm775/scp_ramfw/config_clock.c @@ -91,10 +91,11 @@ static struct fwk_element clock_dev_desc_table[] = { static const struct fwk_element *clock_get_dev_desc_table(fwk_id_t module_id) { unsigned int i; - unsigned int core_count; + unsigned int core_count, cluster_count; struct mod_clock_dev_config *dev_config; core_count = sgm775_core_get_count(); + cluster_count = sgm775_cluster_get_count(); /* Configure all clocks to respond to changes in SYSTOP power state */ for (i = 0; i < CLOCK_DEV_IDX_COUNT; i++) { @@ -102,7 +103,7 @@ static const struct fwk_element *clock_get_dev_desc_table(fwk_id_t module_id) (struct mod_clock_dev_config *)clock_dev_desc_table[i].data; dev_config->pd_source_id = FWK_ID_ELEMENT( FWK_MODULE_IDX_POWER_DOMAIN, - CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM + core_count); + CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM + core_count + cluster_count); } return clock_dev_desc_table; diff --git a/product/sgm775/scp_ramfw/config_power_domain.c b/product/sgm775/scp_ramfw/config_power_domain.c index f56d178d5..4eb401e5e 100644 --- a/product/sgm775/scp_ramfw/config_power_domain.c +++ b/product/sgm775/scp_ramfw/config_power_domain.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -23,11 +24,6 @@ #include #include -static const char *core_pd_name_table[SGM775_CORE_PER_CLUSTER_MAX] = { - "CLUS0CORE0", "CLUS0CORE1", "CLUS0CORE2", "CLUS0CORE3", - "CLUS0CORE4", "CLUS0CORE5", "CLUS0CORE6", "CLUS0CORE7", -}; - /* Mask of the allowed states for the systop power domain */ static const uint32_t systop_allowed_state_mask_table[] = { [0] = MOD_PD_STATE_OFF_MASK | MOD_PD_STATE_ON_MASK | @@ -73,17 +69,6 @@ static const uint32_t core_pd_allowed_state_mask_table[] = { static const struct mod_power_domain_config sgm775_power_domain_config = { 0 }; static struct fwk_element sgm775_power_domain_static_element_table[] = { - [CONFIG_POWER_DOMAIN_SYSTOP_CHILD_CLUSTER0] = { - .name = "CLUS0", - .data = &((struct mod_power_domain_element_config) { - .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), - .allowed_state_mask_table = cluster_pd_allowed_state_mask_table, - .allowed_state_mask_table_size = - FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table) - }), - }, [CONFIG_POWER_DOMAIN_SYSTOP_CHILD_DBGTOP] = { .name = "DBGTOP", .data = &((struct mod_power_domain_element_config) { @@ -166,63 +151,17 @@ static struct fwk_element sgm775_power_domain_static_element_table[] = { static const struct fwk_element *sgm775_power_domain_get_element_table (fwk_id_t module_id) { - struct fwk_element *element_table, *element; - struct mod_power_domain_element_config *pd_config_table, *pd_config; - unsigned int core_idx, i; - unsigned int cluster_offset = sgm775_core_get_count(); - unsigned int systop_idx; - unsigned int elements_count; - - elements_count = sgm775_core_get_count() + - FWK_ARRAY_SIZE(sgm775_power_domain_static_element_table); - - systop_idx = elements_count - 1; - - element_table = fwk_mm_calloc(elements_count + 1, /* Terminator */ - sizeof(struct fwk_element)); - - pd_config_table = fwk_mm_calloc(sgm775_core_get_count(), - sizeof(struct mod_power_domain_element_config)); - - for (core_idx = 0; core_idx < sgm775_core_get_count(); core_idx++) { - element = &element_table[core_idx]; - pd_config = &pd_config_table[core_idx]; - - element->name = core_pd_name_table[core_idx]; - element->data = pd_config; - - pd_config->attributes.pd_type = MOD_PD_TYPE_CORE, - pd_config->parent_idx = cluster_offset, - pd_config->driver_id = FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, core_idx), - pd_config->api_id = FWK_ID_API( - FWK_MODULE_IDX_PPU_V1, MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), - pd_config->allowed_state_mask_table = core_pd_allowed_state_mask_table, - pd_config->allowed_state_mask_table_size = - FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table); - } - - pd_config = (struct mod_power_domain_element_config *) - sgm775_power_domain_static_element_table - [CONFIG_POWER_DOMAIN_SYSTOP_CHILD_CLUSTER0] - .data; - pd_config->driver_id = - FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, sgm775_core_get_count()); - - /* Set the parent for all level one domains */ - for (i = 0; - i < (FWK_ARRAY_SIZE(sgm775_power_domain_static_element_table) - 1); - i++) { - - pd_config = (struct mod_power_domain_element_config *) - sgm775_power_domain_static_element_table[i].data; - pd_config->parent_idx = systop_idx; - } - - memcpy(element_table + sgm775_core_get_count(), - sgm775_power_domain_static_element_table, - sizeof(sgm775_power_domain_static_element_table)); - - return element_table; + return create_power_domain_element_table( + sgm775_core_get_count(), + sgm775_cluster_get_count(), + FWK_MODULE_IDX_PPU_V1, + MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER, + core_pd_allowed_state_mask_table, + FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table), + cluster_pd_allowed_state_mask_table, + FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table), + sgm775_power_domain_static_element_table, + FWK_ARRAY_SIZE(sgm775_power_domain_static_element_table)); } /* diff --git a/product/sgm775/scp_ramfw/config_power_domain.h b/product/sgm775/scp_ramfw/config_power_domain.h index c8926e10e..2dc9c66ec 100644 --- a/product/sgm775/scp_ramfw/config_power_domain.h +++ b/product/sgm775/scp_ramfw/config_power_domain.h @@ -11,7 +11,6 @@ #include enum systop_child_index { - CONFIG_POWER_DOMAIN_SYSTOP_CHILD_CLUSTER0, CONFIG_POWER_DOMAIN_SYSTOP_CHILD_DBGTOP, CONFIG_POWER_DOMAIN_SYSTOP_CHILD_DPU0TOP, CONFIG_POWER_DOMAIN_SYSTOP_CHILD_DPU1TOP, diff --git a/product/sgm775/scp_ramfw/config_ppu_v1.c b/product/sgm775/scp_ramfw/config_ppu_v1.c index 56ca96404..ca2bee610 100644 --- a/product/sgm775/scp_ramfw/config_ppu_v1.c +++ b/product/sgm775/scp_ramfw/config_ppu_v1.c @@ -93,7 +93,9 @@ static const struct fwk_element *sgm775_ppu_v1_get_element_table sgm775_ppu_v1_notification_config.pd_source_id = FWK_ID_ELEMENT( FWK_MODULE_IDX_POWER_DOMAIN, - CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM + sgm775_core_get_count()); + CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM + + sgm775_core_get_count() + + sgm775_cluster_get_count()); return element_table; } diff --git a/product/sgm775/scp_ramfw/config_smt.c b/product/sgm775/scp_ramfw/config_smt.c index 9d2369e35..c55ee829c 100644 --- a/product/sgm775/scp_ramfw/config_smt.c +++ b/product/sgm775/scp_ramfw/config_smt.c @@ -68,7 +68,9 @@ static const struct fwk_element *smt_get_element_table(fwk_id_t module_id) for (idx = 0; idx < SGM775_SCMI_SERVICE_IDX_COUNT; idx++) { config = (struct mod_smt_channel_config *)(smt_element_table[idx].data); config->pd_source_id = FWK_ID_ELEMENT(FWK_MODULE_IDX_POWER_DOMAIN, - CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM + sgm775_core_get_count()); + CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM + + sgm775_core_get_count() + + sgm775_cluster_get_count()); } return smt_element_table; diff --git a/product/sgm775/src/sgm775_core.c b/product/sgm775/src/sgm775_core.c index 8cac171c4..7bcb4a058 100644 --- a/product/sgm775/src/sgm775_core.c +++ b/product/sgm775/src/sgm775_core.c @@ -13,3 +13,8 @@ unsigned int sgm775_core_get_count(void) { return (PIK_CLUS0->PIK_CONFIG & PIK_CPU_V8_2_PIK_CONFIG_NO_OF_PPU) - 1; } + +unsigned int sgm775_cluster_get_count(void) +{ + return SGM775_CLUSTER_COUNT; +} diff --git a/product/sgm776/include/sgm776_core.h b/product/sgm776/include/sgm776_core.h index ef0ccac0b..928d9103c 100644 --- a/product/sgm776/include/sgm776_core.h +++ b/product/sgm776/include/sgm776_core.h @@ -9,7 +9,9 @@ #define SGM776_CORE_H #define SGM776_CORE_PER_CLUSTER_MAX 8 +#define SGM776_CLUSTER_COUNT 1 unsigned int sgm776_core_get_count(void); +unsigned int sgm776_cluster_get_count(void); #endif /* SGM776_CORE_H */ diff --git a/product/sgm776/scp_ramfw/config_clock.c b/product/sgm776/scp_ramfw/config_clock.c index f338acad2..f9263f48f 100644 --- a/product/sgm776/scp_ramfw/config_clock.c +++ b/product/sgm776/scp_ramfw/config_clock.c @@ -91,10 +91,11 @@ static const struct fwk_element clock_dev_desc_table[] = { static const struct fwk_element *clock_get_dev_desc_table(fwk_id_t module_id) { unsigned int i; - unsigned int core_count; + unsigned int core_count, cluster_count; struct mod_clock_dev_config *dev_config; core_count = sgm776_core_get_count(); + cluster_count = sgm776_cluster_get_count(); /* Configure all clocks to respond to changes in SYSTOP power state */ for (i = 0; i < CLOCK_DEV_IDX_COUNT; i++) { @@ -102,7 +103,7 @@ static const struct fwk_element *clock_get_dev_desc_table(fwk_id_t module_id) (struct mod_clock_dev_config *)clock_dev_desc_table[i].data; dev_config->pd_source_id = FWK_ID_ELEMENT( FWK_MODULE_IDX_POWER_DOMAIN, - CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM + core_count); + CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM + core_count + cluster_count); } return clock_dev_desc_table; diff --git a/product/sgm776/scp_ramfw/config_power_domain.c b/product/sgm776/scp_ramfw/config_power_domain.c index 846cfd01f..b8a2c400b 100644 --- a/product/sgm776/scp_ramfw/config_power_domain.c +++ b/product/sgm776/scp_ramfw/config_power_domain.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -23,11 +24,6 @@ #include #include -static const char *core_pd_name_table[SGM776_CORE_PER_CLUSTER_MAX] = { - "CLUS0CORE0", "CLUS0CORE1", "CLUS0CORE2", "CLUS0CORE3", - "CLUS0CORE4", "CLUS0CORE5", "CLUS0CORE6", "CLUS0CORE7", -}; - /* Mask of the allowed states for the systop power domain */ static const uint32_t systop_allowed_state_mask_table[] = { [0] = MOD_PD_STATE_OFF_MASK | MOD_PD_STATE_ON_MASK | @@ -70,17 +66,6 @@ static const uint32_t core_pd_allowed_state_mask_table[] = { static const struct mod_power_domain_config sgm776_power_domain_config = { 0 }; static struct fwk_element sgm776_power_domain_static_element_table[] = { - [CONFIG_POWER_DOMAIN_SYSTOP_CHILD_CLUSTER0] = { - .name = "CLUS0", - .data = &((struct mod_power_domain_element_config) { - .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), - .allowed_state_mask_table = cluster_pd_allowed_state_mask_table, - .allowed_state_mask_table_size = - FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table) - }), - }, [CONFIG_POWER_DOMAIN_SYSTOP_CHILD_DBGTOP] = { .name = "DBGTOP", .data = &((struct mod_power_domain_element_config) { @@ -159,65 +144,32 @@ static struct fwk_element sgm776_power_domain_static_element_table[] = { static const struct fwk_element *sgm776_power_domain_get_element_table (fwk_id_t module_id) { - struct fwk_element *element_table, *element; - struct mod_power_domain_element_config *pd_config_table, *pd_config; - unsigned int core_idx, i; - unsigned int cluster_offset = sgm776_core_get_count(); - unsigned int systop_idx; - unsigned int elements_count; - - elements_count = sgm776_core_get_count() + - FWK_ARRAY_SIZE(sgm776_power_domain_static_element_table); - - systop_idx = elements_count - 1; - - element_table = fwk_mm_calloc(elements_count + 1, /* Terminator */ - sizeof(struct fwk_element)); - - pd_config_table = fwk_mm_calloc(sgm776_core_get_count(), - sizeof(struct mod_power_domain_element_config)); - - for (core_idx = 0; core_idx < sgm776_core_get_count(); core_idx++) { - element = &element_table[core_idx]; - pd_config = &pd_config_table[core_idx]; - - element->name = core_pd_name_table[core_idx]; - element->data = pd_config; - - pd_config->attributes.pd_type = MOD_PD_TYPE_CORE, - pd_config->parent_idx = cluster_offset, - pd_config->driver_id = FWK_ID_ELEMENT( - FWK_MODULE_IDX_PPU_V1, PPU_V1_ELEMENT_IDX_COUNT + core_idx), - pd_config->api_id = FWK_ID_API( - FWK_MODULE_IDX_PPU_V1, MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), - pd_config->allowed_state_mask_table = core_pd_allowed_state_mask_table, - pd_config->allowed_state_mask_table_size = - FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table); - } - - pd_config = (struct mod_power_domain_element_config *) - sgm776_power_domain_static_element_table - [CONFIG_POWER_DOMAIN_SYSTOP_CHILD_CLUSTER0] - .data; - pd_config->driver_id = - FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, - PPU_V1_ELEMENT_IDX_COUNT + sgm776_core_get_count()); + unsigned int elem_idx; + struct mod_power_domain_element_config *pd_config; + size_t static_table_size = + FWK_ARRAY_SIZE(sgm776_power_domain_static_element_table); - /* Set the parent for all level one domains */ - for (i = 0; - i < (FWK_ARRAY_SIZE(sgm776_power_domain_static_element_table) - 1); - i++) { + for (elem_idx = 0; elem_idx < (static_table_size - 1); elem_idx++) { pd_config = (struct mod_power_domain_element_config *) - sgm776_power_domain_static_element_table[i].data; - pd_config->parent_idx = systop_idx; - } + sgm776_power_domain_static_element_table[elem_idx].data; - memcpy(element_table + sgm776_core_get_count(), - sgm776_power_domain_static_element_table, - sizeof(sgm776_power_domain_static_element_table)); + pd_config->driver_id = FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, + elem_idx + sgm776_core_get_count() + + sgm776_cluster_get_count()); + } - return element_table; + return create_power_domain_element_table( + sgm776_core_get_count(), + sgm776_cluster_get_count(), + FWK_MODULE_IDX_PPU_V1, + MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER, + core_pd_allowed_state_mask_table, + FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table), + cluster_pd_allowed_state_mask_table, + FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table), + sgm776_power_domain_static_element_table, + FWK_ARRAY_SIZE(sgm776_power_domain_static_element_table)); } /* diff --git a/product/sgm776/scp_ramfw/config_power_domain.h b/product/sgm776/scp_ramfw/config_power_domain.h index c75109ab0..e1cba64ac 100644 --- a/product/sgm776/scp_ramfw/config_power_domain.h +++ b/product/sgm776/scp_ramfw/config_power_domain.h @@ -11,7 +11,6 @@ #include enum systop_child_index { - CONFIG_POWER_DOMAIN_SYSTOP_CHILD_CLUSTER0, CONFIG_POWER_DOMAIN_SYSTOP_CHILD_DBGTOP, CONFIG_POWER_DOMAIN_SYSTOP_CHILD_DPUTOP, CONFIG_POWER_DOMAIN_SYSTOP_CHILD_GPUTOP, diff --git a/product/sgm776/scp_ramfw/config_ppu_v1.c b/product/sgm776/scp_ramfw/config_ppu_v1.c index 225ae926d..f49ffa721 100644 --- a/product/sgm776/scp_ramfw/config_ppu_v1.c +++ b/product/sgm776/scp_ramfw/config_ppu_v1.c @@ -50,7 +50,7 @@ struct mod_ppu_v1_config sgm776_ppu_v1_notification_config = { MOD_PD_NOTIFICATION_IDX_POWER_STATE_TRANSITION), }; -static const struct fwk_element static_ppu_table[] = { +static struct fwk_element ppu_table[PPU_V1_ELEMENT_IDX_COUNT + 1] = { [PPU_V1_ELEMENT_IDX_DBGTOP] = { .name = "DBGTOP", .data = &((struct mod_ppu_v1_pd_config) { @@ -108,24 +108,15 @@ static const struct fwk_element static_ppu_table[] = { .observer_id = FWK_ID_NONE_INIT, }), }, + [PPU_V1_ELEMENT_IDX_COUNT] = {0}, }; static const struct fwk_element *sgm776_ppu_v1_get_element_table( fwk_id_t module_id) { - struct fwk_element *element_table, *element; + struct fwk_element *element; struct mod_ppu_v1_pd_config *pd_config_table, *pd_config; - unsigned int core_idx, table_size; - - /* - * Allocate element descriptors based on: - * Size of static ppu table - * + Number of cores - * +1 cluster descriptor - * +1 terminator descriptor - */ - table_size = FWK_ARRAY_SIZE(static_ppu_table) + sgm776_core_get_count() + 2; - element_table = fwk_mm_calloc(table_size, sizeof(struct fwk_element)); + unsigned int core_idx; /* Table to hold configs for all cores and the cluster */ pd_config_table = fwk_mm_calloc(sgm776_core_get_count() + 1, @@ -133,7 +124,7 @@ static const struct fwk_element *sgm776_ppu_v1_get_element_table( /* Cores */ for (core_idx = 0; core_idx < sgm776_core_get_count(); core_idx++) { - element = &element_table[PPU_V1_ELEMENT_IDX_COUNT + core_idx]; + element = &ppu_table[PPU_V1_ELEMENT_IDX_CORE0 + core_idx]; pd_config = &pd_config_table[core_idx]; element->name = core_pd_name_table[core_idx]; @@ -143,11 +134,11 @@ static const struct fwk_element *sgm776_ppu_v1_get_element_table( pd_config->ppu.reg_base = core_pd_ppu_base_table[core_idx]; pd_config->ppu.irq = core_pd_ppu_irq_table[core_idx]; pd_config->cluster_id = FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, - table_size - 2); + PPU_V1_ELEMENT_IDX_CLUSTER); pd_config->observer_id = FWK_ID_NONE; } - element = &element_table[table_size - 2]; + element = &ppu_table[PPU_V1_ELEMENT_IDX_CLUSTER]; pd_config = &pd_config_table[sgm776_core_get_count()]; element->name = "CLUS0"; @@ -158,14 +149,13 @@ static const struct fwk_element *sgm776_ppu_v1_get_element_table( pd_config->ppu.irq = PPU_CLUS0_IRQ; pd_config->observer_id = FWK_ID_NONE; - /* Copy static table to the beginning of the dynamic table */ - memcpy(element_table, static_ppu_table, sizeof(static_ppu_table)); - sgm776_ppu_v1_notification_config.pd_source_id = FWK_ID_ELEMENT( FWK_MODULE_IDX_POWER_DOMAIN, - CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM + sgm776_core_get_count()); + CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM + + sgm776_cluster_get_count() + + sgm776_core_get_count()); - return element_table; + return ppu_table; } /* diff --git a/product/sgm776/scp_ramfw/config_ppu_v1.h b/product/sgm776/scp_ramfw/config_ppu_v1.h index 2cf9c7665..0e8c6cec4 100644 --- a/product/sgm776/scp_ramfw/config_ppu_v1.h +++ b/product/sgm776/scp_ramfw/config_ppu_v1.h @@ -9,12 +9,21 @@ #define CONFIG_PPU_V1_H enum ppu_v1_static_element_idx { + PPU_V1_ELEMENT_IDX_CORE0, + PPU_V1_ELEMENT_IDX_CORE1, + PPU_V1_ELEMENT_IDX_CORE2, + PPU_V1_ELEMENT_IDX_CORE3, + PPU_V1_ELEMENT_IDX_CORE4, + PPU_V1_ELEMENT_IDX_CORE5, + PPU_V1_ELEMENT_IDX_CORE6, + PPU_V1_ELEMENT_IDX_CORE7, + PPU_V1_ELEMENT_IDX_CLUSTER, PPU_V1_ELEMENT_IDX_DBGTOP, - PPU_V1_ELEMENT_IDX_SYS0, - PPU_V1_ELEMENT_IDX_SYS1, PPU_V1_ELEMENT_IDX_DPUTOP, PPU_V1_ELEMENT_IDX_GPUTOP, PPU_V1_ELEMENT_IDX_VPUTOP, + PPU_V1_ELEMENT_IDX_SYS0, + PPU_V1_ELEMENT_IDX_SYS1, PPU_V1_ELEMENT_IDX_COUNT, }; diff --git a/product/sgm776/scp_ramfw/config_smt.c b/product/sgm776/scp_ramfw/config_smt.c index b42eee446..34e5ec5c4 100644 --- a/product/sgm776/scp_ramfw/config_smt.c +++ b/product/sgm776/scp_ramfw/config_smt.c @@ -72,7 +72,9 @@ static const struct fwk_element *smt_get_element_table(fwk_id_t module_id) for (idx = 0; idx < SGM776_SCMI_SERVICE_IDX_COUNT; idx++) { config = (struct mod_smt_channel_config *)(smt_element_table[idx].data); config->pd_source_id = FWK_ID_ELEMENT(FWK_MODULE_IDX_POWER_DOMAIN, - CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM + sgm776_core_get_count()); + CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM + + sgm776_core_get_count() + + sgm776_cluster_get_count()); } return smt_element_table; diff --git a/product/sgm776/src/sgm776_core.c b/product/sgm776/src/sgm776_core.c index c038949d2..6a27d1609 100644 --- a/product/sgm776/src/sgm776_core.c +++ b/product/sgm776/src/sgm776_core.c @@ -13,3 +13,8 @@ unsigned int sgm776_core_get_count(void) { return (PIK_CLUS0->PCL_CONFIG & PIK_CPU_PCL_CONFIG_NO_OF_PPU) - 1; } + +unsigned int sgm776_cluster_get_count(void) +{ + return SGM776_CLUSTER_COUNT; +} diff --git a/product/synquacer/scp_ramfw/config_power_domain.c b/product/synquacer/scp_ramfw/config_power_domain.c index cfc872d35..eca585117 100644 --- a/product/synquacer/scp_ramfw/config_power_domain.c +++ b/product/synquacer/scp_ramfw/config_power_domain.c @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -126,109 +127,17 @@ static struct fwk_element synquacer_power_domain_static_element_table[] = { static const struct fwk_element *synquacer_power_domain_get_element_table( fwk_id_t module_id) { - struct fwk_element *element_table, *element; - struct mod_power_domain_element_config *pd_config_table, *pd_config; - unsigned int core_idx, i; - unsigned int cluster_idx; - unsigned int core_count; - unsigned int cluster_count; - unsigned int core_per_cluster_count; - unsigned int element_counter = 0; - unsigned int total_elements; - unsigned int systop_idx; - - core_count = synquacer_core_get_core_count(); - cluster_count = synquacer_core_get_cluster_count(); - core_per_cluster_count = synquacer_core_get_core_per_cluster_count(); - - total_elements = cluster_count + core_count + - FWK_ARRAY_SIZE( - synquacer_power_domain_static_element_table); - - systop_idx = total_elements - 1; - - element_table = fwk_mm_calloc(total_elements + 1, /* Terminator */ - sizeof(struct fwk_element)); - - pd_config_table = fwk_mm_calloc( - (cluster_count + core_count), - sizeof(struct mod_power_domain_element_config)); - - /* - * power domain element table should follow the ascending order - * of tree position. - * It means first element must be cluster0_core0, - * last element should be system power element(SYSTOP) - */ - /* prepare core config table */ - for (cluster_idx = 0; cluster_idx < cluster_count; cluster_idx++) { - for (core_idx = 0; core_idx < core_per_cluster_count; core_idx++) { - element = &element_table[element_counter]; - pd_config = &pd_config_table[element_counter]; - - element->name = fwk_mm_alloc(PD_NAME_SIZE, 1); - - snprintf( - (char *)element->name, - PD_NAME_SIZE, - "CLUS%uCORE%u", - cluster_idx, - core_idx); - - element->data = pd_config; - - pd_config->attributes.pd_type = MOD_PD_TYPE_CORE; - pd_config->driver_id = - FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V0_SYNQUACER, - element_counter); - pd_config->api_id = FWK_ID_API(FWK_MODULE_IDX_PPU_V0_SYNQUACER, 0); - pd_config->allowed_state_mask_table = - core_pd_allowed_state_mask_table; - pd_config->allowed_state_mask_table_size = - FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table); - element_counter++; - } - } - - /* prepare cluster config table */ - for (cluster_idx = 0; cluster_idx < cluster_count; cluster_idx++) { - element = &element_table[element_counter]; - pd_config = &pd_config_table[element_counter]; - - element->name = fwk_mm_alloc(PD_NAME_SIZE, 1); - - snprintf((char *)element->name, PD_NAME_SIZE, "CLUS%u", cluster_idx); - - element->data = pd_config; - - pd_config->attributes.pd_type = MOD_PD_TYPE_CLUSTER; - pd_config->parent_idx = systop_idx; - pd_config->driver_id = - FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V0_SYNQUACER, element_counter); - pd_config->api_id = FWK_ID_API(FWK_MODULE_IDX_PPU_V0_SYNQUACER, 0); - pd_config->allowed_state_mask_table = - cluster_pd_allowed_state_mask_table; - pd_config->allowed_state_mask_table_size = - FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table); - element_counter++; - } - - /* Set the parent for all level one domains */ - for (i = 0; - i < (FWK_ARRAY_SIZE(synquacer_power_domain_static_element_table) - 1); - i++) { - - pd_config = (struct mod_power_domain_element_config *) - synquacer_power_domain_static_element_table[i].data; - pd_config->parent_idx = systop_idx; - } - - memcpy( - element_table + element_counter, + return create_power_domain_element_table( + synquacer_core_get_core_count(), + synquacer_core_get_cluster_count(), + FWK_MODULE_IDX_PPU_V0_SYNQUACER, + 0, + core_pd_allowed_state_mask_table, + FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table), + cluster_pd_allowed_state_mask_table, + FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table), synquacer_power_domain_static_element_table, - sizeof(synquacer_power_domain_static_element_table)); - - return element_table; + FWK_ARRAY_SIZE(synquacer_power_domain_static_element_table)); } /* diff --git a/product/tc0/include/config_power_domain.h b/product/tc0/include/config_power_domain.h index ba381022a..cd3d2e3dd 100644 --- a/product/tc0/include/config_power_domain.h +++ b/product/tc0/include/config_power_domain.h @@ -16,10 +16,9 @@ * - Indexing the SYSTOP children in the power domain tree * * When calculating a power domain element index, use the formula: - * core_count + pd_static_dev_idx + * core_count + cluster_count + pd_static_dev_idx */ enum pd_static_dev_idx { - PD_STATIC_DEV_IDX_CLUSTER0, PD_STATIC_DEV_IDX_SYSTOP, PD_STATIC_DEV_IDX_COUNT, PD_STATIC_DEV_IDX_NONE = UINT32_MAX diff --git a/product/tc0/scp_ramfw/config_clock.c b/product/tc0/scp_ramfw/config_clock.c index b0d6b47c3..3f3dce79a 100644 --- a/product/tc0/scp_ramfw/config_clock.c +++ b/product/tc0/scp_ramfw/config_clock.c @@ -79,7 +79,9 @@ static const struct fwk_element *clock_get_dev_desc_table(fwk_id_t module_id) (struct mod_clock_dev_config *)clock_dev_desc_table[i].data; dev_config->pd_source_id = fwk_id_build_element_id( fwk_module_id_power_domain, - tc0_core_get_core_count() + PD_STATIC_DEV_IDX_SYSTOP); + tc0_core_get_core_count() + + tc0_core_get_cluster_count() + + PD_STATIC_DEV_IDX_SYSTOP); } return clock_dev_desc_table; diff --git a/product/tc0/scp_ramfw/config_power_domain.c b/product/tc0/scp_ramfw/config_power_domain.c index 29de334eb..7383f396f 100644 --- a/product/tc0/scp_ramfw/config_power_domain.c +++ b/product/tc0/scp_ramfw/config_power_domain.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -52,18 +53,6 @@ static const struct mod_power_domain_config tc0_power_domain_config = { 0 }; static struct fwk_element tc0_power_domain_static_element_table[] = { - [PD_STATIC_DEV_IDX_CLUSTER0] = { - .name = "CLUS0", - .data = &((struct mod_power_domain_element_config) { - .attributes.pd_type = MOD_PD_TYPE_CLUSTER, - .api_id = FWK_ID_API_INIT( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER), - .allowed_state_mask_table = cluster_pd_allowed_state_mask_table, - .allowed_state_mask_table_size = - FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table) - }), - }, [PD_STATIC_DEV_IDX_SYSTOP] = { .name = "SYSTOP", .data = &((struct mod_power_domain_element_config) { @@ -86,80 +75,17 @@ static struct fwk_element tc0_power_domain_static_element_table[] = { static const struct fwk_element *tc0_power_domain_get_element_table (fwk_id_t module_id) { - struct fwk_element *element_table, *element; - struct mod_power_domain_element_config *pd_config_table, *pd_config; - unsigned int core_idx; - unsigned int cluster_idx; - unsigned int cluster_offset; - unsigned int core_count; - unsigned int cluster_count; - unsigned int core_element_counter = 0; - unsigned int elements_count; - unsigned int systop_idx; - - core_count = cluster_offset = tc0_core_get_core_count(); - cluster_count = tc0_core_get_cluster_count(); - - elements_count = core_count + - FWK_ARRAY_SIZE(tc0_power_domain_static_element_table); - - systop_idx = elements_count - 1; - - element_table = fwk_mm_calloc(elements_count + 1, /* Terminator */ - sizeof(struct fwk_element)); - if (element_table == NULL) - return NULL; - - pd_config_table = fwk_mm_calloc(core_count, - sizeof(struct mod_power_domain_element_config)); - if (pd_config_table == NULL) - return NULL; - - for (cluster_idx = 0; cluster_idx < cluster_count; cluster_idx++) { - for (core_idx = 0; - core_idx < tc0_core_get_core_per_cluster_count( - cluster_idx); - core_idx++) { - - element = &element_table[core_element_counter]; - pd_config = &pd_config_table[core_element_counter]; - - element->name = fwk_mm_alloc(PD_NAME_SIZE, 1); - if (element->name == NULL) - return NULL; - - snprintf((char *)element->name, PD_NAME_SIZE, "CLUS%uCORE%u", - cluster_idx, core_idx); - - element->data = pd_config; - - pd_config->attributes.pd_type = MOD_PD_TYPE_CORE; - pd_config->parent_idx = cluster_idx + cluster_offset; - pd_config->driver_id = - FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, core_element_counter); - pd_config->api_id = FWK_ID_API( - FWK_MODULE_IDX_PPU_V1, - MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER); - pd_config->allowed_state_mask_table = - core_pd_allowed_state_mask_table; - pd_config->allowed_state_mask_table_size = - FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table); - core_element_counter++; - } - - /* Define the driver id for the cluster */ - pd_config = (struct mod_power_domain_element_config *) - tc0_power_domain_static_element_table[cluster_idx].data; - pd_config->parent_idx = systop_idx; - pd_config->driver_id = FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, - (core_count + cluster_idx)); - } - - memcpy(element_table + core_count, - tc0_power_domain_static_element_table, - sizeof(tc0_power_domain_static_element_table)); - - return element_table; + return create_power_domain_element_table( + tc0_core_get_core_count(), + tc0_core_get_cluster_count(), + FWK_MODULE_IDX_PPU_V1, + MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER, + core_pd_allowed_state_mask_table, + FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table), + cluster_pd_allowed_state_mask_table, + FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table), + tc0_power_domain_static_element_table, + FWK_ARRAY_SIZE(tc0_power_domain_static_element_table)); } /* diff --git a/product/tc0/scp_ramfw/config_ppu_v1.c b/product/tc0/scp_ramfw/config_ppu_v1.c index 7b4f3310e..9dc013b6d 100644 --- a/product/tc0/scp_ramfw/config_ppu_v1.c +++ b/product/tc0/scp_ramfw/config_ppu_v1.c @@ -141,7 +141,7 @@ static const struct fwk_element *ppu_v1_get_element_table(fwk_id_t module_id) */ ppu_v1_config_data.pd_source_id = fwk_id_build_element_id( fwk_module_id_power_domain, - core_count + PD_STATIC_DEV_IDX_SYSTOP); + core_count + cluster_count + PD_STATIC_DEV_IDX_SYSTOP); return element_table; } diff --git a/product/tc0/scp_ramfw/config_smt.c b/product/tc0/scp_ramfw/config_smt.c index f6300242a..5ae687b37 100644 --- a/product/tc0/scp_ramfw/config_smt.c +++ b/product/tc0/scp_ramfw/config_smt.c @@ -56,7 +56,9 @@ static const struct fwk_element *smt_get_element_table(fwk_id_t module_id) for (idx = 0; idx < SCP_TC0_SCMI_SERVICE_IDX_COUNT; idx++) { config = (struct mod_smt_channel_config *)(smt_element_table[idx].data); config->pd_source_id = FWK_ID_ELEMENT(FWK_MODULE_IDX_POWER_DOMAIN, - tc0_core_get_core_count() + PD_STATIC_DEV_IDX_SYSTOP); + tc0_core_get_core_count() + + tc0_core_get_cluster_count() + + PD_STATIC_DEV_IDX_SYSTOP); } return smt_element_table; -- GitLab