aboutsummaryrefslogtreecommitdiff
path: root/product/sgm775
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 /product/sgm775
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>
Diffstat (limited to 'product/sgm775')
-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
7 files changed, 28 insertions, 79 deletions
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;
+}