mb/system76/cml-u/dt: Make use of chipset devicetree
[coreboot.git] / src / soc / mediatek / common / tracker_v2.c
blobfecde161fdf84d9a4862f7dad7d6acbc20a516b3
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <device/mmio.h>
4 #include <soc/addressmap.h>
5 #include <soc/tracker.h>
6 #include <soc/tracker_common.h>
8 /*
9 * for systracker:
10 * offset[0] dump from offset 0x100 ~ 0x2F8.
11 * offset[1] dump from offset 0x300 ~ 0x4FC
13 * for infra tracker:
14 * offset[0] dump from offset 0x100 ~ 0x1F8
15 * offset[1] dump from offset 0x300 ~ 0x3FC
17 * for perisys tracker:
18 * offset[0] dump from offset 0x100 ~ 0x2F8
19 * offset[1] dump from offset 0x300 ~ 0x4FC
21 struct tracker tracker_data[TRACKER_NUM] = {
22 [TRACKER_SYSTRACKER] = {
23 .base_addr = DBG_TRACKER_BASE,
24 .timeout = BUS_DBG_CON_TIMEOUT,
25 .entry = SYS_TRACK_ENTRY,
26 .offset[0] = AR_TRACK_OFFSET,
27 .offset[1] = AW_TRACK_OFFSET,
28 .str = "systracker",
30 [TRACKER_INFRATRACKER] = {
31 .base_addr = INFRA_TRACKER_BASE,
32 .timeout = BUSTRACKER_TIMEOUT,
33 .entry = INFRA_ENTRY_NUM,
34 .offset[0] = AR_TRACK_OFFSET,
35 .offset[1] = AW_TRACK_OFFSET,
36 .str = "infra_tracker",
38 [TRACKER_PERISYSTRACKER] = {
39 .base_addr = PERI_TRACKER_BASE,
40 .timeout = BUSTRACKER_TIMEOUT,
41 .entry = PERI_ENTRY_NUM,
42 .offset[0] = AR_TRACK_OFFSET,
43 .offset[1] = AW_TRACK_OFFSET,
44 .str = "peri_tracker",
48 void tracker_setup(void)
50 u32 val;
52 * Set infra/peri tracker timeout.
53 * timeout = clock_in_mhz * 1000 / 16 * timeout_in_ms
55 * timeout: 200ms
56 * infra tracker clock: 156MHz
57 * peri tracker clock: 78MHz
59 val = 156 * 1000 / 16 * 200;
60 write32((void *)(INFRA_TRACKER_BASE + BUS_DBG_TIMER_CON0), val);
61 write32((void *)(INFRA_TRACKER_BASE + BUS_DBG_TIMER_CON1), val);
63 val = 78 * 1000 / 16 * 200;
64 write32((void *)(PERI_TRACKER_BASE + BUS_DBG_TIMER_CON0), val);
65 write32((void *)(PERI_TRACKER_BASE + BUS_DBG_TIMER_CON1), val);
67 /* Enable infra/peri tracer because tracker and tracer share the same enable bit. */
68 write32((void *)(BUS_TRACE_MONITOR_BASE + BUS_TRACE_CON_1), 1 << BUS_TRACE_EN);
69 write32((void *)(BUS_TRACE_MONITOR_BASE + BUS_TRACE_CON_2), 1 << BUS_TRACE_EN);
72 * Enable infra/peri tracker.
73 * bit[0] - BUS_DBG_EN
74 * bit[1] - TIMEOUT_EN
75 * bit[2] - SLV_ERR_EN
76 * bit[13] - HALT_ON_TIMEOUT_EN
77 * bit[14] - BUS_OT_WEN_CTRL
79 val = BIT(0) | BIT(1) | BIT(2) | BIT(13) | BIT(14);
80 write32((void *)(BUS_TRACE_MONITOR_BASE + BUS_TRACE_CON_AO_1), val);
81 write32((void *)(BUS_TRACE_MONITOR_BASE + BUS_TRACE_CON_AO_2), val);