soc/mediatek/mt8196: Refactor tracker driver to support new platform
Extract the common parts of the mt8196 tracker driver into tracker_v3 to improve code reusability. BUG=b:379008996 BRANCH=skywalker TEST=build passed. Signed-off-by: Zexin Wang <ot_zexin.wang@mediatek.corp-partner.google.com> Change-Id: If71bffe03cd2c30a0e9b3057c39667c1c2fdcb62 Reviewed-on: https://review.coreboot.org/c/coreboot/+/89032 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Yu-Ping Wu <yupingso@google.com> Reviewed-by: Yidi Lin <yidilin@google.com>
This commit is contained in:
parent
97f9ebb5c2
commit
382a7caff3
5 changed files with 104 additions and 84 deletions
20
src/soc/mediatek/common/include/soc/tracker_v3.h
Normal file
20
src/soc/mediatek/common/include/soc/tracker_v3.h
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only OR MIT */
|
||||
|
||||
#ifndef SOC_MEDIATEK_TRACKER_V3_H
|
||||
#define SOC_MEDIATEK_TRACKER_V3_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define TRACKER_V3_OFFSETS_SIZE 8
|
||||
#define AR_TRACK_LOG_OFFSET 0x0200
|
||||
#define AR_ENTRY_ID_OFFSET 0x0300
|
||||
#define AR_TRACK_L_OFFSET 0x0400
|
||||
#define AR_TRACK_H_OFFSET 0x0600
|
||||
#define AW_TRACK_LOG_OFFSET 0x0800
|
||||
#define AW_ENTRY_ID_OFFSET 0x0900
|
||||
#define AW_TRACK_L_OFFSET 0x0A00
|
||||
#define AW_TRACK_H_OFFSET 0x0C00
|
||||
|
||||
extern const u32 tracker_v3_offsets[];
|
||||
|
||||
#endif
|
||||
76
src/soc/mediatek/common/tracker_v3.c
Normal file
76
src/soc/mediatek/common/tracker_v3.c
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only OR MIT */
|
||||
|
||||
#include <commonlib/bsd/helpers.h>
|
||||
#include <console/console.h>
|
||||
#include <device/mmio.h>
|
||||
#include <soc/addressmap.h>
|
||||
#include <soc/tracker.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 vlpsys tracker:
|
||||
* offset[0] dump from offset 0x100 ~ 0x2F8
|
||||
* offset[1] dump from offset 0x300 ~ 0x4FC
|
||||
*/
|
||||
|
||||
const u32 tracker_v3_offsets[TRACKER_V3_OFFSETS_SIZE] = {
|
||||
AR_TRACK_LOG_OFFSET, AR_ENTRY_ID_OFFSET, AR_TRACK_L_OFFSET,
|
||||
AR_TRACK_H_OFFSET, AW_TRACK_LOG_OFFSET, AW_ENTRY_ID_OFFSET,
|
||||
AW_TRACK_L_OFFSET, AW_TRACK_H_OFFSET,
|
||||
};
|
||||
|
||||
__weak void tracker_setup(void)
|
||||
{
|
||||
/* do nothing. */
|
||||
}
|
||||
|
||||
static void tracker_dump_data(void)
|
||||
{
|
||||
u64 reg_entry;
|
||||
int i, j;
|
||||
uintptr_t reg_log, reg_id, reg_low, reg_high;
|
||||
struct tracker *tra;
|
||||
|
||||
for (j = 0; j < TRACKER_NUM; j++) {
|
||||
tra = &tracker_data[j];
|
||||
|
||||
if (!(read32p(tra->base_addr) & tra->timeout))
|
||||
continue;
|
||||
printk(BIOS_INFO, "**Dump %s ar debug register start**\n", tra->str);
|
||||
for (i = 0; i < tra->entry; i++) {
|
||||
reg_log = tra->base_addr + tra->offsets[0] + i * 4;
|
||||
reg_id = tra->base_addr + tra->offsets[1] + i * 4;
|
||||
reg_low = tra->base_addr + tra->offsets[2] + i * 4;
|
||||
reg_high = tra->base_addr + tra->offsets[3] + i * 4;
|
||||
reg_entry = ((u64)read32p(reg_high)) << 32 | read32p(reg_low);
|
||||
printk(BIOS_INFO, "%#lx:%#x:%#x:%#x:%#x:%#llx\n",
|
||||
reg_low, read32p(reg_log), read32p(reg_id), read32p(reg_low),
|
||||
read32p(reg_high), reg_entry);
|
||||
}
|
||||
printk(BIOS_INFO, "**Dump %s aw debug register start**\n", tra->str);
|
||||
for (i = 0; i < tra->entry; i++) {
|
||||
reg_log = tra->base_addr + tra->offsets[4] + i * 4;
|
||||
reg_id = tra->base_addr + tra->offsets[5] + i * 4;
|
||||
reg_low = tra->base_addr + tra->offsets[6] + i * 4;
|
||||
reg_high = tra->base_addr + tra->offsets[7] + i * 4;
|
||||
reg_entry = ((u64)read32p(reg_high)) << 32 | read32p(reg_low);
|
||||
printk(BIOS_INFO, "%#lx:%#x:%#x:%#x:%#x:%#llx\n",
|
||||
reg_low, read32p(reg_log), read32p(reg_id), read32p(reg_low),
|
||||
read32p(reg_high), reg_entry);
|
||||
}
|
||||
printk(BIOS_INFO, "**Dump %s debug register end**\n", tra->str);
|
||||
}
|
||||
}
|
||||
|
||||
void bustracker_init(void)
|
||||
{
|
||||
tracker_dump_data();
|
||||
tracker_setup();
|
||||
}
|
||||
|
|
@ -21,7 +21,7 @@ bootblock-y += mminfra.c
|
|||
bootblock-y += ../common/mmu_operations.c
|
||||
bootblock-y += mtcmos.c
|
||||
bootblock-$(CONFIG_PCI) += ../common/pcie.c pcie.c
|
||||
bootblock-y += tracker.c
|
||||
bootblock-y += ../common/tracker_v3.c tracker.c
|
||||
bootblock-y += ../common/wdt.c ../common/wdt_req.c wdt.c
|
||||
|
||||
romstage-y += ../common/cbmem.c
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#define SOC_MEDIATEK_MT8196_TRACKER_H
|
||||
|
||||
#include <soc/tracker_common.h>
|
||||
#include <stdint.h>
|
||||
#include <soc/tracker_v3.h>
|
||||
|
||||
#define BUS_DBG_CON 0x000
|
||||
#define BUS_TRACE_CON_AO_PRESCALE 0x8f8
|
||||
|
|
@ -21,17 +21,6 @@
|
|||
#define INFRA_ENTRY_NUM 32
|
||||
#define VLP_ENTRY_NUM 4
|
||||
|
||||
#define AR_TRACK_LOG_OFFSET 0x0200
|
||||
#define AR_ENTRY_ID_OFFSET 0x0300
|
||||
#define AR_TRACK_L_OFFSET 0x0400
|
||||
#define AR_TRACK_H_OFFSET 0x0600
|
||||
#define AW_TRACK_LOG_OFFSET 0x0800
|
||||
#define AW_ENTRY_ID_OFFSET 0x0900
|
||||
#define AW_TRACK_L_OFFSET 0x0A00
|
||||
#define AW_TRACK_H_OFFSET 0x0C00
|
||||
|
||||
#define BUSTRACKER_TIMEOUT 0x300
|
||||
|
||||
enum {
|
||||
TRACKER_SYSTRACKER = 0,
|
||||
TRACKER_INFRATRACKER,
|
||||
|
|
|
|||
|
|
@ -1,54 +1,33 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
|
||||
#include <commonlib/bsd/helpers.h>
|
||||
#include <console/console.h>
|
||||
#include <device/mmio.h>
|
||||
#include <soc/addressmap.h>
|
||||
#include <soc/tracker.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 vlpsys tracker:
|
||||
* offset[0] dump from offset 0x100 ~ 0x2F8
|
||||
* offset[1] dump from offset 0x300 ~ 0x4FC
|
||||
*/
|
||||
|
||||
static const u32 offsets[] = {
|
||||
AR_TRACK_LOG_OFFSET, AR_ENTRY_ID_OFFSET, AR_TRACK_L_OFFSET,
|
||||
AR_TRACK_H_OFFSET, AW_TRACK_LOG_OFFSET, AW_ENTRY_ID_OFFSET,
|
||||
AW_TRACK_L_OFFSET, AW_TRACK_H_OFFSET,
|
||||
};
|
||||
|
||||
struct tracker tracker_data[TRACKER_NUM] = {
|
||||
[TRACKER_SYSTRACKER] = {
|
||||
.base_addr = INFRA_TRACKER_BASE,
|
||||
.timeout = BUS_DBG_CON_TIMEOUT,
|
||||
.entry = SYS_TRACK_ENTRY,
|
||||
.offsets = offsets,
|
||||
.offsets_size = ARRAY_SIZE(offsets),
|
||||
.offsets = tracker_v3_offsets,
|
||||
.offsets_size = TRACKER_V3_OFFSETS_SIZE,
|
||||
.str = "systracker",
|
||||
},
|
||||
[TRACKER_INFRATRACKER] = {
|
||||
.base_addr = INFRA_TRACKER_BASE,
|
||||
.timeout = BUS_DBG_CON_TIMEOUT,
|
||||
.entry = INFRA_ENTRY_NUM,
|
||||
.offsets = offsets,
|
||||
.offsets_size = ARRAY_SIZE(offsets),
|
||||
.offsets = tracker_v3_offsets,
|
||||
.offsets_size = TRACKER_V3_OFFSETS_SIZE,
|
||||
.str = "infra_tracker",
|
||||
},
|
||||
[TRACKER_VLPSYSTRACKER] = {
|
||||
.base_addr = VLP_TRACKER_BASE,
|
||||
.timeout = BUS_DBG_CON_TIMEOUT,
|
||||
.entry = VLP_ENTRY_NUM,
|
||||
.offsets = offsets,
|
||||
.offsets_size = ARRAY_SIZE(offsets),
|
||||
.offsets = tracker_v3_offsets,
|
||||
.offsets_size = TRACKER_V3_OFFSETS_SIZE,
|
||||
.str = "vlp_tracker",
|
||||
},
|
||||
};
|
||||
|
|
@ -83,47 +62,3 @@ void tracker_setup(void)
|
|||
write32p(BUS_TRACE_MONITOR_BASE + BUS_TRACE_CON_AO_1, val);
|
||||
write32p(BUS_TRACE_MONITOR_BASE + BUS_TRACE_CON_AO_2, val);
|
||||
}
|
||||
|
||||
static void tracker_dump_data(void)
|
||||
{
|
||||
u64 reg_entry;
|
||||
int i, j;
|
||||
uintptr_t reg_log, reg_id, reg_low, reg_high;
|
||||
struct tracker *tra;
|
||||
|
||||
for (j = 0; j < TRACKER_NUM; j++) {
|
||||
tra = &tracker_data[j];
|
||||
|
||||
if (!(read32p(tra->base_addr) & tra->timeout))
|
||||
continue;
|
||||
printk(BIOS_INFO, "**Dump %s ar debug register start**\n", tra->str);
|
||||
for (i = 0; i < tra->entry; i++) {
|
||||
reg_log = tra->base_addr + tra->offsets[0] + i * 4;
|
||||
reg_id = tra->base_addr + tra->offsets[1] + i * 4;
|
||||
reg_low = tra->base_addr + tra->offsets[2] + i * 4;
|
||||
reg_high = tra->base_addr + tra->offsets[3] + i * 4;
|
||||
reg_entry = ((u64)read32p(reg_high)) << 32 | read32p(reg_low);
|
||||
printk(BIOS_INFO, "%#lx:%#x:%#x:%#x:%#x:%#llx\n",
|
||||
reg_low, read32p(reg_log), read32p(reg_id), read32p(reg_low),
|
||||
read32p(reg_high), reg_entry);
|
||||
}
|
||||
printk(BIOS_INFO, "**Dump %s aw debug register start**\n", tra->str);
|
||||
for (i = 0; i < tra->entry; i++) {
|
||||
reg_log = tra->base_addr + tra->offsets[4] + i * 4;
|
||||
reg_id = tra->base_addr + tra->offsets[5] + i * 4;
|
||||
reg_low = tra->base_addr + tra->offsets[6] + i * 4;
|
||||
reg_high = tra->base_addr + tra->offsets[7] + i * 4;
|
||||
reg_entry = ((u64)read32p(reg_high)) << 32 | read32p(reg_low);
|
||||
printk(BIOS_INFO, "%#lx:%#x:%#x:%#x:%#x:%#llx\n",
|
||||
reg_low, read32p(reg_log), read32p(reg_id), read32p(reg_low),
|
||||
read32p(reg_high), reg_entry);
|
||||
}
|
||||
printk(BIOS_INFO, "**Dump %s debug register end**\n", tra->str);
|
||||
}
|
||||
}
|
||||
|
||||
void bustracker_init(void)
|
||||
{
|
||||
tracker_dump_data();
|
||||
tracker_setup();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue