aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTarek El-Sherbiny <tarek.el-sherbiny@arm.com>2020-06-22 12:20:58 +0100
committerjimqui01 <54316584+jimqui01@users.noreply.github.com>2020-07-07 11:16:06 +0100
commit49d7283b6c4da50b05759ad28e16240b0e36a8a8 (patch)
tree41e36206897dbe1bd520171ffecc6292f0d13e07
parent9c47494027dd4286be4306d2be829b98d026363d (diff)
power_domain: Refactor power domain configuration
Move element table creation into a separate function to be used by multiple platforms. Change-Id: I410616b18af27bd7c99bdcb0315b1bffb6a805bc Signed-off-by: Tarek El-Sherbiny <tarek.el-sherbiny@arm.com>
-rw-r--r--module/power_domain/include/power_domain_utils.h61
-rw-r--r--module/power_domain/src/Makefile4
-rw-r--r--module/power_domain/src/power_domain_utils.c149
-rw-r--r--product/rddaniel/include/config_power_domain.h2
-rw-r--r--product/rddaniel/scp_ramfw/config_clock.c3
-rw-r--r--product/rddaniel/scp_ramfw/config_power_domain.c96
-rw-r--r--product/rddaniel/scp_ramfw/config_ppu_v1.c2
-rw-r--r--product/rddaniel/scp_ramfw/config_smt.c6
-rw-r--r--product/rddanielxlr/include/config_power_domain.h6
-rw-r--r--product/rddanielxlr/scp_ramfw/config_clock.c4
-rw-r--r--product/rddanielxlr/scp_ramfw/config_power_domain.c136
-rw-r--r--product/rddanielxlr/scp_ramfw/config_ppu_v1.c2
-rw-r--r--product/rddanielxlr/scp_ramfw/config_smt.c7
-rw-r--r--product/rdn1e1/scp_ramfw/config_clock.c3
-rw-r--r--product/rdn1e1/scp_ramfw/config_power_domain.c115
-rw-r--r--product/rdn1e1/scp_ramfw/config_power_domain.h4
-rw-r--r--product/rdn1e1/scp_ramfw/config_ppu_v1.c2
-rw-r--r--product/rdn1e1/scp_ramfw/config_smt.c6
-rw-r--r--product/sgi575/scp_ramfw/config_power_domain.c105
-rw-r--r--product/sgi575/scp_ramfw/config_power_domain.h2
-rw-r--r--product/sgm775/include/sgm775_core.h2
-rw-r--r--product/sgm775/scp_ramfw/config_clock.c5
-rw-r--r--product/sgm775/scp_ramfw/config_power_domain.c87
-rw-r--r--product/sgm775/scp_ramfw/config_power_domain.h1
-rw-r--r--product/sgm775/scp_ramfw/config_ppu_v1.c3
-rw-r--r--product/sgm775/scp_ramfw/config_smt.c4
-rw-r--r--product/sgm775/src/sgm775_core.c5
-rw-r--r--product/sgm776/include/sgm776_core.h2
-rw-r--r--product/sgm776/scp_ramfw/config_clock.c5
-rw-r--r--product/sgm776/scp_ramfw/config_power_domain.c92
-rw-r--r--product/sgm776/scp_ramfw/config_power_domain.h1
-rw-r--r--product/sgm776/scp_ramfw/config_ppu_v1.c33
-rw-r--r--product/sgm776/scp_ramfw/config_ppu_v1.h13
-rw-r--r--product/sgm776/scp_ramfw/config_smt.c4
-rw-r--r--product/sgm776/src/sgm776_core.c5
-rw-r--r--product/synquacer/scp_ramfw/config_power_domain.c113
-rw-r--r--product/tc0/include/config_power_domain.h3
-rw-r--r--product/tc0/scp_ramfw/config_clock.c3
-rw-r--r--product/tc0/scp_ramfw/config_power_domain.c99
-rw-r--r--product/tc0/scp_ramfw/config_ppu_v1.c2
-rw-r--r--product/tc0/scp_ramfw/config_smt.c6
41 files changed, 408 insertions, 795 deletions
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 00000000..a21603ed
--- /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 <fwk_element.h>
+#include <fwk_id.h>
+
+/*!
+ * \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 41c83cb3..d98b4986 100644
--- a/module/power_domain/src/Makefile
+++ b/module/power_domain/src/Makefile
@@ -6,6 +6,8 @@
#
BS_LIB_NAME := Power domain
-BS_LIB_SOURCES := mod_power_domain.c
+BS_LIB_SOURCES := \
+ mod_power_domain.c \
+ power_domain_utils.c
include $(BS_DIR)/lib.mk
diff --git a/module/power_domain/src/power_domain_utils.c b/module/power_domain/src/power_domain_utils.c
new file mode 100644
index 00000000..8f026e9f
--- /dev/null
+++ b/module/power_domain/src/power_domain_utils.c
@@ -0,0 +1,149 @@
+/*
+ * 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 <mod_power_domain.h>
+
+#include <fwk_element.h>
+#include <fwk_id.h>
+#include <fwk_mm.h>
+#include <fwk_status.h>
+
+#include <stdio.h>
+#include <string.h>
+
+/* Maximum power domain name size including the null terminator */
+#define PD_NAME_SIZE 25
+/* Maximum number of cores */
+#define MAX_CORES_COUNT 64
+/* Maximum number of static table elements */
+#define MAX_STATIC_ELEMENTS_COUNT 32
+
+static int create_core_cluster_pd_element_table(
+ struct fwk_element *element_table,
+ unsigned int core_count,
+ unsigned int cluster_count,
+ unsigned int driver_idx,
+ unsigned int api_idx,
+ const uint32_t *core_state_table,
+ size_t core_state_table_size,
+ const uint32_t *cluster_state_table,
+ size_t cluster_state_table_size)
+{
+ struct fwk_element *element;
+ struct mod_power_domain_element_config *pd_config, *pd_config_table = NULL;
+ unsigned int core_element_counter = 0;
+ unsigned int core_idx;
+ unsigned int cluster_idx;
+ unsigned int cores_per_clusters = core_count / cluster_count;
+
+ pd_config_table = fwk_mm_calloc(
+ core_count + cluster_count,
+ sizeof(struct mod_power_domain_element_config));
+ if (pd_config_table == NULL)
+ return FWK_E_NOMEM;
+
+ for (cluster_idx = 0; cluster_idx < cluster_count; cluster_idx++) {
+ for (core_idx = 0; core_idx < cores_per_clusters; core_idx++) {
+ element = &element_table[core_element_counter];
+ pd_config = &pd_config_table[core_element_counter];
+ element->name = fwk_mm_alloc(PD_NAME_SIZE, 1);
+ snprintf(
+ (char *)element->name,
+ PD_NAME_SIZE,
+ "CLUS%uCORE%u",
+ cluster_idx,
+ core_idx);
+ element->data = pd_config;
+ pd_config->attributes.pd_type = MOD_PD_TYPE_CORE;
+ pd_config->parent_idx = cluster_idx + core_count;
+ pd_config->driver_id =
+ FWK_ID_ELEMENT(driver_idx, core_element_counter);
+ pd_config->api_id = FWK_ID_API(driver_idx, api_idx);
+ pd_config->allowed_state_mask_table = core_state_table;
+ pd_config->allowed_state_mask_table_size = core_state_table_size;
+ core_element_counter++;
+ }
+ /* Define the cluster configuration */
+ element = &element_table[cluster_idx + core_count];
+ pd_config = &pd_config_table[cluster_idx + core_count];
+ element->name = fwk_mm_alloc(PD_NAME_SIZE, 1);
+ snprintf((char *)element->name, PD_NAME_SIZE, "CLUS%u", cluster_idx);
+ element->data = pd_config;
+ pd_config->attributes.pd_type = MOD_PD_TYPE_CLUSTER;
+ pd_config->driver_id =
+ FWK_ID_ELEMENT(driver_idx, cluster_idx + core_count);
+ pd_config->api_id = FWK_ID_API(driver_idx, api_idx);
+ pd_config->allowed_state_mask_table = cluster_state_table;
+ pd_config->allowed_state_mask_table_size = cluster_state_table_size;
+ }
+
+ return FWK_SUCCESS;
+}
+
+const struct fwk_element *create_power_domain_element_table(
+ unsigned int core_count,
+ unsigned int cluster_count,
+ unsigned int driver_idx,
+ unsigned int api_idx,
+ const uint32_t *core_state_table,
+ size_t core_state_table_size,
+ const uint32_t *cluster_state_table,
+ size_t cluster_state_table_size,
+ struct fwk_element *static_table,
+ size_t static_table_size)
+{
+ struct fwk_element *element_table = NULL;
+ struct mod_power_domain_element_config *pd_config;
+ unsigned int systop_idx, element_idx;
+ int status;
+
+ if ((core_count % cluster_count != 0) || (core_count > MAX_CORES_COUNT) ||
+ (static_table_size > MAX_STATIC_ELEMENTS_COUNT))
+ return NULL;
+
+ element_table = fwk_mm_calloc(
+ core_count + cluster_count + static_table_size + 1, /* Terminator */
+ sizeof(struct fwk_element));
+
+ if (element_table == NULL)
+ return element_table;
+
+ status = create_core_cluster_pd_element_table(
+ element_table,
+ core_count,
+ cluster_count,
+ driver_idx,
+ api_idx,
+ core_state_table,
+ core_state_table_size,
+ cluster_state_table,
+ cluster_state_table_size);
+
+ if (status != FWK_SUCCESS)
+ return NULL;
+
+ memcpy(
+ element_table + (core_count + cluster_count),
+ static_table,
+ static_table_size * sizeof(struct fwk_element));
+
+ /* Calculate SYSTOP index */
+ systop_idx = core_count + cluster_count + static_table_size - 1;
+
+ /* Set Power Domain Parent for all SYSTOP children */
+ for (element_idx = core_count; element_idx < systop_idx; element_idx++) {
+ pd_config =
+ (struct mod_power_domain_element_config *)element_table[element_idx]
+ .data;
+ pd_config->parent_idx = systop_idx;
+ }
+
+ return element_table;
+}
diff --git a/product/rddaniel/include/config_power_domain.h b/product/rddaniel/include/config_power_domain.h
index f4166689..ee27f973 100644
--- a/product/rddaniel/include/config_power_domain.h
+++ b/product/rddaniel/include/config_power_domain.h
@@ -16,7 +16,7 @@
* - Indexing the SYSTOP children in the power domain tree
*
* When calculating a power domain element index, use the formula:
- * core_count + pd_static_dev_idx
+ * core_count + cluster_count + pd_static_dev_idx
*/
enum pd_static_dev_idx {
PD_STATIC_DEV_IDX_SYSTOP,
diff --git a/product/rddaniel/scp_ramfw/config_clock.c b/product/rddaniel/scp_ramfw/config_clock.c
index 628530fb..c38cf70d 100644
--- a/product/rddaniel/scp_ramfw/config_clock.c
+++ b/product/rddaniel/scp_ramfw/config_clock.c
@@ -186,7 +186,8 @@ 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 ce451a28..c99b8e7d 100644
--- a/product/rddaniel/scp_ramfw/config_power_domain.c
+++ b/product/rddaniel/scp_ramfw/config_power_domain.c
@@ -9,6 +9,8 @@
#include "rddaniel_core.h"
#include "rddaniel_power_domain.h"
+#include <power_domain_utils.h>
+
#include <mod_power_domain.h>
#include <mod_ppu_v1.h>
#include <mod_system_power.h>
@@ -74,91 +76,17 @@ static struct fwk_element rddaniel_power_domain_static_element_table[] = {
static const struct fwk_element *rddaniel_power_domain_get_element_table
(fwk_id_t module_id)
{
- struct fwk_element *element_table, *element;
- struct mod_power_domain_element_config *pd_config_table, *pd_config;
- unsigned int core_idx;
- unsigned int cluster_idx;
- unsigned int core_count;
- unsigned int cluster_count;
- unsigned int cluster_offset;
- unsigned int core_element_counter = 0;
- unsigned int elements_count;
- unsigned int systop_idx;
- const size_t config_size = sizeof(struct mod_power_domain_element_config);
-
- core_count = rddaniel_core_get_core_count();
- cluster_count = rddaniel_core_get_cluster_count();
-
- elements_count = core_count + cluster_count +
- FWK_ARRAY_SIZE(rddaniel_power_domain_static_element_table);
- systop_idx = elements_count - 1;
-
- cluster_offset = core_count;
-
- element_table = fwk_mm_calloc(
- elements_count + 1, /* Terminator */
- sizeof(struct fwk_element));
- if (element_table == NULL)
- return NULL;
-
- pd_config_table = fwk_mm_calloc(core_count + cluster_count, config_size);
-
- for (cluster_idx = 0; cluster_idx < cluster_count; cluster_idx++) {
- for (core_idx = 0;
- core_idx < rddaniel_core_get_core_per_cluster_count(cluster_idx);
- core_idx++) {
- element = &element_table[core_element_counter];
- pd_config = &pd_config_table[core_element_counter];
-
- element->name = fwk_mm_alloc(PD_NAME_SIZE, 1);
-
- snprintf((char *)element->name, PD_NAME_SIZE, "CLUS%uCORE%u",
- cluster_idx, core_idx);
-
- element->data = pd_config;
-
- pd_config->attributes.pd_type = MOD_PD_TYPE_CORE;
- pd_config->parent_idx = cluster_idx + cluster_offset;
- pd_config->driver_id =
- FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, core_element_counter);
- pd_config->api_id = FWK_ID_API(
- FWK_MODULE_IDX_PPU_V1,
- MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER);
- pd_config->allowed_state_mask_table =
- core_pd_allowed_state_mask_table;
- pd_config->allowed_state_mask_table_size =
- FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table);
- core_element_counter++;
- }
-
- /* Define the cluster configuration */
- element = &element_table[cluster_idx + cluster_offset];
- pd_config = &pd_config_table[cluster_idx + cluster_offset];
-
- element->name = fwk_mm_alloc(PD_NAME_SIZE, 1);
-
- snprintf((char *)element->name, PD_NAME_SIZE, "CLUS%u", cluster_idx);
-
- element->data = pd_config;
-
- pd_config->attributes.pd_type = MOD_PD_TYPE_CLUSTER;
- pd_config->parent_idx = systop_idx;
- pd_config->driver_id =
- FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, cluster_idx + cluster_offset);
- pd_config->api_id = FWK_ID_API(
- FWK_MODULE_IDX_PPU_V1, MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER);
- pd_config->allowed_state_mask_table =
- cluster_pd_allowed_state_mask_table;
- pd_config->allowed_state_mask_table_size =
- FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table);
- }
-
- memcpy(
- element_table + core_count + cluster_count,
+ 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,
- sizeof(rddaniel_power_domain_static_element_table));
-
- return 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 a4d12d86..499d62bd 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 309e55e5..0368e895 100644
--- a/product/rddaniel/scp_ramfw/config_smt.c
+++ b/product/rddaniel/scp_ramfw/config_smt.c
@@ -43,8 +43,10 @@ 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);
+ config->pd_source_id = FWK_ID_ELEMENT(
+ FWK_MODULE_IDX_POWER_DOMAIN,
+ 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 4ac34231..8d077538 100644
--- a/product/rddanielxlr/include/config_power_domain.h
+++ b/product/rddanielxlr/include/config_power_domain.h
@@ -16,13 +16,9 @@
* - Indexing the SYSTOP children in the power domain tree
*
* When calculating a power domain element index, use the formula:
- * core_count + pd_static_dev_idx
+ * core_count + cluster_count + pd_static_dev_idx
*/
enum pd_static_dev_idx {
- PD_STATIC_DEV_IDX_CLUSTER0,
- PD_STATIC_DEV_IDX_CLUSTER1,
- PD_STATIC_DEV_IDX_CLUSTER2,
- PD_STATIC_DEV_IDX_CLUSTER3,
PD_STATIC_DEV_IDX_SYSTOP,
PD_STATIC_DEV_IDX_NONE = UINT32_MAX
};
diff --git a/product/rddanielxlr/scp_ramfw/config_clock.c b/product/rddanielxlr/scp_ramfw/config_clock.c
index 8dc69391..3f549082 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 e8b46961..bd2df525 100644
--- a/product/rddanielxlr/scp_ramfw/config_power_domain.c
+++ b/product/rddanielxlr/scp_ramfw/config_power_domain.c
@@ -8,6 +8,8 @@
#include "rddanielxlr_core.h"
#include "rddanielxlr_power_domain.h"
+#include <power_domain_utils.h>
+
#include <mod_power_domain.h>
#include <mod_ppu_v1.h>
#include <mod_system_power.h>
@@ -23,7 +25,6 @@
#include <stdio.h>
#include <string.h>
-
/* Maximum power domain name size including the null terminator */
#define PD_NAME_SIZE 12
@@ -52,54 +53,6 @@ static const struct mod_power_domain_config
rddanielxlr_power_domain_config = { 0 };
static struct fwk_element rddanielxlr_power_domain_static_element_table[] = {
- [PD_STATIC_DEV_IDX_CLUSTER0] = {
- .name = "CLUS0",
- .data = &((struct mod_power_domain_element_config) {
- .attributes.pd_type = MOD_PD_TYPE_CLUSTER,
- .api_id = FWK_ID_API_INIT(
- FWK_MODULE_IDX_PPU_V1,
- MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER),
- .allowed_state_mask_table = cluster_pd_allowed_state_mask_table,
- .allowed_state_mask_table_size =
- FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table)
- }),
- },
- [PD_STATIC_DEV_IDX_CLUSTER1] = {
- .name = "CLUS1",
- .data = &((struct mod_power_domain_element_config) {
- .attributes.pd_type = MOD_PD_TYPE_CLUSTER,
- .api_id = FWK_ID_API_INIT(
- FWK_MODULE_IDX_PPU_V1,
- MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER),
- .allowed_state_mask_table = cluster_pd_allowed_state_mask_table,
- .allowed_state_mask_table_size =
- FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table)
- }),
- },
- [PD_STATIC_DEV_IDX_CLUSTER2] = {
- .name = "CLUS2",
- .data = &((struct mod_power_domain_element_config) {
- .attributes.pd_type = MOD_PD_TYPE_CLUSTER,
- .api_id = FWK_ID_API_INIT(
- FWK_MODULE_IDX_PPU_V1,
- MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER),
- .allowed_state_mask_table = cluster_pd_allowed_state_mask_table,
- .allowed_state_mask_table_size =
- FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table)
- }),
- },
- [PD_STATIC_DEV_IDX_CLUSTER3] = {
- .name = "CLUS3",
- .data = &((struct mod_power_domain_element_config) {
- .attributes.pd_type = MOD_PD_TYPE_CLUSTER,
- .api_id = FWK_ID_API_INIT(
- FWK_MODULE_IDX_PPU_V1,
- MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER),
- .allowed_state_mask_table = cluster_pd_allowed_state_mask_table,
- .allowed_state_mask_table_size =
- FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table)
- }),
- },
[PD_STATIC_DEV_IDX_SYSTOP] = {
.name = "SYSTOP",
.data = &((struct mod_power_domain_element_config) {
@@ -122,80 +75,17 @@ static struct fwk_element rddanielxlr_power_domain_static_element_table[] = {
static const struct fwk_element *rddanielxlr_power_domain_get_element_table
(fwk_id_t module_id)
{
- struct fwk_element *element_table, *element;
- struct mod_power_domain_element_config *pd_config_table, *pd_config;
- unsigned int core_idx;
- unsigned int cluster_idx;
- unsigned int cluster_offset = rddanielxlr_core_get_core_count();
- unsigned int core_count;
- unsigned int cluster_count;
- unsigned int core_element_counter = 0;
- unsigned int elements_count;
- unsigned int systop_idx;
-
- core_count = rddanielxlr_core_get_core_count();
- cluster_count = rddanielxlr_core_get_cluster_count();
-
- elements_count = core_count +
- FWK_ARRAY_SIZE(rddanielxlr_power_domain_static_element_table);
-
- systop_idx = elements_count - 1;
-
- element_table = fwk_mm_calloc(
- elements_count + 1, /* Terminator */
- sizeof(struct fwk_element));
- if (element_table == NULL)
- return NULL;
-
- pd_config_table = fwk_mm_calloc(
- core_count, sizeof(struct mod_power_domain_element_config));
- if (pd_config_table == NULL)
- return NULL;
-
- for (cluster_idx = 0; cluster_idx < cluster_count; cluster_idx++) {
- for (core_idx = 0;
- core_idx < rddanielxlr_core_get_core_per_cluster_count(cluster_idx);
- core_idx++) {
- element = &element_table[core_element_counter];
- pd_config = &pd_config_table[core_element_counter];
-
- element->name = fwk_mm_alloc(PD_NAME_SIZE, 1);
- if (element->name == NULL)
- return NULL;
-
- snprintf((char *)element->name, PD_NAME_SIZE, "CLUS%uCORE%u",
- cluster_idx, core_idx);
-
- element->data = pd_config;
-
- pd_config->attributes.pd_type = MOD_PD_TYPE_CORE;
- pd_config->parent_idx = cluster_offset + cluster_idx;
- pd_config->driver_id =
- FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, core_element_counter);
- pd_config->api_id = FWK_ID_API(
- FWK_MODULE_IDX_PPU_V1,
- MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER);
- pd_config->allowed_state_mask_table =
- core_pd_allowed_state_mask_table;
- pd_config->allowed_state_mask_table_size =
- FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table);
- core_element_counter++;
- }
-
- /* Define the driver id for the cluster */
- pd_config = (struct mod_power_domain_element_config *)
- rddanielxlr_power_domain_static_element_table[cluster_idx].data;
- pd_config->parent_idx = systop_idx;
- pd_config->driver_id =
- FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1,
- (core_count + cluster_idx));
- }
-
- memcpy(element_table + core_count,
- rddanielxlr_power_domain_static_element_table,
- sizeof(rddanielxlr_power_domain_static_element_table));
-
- return element_table;
+ return create_power_domain_element_table(
+ rddanielxlr_core_get_core_count(),
+ rddanielxlr_core_get_cluster_count(),
+ FWK_MODULE_IDX_PPU_V1,
+ MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER,
+ core_pd_allowed_state_mask_table,
+ FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table),
+ cluster_pd_allowed_state_mask_table,
+ FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table),
+ rddanielxlr_power_domain_static_element_table,
+ FWK_ARRAY_SIZE(rddanielxlr_power_domain_static_element_table));
}
/*
diff --git a/product/rddanielxlr/scp_ramfw/config_ppu_v1.c b/product/rddanielxlr/scp_ramfw/config_ppu_v1.c
index 95f2f3eb..720203d3 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 443f4b1f..de0995b4 100644
--- a/product/rddanielxlr/scp_ramfw/config_smt.c
+++ b/product/rddanielxlr/scp_ramfw/config_smt.c
@@ -43,8 +43,11 @@ 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);
+ config->pd_source_id = FWK_ID_ELEMENT(
+ FWK_MODULE_IDX_POWER_DOMAIN,
+ rddanielxlr_core_get_core_count() +
+ rddanielxlr_core_get_cluster_count() +
+ PD_STATIC_DEV_IDX_SYSTOP);
}
return smt_element_table;
diff --git a/product/rdn1e1/scp_ramfw/config_clock.c b/product/rdn1e1/scp_ramfw/config_clock.c
index 9daad5b3..4d6868a8 100644
--- a/product/rdn1e1/scp_ramfw/config_clock.c
+++ b/product/rdn1e1/scp_ramfw/config_clock.c
@@ -60,7 +60,8 @@ 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 bf402f1f..0eabbb32 100644
--- a/product/rdn1e1/scp_ramfw/config_power_domain.c
+++ b/product/rdn1e1/scp_ramfw/config_power_domain.c
@@ -10,6 +10,8 @@
#include "rdn1e1_core.h"
#include "rdn1e1_power_domain.h"
+#include <power_domain_utils.h>
+
#include <mod_power_domain.h>
#include <mod_ppu_v1.h>
#include <mod_system_power.h>
@@ -76,30 +78,6 @@ static const struct mod_power_domain_config
rdn1e1_power_domain_config = { 0 };
static struct fwk_element rdn1e1_power_domain_static_element_table[] = {
- [PD_STATIC_DEV_IDX_CLUSTER0] = {
- .name = "CLUS0",
- .data = &((struct mod_power_domain_element_config) {
- .attributes.pd_type = MOD_PD_TYPE_CLUSTER,
- .api_id = FWK_ID_API_INIT(
- FWK_MODULE_IDX_PPU_V1,
- MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER),
- .allowed_state_mask_table = cluster_pd_allowed_state_mask_table,
- .allowed_state_mask_table_size =
- FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table)
- }),
- },
- [PD_STATIC_DEV_IDX_CLUSTER1] = {
- .name = "CLUS1",
- .data = &((struct mod_power_domain_element_config) {
- .attributes.pd_type = MOD_PD_TYPE_CLUSTER,
- .api_id = FWK_ID_API_INIT(
- FWK_MODULE_IDX_PPU_V1,
- MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER),
- .allowed_state_mask_table = cluster_pd_allowed_state_mask_table,
- .allowed_state_mask_table_size =
- FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table)
- }),
- },
[PD_STATIC_DEV_IDX_DBGTOP] = {
.name = "DBGTOP",
.data = &((struct mod_power_domain_element_config) {
@@ -134,84 +112,17 @@ static struct fwk_element rdn1e1_power_domain_static_element_table[] = {
static const struct fwk_element *rdn1e1_power_domain_get_element_table
(fwk_id_t module_id)
{
- struct fwk_element *element_table, *element;
- struct mod_power_domain_element_config *pd_config_table, *pd_config;
- unsigned int core_idx;
- unsigned int cluster_idx;
- unsigned int cluster_offset = rdn1e1_core_get_core_count();
- unsigned int core_count;
- unsigned int cluster_count;
- unsigned int core_element_counter = 0;
- unsigned int elements_count;
- unsigned int systop_idx;
-
- core_count = rdn1e1_core_get_core_count();
- cluster_count = rdn1e1_core_get_cluster_count();
-
- elements_count =
- core_count + FWK_ARRAY_SIZE(rdn1e1_power_domain_static_element_table);
- systop_idx = elements_count - 1;
-
- element_table = fwk_mm_calloc(
- elements_count + 1, /* Terminator */
- sizeof(struct fwk_element));
- if (element_table == NULL)
- return NULL;
-
- pd_config_table = fwk_mm_calloc(core_count,
- sizeof(struct mod_power_domain_element_config));
- if (pd_config_table == NULL)
- return NULL;
-
- for (cluster_idx = 0; cluster_idx < cluster_count; cluster_idx++) {
- for (core_idx = 0;
- core_idx < rdn1e1_core_get_core_per_cluster_count(cluster_idx);
- core_idx++) {
- element = &element_table[core_element_counter];
- pd_config = &pd_config_table[core_element_counter];
-
- element->name = fwk_mm_alloc(PD_NAME_SIZE, 1);
-
- snprintf((char *)element->name, PD_NAME_SIZE, "CLUS%uCORE%u",
- cluster_idx, core_idx);
-
- element->data = pd_config;
-
- pd_config->attributes.pd_type = MOD_PD_TYPE_CORE;
- pd_config->parent_idx = cluster_idx + cluster_offset;
- pd_config->driver_id =
- FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, core_element_counter);
- pd_config->api_id = FWK_ID_API(
- FWK_MODULE_IDX_PPU_V1,
- MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER);
- pd_config->allowed_state_mask_table =
- core_pd_allowed_state_mask_table;
- pd_config->allowed_state_mask_table_size =
- FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table);
- core_element_counter++;
- }
-
- /* Define the driver id for the cluster */
- pd_config = (struct mod_power_domain_element_config *)
- rdn1e1_power_domain_static_element_table[cluster_idx].data;
- pd_config->parent_idx = systop_idx;
- pd_config->driver_id =
- FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1,
- (core_count + cluster_idx));
- }
-
- /* Set debug config */
- pd_config =
- (struct mod_power_domain_element_config *)
- rdn1e1_power_domain_static_element_table[PD_STATIC_DEV_IDX_DBGTOP]
- .data;
- pd_config->parent_idx = systop_idx;
-
- memcpy(element_table + core_count,
- rdn1e1_power_domain_static_element_table,
- sizeof(rdn1e1_power_domain_static_element_table));
-
- return element_table;
+ return create_power_domain_element_table(
+ rdn1e1_core_get_core_count(),
+ rdn1e1_core_get_cluster_count(),
+ FWK_MODULE_IDX_PPU_V1,
+ MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER,
+ core_pd_allowed_state_mask_table,
+ FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table),
+ cluster_pd_allowed_state_mask_table,
+ FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table),
+ rdn1e1_power_domain_static_element_table,
+ FWK_ARRAY_SIZE(rdn1e1_power_domain_static_element_table));
}
/*
diff --git a/product/rdn1e1/scp_ramfw/config_power_domain.h b/product/rdn1e1/scp_ramfw/config_power_domain.h
index a47d6fd0..580e2fe5 100644
--- a/product/rdn1e1/scp_ramfw/config_power_domain.h
+++ b/product/rdn1e1/scp_ramfw/config_power_domain.h
@@ -15,11 +15,9 @@
* - Indexing the SYSTOP children in the power domain tree
*
* When calculating a power domain element index, use the formula:
- * core_count + pd_static_dev_idx
+ * core_count + cluster_count + pd_static_dev_idx
*/
enum pd_static_dev_idx {
- PD_STATIC_DEV_IDX_CLUSTER0,
- PD_STATIC_DEV_IDX_CLUSTER1,
PD_STATIC_DEV_IDX_DBGTOP,
PD_STATIC_DEV_IDX_SYSTOP,
PD_STATIC_DEV_IDX_NONE = UINT32_MAX
diff --git a/product/rdn1e1/scp_ramfw/config_ppu_v1.c b/product/rdn1e1/scp_ramfw/config_ppu_v1.c
index 4aad1cce..dbd8b4e3 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 4518a537..de41ea70 100644
--- a/product/rdn1e1/scp_ramfw/config_smt.c
+++ b/product/rdn1e1/scp_ramfw/config_smt.c
@@ -55,8 +55,10 @@ 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);
+ config->pd_source_id = FWK_ID_ELEMENT(
+ FWK_MODULE_IDX_POWER_DOMAIN,
+ rdn1e1_core_get_core_count() + rdn1e1_core_get_cluster_count() +
+ PD_STATIC_DEV_IDX_SYSTOP);
}
return smt_element_table;
diff --git a/product/sgi575/scp_ramfw/config_power_domain.c b/product/sgi575/scp_ramfw/config_power_domain.c
index 0463358e..d900c670 100644
--- a/product/sgi575/scp_ramfw/config_power_domain.c
+++ b/product/sgi575/scp_ramfw/config_power_domain.c
@@ -10,6 +10,8 @@
#include "sgi575_core.h"
#include "sgi575_power_domain.h"
+#include <power_domain_utils.h>
+
#include <mod_power_domain.h>
#include <mod_ppu_v1.h>
#include <mod_system_power.h>
@@ -109,100 +111,17 @@ static struct fwk_element sgi575_power_domain_static_element_table[] = {
static const struct fwk_element *sgi575_power_domain_get_element_table
(fwk_id_t module_id)
{
- struct fwk_element *element_table, *element;
- struct mod_power_domain_element_config *pd_config_table, *pd_config;
- unsigned int core_idx;
- unsigned int cluster_idx;
- unsigned int core_count;
- unsigned int cluster_count;
- unsigned int cluster_offset;
- unsigned int core_element_counter = 0;
- unsigned int elements_count;
- unsigned int systop_idx;
-
- core_count = sgi575_core_get_core_count();
- cluster_count = sgi575_core_get_cluster_count();
-
- elements_count = core_count + cluster_count +
- FWK_ARRAY_SIZE(sgi575_power_domain_static_element_table);
-
- systop_idx = elements_count - 1;
-
- cluster_offset = core_count;
-
- element_table = fwk_mm_calloc(
- elements_count + 1, /* Terminator */
- sizeof(struct fwk_element));
- if (element_table == NULL)
- return NULL;
-
- pd_config_table = fwk_mm_calloc(
- core_count + cluster_count,
- sizeof(struct mod_power_domain_element_config));
-
- for (cluster_idx = 0; cluster_idx < cluster_count; cluster_idx++) {
- for (core_idx = 0;
- core_idx < sgi575_core_get_core_per_cluster_count(cluster_idx);
- core_idx++) {
- element = &element_table[core_element_counter];
- pd_config = &pd_config_table[core_element_counter];
-
- element->name = fwk_mm_alloc(PD_NAME_SIZE, 1);
-
- snprintf((char *)element->name, PD_NAME_SIZE, "CLUS%uCORE%u",
- cluster_idx, core_idx);
-
- element->data = pd_config;
-
- pd_config->attributes.pd_type = MOD_PD_TYPE_CORE;
- pd_config->parent_idx = cluster_idx + cluster_offset;
- pd_config->driver_id =
- FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, core_element_counter);
- pd_config->api_id = FWK_ID_API(
- FWK_MODULE_IDX_PPU_V1,
- MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER);
- pd_config->allowed_state_mask_table =
- core_pd_allowed_state_mask_table;
- pd_config->allowed_state_mask_table_size =
- FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table);
- core_element_counter++;
- }
-
- /* Define the cluster configuration */
- element = &element_table[cluster_idx + cluster_offset];
- pd_config = &pd_config_table[cluster_idx + cluster_offset];
-
- element->name = fwk_mm_alloc(PD_NAME_SIZE, 1);
-
- snprintf((char *)element->name, PD_NAME_SIZE, "CLUS%u", cluster_idx);
-
- element->data = pd_config;
-
- pd_config->attributes.pd_type = MOD_PD_TYPE_CLUSTER;
- pd_config->parent_idx = systop_idx;
- pd_config->driver_id =
- FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, cluster_idx + cluster_offset);
- pd_config->api_id = FWK_ID_API(
- FWK_MODULE_IDX_PPU_V1, MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER);
- pd_config->allowed_state_mask_table =
- cluster_pd_allowed_state_mask_table;
- pd_config->allowed_state_mask_table_size =
- FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table);
- }
-
- /* Set debug config */
- pd_config =
- (struct mod_power_domain_element_config *)
- sgi575_power_domain_static_element_table[PD_STATIC_DEV_IDX_DBGTOP]
- .data;
- pd_config->parent_idx = systop_idx;
-
- memcpy(
- element_table + core_count + cluster_count,
+ 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,
- sizeof(sgi575_power_domain_static_element_table));
-
- return 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 e6de52bd..f1825862 100644
--- a/product/sgi575/scp_ramfw/config_power_domain.h
+++ b/product/sgi575/scp_ramfw/config_power_domain.h
@@ -15,7 +15,7 @@
* - Indexing the SYSTOP children in the power domain tree
*
* When calculating a power domain element index, use the formula:
- * core_count + pd_static_dev_idx
+ * core_count + cluster_count + pd_static_dev_idx
*/
enum pd_static_dev_idx {
PD_STATIC_DEV_IDX_DBGTOP,
diff --git a/product/sgm775/include/sgm775_core.h b/product/sgm775/include/sgm775_core.h
index 8984e166..7ff3f44e 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 8665bc50..fe7cb249 100644
--- a/product/sgm775/scp_ramfw/config_clock.c
+++ b/product/sgm775/scp_ramfw/config_clock.c
@@ -91,10 +91,11 @@ static struct fwk_element clock_dev_desc_table[] = {
static const struct fwk_element *clock_get_dev_desc_table(fwk_id_t module_id)
{
unsigned int i;
- unsigned int core_count;
+ unsigned int core_count, cluster_count;
struct mod_clock_dev_config *dev_config;
core_count = sgm775_core_get_count();
+ cluster_count = sgm775_cluster_get_count();
/* Configure all clocks to respond to changes in SYSTOP power state */
for (i = 0; i < CLOCK_DEV_IDX_COUNT; i++) {
@@ -102,7 +103,7 @@ static const struct fwk_element *clock_get_dev_desc_table(fwk_id_t module_id)
(struct mod_clock_dev_config *)clock_dev_desc_table[i].data;
dev_config->pd_source_id = FWK_ID_ELEMENT(
FWK_MODULE_IDX_POWER_DOMAIN,
- CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM + core_count);
+ CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM + core_count + cluster_count);
}
return clock_dev_desc_table;
diff --git a/product/sgm775/scp_ramfw/config_power_domain.c b/product/sgm775/scp_ramfw/config_power_domain.c
index 17a894d1..f0e1ab77 100644
--- a/product/sgm775/scp_ramfw/config_power_domain.c
+++ b/product/sgm775/scp_ramfw/config_power_domain.c
@@ -9,6 +9,8 @@
#include "config_ppu_v0.h"
#include "sgm775_core.h"
+#include <power_domain_utils.h>
+
#include <mod_power_domain.h>
#include <mod_ppu_v1.h>
#include <mod_system_power.h>
@@ -23,11 +25,6 @@
#include <stdint.h>
#include <string.h>
-static const char *core_pd_name_table[SGM775_CORE_PER_CLUSTER_MAX] = {
- "CLUS0CORE0", "CLUS0CORE1", "CLUS0CORE2", "CLUS0CORE3",
- "CLUS0CORE4", "CLUS0CORE5", "CLUS0CORE6", "CLUS0CORE7",
-};
-
/* Mask of the allowed states for the systop power domain */
static const uint32_t systop_allowed_state_mask_table[] = {
[0] = MOD_PD_STATE_OFF_MASK | MOD_PD_STATE_ON_MASK |
@@ -73,17 +70,6 @@ static const uint32_t core_pd_allowed_state_mask_table[] = {
static const struct mod_power_domain_config sgm775_power_domain_config = { 0 };
static struct fwk_element sgm775_power_domain_static_element_table[] = {
- [CONFIG_POWER_DOMAIN_SYSTOP_CHILD_CLUSTER0] = {
- .name = "CLUS0",
- .data = &((struct mod_power_domain_element_config) {
- .attributes.pd_type = MOD_PD_TYPE_CLUSTER,
- .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_PPU_V1,
- MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER),
- .allowed_state_mask_table = cluster_pd_allowed_state_mask_table,
- .allowed_state_mask_table_size =
- FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table)
- }),
- },
[CONFIG_POWER_DOMAIN_SYSTOP_CHILD_DBGTOP] = {
.name = "DBGTOP",
.data = &((struct mod_power_domain_element_config) {
@@ -165,64 +151,17 @@ static struct fwk_element sgm775_power_domain_static_element_table[] = {
static const struct fwk_element *sgm775_power_domain_get_element_table
(fwk_id_t module_id)
{
- struct fwk_element *element_table, *element;
- struct mod_power_domain_element_config *pd_config_table, *pd_config;
- unsigned int core_idx, i;
- unsigned int cluster_offset = sgm775_core_get_count();
- unsigned int systop_idx;
- unsigned int elements_count;
-
- elements_count = sgm775_core_get_count() +
- FWK_ARRAY_SIZE(sgm775_power_domain_static_element_table);
-
- systop_idx = elements_count - 1;
-
- element_table = fwk_mm_calloc(
- elements_count + 1, /* Terminator */
- sizeof(struct fwk_element));
-
- pd_config_table = fwk_mm_calloc(sgm775_core_get_count(),
- sizeof(struct mod_power_domain_element_config));
-
- for (core_idx = 0; core_idx < sgm775_core_get_count(); core_idx++) {
- element = &element_table[core_idx];
- pd_config = &pd_config_table[core_idx];
-
- element->name = core_pd_name_table[core_idx];
- element->data = pd_config;
-
- pd_config->attributes.pd_type = MOD_PD_TYPE_CORE,
- pd_config->parent_idx = cluster_offset,
- pd_config->driver_id = FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, core_idx),
- pd_config->api_id = FWK_ID_API(
- FWK_MODULE_IDX_PPU_V1, MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER),
- pd_config->allowed_state_mask_table = core_pd_allowed_state_mask_table,
- pd_config->allowed_state_mask_table_size =
- FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table);
- }
-
- pd_config = (struct mod_power_domain_element_config *)
- sgm775_power_domain_static_element_table
- [CONFIG_POWER_DOMAIN_SYSTOP_CHILD_CLUSTER0]
- .data;
- pd_config->driver_id =
- FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, sgm775_core_get_count());
-
- /* Set the parent for all level one domains */
- for (i = 0;
- i < (FWK_ARRAY_SIZE(sgm775_power_domain_static_element_table) - 1);
- i++) {
- pd_config = (struct mod_power_domain_element_config *)
- sgm775_power_domain_static_element_table[i]
- .data;
- pd_config->parent_idx = systop_idx;
- }
-
- memcpy(element_table + sgm775_core_get_count(),
- sgm775_power_domain_static_element_table,
- sizeof(sgm775_power_domain_static_element_table));
-
- return element_table;
+ return create_power_domain_element_table(
+ sgm775_core_get_count(),
+ sgm775_cluster_get_count(),
+ FWK_MODULE_IDX_PPU_V1,
+ MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER,
+ core_pd_allowed_state_mask_table,
+ FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table),
+ cluster_pd_allowed_state_mask_table,
+ FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table),
+ sgm775_power_domain_static_element_table,
+ FWK_ARRAY_SIZE(sgm775_power_domain_static_element_table));
}
/*
diff --git a/product/sgm775/scp_ramfw/config_power_domain.h b/product/sgm775/scp_ramfw/config_power_domain.h
index c8926e10..2dc9c66e 100644
--- a/product/sgm775/scp_ramfw/config_power_domain.h
+++ b/product/sgm775/scp_ramfw/config_power_domain.h
@@ -11,7 +11,6 @@
#include <stdint.h>
enum systop_child_index {
- CONFIG_POWER_DOMAIN_SYSTOP_CHILD_CLUSTER0,
CONFIG_POWER_DOMAIN_SYSTOP_CHILD_DBGTOP,
CONFIG_POWER_DOMAIN_SYSTOP_CHILD_DPU0TOP,
CONFIG_POWER_DOMAIN_SYSTOP_CHILD_DPU1TOP,
diff --git a/product/sgm775/scp_ramfw/config_ppu_v1.c b/product/sgm775/scp_ramfw/config_ppu_v1.c
index 56ca9640..9a4db990 100644
--- a/product/sgm775/scp_ramfw/config_ppu_v1.c
+++ b/product/sgm775/scp_ramfw/config_ppu_v1.c
@@ -93,7 +93,8 @@ static const struct fwk_element *sgm775_ppu_v1_get_element_table
sgm775_ppu_v1_notification_config.pd_source_id = FWK_ID_ELEMENT(
FWK_MODULE_IDX_POWER_DOMAIN,
- CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM + sgm775_core_get_count());
+ CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM + sgm775_core_get_count() +
+ sgm775_cluster_get_count());
return element_table;
}
diff --git a/product/sgm775/scp_ramfw/config_smt.c b/product/sgm775/scp_ramfw/config_smt.c
index d1adeaca..7eec69b4 100644
--- a/product/sgm775/scp_ramfw/config_smt.c
+++ b/product/sgm775/scp_ramfw/config_smt.c
@@ -67,9 +67,11 @@ static const struct fwk_element *smt_get_element_table(fwk_id_t module_id)
for (idx = 0; idx < SGM775_SCMI_SERVICE_IDX_COUNT; idx++) {
config = (struct mod_smt_channel_config *)(smt_element_table[idx].data);
+
config->pd_source_id = FWK_ID_ELEMENT(
FWK_MODULE_IDX_POWER_DOMAIN,
- CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM + sgm775_core_get_count());
+ CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM + sgm775_core_get_count() +
+ sgm775_cluster_get_count());
}
return smt_element_table;
diff --git a/product/sgm775/src/sgm775_core.c b/product/sgm775/src/sgm775_core.c
index 8cac171c..7bcb4a05 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 ef0ccac0..928d9103 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 f338acad..f9263f48 100644
--- a/product/sgm776/scp_ramfw/config_clock.c
+++ b/product/sgm776/scp_ramfw/config_clock.c
@@ -91,10 +91,11 @@ static const struct fwk_element clock_dev_desc_table[] = {
static const struct fwk_element *clock_get_dev_desc_table(fwk_id_t module_id)
{
unsigned int i;
- unsigned int core_count;
+ unsigned int core_count, cluster_count;
struct mod_clock_dev_config *dev_config;
core_count = sgm776_core_get_count();
+ cluster_count = sgm776_cluster_get_count();
/* Configure all clocks to respond to changes in SYSTOP power state */
for (i = 0; i < CLOCK_DEV_IDX_COUNT; i++) {
@@ -102,7 +103,7 @@ static const struct fwk_element *clock_get_dev_desc_table(fwk_id_t module_id)
(struct mod_clock_dev_config *)clock_dev_desc_table[i].data;
dev_config->pd_source_id = FWK_ID_ELEMENT(
FWK_MODULE_IDX_POWER_DOMAIN,
- CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM + core_count);
+ CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM + core_count + cluster_count);
}
return clock_dev_desc_table;
diff --git a/product/sgm776/scp_ramfw/config_power_domain.c b/product/sgm776/scp_ramfw/config_power_domain.c
index 0dc5c825..8e9274cb 100644
--- a/product/sgm776/scp_ramfw/config_power_domain.c
+++ b/product/sgm776/scp_ramfw/config_power_domain.c
@@ -9,6 +9,8 @@
#include "config_ppu_v1.h"
#include "sgm776_core.h"
+#include <power_domain_utils.h>
+
#include <mod_power_domain.h>
#include <mod_ppu_v1.h>
#include <mod_system_power.h>
@@ -23,11 +25,6 @@
#include <stdint.h>
#include <string.h>
-static const char *core_pd_name_table[SGM776_CORE_PER_CLUSTER_MAX] = {
- "CLUS0CORE0", "CLUS0CORE1", "CLUS0CORE2", "CLUS0CORE3",
- "CLUS0CORE4", "CLUS0CORE5", "CLUS0CORE6", "CLUS0CORE7",
-};
-
/* Mask of the allowed states for the systop power domain */
static const uint32_t systop_allowed_state_mask_table[] = {
[0] = MOD_PD_STATE_OFF_MASK | MOD_PD_STATE_ON_MASK |
@@ -70,17 +67,6 @@ static const uint32_t core_pd_allowed_state_mask_table[] = {
static const struct mod_power_domain_config sgm776_power_domain_config = { 0 };
static struct fwk_element sgm776_power_domain_static_element_table[] = {
- [CONFIG_POWER_DOMAIN_SYSTOP_CHILD_CLUSTER0] = {
- .name = "CLUS0",
- .data = &((struct mod_power_domain_element_config) {
- .attributes.pd_type = MOD_PD_TYPE_CLUSTER,
- .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_PPU_V1,
- MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER),
- .allowed_state_mask_table = cluster_pd_allowed_state_mask_table,
- .allowed_state_mask_table_size =
- FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table)
- }),
- },
[CONFIG_POWER_DOMAIN_SYSTOP_CHILD_DBGTOP] = {
.name = "DBGTOP",
.data = &((struct mod_power_domain_element_config) {
@@ -158,66 +144,32 @@ static struct fwk_element sgm776_power_domain_static_element_table[] = {
static const struct fwk_element *sgm776_power_domain_get_element_table
(fwk_id_t module_id)
{
- struct fwk_element *element_table, *element;
- struct mod_power_domain_element_config *pd_config_table, *pd_config;
- unsigned int core_idx, i;
- unsigned int cluster_offset = sgm776_core_get_count();
- unsigned int systop_idx;
- unsigned int elements_count;
-
- elements_count = sgm776_core_get_count() +
+ 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);
- systop_idx = elements_count - 1;
-
- element_table = fwk_mm_calloc(
- elements_count + 1, /* Terminator */
- sizeof(struct fwk_element));
-
- pd_config_table = fwk_mm_calloc(sgm776_core_get_count(),
- sizeof(struct mod_power_domain_element_config));
-
- for (core_idx = 0; core_idx < sgm776_core_get_count(); core_idx++) {
- element = &element_table[core_idx];
- pd_config = &pd_config_table[core_idx];
-
- element->name = core_pd_name_table[core_idx];
- element->data = pd_config;
-
- pd_config->attributes.pd_type = MOD_PD_TYPE_CORE,
- pd_config->parent_idx = cluster_offset,
- pd_config->driver_id = FWK_ID_ELEMENT(
- FWK_MODULE_IDX_PPU_V1, PPU_V1_ELEMENT_IDX_COUNT + core_idx),
- pd_config->api_id = FWK_ID_API(
- FWK_MODULE_IDX_PPU_V1, MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER),
- pd_config->allowed_state_mask_table = core_pd_allowed_state_mask_table,
- pd_config->allowed_state_mask_table_size =
- FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table);
- }
-
- pd_config = (struct mod_power_domain_element_config *)
- sgm776_power_domain_static_element_table
- [CONFIG_POWER_DOMAIN_SYSTOP_CHILD_CLUSTER0]
- .data;
- pd_config->driver_id =
- FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1,
- PPU_V1_ELEMENT_IDX_COUNT + sgm776_core_get_count());
-
- /* Set the parent for all level one domains */
- for (i = 0;
- i < (FWK_ARRAY_SIZE(sgm776_power_domain_static_element_table) - 1);
- i++) {
+ for (elem_idx = 0; elem_idx < (static_table_size - 1); elem_idx++) {
pd_config = (struct mod_power_domain_element_config *)
- sgm776_power_domain_static_element_table[i]
+ sgm776_power_domain_static_element_table[elem_idx]
.data;
- pd_config->parent_idx = systop_idx;
- }
- memcpy(element_table + sgm776_core_get_count(),
- sgm776_power_domain_static_element_table,
- sizeof(sgm776_power_domain_static_element_table));
+ 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 c75109ab..e1cba64a 100644
--- a/product/sgm776/scp_ramfw/config_power_domain.h
+++ b/product/sgm776/scp_ramfw/config_power_domain.h
@@ -11,7 +11,6 @@
#include <stdint.h>
enum systop_child_index {
- CONFIG_POWER_DOMAIN_SYSTOP_CHILD_CLUSTER0,
CONFIG_POWER_DOMAIN_SYSTOP_CHILD_DBGTOP,
CONFIG_POWER_DOMAIN_SYSTOP_CHILD_DPUTOP,
CONFIG_POWER_DOMAIN_SYSTOP_CHILD_GPUTOP,
diff --git a/product/sgm776/scp_ramfw/config_ppu_v1.c b/product/sgm776/scp_ramfw/config_ppu_v1.c
index 225ae926..c9c46f19 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];
@@ -142,12 +133,12 @@ static const struct fwk_element *sgm776_ppu_v1_get_element_table(
pd_config->pd_type = MOD_PD_TYPE_CORE;
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);
+ pd_config->cluster_id =
+ FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, 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,12 @@ static const struct fwk_element *sgm776_ppu_v1_get_element_table(
pd_config->ppu.irq = PPU_CLUS0_IRQ;
pd_config->observer_id = FWK_ID_NONE;
- /* Copy static table to the beginning of the dynamic table */
- memcpy(element_table, static_ppu_table, sizeof(static_ppu_table));
-
sgm776_ppu_v1_notification_config.pd_source_id = FWK_ID_ELEMENT(
FWK_MODULE_IDX_POWER_DOMAIN,
- CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM + sgm776_core_get_count());
+ CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM + sgm776_cluster_get_count() +
+ sgm776_core_get_count());
- return element_table;
+ return ppu_table;
}
/*
diff --git a/product/sgm776/scp_ramfw/config_ppu_v1.h b/product/sgm776/scp_ramfw/config_ppu_v1.h
index 2cf9c766..0e8c6cec 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 9884f3d9..5dc7d456 100644
--- a/product/sgm776/scp_ramfw/config_smt.c
+++ b/product/sgm776/scp_ramfw/config_smt.c
@@ -71,9 +71,11 @@ static const struct fwk_element *smt_get_element_table(fwk_id_t module_id)
for (idx = 0; idx < SGM776_SCMI_SERVICE_IDX_COUNT; idx++) {
config = (struct mod_smt_channel_config *)(smt_element_table[idx].data);
+
config->pd_source_id = FWK_ID_ELEMENT(
FWK_MODULE_IDX_POWER_DOMAIN,
- CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM + sgm776_core_get_count());
+ CONFIG_POWER_DOMAIN_SYSTOP_SYSTEM + sgm776_core_get_count() +
+ sgm776_cluster_get_count());
}
return smt_element_table;
diff --git a/product/sgm776/src/sgm776_core.c b/product/sgm776/src/sgm776_core.c
index c038949d..6a27d160 100644
--- a/product/sgm776/src/sgm776_core.c
+++ b/product/sgm776/src/sgm776_core.c
@@ -13,3 +13,8 @@ unsigned int sgm776_core_get_count(void)
{
return (PIK_CLUS0->PCL_CONFIG & PIK_CPU_PCL_CONFIG_NO_OF_PPU) - 1;
}
+
+unsigned int sgm776_cluster_get_count(void)
+{
+ return SGM776_CLUSTER_COUNT;
+}
diff --git a/product/synquacer/scp_ramfw/config_power_domain.c b/product/synquacer/scp_ramfw/config_power_domain.c
index 295fa8f6..87e7cb48 100644
--- a/product/synquacer/scp_ramfw/config_power_domain.c
+++ b/product/synquacer/scp_ramfw/config_power_domain.c
@@ -9,6 +9,8 @@
#include "config_ppu_v0.h"
#include "synquacer_core.h"
+#include <power_domain_utils.h>
+
#include <mod_power_domain.h>
#include <mod_system_power.h>
@@ -126,108 +128,17 @@ static struct fwk_element synquacer_power_domain_static_element_table[] = {
static const struct fwk_element *synquacer_power_domain_get_element_table(
fwk_id_t module_id)
{
- struct fwk_element *element_table, *element;
- struct mod_power_domain_element_config *pd_config_table, *pd_config;
- unsigned int core_idx, i;
- unsigned int cluster_idx;
- unsigned int core_count;
- unsigned int cluster_count;
- unsigned int core_per_cluster_count;
- unsigned int element_counter = 0;
- unsigned int total_elements;
- unsigned int systop_idx;
-
- core_count = synquacer_core_get_core_count();
- cluster_count = synquacer_core_get_cluster_count();
- core_per_cluster_count = synquacer_core_get_core_per_cluster_count();
-
- total_elements = cluster_count + core_count +
- FWK_ARRAY_SIZE(synquacer_power_domain_static_element_table);
-
- systop_idx = total_elements - 1;
-
- element_table = fwk_mm_calloc(
- total_elements + 1, /* Terminator */
- sizeof(struct fwk_element));
-
- pd_config_table = fwk_mm_calloc(
- (cluster_count + core_count),
- sizeof(struct mod_power_domain_element_config));
-
- /*
- * power domain element table should follow the ascending order
- * of tree position.
- * It means first element must be cluster0_core0,
- * last element should be system power element(SYSTOP)
- */
- /* prepare core config table */
- for (cluster_idx = 0; cluster_idx < cluster_count; cluster_idx++) {
- for (core_idx = 0; core_idx < core_per_cluster_count; core_idx++) {
- element = &element_table[element_counter];
- pd_config = &pd_config_table[element_counter];
-
- element->name = fwk_mm_alloc(PD_NAME_SIZE, 1);
-
- snprintf(
- (char *)element->name,
- PD_NAME_SIZE,
- "CLUS%uCORE%u",
- cluster_idx,
- core_idx);
-
- element->data = pd_config;
-
- pd_config->attributes.pd_type = MOD_PD_TYPE_CORE;
- pd_config->driver_id = FWK_ID_ELEMENT(
- FWK_MODULE_IDX_PPU_V0_SYNQUACER, element_counter);
- pd_config->api_id = FWK_ID_API(FWK_MODULE_IDX_PPU_V0_SYNQUACER, 0);
- pd_config->allowed_state_mask_table =
- core_pd_allowed_state_mask_table;
- pd_config->allowed_state_mask_table_size =
- FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table);
- element_counter++;
- }
- }
-
- /* prepare cluster config table */
- for (cluster_idx = 0; cluster_idx < cluster_count; cluster_idx++) {
- element = &element_table[element_counter];
- pd_config = &pd_config_table[element_counter];
-
- element->name = fwk_mm_alloc(PD_NAME_SIZE, 1);
-
- snprintf((char *)element->name, PD_NAME_SIZE, "CLUS%u", cluster_idx);
-
- element->data = pd_config;
-
- pd_config->attributes.pd_type = MOD_PD_TYPE_CLUSTER;
- pd_config->parent_idx = systop_idx;
- pd_config->driver_id =
- FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V0_SYNQUACER, element_counter);
- pd_config->api_id = FWK_ID_API(FWK_MODULE_IDX_PPU_V0_SYNQUACER, 0);
- pd_config->allowed_state_mask_table =
- cluster_pd_allowed_state_mask_table;
- pd_config->allowed_state_mask_table_size =
- FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table);
- element_counter++;
- }
-
- /* Set the parent for all level one domains */
- for (i = 0;
- i < (FWK_ARRAY_SIZE(synquacer_power_domain_static_element_table) - 1);
- i++) {
- pd_config = (struct mod_power_domain_element_config *)
- synquacer_power_domain_static_element_table[i]
- .data;
- pd_config->parent_idx = systop_idx;
- }
-
- memcpy(
- element_table + element_counter,
+ return create_power_domain_element_table(
+ synquacer_core_get_core_count(),
+ synquacer_core_get_cluster_count(),
+ FWK_MODULE_IDX_PPU_V0_SYNQUACER,
+ 0,
+ core_pd_allowed_state_mask_table,
+ FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table),
+ cluster_pd_allowed_state_mask_table,
+ FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table),
synquacer_power_domain_static_element_table,
- sizeof(synquacer_power_domain_static_element_table));
-
- return element_table;
+ FWK_ARRAY_SIZE(synquacer_power_domain_static_element_table));
}
/*
diff --git a/product/tc0/include/config_power_domain.h b/product/tc0/include/config_power_domain.h
index ba381022..cd3d2e3d 100644
--- a/product/tc0/include/config_power_domain.h
+++ b/product/tc0/include/config_power_domain.h
@@ -16,10 +16,9 @@
* - Indexing the SYSTOP children in the power domain tree
*
* When calculating a power domain element index, use the formula:
- * core_count + pd_static_dev_idx
+ * core_count + cluster_count + pd_static_dev_idx
*/
enum pd_static_dev_idx {
- PD_STATIC_DEV_IDX_CLUSTER0,
PD_STATIC_DEV_IDX_SYSTOP,
PD_STATIC_DEV_IDX_COUNT,
PD_STATIC_DEV_IDX_NONE = UINT32_MAX
diff --git a/product/tc0/scp_ramfw/config_clock.c b/product/tc0/scp_ramfw/config_clock.c
index b0d6b47c..083f6491 100644
--- a/product/tc0/scp_ramfw/config_clock.c
+++ b/product/tc0/scp_ramfw/config_clock.c
@@ -79,7 +79,8 @@ 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 72c0727d..a6844aa2 100644
--- a/product/tc0/scp_ramfw/config_power_domain.c
+++ b/product/tc0/scp_ramfw/config_power_domain.c
@@ -9,6 +9,8 @@
#include "tc0_core.h"
#include "tc0_power_domain.h"
+#include <power_domain_utils.h>
+
#include <mod_power_domain.h>
#include <mod_ppu_v1.h>
#include <mod_system_power.h>
@@ -52,18 +54,6 @@ static const struct mod_power_domain_config
tc0_power_domain_config = { 0 };
static struct fwk_element tc0_power_domain_static_element_table[] = {
- [PD_STATIC_DEV_IDX_CLUSTER0] = {
- .name = "CLUS0",
- .data = &((struct mod_power_domain_element_config) {
- .attributes.pd_type = MOD_PD_TYPE_CLUSTER,
- .api_id = FWK_ID_API_INIT(
- FWK_MODULE_IDX_PPU_V1,
- MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER),
- .allowed_state_mask_table = cluster_pd_allowed_state_mask_table,
- .allowed_state_mask_table_size =
- FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table)
- }),
- },
[PD_STATIC_DEV_IDX_SYSTOP] = {
.name = "SYSTOP",
.data = &((struct mod_power_domain_element_config) {
@@ -86,80 +76,17 @@ static struct fwk_element tc0_power_domain_static_element_table[] = {
static const struct fwk_element *tc0_power_domain_get_element_table
(fwk_id_t module_id)
{
- struct fwk_element *element_table, *element;
- struct mod_power_domain_element_config *pd_config_table, *pd_config;
- unsigned int core_idx;
- unsigned int cluster_idx;
- unsigned int cluster_offset;
- unsigned int core_count;
- unsigned int cluster_count;
- unsigned int core_element_counter = 0;
- unsigned int elements_count;
- unsigned int systop_idx;
-
- core_count = cluster_offset = tc0_core_get_core_count();
- cluster_count = tc0_core_get_cluster_count();
-
- elements_count =
- core_count + FWK_ARRAY_SIZE(tc0_power_domain_static_element_table);
-
- systop_idx = elements_count - 1;
-
- element_table = fwk_mm_calloc(
- elements_count + 1, /* Terminator */
- sizeof(struct fwk_element));
- if (element_table == NULL)
- return NULL;
-
- pd_config_table = fwk_mm_calloc(core_count,
- sizeof(struct mod_power_domain_element_config));
- if (pd_config_table == NULL)
- return NULL;
-
- for (cluster_idx = 0; cluster_idx < cluster_count; cluster_idx++) {
- for (core_idx = 0;
- core_idx < tc0_core_get_core_per_cluster_count(
- cluster_idx);
- core_idx++) {
- element = &element_table[core_element_counter];
- pd_config = &pd_config_table[core_element_counter];
-
- element->name = fwk_mm_alloc(PD_NAME_SIZE, 1);
- if (element->name == NULL)
- return NULL;
-
- snprintf((char *)element->name, PD_NAME_SIZE, "CLUS%uCORE%u",
- cluster_idx, core_idx);
-
- element->data = pd_config;
-
- pd_config->attributes.pd_type = MOD_PD_TYPE_CORE;
- pd_config->parent_idx = cluster_idx + cluster_offset;
- pd_config->driver_id =
- FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, core_element_counter);
- pd_config->api_id = FWK_ID_API(
- FWK_MODULE_IDX_PPU_V1,
- MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER);
- pd_config->allowed_state_mask_table =
- core_pd_allowed_state_mask_table;
- pd_config->allowed_state_mask_table_size =
- FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table);
- core_element_counter++;
- }
-
- /* Define the driver id for the cluster */
- pd_config = (struct mod_power_domain_element_config *)
- tc0_power_domain_static_element_table[cluster_idx].data;
- pd_config->parent_idx = systop_idx;
- pd_config->driver_id =
- FWK_ID_ELEMENT(FWK_MODULE_IDX_PPU_V1, (core_count + cluster_idx));
- }
-
- memcpy(element_table + core_count,
- tc0_power_domain_static_element_table,
- sizeof(tc0_power_domain_static_element_table));
-
- return element_table;
+ return create_power_domain_element_table(
+ tc0_core_get_core_count(),
+ tc0_core_get_cluster_count(),
+ FWK_MODULE_IDX_PPU_V1,
+ MOD_PPU_V1_API_IDX_POWER_DOMAIN_DRIVER,
+ core_pd_allowed_state_mask_table,
+ FWK_ARRAY_SIZE(core_pd_allowed_state_mask_table),
+ cluster_pd_allowed_state_mask_table,
+ FWK_ARRAY_SIZE(cluster_pd_allowed_state_mask_table),
+ tc0_power_domain_static_element_table,
+ FWK_ARRAY_SIZE(tc0_power_domain_static_element_table));
}
/*
diff --git a/product/tc0/scp_ramfw/config_ppu_v1.c b/product/tc0/scp_ramfw/config_ppu_v1.c
index 7b4f3310..9dc013b6 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 f6300242..35a2b9ce 100644
--- a/product/tc0/scp_ramfw/config_smt.c
+++ b/product/tc0/scp_ramfw/config_smt.c
@@ -55,8 +55,10 @@ 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);
+ config->pd_source_id = FWK_ID_ELEMENT(
+ FWK_MODULE_IDX_POWER_DOMAIN,
+ tc0_core_get_core_count() + tc0_core_get_cluster_count() +
+ PD_STATIC_DEV_IDX_SYSTOP);
}
return smt_element_table;