Yidi Lin has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/84958?usp=email )
Change subject: soc/mediatek/common: Refactor `struct tracker` ......................................................................
soc/mediatek/common: Refactor `struct tracker`
Rather than using a static array size for the `offset` variable, use a pointer named `offsets` that points to a dynamically allocated array. A separate variable called `offset_size` stores the size of this array.
TEST=emerge-corsola coreboot && emerge-geralt coreboot
Change-Id: I4b89c27fd693ee08e670c1a9ab4cbdbec220bee7 Signed-off-by: Yidi Lin yidilin@chromium.org --- M src/soc/mediatek/common/include/soc/tracker_common.h M src/soc/mediatek/common/tracker.c M src/soc/mediatek/common/tracker_v1.c M src/soc/mediatek/common/tracker_v2.c 4 files changed, 20 insertions(+), 11 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/58/84958/1
diff --git a/src/soc/mediatek/common/include/soc/tracker_common.h b/src/soc/mediatek/common/include/soc/tracker_common.h index 0269457..ee9d94c 100644 --- a/src/soc/mediatek/common/include/soc/tracker_common.h +++ b/src/soc/mediatek/common/include/soc/tracker_common.h @@ -16,7 +16,8 @@ uintptr_t base_addr; u32 timeout; u32 entry; - u32 offset[2]; + u32 *offsets; + u32 offsets_size; const char *str; };
diff --git a/src/soc/mediatek/common/tracker.c b/src/soc/mediatek/common/tracker.c index 3485449..1341d5a 100644 --- a/src/soc/mediatek/common/tracker.c +++ b/src/soc/mediatek/common/tracker.c @@ -25,10 +25,10 @@ continue;
printk(BIOS_INFO, "**Dump %s debug register start**\n", tra->str); - for (k = 0; k < 2; k++) { + for (k = 0; k < tra->offsets_size; k++) { size = 2 * tra->entry; for (i = 0; i < size; i++) { - reg = tra->base_addr + tra->offset[k] + i * 4; + reg = tra->base_addr + tra->offsets[k] + i * 4; printk(BIOS_INFO, "%#lx:%#x,", reg, read32((void *)reg));
if (i % 4 == 3 || i == size - 1) diff --git a/src/soc/mediatek/common/tracker_v1.c b/src/soc/mediatek/common/tracker_v1.c index 746951b..b2736c4 100644 --- a/src/soc/mediatek/common/tracker_v1.c +++ b/src/soc/mediatek/common/tracker_v1.c @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */
+#include <commonlib/bsd/helpers.h> #include <soc/addressmap.h> #include <soc/tracker.h> #include <soc/tracker_common.h> @@ -9,13 +10,16 @@ * offset[0] dump from offset 0x100 ~ 0x13C. * offset[1] dump from offset 0x200 ~ 0x23C. */ + +static u32 offsets[] = { AR_TRACK_OFFSET, AW_TRACK_OFFSET }; + struct tracker tracker_data[TRACKER_NUM] = { [TRACKER_SYSTRACKER] = { .base_addr = DBG_TRACKER_BASE, .timeout = BUS_DBG_CON_TIMEOUT, .entry = SYS_TRACK_ENTRY, - .offset[0] = AR_TRACK_OFFSET, - .offset[1] = AW_TRACK_OFFSET, + .offsets = offsets, + .offsets_size = ARRAY_SIZE(offsets), .str = "systracker", }, }; diff --git a/src/soc/mediatek/common/tracker_v2.c b/src/soc/mediatek/common/tracker_v2.c index fecde16..415cd0b 100644 --- a/src/soc/mediatek/common/tracker_v2.c +++ b/src/soc/mediatek/common/tracker_v2.c @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */
+#include <commonlib/bsd/helpers.h> #include <device/mmio.h> #include <soc/addressmap.h> #include <soc/tracker.h> @@ -18,29 +19,32 @@ * offset[0] dump from offset 0x100 ~ 0x2F8 * offset[1] dump from offset 0x300 ~ 0x4FC */ + +static u32 offsets[] = { AR_TRACK_OFFSET, AW_TRACK_OFFSET }; + struct tracker tracker_data[TRACKER_NUM] = { [TRACKER_SYSTRACKER] = { .base_addr = DBG_TRACKER_BASE, .timeout = BUS_DBG_CON_TIMEOUT, .entry = SYS_TRACK_ENTRY, - .offset[0] = AR_TRACK_OFFSET, - .offset[1] = AW_TRACK_OFFSET, + .offsets = offsets, + .offsets_size = ARRAY_SIZE(offsets), .str = "systracker", }, [TRACKER_INFRATRACKER] = { .base_addr = INFRA_TRACKER_BASE, .timeout = BUSTRACKER_TIMEOUT, .entry = INFRA_ENTRY_NUM, - .offset[0] = AR_TRACK_OFFSET, - .offset[1] = AW_TRACK_OFFSET, + .offsets = offsets, + .offsets_size = ARRAY_SIZE(offsets), .str = "infra_tracker", }, [TRACKER_PERISYSTRACKER] = { .base_addr = PERI_TRACKER_BASE, .timeout = BUSTRACKER_TIMEOUT, .entry = PERI_ENTRY_NUM, - .offset[0] = AR_TRACK_OFFSET, - .offset[1] = AW_TRACK_OFFSET, + .offsets = offsets, + .offsets_size = ARRAY_SIZE(offsets), .str = "peri_tracker", }, };