soc/mediatek: Allow specifying multiple EINT base registers

Unlike MT8186/MT8188/MT8192/MT8195, MT8196 has 5 EINT base registers,
each with a different number of EINT bits. In preparation for the
upcoming MT8196 EINT unmasking support, replace the `eint_event_reg`
struct (which has a hardcoded register number) with an array
`eint_event` to specify the EINT base register(s).

BUG=none
TEST=emerge-geralt coreboot
BRANCH=none

Change-Id: I86fd3109c9ff72f33b9fea45587d012b003a34ba
Signed-off-by: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86033
Reviewed-by: Yidi Lin <yidilin@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Yu-Ping Wu 2025-01-17 17:52:33 +08:00 committed by Yidi Lin
commit b229c120f7
7 changed files with 44 additions and 15 deletions

View file

@ -1,10 +1,30 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <commonlib/bsd/helpers.h>
#include <device/mmio.h>
#include <soc/eint_event.h>
#include <types.h>
/* EINT reg_base + 0x880 is eint_event_mask_clr register with access type W1C. */
#define EINT_EVENT_MASK_CLR_OFFSET 0x880
#define EINT_VALUE 0xFFFFFFFF
static void enable_eint_event(const struct eint_event_info *event)
{
uint32_t *reg = (uint32_t *)(event->reg_base + EINT_EVENT_MASK_CLR_OFFSET);
size_t port = DIV_ROUND_UP(event->eint_num, sizeof(*reg) * BITS_PER_BYTE);
int i;
for (i = 0; i < port; i++)
write32p(reg[i], EINT_VALUE);
}
void unmask_eint_event_mask(void)
{
int i;
for (i = 0; i < ARRAY_SIZE(mtk_eint_event->eint_event_mask_clr); i++)
write32(&mtk_eint_event->eint_event_mask_clr[i], 0xffffffff);
const struct eint_event_info *event = &eint_event[0];
while (event->reg_base && event->eint_num) {
enable_eint_event(event);
event++;
}
}

View file

@ -0,0 +1,9 @@
/* SPDX-License-Identifier: GPL-2.0-only OR MIT */
#include <soc/addressmap.h>
#include <soc/eint_event.h>
const struct eint_event_info eint_event[] = {
{ EINT_BASE, 224 },
{},
};

View file

@ -3,18 +3,18 @@
#ifndef SOC_MEDIATEK_COMMON_EINT_EVENT_H
#define SOC_MEDIATEK_COMMON_EINT_EVENT_H
#include <device/mmio.h>
#include <soc/addressmap.h>
#include <stddef.h>
#include <stdint.h>
/* eint event mask clear register */
struct eint_event_reg {
uint32_t eint_event_mask_clr[7];
struct eint_event_info {
uintptr_t reg_base;
size_t eint_num;
};
/* eint_base + 0x880 is eint_event_mask_clr register with access type W1C. */
static struct eint_event_reg *const mtk_eint_event = (void *)(EINT_BASE + 0x880);
/* An element { 0, 0 } indicates the end of array. */
extern const struct eint_event_info eint_event[];
/* unmask eint event, eint can wakeup by spm */
/* Unmask eint event, which can be waken up by SPM. */
void unmask_eint_event_mask(void);
#endif

View file

@ -12,7 +12,7 @@ all-y += ../common/timer.c ../common/timer_prepare.c
all-y += ../common/uart.c
bootblock-y += bootblock.c
bootblock-y += ../common/eint_event.c
bootblock-y += ../common/eint_event.c ../common/eint_event_info.c
bootblock-y += gic.c
bootblock-y += ../common/lastbus_v1.c
bootblock-y += ../common/mmu_operations.c

View file

@ -10,7 +10,7 @@ all-y += timer.c ../common/timer_prepare.c
all-y += ../common/uart.c
bootblock-y += ../common/bootblock.c bootblock.c
bootblock-y += ../common/eint_event.c
bootblock-y += ../common/eint_event.c ../common/eint_event_info.c
bootblock-y += ../common/lastbus_v2.c lastbus.c
bootblock-y += ../common/mmu_operations.c
bootblock-y += ../common/tracker.c ../common/tracker_v2.c

View file

@ -10,7 +10,7 @@ all-y += ../common/timer.c
all-y += ../common/uart.c
bootblock-y += bootblock.c
bootblock-y += ../common/eint_event.c
bootblock-y += ../common/eint_event.c ../common/eint_event_info.c
bootblock-y += ../common/mmu_operations.c
bootblock-y += ../common/pll.c pll.c
bootblock-y += ../common/tracker.c ../common/tracker_v2.c

View file

@ -11,7 +11,7 @@ all-y += ../common/uart.c
bootblock-y += bootblock.c
bootblock-y += ../common/early_init.c
bootblock-y += ../common/eint_event.c
bootblock-y += ../common/eint_event.c ../common/eint_event_info.c
bootblock-y += ../common/mmu_operations.c
bootblock-$(CONFIG_PCI) += ../common/pcie.c pcie.c
bootblock-y += ../common/pll.c pll.c