Felix Held has submitted this change. ( https://review.coreboot.org/c/coreboot/+/68576 )
(
2 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: soc/mediatek/mt8186: Add support for reading CPU ID ......................................................................
soc/mediatek/mt8186: Add support for reading CPU ID
MT8186 has two slightly different versions: MT8186G and MT8186T (turbo version). Add get_cpu_id() to identify different CPUs.
BUG=b:249436110 TEST=cpu id is correct. BRANCH=corsola
Signed-off-by: Bo-Chen Chen rex-bc.chen@mediatek.com Change-Id: I0612dd589e11853dbddc1d99526e9c9bf170acec Reviewed-on: https://review.coreboot.org/c/coreboot/+/68576 Reviewed-by: Yu-Ping Wu yupingso@google.com Reviewed-by: Yidi Lin yidilin@google.com Tested-by: build bot (Jenkins) no-reply@coreboot.org --- A src/soc/mediatek/common/cpu_id.c A src/soc/mediatek/common/include/soc/cpu_id.h M src/soc/mediatek/mt8186/Makefile.inc M src/soc/mediatek/mt8186/include/soc/efuse.h 4 files changed, 51 insertions(+), 0 deletions(-)
Approvals: build bot (Jenkins): Verified Yu-Ping Wu: Looks good to me, approved Yidi Lin: Looks good to me, but someone else must approve
diff --git a/src/soc/mediatek/common/cpu_id.c b/src/soc/mediatek/common/cpu_id.c new file mode 100644 index 0000000..e31adcd --- /dev/null +++ b/src/soc/mediatek/common/cpu_id.c @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <console/console.h> +#include <device/mmio.h> +#include <soc/cpu_id.h> +#include <soc/efuse.h> + +u32 get_cpu_id(void) +{ + u32 id = read32(&mtk_efuse->cpu_id_reg); + + printk(BIOS_INFO, "CPU: %#x\n", id); + + return id; +} diff --git a/src/soc/mediatek/common/include/soc/cpu_id.h b/src/soc/mediatek/common/include/soc/cpu_id.h new file mode 100644 index 0000000..9453a15 --- /dev/null +++ b/src/soc/mediatek/common/include/soc/cpu_id.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef SOC_MEDIATEK_COMMON_CPU_ID_H +#define SOC_MEDIATEK_COMMON_CPU_ID_H + +#define MTK_CPU_ID_MT8186G 0x81861001 +#define MTK_CPU_ID_MT8186T 0x81862001 + +u32 get_cpu_id(void); + +#endif /* SOC_MEDIATEK_COMMON_CPU_ID_H */ diff --git a/src/soc/mediatek/mt8186/Makefile.inc b/src/soc/mediatek/mt8186/Makefile.inc index cd20777..c8dbbc9 100644 --- a/src/soc/mediatek/mt8186/Makefile.inc +++ b/src/soc/mediatek/mt8186/Makefile.inc @@ -1,6 +1,7 @@ ifeq ($(CONFIG_SOC_MEDIATEK_MT8186),y)
# for bootblock, verstage, romstage, ramstage +all-y += ../common/cpu_id.c all-y += ../common/flash_controller.c all-y += ../common/gpio.c ../common/gpio_op.c gpio.c all-y += ../common/i2c.c i2c.c diff --git a/src/soc/mediatek/mt8186/include/soc/efuse.h b/src/soc/mediatek/mt8186/include/soc/efuse.h index fe3dfff..3804b46 100644 --- a/src/soc/mediatek/mt8186/include/soc/efuse.h +++ b/src/soc/mediatek/mt8186/include/soc/efuse.h @@ -9,9 +9,12 @@ struct efuse_regs { uint32_t reserved[130]; uint32_t adc_cali_reg; + uint32_t reserved1[357]; + uint32_t cpu_id_reg; };
check_member(efuse_regs, adc_cali_reg, 0x208); +check_member(efuse_regs, cpu_id_reg, 0x7a0); static struct efuse_regs *const mtk_efuse = (void *)EFUSEC_BASE;
#endif