summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYidi Lin <yidilin@chromium.org>2023-03-28 10:47:27 +0800
committerRex-BC Chen <rex-bc.chen@mediatek.com>2023-04-10 01:54:49 +0000
commit9fbdb2b19295380e0f222e62c12f1b2a2b58540d (patch)
treed0d0d22b66918e21c34aa8a5eddf0951c7ef7d21 /src
parent47a9797100d65f2b23b81d9893302abd92994abd (diff)
soc/mediatek/mt8188: Reduce lastbus configuration size by 1280 bytes
Original lastbus configuration consumes constant memory size by allocating 16 and 8 members arrays and the utilization is bad. Refactor the lastbus structs to save memory usage. BRANCH=none BUG=none TEST=bootblock.raw.bin size is reduced from 60328 bytes to 59048 bytes. Change-Id: I07ff9ff7c75f03219e1792b92b62814293ef43fe Signed-off-by: Yidi Lin <yidilin@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/74061 Reviewed-by: Yidi Lin <yidilin@google.com> Reviewed-by: Rex-BC Chen <rex-bc.chen@mediatek.com> Reviewed-by: Yu-Ping Wu <yupingso@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src')
-rw-r--r--src/soc/mediatek/common/include/soc/lastbus_v2.h6
-rw-r--r--src/soc/mediatek/mt8188/lastbus.c142
2 files changed, 77 insertions, 71 deletions
diff --git a/src/soc/mediatek/common/include/soc/lastbus_v2.h b/src/soc/mediatek/common/include/soc/lastbus_v2.h
index d58da76b57..8146debf4e 100644
--- a/src/soc/mediatek/common/include/soc/lastbus_v2.h
+++ b/src/soc/mediatek/common/include/soc/lastbus_v2.h
@@ -3,8 +3,6 @@
#ifndef SOC_MEDIATEK_COMMON_LASTBUS_V2_H
#define SOC_MEDIATEK_COMMON_LASTBUS_V2_H
-#define NR_MAX_LASTBUS_IDLE_MASK 8
-#define NR_MAX_LASTBUS_MONITOR 16
#define TIMEOUT_THRES_SHIFT 16
#define TIMEOUT_TYPE_SHIFT 1
#define LASTBUS_TIMEOUT_CLR 0x0200
@@ -23,7 +21,7 @@ struct lastbus_monitor {
size_t num_ports;
u16 bus_freq_mhz;
size_t num_idle_mask;
- struct lastbus_idle_mask idle_masks[NR_MAX_LASTBUS_IDLE_MASK];
+ const struct lastbus_idle_mask *idle_masks;
};
struct lastbus_config {
@@ -31,7 +29,7 @@ struct lastbus_config {
unsigned int timeout_ms;
unsigned int timeout_type;
unsigned int num_used_monitors;
- struct lastbus_monitor monitors[NR_MAX_LASTBUS_MONITOR];
+ const struct lastbus_monitor *monitors;
};
void lastbus_init(void);
diff --git a/src/soc/mediatek/mt8188/lastbus.c b/src/soc/mediatek/mt8188/lastbus.c
index f2c0b0d57f..5d117af03b 100644
--- a/src/soc/mediatek/mt8188/lastbus.c
+++ b/src/soc/mediatek/mt8188/lastbus.c
@@ -5,75 +5,83 @@
#include <soc/addressmap.h>
#include <soc/lastbus_v2.h>
+static const struct lastbus_idle_mask infra_ao_mask[] = {
+ {
+ .reg_offset = 0x04,
+ .reg_value = 0x2,
+ },
+ {
+ .reg_offset = 0x08,
+ .reg_value = 0x10000,
+ },
+};
+
+static const struct lastbus_idle_mask peri_ao_mask[] = {
+ {
+ .reg_offset = 0x04,
+ .reg_value = 0x20000,
+ },
+};
+
+static const struct lastbus_idle_mask fmem_ao_mask[] = {
+ {
+ .reg_offset = 0x14,
+ .reg_value = 0x204,
+ },
+};
+
+static const struct lastbus_monitor monitors[] = {
+ {
+ .name = "debug_ctrl_ao_INFRA_AO",
+ .base = INFRA_AO_DBUG_BASE,
+ .num_ports = 34,
+ .num_idle_mask = ARRAY_SIZE(infra_ao_mask),
+ .idle_masks = infra_ao_mask,
+ .bus_freq_mhz = 78,
+ },
+ {
+ .name = "debug_ctrl_ao_INFRA2_AO",
+ .base = INFRA2_AO_DBUG_BASE,
+ .num_ports = 9,
+ .num_idle_mask = 0,
+ .bus_freq_mhz = 78,
+ },
+ {
+ .name = "debug_ctrl_ao_PERI_AO",
+ .base = PERI_AO_BASE,
+ .num_ports = 25,
+ .num_idle_mask = ARRAY_SIZE(peri_ao_mask),
+ .idle_masks = peri_ao_mask,
+ .bus_freq_mhz = 78,
+ },
+ {
+ .name = "debug_ctrl_ao_PERI_AO2",
+ .base = PERI_AO2_BASE,
+ .num_ports = 20,
+ .num_idle_mask = 0,
+ .bus_freq_mhz = 78,
+ },
+ {
+ .name = "debug_ctrl_ao_PERI_PAR_AO",
+ .base = PERI_PAR_AO_BASE,
+ .num_ports = 18,
+ .num_idle_mask = 0,
+ .bus_freq_mhz = 78,
+ },
+ {
+ .name = "debug_ctrl_ao_FMEM_AO",
+ .base = FMEM_AO_BASE,
+ .num_ports = 28,
+ .num_idle_mask = ARRAY_SIZE(fmem_ao_mask),
+ .idle_masks = fmem_ao_mask,
+ .bus_freq_mhz = 78,
+ },
+};
+
const struct lastbus_config lastbus_cfg = {
.latch_platform = "MT8188",
.timeout_ms = 200,
.timeout_type = 0,
- .num_used_monitors = 6,
- .monitors = {
- {
- .name = "debug_ctrl_ao_INFRA_AO",
- .base = INFRA_AO_DBUG_BASE,
- .num_ports = 34,
- .num_idle_mask = 2,
- .idle_masks = {
- {
- .reg_offset = 0x04,
- .reg_value = 0x2,
- },
- {
- .reg_offset = 0x08,
- .reg_value = 0x10000,
- },
- },
- .bus_freq_mhz = 78,
- },
- {
- .name = "debug_ctrl_ao_INFRA2_AO",
- .base = INFRA2_AO_DBUG_BASE,
- .num_ports = 9,
- .num_idle_mask = 0,
- .bus_freq_mhz = 78,
- },
- {
- .name = "debug_ctrl_ao_PERI_AO",
- .base = PERI_AO_BASE,
- .num_ports = 25,
- .num_idle_mask = 1,
- .idle_masks = {
- {
- .reg_offset = 0x04,
- .reg_value = 0x20000,
- },
- },
- .bus_freq_mhz = 78,
- },
- {
- .name = "debug_ctrl_ao_PERI_AO2",
- .base = PERI_AO2_BASE,
- .num_ports = 20,
- .num_idle_mask = 0,
- .bus_freq_mhz = 78,
- },
- {
- .name = "debug_ctrl_ao_PERI_PAR_AO",
- .base = PERI_PAR_AO_BASE,
- .num_ports = 18,
- .num_idle_mask = 0,
- .bus_freq_mhz = 78,
- },
- {
- .name = "debug_ctrl_ao_FMEM_AO",
- .base = FMEM_AO_BASE,
- .num_ports = 28,
- .num_idle_mask = 1,
- .idle_masks = {
- {
- .reg_offset = 0x14,
- .reg_value = 0x204,
- },
- },
- .bus_freq_mhz = 78,
- },
- },
+ .num_used_monitors = ARRAY_SIZE(monitors),
+ .monitors = monitors,
};