soc/mediatek/mt8189: Add CPU segment ID support

Some of MTK's ICs (such as the MT8189) use two eFuse registers to
record CPU ID information.

Users can use get_cpu_id and get_cpu_segment_id to obtain the SoC
version. For example, the CPU ID of the MT8189H is 0x81890000, and
the CPU segment ID is 0x21.

BUG=b:379008996
BRANCH=none
TEST=build pass

Signed-off-by: Vince Liu <vince-wl.liu@mediatek.corp-partner.google.com>
Change-Id: I535874025cde7f6f975246105e32e165083601e0
Reviewed-on: https://review.coreboot.org/c/coreboot/+/87509
Reviewed-by: Yidi Lin <yidilin@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
This commit is contained in:
Vince Liu 2024-12-11 11:39:49 +08:00 committed by Yidi Lin
commit f83fb11e5f
3 changed files with 39 additions and 0 deletions

View file

@ -0,0 +1,15 @@
/* SPDX-License-Identifier: GPL-2.0-only OR MIT */
#include <console/console.h>
#include <device/mmio.h>
#include <soc/cpu_id.h>
#include <soc/efuse.h>
u32 get_cpu_segment_id(void)
{
u32 id = read32(&mtk_efuse->cpu_seg_id_reg);
printk(BIOS_INFO, "CPU Segment ID: %#x\n", id);
return id;
}

View file

@ -5,7 +5,11 @@
#define MTK_CPU_ID_MT8186G 0x81861001
#define MTK_CPU_ID_MT8186T 0x81862001
#define MTK_CPU_ID_MT8189 0x81890000
#define MTK_CPU_SEG_ID_MT8189G 0x20
#define MTK_CPU_SEG_ID_MT8189H 0x21
u32 get_cpu_id(void);
u32 get_cpu_segment_id(void);
#endif /* SOC_MEDIATEK_COMMON_CPU_ID_H */

View file

@ -0,0 +1,20 @@
/* SPDX-License-Identifier: GPL-2.0-only OR MIT */
#ifndef __SOC_MEDIATEK_MT8189_INCLUDE_SOC_EFUSE_H__
#define __SOC_MEDIATEK_MT8189_INCLUDE_SOC_EFUSE_H__
#include <soc/addressmap.h>
#include <stdint.h>
struct efuse_regs {
u32 reserved1[488];
u32 cpu_id_reg;
u32 reserved2[15];
u32 cpu_seg_id_reg;
};
check_member(efuse_regs, cpu_id_reg, 0x7A0);
check_member(efuse_regs, cpu_seg_id_reg, 0x7E0);
static struct efuse_regs *const mtk_efuse = (void *)EFUSEC_BASE;
#endif /*__SOC_MEDIATEK_MT8189_INCLUDE_SOC_EFUSE_H__*/