summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/soc/mediatek/common/include/soc/tracker_common.h36
-rw-r--r--src/soc/mediatek/common/include/soc/tracker_v1.h16
-rw-r--r--src/soc/mediatek/common/include/soc/tracker_v2.h31
-rw-r--r--src/soc/mediatek/common/tracker.c87
-rw-r--r--src/soc/mediatek/common/tracker_v1.c21
-rw-r--r--src/soc/mediatek/common/tracker_v2.c82
-rw-r--r--src/soc/mediatek/mt8192/Makefile.inc2
-rw-r--r--src/soc/mediatek/mt8192/include/soc/tracker.h8
-rw-r--r--src/soc/mediatek/mt8195/Makefile.inc2
-rw-r--r--src/soc/mediatek/mt8195/include/soc/tracker.h8
10 files changed, 182 insertions, 111 deletions
diff --git a/src/soc/mediatek/common/include/soc/tracker_common.h b/src/soc/mediatek/common/include/soc/tracker_common.h
index a68d329a25..02694579e1 100644
--- a/src/soc/mediatek/common/include/soc/tracker_common.h
+++ b/src/soc/mediatek/common/include/soc/tracker_common.h
@@ -1,25 +1,9 @@
/* SPDX-License-Identifier: GPL-2.0-only */
-#ifndef SOC_MEDIATEK_COMMON_TRACKER_H
-#define SOC_MEDIATEK_COMMON_TRACKER_H
+#ifndef SOC_MEDIATEK_TRACKER_COMMON_H
+#define SOC_MEDIATEK_TRACKER_COMMON_H
-#define BUS_DBG_CON 0x000
-#define BUS_DBG_TIMER_CON0 0x004
-#define BUS_DBG_TIMER_CON1 0x008
-#define BUS_TRACE_CON_1 0x900
-#define BUS_TRACE_CON_AO_1 0x9FC
-#define BUS_TRACE_CON_2 0xA00
-#define BUS_TRACE_CON_AO_2 0xAFC
-#define BUS_TRACE_EN 16
-
-#define SYS_TRACK_ENTRY 64
-#define INFRA_ENTRY_NUM 32
-#define PERI_ENTRY_NUM 16
-
-#define AR_TRACK_OFFSET 0x0100
-#define AW_TRACK_OFFSET 0x0300
-
-#define BUSTRACKER_TIMEOUT 0x300
+#include <stdint.h>
#define BUS_DBG_CON_IRQ_AR_STA0 0x00000100
#define BUS_DBG_CON_IRQ_AW_STA0 0x00000200
@@ -28,13 +12,17 @@
#define BUS_DBG_CON_TIMEOUT (BUS_DBG_CON_IRQ_AR_STA0 | BUS_DBG_CON_IRQ_AW_STA0 | \
BUS_DBG_CON_IRQ_AR_STA1 | BUS_DBG_CON_IRQ_AW_STA1)
-enum {
- TRACKER_SYSTRACKER = 0,
- TRACKER_INFRATRACKER,
- TRACKER_PERISYSTRACKER,
- TRACKER_NUM,
+struct tracker {
+ uintptr_t base_addr;
+ u32 timeout;
+ u32 entry;
+ u32 offset[2];
+ const char *str;
};
+extern struct tracker tracker_data[];
+
+void tracker_setup(void);
void bustracker_init(void);
#endif
diff --git a/src/soc/mediatek/common/include/soc/tracker_v1.h b/src/soc/mediatek/common/include/soc/tracker_v1.h
new file mode 100644
index 0000000000..e2a4b67159
--- /dev/null
+++ b/src/soc/mediatek/common/include/soc/tracker_v1.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef SOC_MEDIATEK_TRACKER_V1_H
+#define SOC_MEDIATEK_TRACKER_V1_H
+
+#define SYS_TRACK_ENTRY 8
+
+#define AR_TRACK_OFFSET 0x0100
+#define AW_TRACK_OFFSET 0x0200
+
+enum {
+ TRACKER_SYSTRACKER = 0,
+ TRACKER_NUM,
+};
+
+#endif
diff --git a/src/soc/mediatek/common/include/soc/tracker_v2.h b/src/soc/mediatek/common/include/soc/tracker_v2.h
new file mode 100644
index 0000000000..e7bf8df865
--- /dev/null
+++ b/src/soc/mediatek/common/include/soc/tracker_v2.h
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef SOC_MEDIATEK_TRACKER_V2_H
+#define SOC_MEDIATEK_TRACKER_V2_H
+
+#define BUS_DBG_CON 0x000
+#define BUS_DBG_TIMER_CON0 0x004
+#define BUS_DBG_TIMER_CON1 0x008
+#define BUS_TRACE_CON_1 0x900
+#define BUS_TRACE_CON_AO_1 0x9FC
+#define BUS_TRACE_CON_2 0xA00
+#define BUS_TRACE_CON_AO_2 0xAFC
+#define BUS_TRACE_EN 16
+
+#define SYS_TRACK_ENTRY 64
+#define INFRA_ENTRY_NUM 32
+#define PERI_ENTRY_NUM 16
+
+#define AR_TRACK_OFFSET 0x0100
+#define AW_TRACK_OFFSET 0x0300
+
+#define BUSTRACKER_TIMEOUT 0x300
+
+enum {
+ TRACKER_SYSTRACKER = 0,
+ TRACKER_INFRATRACKER,
+ TRACKER_PERISYSTRACKER,
+ TRACKER_NUM,
+};
+
+#endif
diff --git a/src/soc/mediatek/common/tracker.c b/src/soc/mediatek/common/tracker.c
index 6d4e6b2f05..f3b2e9bfd8 100644
--- a/src/soc/mediatek/common/tracker.c
+++ b/src/soc/mediatek/common/tracker.c
@@ -1,81 +1,11 @@
/* SPDX-License-Identifier: GPL-2.0-only */
-#include <stdio.h>
#include <console/console.h>
#include <device/mmio.h>
#include <soc/addressmap.h>
+#include <soc/tracker.h>
#include <soc/tracker_common.h>
-static struct tracker {
- uintptr_t base_addr;
- u32 timeout;
- u32 entry;
- u32 offset[2];
- const char *str;
-} 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,
- .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,
- .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,
- .str = "peri_tracker",
- },
-};
-
-static void setup_init(void)
-{
- u32 val;
- /*
- * Set infra/peri tracker timeout.
- * timeout = clock_in_mhz * 1000 / 16 * timeout_in_ms
- *
- * timeout: 200ms
- * infra tracker clock: 156MHz
- * peri tracker clock: 78MHz
- */
- val = 156 * 1000 / 16 * 200;
- write32((void *)(INFRA_TRACKER_BASE + BUS_DBG_TIMER_CON0), val);
- write32((void *)(INFRA_TRACKER_BASE + BUS_DBG_TIMER_CON1), val);
-
- val = 78 * 1000 / 16 * 200;
- write32((void *)(PERI_TRACKER_BASE + BUS_DBG_TIMER_CON0), val);
- write32((void *)(PERI_TRACKER_BASE + BUS_DBG_TIMER_CON1), val);
-
- /* Enable infra/peri tracer because tracker and tracer share the same enable bit. */
- write32((void *)(BUS_TRACE_MONITOR_BASE + BUS_TRACE_CON_1), 1 << BUS_TRACE_EN);
- write32((void *)(BUS_TRACE_MONITOR_BASE + BUS_TRACE_CON_2), 1 << BUS_TRACE_EN);
-
- /*
- * Enable infra/peri tracker.
- * bit[0] - BUS_DBG_EN
- * bit[1] - TIMEOUT_EN
- * bit[2] - SLV_ERR_EN
- * bit[13] - HALT_ON_TIMEOUT_EN
- * bit[14] - BUS_OT_WEN_CTRL
- */
- val = BIT(0) | BIT(1) | BIT(2) | BIT(13) | BIT(14);
- write32((void *)(BUS_TRACE_MONITOR_BASE + BUS_TRACE_CON_AO_1), val);
- write32((void *)(BUS_TRACE_MONITOR_BASE + BUS_TRACE_CON_AO_2), val);
-
-}
-
static void tracker_dump_data(void)
{
int i, j, k;
@@ -91,19 +21,6 @@ static void tracker_dump_data(void)
printk(BIOS_INFO, "**Dump %s debug register start**\n", tra->str);
for (k = 0; k < 2; k++) {
- /*
- * for systracker:
- * offset[0] dump from offset 0x100 ~ 0x2F8.
- * offset[1] dump from offset 0x300 ~ 0x4FC
- *
- * for infra tracker:
- * offset[0] dump from offset 0x100 ~ 0x1F8
- * offset[1] dump from offset 0x300 ~ 0x3FC
- *
- * for perisys tracker:
- * offset[0] dump from offset 0x100 ~ 0x2F8
- * offset[1] dump from offset 0x300 ~ 0x4FC
- */
size = 2 * tra->entry;
for (i = 0; i < size; i++) {
reg = tra->base_addr + tra->offset[k] + i * 4;
@@ -121,5 +38,5 @@ static void tracker_dump_data(void)
void bustracker_init(void)
{
tracker_dump_data();
- setup_init();
+ tracker_setup();
}
diff --git a/src/soc/mediatek/common/tracker_v1.c b/src/soc/mediatek/common/tracker_v1.c
new file mode 100644
index 0000000000..746951b8de
--- /dev/null
+++ b/src/soc/mediatek/common/tracker_v1.c
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <soc/addressmap.h>
+#include <soc/tracker.h>
+#include <soc/tracker_common.h>
+
+/*
+ * for systracker:
+ * offset[0] dump from offset 0x100 ~ 0x13C.
+ * offset[1] dump from offset 0x200 ~ 0x23C.
+ */
+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,
+ .str = "systracker",
+ },
+};
diff --git a/src/soc/mediatek/common/tracker_v2.c b/src/soc/mediatek/common/tracker_v2.c
new file mode 100644
index 0000000000..fecde161fd
--- /dev/null
+++ b/src/soc/mediatek/common/tracker_v2.c
@@ -0,0 +1,82 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <device/mmio.h>
+#include <soc/addressmap.h>
+#include <soc/tracker.h>
+#include <soc/tracker_common.h>
+
+/*
+ * for systracker:
+ * offset[0] dump from offset 0x100 ~ 0x2F8.
+ * offset[1] dump from offset 0x300 ~ 0x4FC
+ *
+ * for infra tracker:
+ * offset[0] dump from offset 0x100 ~ 0x1F8
+ * offset[1] dump from offset 0x300 ~ 0x3FC
+ *
+ * for perisys tracker:
+ * offset[0] dump from offset 0x100 ~ 0x2F8
+ * offset[1] dump from offset 0x300 ~ 0x4FC
+ */
+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,
+ .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,
+ .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,
+ .str = "peri_tracker",
+ },
+};
+
+void tracker_setup(void)
+{
+ u32 val;
+ /*
+ * Set infra/peri tracker timeout.
+ * timeout = clock_in_mhz * 1000 / 16 * timeout_in_ms
+ *
+ * timeout: 200ms
+ * infra tracker clock: 156MHz
+ * peri tracker clock: 78MHz
+ */
+ val = 156 * 1000 / 16 * 200;
+ write32((void *)(INFRA_TRACKER_BASE + BUS_DBG_TIMER_CON0), val);
+ write32((void *)(INFRA_TRACKER_BASE + BUS_DBG_TIMER_CON1), val);
+
+ val = 78 * 1000 / 16 * 200;
+ write32((void *)(PERI_TRACKER_BASE + BUS_DBG_TIMER_CON0), val);
+ write32((void *)(PERI_TRACKER_BASE + BUS_DBG_TIMER_CON1), val);
+
+ /* Enable infra/peri tracer because tracker and tracer share the same enable bit. */
+ write32((void *)(BUS_TRACE_MONITOR_BASE + BUS_TRACE_CON_1), 1 << BUS_TRACE_EN);
+ write32((void *)(BUS_TRACE_MONITOR_BASE + BUS_TRACE_CON_2), 1 << BUS_TRACE_EN);
+
+ /*
+ * Enable infra/peri tracker.
+ * bit[0] - BUS_DBG_EN
+ * bit[1] - TIMEOUT_EN
+ * bit[2] - SLV_ERR_EN
+ * bit[13] - HALT_ON_TIMEOUT_EN
+ * bit[14] - BUS_OT_WEN_CTRL
+ */
+ val = BIT(0) | BIT(1) | BIT(2) | BIT(13) | BIT(14);
+ write32((void *)(BUS_TRACE_MONITOR_BASE + BUS_TRACE_CON_AO_1), val);
+ write32((void *)(BUS_TRACE_MONITOR_BASE + BUS_TRACE_CON_AO_2), val);
+}
diff --git a/src/soc/mediatek/mt8192/Makefile.inc b/src/soc/mediatek/mt8192/Makefile.inc
index b04acb56f1..aeb50a729b 100644
--- a/src/soc/mediatek/mt8192/Makefile.inc
+++ b/src/soc/mediatek/mt8192/Makefile.inc
@@ -10,7 +10,7 @@ bootblock-y += ../common/mmu_operations.c
bootblock-y += ../common/pll.c pll.c
bootblock-$(CONFIG_SPI_FLASH) += ../common/spi.c spi.c
bootblock-y += ../common/timer.c
-bootblock-y += ../common/tracker.c
+bootblock-y += ../common/tracker.c ../common/tracker_v2.c
bootblock-y += ../common/uart.c
bootblock-y += ../common/wdt.c
diff --git a/src/soc/mediatek/mt8192/include/soc/tracker.h b/src/soc/mediatek/mt8192/include/soc/tracker.h
new file mode 100644
index 0000000000..0b6281114f
--- /dev/null
+++ b/src/soc/mediatek/mt8192/include/soc/tracker.h
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef SOC_MEDIATEK_MT8192_TRACKER_H
+#define SOC_MEDIATEK_MT8192_TRACKER_H
+
+#include <soc/tracker_v2.h>
+
+#endif
diff --git a/src/soc/mediatek/mt8195/Makefile.inc b/src/soc/mediatek/mt8195/Makefile.inc
index a7ada28054..8ab78a80e2 100644
--- a/src/soc/mediatek/mt8195/Makefile.inc
+++ b/src/soc/mediatek/mt8195/Makefile.inc
@@ -7,7 +7,7 @@ bootblock-y += ../common/flash_controller.c
bootblock-y += ../common/gpio.c gpio.c
bootblock-y += ../common/i2c.c i2c.c
bootblock-y += ../common/mmu_operations.c
-bootblock-y += ../common/tracker.c
+bootblock-y += ../common/tracker.c ../common/tracker_v2.c
bootblock-y += ../common/pll.c pll.c
bootblock-$(CONFIG_SPI_FLASH) += ../common/spi.c spi.c
bootblock-y += ../common/timer.c timer.c
diff --git a/src/soc/mediatek/mt8195/include/soc/tracker.h b/src/soc/mediatek/mt8195/include/soc/tracker.h
new file mode 100644
index 0000000000..293ce3ca7f
--- /dev/null
+++ b/src/soc/mediatek/mt8195/include/soc/tracker.h
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef SOC_MEDIATEK_MT8195_TRACKER_H
+#define SOC_MEDIATEK_MT8195_TRACKER_H
+
+#include <soc/tracker_v2.h>
+
+#endif