diff --git a/module/power_domain/include/mod_power_domain.h b/module/power_domain/include/mod_power_domain.h index bf2e1f571f9f74e3bc77d681b0103b2d5ccc3275..13daf8c000eba7fbc2b09acc68abaee5918e2eeb 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 @@ -238,6 +158,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 +252,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 }; /*! @@ -550,39 +478,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. @@ -593,22 +488,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 @@ -619,19 +514,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. @@ -649,27 +543,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. * @@ -734,26 +607,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. * @@ -777,8 +630,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/include/power_domain_utils.h b/module/power_domain/include/power_domain_utils.h new file mode 100644 index 0000000000000000000000000000000000000000..a21603ed7fe22890301e364742f6c2635c0a857c --- /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 41c83cb37d1e1d4f51030cceff8ddc91cca70f94..d98b4986a33b8ee8de697b7b2008f1431353e952 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/mod_power_domain.c b/module/power_domain/src/mod_power_domain.c index 6628ab4044f24070ded377f2aa6c857230df20a2..ae68a732bbf7a396fd1471a418d0439ee89d3b6d 100644 --- a/module/power_domain/src/mod_power_domain.c +++ b/module/power_domain/src/mod_power_domain.c @@ -108,20 +108,33 @@ 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; /* - * 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; @@ -267,15 +280,12 @@ 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, + 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, }; /* @@ -293,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) { @@ -404,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; } @@ -426,19 +372,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 +443,29 @@ 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; + + assert(target_pd != NULL); - if (composite_state & (~MOD_PD_CS_VALID_BITS)) + if (!pd->cs_support) goto error; - 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); + + state_mask_table = pd->composite_state_mask_table; + table_size = pd->composite_state_mask_table_size; - if ((highest_level < level) || - (highest_level >= MOD_PD_LEVEL_COUNT)) + if (highest_level >= table_size) goto error; - for (; level <= highest_level; level++) { + for (level = 0; level <= highest_level; 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 +499,24 @@ 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 highest_level, level; const struct pd_ctx *pd; unsigned int state; + const uint32_t *state_mask_table; + + highest_level = get_highest_level_from_composite_state(lowest_pd, + composite_state); - lowest_level = get_level_from_tree_pos(lowest_pd->config->tree_pos); - highest_level = get_highest_level_from_composite_state(composite_state); + if (!lowest_pd->cs_support) + return is_deeper_state(composite_state, lowest_pd->requested_state); - for (level = lowest_level, pd = lowest_pd; level <= highest_level; + state_mask_table = lowest_pd->composite_state_mask_table; + + for (level = 0, pd = lowest_pd; (level <= highest_level) && (pd != NULL); 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; @@ -519,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; @@ -583,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) { @@ -591,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; @@ -764,11 +740,13 @@ 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; 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; @@ -786,15 +764,21 @@ 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); - highest_level = get_highest_level_from_composite_state(composite_state); - nb_pds = highest_level - lowest_level + 1; + lowest_level = 0; + highest_level = get_highest_level_from_composite_state(lowest_pd, + composite_state); + nb_pds = highest_level + 1; status = FWK_SUCCESS; pd = lowest_pd; + + 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) - level = lowest_level + pd_index; + level = pd_index; else { /* * When walking down the power domain tree, get the context of the @@ -806,7 +790,14 @@ static void process_set_state_request( pd = pd->parent; } - state = get_level_state_from_composite_state(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; @@ -911,26 +902,34 @@ 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 * 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 : - 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 @@ -959,28 +958,39 @@ 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; + 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; } @@ -998,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); @@ -1054,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; @@ -1371,11 +1384,10 @@ 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) +static int pd_set_state(fwk_id_t pd_id, uint32_t 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 = @@ -1385,77 +1397,13 @@ static int pd_set_state(fwk_id_t pd_id, unsigned int state) 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) -{ - int status; - struct pd_ctx *pd; - 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_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, @@ -1464,7 +1412,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) @@ -1473,9 +1421,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; @@ -1484,8 +1432,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, @@ -1495,7 +1448,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); } @@ -1533,39 +1486,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; @@ -1699,10 +1619,7 @@ 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, .system_suspend = pd_system_suspend, .system_shutdown = pd_system_shutdown @@ -1710,7 +1627,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, @@ -1742,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; @@ -1751,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; @@ -1778,6 +1682,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; @@ -1788,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/module/power_domain/src/power_domain_utils.c b/module/power_domain/src/power_domain_utils.c new file mode 100644 index 0000000000000000000000000000000000000000..ca1e1d44e2cdd7bb3bf9b2934048ef6445e53b70 --- /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/module/scmi_power_domain/include/internal/scmi_power_domain.h b/module/scmi_power_domain/include/internal/scmi_power_domain.h index 279845cc1ed4486b42d29b6c447a5fdaba6d7200..b7f044a2bc0d7d4cc74523704d30158458affa1f 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 220596f444583ec6792ca9afa419ab3170ff0f6a..a0b122fefc17a9a742b4c6108f47f3aadac14866 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; @@ -212,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; } @@ -367,8 +356,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))", @@ -521,7 +510,9 @@ 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_state_async(pd_id, false, + pd_power_state); break; case MOD_PD_TYPE_SYSTEM: @@ -581,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; 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 b60813a46c1bc9ce9c5728340c72148465c0cd26..9add1395e747d89a42e30a0f16a7add418c66f99 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 3e9304fa73380c40f598e6477c636a7dd4db3ce5..d021d305f50a7f0700261506e954725e91ff5038 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 8885c089772ab6b1cde07149838ce8ad6693b2cc..ce489b4b8561c375e1cefb05fb6a6c63bb06021a 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/juno/scp_ramfw/config_power_domain.c b/product/juno/scp_ramfw/config_power_domain.c index 291a2712454b871386cedefa89b73356e1f9d823..af2bc650dd376e151462a25c4bb2466df779d548 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 7ef130fc5996acdf1dad1ba26e20e1e3d1e72f2d..80875818bb95009a08ced1e0c33d1c110f27bb11 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/module/n1sdp_c2c/src/mod_n1sdp_c2c_i2c.c b/product/n1sdp/module/n1sdp_c2c/src/mod_n1sdp_c2c_i2c.c index 15f56f18e87bd00a9640b4631d58d77b024ec9be..79e1c031980c459c7578d8c10c61dc0835a90a28 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 17bec939462c1506795d071a1ecbe579424c5baf..27cbf9928261e07e97c69c0757018515b321cf69 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/n1sdp/scp_ramfw/config_power_domain.c b/product/n1sdp/scp_ramfw/config_power_domain.c index 21aa763d975f489c7babe4f14d6fcde014ffa13b..a0eb552de438bccfaed3af9eaa3a8f9915a17655 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 8d24c56ae7bcf49ef4aa13d428f4cde78cf110e7..cf394820044f77a5ffd8f0a3609de25b393dce04 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 4cdfd64b885c4fe0467bea54d9530c8b170bfa84..ee27f973fa4ce15e908d42b0828bd71f2ace65d3 100644 --- a/product/rddaniel/include/config_power_domain.h +++ b/product/rddaniel/include/config_power_domain.h @@ -8,33 +8,19 @@ #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 * - 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_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/module/rddaniel_system/src/mod_rddaniel_system.c b/product/rddaniel/module/rddaniel_system/src/mod_rddaniel_system.c index 5910986c20767e4927fa5062e0c90d0c8f8d8572..036e11a3f16a7bb1d4140f46d2d9efda2770643e 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/rddaniel/scp_ramfw/config_clock.c b/product/rddaniel/scp_ramfw/config_clock.c index 628530fb27d91cf15bc276eb77227405feca568e..fda0e854020ac70cb9257064b3fa38418b76dc9b 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 b62b6eabdb24e3ca04625a4ca4f540ff3fe3bd14..9d41b713117356759aacad5f918ccdec80b57929 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 @@ -52,236 +53,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, @@ -299,70 +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 core_element_count = 0; - - 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)); - - pd_config_table = fwk_mm_calloc(core_count, - sizeof(struct mod_power_domain_element_config)); - - 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->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->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_V1, - core_element_count); - 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_count++; - } - - /* Define the driver id for the cluster */ - pd_config = (struct mod_power_domain_element_config *) - rddaniel_power_domain_static_element_table[cluster_idx].data; - pd_config->driver_id = - FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, - (core_count + cluster_idx)); - } - - memcpy(element_table + core_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 a4d12d86e114c70b5b8fea7d9523522f9d0ba021..499d62bd8c33f7b60a300535bce4bda213a15f0b 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 309e55e561d9befafad4288c674390156feca611..b5646ed2898e233273e4f4df91412973d9367641 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 720abdb1ada552ab41611914ec6606603eccb4cd..8d07753895bce91d95e1b28e33fcd51d4b6573b4 100644 --- a/product/rddanielxlr/include/config_power_domain.h +++ b/product/rddanielxlr/include/config_power_domain.h @@ -8,21 +8,19 @@ #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 * - 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_COUNT + PD_STATIC_DEV_IDX_NONE = UINT32_MAX }; #endif /* CONFIG_POWER_DOMAIN_H */ 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 162307643e33be2b36f67153d30a8e151e6c61cd..fdd2f3c0614c4e6e934569605546ad3a959901c2 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/rddanielxlr/scp_ramfw/config_clock.c b/product/rddanielxlr/scp_ramfw/config_clock.c index 8dc693912d8b985cdef384c8359ce4e4b9f09fd2..7e76dafa0893db4deaf91a6c944033a530a06838 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 54c68a80a031b55903dab26a55c6e2646fc40cb7..2d0c73fdeeeb8034d39db577b0525276928579b2 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,68 +53,11 @@ 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, - .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_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, @@ -131,76 +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 core_count; - unsigned int cluster_count; - unsigned int core_element_count = 0; - - 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)); - 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_count]; - pd_config = &pd_config_table[core_element_count]; - - 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->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_V1, - core_element_count); - 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_count++; - } - - /* 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->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 95f2f3eb47a4853556b9f4a563958f9064ec589b..720203d32a7f5bb09c883400078a72feafe0e9cc 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 443f4b1f948dd88d9b0c51f8ae2aa6ed3576cfe8..c0aa13e72643d4a399ba52f01126ced50888b830 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/module/rdn1e1_system/src/mod_rdn1e1_system.c b/product/rdn1e1/module/rdn1e1_system/src/mod_rdn1e1_system.c index f38508d145d2b3f0811a6c5bbfb1094d19367abd..f99e76382f103d54afe0fdf8b2496a6d758664c6 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/rdn1e1/scp_ramfw/config_clock.c b/product/rdn1e1/scp_ramfw/config_clock.c index 9daad5b33b20bb6330d302068c79111e8bb925ac..1c4eba73c4af50ca3269ebef86a82c2529b8513b 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 7e62817bd3b6020351f866108727f18196acbeff..54cfb713c16829e719ab7dddd364366bd70ff293 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,40 +77,10 @@ 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, - .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), @@ -122,8 +93,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, @@ -141,70 +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 core_count; - unsigned int cluster_count; - unsigned int core_element_count = 0; - - 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 */ - sizeof(struct fwk_element)); - - pd_config_table = fwk_mm_calloc(core_count, - sizeof(struct mod_power_domain_element_config)); - - 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->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->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_V1, - core_element_count); - 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_count++; - } - - /* 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->driver_id = - FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, - (core_count + cluster_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 dfaf8ca273e1f7cb4b6bf6ff3d97d075fbe1c898..580e2fe5b108530b31ab59c2d6b030f7b88da6b8 100644 --- a/product/rdn1e1/scp_ramfw/config_power_domain.h +++ b/product/rdn1e1/scp_ramfw/config_power_domain.h @@ -8,20 +8,19 @@ #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 * - 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_COUNT + PD_STATIC_DEV_IDX_NONE = UINT32_MAX }; #endif /* CONFIG_POWER_DOMAIN_H */ diff --git a/product/rdn1e1/scp_ramfw/config_ppu_v1.c b/product/rdn1e1/scp_ramfw/config_ppu_v1.c index 4aad1cce142706ad50d52f2b4db8bd15fb931e2d..dbd8b4e3a16ebb5f9bec970a411672e031deb651 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 4518a537186ac001c8cc5726288cf18f139edaaa..279d40da34efc2ec9a2785cd6b290f6a63e5baab 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/module/sgi575_system/src/mod_sgi575_system.c b/product/sgi575/module/sgi575_system/src/mod_sgi575_system.c index 76d8b00f128cb91b9cee26431cd4bfa49d638f08..d7b0818a3d64512c1af95d6c0a93da2dc5f843d8 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/sgi575/scp_ramfw/config_clock.c b/product/sgi575/scp_ramfw/config_clock.c index 916446b531ac6e1e7e3a58e132ffeab84e494200..ee7ca8cf3b18e98499ee204d5c349d45de8bba65 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 51c53bc4061671fce3e7ca531cadc9373292dda0..7266452766ed34c7d21f97eaa0b20e4a27b04f0d 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 @@ -75,40 +76,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 +92,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, @@ -140,72 +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 core_element_count = 0; - - 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)); - if (element_table == NULL) - return NULL; - - pd_config_table = fwk_mm_calloc(core_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->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->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_V1, - core_element_count); - 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_count++; - } - - /* Define the driver id for the cluster */ - pd_config = (struct mod_power_domain_element_config *) - sgi575_power_domain_static_element_table[cluster_idx].data; - pd_config->driver_id = - FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, - (core_count + cluster_idx)); - } - - memcpy(element_table + core_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 e65be28ce93d6569eb1e3e7af5dd3b9405bbe1e3..f18258623e3ec63bde542aab247ac76c0226dae8 100644 --- a/product/sgi575/scp_ramfw/config_power_domain.h +++ b/product/sgi575/scp_ramfw/config_power_domain.h @@ -8,20 +8,19 @@ #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 * - 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_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 d6419853ad1dfa24877d49429a89bbd0702b597c..211f88fdf7b527513c822d6e83f6b8849ad84869 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 cc3f16f4e5b487bfe0b802fcdb3e5789b35082e0..91b3e7c7345b7a1a3273343f5486fc52c7e8ea6c 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/include/sgm775_core.h b/product/sgm775/include/sgm775_core.h index 8984e166362951cc5d03633238591e40536a112f..7ff3f44e9d02a18c710332cadd417a1c87a7645a 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 84d3b29ae5baf32f782aec0abc3cfcb76c06f294..fe7cb24981391dac70ac60114b3de10c4be5b6f3 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_CHILD_COUNT + 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 4aa040a5bc6d4733bc6f697c944f2391d8dca0d7..4eb401e5e1ac8118da9052042af54193bbb3f618 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,33 +69,10 @@ 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, - .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, - .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) { .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 +85,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 +97,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 +109,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 +121,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 +129,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), @@ -203,53 +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; - - element_table = fwk_mm_calloc( - sgm775_core_get_count() - + FWK_ARRAY_SIZE(sgm775_power_domain_static_element_table) - + 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->tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_0, - 0, - 0, - CONFIG_POWER_DOMAIN_SYSTOP_CHILD_CLUSTER0, - core_idx), - 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()); - - 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 fc0738674b6e635f2c3a7621135112d6e640e0b7..2dc9c66ecaeefe2b77022b282d247b3e0c2705fa 100644 --- a/product/sgm775/scp_ramfw/config_power_domain.h +++ b/product/sgm775/scp_ramfw/config_power_domain.h @@ -8,14 +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_DPU0TOP, 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 f13dc3f08c6724cd88ac92f2ed4550a16844e2be..ca2bee610fcffdd91771041ed1faf2fda0e4334b 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_CHILD_COUNT + 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 67e646d2c981457da560a20d181569051c72331f..c55ee829c461f400af3d54a57458f449a49b174c 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_CHILD_COUNT + 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 8cac171c41780455fbf838f5ccc87edcb6a406da..7bcb4a05871b79828c276d4628e6cc8f17f13c2e 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 ef0ccac0be6097c5d0358227417450e4dfbe03ea..928d9103cdea532ba901e769b2780258cc2ca8c1 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 b39763f89c3d38cec91184e5a54104f361bcd7aa..f9263f48fc170297bad70767513a668a8d4595de 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_CHILD_COUNT + 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 df69d520e1b5ba82dc1d5cb2f064960475eed271..b8a2c400baefdcd485f6168e81378fcbdd887c46 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,33 +66,10 @@ 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, - .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, - .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) { .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 +84,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 +98,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 +112,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 +122,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), @@ -190,55 +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; - - element_table = fwk_mm_calloc( - sgm776_core_get_count() - + FWK_ARRAY_SIZE(sgm776_power_domain_static_element_table) - + 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->tree_pos = MOD_PD_TREE_POS( - MOD_PD_LEVEL_0, - 0, - 0, - CONFIG_POWER_DOMAIN_SYSTOP_CHILD_CLUSTER0, - core_idx), - 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); - } + 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); - 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()); + for (elem_idx = 0; elem_idx < (static_table_size - 1); elem_idx++) { - memcpy(element_table + sgm776_core_get_count(), - sgm776_power_domain_static_element_table, - sizeof(sgm776_power_domain_static_element_table)); + pd_config = (struct mod_power_domain_element_config *) + sgm776_power_domain_static_element_table[elem_idx].data; + + 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 a510220b9c004a69ec805ce6cdf83d2a64d21c90..e1cba64acfaee537b00ecb8a6002b62d364ad6d3 100644 --- a/product/sgm776/scp_ramfw/config_power_domain.h +++ b/product/sgm776/scp_ramfw/config_power_domain.h @@ -8,13 +8,15 @@ #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 049d4a18b3932a761fe1f5bffb539066cd89fdc8..f49ffa72143e253c9e350f6bdd105b8d70bcb062 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_CHILD_COUNT + 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 2cf9c766563f80429c23ff41370da90ebf0c905a..0e8c6cec46a14a38d85048331012a2b615f582e0 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 8131cce43aa7c4d947dfe4ee0588285893b1f8a4..34e5ec5c468b6011e2300c8498b60e142fa54100 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_CHILD_COUNT + 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 c038949d26ee3f36abefd935b3aef10eea95b584..6a27d1609233cbd2ad453e8d15797c0670b1bc1b 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/module/synquacer_system/src/synquacer_main.c b/product/synquacer/module/synquacer_system/src/synquacer_main.c index 893690b7261c550f73c9228719d53d845d4e2bd8..d871a5315f6d9d79a06eda1ed483322870a869ca 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/synquacer/scp_ramfw/config_power_domain.c b/product/synquacer/scp_ramfw/config_power_domain.c index fa7438155c2346539df449543535d4b36221bd84..eca58511762e3eb75b45200c9096e95e7803c894 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 @@ -61,7 +62,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 +74,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 +86,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 +101,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 +113,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,102 +122,22 @@ 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( 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 core_per_cluster_count; - unsigned int element_count = 0; - - 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 */ - 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_count]; - pd_config = &pd_config_table[element_count]; - - 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->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); - 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++; - } - } - - /* 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->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->tree_pos = - MOD_PD_TREE_POS(MOD_PD_LEVEL_1, 0, 0, cluster_idx, 0); - pd_config->driver_id = - FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V0_SYNQUACER, element_count); - 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++; - } - - memcpy( - element_table + element_count, + 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/synquacer/scp_ramfw/config_power_domain.h b/product/synquacer/scp_ramfw/config_power_domain.h index 152cc5a0c3e3c45ec6aedae9531d972b97fefa1c..235d290abba3a283b8ae85eb164482bed5a52ae0 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 a85ea581fc82db437031088c54e988a758602690..cd3d2e3dd2d9f52c92430b59fb114d09f25e82d2 100644 --- a/product/tc0/include/config_power_domain.h +++ b/product/tc0/include/config_power_domain.h @@ -8,18 +8,20 @@ #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 * - 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_COUNT, + PD_STATIC_DEV_IDX_NONE = UINT32_MAX }; #endif /* CONFIG_POWER_DOMAIN_H */ 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 1036e8ae2cfdaf6e8ff7bdaffe0ae0b2aca090d9..be593c9cdc5adab9f75f9bbb76bc014b964adbf0 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)); diff --git a/product/tc0/scp_ramfw/config_clock.c b/product/tc0/scp_ramfw/config_clock.c index b0d6b47c376b9dfbc84ead09ecc979fc49621b31..3f3dce79a016888932b2cb9039584843d2e1c00f 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 bd0428836e597403833e0b3ba33835535ecee4d9..7383f396f5c430e72cc6b529d1b4b432871ab47a 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,26 +53,11 @@ 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, - .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_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, @@ -89,77 +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 core_count; - unsigned int cluster_count; - unsigned int core_element_count = 0; - - core_count = 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 */ - 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_count]; - pd_config = &pd_config_table[core_element_count]; - - 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->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_V1, - core_element_count); - 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_count++; - } - - /* 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)); - } - - 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 7b4f3310e23d14ad4d7a2f1132975cef38d444a9..9dc013b6df6b4b54c4157b6fa4a0210c97043768 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 f6300242abe645f23977b1251f4878d6631f3483..5ae687b3750554efc5f0e2d060a54d8f3fb40494 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;