soc/mediatek/mt8188: Add DEVAPC basic driver

Add basic DEVAPC (device access permission control) driver.

DEVAPC driver is used to set up bus fabric security and data protection
among hardwares. DEVAPC driver groups the master hardwares into
different domains and gives secure and non-secure property. The slave
hardware can configure different access permissions for different
domains via DEVAPC driver.

1. Initialize DEVAPC.
2. Set master domain and secure side band.
3. Set default permission.

TEST=check logs of DEVAPC ok.
BUG=b:236331724

Signed-off-by: Nina Wu <nina-cm.wu@mediatek.com>
Change-Id: Iad3569bc6f8ba032d478934ba839dc4b5387bafc
Reviewed-on: https://review.coreboot.org/c/coreboot/+/66970
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
This commit is contained in:
Nina Wu 2022-08-18 11:13:31 +08:00 committed by Felix Held
parent 297b634062
commit c0797f50e1
5 changed files with 1683 additions and 0 deletions

View File

@ -29,6 +29,7 @@ romstage-y += ../common/pmif_spmi.c pmif_spmi.c
romstage-y += ../common/rtc.c ../common/rtc_osc_init.c ../common/rtc_mt6359p.c
ramstage-y += ../common/auxadc.c
ramstage-y += ../common/devapc.c devapc.c
ramstage-y += ../common/dfd.c
ramstage-y += ../common/dpm.c
ramstage-$(CONFIG_DPM_FOUR_CHANNEL) += ../common/dpm_4ch.c

File diff suppressed because it is too large Load Diff

View File

@ -31,6 +31,10 @@ enum {
PMICSPI_MST_BASE = IO_PHYS + 0x00025000,
PMIF_SPMI_BASE = IO_PHYS + 0x00027000,
SPMI_MST_BASE = IO_PHYS + 0x00029000,
DEVAPC_INFRA_AO_BASE = IO_PHYS + 0x00030000,
DEVAPC_PERI_AO_BASE = IO_PHYS + 0x00034000,
DEVAPC_PERI2_AO_BASE = IO_PHYS + 0x00038000,
DEVAPC_PERI_PAR_AO_BASE = IO_PHYS + 0x0003C000,
DBG_TRACKER_BASE = IO_PHYS + 0x00208000,
PERI_TRACKER_BASE = IO_PHYS + 0x00218000,
EMI0_BASE = IO_PHYS + 0x00219000,

View File

@ -0,0 +1,70 @@
/* SPDX-License-Identifier: GPL-2.0-only OR MIT */
#ifndef SOC_MEDIATEK_MT8188_DEVAPC_H
#define SOC_MEDIATEK_MT8188_DEVAPC_H
#include <device/mmio.h>
#include <soc/addressmap.h>
void dapc_init(void);
enum devapc_ao_offset {
SYS0_D0_APC_0 = 0x00000,
SYS1_D0_APC_0 = 0x01000,
SYS2_D0_APC_0 = 0x02000,
MAS_DOM_0 = 0x00900,
MAS_SEC_0 = 0x00A00,
AO_APC_CON = 0x00F00,
};
/******************************************************************************
* STRUCTURE DEFINITION
******************************************************************************/
struct apc_infra_peri_dom_16 {
unsigned char d_permission[16];
};
struct apc_infra_peri_dom_8 {
unsigned char d_permission[8];
};
struct apc_infra_peri_dom_4 {
unsigned char d_permission[4];
};
enum devapc_sys_dom_num {
DOM_NUM_INFRA_AO_SYS0 = 16,
DOM_NUM_INFRA_AO_SYS1 = 4,
DOM_NUM_INFRA_AO_SYS2 = 4,
DOM_NUM_PERI_AO_SYS0 = 16,
DOM_NUM_PERI_AO_SYS1 = 8,
DOM_NUM_PERI2_AO_SYS0 = 16,
DOM_NUM_PERI_PAR_AO_SYS0 = 16,
};
enum devapc_cfg_index {
DEVAPC_DEBUGSYS_INDEX = 14,
};
/* PERM_ATTR MACRO */
#define DAPC_INFRA_AO_SYS0_ATTR(...) { { DAPC_PERM_ATTR_16(__VA_ARGS__) } }
#define DAPC_INFRA_AO_SYS1_ATTR(...) { { DAPC_PERM_ATTR_4(__VA_ARGS__) } }
#define DAPC_INFRA_AO_SYS2_ATTR(...) { { DAPC_PERM_ATTR_4(__VA_ARGS__) } }
#define DAPC_PERI_AO_SYS0_ATTR(...) { { DAPC_PERM_ATTR_16(__VA_ARGS__) } }
#define DAPC_PERI_AO_SYS1_ATTR(...) { { DAPC_PERM_ATTR_8(__VA_ARGS__) } }
#define DAPC_PERI2_AO_SYS0_ATTR(...) { { DAPC_PERM_ATTR_16(__VA_ARGS__) } }
#define DAPC_PERI_PAR_AO_SYS0_ATTR(...) { { DAPC_PERM_ATTR_16(__VA_ARGS__) } }
/******************************************************************************
* Variable DEFINITION
******************************************************************************/
#define MOD_NO_IN_1_DEVAPC 16
#define DOMAIN_OFT 0x40
#define IDX_OFT 0x4
/******************************************************************************
* Bit Field DEFINITION
******************************************************************************/
/* TODO */
#endif /* SOC_MEDIATEK_MT8188_DEVAPC_H */

View File

@ -3,6 +3,7 @@
#include <bootmem.h>
#include <console/console.h>
#include <device/device.h>
#include <soc/devapc.h>
#include <soc/dfd.h>
#include <soc/dpm.h>
#include <soc/emi.h>
@ -25,6 +26,7 @@ static void soc_read_resources(struct device *dev)
static void soc_init(struct device *dev)
{
mtk_mmu_disable_l2c_sram();
dapc_init();
mcupm_init();
sspm_init();