Initial commit: Linux kernel 4.19 for Unplugged OS

This commit is contained in:
ziv committed 2025-10-06 13:52:42 +00:00
commit d30235b04c
80519 files changed
+35800681

No files matched your search

+152
View File
@@ -0,0 +1,152 @@
config MTK_DEVAPC
tristate "Mediatek Device APC Support"
default y
help
Device APC is a kernel driver controlling internal device security.
If someone tries to access a device, which is not allowed by the
device, it cannot access the device and will get a violation
interrupt. Device APC prevents malicious access to internal devices.
config DEVAPC_LEGACY
bool "Mediatek Device APC driver for legacy platform"
default y
select MTK_DEVAPC
help
Say yes here to enable support Mediatek legacy
Device APC driver.
This driver do not split common handle flow
into different files.
config DEVAPC_ARCH_V1
bool "Mediatek Device APC driver architecture v1"
help
Say yes here to enable support Mediatek
Device APC driver which is based on HW
architecture version 1.
This architecture supports 1 Infra-peri.
config DEVAPC_ARCH_V2
bool "Mediatek Device APC driver architecture v2"
help
Say yes here to enable support Mediatek
Device APC driver which is based on HW
architecture version 2.
This architecture supports multiple Infra AO.
config DEVAPC_MMAP_DEBUG
bool "Mediatek Device APC memory map debug mode"
help
Say yes here to enable support Mediatek
Device APC driver to debug violation
through catching illegal memory mapped
range.
config DEVAPC_SWP_SUPPORT
bool "Mediatek Device APC software watchpoint support"
help
Say yes here to enable support Mediatek
Device APC driver to debug violation
through software watchpoint.
Support read/write transaction separately.
config DEVAPC_MT6833
bool "Mediatek MT6833 Device APC driver"
depends on MACH_MT6833 || COMPILE_TEST
select DEVAPC_ARCH_V2
select MTK_DEVAPC
select DEVAPC_MMAP_DEBUG
select DEVAPC_SWP_SUPPORT if MTK_ENG_BUILD
help
Say yes here to enable support Mediatek MT6833
Device APC driver.
This driver is combined with DEVAPC_ARCH_V2 for
common handle flow.
config DEVAPC_MT6853
bool "Mediatek MT6853 Device APC driver"
depends on MACH_MT6853 || COMPILE_TEST
select DEVAPC_ARCH_V2
select MTK_DEVAPC
select DEVAPC_MMAP_DEBUG
select DEVAPC_SWP_SUPPORT if MTK_ENG_BUILD
help
Say yes here to enable support Mediatek MT6853
Device APC driver.
This driver is combined with DEVAPC_ARCH_V2 for
common handle flow.
config DEVAPC_MT6873
bool "Mediatek MT6873 Device APC driver"
depends on MACH_MT6873 || COMPILE_TEST
select DEVAPC_ARCH_V2
select MTK_DEVAPC
select DEVAPC_MMAP_DEBUG
select DEVAPC_SWP_SUPPORT if MTK_ENG_BUILD
help
Say yes here to enable support Mediatek MT6873
Device APC driver.
This driver is combined with DEVAPC_ARCH_V2 for
common handle flow.
config DEVAPC_MT6877
bool "Mediatek MT6877 Device APC driver"
depends on MACH_MT6877 || COMPILE_TEST
select DEVAPC_ARCH_V2
select MTK_DEVAPC
select DEVAPC_MMAP_DEBUG
select DEVAPC_SWP_SUPPORT if MTK_ENG_BUILD
help
Say yes here to enable support Mediatek MT6877
Device APC driver.
This driver is combined with DEVAPC_ARCH_V2 for
common handle flow.
config DEVAPC_MT6885
bool "Mediatek MT6885 Device APC driver"
depends on MACH_MT6885 || MACH_MT6893 || COMPILE_TEST
select DEVAPC_ARCH_V2
select MTK_DEVAPC
select DEVAPC_MMAP_DEBUG
select DEVAPC_SWP_SUPPORT if MTK_ENG_BUILD
help
Say yes here to enable support Mediatek MT6885
Device APC driver.
This driver is combined with DEVAPC_ARCH_V2 for
common handle flow.
config DEVAPC_MT6781
bool "Mediatek MT6781 Device APC driver"
depends on MACH_MT6781 || COMPILE_TEST
select DEVAPC_ARCH_V1
select MTK_DEVAPC
select DEVAPC_SWP_SUPPORT if MTK_ENG_BUILD
help
Say yes here to enable support Mediatek MT6781
Device APC driver.
This driver is combined with DEVAPC_ARCH_V1 for
common handle flow.
config DEVAPC_MT6768
bool "Mediatek MT6768 Device APC driver"
depends on MACH_MT6768 || COMPILE_TEST
select DEVAPC_ARCH_V1
select MTK_DEVAPC
select DEVAPC_MMAP_DEBUG
select DEVAPC_SWP_SUPPORT if MTK_ENG_BUILD
help
Say yes here to enable support Mediatek MT6768
Device APC driver.
This driver is combined with DEVAPC_ARCH_V1 for
common handle flow.
config DEVAPC_MT6785
bool "Mediatek MT6785 Device APC driver"
depends on MACH_MT6785 || COMPILE_TEST
select DEVAPC_ARCH_V1
select MTK_DEVAPC
select DEVAPC_SWP_SUPPORT if MTK_ENG_BUILD
help
Say yes here to enable support Mediatek MT6785
Device APC driver.
This driver is combined with DEVAPC_ARCH_V1 for
common handle flow.
+25
View File
@@ -0,0 +1,25 @@
# SPDX-License-Identifier: GPL-2.0
ifeq ($(CONFIG_MTK_GCOV_KERNEL),y)
GCOV_PROFILE := y
endif
LOCAL_PATH := $(srctree)/drivers/soc/mediatek/devapc
subdir-ccflags-$(CONFIG_MTK_ENG_BUILD) += -DDBG_ENABLE
ifneq ($(wildcard $(LOCAL_PATH)/$(MTK_PLATFORM)/Makefile),)
obj-$(CONFIG_DEVAPC_LEGACY) += $(MTK_PLATFORM)/
else
# Core
obj-$(CONFIG_DEVAPC_ARCH_V1) += devapc-mtk-common.o
obj-$(CONFIG_DEVAPC_ARCH_V2) += devapc-mtk-multi-ao.o
# SoC
obj-$(CONFIG_DEVAPC_MT6768) += devapc-mt6768.o
obj-$(CONFIG_DEVAPC_MT6781) += devapc-mt6781.o
obj-$(CONFIG_DEVAPC_MT6833) += devapc-mt6833.o
obj-$(CONFIG_DEVAPC_MT6853) += devapc-mt6853.o
obj-$(CONFIG_DEVAPC_MT6873) += devapc-mt6873.o
obj-$(CONFIG_DEVAPC_MT6877) += devapc-mt6877.o
obj-$(CONFIG_DEVAPC_MT6885) += devapc-mt6885.o
endif
+736
View File
@@ -0,0 +1,736 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2019 MediaTek Inc.
*/
#include <linux/module.h>
#include <linux/proc_fs.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/bug.h>
#include "devapc-mtk-common.h"
#include "devapc-mt6768.h"
static struct mtk_device_info mt6768_infra_devices[] = {
/* slave type, config_idx, device name enable_vio_irq */
/* 0 */
{E_DAPC_INFRA_PERI_SLAVE, 0, "INFRA_AO_TOPCKGEN", true},
{E_DAPC_INFRA_PERI_SLAVE, 1, "INFRA_AO_INFRASYS_CONFIG_REGS", true},
{E_DAPC_INFRA_PERI_SLAVE, 2, "IO_CFG_REG", true},
{E_DAPC_INFRA_PERI_SLAVE, 3, "INFRA_AO_ PERICFG", true},
{E_DAPC_INFRA_PERI_SLAVE, 4, "INFRA_AO_EFUSE_AO_DEBUG", true},
{E_DAPC_INFRA_PERI_SLAVE, 5, "INFRA_AO_GPIO", true},
{E_DAPC_INFRA_PERI_SLAVE, 6, "INFRA_AO_SLEEP_CONTROLLER", true},
{E_DAPC_INFRA_PERI_SLAVE, 7, "INFRA_AO_TOPRGU", true},
{E_DAPC_INFRA_PERI_SLAVE, 8, "INFRA_AO_APXGPT", true},
{E_DAPC_INFRA_PERI_SLAVE, 9, "INFRA_AO_RESERVE", true},
/* 10 */
{E_DAPC_INFRA_PERI_SLAVE, 10, "INFRA_AO_SEJ", true},
{E_DAPC_INFRA_PERI_SLAVE, 11, "INFRA_AO_AP_CIRQ_EINT", true},
{E_DAPC_INFRA_PERI_SLAVE, 12, "INFRA_AO_APMIXEDSYS", true},
{E_DAPC_INFRA_PERI_SLAVE, 13, "INFRA_AO_PMIC_WRAP", true},
{E_DAPC_INFRA_PERI_SLAVE, 14, "INFRA_AO_DEVICE_APC_AO_INFRA_PERI", true},
{E_DAPC_INFRA_PERI_SLAVE, 15, "INFRA_AO_SLEEP_CONTROLLER_MD", true},
{E_DAPC_INFRA_PERI_SLAVE, 16, "INFRA_AO_KEYPAD", true},
{E_DAPC_INFRA_PERI_SLAVE, 17, "INFRA_AO_TOP_MISC", true},
{E_DAPC_INFRA_PERI_SLAVE, 18, "INFRA_AO_ DVFS_CTRL_PROC", true},
{E_DAPC_INFRA_PERI_SLAVE, 19, "INFRA_AO_MBIST_AO_REG", true},
/* 20 */
{E_DAPC_INFRA_PERI_SLAVE, 20, "INFRA_AO_CLDMA_AO_AP", true},
{E_DAPC_INFRA_PERI_SLAVE, 21, "INFRA_AO_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 22, "INFRA_AO_AES_TOP_0", true},
{E_DAPC_INFRA_PERI_SLAVE, 23, "INFRA_AO_SYS_TIMER", true},
{E_DAPC_INFRA_PERI_SLAVE, 24, "INFRA_AO_MDEM_TEMP_SHARE", true},
{E_DAPC_INFRA_PERI_SLAVE, 25, "INFRA_AO_DEVICE_APC_AO_MD", true},
{E_DAPC_INFRA_PERI_SLAVE, 26, "INFRA_AO_SECURITY_AO", true},
{E_DAPC_INFRA_PERI_SLAVE, 27, "INFRA_AO_TOPCKGEN_REG", true},
{E_DAPC_INFRA_PERI_SLAVE, 28, "INFRA_AO_DEVICE_APC_AO_MM", true},
{E_DAPC_INFRA_PERI_SLAVE, 29, "INFRA_AO_RESERVE", true},
/* 30 */
{E_DAPC_INFRA_PERI_SLAVE, 30, "INFRA_AO_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 31, "INFRA_AO_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 32, "INFRASYS_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 33, "INFRASYS_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 34, "INFRASYS_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 35, "INFRASYS_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 36, "INFRASYS_SYS_CIRQ", true},
{E_DAPC_INFRA_PERI_SLAVE, 37, "INFRASYS_MM_IOMMU", true},
{E_DAPC_INFRA_PERI_SLAVE, 38, "INFRASYS_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 39, "INFRASYS_DEVICE_APC", true},
/* 40 */
{E_DAPC_INFRA_PERI_SLAVE, 40, "INFRASYS_DBG_TRACKER", true},
{E_DAPC_INFRA_PERI_SLAVE, 41, "INFRASYS_CCIF0_AP", true},
{E_DAPC_INFRA_PERI_SLAVE, 42, "INFRASYS_CCIF0_MD", true},
{E_DAPC_INFRA_PERI_SLAVE, 43, "INFRASYS_CCIF1_AP", true},
{E_DAPC_INFRA_PERI_SLAVE, 44, "INFRASYS_CCIF1_MD", true},
{E_DAPC_INFRA_PERI_SLAVE, 45, "INFRASYS_MBIST", true},
{E_DAPC_INFRA_PERI_SLAVE, 46, "INFRASYS_INFRA_PDN_REGISTER", true},
{E_DAPC_INFRA_PERI_SLAVE, 47, "INFRASYS_TRNG", true},
{E_DAPC_INFRA_PERI_SLAVE, 48, "INFRASYS_DX_CC", true},
{E_DAPC_INFRA_PERI_SLAVE, 49, "INFRASYS_MCUPM_SRAM2", true},
/* 50 */
{E_DAPC_INFRA_PERI_SLAVE, 50, "INFRASYS_CQ_DMA", true},
{E_DAPC_INFRA_PERI_SLAVE, 51, "INFRASYS_MCUPM_SRAM3", true},
{E_DAPC_INFRA_PERI_SLAVE, 52, "INFRASYS_SRAMROM", true},
{E_DAPC_INFRA_PERI_SLAVE, 53, "INFRASYS_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 54, "INFRASYS_MCUPM_REG", true},
{E_DAPC_INFRA_PERI_SLAVE, 55, "INFRASYS_MCUPM_SRAM0", true},
{E_DAPC_INFRA_PERI_SLAVE, 56, "INFRASYS_MCUPM_SRAM1", true},
{E_DAPC_INFRA_PERI_SLAVE, 57, "INFRASYS_EMI", true},
{E_DAPC_INFRA_PERI_SLAVE, 58, "INFRASYS_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 59, "INFRASYS_CLDMA_PDN_AP", true},
/* 60 */
{E_DAPC_INFRA_PERI_SLAVE, 60, "INFRASYS_CLDMA_PDN_MD", true},
{E_DAPC_INFRA_PERI_SLAVE, 61, "INFRASYS_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 62, "INFRASYS_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 63, "INFRASYS_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 64, "INFRASYS_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 65, "INFRASYS_EMI_MPU", true},
{E_DAPC_INFRA_PERI_SLAVE, 66, "INFRASYS_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 67, "INFRASYS_DRAMC_CH0_TOP0", true},
{E_DAPC_INFRA_PERI_SLAVE, 68, "INFRASYS_DRAMC_CH0_TOP1", true},
{E_DAPC_INFRA_PERI_SLAVE, 69, "INFRASYS_DRAMC_CH0_TOP2", true},
/* 70 */
{E_DAPC_INFRA_PERI_SLAVE, 70, "INFRASYS_DRAMC_CH0_TOP3", true},
{E_DAPC_INFRA_PERI_SLAVE, 71, "INFRASYS_DRAMC_CH0_TOP4", true},
{E_DAPC_INFRA_PERI_SLAVE, 72, "INFRASYS_DRAMC_CH1_TOP0", true},
{E_DAPC_INFRA_PERI_SLAVE, 73, "INFRASYS_DRAMC_CH1_TOP1", true},
{E_DAPC_INFRA_PERI_SLAVE, 74, "INFRASYS_DRAMC_CH1_TOP2", true},
{E_DAPC_INFRA_PERI_SLAVE, 75, "INFRASYS_DRAMC_CH1_TOP3", true},
{E_DAPC_INFRA_PERI_SLAVE, 76, "INFRASYS_DRAMC_CH1_TOP4", true},
{E_DAPC_INFRA_PERI_SLAVE, 77, "INFRASYS_GCE", true},
{E_DAPC_INFRA_PERI_SLAVE, 78, "INFRASYS_CCIF2_AP", true},
{E_DAPC_INFRA_PERI_SLAVE, 79, "INFRASYS_CCIF2_MD", true},
/* 80 */
{E_DAPC_INFRA_PERI_SLAVE, 80, "INFRASYS_CCIF3_AP", true},
{E_DAPC_INFRA_PERI_SLAVE, 81, "INFRASYS_CCIF3_MD", true},
{E_DAPC_INFRA_PERI_SLAVE, 82, "INFRA_AO_SSPM_1_1", true},
{E_DAPC_INFRA_PERI_SLAVE, 83, "INFRA_AO_SSPM_1_2", true},
{E_DAPC_INFRA_PERI_SLAVE, 84, "INFRA_AO_SSPM_1_3", true},
{E_DAPC_INFRA_PERI_SLAVE, 85, "INFRA_AO_SSPM_2", true},
{E_DAPC_INFRA_PERI_SLAVE, 86, "INFRA_AO_SSPM_3", true},
{E_DAPC_INFRA_PERI_SLAVE, 87, "INFRA_AO_SSPM_4", true},
{E_DAPC_INFRA_PERI_SLAVE, 88, "INFRA_AO_SSPM_5", true},
{E_DAPC_INFRA_PERI_SLAVE, 89, "INFRA_AO_SSPM_6", true},
/* 90 */
{E_DAPC_INFRA_PERI_SLAVE, 90, "INFRA_AO_SSPM_7", true},
{E_DAPC_INFRA_PERI_SLAVE, 91, "INFRA_AO_SSPM_8", true},
{E_DAPC_INFRA_PERI_SLAVE, 92, "INFRA_AO_SCP", true},
{E_DAPC_INFRA_PERI_SLAVE, 93, "INFRASYS_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 94, "INFRASYS_DBUGSYS", true},
{E_DAPC_INFRA_PERI_SLAVE, 95, "PERISYS_APDMA", true},
{E_DAPC_INFRA_PERI_SLAVE, 96, "PERISYS_AUXADC", true},
{E_DAPC_INFRA_PERI_SLAVE, 97, "PERISYS_UART0", true},
{E_DAPC_INFRA_PERI_SLAVE, 98, "PERISYS_UART1", true},
{E_DAPC_INFRA_PERI_SLAVE, 99, "PERISYS_I2C7", true},
/* 100 */
{E_DAPC_INFRA_PERI_SLAVE, 100, "PERISYS_I2C8", true},
{E_DAPC_INFRA_PERI_SLAVE, 101, "PERISYS_PWM", true},
{E_DAPC_INFRA_PERI_SLAVE, 102, "PERISYS_I2C0", true},
{E_DAPC_INFRA_PERI_SLAVE, 103, "PERISYS_I2C1", true},
{E_DAPC_INFRA_PERI_SLAVE, 104, "PERISYS_I2C2", true},
{E_DAPC_INFRA_PERI_SLAVE, 105, "PERISYS_SPI0", true},
{E_DAPC_INFRA_PERI_SLAVE, 106, "PERISYS_PTP", true},
{E_DAPC_INFRA_PERI_SLAVE, 107, "PERISYS_BTIF", true},
{E_DAPC_INFRA_PERI_SLAVE, 108, "PERISYS_I2C6", true},
{E_DAPC_INFRA_PERI_SLAVE, 109, "PERISYS_DISP_PWM", true},
/* 110 */
{E_DAPC_INFRA_PERI_SLAVE, 110, "PERISYS_I2C3", true},
{E_DAPC_INFRA_PERI_SLAVE, 111, "PERISYS_SPI1", true},
{E_DAPC_INFRA_PERI_SLAVE, 112, "PERISYS_I2C4", true},
{E_DAPC_INFRA_PERI_SLAVE, 113, "PERISYS_SPI2", true},
{E_DAPC_INFRA_PERI_SLAVE, 114, "PERISYS_SPI3", true},
{E_DAPC_INFRA_PERI_SLAVE, 115, "PERISYS_SPI4", true},
{E_DAPC_INFRA_PERI_SLAVE, 116, "PERISYS_SPI5", true},
{E_DAPC_INFRA_PERI_SLAVE, 117, "PERISYS_I2C5", true},
{E_DAPC_INFRA_PERI_SLAVE, 118, "PERISYS_IMP_IIC_WRAP", true},
{E_DAPC_INFRA_PERI_SLAVE, 119, "PERISYS_NFI", true},
/* 120 */
{E_DAPC_INFRA_PERI_SLAVE, 120, "PERISYS_NFIECC", true},
{E_DAPC_INFRA_PERI_SLAVE, 121, "PERISYS_USB", true},
{E_DAPC_INFRA_PERI_SLAVE, 122, "PERISYS_USB_2.0_SUB", true},
{E_DAPC_INFRA_PERI_SLAVE, 123, "PERISYS_MSDC0", true},
{E_DAPC_INFRA_PERI_SLAVE, 124, "PERISYS_MSDC1", true},
{E_DAPC_INFRA_PERI_SLAVE, 125, "PERISYS_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 126, "PERISYS_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 127, "PERISYS_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 128, "PERISYS_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 129, "PERISYS_RESERVE", true},
/* 130 */
{E_DAPC_INFRA_PERI_SLAVE, 130, "PERISYS_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 131, "PERISYS_AUDIO", true},
{E_DAPC_INFRA_PERI_SLAVE, 132, "EAST_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 133, "EAST_ CSI_TOP_AO", true},
{E_DAPC_INFRA_PERI_SLAVE, 134, "EAST_ RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 135, "EAST_ RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 136, "SOUTH_ RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 137, "SOUTH_EFUSE", true},
{E_DAPC_INFRA_PERI_SLAVE, 138, "SOUTH_RESERVE_1", true},
{E_DAPC_INFRA_PERI_SLAVE, 139, "SOUTH_RESERVE_2", true},
/* 140 */
{E_DAPC_INFRA_PERI_SLAVE, 140, "WEST_MIPI_TX_CONFIG", true},
{E_DAPC_INFRA_PERI_SLAVE, 141, "WEST_MSDC1", true},
{E_DAPC_INFRA_PERI_SLAVE, 142, "WEST_RESERVE_1", true},
{E_DAPC_INFRA_PERI_SLAVE, 143, "WEST_RESERVE_2", true},
{E_DAPC_INFRA_PERI_SLAVE, 144, "NORTH_USBSIF_TOP", true},
{E_DAPC_INFRA_PERI_SLAVE, 145, "NORTH_MSDC0", true},
{E_DAPC_INFRA_PERI_SLAVE, 146, "NORTH_RESERVE_0", true},
{E_DAPC_INFRA_PERI_SLAVE, 147, "NORTH_RESERVE_1", true},
{E_DAPC_INFRA_PERI_SLAVE, 148, "PERISYS_CONN", true},
{E_DAPC_INFRA_PERI_SLAVE, 149, "PERISYS_MD1", true},
/* 150 */
{E_DAPC_INFRA_PERI_SLAVE, 150, "PERISYS_RESERVE", true},
{E_DAPC_MM_SLAVE, 0, "GPU config", true},
{E_DAPC_MM_SLAVE, 1, "GPU IP", true},
{E_DAPC_MM_SLAVE, 2, "GPU mali_dvfs_hint", true},
{E_DAPC_MM_SLAVE, 3, "MFG_OTHERS", true},
{E_DAPC_MM_SLAVE, 4, "MMSYS_CONFIG", true},
{E_DAPC_MM_SLAVE, 5, "DISP_MUTEX", true},
{E_DAPC_MM_SLAVE, 6, "SMI_COMMON", true},
{E_DAPC_MM_SLAVE, 7, "SMI_LARB0", true},
{E_DAPC_MM_SLAVE, 8, "MDP_RDMA0", true},
/* 160 */
{E_DAPC_MM_SLAVE, 9, "MDP_CCORR0", true},
{E_DAPC_MM_SLAVE, 10, "MDP_RSZ0", true},
{E_DAPC_MM_SLAVE, 11, "MDP_RSZ1", true},
{E_DAPC_MM_SLAVE, 12, "MDP_WDMA0", true},
{E_DAPC_MM_SLAVE, 13, "MDP_WROT0", true},
{E_DAPC_MM_SLAVE, 14, "MDP_TDSHP0", true},
{E_DAPC_MM_SLAVE, 15, "DISP_OVL0", true},
{E_DAPC_MM_SLAVE, 16, "DISP_OVL0_2L", true},
{E_DAPC_MM_SLAVE, 17, "DISP_RDMA0", true},
{E_DAPC_MM_SLAVE, 18, "DISP_WDMA0", true},
/* 170 */
{E_DAPC_MM_SLAVE, 19, "DISP_COLOR0", true},
{E_DAPC_MM_SLAVE, 20, "DISP_CCORR0", true},
{E_DAPC_MM_SLAVE, 21, "DISP_AAL0", true},
{E_DAPC_MM_SLAVE, 22, "DISP_GAMMA0", true},
{E_DAPC_MM_SLAVE, 23, "DISP_DITHER0", true},
{E_DAPC_MM_SLAVE, 24, "DSI0", true},
{E_DAPC_MM_SLAVE, 25, "DISP_RSZ0", true},
{E_DAPC_MM_SLAVE, 26, "MM_MUTEX", true},
{E_DAPC_MM_SLAVE, 27, "SMI_LARB0", true},
{E_DAPC_MM_SLAVE, 28, "SMI_LARB1", true},
/* 180 */
{E_DAPC_MM_SLAVE, 29, "SMI_COMMON", true},
{E_DAPC_MM_SLAVE, 30, "IMGSYS_CONFIG", true},
{E_DAPC_MM_SLAVE, 31, "IMGSYS_SMI_LARB2", true},
{E_DAPC_MM_SLAVE, 32, "IMGSYS_DISP_A0", true},
{E_DAPC_MM_SLAVE, 33, "IMGSYS_DISP_A1", true},
{E_DAPC_MM_SLAVE, 34, "IMGSYS_DISP_A_NBC", true},
{E_DAPC_MM_SLAVE, 35, "IMGSYS_RESERVE", true},
{E_DAPC_MM_SLAVE, 36, "IMGSYS_RESERVE", true},
{E_DAPC_MM_SLAVE, 37, "IMGSYS_RESERVE", true},
{E_DAPC_MM_SLAVE, 38, "IMGSYS_DPE", true},
/* 190 */
{E_DAPC_MM_SLAVE, 39, "IMGSYS_RESERVE", true},
{E_DAPC_MM_SLAVE, 40, "IMGSYS_RESERVE", true},
{E_DAPC_MM_SLAVE, 41, "IMGSYS_FDVT", true},
{E_DAPC_MM_SLAVE, 42, "IMGSYS_RESERVE", true},
{E_DAPC_MM_SLAVE, 43, "IMGSYS_RESERVE", true},
{E_DAPC_MM_SLAVE, 44, "IMGSYS_RESERVE", true},
{E_DAPC_MM_SLAVE, 45, "IMGSYS_RESERVE", true},
{E_DAPC_MM_SLAVE, 46, "VDEC_GLOBAL_CON", true},
{E_DAPC_MM_SLAVE, 47, "VDEC_CONFIG", true},
{E_DAPC_MM_SLAVE, 48, "VDEC_FULL", true},
/* 200 */
{E_DAPC_MM_SLAVE, 49, "VDEC_Reserved", true},
{E_DAPC_MM_SLAVE, 50, "VENC_GLOBAL_CON", true},
{E_DAPC_MM_SLAVE, 51, "VENC_CONFG", true},
{E_DAPC_MM_SLAVE, 52, "VENC_I0", true},
{E_DAPC_MM_SLAVE, 53, "VENC_JPB_ENC_REG", true},
{E_DAPC_MM_SLAVE, 54, "VENC_SRAM_POOL_MBIST_CTRL", true},
{E_DAPC_MM_SLAVE, 55, "VENC_SRAM_POOL_MBIST_CTRL", true},
{E_DAPC_MM_SLAVE, 56, "VENC_SRAM_POOL_MBIST_CTRL", true},
{E_DAPC_MM_SLAVE, 57, "VENC_SRAM_POOL_MBIST_CTRL", true},
{E_DAPC_MM_SLAVE, 58, "CAMSYS_CAMSYS_TOP", true},
/* 210 */
{E_DAPC_MM_SLAVE, 59, "CAMSYS_LARB3", true},
{E_DAPC_MM_SLAVE, 60, "CAMSYS_CAM_TOP", true},
{E_DAPC_MM_SLAVE, 61, "CAMSYS_CAM_A", true},
{E_DAPC_MM_SLAVE, 62, "CAMSYS_CAM_B", true},
{E_DAPC_MM_SLAVE, 63, "CAMSYS_CAM_TOP_SET", true},
{E_DAPC_MM_SLAVE, 64, "CAMSYS_CAM_A_SET", true},
{E_DAPC_MM_SLAVE, 65, "CAMSYS_CAM_B_SET", true},
{E_DAPC_MM_SLAVE, 66, "CAMSYS_CAM_TOP_INNER", true},
{E_DAPC_MM_SLAVE, 67, "CAMSYS_CAM_A_INNER", true},
{E_DAPC_MM_SLAVE, 68, "CAMSYS_CAM_B_INNER", true},
/* 220 */
{E_DAPC_MM_SLAVE, 69, "CAMSYS_CAM_TOP_CLR", true},
{E_DAPC_MM_SLAVE, 70, "CAMSYS_CAM_A_CLR", true},
{E_DAPC_MM_SLAVE, 71, "CAMSYS_CAM_B_CLR", true},
{E_DAPC_MM_SLAVE, 72, "CAMSYS_CAM_A_EXT", true},
{E_DAPC_MM_SLAVE, 73, "CAMSYS_CAM_B_EXT", true},
{E_DAPC_MM_SLAVE, 74, "CAMSYS_SENINF_A", true},
{E_DAPC_MM_SLAVE, 75, "CAMSYS_SENINF_B", true},
{E_DAPC_MM_SLAVE, 76, "CAMSYS_SENINF_C", true},
{E_DAPC_MM_SLAVE, 77, "CAMSYS_SENINF_D", true},
{E_DAPC_MM_SLAVE, 78, "CAMSYS_SENINF_E", true},
/* 230 */
{E_DAPC_MM_SLAVE, 79, "CAMSYS_SENINF_F", true},
{E_DAPC_MM_SLAVE, 80, "CAMSYS_SENINF_G", true},
{E_DAPC_MM_SLAVE, 81, "CAMSYS_SENINF_H", true},
{E_DAPC_MM_SLAVE, 82, "CAMSYS_CAMSV_A", true},
{E_DAPC_MM_SLAVE, 83, "CAMSYS_CAMSV_B", true},
{E_DAPC_MM_SLAVE, 84, "CAMSYS_CAMSV_C", true},
{E_DAPC_MM_SLAVE, 85, "CAMSYS_CAMSV_D", true},
{E_DAPC_MM_SLAVE, 86, "CAMSYS_OTHERS_0", true},
{E_DAPC_MM_SLAVE, 87, "CAMSYS_MD32 DMEM", true},
{E_DAPC_MM_SLAVE, 88, "CAMSYS_RESERVED", true},
/* 240 */
{E_DAPC_MM_SLAVE, 89, "CAMSYS_MD32 PMEM", true},
{E_DAPC_MM_SLAVE, 90, "CAMSYS_MD32 IP", true},
{E_DAPC_MM_SLAVE, 91, "CAMSYS_CCU_CTL", true},
{E_DAPC_OTHERS_SLAVE, -1, "SSPM_SBUS2APB_BRIDGE_UNALIGN", true},
{E_DAPC_OTHERS_SLAVE, -1, "SSPM_SBUS2APB_BRIDGE_OUT_OF_BOUND", true},
{E_DAPC_OTHERS_SLAVE, -1, "SSPM_SBUS2APB_BRIDGE_WAY_EN", true},
{E_DAPC_OTHERS_SLAVE, -1, "PERIAPB_BRIDGE_UNALIGN", true},
{E_DAPC_OTHERS_SLAVE, -1, "PERIAPB_BRIDGE_OUT_OF_BOUND", true},
{E_DAPC_OTHERS_SLAVE, -1, "PERIAPB_BRIDGE_WAY_EN", true},
{E_DAPC_OTHERS_SLAVE, -1, "EAST_PERIAPB_UNALIGN", true},
/* 250 */
{E_DAPC_OTHERS_SLAVE, -1, "EAST_PERIAPB _OUT_OF_BOUND", true},
{E_DAPC_OTHERS_SLAVE, -1, "EAST_PERIAPB _ERR_WAY_EN", true},
{E_DAPC_OTHERS_SLAVE, -1, "SOUTH_PERIAPB_UNALIGN", true},
{E_DAPC_OTHERS_SLAVE, -1, "SOUTH_PERIAPB _OUT_OF_BOUND", true},
{E_DAPC_OTHERS_SLAVE, -1, "SOUTH_PERIAPB _ERR_WAY_EN", true},
{E_DAPC_OTHERS_SLAVE, -1, "WEST_PERIAPB_UNALIGN", true},
{E_DAPC_OTHERS_SLAVE, -1, "WEST _PERIAPB _OUT_OF_BOUND", true},
{E_DAPC_OTHERS_SLAVE, -1, "WEST _PERIAPB _ERR_WAY_EN", true},
{E_DAPC_OTHERS_SLAVE, -1, "NORTH_SBUS2APB_BRIDGE_UNALIGN", true},
{E_DAPC_OTHERS_SLAVE, -1, "NORTH_SBUS2APB_BRIDGE_OUT_OF_BOUND", true},
/* 260 */
{E_DAPC_OTHERS_SLAVE, -1, "NORTH_SBUS2APB_BRIDGE_ERR_WAY_EN", true},
{E_DAPC_OTHERS_SLAVE, -1, "INFRA_PDN_SBUS2APB_BRIDGE_DECERR", true},
{E_DAPC_OTHERS_SLAVE, -1, "TOPAXI_SI2_DECERR", true},
{E_DAPC_OTHERS_SLAVE, -1, "TOPAXI_SI1_DECERR", true},
{E_DAPC_OTHERS_SLAVE, -1, "TOPAXI_SI0_DECERR", true},
{E_DAPC_OTHERS_SLAVE, -1, "PERIAXI_SI0_DECERR", true},
{E_DAPC_OTHERS_SLAVE, -1, "PERIAXI_SI1_DECERR", true},
{E_DAPC_OTHERS_SLAVE, -1, "TOPAXI_SI3_DECERR", true},
{E_DAPC_OTHERS_SLAVE, -1, "TOPAXI_SI4_DECERR", true},
{E_DAPC_OTHERS_SLAVE, -1, "SRAMROM_SI0_DECERR", true},
/* 270 */
{E_DAPC_OTHERS_SLAVE, -1, "SRAMROM*", true},
{E_DAPC_OTHERS_SLAVE, -1, "AP_DMA*", false},
{E_DAPC_OTHERS_SLAVE, -1, "DEVICE_APC_AO_INFRA_PERI*", false},
{E_DAPC_OTHERS_SLAVE, -1, "DEVICE_APC_AO_MD*", false},
{E_DAPC_OTHERS_SLAVE, -1, "DEVICE_APC_AO_MM*", false},
{E_DAPC_OTHERS_SLAVE, -1, "CM_DQ_SECURE*", false},
{E_DAPC_OTHERS_SLAVE, -1, "MM_IOMMU_DOMAIN*", false},
{E_DAPC_OTHERS_SLAVE, -1, "DISP_GCE*", false},
{E_DAPC_OTHERS_SLAVE, -1, "DEVICE_APC*", false},
{E_DAPC_OTHERS_SLAVE, -1, "EMI*", false},
/* 280 */
{E_DAPC_OTHERS_SLAVE, -1, "EMI_MPU*", false},
{E_DAPC_OTHERS_SLAVE, -1, "PMIC_WRAP*", false},
{E_DAPC_OTHERS_SLAVE, -1, "IMP_IIC_WRAP*", false},
};
static struct PERIAXI_ID_INFO paxi_int_mi_id_to_master[] = {
{"MD", { 1, 1, 2, 0 } },
{"APDMA", { 1, 0, 2, 0 } },
{"MCUPM", { 0, 0, 0, 0 } },
{"SPM", { 0, 0, 1, 0 } },
{"CCU", { 0, 0, 0, 1 } },
{"THERM", { 0, 0, 1, 1 } },
};
static struct TOPAXI_ID_INFO topaxi_mi0_id_to_master[] = {
{"DebugTop", { 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0 } },
{"MSDC0", { 1, 0, 1, 0, 0, 0, 0, 0, 2, 2, 0, 0 } },
{"SPI0", { 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0 } },
{"Audio", { 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0 } },
{"MSDC1", { 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0 } },
{"PWM", { 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0 } },
{"USB20", { 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0 } },
{"SPI1", { 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0 } },
{"SPI2", { 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0 } },
{"N/A", { 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0 } },
{"THERM", { 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0 } },
{"CCU", { 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0 } },
{"SPM", { 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0 } },
{"MCUPM", { 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0 } },
{"DMA_EXT", { 1, 0, 1, 0, 0, 0, 0, 1, 2, 0, 0, 0 } },
{"SPI5", { 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0 } },
{"SPI4", { 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0 } },
{"SPI3", { 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0 } },
{"N/A", { 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0 } },
{"Connsys WiFi", { 1, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 0 } },
{"Connsys Rbist", { 1, 0, 0, 1, 0, 1, 0, 2, 0, 0, 0, 0 } },
{"Connsys MCU R/W", { 1, 0, 0, 1, 0, 0, 1, 2, 0, 0, 0, 0 } },
{"Connsys N/A", { 1, 0, 0, 1, 0, 1, 1, 2, 0, 0, 0, 0 } },
{"DX_CC", { 1, 0, 1, 1, 0, 2, 2, 2, 2, 0, 0, 0 } },
{"CQ_DMA", { 1, 0, 0, 0, 1, 2, 2, 2, 0, 0, 0, 0 } },
{"CLDMA", { 1, 0, 1, 0, 1, 2, 2, 0, 0, 0, 0, 0 } },
{"GCE_M", { 1, 0, 0, 1, 1, 2, 2, 0, 0, 0, 0, 0 } },
{"SCP", { 0, 1, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0 } },
{"SSPM", { 0, 1, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0 } },
{"APMCU_mp0_Write", { 0, 0, 0, 0, 1, 2, 2, 0, 0, 0, 0, 0 } },
{"APMCU_mp0_Write", { 0, 0, 0, 0, 1, 2, 2, 1, 0, 0, 0, 0 } },
{"APMCU_mp0_Write", { 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 } },
{"APMCU_mp0_Write", { 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0 } },
{"APMCU_mp0_Write", { 0, 0, 0, 0, 1, 2, 1, 0, 1, 0, 0, 0 } },
{"APMCU_mp0_Write", { 0, 0, 0, 0, 1, 2, 2, 1, 1, 0, 0, 0 } },
{"APMCU_mp0_Write", { 0, 0, 0, 0, 1, 2, 2, 2, 2, 1, 0, 0 } },
{"APMCU_mp0_Write", { 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2 } },
{"APMCU_mp0_Read", { 0, 0, 0, 0, 1, 2, 2, 0, 0, 0, 0, 0 } },
{"APMCU_mp0_Read", { 0, 0, 0, 0, 1, 2, 2, 1, 0, 0, 0, 0 } },
{"APMCU_mp0_Read", { 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 } },
{"APMCU_mp0_Read", { 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0 } },
{"APMCU_mp0_Read", { 0, 0, 0, 0, 1, 2, 1, 0, 1, 0, 0, 0 } },
{"APMCU_mp0_Read", { 0, 0, 0, 0, 1, 2, 2, 1, 1, 0, 0, 0 } },
{"APMCU_mp0_Read", { 0, 0, 0, 0, 1, 0, 0, 2, 2, 1, 0, 0 } },
{"APMCU_mp0_Read", { 0, 0, 0, 0, 1, 1, 0, 2, 2, 1, 0, 0 } },
{"APMCU_mp0_Read", { 0, 0, 0, 0, 1, 2, 1, 2, 2, 1, 0, 0 } },
{"APMCU_mp0_Read", { 0, 0, 0, 0, 1, 2, 2, 2, 2, 2, 1, 0 } },
{"APMCU_mp1_Write", { 0, 0, 1, 1, 0, 2, 2, 0, 0, 0, 0, 0 } },
{"APMCU_mp1_Write", { 0, 0, 1, 1, 0, 2, 2, 1, 0, 0, 0, 0 } },
{"APMCU_mp1_Write", { 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0 } },
{"APMCU_mp1_Write", { 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0 } },
{"APMCU_mp1_Write", { 0, 0, 1, 1, 0, 2, 1, 0, 1, 0, 0, 0 } },
{"APMCU_mp1_Write", { 0, 0, 1, 1, 0, 2, 2, 1, 1, 0, 0, 0 } },
{"APMCU_mp1_Write", { 0, 0, 1, 1, 0, 2, 2, 2, 2, 1, 0, 0 } },
{"APMCU_mp1_Write", { 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2 } },
{"APMCU_mp1_Read", { 0, 0, 1, 1, 0, 2, 2, 0, 0, 0, 0, 0 } },
{"APMCU_mp1_Read", { 0, 0, 1, 1, 0, 2, 2, 1, 0, 0, 0, 0 } },
{"APMCU_mp1_Read", { 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0 } },
{"APMCU_mp1_Read", { 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0 } },
{"APMCU_mp1_Read", { 0, 0, 1, 1, 0, 2, 1, 0, 1, 0, 0, 0 } },
{"APMCU_mp1_Read", { 0, 0, 1, 1, 0, 2, 2, 1, 1, 0, 0, 0 } },
{"APMCU_mp1_Read", { 0, 0, 1, 1, 0, 0, 0, 2, 2, 1, 0, 0 } },
{"APMCU_mp1_Read", { 0, 0, 1, 1, 0, 1, 0, 2, 2, 1, 0, 0 } },
{"APMCU_mp1_Read", { 0, 0, 1, 1, 0, 2, 1, 2, 2, 1, 0, 0 } },
{"APMCU_mp1_Read", { 0, 0, 1, 1, 0, 2, 2, 2, 2, 2, 1, 0 } },
{"APMCU_Write", { 0, 0, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0 } },
{"APMCU_Write", { 0, 0, 2, 2, 2, 2, 0, 0, 1, 0, 0, 0 } },
{"APMCU_Write", { 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0 } },
{"APMCU_Read", { 0, 0, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0 } },
{"APMCU_Read", { 0, 0, 2, 2, 2, 2, 0, 0, 1, 0, 0, 0 } },
{"APMCU_Read", { 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0 } },
{"APMCU_Read", { 0, 0, 2, 1, 0, 0, 0, 0, 0, 1, 0, 0 } },
{"APMCU_Read", { 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0 } },
{"APMCU_Read", { 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1 } },
};
static const char *topaxi_mi0_trans(int bus_id)
{
const char *master = "UNKNOWN_MASTER_FROM_TOPAXI";
int master_count = ARRAY_SIZE(topaxi_mi0_id_to_master);
int i, j;
for (i = 0 ; i < master_count; i++) {
for (j = 0 ; j < TOPAXI_MI0_BIT_LENGTH ; j++) {
if (topaxi_mi0_id_to_master[i].bit[j] == 2)
continue;
if (((bus_id >> j) & 0x1) ==
topaxi_mi0_id_to_master[i].bit[j]) {
continue;
} else {
break;
}
}
if (j == TOPAXI_MI0_BIT_LENGTH) {
DEVAPC_MSG("%s %s %s\n",
"catch it from TOPAXI_MI0.",
"Master is:",
topaxi_mi0_id_to_master[i].master);
master = topaxi_mi0_id_to_master[i].master;
}
}
return master;
}
static const char *paxi_int_mi_trans(int bus_id)
{
const char *master = "UNKNOWN_MASTER_FROM_PAXI";
int master_count = ARRAY_SIZE(paxi_int_mi_id_to_master);
int i, j;
if ((bus_id & 0x3) == 0x2) {
master = topaxi_mi0_trans(bus_id >> 2);
return master;
}
for (i = 0 ; i < master_count; i++) {
for (j = 0 ; j < PERIAXI_INT_MI_BIT_LENGTH ; j++) {
if (paxi_int_mi_id_to_master[i].bit[j] == 2)
continue;
if (((bus_id >> j) & 0x1) ==
paxi_int_mi_id_to_master[i].bit[j]) {
continue;
} else {
break;
}
}
if (j == PERIAXI_INT_MI_BIT_LENGTH) {
DEVAPC_MSG("%s %s %s\n",
"catch it from PERIAXI_INT_MI.",
"Master is:",
paxi_int_mi_id_to_master[i].master);
master = paxi_int_mi_id_to_master[i].master;
}
}
return master;
}
const char *bus_id_to_master(int bus_id, uint32_t vio_addr, int vio_idx)
{
uint32_t h_byte;
const char *master = "UNKNOWN_MASTER";
DEVAPC_DBG_MSG("bus id = 0x%x, vio_addr = 0x%x\n",
bus_id, vio_addr);
/* SPM MTCMOS disable will set way_en[7:4] reg to block transaction,
* and it will triggered TOPAXI_SI0_DECERR instead of slave vio.
*/
if (vio_idx == TOPAXI_SI0_DECERR) {
DEVAPC_DBG_MSG("vio is from TOPAXI_SI0_DECERR\n");
master = topaxi_mi0_trans(bus_id);
return master;
} else if (vio_idx == PERIAXI_SI1_DECERR) {
DEVAPC_DBG_MSG("vio is from PERIAXI_SI1_DECERR\n");
master = paxi_int_mi_trans(bus_id);
return master;
} else if (vio_idx == SRAMROM_VIO_INDEX) {
DEVAPC_DBG_MSG("vio is from SRAMROM\n");
if ((bus_id & 0x1) == 0x0)
master = topaxi_mi0_trans(bus_id >> 1);
else
DEVAPC_MSG("[FAILED] Cannot decode bus_id: 0x%x\n",
bus_id);
return master;
}
h_byte = (vio_addr >> 24) & 0xFF;
/* to Infra/Peri/Audio/MD/CONN
* or MMSYS
* or MFG
*/
if (((h_byte >> 4) == 0x0) && h_byte != 0x0C && h_byte != 0x0D &&
h_byte != 0x0E) {
DEVAPC_DBG_MSG("vio addr is from on-chip SRAMROM\n");
if ((bus_id & 0x1) == 0x0)
master = topaxi_mi0_trans(bus_id >> 1);
else
DEVAPC_MSG("decode failed for sram_s\n");
} else if (h_byte == 0x10 || h_byte == 0x11 || h_byte == 0x18 ||
h_byte == 0x0C || h_byte == 0x0D || h_byte == 0x0E ||
(h_byte >> 4) == 0x2 || (h_byte >> 4) == 0x3) {
DEVAPC_DBG_MSG("vio addr is from Infra/Peri\n");
master = paxi_int_mi_trans(bus_id);
} else if (h_byte == 0x14 || h_byte == 0x15 || h_byte == 0x16 ||
h_byte == 0x17 || h_byte == 0x1A) {
DEVAPC_DBG_MSG("vio addr is from MM\n");
if ((bus_id & 0x1) == 1)
return "GCE";
master = topaxi_mi0_trans(bus_id >> 1);
} else if (h_byte == 0x13) {
DEVAPC_DBG_MSG("vio addr is from MFG\n");
master = topaxi_mi0_trans(bus_id);
} else {
DEVAPC_MSG("[FAILED] Cannot decode vio addr\n");
master = "UNKNOWN_MASTER";
}
return master;
}
/* violation index corresponds to subsys */
const char *index_to_subsys(uint32_t index)
{
if (index >= MFGSYS_START && index <= MFGSYS_END)
return "MFGSYS";
else if (index == SMI_COMMON || index == SMI_LARB0 ||
index == IMGSYS_SMI_LARB2 || index == VDECSYS_SMI_LARB1)
return "SMI";
else if (index >= MMSYS_MDP_START && index <= MMSYS_MDP_END)
return "MMSYS_MDP";
else if (index >= MMSYS_DISP_START && index <= MMSYS_DISP_END)
return "MMSYS_DISP";
else if (index >= IMGSYS_START && index <= IMGSYS_END)
return "IMGSYS";
else if (index >= VENCSYS_START && index <= VENCSYS_END)
return "VENCSYS";
else if (index >= VDECSYS_START && index <= VDECSYS_END)
return "VDECSYS";
else if (index >= CAMSYS_START && index <= CAMSYS_END)
return "CAMSYS";
else if (index < ARRAY_SIZE(mt6768_infra_devices))
return mt6768_infra_devices[index].device;
else
return "OUT_OF_BOUND";
}
#ifdef CONFIG_DEVAPC_MMAP_DEBUG
void devapc_catch_illegal_range(phys_addr_t phys_addr, size_t size)
{
/*
* Catch BROM addr mapped
*/
if (phys_addr >= 0x0 && phys_addr < SRAM_START_ADDR) {
DEVAPC_MSG("%s: %s %s:(%pa), %s:(0x%lx)\n",
"catch BROM address mapped!",
__func__, "phys_addr", &phys_addr,
"size", size);
BUG_ON(1);
}
}
EXPORT_SYMBOL(devapc_catch_illegal_range);
#endif
static ssize_t mt6768_devapc_dbg_read(struct file *file, char __user *buffer,
size_t count, loff_t *ppos)
{
return mtk_devapc_dbg_read(file, buffer, count, ppos);
}
static ssize_t mt6768_devapc_dbg_write(struct file *file,
const char __user *buffer, size_t count, loff_t *data)
{
return mtk_devapc_dbg_write(file, buffer, count, data);
}
static const struct file_operations devapc_dbg_fops = {
.owner = THIS_MODULE,
.write = mt6768_devapc_dbg_write,
.read = mt6768_devapc_dbg_read,
};
static struct mtk_devapc_dbg_status mt6768_devapc_dbg_stat = {
.enable_ut = PLAT_DBG_UT_DEFAULT,
.enable_KE = PLAT_DBG_KE_DEFAULT,
.enable_AEE = PLAT_DBG_AEE_DEFAULT,
.enable_dapc = PLAT_DBG_DAPC_DEFAULT,
};
static struct mtk_devapc_vio_info mt6768_devapc_vio_info = {
.vio_cfg_max_idx = PLAT_VIO_CFG_MAX_IDX,
.vio_max_idx = PLAT_VIO_MAX_IDX,
.vio_mask_sta_num = PLAT_VIO_MASK_STA_NUM,
.vio_shift_max_bit = PLAT_VIO_SHIFT_MAX_BIT,
.sramrom_vio_idx = SRAMROM_VIO_INDEX,
};
static const struct mtk_infra_vio_dbg_desc mt6768_vio_dbgs = {
.infra_vio_dbg_mstid = INFRA_VIO_DBG_MSTID,
.infra_vio_dbg_mstid_start_bit = INFRA_VIO_DBG_MSTID_START_BIT,
.infra_vio_dbg_dmnid = INFRA_VIO_DBG_DMNID,
.infra_vio_dbg_dmnid_start_bit = INFRA_VIO_DBG_DMNID_START_BIT,
.infra_vio_dbg_w_vio = INFRA_VIO_DBG_W_VIO,
.infra_vio_dbg_w_vio_start_bit = INFRA_VIO_DBG_W_VIO_START_BIT,
.infra_vio_dbg_r_vio = INFRA_VIO_DBG_R_VIO,
.infra_vio_dbg_r_vio_start_bit = INFRA_VIO_DBG_R_VIO_START_BIT,
.infra_vio_addr_high = INFRA_VIO_ADDR_HIGH,
.infra_vio_addr_high_start_bit = INFRA_VIO_ADDR_HIGH_START_BIT,
};
static const struct mtk_sramrom_sec_vio_desc mt6768_sramrom_sec_vios = {
.sramrom_sec_vio_id_mask = SRAMROM_SEC_VIO_ID_MASK,
.sramrom_sec_vio_id_shift = SRAMROM_SEC_VIO_ID_SHIFT,
.sramrom_sec_vio_domain_mask = SRAMROM_SEC_VIO_DOMAIN_MASK,
.sramrom_sec_vio_domain_shift = SRAMROM_SEC_VIO_DOMAIN_SHIFT,
.sramrom_sec_vio_rw_mask = SRAMROM_SEC_VIO_RW_MASK,
.sramrom_sec_vio_rw_shift = SRAMROM_SEC_VIO_RW_SHIFT,
};
static const struct mtk_devapc_pd_desc mt6768_devapc_pds = {
.pd_vio_mask_offset = PD_VIO_MASK_OFFSET,
.pd_vio_sta_offset = PD_VIO_STA_OFFSET,
.pd_vio_dbg0_offset = PD_VIO_DBG0_OFFSET,
.pd_vio_dbg1_offset = PD_VIO_DBG1_OFFSET,
.pd_apc_con_offset = PD_APC_CON_OFFSET,
.pd_shift_sta_offset = PD_SHIFT_STA_OFFSET,
.pd_shift_sel_offset = PD_SHIFT_SEL_OFFSET,
.pd_shift_con_offset = PD_SHIFT_CON_OFFSET,
};
static struct mtk_devapc_soc mt6768_data = {
.dbg_stat = &mt6768_devapc_dbg_stat,
.device_info = mt6768_infra_devices,
.ndevices = ARRAY_SIZE(mt6768_infra_devices),
.vio_info = &mt6768_devapc_vio_info,
.vio_dbgs = &mt6768_vio_dbgs,
.sramrom_sec_vios = &mt6768_sramrom_sec_vios,
.devapc_pds = &mt6768_devapc_pds,
.subsys_get = &index_to_subsys,
.master_get = &bus_id_to_master,
};
static const struct of_device_id mt6768_devapc_dt_match[] = {
{ .compatible = "mediatek,mt6768-devapc" },
{},
};
static int mt6768_devapc_probe(struct platform_device *pdev)
{
proc_create("devapc_dbg", 0664, NULL, &devapc_dbg_fops);
return mtk_devapc_probe(pdev, &mt6768_data);
}
static int mt6768_devapc_remove(struct platform_device *dev)
{
return mtk_devapc_remove(dev);
}
static struct platform_driver mt6768_devapc_driver = {
.probe = mt6768_devapc_probe,
.remove = mt6768_devapc_remove,
.driver = {
.name = KBUILD_MODNAME,
.owner = THIS_MODULE,
.of_match_table = mt6768_devapc_dt_match,
},
};
module_platform_driver(mt6768_devapc_driver);
MODULE_DESCRIPTION("Mediatek MT6768 Device APC Driver");
MODULE_AUTHOR("Neal Liu <neal.liu@mediatek.com>");
MODULE_LICENSE("GPL");
+129
View File
@@ -0,0 +1,129 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2019 MediaTek Inc.
*/
#ifndef __DEVAPC_MT6768_H__
#define __DEVAPC_MT6768_H__
/******************************************************************************
* VARIABLE DEFINATION
******************************************************************************/
/* dbg status default setting */
#define PLAT_DBG_UT_DEFAULT false
#define PLAT_DBG_KE_DEFAULT true
#define PLAT_DBG_AEE_DEFAULT true
#define PLAT_DBG_DAPC_DEFAULT false
#define PLAT_VIO_CFG_MAX_IDX 242
#define PLAT_VIO_MAX_IDX 282
#define PLAT_VIO_MASK_STA_NUM 9
#define PLAT_VIO_SHIFT_MAX_BIT 21
/******************************************************************************
* DATA STRUCTURE & FUNCTION DEFINATION
******************************************************************************/
const char *bus_id_to_master(int bus_id, uint32_t vio_addr, int vio_idx);
const char *index_to_subsys(unsigned int index);
/* violation index corresponds to subsys */
enum SMI_INDEX {
SMI_COMMON = 157,
SMI_LARB0 = 158,
IMGSYS_SMI_LARB2 = 182,
VDECSYS_SMI_LARB1 = 198,
};
enum MFGSYS_INDEX {
MFGSYS_START = 151,
MFGSYS_END = 154,
};
enum MMSYS_INDEX {
MMSYS_MDP_START = 155,
MMSYS_MDP_END = 165,
MMSYS_DISP_START = 166,
MMSYS_DISP_END = 176,
};
enum IMGSYS_INDEX {
IMGSYS_START = 181,
IMGSYS_END = 196,
};
enum VENCSYS_INDEX {
VENCSYS_START = 201,
VENCSYS_END = 208,
};
enum VDECSYS_INDEX {
VDECSYS_START = 197,
VDECSYS_END = 200,
};
enum CAMSYS_INDEX {
CAMSYS_START = 209,
CAMSYS_END = 242,
};
enum OTHER_TYPES_INDEX {
SRAMROM_VIO_INDEX = 270,
TOPAXI_SI0_DECERR = 264,
PERIAXI_SI1_DECERR = 266,
};
enum BUSID_LENGTH {
PERIAXI_INT_MI_BIT_LENGTH = 4,
TOPAXI_MI0_BIT_LENGTH = 12,
};
/* bit == 2 means don't care */
struct PERIAXI_ID_INFO {
const char *master;
uint8_t bit[PERIAXI_INT_MI_BIT_LENGTH];
};
struct TOPAXI_ID_INFO {
const char *master;
uint8_t bit[TOPAXI_MI0_BIT_LENGTH];
};
/******************************************************************************
* PLATFORM DEFINATION
******************************************************************************/
/* For Infra VIO_DBG */
#define INFRA_VIO_DBG_MSTID 0x0000FFFF
#define INFRA_VIO_DBG_MSTID_START_BIT 0
#define INFRA_VIO_DBG_DMNID 0x003F0000
#define INFRA_VIO_DBG_DMNID_START_BIT 16
#define INFRA_VIO_DBG_W_VIO 0x00400000
#define INFRA_VIO_DBG_W_VIO_START_BIT 22
#define INFRA_VIO_DBG_R_VIO 0x00800000
#define INFRA_VIO_DBG_R_VIO_START_BIT 23
#define INFRA_VIO_ADDR_HIGH 0x0F000000
#define INFRA_VIO_ADDR_HIGH_START_BIT 24
/* For SRAMROM VIO */
#define SRAMROM_SEC_VIO_ID_MASK 0x00FFFF00
#define SRAMROM_SEC_VIO_ID_SHIFT 8
#define SRAMROM_SEC_VIO_DOMAIN_MASK 0x0F000000
#define SRAMROM_SEC_VIO_DOMAIN_SHIFT 24
#define SRAMROM_SEC_VIO_RW_MASK 0x80000000
#define SRAMROM_SEC_VIO_RW_SHIFT 31
/* For DEVAPC PD */
#define PD_VIO_MASK_OFFSET 0x0
#define PD_VIO_STA_OFFSET 0x400
#define PD_VIO_DBG0_OFFSET 0x900
#define PD_VIO_DBG1_OFFSET 0x904
#define PD_APC_CON_OFFSET 0xF00
#define PD_SHIFT_STA_OFFSET 0xF10
#define PD_SHIFT_SEL_OFFSET 0xF14
#define PD_SHIFT_CON_OFFSET 0xF20
#define SRAM_START_ADDR (0x100000)
#endif /* __DEVAPC_MT6768_H__ */
+968
View File
@@ -0,0 +1,968 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2019 MediaTek Inc.
*/
#include <linux/bug.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include "devapc-mtk-common.h"
#include "devapc-mt6779.h"
static struct mtk_device_info mt6779_infra_devices[] = {
/* slave type, config_idx, device name enable_vio_irq */
/* 0 */
{E_DAPC_INFRA_PERI_SLAVE, 0, "INFRA_AO_TOPCKGEN", true},
{E_DAPC_INFRA_PERI_SLAVE, 1, "INFRA_AO_INFRASYS_CONFIG_REGS", true},
{E_DAPC_INFRA_PERI_SLAVE, 2, "INFRA_AO_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 3, "INFRA_AO_ PERICFG", true},
{E_DAPC_INFRA_PERI_SLAVE, 4, "INFRA_AO_EFUSE_AO_DEBUG", true},
{E_DAPC_INFRA_PERI_SLAVE, 5, "INFRA_AO_GPIO", true},
{E_DAPC_INFRA_PERI_SLAVE, 6, "INFRA_AO_SLEEP_CONTROLLER", true},
{E_DAPC_INFRA_PERI_SLAVE, 7, "INFRA_AO_TOPRGU", true},
{E_DAPC_INFRA_PERI_SLAVE, 8, "INFRA_AO_APXGPT", true},
{E_DAPC_INFRA_PERI_SLAVE, 9, "INFRA_AO_RESERVE", true},
/* 10 */
{E_DAPC_INFRA_PERI_SLAVE, 10, "INFRA_AO_SEJ", true},
{E_DAPC_INFRA_PERI_SLAVE, 11, "INFRA_AO_AP_CIRQ_EINT", true},
{E_DAPC_INFRA_PERI_SLAVE, 12, "INFRA_AO_APMIXEDSYS", true},
{E_DAPC_INFRA_PERI_SLAVE, 13, "INFRA_AO_PMIC_WRAP", true},
{E_DAPC_INFRA_PERI_SLAVE, 14, "INFRA_AO_DEVICE_APC_AO_MM", true},
{E_DAPC_INFRA_PERI_SLAVE, 15, "INFRA_AO_SLEEP_CONTROLLER_MD", true},
{E_DAPC_INFRA_PERI_SLAVE, 16, "INFRA_AO_KEYPAD", true},
{E_DAPC_INFRA_PERI_SLAVE, 17, "INFRA_AO_TOP_MISC", true},
{E_DAPC_INFRA_PERI_SLAVE, 18, "INFRA_AO_ DVFS_CTRL_PROC", true},
{E_DAPC_INFRA_PERI_SLAVE, 19, "INFRA_AO_MBIST_AO_REG", true},
/* 20 */
{E_DAPC_INFRA_PERI_SLAVE, 20, "INFRA_AO_CLDMA_AO_AP", true},
{E_DAPC_INFRA_PERI_SLAVE, 21, "INFRA_AO_DEVICE_MPU", true},
{E_DAPC_INFRA_PERI_SLAVE, 22, "INFRA_AO_AES_TOP_0", true},
{E_DAPC_INFRA_PERI_SLAVE, 23, "INFRA_AO_SYS_TIMER", true},
{E_DAPC_INFRA_PERI_SLAVE, 24, "INFRA_AO_MDEM_TEMP_SHARE", true},
{E_DAPC_INFRA_PERI_SLAVE, 25, "INFRA_AO_DEVICE_APC_AO_MD", true},
{E_DAPC_INFRA_PERI_SLAVE, 26, "INFRA_AO_SECURITY_AO", true},
{E_DAPC_INFRA_PERI_SLAVE, 27, "INFRA_AO_TOPCKGEN_REG", true},
{E_DAPC_INFRA_PERI_SLAVE, 28, "INFRA_AO_DEVICE_APC_AO_INFRA_PERI", true},
{E_DAPC_INFRA_PERI_SLAVE, 29, "INFRA_AO_SLEEP_SRAM", true},
/* 30 */
{E_DAPC_INFRA_PERI_SLAVE, 30, "INFRA_AO_SLEEP_SRAM", true},
{E_DAPC_INFRA_PERI_SLAVE, 31, "INFRA_AO_SLEEP_SRAM", true},
{E_DAPC_INFRA_PERI_SLAVE, 32, "INFRA_AO_SLEEP_SRAM", true},
{E_DAPC_INFRA_PERI_SLAVE, -1, "INFRASYS_RESERVE", false},
{E_DAPC_INFRA_PERI_SLAVE, -1, "INFRASYS_RESERVE", false},
{E_DAPC_INFRA_PERI_SLAVE, -1, "INFRASYS_RESERVE", false},
{E_DAPC_INFRA_PERI_SLAVE, -1, "INFRASYS_RESERVE", false},
{E_DAPC_INFRA_PERI_SLAVE, 37, "INFRASYS_SYS_CIRQ", true},
{E_DAPC_INFRA_PERI_SLAVE, 38, "INFRASYS_MM_IOMMU", true},
{E_DAPC_INFRA_PERI_SLAVE, 39, "INFRASYS_EFUSE_PDN_DEBUG", true},
/* 40 */
{E_DAPC_INFRA_PERI_SLAVE, 40, "INFRASYS_DEVICE_APC", true},
{E_DAPC_INFRA_PERI_SLAVE, 41, "INFRASYS_DBG_TRACKER", true},
{E_DAPC_INFRA_PERI_SLAVE, 42, "INFRASYS_CCIF0_AP", true},
{E_DAPC_INFRA_PERI_SLAVE, 43, "INFRASYS_CCIF0_MD", true},
{E_DAPC_INFRA_PERI_SLAVE, 44, "INFRASYS_CCIF1_AP", true},
{E_DAPC_INFRA_PERI_SLAVE, 45, "INFRASYS_CCIF1_MD", true},
{E_DAPC_INFRA_PERI_SLAVE, 46, "INFRASYS_MBIST", true},
{E_DAPC_INFRA_PERI_SLAVE, 47, "INFRASYS_INFRA_PDN_REGISTER", true},
{E_DAPC_INFRA_PERI_SLAVE, 48, "INFRASYS_TRNG", true},
{E_DAPC_INFRA_PERI_SLAVE, 49, "INFRASYS_DX_CC", true},
/* 50 */
{E_DAPC_INFRA_PERI_SLAVE, 50, "INFRASYS_MD_CCIF_MD1", true},
{E_DAPC_INFRA_PERI_SLAVE, 51, "INFRASYS_CQ_DMA", true},
{E_DAPC_INFRA_PERI_SLAVE, 52, "INFRASYS_MD_CCIF_MD2", true},
{E_DAPC_INFRA_PERI_SLAVE, 53, "INFRASYS_SRAMROM", true},
{E_DAPC_INFRA_PERI_SLAVE, 54, "INFRASYS_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 55, "INFRASYS_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 56, "INFRASYS_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 57, "INFRASYS_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 58, "INFRASYS_EMI", true},
{E_DAPC_INFRA_PERI_SLAVE, 59, "INFRASYS_DEVICE_MPU", true},
/* 60 */
{E_DAPC_INFRA_PERI_SLAVE, 60, "INFRASYS_CLDMA_PDN", true},
{E_DAPC_INFRA_PERI_SLAVE, 61, "INFRASYS_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 62, "INFRASYS_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 63, "INFRASYS_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 64, "INFRASYS_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, -1, "INFRASYS_RESERVE", false},
{E_DAPC_INFRA_PERI_SLAVE, -1, "INFRASYS_RESERVE", false},
{E_DAPC_INFRA_PERI_SLAVE, -1, "INFRASYS_RESERVE", false},
{E_DAPC_INFRA_PERI_SLAVE, -1, "INFRASYS_RESERVE", false},
{E_DAPC_INFRA_PERI_SLAVE, -1, "INFRASYS_RESERVE", false},
/* 70 */
{E_DAPC_INFRA_PERI_SLAVE, 65, "INFRASYS_RESERVE", true},
{E_DAPC_INFRA_PERI_SLAVE, 66, "INFRASYS_EMI_MPU", true},
{E_DAPC_INFRA_PERI_SLAVE, 67, "INFRASYS_DVFS_PROC", true},
{E_DAPC_INFRA_PERI_SLAVE, 68, "INFRASYS_GCE", true},
{E_DAPC_INFRA_PERI_SLAVE, -1, "INFRASYS_RESERVE", false},
{E_DAPC_INFRA_PERI_SLAVE, -1, "INFRASYS_RESERVE", false},
{E_DAPC_INFRA_PERI_SLAVE, -1, "INFRASYS_RESERVE", false},
{E_DAPC_INFRA_PERI_SLAVE, 33, "INFRASYS_DPMAIF", true},
{E_DAPC_INFRA_PERI_SLAVE, 34, "INFRASYS_DPMAIF", true},
{E_DAPC_INFRA_PERI_SLAVE, 35, "INFRASYS_DPMAIF", true},
/* 80 */
{E_DAPC_INFRA_PERI_SLAVE, 35, "INFRASYS_DPMAIF", true},
{E_DAPC_INFRA_PERI_SLAVE, 70, "INFRASYS_DRAMC_CH1_TOP0", true},
{E_DAPC_INFRA_PERI_SLAVE, 71, "INFRASYS_DRAMC_CH1_TOP1", true},
{E_DAPC_INFRA_PERI_SLAVE, 72, "INFRASYS_DRAMC_CH1_TOP2", true},
{E_DAPC_INFRA_PERI_SLAVE, 73, "INFRASYS_DRAMC_CH1_TOP3", true},
{E_DAPC_INFRA_PERI_SLAVE, 74, "INFRASYS_DRAMC_CH1_TOP4", true},
{E_DAPC_INFRA_PERI_SLAVE, 75, "INFRASYS_DRAMC_CH1_TOP5", true},
{E_DAPC_INFRA_PERI_SLAVE, 76, "INFRASYS_DRAMC_CH1_TOP6", true},
{E_DAPC_INFRA_PERI_SLAVE, 77, "INFRASYS_CCIF2_AP", true},
{E_DAPC_INFRA_PERI_SLAVE, 78, "INFRASYS_CCIF2_MD", true},
/* 90 */
{E_DAPC_INFRA_PERI_SLAVE, 79, "INFRASYS_CCIF3_AP", true},
{E_DAPC_INFRA_PERI_SLAVE, 80, "INFRASYS_CCIF3_MD", true},
{E_DAPC_INFRA_PERI_SLAVE, 81, "INFRASYS_DRAMC_CH0_TOP0", true},
{E_DAPC_INFRA_PERI_SLAVE, 82, "INFRASYS_DRAMC_CH0_TOP1", true},
{E_DAPC_INFRA_PERI_SLAVE, 83, "INFRASYS_DRAMC_CH0_TOP2", true},
{E_DAPC_INFRA_PERI_SLAVE, 84, "INFRASYS_DRAMC_CH0_TOP3", true},
{E_DAPC_INFRA_PERI_SLAVE, 85, "INFRASYS_DRAMC_CH0_TOP4", true},
{E_DAPC_INFRA_PERI_SLAVE, 86, "INFRASYS_DRAMC_CH0_TOP5", true},
{E_DAPC_INFRA_PERI_SLAVE, 87, "INFRASYS_DRAMC_CH0_TOP6", true},
{E_DAPC_INFRA_PERI_SLAVE, 88, "INFRASYS_CCIF4_AP", true},
/* 100 */
{E_DAPC_INFRA_PERI_SLAVE, 89, "INFRASYS_CCIF4_MD", true},
{E_DAPC_INFRA_PERI_SLAVE, 90, "INFRA_TOPAXI_BUS_TRACE", true},
{E_DAPC_INFRA_PERI_SLAVE, 91, "vpu_iommu/mm_iommu", true},
{E_DAPC_INFRA_PERI_SLAVE, 92, "vpu_iommu/mm_iommu", true},
{E_DAPC_INFRA_PERI_SLAVE, 93, "vpu_iommu/mm_iommu", true},
{E_DAPC_INFRA_PERI_SLAVE, 94, "vpu_iommu/mm_iommu", true},
{E_DAPC_INFRA_PERI_SLAVE, 95, "vpu_iommu/mm_iommu", true},
{E_DAPC_INFRA_PERI_SLAVE, 96, "sub_common2x1", true},
{E_DAPC_INFRA_PERI_SLAVE, 97, "sub_common2x1", true},
{E_DAPC_INFRA_PERI_SLAVE, 98, "sub_common2x1", true},
/* 110 */
{E_DAPC_INFRA_PERI_SLAVE, 110, "INFRA_AO_SSPM Partition 1", true},
{E_DAPC_INFRA_PERI_SLAVE, 111, "INFRA_AO_SSPM Partition 2", true},
{E_DAPC_INFRA_PERI_SLAVE, 112, "INFRA_AO_SSPM Partition 3", true},
{E_DAPC_INFRA_PERI_SLAVE, 113, "INFRA_AO_SSPM Partition 4", true},
{E_DAPC_INFRA_PERI_SLAVE, 114, "INFRA_AO_SSPM Partition 5", true},
{E_DAPC_INFRA_PERI_SLAVE, 115, "INFRA_AO_SSPM Partition 6", true},
{E_DAPC_INFRA_PERI_SLAVE, 116, "INFRA_AO_SSPM Partition 7", true},
{E_DAPC_INFRA_PERI_SLAVE, 117, "INFRA_AO_SSPM Partition 8", true},
{E_DAPC_INFRA_PERI_SLAVE, 118, "INFRA_AO_SSPM Partition 9", true},
{E_DAPC_INFRA_PERI_SLAVE, 119, "INFRA_AO_SSPM Partition 10", true},
/* 120 */
{E_DAPC_INFRA_PERI_SLAVE, 120, "INFRA_AO_SSPM Partition 11", true},
{E_DAPC_INFRA_PERI_SLAVE, 121, "INFRA_AO_SCP", true},
{E_DAPC_INFRA_PERI_SLAVE, 122, "INFRA_AO_HIFI3", true},
{E_DAPC_INFRA_PERI_SLAVE, 123, "INFRA_AO_MCUCFG", true},
{E_DAPC_INFRA_PERI_SLAVE, 124, "INFRASYS_DBUGSYS", true},
{E_DAPC_INFRA_PERI_SLAVE, 125, "PERISYS_APDMA", true},
{E_DAPC_INFRA_PERI_SLAVE, 126, "PERISYS_AUXADC", true},
{E_DAPC_INFRA_PERI_SLAVE, 127, "PERISYS_UART0", true},
{E_DAPC_INFRA_PERI_SLAVE, 128, "PERISYS_UART1", true},
{E_DAPC_INFRA_PERI_SLAVE, 129, "PERISYS_UART2", true},
/* 130 */
{E_DAPC_INFRA_PERI_SLAVE, 130, "PERISYS_UART3", true},
{E_DAPC_INFRA_PERI_SLAVE, 131, "PERISYS_PWM", true},
{E_DAPC_INFRA_PERI_SLAVE, 132, "PERISYS_I2C0", true},
{E_DAPC_INFRA_PERI_SLAVE, 133, "PERISYS_I2C1", true},
{E_DAPC_INFRA_PERI_SLAVE, 134, "PERISYS_I2C2", true},
{E_DAPC_INFRA_PERI_SLAVE, 135, "PERISYS_SPI0", true},
{E_DAPC_INFRA_PERI_SLAVE, 136, "PERISYS_PTP", true},
{E_DAPC_INFRA_PERI_SLAVE, 137, "PERISYS_BTIF", true},
{E_DAPC_INFRA_PERI_SLAVE, 138, "PERISYS_IRTX", true},
{E_DAPC_INFRA_PERI_SLAVE, 139, "PERISYS_DISP_PWM", true},
/* 140 */
{E_DAPC_INFRA_PERI_SLAVE, 140, "PERISYS_I2C3", true},
{E_DAPC_INFRA_PERI_SLAVE, 141, "PERISYS_SPI1", true},
{E_DAPC_INFRA_PERI_SLAVE, 142, "PERISYS_I2C4", true},
{E_DAPC_INFRA_PERI_SLAVE, 143, "PERISYS_SPI2", true},
{E_DAPC_INFRA_PERI_SLAVE, 144, "PERISYS_SPI3", true},
{E_DAPC_INFRA_PERI_SLAVE, 145, "PERISYS_I2C1_IMM", true},
{E_DAPC_INFRA_PERI_SLAVE, 146, "PERISYS_I2C2_IMM", true},
{E_DAPC_INFRA_PERI_SLAVE, 147, "PERISYS_I2C5", true},
{E_DAPC_INFRA_PERI_SLAVE, 148, "PERISYS_I2C5_IMM", true},
{E_DAPC_INFRA_PERI_SLAVE, 149, "PERISYS_SPI4", true},
/* 150 */
{E_DAPC_INFRA_PERI_SLAVE, 150, "PERISYS_SPI5", true},
{E_DAPC_INFRA_PERI_SLAVE, 151, "PERISYS_I2C7", true},
{E_DAPC_INFRA_PERI_SLAVE, 152, "PERISYS_I2C8", true},
{E_DAPC_INFRA_PERI_SLAVE, 153, "PERISYS_BUS_TRACE", true},
{E_DAPC_INFRA_PERI_SLAVE, 154, "PERISYS_SPI6", true},
{E_DAPC_INFRA_PERI_SLAVE, 155, "PERISYS_SPI7", true},
{E_DAPC_INFRA_PERI_SLAVE, 156, "PERISYS_USB", true},
{E_DAPC_INFRA_PERI_SLAVE, 157, "PERISYS_USB_2.0_SUB", true},
{E_DAPC_INFRA_PERI_SLAVE, 158, "PERISYS_AUDIO", true},
{E_DAPC_INFRA_PERI_SLAVE, 159, "PERISYS_MSDC0", true},
/* 160 */
{E_DAPC_INFRA_PERI_SLAVE, 160, "PERISYS_MSDC1", true},
{E_DAPC_INFRA_PERI_SLAVE, 161, "PERISYS_MSDC2", true},
{E_DAPC_INFRA_PERI_SLAVE, 162, "PERISYS_MSDC3", true},
{E_DAPC_INFRA_PERI_SLAVE, 163, "PERISYS_UFS", true},
{E_DAPC_INFRA_PERI_SLAVE, 164, "PERISUS_USB3.0_SIF", true},
{E_DAPC_INFRA_PERI_SLAVE, 165, "PERISUS_USB3.0_SIF2", true},
{E_DAPC_INFRA_PERI_SLAVE, 166, "EAST_RESERVE_0", true},
{E_DAPC_INFRA_PERI_SLAVE, 167, "EAST_ RESERVE_1", true},
{E_DAPC_INFRA_PERI_SLAVE, 168, "EAST_ RESERVE_2", true},
{E_DAPC_INFRA_PERI_SLAVE, 169, "EAST_ RESERVE_3", true},
/* 170 */
{E_DAPC_INFRA_PERI_SLAVE, 170, "EAST_ RESERVE_4", true},
{E_DAPC_INFRA_PERI_SLAVE, 171, "EAST_IO_CFG_RT", true},
{E_DAPC_INFRA_PERI_SLAVE, 172, "EAST_ RESERVE_6", true},
{E_DAPC_INFRA_PERI_SLAVE, 173, "EAST_ RESERVE_7", true},
{E_DAPC_INFRA_PERI_SLAVE, 174, "EAST_CSI0_TOP_AO", true},
{E_DAPC_INFRA_PERI_SLAVE, 175, "EAST_CSI1_TOP_AO", true},
{E_DAPC_INFRA_PERI_SLAVE, 176, "EAST_ RESERVE_A", true},
{E_DAPC_INFRA_PERI_SLAVE, 177, "EAST_ RESERVE_B", true},
{E_DAPC_INFRA_PERI_SLAVE, 178, "EAST_RESERVE_C", true},
{E_DAPC_INFRA_PERI_SLAVE, 179, "EAST_RESERVE_D", true},
/* 180 */
{E_DAPC_INFRA_PERI_SLAVE, 180, "EAST_RESERVE_E", true},
{E_DAPC_INFRA_PERI_SLAVE, 181, "EAST_RESERVE_F", true},
{E_DAPC_INFRA_PERI_SLAVE, 182, "SOUTH_RESERVE_0", true},
{E_DAPC_INFRA_PERI_SLAVE, 183, "SOUTH_RESERVE_1", true},
{E_DAPC_INFRA_PERI_SLAVE, 184, "SOUTH_IO_CFG_RM", true},
{E_DAPC_INFRA_PERI_SLAVE, 185, "SOUTH_IO_CFG_RB", true},
{E_DAPC_INFRA_PERI_SLAVE, 186, "SOUTH_EFUSE", true},
{E_DAPC_INFRA_PERI_SLAVE, 187, "SOUTH_ RESERVE_5", true},
{E_DAPC_INFRA_PERI_SLAVE, 188, "SOUTH_ RESERVE_6", true},
{E_DAPC_INFRA_PERI_SLAVE, 189, "SOUTH_ RESERVE_7", true},
/* 190 */
{E_DAPC_INFRA_PERI_SLAVE, 190, "SOUTH_ RESERVE_8", true},
{E_DAPC_INFRA_PERI_SLAVE, 191, "SOUTH_ RESERVE_9", true},
{E_DAPC_INFRA_PERI_SLAVE, 192, "SOUTH_ RESERVE_A", true},
{E_DAPC_INFRA_PERI_SLAVE, 193, "SOUTH_ RESERVE_B", true},
{E_DAPC_INFRA_PERI_SLAVE, 194, "SOUTH_RESERVE_C", true},
{E_DAPC_INFRA_PERI_SLAVE, 195, "SOUTH_RESERVE_D", true},
{E_DAPC_INFRA_PERI_SLAVE, 196, "SOUTH_RESERVE_E", true},
{E_DAPC_INFRA_PERI_SLAVE, 197, "SOUTH_RESERVE_F", true},
{E_DAPC_INFRA_PERI_SLAVE, 198, "WEST_ RESERVE_0", true},
{E_DAPC_INFRA_PERI_SLAVE, 199, "WEST_ msdc1_pad_macro", true},
/* 200 */
{E_DAPC_INFRA_PERI_SLAVE, 200, "WEST_ RESERVE_2", true},
{E_DAPC_INFRA_PERI_SLAVE, 201, "WEST_ RESERVE_3", true},
{E_DAPC_INFRA_PERI_SLAVE, 202, "WEST_ RESERVE_4", true},
{E_DAPC_INFRA_PERI_SLAVE, 203, "WEST_ MIPI_TX_CONFIG", true},
{E_DAPC_INFRA_PERI_SLAVE, 204, "WEST_ RESERVE_6", true},
{E_DAPC_INFRA_PERI_SLAVE, 205, "WEST_ IO_CFG_LB", true},
{E_DAPC_INFRA_PERI_SLAVE, 206, "WEST_ IO_CFG_LM", true},
{E_DAPC_INFRA_PERI_SLAVE, 207, "WEST_ IO_CFG_BL", true},
{E_DAPC_INFRA_PERI_SLAVE, 208, "WEST_ RESERVE_A", true},
{E_DAPC_INFRA_PERI_SLAVE, 209, "WEST_ RESERVE_B", true},
/* 210 */
{E_DAPC_INFRA_PERI_SLAVE, 210, "WEST_ RESERVE_C", true},
{E_DAPC_INFRA_PERI_SLAVE, 211, "WEST_ RESERVE_D", true},
{E_DAPC_INFRA_PERI_SLAVE, 212, "WEST_RESERVE_E", true},
{E_DAPC_INFRA_PERI_SLAVE, 213, "WEST_RESERVE_F", true},
{E_DAPC_INFRA_PERI_SLAVE, 214, "NORTH_RESERVE_0", true},
{E_DAPC_INFRA_PERI_SLAVE, 215, "NORTH_RESERVE_1", true},
{E_DAPC_INFRA_PERI_SLAVE, 216, "NORTH_IO_CFG_LT", true},
{E_DAPC_INFRA_PERI_SLAVE, 217, "NORTH_IO_CFG_TL", true},
{E_DAPC_INFRA_PERI_SLAVE, 218, "NORTH_USB20 PHY", true},
{E_DAPC_INFRA_PERI_SLAVE, 219, "NORTH_msdc0 pad macro", true},
/* 220 */
{E_DAPC_INFRA_PERI_SLAVE, 220, "NORTH_ RESERVE_6", true},
{E_DAPC_INFRA_PERI_SLAVE, 221, "NORTH_ RESERVE_7", true},
{E_DAPC_INFRA_PERI_SLAVE, 222, "NORTH_ RESERVE_8", true},
{E_DAPC_INFRA_PERI_SLAVE, 223, "NORTH_ RESERVE_9", true},
{E_DAPC_INFRA_PERI_SLAVE, 224, "NORTH_ UFS_MPHY", true},
{E_DAPC_INFRA_PERI_SLAVE, 225, "NORTH_ RESERVE_B", true},
{E_DAPC_INFRA_PERI_SLAVE, 226, "NORTH_RESERVE_C", true},
{E_DAPC_INFRA_PERI_SLAVE, 227, "NORTH_RESERVE_D", true},
{E_DAPC_INFRA_PERI_SLAVE, 228, "NORTH_RESERVE_E", true},
{E_DAPC_INFRA_PERI_SLAVE, 229, "NORTH_RESERVE_F", true},
/* 230 */
{E_DAPC_INFRA_PERI_SLAVE, 230, "PERISYS_CONN", true},
{E_DAPC_INFRA_PERI_SLAVE, 231, "PERISYS_MD_VIOLATION", true},
{E_DAPC_MM_SLAVE, 0, "Gpu", true},
{E_DAPC_MM_SLAVE, 1, "Gpu", true},
{E_DAPC_MM_SLAVE, 2, "Gpu", true},
{E_DAPC_MM_SLAVE, 3, "Gpu", true},
{E_DAPC_MM_SLAVE, 4, "Gpu", true},
{E_DAPC_MM_SLAVE, 5, "Gpu", true},
{E_DAPC_MM_SLAVE, 6, "Gpu", true},
{E_DAPC_MM_SLAVE, 7, "Gpu", true},
/* 240 */
{E_DAPC_MM_SLAVE, 8, "Gpu", true},
{E_DAPC_MM_SLAVE, 9, "DFD", true},
{E_DAPC_MM_SLAVE, 10, "G3D_CONFIG", true},
{E_DAPC_MM_SLAVE, 11, "G3D_DVFS", true},
{E_DAPC_MM_SLAVE, 12, "MFG_OTHERS", true},
{E_DAPC_MM_SLAVE, 13, "MMSYS_CONFIG", true},
{E_DAPC_MM_SLAVE, 14, "MDP_RDMA0", true},
{E_DAPC_MM_SLAVE, 15, "MDP_RDMA1", true},
{E_DAPC_MM_SLAVE, 16, "MDP_RSZ0", true},
{E_DAPC_MM_SLAVE, 17, "MDP_RSZ1", true},
/* 250 */
{E_DAPC_MM_SLAVE, 18, "MDP_WROT0", true},
{E_DAPC_MM_SLAVE, 19, "MDP_WDMA", true},
{E_DAPC_MM_SLAVE, 20, "MDP_TDSHP", true},
{E_DAPC_MM_SLAVE, 21, "DISP_OVL0", true},
{E_DAPC_MM_SLAVE, 22, "DISP_OVL0_2L", true},
{E_DAPC_MM_SLAVE, 23, "DISP_OVL1_2L", true},
{E_DAPC_MM_SLAVE, 24, "DISP_RDMA0", true},
{E_DAPC_MM_SLAVE, 25, "DISP_RDMA1", true},
{E_DAPC_MM_SLAVE, 26, "DISP_WDMA0", true},
{E_DAPC_MM_SLAVE, 27, "DISP_COLOR0", true},
/* 260 */
{E_DAPC_MM_SLAVE, 28, "DISP_CCORR0", true},
{E_DAPC_MM_SLAVE, 29, "DISP_AAL0", true},
{E_DAPC_MM_SLAVE, 30, "DISP_GAMMA0", true},
{E_DAPC_MM_SLAVE, 31, "DISP_DITHER0", true},
{E_DAPC_MM_SLAVE, 32, "DSI_SPLIT", true},
{E_DAPC_MM_SLAVE, 33, "DSI0", true},
{E_DAPC_MM_SLAVE, 34, "DPI", true},
{E_DAPC_MM_SLAVE, 35, "MM_MUTEX", true},
{E_DAPC_MM_SLAVE, 36, "SMI_LARB0", true},
{E_DAPC_MM_SLAVE, 37, "SMI_LARB1", true},
/* 270 */
{E_DAPC_MM_SLAVE, 38, "SMI_COMMON", true},
{E_DAPC_MM_SLAVE, 39, "DISP_RSZ", true},
{E_DAPC_MM_SLAVE, 40, "MDP_AAL", true},
{E_DAPC_MM_SLAVE, 41, "MDP_CCORR", true},
{E_DAPC_MM_SLAVE, 42, "DBI", true},
{E_DAPC_MM_SLAVE, 43, "MMSYS_RESERVE", true},
{E_DAPC_MM_SLAVE, 44, "MMSYS_RESERVE", true},
{E_DAPC_MM_SLAVE, 45, "MDP_WROT1", true},
{E_DAPC_MM_SLAVE, 46, "DISP_POSTMASK0", true},
{E_DAPC_MM_SLAVE, 47, "MMSYS_OTHERS", true},
/* 280 */
{E_DAPC_MM_SLAVE, 48, "imgsys1_top", true},
{E_DAPC_MM_SLAVE, 49, "dip_a0", true},
{E_DAPC_MM_SLAVE, 50, "dip_a1", true},
{E_DAPC_MM_SLAVE, 51, "dip_a2", true},
{E_DAPC_MM_SLAVE, 52, "dip_a3", true},
{E_DAPC_MM_SLAVE, 53, "dip_a4", true},
{E_DAPC_MM_SLAVE, 54, "dip_a5", true},
{E_DAPC_MM_SLAVE, 55, "dip_a6", true},
{E_DAPC_MM_SLAVE, 56, "dip_a7", true},
{E_DAPC_MM_SLAVE, 57, "dip_a8", true},
/* 290 */
{E_DAPC_MM_SLAVE, 58, "dip_a9", true},
{E_DAPC_MM_SLAVE, 59, "dip_a10", true},
{E_DAPC_MM_SLAVE, 60, "dip_a11", true},
{E_DAPC_MM_SLAVE, 61, "IMGSYS_RESERVE", true},
{E_DAPC_MM_SLAVE, 62, "smi_larb5", true},
{E_DAPC_MM_SLAVE, 63, "smi_larb6", true},
{E_DAPC_MM_SLAVE, 64, "IMGSYS_OTHERS", true},
{E_DAPC_MM_SLAVE, 65, "VENCSYS_GLOBAL_CON", true},
{E_DAPC_MM_SLAVE, 66, "VENCSYSSYS_SMI_LARB3", true},
{E_DAPC_MM_SLAVE, 67, "VENCSYS_VENC", true},
/* 300 */
{E_DAPC_MM_SLAVE, 68, "VENCSYS_JPGENC", true},
{E_DAPC_MM_SLAVE, 69, "VENC_RESERVE", true},
{E_DAPC_MM_SLAVE, 70, "VENC_RESERVE", true},
{E_DAPC_MM_SLAVE, 71, "VENC_RESERVE", true},
{E_DAPC_MM_SLAVE, 72, "VENCSYS_MBIST_CTRL", true},
{E_DAPC_MM_SLAVE, 73, "VENCSYS_OTHERS", true},
{E_DAPC_MM_SLAVE, 74, "VDECSYS_GLOBAL_CON", true},
{E_DAPC_MM_SLAVE, 75, "vdec_smi_larbx", true},
{E_DAPC_MM_SLAVE, 76, "VDECSYS_FULL_TOP", true},
{E_DAPC_MM_SLAVE, 77, "vdec_full_top_lat", true},
/* 310 */
{E_DAPC_MM_SLAVE, 78, "VDEC_RESERVE", true},
{E_DAPC_MM_SLAVE, 79, "VDEC_RESERVE", true},
{E_DAPC_MM_SLAVE, 80, "VDECSYS_OTHERS", true},
{E_DAPC_MM_SLAVE, 81, "CAMSYS_CAMSYS_TOP", true},
{E_DAPC_MM_SLAVE, 82, "CAMSYS_LARB9", true},
{E_DAPC_MM_SLAVE, 83, "CAMSYS_LARB10", true},
{E_DAPC_MM_SLAVE, 84, "CAMSYS_LARB11", true},
{E_DAPC_MM_SLAVE, 85, "CAMSYS_seninf_a", true},
{E_DAPC_MM_SLAVE, 86, "CAMSYS_seninf_b", true},
{E_DAPC_MM_SLAVE, 87, "CAMSYS_seninf_c", true},
/* 320 */
{E_DAPC_MM_SLAVE, 88, "CAMSYS_seninf_d", true},
{E_DAPC_MM_SLAVE, 89, "CAMSYS_seninf_e", true},
{E_DAPC_MM_SLAVE, 90, "CAMSYS_seninf_f", true},
{E_DAPC_MM_SLAVE, 91, "CAMSYS_seninf_g", true},
{E_DAPC_MM_SLAVE, 92, "CAMSYS_seninf_h", true},
{E_DAPC_MM_SLAVE, 93, "CAMSYS_smi_sub_common", true},
{E_DAPC_MM_SLAVE, 94, "CAMSYS_RESERVED", true},
{E_DAPC_MM_SLAVE, 95, "CAMSYS_RESERVED", true},
{E_DAPC_MM_SLAVE, 96, "CAMSYS_RESERVED", true},
{E_DAPC_MM_SLAVE, 97, "cam_raw_a_ip_group_0", true},
/* 330 */
{E_DAPC_MM_SLAVE, 98, "cam_raw_a_ip_group_1", true},
{E_DAPC_MM_SLAVE, 99, "cam_raw_a_ip_group_2", true},
{E_DAPC_MM_SLAVE, 100, "cam_raw_a_ip_group_3", true},
{E_DAPC_MM_SLAVE, 101, "cam_raw_a_dma_0", true},
{E_DAPC_MM_SLAVE, 102, "cam_raw_a_dma_1", true},
{E_DAPC_MM_SLAVE, 103, "ltm_curve_a_0", true},
{E_DAPC_MM_SLAVE, 104, "ltm_curve_a_1", true},
{E_DAPC_MM_SLAVE, 105, "cam_raw_a_ip_group_0_inner", true},
{E_DAPC_MM_SLAVE, 106, "cam_raw_a_ip_group_1_inner", true},
{E_DAPC_MM_SLAVE, 107, "cam_raw_a_ip_group_2_inner", true},
/* 340 */
{E_DAPC_MM_SLAVE, 108, "cam_raw_a_ip_group_3_inner", true},
{E_DAPC_MM_SLAVE, 109, "cam_raw_a_dma_0_inner", true},
{E_DAPC_MM_SLAVE, 110, "cam_raw_a_dma_1_inner", true},
{E_DAPC_MM_SLAVE, 111, "ltm_curve_a_0_inner", true},
{E_DAPC_MM_SLAVE, 112, "ltm_curve_a_1_inner", true},
{E_DAPC_MM_SLAVE, 113, "cam_raw_b_ip_group_0", true},
{E_DAPC_MM_SLAVE, 114, "cam_raw_b_ip_group_1", true},
{E_DAPC_MM_SLAVE, 115, "cam_raw_b_ip_group_2", true},
{E_DAPC_MM_SLAVE, 116, "cam_raw_b_ip_group_3", true},
{E_DAPC_MM_SLAVE, 117, "cam_raw_b_dma_0", true},
/* 350 */
{E_DAPC_MM_SLAVE, 118, "cam_raw_b_dma_1", true},
{E_DAPC_MM_SLAVE, 119, "ltm_curve_b_0", true},
{E_DAPC_MM_SLAVE, 120, "ltm_curve_b_1", true},
{E_DAPC_MM_SLAVE, 121, "cam_raw_b_ip_group_0_inner", true},
{E_DAPC_MM_SLAVE, 122, "cam_raw_b_ip_group_1_inner", true},
{E_DAPC_MM_SLAVE, 123, "cam_raw_b_ip_group_2_inner", true},
{E_DAPC_MM_SLAVE, 124, "cam_raw_b_ip_group_3_inner", true},
{E_DAPC_MM_SLAVE, 125, "cam_raw_b_dma_0_inner", true},
{E_DAPC_MM_SLAVE, 126, "cam_raw_b_dma_1_inner", true},
{E_DAPC_MM_SLAVE, 127, "ltm_curve_b_0_inner", true},
/* 360 */
{E_DAPC_MM_SLAVE, 128, "ltm_curve_b_1_inner", true},
{E_DAPC_MM_SLAVE, 129, "cam_raw_c_ip_group_0", true},
{E_DAPC_MM_SLAVE, 130, "cam_raw_c_ip_group_1", true},
{E_DAPC_MM_SLAVE, 131, "cam_raw_c_ip_group_2", true},
{E_DAPC_MM_SLAVE, 132, "cam_raw_c_ip_group_3", true},
{E_DAPC_MM_SLAVE, 133, "cam_raw_c_dma_0", true},
{E_DAPC_MM_SLAVE, 134, "cam_raw_c_dma_1", true},
{E_DAPC_MM_SLAVE, 135, "ltm_curve_c_0", true},
{E_DAPC_MM_SLAVE, 136, "ltm_curve_c_1", true},
{E_DAPC_MM_SLAVE, 137, "cam_raw_c_ip_group_0_inner", true},
/* 370 */
{E_DAPC_MM_SLAVE, 138, "cam_raw_c_ip_group_1_inner", true},
{E_DAPC_MM_SLAVE, 139, "cam_raw_c_ip_group_2_inner", true},
{E_DAPC_MM_SLAVE, 140, "cam_raw_c_ip_group_3_inner", true},
{E_DAPC_MM_SLAVE, 141, "cam_raw_c_dma_0_inner", true},
{E_DAPC_MM_SLAVE, 142, "cam_raw_c_dma_1_inner", true},
{E_DAPC_MM_SLAVE, 143, "ltm_curve_c_0_inner", true},
{E_DAPC_MM_SLAVE, 144, "ltm_curve_c_1_inner", true},
{E_DAPC_MM_SLAVE, 145, "cam_raw_a_AA_histogram_0", true},
{E_DAPC_MM_SLAVE, 146, "cam_raw_a_AA_histogram_1", true},
{E_DAPC_MM_SLAVE, 147, "cam_raw_a_AA_histogram_2", true},
/* 380 */
{E_DAPC_MM_SLAVE, 148, "cam_raw_a_MAE_histogram", true},
{E_DAPC_MM_SLAVE, 149, "cam_raw_b_AA_histogram_0", true},
{E_DAPC_MM_SLAVE, 150, "cam_raw_b_AA_histogram_1", true},
{E_DAPC_MM_SLAVE, 151, "cam_raw_b_AA_histogram_2", true},
{E_DAPC_MM_SLAVE, 152, "cam_raw_b_MAE_histogram", true},
{E_DAPC_MM_SLAVE, 153, "cam_raw_c_AA_histogram_0", true},
{E_DAPC_MM_SLAVE, 154, "cam_raw_c_AA_histogram_1", true},
{E_DAPC_MM_SLAVE, 155, "cam_raw_c_AA_histogram_2", true},
{E_DAPC_MM_SLAVE, 156, "cam_raw_c_MAE_histogram", true},
{E_DAPC_MM_SLAVE, 157, "CAMSYS_RESERVED", true},
/* 390 */
{E_DAPC_MM_SLAVE, 158, "CAMSYS_RESERVED", true},
{E_DAPC_MM_SLAVE, 159, "CAMSYS_RESERVED", true},
{E_DAPC_MM_SLAVE, 160, "CAMSYS_RESERVED", true},
{E_DAPC_MM_SLAVE, 161, "CAMSYS_adl", true},
{E_DAPC_MM_SLAVE, 162, "camsv_0", true},
{E_DAPC_MM_SLAVE, 163, "camsv_1", true},
{E_DAPC_MM_SLAVE, 164, "camsv_2", true},
{E_DAPC_MM_SLAVE, 165, "camsv_3", true},
{E_DAPC_MM_SLAVE, 166, "camsv_4", true},
{E_DAPC_MM_SLAVE, 167, "camsv_5", true},
/* 400 */
{E_DAPC_MM_SLAVE, 168, "camsv_6", true},
{E_DAPC_MM_SLAVE, 169, "camsv_7", true},
{E_DAPC_MM_SLAVE, 170, "CAMSYS_asg", true},
{E_DAPC_MM_SLAVE, 171, "cam_raw_a_set", true},
{E_DAPC_MM_SLAVE, 172, "cam_raw_a_clr", true},
{E_DAPC_MM_SLAVE, 173, "cam_raw_b_set", true},
{E_DAPC_MM_SLAVE, 174, "cam_raw_b_clr", true},
{E_DAPC_MM_SLAVE, 175, "cam_raw_c_set", true},
{E_DAPC_MM_SLAVE, 176, "cam_raw_c_clr", true},
{E_DAPC_MM_SLAVE, 177, "CAMSYS_RESERVED", true},
/* 410 */
{E_DAPC_MM_SLAVE, 178, "CAMSYS_RESERVED", true},
{E_DAPC_MM_SLAVE, 179, "CAMSYS_RESERVED", true},
{E_DAPC_MM_SLAVE, 180, "CAMSYS_RESERVED", true},
{E_DAPC_MM_SLAVE, 181, "CAMSYS_RESERVED", true},
{E_DAPC_MM_SLAVE, 182, "CAMSYS_RESERVED", true},
{E_DAPC_MM_SLAVE, 183, "CAMSYS_tsf", true},
{E_DAPC_MM_SLAVE, 184, "ccu_ctl", true},
{E_DAPC_MM_SLAVE, 185, "ccu_h2t_a", true},
{E_DAPC_MM_SLAVE, 186, "ccu_t2h_a", true},
{E_DAPC_MM_SLAVE, 187, "ccu_dma", true},
/* 420 */
{E_DAPC_MM_SLAVE, 188, "CAMSYS_RESERVED", true},
{E_DAPC_MM_SLAVE, 189, "DCCM", true},
{E_DAPC_MM_SLAVE, 190, "CAMSYS_RESEVE", true},
{E_DAPC_MM_SLAVE, 191, "CAMSYS_OTHERS", true},
{E_DAPC_MM_SLAVE, 192, "APUSYS_apu_conn_config", true},
{E_DAPC_MM_SLAVE, 193, "APUSYS_ADL_CTRL", true},
{E_DAPC_MM_SLAVE, 194, "APUSYS_vcore_config", true},
{E_DAPC_MM_SLAVE, 195, "APUSYS_apu_edma", true},
{E_DAPC_MM_SLAVE, 196, "APUSYS_apu1_edmb", true},
{E_DAPC_MM_SLAVE, 197, "APUSYS_apu2_edmc", true},
/* 430 */
{E_DAPC_MM_SLAVE, 198, "APUSYS_COREA_DMEM_0", true},
{E_DAPC_MM_SLAVE, 199, "APUSYS_COREA_DMEM_1", true},
{E_DAPC_MM_SLAVE, 200, "APUSYS_COREA_IMEM", true},
{E_DAPC_MM_SLAVE, 201, "APUSYS_COREA_CONTROL", true},
{E_DAPC_MM_SLAVE, 202, "APUSYS_COREA_DEBUG", true},
{E_DAPC_MM_SLAVE, 203, "APUSYS_COREB_DMEM_0", true},
{E_DAPC_MM_SLAVE, 204, "APUSYS_COREB_DMEM_1", true},
{E_DAPC_MM_SLAVE, 205, "APUSYS_COREB_IMEM", true},
{E_DAPC_MM_SLAVE, 206, "APUSYS_COREB_CONTROL", true},
{E_DAPC_MM_SLAVE, 207, "APUSYS_COREB_DEBUG", true},
/* 440 */
{E_DAPC_MM_SLAVE, 208, "APUSYS_ RESERVED", true},
{E_DAPC_MM_SLAVE, 209, "APUSYS_ RESERVED", true},
{E_DAPC_MM_SLAVE, 210, "APUSYS_ RESERVED", true},
{E_DAPC_MM_SLAVE, 211, "APUSYS_COREC_CONTROL", true},
{E_DAPC_MM_SLAVE, 212, "APUSYS_COREC_MDLA", true},
{E_DAPC_MM_SLAVE, 213, "APUSYS_OTHERS", true},
{E_DAPC_MM_SLAVE, 214, "IPESYS_ipesys_top", true},
{E_DAPC_MM_SLAVE, 215, "IPESYS_fdvt", true},
{E_DAPC_MM_SLAVE, 216, "IPESYS_fe", true},
{E_DAPC_MM_SLAVE, 217, "IPESYS_rsc", true},
/* 450 */
{E_DAPC_MM_SLAVE, 218, "IPESYS_ RESERVED", true},
{E_DAPC_MM_SLAVE, 219, "IPESYS_ RESERVED", true},
{E_DAPC_MM_SLAVE, 220, "IPESYS_ RESERVED", true},
{E_DAPC_MM_SLAVE, 221, "IPESYS_ RESERVED", true},
{E_DAPC_MM_SLAVE, 222, "IPESYS_ RESERVED", true},
{E_DAPC_MM_SLAVE, 223, "IPESYS_ RESERVED", true},
{E_DAPC_MM_SLAVE, 224, "IPESYS_ RESERVED", true},
{E_DAPC_MM_SLAVE, 225, "IPESYS_ RESERVED", true},
{E_DAPC_MM_SLAVE, 226, "IPESYS_ RESERVED", true},
{E_DAPC_MM_SLAVE, 227, "IPESYS_ RESERVED", true},
/* 460 */
{E_DAPC_MM_SLAVE, 228, "IPESYS_smi_2x1_sub_common", true},
{E_DAPC_MM_SLAVE, 229, "IPESYS_smi_larb8", true},
{E_DAPC_MM_SLAVE, 230, "IPESYS_depth", true},
{E_DAPC_MM_SLAVE, 231, "IPESYS_ RESERVED", true},
{E_DAPC_MM_SLAVE, 232, "IPESYS_ RESERVED", true},
{E_DAPC_MM_SLAVE, 233, "IPESYS_ RESERVED", true},
{E_DAPC_MM_SLAVE, 234, "IPESYS_ RESERVED", true},
{E_DAPC_MM_SLAVE, 235, "IPESYS_ RESERVED", true},
{E_DAPC_MM_SLAVE, 236, "IPESYS_ RESERVED", true},
{E_DAPC_MM_SLAVE, 237, "IPESYS_ RESERVED", true},
/* 470 */
{E_DAPC_MM_SLAVE, 238, "IPESYS_ RESERVED", true},
{E_DAPC_MM_SLAVE, 239, "IPESYS_ RESERVED", true},
{E_DAPC_MM_SLAVE, 240, "IPESYS_ RESERVED", true},
{E_DAPC_MM_SLAVE, 241, "IPESYS_ RESERVED", true},
{E_DAPC_MM_SLAVE, 242, "IPESYS_ RESERVED", true},
{E_DAPC_MM_SLAVE, 243, "IPESYS_ RESERVED", true},
{E_DAPC_MM_SLAVE, 244, "IPESYS_ RESERVED", true},
{E_DAPC_MM_SLAVE, 245, "IPESYS_smi_larb7", true},
{E_DAPC_MM_SLAVE, 246, "IPESYS_OTHERS", true},
{E_DAPC_OTHERS_SLAVE, -1, "SSPM_UNALIGN", true},
/* 480 */
{E_DAPC_OTHERS_SLAVE, -1, "SSPM_OUT_OF_BOUND", true},
{E_DAPC_OTHERS_SLAVE, -1, "SSPM_ERR_WAY_EN", true},
{E_DAPC_OTHERS_SLAVE, -1, "EAST_PERIAPB_UNALIGN", true},
{E_DAPC_OTHERS_SLAVE, -1, "EAST_PERIAPB _OUT_OF_BOUND", true},
{E_DAPC_OTHERS_SLAVE, -1, "EAST_PERIAPB _ERR_WAY_EN", true},
{E_DAPC_OTHERS_SLAVE, -1, "SOUTH_PERIAPB_UNALIGN", true},
{E_DAPC_OTHERS_SLAVE, -1, "SOUTH_PERIAPB _OUT_OF_BOUND", true},
{E_DAPC_OTHERS_SLAVE, -1, "SOUTH_PERIAPB _ERR_WAY_EN", true},
{E_DAPC_OTHERS_SLAVE, -1, "WEST_PERIAPB_UNALIGN", true},
{E_DAPC_OTHERS_SLAVE, -1, "WEST _PERIAPB _OUT_OF_BOUND", true},
/* 490 */
{E_DAPC_OTHERS_SLAVE, -1, "WEST _PERIAPB _ERR_WAY_EN", true},
{E_DAPC_OTHERS_SLAVE, -1, "NORTH_PERIAPB_UNALIGN", true},
{E_DAPC_OTHERS_SLAVE, -1, "NORTH _PERIAPB _OUT_OF_BOUND", true},
{E_DAPC_OTHERS_SLAVE, -1, "NORTH _PERIAPB _ERR_WAY_EN", true},
{E_DAPC_OTHERS_SLAVE, -1, "INFRA_PDN_DECODE_ERROR", true},
{E_DAPC_OTHERS_SLAVE, -1, "PERIAPB_UNALIGN", true},
{E_DAPC_OTHERS_SLAVE, -1, "PERIAPB_OUT_OF_BOUND", true},
{E_DAPC_OTHERS_SLAVE, -1, "PERIAPB_ERR_WAY_EN", true},
{E_DAPC_OTHERS_SLAVE, -1, "EAST_NORTH_PERIAPB_UNALIGN", true},
{E_DAPC_OTHERS_SLAVE, -1, "EAST_NORTH _PERIAPB _OUT_OF_BOUND", true},
/* 500 */
{E_DAPC_OTHERS_SLAVE, -1, "EAST_NORTH _PERIAPB _ERR_WAY_EN", true},
{E_DAPC_OTHERS_SLAVE, -1, "TOPAXI_SI2_DECERR", true},
{E_DAPC_OTHERS_SLAVE, -1, "TOPAXI_SI1_DECERR", true},
{E_DAPC_OTHERS_SLAVE, -1, "TOPAXI_SI0_DECERR", true},
{E_DAPC_OTHERS_SLAVE, -1, "PERIAXI_SI0_DECERR", true},
{E_DAPC_OTHERS_SLAVE, -1, "PERIAXI_SI1_DECERR", true},
{E_DAPC_OTHERS_SLAVE, -1, "TOPAXI_SI3_DECERR", true},
{E_DAPC_OTHERS_SLAVE, -1, "TOPAXI_SI4_DECERR", true},
{E_DAPC_OTHERS_SLAVE, -1, "SRAMROM_DECERR", true},
{E_DAPC_OTHERS_SLAVE, -1, "HIFI3_DECERR", true},
/* 510 */
{E_DAPC_OTHERS_SLAVE, -1, "MD_DECERR", true},
{E_DAPC_OTHERS_SLAVE, -1, "SRAMROM*", true},
{E_DAPC_OTHERS_SLAVE, -1, "AP_DMA*", false},
{E_DAPC_OTHERS_SLAVE, -1, "DEVICE_APC_AO_INFRA_PERI*", false},
{E_DAPC_OTHERS_SLAVE, -1, "DEVICE_APC_AO_MD*", false},
{E_DAPC_OTHERS_SLAVE, -1, "DEVICE_APC_AO_MM*", false},
{E_DAPC_OTHERS_SLAVE, -1, "CM_DQ_SECURE*", false},
{E_DAPC_OTHERS_SLAVE, -1, "MM_IOMMU_DOMAIN*", false},
{E_DAPC_OTHERS_SLAVE, -1, "DISP_GCE*", false},
{E_DAPC_OTHERS_SLAVE, -1, "DEVICE_APC*", false},
/* 520 */
{E_DAPC_OTHERS_SLAVE, -1, "EMI*", false},
{E_DAPC_OTHERS_SLAVE, -1, "EMI_MPU*", false},
{E_DAPC_OTHERS_SLAVE, -1, "PMIC_WRAP*", false},
{E_DAPC_OTHERS_SLAVE, -1, "I2C1*", false},
{E_DAPC_OTHERS_SLAVE, -1, "I2C2*", false},
{E_DAPC_OTHERS_SLAVE, -1, "I2C4*", false},
};
static struct PERIAXI_ID_INFO paxi_int_mi_id_to_master[] = {
{"APDMA", { 0, 1, 2, 0, 0 } },
{"MD", { 1, 0, 2, 2, 0 } },
{"SPM", { 0, 0, 1, 0, 0 } },
{"CCU", { 0, 0, 0, 0, 0 } },
{"SPM", { 0, 0, 0, 1, 0 } },
{"N/A", { 0, 0, 0, 0, 1 } },
{"THERM", { 0, 0, 0, 1, 1 } },
};
static struct TOPAXI_ID_INFO topaxi_mi0_id_to_master[] = {
{"DebugTop", { 1, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0 } },
{"Audio", { 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0 } },
{"IPU", { 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0 } },
{"SPI1", { 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0 } },
{"SPI7", { 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 } },
{"CCU", { 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0 } },
{"SPM ", { 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0 } },
{"N/A", { 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0 } },
{"THERM", { 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0 } },
{"UFS", { 1, 0, 0, 1, 0, 0, 0, 1, 0, 2, 2, 0 } },
{"DMA_EXT", { 1, 0, 0, 1, 0, 0, 1, 1, 0, 2, 0, 0 } },
{"SSUSB", { 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2, 2 } },
{"PWM", { 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0 } },
{"MSDC1", { 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0 } },
{"SPI6", { 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1 } },
{"SPI0", { 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1 } },
{"SPI2", { 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0 } },
{"SPI3", { 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0 } },
{"SPI4", { 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0 } },
{"SPI5", { 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0 } },
{"MSDC0", { 1, 0, 0, 1, 0, 0, 0, 1, 1, 2, 2, 2 } },
{"DX_CC", { 1, 0, 0, 0, 1, 0, 2, 2, 2, 2, 0, 0 } },
{"CQ_DMA", { 1, 0, 0, 1, 1, 0, 2, 2, 2, 0, 0, 0 } },
{"GCE_M", { 1, 0, 0, 0, 0, 1, 2, 2, 0, 0, 0, 0 } },
{"HiFi3", { 1, 1, 0, 0, 2, 2, 2, 2, 2, 0, 0, 0 } },
{"CLDMA(dpmaif)", { 1, 1, 0, 1, 2, 2, 2, 2, 0, 0, 0, 0 } },
{"SSPM", { 1, 0, 1, 1, 2, 2, 0, 0, 0, 0, 0, 0 } },
{"SCP", { 1, 0, 1, 0, 2, 2, 0, 0, 0, 0, 0, 0 } },
{"CONNSYS", { 1, 1, 1, 2, 2, 2, 0, 0, 0, 0, 0, 0 } },
{"APMCU_write", { 0, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0 } },
{"APMCU_write", { 0, 2, 2, 2, 2, 0, 0, 1, 0, 0, 0, 0 } },
{"APMCU_write", { 0, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0 } },
{"APMCU_read", { 0, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0 } },
{"APMCU_read", { 0, 2, 2, 2, 2, 0, 0, 1, 0, 0, 0, 0 } },
{"APMCU_read", { 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 } },
{"APMCU_read", { 0, 2, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0 } },
{"APMCU_read", { 0, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0 } },
{"APMCU_read", { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0 } },
};
static const char *topaxi_mi0_trans(int bus_id)
{
int master_count = ARRAY_SIZE(topaxi_mi0_id_to_master);
const char *master = "UNKNOWN_MASTER_FROM_TOPAXI";
int i, j;
for (i = 0 ; i < master_count; i++) {
for (j = 0 ; j < TOPAXI_MI0_BIT_LENGTH ; j++) {
if (topaxi_mi0_id_to_master[i].bit[j] == 2)
continue;
if (((bus_id >> j) & 0x1) ==
topaxi_mi0_id_to_master[i].bit[j]) {
continue;
} else {
break;
}
}
if (j == TOPAXI_MI0_BIT_LENGTH) {
pr_debug(PFX "%s %s %s %s\n",
"[DEVAPC]",
"catch it from TOPAXI_MI0.",
"Master is:",
topaxi_mi0_id_to_master[i].master);
master = topaxi_mi0_id_to_master[i].master;
}
}
return master;
}
static const char *paxi_int_mi_trans(int bus_id)
{
int master_count = ARRAY_SIZE(paxi_int_mi_id_to_master);
const char *master = "UNKNOWN_MASTER_FROM_PAXI";
int i, j;
if ((bus_id & 0x3) == 0x3) {
master = topaxi_mi0_trans(bus_id >> 2);
return master;
}
for (i = 0 ; i < master_count; i++) {
for (j = 0 ; j < PERIAXI_INT_MI_BIT_LENGTH ; j++) {
if (paxi_int_mi_id_to_master[i].bit[j] == 2)
continue;
if (((bus_id >> j) & 0x1) ==
paxi_int_mi_id_to_master[i].bit[j]) {
continue;
} else {
break;
}
}
if (j == PERIAXI_INT_MI_BIT_LENGTH) {
pr_debug(PFX "%s %s %s %s\n",
"[DEVAPC]",
"catch it from PERIAXI_INT_MI.",
"Master is:",
paxi_int_mi_id_to_master[i].master);
master = paxi_int_mi_id_to_master[i].master;
}
}
return master;
}
/* violation index corresponds to subsys */
static const char *mt6779_index_to_subsys(uint32_t index)
{
if (index >= MFGSYS_START && index <= MFGSYS_END)
return "MFGSYS";
else if (index == SMI_LARB0 || index == SMI_LARB1 ||
index == SMI_COMMON || index == SMI_LARB5 ||
index == SMI_LARB6 || index == VENCSYS_SMI_LARB ||
index == VDECSYS_SMI_LARB || index == CAMSYS_SMI_LARB ||
index == IPESYS_SMI_LARB || index == IPESYS_SMI_LARB8 ||
index == IPESYS_SMI_LARB7)
return "SMI";
else if ((index >= MMSYS_MDP_START && index <= MMSYS_MDP_END) ||
(index >= MMSYS_MDP2_START && index <= MMSYS_MDP2_END))
return "MMSYS_MDP";
else if (index >= MMSYS_DISP_START && index <= MMSYS_DISP_END)
return "MMSYS_DISP";
else if (index >= IMGSYS_START && index <= IMGSYS_END)
return "IMGSYS";
else if (index >= VENCSYS_START && index <= VENCSYS_END)
return "VENCSYS";
else if (index >= VDECSYS_START && index <= VDECSYS_END)
return "VDECSYS";
else if (index >= CAMSYS_START && index <= CAMSYS_END)
return "CAMSYS";
else if (index >= APUSYS_START && index <= APUSYS_END)
return "APUSYS";
else if (index >= IPESYS_START && index <= IPESYS_END)
return "IPESYS";
else if (index < ARRAY_SIZE(mt6779_infra_devices))
return mt6779_infra_devices[index].device;
else
return "OUT_OF_BOUND";
}
static const char *mt6779_bus_id_to_master(int bus_id, uint32_t vio_addr,
int vio_idx)
{
const char *master = "UNKNOWN_MASTER";
uint32_t h_byte;
pr_debug(PFX "[DEVAPC] bus id = 0x%x, vio_addr = 0x%x\n",
bus_id, vio_addr);
/* SPM MTCMOS disable will set way_en[7:4] reg to block transaction,
* and it will triggered TOPAXI_SI0_DECERR instead of slave vio.
*/
if (vio_idx == TOPAXI_SI0_DECERR) {
pr_debug(PFX "[DEVAPC] vio is from TOPAXI_SI0_DECERR\n");
master = topaxi_mi0_trans(bus_id);
return master;
} else if (vio_idx == SRAMROM_VIO_INDEX) {
pr_debug(PFX "vio is from SRAMROM\n");
if ((bus_id & 0x1) == 0x0)
master = topaxi_mi0_trans(bus_id >> 1);
else
pr_debug(PFX "[FAILED] Cannot decode bus_id: 0x%x\n",
bus_id);
return master;
}
h_byte = (vio_addr >> 24) & 0xFF;
/* to Infra/Peri/Audio/MD/CONN
* or MMSYS
* or MFG
*/
if (((h_byte >> 4) == 0x0) && h_byte != 0x0C && h_byte != 0x0D) {
pr_debug(PFX "[DEVAPC] vio addr is from on-chip SRAMROM\n");
master = topaxi_mi0_trans(bus_id);
} else if (h_byte == 0x10 || h_byte == 0x11 || h_byte == 0x18 ||
h_byte == 0x0C || h_byte == 0x0D ||
(h_byte >> 4) == 0x2 || (h_byte >> 4) == 0x3) {
pr_debug(PFX "[DEVAPC] vio addr is from Infra/Peri\n");
/* CONN */
if (h_byte == 0x18) {
if ((bus_id & 0x1) == 1)
return "CQ_DMA"; /*should not be walked */
bus_id = bus_id >> 1;
}
/* HIFI3/SCP/SSPM */
h_byte = (vio_addr >> 20) & 0xFFF;
if (h_byte == 0x106 || h_byte == 0x105 || h_byte == 0x104) {
if ((bus_id & 0x1) == 0)
return "MD";
bus_id = bus_id >> 1;
}
master = paxi_int_mi_trans(bus_id);
} else if (h_byte == 0x14 || h_byte == 0x15 || h_byte == 0x16 ||
h_byte == 0x17 || h_byte == 0x19 || h_byte == 0x1A ||
h_byte == 0x1B) {
pr_debug(PFX "[DEVAPC] vio addr is from MM\n");
if ((bus_id & 0x1) == 1)
return "GCE";
master = topaxi_mi0_trans(bus_id >> 1);
} else if (h_byte == 0x13) {
pr_debug(PFX "[DEVAPC] vio addr is from MFG\n");
master = topaxi_mi0_trans(bus_id);
} else {
master = "UNKNOWN_MASTER";
}
return master;
}
static struct mtk_devapc_dbg_status mt6779_devapc_dbg_stat = {
.enable_ut = PLAT_DBG_UT_DEFAULT,
.enable_KE = PLAT_DBG_KE_DEFAULT,
.enable_WARN = PLAT_DBG_WARN_DEFAULT,
.enable_dapc = PLAT_DBG_DAPC_DEFAULT,
};
static struct mtk_devapc_vio_info mt6779_devapc_vio_info = {
.vio_cfg_max_idx = PLAT_VIO_CFG_MAX_IDX,
.vio_max_idx = PLAT_VIO_MAX_IDX,
.vio_mask_sta_num = PLAT_VIO_MASK_STA_NUM,
.vio_shift_max_bit = PLAT_VIO_SHIFT_MAX_BIT,
.sramrom_vio_idx = SRAMROM_VIO_INDEX,
};
static const struct mtk_infra_vio_dbg_desc mt6779_vio_dbgs = {
.vio_dbg_mstid = INFRA_VIO_DBG_MSTID,
.vio_dbg_mstid_start_bit = INFRA_VIO_DBG_MSTID_START_BIT,
.vio_dbg_dmnid = INFRA_VIO_DBG_DMNID,
.vio_dbg_dmnid_start_bit = INFRA_VIO_DBG_DMNID_START_BIT,
.vio_dbg_w_vio = INFRA_VIO_DBG_W_VIO,
.vio_dbg_w_vio_start_bit = INFRA_VIO_DBG_W_VIO_START_BIT,
.vio_dbg_r_vio = INFRA_VIO_DBG_R_VIO,
.vio_dbg_r_vio_start_bit = INFRA_VIO_DBG_R_VIO_START_BIT,
.vio_addr_high = INFRA_VIO_ADDR_HIGH,
.vio_addr_high_start_bit = INFRA_VIO_ADDR_HIGH_START_BIT,
};
static const struct mtk_sramrom_sec_vio_desc mt6779_sramrom_sec_vios = {
.vio_id_mask = SRAMROM_SEC_VIO_ID_MASK,
.vio_id_shift = SRAMROM_SEC_VIO_ID_SHIFT,
.vio_domain_mask = SRAMROM_SEC_VIO_DOMAIN_MASK,
.vio_domain_shift = SRAMROM_SEC_VIO_DOMAIN_SHIFT,
.vio_rw_mask = SRAMROM_SEC_VIO_RW_MASK,
.vio_rw_shift = SRAMROM_SEC_VIO_RW_SHIFT,
};
static const uint32_t mt6779_devapc_pds[] = {
PD_VIO_MASK_OFFSET,
PD_VIO_STA_OFFSET,
PD_VIO_DBG0_OFFSET,
PD_VIO_DBG1_OFFSET,
PD_APC_CON_OFFSET,
PD_SHIFT_STA_OFFSET,
PD_SHIFT_SEL_OFFSET,
PD_SHIFT_CON_OFFSET,
};
static struct mtk_devapc_soc mt6779_data = {
.dbg_stat = &mt6779_devapc_dbg_stat,
.device_info = mt6779_infra_devices,
.ndevices = ARRAY_SIZE(mt6779_infra_devices),
.vio_info = &mt6779_devapc_vio_info,
.vio_dbgs = &mt6779_vio_dbgs,
.sramrom_sec_vios = &mt6779_sramrom_sec_vios,
.devapc_pds = mt6779_devapc_pds,
.subsys_get = &mt6779_index_to_subsys,
.master_get = &mt6779_bus_id_to_master,
};
static const struct of_device_id mt6779_devapc_dt_match[] = {
{ .compatible = "mediatek,mt6779-devapc" },
{},
};
static int mt6779_devapc_probe(struct platform_device *pdev)
{
return mtk_devapc_probe(pdev, &mt6779_data);
}
static int mt6779_devapc_remove(struct platform_device *dev)
{
return mtk_devapc_remove(dev);
}
static struct platform_driver mt6779_devapc_driver = {
.probe = mt6779_devapc_probe,
.remove = mt6779_devapc_remove,
.driver = {
.name = KBUILD_MODNAME,
.of_match_table = mt6779_devapc_dt_match,
},
};
module_platform_driver(mt6779_devapc_driver);
MODULE_DESCRIPTION("Mediatek MT6779 Device APC Driver");
MODULE_AUTHOR("Neal Liu <neal.liu@mediatek.com>");
MODULE_LICENSE("GPL");
+141
View File
@@ -0,0 +1,141 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2019 MediaTek Inc.
*/
#ifndef __DEVAPC_MT6779_H__
#define __DEVAPC_MT6779_H__
/******************************************************************************
* VARIABLE DEFINATION
******************************************************************************/
/* dbg status default setting */
#define PLAT_DBG_UT_DEFAULT false
#define PLAT_DBG_KE_DEFAULT true
#define PLAT_DBG_WARN_DEFAULT false
#define PLAT_DBG_DAPC_DEFAULT false
#define PLAT_VIO_CFG_MAX_IDX 478
#define PLAT_VIO_MAX_IDX 525
#define PLAT_VIO_MASK_STA_NUM 17
#define PLAT_VIO_SHIFT_MAX_BIT 25
/******************************************************************************
* DATA STRUCTURE
******************************************************************************/
/* violation index corresponds to subsys */
enum MFGSYS_INDEX {
MFGSYS_START = 232,
MFGSYS_END = 244,
};
enum SMI_INDEX {
SMI_LARB0 = 268,
SMI_LARB1 = 269,
SMI_COMMON = 270,
SMI_LARB5 = 294,
SMI_LARB6 = 295,
VENCSYS_SMI_LARB = 298,
VDECSYS_SMI_LARB = 307,
CAMSYS_SMI_LARB = 325,
IPESYS_SMI_LARB = 460,
IPESYS_SMI_LARB8 = 461,
IPESYS_SMI_LARB7 = 477,
};
enum MMSYS_INDEX {
MMSYS_MDP_START = 245,
MMSYS_MDP_END = 252,
MMSYS_DISP_START = 253,
MMSYS_DISP_END = 271,
MMSYS_MDP2_START = 272,
MMSYS_MDP2_END = 279,
};
enum IMGSYS_INDEX {
IMGSYS_START = 280,
IMGSYS_END = 296,
};
enum VENCSYS_INDEX {
VENCSYS_START = 297,
VENCSYS_END = 305,
};
enum VDECSYS_INDEX {
VDECSYS_START = 306,
VDECSYS_END = 312,
};
enum CAMSYS_INDEX {
CAMSYS_START = 313,
CAMSYS_END = 423,
};
enum APUSYS_INDEX {
APUSYS_START = 424,
APUSYS_END = 445,
};
enum IPESYS_INDEX {
IPESYS_START = 446,
IPESYS_END = 478,
};
enum OTHER_TYPES_INDEX {
SRAMROM_VIO_INDEX = 511,
TOPAXI_SI0_DECERR = 503,
};
enum BUSID_LENGTH {
PERIAXI_INT_MI_BIT_LENGTH = 5,
TOPAXI_MI0_BIT_LENGTH = 12,
};
/* bit == 2 means don't care */
struct PERIAXI_ID_INFO {
const char *master;
uint8_t bit[PERIAXI_INT_MI_BIT_LENGTH];
};
struct TOPAXI_ID_INFO {
const char *master;
uint8_t bit[TOPAXI_MI0_BIT_LENGTH];
};
/******************************************************************************
* PLATFORM DEFINATION
******************************************************************************/
/* For Infra VIO_DBG */
#define INFRA_VIO_DBG_MSTID 0x0000FFFF
#define INFRA_VIO_DBG_MSTID_START_BIT 0
#define INFRA_VIO_DBG_DMNID 0x003F0000
#define INFRA_VIO_DBG_DMNID_START_BIT 16
#define INFRA_VIO_DBG_W_VIO 0x00400000
#define INFRA_VIO_DBG_W_VIO_START_BIT 22
#define INFRA_VIO_DBG_R_VIO 0x00800000
#define INFRA_VIO_DBG_R_VIO_START_BIT 23
#define INFRA_VIO_ADDR_HIGH 0x0F000000
#define INFRA_VIO_ADDR_HIGH_START_BIT 24
/* For SRAMROM VIO */
#define SRAMROM_SEC_VIO_ID_MASK 0x00FFFF00
#define SRAMROM_SEC_VIO_ID_SHIFT 8
#define SRAMROM_SEC_VIO_DOMAIN_MASK 0x0F000000
#define SRAMROM_SEC_VIO_DOMAIN_SHIFT 24
#define SRAMROM_SEC_VIO_RW_MASK 0x80000000
#define SRAMROM_SEC_VIO_RW_SHIFT 31
/* For DEVAPC PD */
#define PD_VIO_MASK_OFFSET 0x0
#define PD_VIO_STA_OFFSET 0x400
#define PD_VIO_DBG0_OFFSET 0x900
#define PD_VIO_DBG1_OFFSET 0x904
#define PD_APC_CON_OFFSET 0xF00
#define PD_SHIFT_STA_OFFSET 0xF10
#define PD_SHIFT_SEL_OFFSET 0xF14
#define PD_SHIFT_CON_OFFSET 0xF20
#endif /* __DEVAPC_MT6779_H__ */
File diff suppressed because it is too large. Load diff
+145
View File
@@ -0,0 +1,145 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2021 MediaTek Inc.
*/
#ifndef __DEVAPC_MT6781_H__
#define __DEVAPC_MT6781_H__
/******************************************************************************
* VARIABLE DEFINATION
******************************************************************************/
/* dbg status default setting */
#define PLAT_DBG_UT_DEFAULT false
#define PLAT_DBG_KE_DEFAULT true
#define PLAT_DBG_AEE_DEFAULT true
#define PLAT_DBG_DAPC_DEFAULT false
#define PLAT_VIO_CFG_MAX_IDX 518
#define PLAT_VIO_MAX_IDX 558
#define PLAT_VIO_MASK_STA_NUM 18
#define PLAT_VIO_SHIFT_MAX_BIT 21
/******************************************************************************
* DATA STRUCTURE & FUNCTION DEFINATION
******************************************************************************/
const char *bus_id_to_master(int bus_id, uint32_t vio_addr, int vio_idx);
const char *index_to_subsys(unsigned int index);
/* violation index corresponds to subsys */
enum SMI_INDEX {
SMI_COMMON = 161,
SMI_LARB0 = 162,
SMI_LARB1 = 163,
DISP_SMI_2X1_SUB_COMMON_U0 = 186,
DISP_SMI_2X1_SUB_COMMON_U1 = 187,
IMG1_SMI_2X1_SUB_COMMON = 189,
SMI_LARB9 = 222,
SMI_LARB11 = 255,
SMI_LARB12 = 256,
SMI_LARB7 = 277,
SMI_LARB13 = 285,
SMI_LARB14 = 286,
CAM_SIM_3X1_SUB_COMMON_U0 = 296,
CAM_SIM_4X1_SUB_COMMON_U0 = 297,
SMI_LARB_16 = 299,
SMI_LARB_17 = 300,
SMI_LARB0_S = 472,
IPE_SMI_2X1_SUB_COMMON = 500,
SMI_LARB20 = 501,
SMI_LARB19 = 517,
};
enum MMSYS_INDEX {
MMSYS_MDP_START = 245,
MMSYS_MDP_END = 252,
MMSYS_DISP_START = 253,
MMSYS_DISP_END = 271,
MMSYS_MDP2_START = 272,
MMSYS_MDP2_END = 279,
};
enum IMGSYS_INDEX {
IMGSYS1_TOP = 208,
IMGSYS2_TOP = 240,
};
enum VENCSYS_INDEX {
VENC_GLOBAL_CON = 276,
VENC = 278,
VENC_MBIST_CTR = 282,
};
enum VDECSYS_INDEX {
VDECSYS_START = 258,
VDECSYS_END = 274,
};
enum CAMSYS_INDEX {
CAMSYS_START = 332,
CAMSYS_END = 443,
CAMSYS_SENINF_START = 288,
CAMSYS_SENINF_END = 295,
CAMSYS_P1_START = 430,
CAMSYS_P1_END = 443,
};
enum OTHER_TYPES_INDEX {
SRAMROM_VIO_INDEX = 546,
TOPAXI_SI0_DECERR = 540,
PERIAXI_SI1_DECERR = 542,
};
enum BUSID_LENGTH {
PERIAXI_INT_MI_BIT_LENGTH = 4,
TOPAXI_MI0_BIT_LENGTH = 14,
};
/* bit == 2 means don't care */
struct PERIAXI_ID_INFO {
const char *master;
uint8_t bit[PERIAXI_INT_MI_BIT_LENGTH];
};
struct TOPAXI_ID_INFO {
const char *master;
uint8_t bit[TOPAXI_MI0_BIT_LENGTH];
};
/******************************************************************************
* PLATFORM DEFINATION
******************************************************************************/
/* For Infra VIO_DBG */
#define INFRA_VIO_DBG_MSTID 0x0000FFFF
#define INFRA_VIO_DBG_MSTID_START_BIT 0
#define INFRA_VIO_DBG_DMNID 0x003F0000
#define INFRA_VIO_DBG_DMNID_START_BIT 16
#define INFRA_VIO_DBG_W_VIO 0x00400000
#define INFRA_VIO_DBG_W_VIO_START_BIT 22
#define INFRA_VIO_DBG_R_VIO 0x00800000
#define INFRA_VIO_DBG_R_VIO_START_BIT 23
#define INFRA_VIO_ADDR_HIGH 0x0F000000
#define INFRA_VIO_ADDR_HIGH_START_BIT 24
/* For SRAMROM VIO */
#define SRAMROM_SEC_VIO_ID_MASK 0x00FFFF00
#define SRAMROM_SEC_VIO_ID_SHIFT 8
#define SRAMROM_SEC_VIO_DOMAIN_MASK 0x0F000000
#define SRAMROM_SEC_VIO_DOMAIN_SHIFT 24
#define SRAMROM_SEC_VIO_RW_MASK 0x80000000
#define SRAMROM_SEC_VIO_RW_SHIFT 31
/* For DEVAPC PD */
#define PD_VIO_MASK_OFFSET 0x0
#define PD_VIO_STA_OFFSET 0x400
#define PD_VIO_DBG0_OFFSET 0x900
#define PD_VIO_DBG1_OFFSET 0x904
#define PD_APC_CON_OFFSET 0xF00
#define PD_SHIFT_STA_OFFSET 0xF10
#define PD_SHIFT_SEL_OFFSET 0xF14
#define PD_SHIFT_CON_OFFSET 0xF20
#endif /* __DEVAPC_MT6781_H__ */
+606
View File
@@ -0,0 +1,606 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2019 MediaTek Inc.
*/
#include <linux/bug.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <asm-generic/io.h>
#include "devapc-mt6833.h"
static struct mtk_device_num mtk6833_devices_num[] = {
{SLAVE_TYPE_INFRA, VIO_SLAVE_NUM_INFRA},
{SLAVE_TYPE_PERI, VIO_SLAVE_NUM_PERI},
{SLAVE_TYPE_PERI2, VIO_SLAVE_NUM_PERI2},
{SLAVE_TYPE_PERI_PAR, VIO_SLAVE_NUM_PERI_PAR},
};
static struct PERIAXI_ID_INFO peri_mi_id_to_master[] = {
{"THERM2", { 0, 0, 0 } },
{"SPM", { 0, 1, 0 } },
{"CCU", { 0, 0, 1 } },
{"THERM", { 0, 1, 1 } },
{"SPM", { 1, 1, 0 } },
};
static struct INFRAAXI_ID_INFO infra_mi_id_to_master[] = {
{"CONNSYS_WFDMA", { 0, 0, 0, 0, 0, 1, 2, 2, 2, 2, 2, 2, 2, 0 } },
{"CONNSYS_ICAP", { 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0 } },
{"CONNSYS_WF_MCU", { 0, 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 0 } },
{"CONNSYS_BT_MCU", { 0, 0, 0, 0, 1, 0, 0, 1, 2, 2, 2, 2, 2, 0 } },
{"CONNSYS_GPS", { 0, 0, 0, 0, 1, 0, 0, 0, 2, 2, 2, 2, 2, 0 } },
{"Tinysys", { 0, 1, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0 } },
{"CQ_DMA", { 0, 0, 1, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0 } },
{"DebugTop", { 0, 0, 1, 0, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0 } },
{"SSUSB", { 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 2 } },
{"PWM", { 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0 } },
{"MSDC1", { 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0 } },
{"SPI6", { 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1 } },
{"SPI0", { 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1 } },
{"MSDC0", { 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 2, 2, 0, 0 } },
{"SPI2", { 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0 } },
{"SPI3", { 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0 } },
{"SPI4", { 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0 } },
{"SPI5", { 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0 } },
{"SPI7", { 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0 } },
{"Audio", { 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0 } },
{"SPI1", { 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0 } },
{"AP_DMA_EXT", { 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 2, 2, 2, 0 } },
{"THERM2", { 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0 } },
{"SPM", { 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0 } },
{"CCU", { 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0 } },
{"THERM", { 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0 } },
{"HWCCF", { 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 2, 2, 0, 0 } },
{"DX_CC", { 0, 0, 1, 0, 1, 1, 0, 2, 2, 2, 2, 0, 0, 0 } },
{"GCE", { 0, 0, 1, 0, 0, 0, 1, 2, 2, 0, 0, 0, 0, 0 } },
{"CPUEB", { 0, 0, 1, 0, 1, 0, 1, 2, 2, 2, 2, 2, 2, 0 } },
{"DPMAIF", { 0, 1, 1, 0, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0 } },
{"SSPM", { 0, 0, 0, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0 } },
{"UFS", { 0, 1, 0, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0 } },
{"CPUEB", { 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0 } },
{"APMCU_Write", { 1, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
{"APMCU_Write", { 1, 2, 2, 2, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0 } },
{"APMCU_Write", { 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0 } },
{"APMCU_Read", { 1, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
{"APMCU_Read", { 1, 2, 2, 2, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0 } },
{"APMCU_Read", { 1, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 } },
{"APMCU_Read", { 1, 2, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 } },
{"APMCU_Read", { 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0 } },
{"APMCU_Read", { 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0 } },
};
static const char *infra_mi_trans(uint32_t bus_id)
{
int master_count = ARRAY_SIZE(infra_mi_id_to_master);
const char *master = "UNKNOWN_MASTER_FROM_INFRA";
int i, j;
for (i = 0; i < master_count; i++) {
for (j = 0; j < INFRAAXI_MI_BIT_LENGTH; j++) {
if (infra_mi_id_to_master[i].bit[j] == 2)
continue;
if (((bus_id >> j) & 0x1) ==
infra_mi_id_to_master[i].bit[j])
continue;
break;
}
if (j == INFRAAXI_MI_BIT_LENGTH) {
pr_debug(PFX "%s %s %s\n",
"catch it from INFRAAXI_MI",
"Master is:",
infra_mi_id_to_master[i].master);
master = infra_mi_id_to_master[i].master;
}
}
return master;
}
static const char *peri_mi_trans(uint32_t bus_id)
{
int master_count = ARRAY_SIZE(peri_mi_id_to_master);
const char *master = "UNKNOWN_MASTER_FROM_PERI";
int i, j;
if ((bus_id & 0x3) == 0x0)
return infra_mi_trans(bus_id >> 2);
else if ((bus_id & 0x3) == 0x2)
return "MD_AP_M";
else if ((bus_id & 0x3) == 0x3)
return "AP_DMA_M";
bus_id = bus_id >> 2;
for (i = 0 ; i < master_count; i++) {
for (j = 0 ; j < PERIAXI_MI_BIT_LENGTH ; j++) {
if (peri_mi_id_to_master[i].bit[j] == 2)
continue;
if (((bus_id >> j) & 0x1) ==
peri_mi_id_to_master[i].bit[j])
continue;
break;
}
if (j == PERIAXI_MI_BIT_LENGTH) {
pr_debug(PFX "%s %s %s\n",
"catch it from PERIAXI_MI.",
"Master is:",
peri_mi_id_to_master[i].master);
master = peri_mi_id_to_master[i].master;
}
}
return master;
}
static bool is_addr_in_mdp_mali(uint32_t addr)
{
if ((addr >= MDP_REGION1_START_ADDR && addr <= MDP_REGION1_END_ADDR) ||
(addr >= MDP_REGION2_START_ADDR && addr <= MDP_REGION2_END_ADDR) ||
(addr >= MDP_REGION3_START_ADDR && addr <= MDP_REGION3_END_ADDR)) {
pr_info(PFX "vio_addr might from MDP_MALI\n");
return true;
}
return false;
}
static bool is_addr_in_mmsys_mali(uint32_t addr)
{
if ((addr >= MMSYS_REGION1_START_ADDR && addr <= MMSYS_REGION1_END_ADDR) ||
(addr >= MMSYS_REGION2_START_ADDR && addr <= MMSYS_REGION2_END_ADDR)) {
pr_info(PFX "vio_addr might from MMSYS_MALI\n");
return true;
}
return false;
}
static const char *mt6833_bus_id_to_master(uint32_t bus_id, uint32_t vio_addr,
int slave_type, int shift_sta_bit, int domain)
{
const char *err_master = "UNKNOWN_MASTER";
uint8_t h_1byte;
pr_debug(PFX "[DEVAPC] %s:0x%x, %s:0x%x, %s:0x%x, %s:%d\n",
"bus_id", bus_id, "vio_addr", vio_addr,
"slave_type", slave_type,
"shift_sta_bit", shift_sta_bit);
h_1byte = (vio_addr >> 24) & 0xFF;
if ((vio_addr >= TINYSYS_START_ADDR && vio_addr <= TINYSYS_END_ADDR) ||
(vio_addr >= MD_START_ADDR && vio_addr <= MD_END_ADDR)) {
pr_info(PFX "[DEVAPC] bus_id might be wrong\n");
if (domain == 0x1)
return "SSPM";
else if (domain == 0x2)
return "CONNSYS";
} else if (vio_addr >= CONN_START_ADDR && vio_addr <= CONN_END_ADDR) {
pr_info(PFX "[DEVAPC] bus_id might be wrong\n");
if (domain == 0x1)
return "MD";
else if (domain == 0x2)
return "ADSP";
}
if (slave_type == SLAVE_TYPE_INFRA) {
if (vio_addr <= 0x1FFFFF || shift_sta_bit == 6) {
pr_info(PFX "vio_addr might from SRAMROM\n");
if ((bus_id & 0x1) == 0x0)
return "EMI_L2C_M";
return infra_mi_trans(bus_id >> 1);
} else if (is_addr_in_mdp_mali(vio_addr) ||
is_addr_in_mmsys_mali(vio_addr) ||
shift_sta_bit == 7) {
if ((bus_id & 0x1) == 0x1)
return "GCE_M";
return infra_mi_trans(bus_id >> 1);
} else if (shift_sta_bit >= 0 && shift_sta_bit <= 3) {
return peri_mi_trans(bus_id);
} else if (shift_sta_bit >= 4 && shift_sta_bit <= 5) {
return infra_mi_trans(bus_id);
}
return err_master;
} else if (slave_type == SLAVE_TYPE_PERI) {
if (shift_sta_bit == 1 || shift_sta_bit == 2 ||
shift_sta_bit == 7) {
if ((bus_id & 0x1) == 0)
return "MD_AP_M";
return peri_mi_trans(bus_id >> 1);
}
return peri_mi_trans(bus_id);
} else if (slave_type == SLAVE_TYPE_PERI2) {
return peri_mi_trans(bus_id);
} else if (slave_type == SLAVE_TYPE_PERI_PAR) {
return peri_mi_trans(bus_id);
}
return err_master;
}
/* violation index corresponds to subsys */
const char *index_to_subsys(int slave_type, uint32_t vio_index,
uint32_t vio_addr)
{
int i;
/* Filter by violation address */
if ((vio_addr & 0xFF000000) == CONN_START_ADDR)
return "CONNSYS";
/* Filter by violation index */
if (slave_type == SLAVE_TYPE_INFRA &&
vio_index < VIO_SLAVE_NUM_INFRA) {
for (i = 0; i < VIO_SLAVE_NUM_INFRA; i++) {
if (vio_index == mt6833_devices_infra[i].vio_index)
return mt6833_devices_infra[i].device;
}
} else if (slave_type == SLAVE_TYPE_PERI &&
vio_index < VIO_SLAVE_NUM_PERI)
for (i = 0; i < VIO_SLAVE_NUM_PERI; i++) {
if (vio_index == mt6833_devices_peri[i].vio_index)
return mt6833_devices_peri[i].device;
}
else if (slave_type == SLAVE_TYPE_PERI2 &&
vio_index < VIO_SLAVE_NUM_PERI2)
for (i = 0; i < VIO_SLAVE_NUM_PERI2; i++) {
if (vio_index == mt6833_devices_peri2[i].vio_index)
return mt6833_devices_peri2[i].device;
}
else if (slave_type == SLAVE_TYPE_PERI_PAR &&
vio_index < VIO_SLAVE_NUM_PERI_PAR)
for (i = 0; i < VIO_SLAVE_NUM_PERI_PAR; i++) {
if (vio_index == mt6833_devices_peri_par[i].vio_index)
return mt6833_devices_peri_par[i].device;
}
return "OUT_OF_BOUND";
}
static void mm2nd_vio_handler(void __iomem *infracfg,
struct mtk_devapc_vio_info *vio_info,
bool mdp_vio, bool disp2_vio, bool mmsys_vio)
{
uint32_t vio_sta, vio_dbg, rw;
uint32_t vio_sta_num;
uint32_t vio0_offset;
char mm_str[64] = {0};
void __iomem *reg;
int i;
if (!infracfg) {
pr_err(PFX "%s, param check failed, infracfg ptr is NULL\n",
__func__);
return;
}
if (mdp_vio) {
vio_sta_num = INFRACFG_MDP_VIO_STA_NUM;
vio0_offset = INFRACFG_MDP_SEC_VIO0_OFFSET;
strncpy(mm_str, "INFRACFG_MDP_SEC_VIO", sizeof(mm_str));
} else if (mmsys_vio) {
vio_sta_num = INFRACFG_MM_VIO_STA_NUM;
vio0_offset = INFRACFG_MM_SEC_VIO0_OFFSET;
strncpy(mm_str, "INFRACFG_MM_SEC_VIO", sizeof(mm_str));
} else {
pr_err(PFX "%s: param check failed, %s:%s, %s:%s, %s:%s\n",
__func__,
"mdp_vio", mdp_vio ? "true" : "false",
"disp2_vio", disp2_vio ? "true" : "false",
"mmsys_vio", mmsys_vio ? "true" : "false");
return;
}
/* Get mm2nd violation status */
for (i = 0; i < vio_sta_num; i++) {
reg = infracfg + vio0_offset + i * 4;
vio_sta = readl(reg);
if (vio_sta)
pr_info(PFX "MM 2nd violation: %s%d:0x%x\n",
mm_str, i, vio_sta);
}
/* Get mm2nd violation address */
reg = infracfg + vio0_offset + i * 4;
vio_info->vio_addr = readl(reg);
/* Get mm2nd violation information */
reg = infracfg + vio0_offset + (i + 1) * 4;
vio_dbg = readl(reg);
vio_info->domain_id = (vio_dbg & INFRACFG_MM2ND_VIO_DOMAIN_MASK) >>
INFRACFG_MM2ND_VIO_DOMAIN_SHIFT;
vio_info->master_id = (vio_dbg & INFRACFG_MM2ND_VIO_ID_MASK) >>
INFRACFG_MM2ND_VIO_ID_SHIFT;
rw = (vio_dbg & INFRACFG_MM2ND_VIO_RW_MASK) >>
INFRACFG_MM2ND_VIO_RW_SHIFT;
vio_info->read = (rw == 0);
vio_info->write = (rw == 1);
}
static uint32_t mt6833_shift_group_get(int slave_type, uint32_t vio_idx)
{
if (slave_type == SLAVE_TYPE_INFRA) {
if (vio_idx >= 0 && vio_idx <= 3)
return 0;
else if (vio_idx >= 4 && vio_idx <= 5)
return 1;
else if ((vio_idx >= 6 && vio_idx <= 31) ||
(vio_idx >= 347 && vio_idx <= 373) ||
vio_idx == 392)
return 2;
else if ((vio_idx >= 32 && vio_idx <= 45) ||
(vio_idx >= 374 && vio_idx <= 388) ||
vio_idx == 393)
return 3;
else if ((vio_idx >= 46 && vio_idx <= 63) || vio_idx == 389)
return 4;
else if ((vio_idx >= 64 && vio_idx <= 68) || vio_idx == 390)
return 5;
else if ((vio_idx >= 69 && vio_idx <= 70) || vio_idx == 391)
return 6;
else if (vio_idx >= 71 && vio_idx <= 346)
return 7;
pr_err(PFX "%s:%d Wrong vio_idx:0x%x\n",
__func__, __LINE__, vio_idx);
} else if (slave_type == SLAVE_TYPE_PERI) {
if ((vio_idx >= 0 && vio_idx <= 2) ||
(vio_idx >= 121 && vio_idx <= 124) ||
vio_idx == 160)
return 0;
else if ((vio_idx >= 3 && vio_idx <= 25) || vio_idx == 125)
return 1;
else if ((vio_idx >= 26 && vio_idx <= 40) || vio_idx == 126)
return 2;
else if ((vio_idx >= 41 && vio_idx <= 83) || vio_idx == 127)
return 3;
else if ((vio_idx >= 84 && vio_idx <= 85) || vio_idx == 128)
return 4;
else if ((vio_idx >= 86 && vio_idx <= 89) || vio_idx == 129)
return 5;
else if (vio_idx == 90 || vio_idx == 130)
return 6;
else if ((vio_idx >= 91 && vio_idx <= 93) || vio_idx == 131)
return 7;
else if (vio_idx == 94 ||
(vio_idx >= 132 && vio_idx <= 133) ||
vio_idx == 161)
return 8;
else if (vio_idx >= 95 && vio_idx <= 96)
return 9;
else if ((vio_idx >= 97 && vio_idx <= 111) ||
(vio_idx >= 134 && vio_idx <= 149) ||
vio_idx == 162)
return 10;
else if ((vio_idx >= 112 && vio_idx <= 120) ||
(vio_idx >= 150 && vio_idx <= 159) ||
vio_idx == 163)
return 11;
pr_err(PFX "%s:%d Wrong vio_idx:0x%x\n",
__func__, __LINE__, vio_idx);
} else if (slave_type == SLAVE_TYPE_PERI2) {
if ((vio_idx >= 0 && vio_idx <= 2) ||
(vio_idx >= 106 && vio_idx <= 109) ||
vio_idx == 212)
return 0;
else if (vio_idx >= 3 && vio_idx <= 6)
return 1;
else if (vio_idx >= 7 && vio_idx <= 10)
return 2;
else if ((vio_idx >= 11 && vio_idx <= 26) ||
(vio_idx >= 110 && vio_idx <= 126) ||
vio_idx == 213)
return 3;
else if ((vio_idx >= 27 && vio_idx <= 34) ||
(vio_idx >= 127 && vio_idx <= 135) ||
vio_idx == 214)
return 4;
else if ((vio_idx >= 35 && vio_idx <= 50) ||
(vio_idx >= 136 && vio_idx <= 152) ||
vio_idx == 215)
return 5;
else if ((vio_idx >= 51 && vio_idx <= 66) ||
(vio_idx >= 153 && vio_idx <= 169) ||
vio_idx == 216)
return 6;
else if ((vio_idx >= 67 && vio_idx <= 74) ||
(vio_idx >= 170 && vio_idx <= 178) ||
vio_idx == 217)
return 7;
else if ((vio_idx >= 75 && vio_idx <= 93) ||
(vio_idx >= 179 && vio_idx <= 198) ||
vio_idx == 218)
return 8;
else if ((vio_idx >= 94 && vio_idx <= 105) ||
(vio_idx >= 199 && vio_idx <= 211) ||
vio_idx == 219)
return 9;
pr_err(PFX "%s:%d Wrong vio_idx:0x%x\n",
__func__, __LINE__, vio_idx);
} else if (slave_type == SLAVE_TYPE_PERI_PAR) {
if ((vio_idx >= 0 && vio_idx <= 1) ||
(vio_idx >= 28 && vio_idx <= 29) ||
vio_idx == 58)
return 0;
else if ((vio_idx >= 2 && vio_idx <= 24) ||
(vio_idx >= 30 && vio_idx <= 53) ||
vio_idx == 59)
return 1;
else if ((vio_idx >= 25 && vio_idx <= 27) ||
(vio_idx >= 54 && vio_idx <= 57) ||
vio_idx == 60)
return 2;
pr_err(PFX "%s:%d Wrong vio_idx:0x%x\n",
__func__, __LINE__, vio_idx);
}
pr_err(PFX "%s:%d Wrong slave_type:0x%x\n",
__func__, __LINE__, slave_type);
return 31;
}
void devapc_catch_illegal_range(phys_addr_t phys_addr, size_t size)
{
/*
* Catch BROM addr mapped
*/
if (phys_addr >= 0x0 && phys_addr < SRAM_START_ADDR) {
pr_err(PFX "%s: %s %s:(%pa), %s:(0x%lx)\n",
"catch BROM address mapped!",
__func__, "phys_addr", &phys_addr,
"size", size);
BUG_ON(1);
}
}
EXPORT_SYMBOL(devapc_catch_illegal_range);
static struct mtk_devapc_dbg_status mt6833_devapc_dbg_stat = {
.enable_ut = PLAT_DBG_UT_DEFAULT,
.enable_KE = PLAT_DBG_KE_DEFAULT,
.enable_AEE = PLAT_DBG_AEE_DEFAULT,
.enable_WARN = PLAT_DBG_WARN_DEFAULT,
.enable_dapc = PLAT_DBG_DAPC_DEFAULT,
};
static const char * const slave_type_to_str[] = {
"SLAVE_TYPE_INFRA",
"SLAVE_TYPE_PERI",
"SLAVE_TYPE_PERI2",
"SLAVE_TYPE_PERI_PAR",
"WRONG_SLAVE_TYPE",
};
static int mtk_vio_mask_sta_num[] = {
VIO_MASK_STA_NUM_INFRA,
VIO_MASK_STA_NUM_PERI,
VIO_MASK_STA_NUM_PERI2,
VIO_MASK_STA_NUM_PERI_PAR,
};
static struct mtk_devapc_vio_info mt6833_devapc_vio_info = {
.vio_mask_sta_num = mtk_vio_mask_sta_num,
.sramrom_vio_idx = SRAMROM_VIO_INDEX,
.mdp_vio_idx = MDP_VIO_INDEX,
.disp2_vio_idx = MDP_VIO_INDEX,
.mmsys_vio_idx = MMSYS_VIO_INDEX,
.sramrom_slv_type = SRAMROM_SLAVE_TYPE,
.mm2nd_slv_type = MM2ND_SLAVE_TYPE,
};
static const struct mtk_infra_vio_dbg_desc mt6833_vio_dbgs = {
.vio_dbg_mstid = INFRA_VIO_DBG_MSTID,
.vio_dbg_mstid_start_bit = INFRA_VIO_DBG_MSTID_START_BIT,
.vio_dbg_dmnid = INFRA_VIO_DBG_DMNID,
.vio_dbg_dmnid_start_bit = INFRA_VIO_DBG_DMNID_START_BIT,
.vio_dbg_w_vio = INFRA_VIO_DBG_W_VIO,
.vio_dbg_w_vio_start_bit = INFRA_VIO_DBG_W_VIO_START_BIT,
.vio_dbg_r_vio = INFRA_VIO_DBG_R_VIO,
.vio_dbg_r_vio_start_bit = INFRA_VIO_DBG_R_VIO_START_BIT,
.vio_addr_high = INFRA_VIO_ADDR_HIGH,
.vio_addr_high_start_bit = INFRA_VIO_ADDR_HIGH_START_BIT,
};
static const struct mtk_sramrom_sec_vio_desc mt6833_sramrom_sec_vios = {
.vio_id_mask = SRAMROM_SEC_VIO_ID_MASK,
.vio_id_shift = SRAMROM_SEC_VIO_ID_SHIFT,
.vio_domain_mask = SRAMROM_SEC_VIO_DOMAIN_MASK,
.vio_domain_shift = SRAMROM_SEC_VIO_DOMAIN_SHIFT,
.vio_rw_mask = SRAMROM_SEC_VIO_RW_MASK,
.vio_rw_shift = SRAMROM_SEC_VIO_RW_SHIFT,
};
static const uint32_t mt6833_devapc_pds[] = {
PD_VIO_MASK_OFFSET,
PD_VIO_STA_OFFSET,
PD_VIO_DBG0_OFFSET,
PD_VIO_DBG1_OFFSET,
PD_VIO_DBG2_OFFSET,
PD_APC_CON_OFFSET,
PD_SHIFT_STA_OFFSET,
PD_SHIFT_SEL_OFFSET,
PD_SHIFT_CON_OFFSET,
};
static struct mtk_devapc_soc mt6833_data = {
.dbg_stat = &mt6833_devapc_dbg_stat,
.slave_type_arr = slave_type_to_str,
.slave_type_num = SLAVE_TYPE_NUM,
.device_info[SLAVE_TYPE_INFRA] = mt6833_devices_infra,
.device_info[SLAVE_TYPE_PERI] = mt6833_devices_peri,
.device_info[SLAVE_TYPE_PERI2] = mt6833_devices_peri2,
.device_info[SLAVE_TYPE_PERI_PAR] = mt6833_devices_peri_par,
.ndevices = mtk6833_devices_num,
.vio_info = &mt6833_devapc_vio_info,
.vio_dbgs = &mt6833_vio_dbgs,
.sramrom_sec_vios = &mt6833_sramrom_sec_vios,
.devapc_pds = mt6833_devapc_pds,
.subsys_get = &index_to_subsys,
.master_get = &mt6833_bus_id_to_master,
.mm2nd_vio_handler = &mm2nd_vio_handler,
.shift_group_get = mt6833_shift_group_get,
};
static const struct of_device_id mt6833_devapc_dt_match[] = {
{ .compatible = "mediatek,mt6833-devapc" },
{},
};
static int mt6833_devapc_probe(struct platform_device *pdev)
{
return mtk_devapc_probe(pdev, &mt6833_data);
}
static int mt6833_devapc_remove(struct platform_device *dev)
{
return mtk_devapc_remove(dev);
}
static struct platform_driver mt6833_devapc_driver = {
.probe = mt6833_devapc_probe,
.remove = mt6833_devapc_remove,
.driver = {
.name = KBUILD_MODNAME,
.of_match_table = mt6833_devapc_dt_match,
},
};
module_platform_driver(mt6833_devapc_driver);
MODULE_DESCRIPTION("Mediatek MT6833 Device APC Driver");
MODULE_AUTHOR("Neal Liu <neal.liu@mediatek.com>");
MODULE_LICENSE("GPL");
File diff suppressed because it is too large. Load diff
+588
View File
@@ -0,0 +1,588 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2019 MediaTek Inc.
*/
#include <linux/bug.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <asm-generic/io.h>
#include "devapc-mt6853.h"
static struct mtk_device_num mtk6853_devices_num[] = {
{SLAVE_TYPE_INFRA, VIO_SLAVE_NUM_INFRA},
{SLAVE_TYPE_PERI, VIO_SLAVE_NUM_PERI},
{SLAVE_TYPE_PERI2, VIO_SLAVE_NUM_PERI2},
{SLAVE_TYPE_PERI_PAR, VIO_SLAVE_NUM_PERI_PAR},
};
static struct PERIAXI_ID_INFO peri_mi_id_to_master[] = {
{"THERM2", { 0, 0, 0 } },
{"SPM", { 0, 1, 0 } },
{"CCU", { 0, 0, 1 } },
{"THERM", { 0, 1, 1 } },
{"SPM", { 1, 1, 0 } },
};
static struct INFRAAXI_ID_INFO infra_mi_id_to_master[] = {
{"CONNSYS_WFDMA", { 0, 0, 0, 0, 0, 1, 2, 2, 2, 2, 2, 2, 2, 0 } },
{"CONNSYS_ICAP", { 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0 } },
{"CONNSYS_WF_MCU", { 0, 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 0 } },
{"CONNSYS_BT_MCU", { 0, 0, 0, 0, 1, 0, 0, 1, 2, 2, 2, 2, 2, 0 } },
{"CONNSYS_GPS", { 0, 0, 0, 0, 1, 0, 0, 0, 2, 2, 2, 2, 2, 0 } },
{"Tinysys", { 0, 1, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0 } },
{"CQ_DMA", { 0, 0, 1, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0 } },
{"DebugTop", { 0, 0, 1, 0, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0 } },
{"SSUSB", { 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 2 } },
{"NOR", { 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2, 2 } },
{"PWM", { 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0 } },
{"MSDC1", { 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0 } },
{"SPI6", { 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1 } },
{"SPI0", { 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1 } },
{"APU", { 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 2, 2, 0, 0 } },
{"MSDC0", { 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 2, 2, 0, 0 } },
{"SPI2", { 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0 } },
{"SPI3", { 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0 } },
{"SPI4", { 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0 } },
{"SPI5", { 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0 } },
{"SPI7", { 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0 } },
{"Audio", { 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0 } },
{"SPI1", { 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0 } },
{"AP_DMA_EXT", { 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 2, 2, 2, 0 } },
{"THERM2", { 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0 } },
{"SPM", { 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0 } },
{"CCU", { 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0 } },
{"THERM", { 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0 } },
{"DX_CC", { 0, 0, 1, 0, 1, 1, 0, 2, 2, 2, 2, 0, 0, 0 } },
{"GCE", { 0, 0, 1, 0, 0, 0, 1, 2, 2, 0, 0, 0, 0, 0 } },
{"DPMAIF", { 0, 1, 1, 0, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0 } },
{"SSPM", { 0, 0, 0, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0 } },
{"UFS", { 0, 1, 0, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0 } },
{"CPUEB", { 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0 } },
{"APMCU_Write", { 1, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
{"APMCU_Write", { 1, 2, 2, 2, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0 } },
{"APMCU_Write", { 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0 } },
{"APMCU_Read", { 1, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
{"APMCU_Read", { 1, 2, 2, 2, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0 } },
{"APMCU_Read", { 1, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 } },
{"APMCU_Read", { 1, 2, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 } },
{"APMCU_Read", { 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0 } },
{"APMCU_Read", { 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0 } },
};
static const char *infra_mi_trans(uint32_t bus_id)
{
int master_count = ARRAY_SIZE(infra_mi_id_to_master);
const char *master = "UNKNOWN_MASTER_FROM_INFRA";
int i, j;
for (i = 0; i < master_count; i++) {
for (j = 0; j < INFRAAXI_MI_BIT_LENGTH; j++) {
if (infra_mi_id_to_master[i].bit[j] == 2)
continue;
if (((bus_id >> j) & 0x1) ==
infra_mi_id_to_master[i].bit[j])
continue;
break;
}
if (j == INFRAAXI_MI_BIT_LENGTH) {
pr_debug(PFX "%s %s %s\n",
"catch it from INFRAAXI_MI",
"Master is:",
infra_mi_id_to_master[i].master);
master = infra_mi_id_to_master[i].master;
}
}
return master;
}
static const char *peri_mi_trans(uint32_t bus_id)
{
int master_count = ARRAY_SIZE(peri_mi_id_to_master);
const char *master = "UNKNOWN_MASTER_FROM_PERI";
int i, j;
if ((bus_id & 0x3) == 0x0)
return infra_mi_trans(bus_id >> 2);
else if ((bus_id & 0x3) == 0x2)
return "MD_AP_M";
else if ((bus_id & 0x3) == 0x3)
return "AP_DMA_M";
bus_id = bus_id >> 2;
for (i = 0 ; i < master_count; i++) {
for (j = 0 ; j < PERIAXI_MI_BIT_LENGTH ; j++) {
if (peri_mi_id_to_master[i].bit[j] == 2)
continue;
if (((bus_id >> j) & 0x1) ==
peri_mi_id_to_master[i].bit[j])
continue;
break;
}
if (j == PERIAXI_MI_BIT_LENGTH) {
pr_debug(PFX "%s %s %s\n",
"catch it from PERIAXI_MI.",
"Master is:",
peri_mi_id_to_master[i].master);
master = peri_mi_id_to_master[i].master;
}
}
return master;
}
static const char *mt6853_bus_id_to_master(uint32_t bus_id, uint32_t vio_addr,
int slave_type, int shift_sta_bit, int domain)
{
const char *err_master = "UNKNOWN_MASTER";
uint8_t h_1byte;
pr_debug(PFX "[DEVAPC] %s:0x%x, %s:0x%x, %s:0x%x, %s:%d\n",
"bus_id", bus_id, "vio_addr", vio_addr,
"slave_type", slave_type,
"shift_sta_bit", shift_sta_bit);
h_1byte = (vio_addr >> 24) & 0xFF;
if ((vio_addr >= TINYSYS_START_ADDR && vio_addr <= TINYSYS_END_ADDR) ||
(vio_addr >= MD_START_ADDR && vio_addr <= MD_END_ADDR)) {
pr_info(PFX "[DEVAPC] bus_id might be wrong\n");
if (domain == 0x1)
return "SSPM";
else if (domain == 0x2)
return "CONNSYS";
} else if (vio_addr >= CONN_START_ADDR && vio_addr <= CONN_END_ADDR) {
pr_info(PFX "[DEVAPC] bus_id might be wrong\n");
if (domain == 0x1)
return "MD";
else if (domain == 0x2)
return "ADSP";
}
if (slave_type == SLAVE_TYPE_INFRA) {
if (vio_addr <= 0x1FFFFF || shift_sta_bit == 7) {
pr_info(PFX "vio_addr is from on-chip SRAMROM\n");
if ((bus_id & 0x1) == 0)
return "EMI_L2C_M";
return infra_mi_trans(bus_id >> 1);
} else if (shift_sta_bit >= 0 && shift_sta_bit <= 3) {
return peri_mi_trans(bus_id);
} else if (shift_sta_bit >= 4 && shift_sta_bit <= 6) {
return infra_mi_trans(bus_id);
} else if (shift_sta_bit == 8) {
pr_info(PFX "vio_addr is from MMSYS_MALI\n");
if ((bus_id & 0x1) == 1)
return "GCE_M";
return infra_mi_trans(bus_id >> 1);
}
return err_master;
} else if (slave_type == SLAVE_TYPE_PERI) {
if (shift_sta_bit == 1 || shift_sta_bit == 2 ||
shift_sta_bit == 7) {
if ((bus_id & 0x1) == 0)
return "MD_AP_M";
return peri_mi_trans(bus_id >> 1);
}
return peri_mi_trans(bus_id);
} else if (slave_type == SLAVE_TYPE_PERI2) {
return peri_mi_trans(bus_id);
} else if (slave_type == SLAVE_TYPE_PERI_PAR) {
return peri_mi_trans(bus_id);
}
return err_master;
}
/* violation index corresponds to subsys */
const char *index_to_subsys(int slave_type, uint32_t vio_index,
uint32_t vio_addr)
{
int i;
/* Filter by violation address */
if ((vio_addr & 0xFF000000) == CONN_START_ADDR)
return "CONNSYS";
/* Filter by violation index */
if (slave_type == SLAVE_TYPE_INFRA &&
vio_index < VIO_SLAVE_NUM_INFRA) {
for (i = 0; i < VIO_SLAVE_NUM_INFRA; i++) {
if (vio_index == mt6853_devices_infra[i].vio_index)
return mt6853_devices_infra[i].device;
}
} else if (slave_type == SLAVE_TYPE_PERI &&
vio_index < VIO_SLAVE_NUM_PERI)
for (i = 0; i < VIO_SLAVE_NUM_PERI; i++) {
if (vio_index == mt6853_devices_peri[i].vio_index)
return mt6853_devices_peri[i].device;
}
else if (slave_type == SLAVE_TYPE_PERI2 &&
vio_index < VIO_SLAVE_NUM_PERI2)
for (i = 0; i < VIO_SLAVE_NUM_PERI2; i++) {
if (vio_index == mt6853_devices_peri2[i].vio_index)
return mt6853_devices_peri2[i].device;
}
else if (slave_type == SLAVE_TYPE_PERI_PAR &&
vio_index < VIO_SLAVE_NUM_PERI_PAR)
for (i = 0; i < VIO_SLAVE_NUM_PERI_PAR; i++) {
if (vio_index == mt6853_devices_peri_par[i].vio_index)
return mt6853_devices_peri_par[i].device;
}
return "OUT_OF_BOUND";
}
static void mm2nd_vio_handler(void __iomem *infracfg,
struct mtk_devapc_vio_info *vio_info,
bool mdp_vio, bool disp2_vio, bool mmsys_vio)
{
uint32_t vio_sta, vio_dbg, rw;
uint32_t vio_sta_num;
uint32_t vio0_offset;
char mm_str[64] = {0};
void __iomem *reg;
int i;
if (!infracfg) {
pr_err(PFX "%s, param check failed, infracfg ptr is NULL\n",
__func__);
return;
}
if (mdp_vio) {
vio_sta_num = INFRACFG_MDP_VIO_STA_NUM;
vio0_offset = INFRACFG_MDP_SEC_VIO0_OFFSET;
strncpy(mm_str, "INFRACFG_MDP_SEC_VIO", sizeof(mm_str));
} else if (mmsys_vio) {
vio_sta_num = INFRACFG_MM_VIO_STA_NUM;
vio0_offset = INFRACFG_MM_SEC_VIO0_OFFSET;
strncpy(mm_str, "INFRACFG_MM_SEC_VIO", sizeof(mm_str));
} else {
pr_err(PFX "%s: param check failed, %s:%s, %s:%s, %s:%s\n",
__func__,
"mdp_vio", mdp_vio ? "true" : "false",
"disp2_vio", disp2_vio ? "true" : "false",
"mmsys_vio", mmsys_vio ? "true" : "false");
return;
}
/* Get mm2nd violation status */
for (i = 0; i < vio_sta_num; i++) {
reg = infracfg + vio0_offset + i * 4;
vio_sta = readl(reg);
if (vio_sta)
pr_info(PFX "MM 2nd violation: %s%d:0x%x\n",
mm_str, i, vio_sta);
}
/* Get mm2nd violation address */
reg = infracfg + vio0_offset + i * 4;
vio_info->vio_addr = readl(reg);
/* Get mm2nd violation information */
reg = infracfg + vio0_offset + (i + 1) * 4;
vio_dbg = readl(reg);
vio_info->domain_id = (vio_dbg & INFRACFG_MM2ND_VIO_DOMAIN_MASK) >>
INFRACFG_MM2ND_VIO_DOMAIN_SHIFT;
vio_info->master_id = (vio_dbg & INFRACFG_MM2ND_VIO_ID_MASK) >>
INFRACFG_MM2ND_VIO_ID_SHIFT;
rw = (vio_dbg & INFRACFG_MM2ND_VIO_RW_MASK) >>
INFRACFG_MM2ND_VIO_RW_SHIFT;
vio_info->read = (rw == 0);
vio_info->write = (rw == 1);
}
static uint32_t mt6853_shift_group_get(int slave_type, uint32_t vio_idx)
{
if (slave_type == SLAVE_TYPE_INFRA) {
if (vio_idx <= 3)
return 0;
else if (vio_idx >= 4 && vio_idx <= 5)
return 1;
else if ((vio_idx >= 6 && vio_idx <= 31) ||
(vio_idx >= 344 && vio_idx <= 370) ||
vio_idx == 390)
return 2;
else if ((vio_idx >= 32 && vio_idx <= 45) ||
(vio_idx >= 371 && vio_idx <= 385) ||
vio_idx == 391)
return 3;
else if ((vio_idx >= 46 && vio_idx <= 54) || vio_idx == 386)
return 4;
else if ((vio_idx >= 55 && vio_idx <= 60) || vio_idx == 387)
return 5;
else if ((vio_idx >= 61 && vio_idx <= 65) || vio_idx == 388)
return 6;
else if ((vio_idx >= 66 && vio_idx <= 67) || vio_idx == 389)
return 7;
else if (vio_idx >= 68 && vio_idx <= 343)
return 8;
pr_err(PFX "%s:%d Wrong vio_idx:0x%x\n",
__func__, __LINE__, vio_idx);
} else if (slave_type == SLAVE_TYPE_PERI) {
if (vio_idx <= 2 ||
(vio_idx >= 132 && vio_idx <= 135) ||
vio_idx == 186)
return 0;
else if ((vio_idx >= 3 && vio_idx <= 25) || vio_idx == 136)
return 1;
else if ((vio_idx >= 26 && vio_idx <= 36) || vio_idx == 137)
return 2;
else if ((vio_idx >= 37 && vio_idx <= 38) || vio_idx == 138)
return 3;
else if ((vio_idx >= 39 && vio_idx <= 42) || vio_idx == 139)
return 4;
else if (vio_idx == 43 || vio_idx == 140)
return 5;
else if ((vio_idx >= 44 && vio_idx <= 86) || vio_idx == 141)
return 6;
else if ((vio_idx >= 87 && vio_idx <= 89) || vio_idx == 142)
return 7;
else if (vio_idx == 90 || vio_idx == 143 ||
vio_idx == 144 || vio_idx == 187)
return 8;
if (vio_idx >= 91 && vio_idx <= 92)
return 9;
else if ((vio_idx >= 93 && vio_idx <= 104) ||
(vio_idx >= 145 && vio_idx <= 156) ||
vio_idx == 188)
return 10;
else if ((vio_idx >= 105 && vio_idx <= 119) ||
(vio_idx >= 157 && vio_idx <= 172) ||
vio_idx == 189)
return 11;
else if ((vio_idx >= 120 && vio_idx <= 131) ||
(vio_idx >= 174 && vio_idx <= 185) ||
vio_idx == 153 || vio_idx == 190)
return 12;
pr_err(PFX "%s:%d Wrong vio_idx:0x%x\n",
__func__, __LINE__, vio_idx);
} else if (slave_type == SLAVE_TYPE_PERI2) {
if (vio_idx <= 2 ||
(vio_idx >= 106 && vio_idx <= 109) ||
vio_idx == 212)
return 0;
else if (vio_idx >= 3 && vio_idx <= 6)
return 1;
else if (vio_idx >= 7 && vio_idx <= 10)
return 2;
else if ((vio_idx >= 11 && vio_idx <= 26) ||
(vio_idx >= 110 && vio_idx <= 126) ||
vio_idx == 213)
return 3;
else if ((vio_idx >= 27 && vio_idx <= 34) ||
(vio_idx >= 127 && vio_idx <= 135) ||
vio_idx == 214)
return 4;
else if ((vio_idx >= 35 && vio_idx <= 50) ||
(vio_idx >= 136 && vio_idx <= 152) ||
vio_idx == 215)
return 5;
else if ((vio_idx >= 51 && vio_idx <= 66) ||
(vio_idx >= 153 && vio_idx <= 169) ||
vio_idx == 216)
return 6;
else if ((vio_idx >= 67 && vio_idx <= 74) ||
(vio_idx >= 170 && vio_idx <= 178) ||
vio_idx == 217)
return 7;
else if ((vio_idx >= 75 && vio_idx <= 94) ||
(vio_idx >= 179 && vio_idx <= 199) ||
vio_idx == 218)
return 8;
else if ((vio_idx >= 95 && vio_idx <= 105) ||
(vio_idx >= 200 && vio_idx <= 211) ||
vio_idx == 219)
return 9;
pr_err(PFX "%s:%d Wrong vio_idx:0x%x\n",
__func__, __LINE__, vio_idx);
} else if (slave_type == SLAVE_TYPE_PERI_PAR) {
if (vio_idx <= 2 ||
(vio_idx >= 29 && vio_idx <= 30) ||
vio_idx == 60)
return 0;
else if ((vio_idx >= 3 && vio_idx <= 26) ||
(vio_idx >= 31 && vio_idx <= 55) ||
vio_idx == 61)
return 1;
else if ((vio_idx >= 27 && vio_idx <= 29) ||
(vio_idx >= 56 && vio_idx <= 59) ||
vio_idx == 62)
return 2;
pr_err(PFX "%s:%d Wrong vio_idx:0x%x\n",
__func__, __LINE__, vio_idx);
}
pr_err(PFX "%s:%d Wrong slave_type:0x%x\n",
__func__, __LINE__, slave_type);
return 31;
}
void devapc_catch_illegal_range(phys_addr_t phys_addr, size_t size)
{
/*
* Catch BROM addr mapped
*/
if (phys_addr >= 0x0 && phys_addr < SRAM_START_ADDR) {
pr_err(PFX "%s: %s %s:(%pa), %s:(0x%lx)\n",
"catch BROM address mapped!",
__func__, "phys_addr", &phys_addr,
"size", size);
BUG_ON(1);
}
}
EXPORT_SYMBOL(devapc_catch_illegal_range);
static struct mtk_devapc_dbg_status mt6853_devapc_dbg_stat = {
.enable_ut = PLAT_DBG_UT_DEFAULT,
.enable_KE = PLAT_DBG_KE_DEFAULT,
.enable_AEE = PLAT_DBG_AEE_DEFAULT,
.enable_WARN = PLAT_DBG_WARN_DEFAULT,
.enable_dapc = PLAT_DBG_DAPC_DEFAULT,
};
static const char * const slave_type_to_str[] = {
"SLAVE_TYPE_INFRA",
"SLAVE_TYPE_PERI",
"SLAVE_TYPE_PERI2",
"SLAVE_TYPE_PERI_PAR",
"WRONG_SLAVE_TYPE",
};
static int mtk_vio_mask_sta_num[] = {
VIO_MASK_STA_NUM_INFRA,
VIO_MASK_STA_NUM_PERI,
VIO_MASK_STA_NUM_PERI2,
VIO_MASK_STA_NUM_PERI_PAR,
};
static struct mtk_devapc_vio_info mt6853_devapc_vio_info = {
.vio_mask_sta_num = mtk_vio_mask_sta_num,
.sramrom_vio_idx = SRAMROM_VIO_INDEX,
.mdp_vio_idx = MDP_VIO_INDEX,
.disp2_vio_idx = MDP_VIO_INDEX,
.mmsys_vio_idx = MMSYS_VIO_INDEX,
.sramrom_slv_type = SRAMROM_SLAVE_TYPE,
.mm2nd_slv_type = MM2ND_SLAVE_TYPE,
};
static const struct mtk_infra_vio_dbg_desc mt6853_vio_dbgs = {
.vio_dbg_mstid = INFRA_VIO_DBG_MSTID,
.vio_dbg_mstid_start_bit = INFRA_VIO_DBG_MSTID_START_BIT,
.vio_dbg_dmnid = INFRA_VIO_DBG_DMNID,
.vio_dbg_dmnid_start_bit = INFRA_VIO_DBG_DMNID_START_BIT,
.vio_dbg_w_vio = INFRA_VIO_DBG_W_VIO,
.vio_dbg_w_vio_start_bit = INFRA_VIO_DBG_W_VIO_START_BIT,
.vio_dbg_r_vio = INFRA_VIO_DBG_R_VIO,
.vio_dbg_r_vio_start_bit = INFRA_VIO_DBG_R_VIO_START_BIT,
.vio_addr_high = INFRA_VIO_ADDR_HIGH,
.vio_addr_high_start_bit = INFRA_VIO_ADDR_HIGH_START_BIT,
};
static const struct mtk_sramrom_sec_vio_desc mt6853_sramrom_sec_vios = {
.vio_id_mask = SRAMROM_SEC_VIO_ID_MASK,
.vio_id_shift = SRAMROM_SEC_VIO_ID_SHIFT,
.vio_domain_mask = SRAMROM_SEC_VIO_DOMAIN_MASK,
.vio_domain_shift = SRAMROM_SEC_VIO_DOMAIN_SHIFT,
.vio_rw_mask = SRAMROM_SEC_VIO_RW_MASK,
.vio_rw_shift = SRAMROM_SEC_VIO_RW_SHIFT,
};
static const uint32_t mt6853_devapc_pds[] = {
PD_VIO_MASK_OFFSET,
PD_VIO_STA_OFFSET,
PD_VIO_DBG0_OFFSET,
PD_VIO_DBG1_OFFSET,
PD_VIO_DBG2_OFFSET,
PD_APC_CON_OFFSET,
PD_SHIFT_STA_OFFSET,
PD_SHIFT_SEL_OFFSET,
PD_SHIFT_CON_OFFSET,
};
static struct mtk_devapc_soc mt6853_data = {
.dbg_stat = &mt6853_devapc_dbg_stat,
.slave_type_arr = slave_type_to_str,
.slave_type_num = SLAVE_TYPE_NUM,
.device_info[SLAVE_TYPE_INFRA] = mt6853_devices_infra,
.device_info[SLAVE_TYPE_PERI] = mt6853_devices_peri,
.device_info[SLAVE_TYPE_PERI2] = mt6853_devices_peri2,
.device_info[SLAVE_TYPE_PERI_PAR] = mt6853_devices_peri_par,
.ndevices = mtk6853_devices_num,
.vio_info = &mt6853_devapc_vio_info,
.vio_dbgs = &mt6853_vio_dbgs,
.sramrom_sec_vios = &mt6853_sramrom_sec_vios,
.devapc_pds = mt6853_devapc_pds,
.subsys_get = &index_to_subsys,
.master_get = &mt6853_bus_id_to_master,
.mm2nd_vio_handler = &mm2nd_vio_handler,
.shift_group_get = mt6853_shift_group_get,
};
static const struct of_device_id mt6853_devapc_dt_match[] = {
{ .compatible = "mediatek,mt6853-devapc" },
{},
};
static int mt6853_devapc_probe(struct platform_device *pdev)
{
return mtk_devapc_probe(pdev, &mt6853_data);
}
static int mt6853_devapc_remove(struct platform_device *dev)
{
return mtk_devapc_remove(dev);
}
static struct platform_driver mt6853_devapc_driver = {
.probe = mt6853_devapc_probe,
.remove = mt6853_devapc_remove,
.driver = {
.name = KBUILD_MODNAME,
.of_match_table = mt6853_devapc_dt_match,
},
};
module_platform_driver(mt6853_devapc_driver);
MODULE_DESCRIPTION("Mediatek MT6853 Device APC Driver");
MODULE_AUTHOR("Neal Liu <neal.liu@mediatek.com>");
MODULE_LICENSE("GPL");
File diff suppressed because it is too large. Load diff
+600
View File
@@ -0,0 +1,600 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2019 MediaTek Inc.
*/
#include <linux/bug.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <asm-generic/io.h>
#include "devapc-mt6873.h"
static struct mtk_device_num mtk6873_devices_num[] = {
{SLAVE_TYPE_INFRA, VIO_SLAVE_NUM_INFRA},
{SLAVE_TYPE_PERI, VIO_SLAVE_NUM_PERI},
{SLAVE_TYPE_PERI2, VIO_SLAVE_NUM_PERI2},
{SLAVE_TYPE_PERI_PAR, VIO_SLAVE_NUM_PERI_PAR},
};
static struct PERIAXI_ID_INFO peri_mi_id_to_master[] = {
{"THERM2", { 0, 0, 0 } },
{"SPM", { 0, 1, 0 } },
{"CCU", { 0, 0, 1 } },
{"THERM", { 0, 1, 1 } },
{"SPM_DRAMC", { 1, 1, 0 } },
};
static struct INFRAAXI_ID_INFO infra_mi_id_to_master[] = {
{"CONNSYS_WFDMA", { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
{"CONNSYS_ICAP", { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
{"CONNSYS_MCU_SYS", { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 } },
{"CONNSYS_GPS", { 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 } },
{"Tinysys", { 0, 1, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0 } },
{"CQ_DMA", { 0, 0, 1, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0 } },
{"DebugTop", { 0, 0, 1, 0, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0 } },
{"SSUSB", { 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 0 } },
{"SSUSB2", { 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2, 0 } },
{"NOR", { 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 2, 0 } },
{"PWM", { 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0 } },
{"SPI6", { 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0 } },
{"SPI0", { 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0 } },
{"APU", { 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 2, 2, 0, 0 } },
{"SPI2", { 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0 } },
{"SPI3", { 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0 } },
{"SPI4", { 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0 } },
{"SPI5", { 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0 } },
{"SPI7", { 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0 } },
{"Audio", { 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0 } },
{"SPI1", { 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0 } },
{"AP_DMA_EXT", { 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 2, 2, 2, 0 } },
{"THERM2", { 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0 } },
{"SPM", { 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0 } },
{"CCU", { 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0 } },
{"THERM", { 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0 } },
{"DX_CC", { 0, 0, 1, 0, 1, 1, 0, 2, 2, 2, 2, 0, 0, 0 } },
{"GCE", { 0, 0, 1, 0, 0, 0, 1, 2, 2, 0, 0, 0, 0, 0 } },
{"PCIE", { 0, 0, 1, 0, 0, 1, 1, 2, 2, 2, 2, 2, 0, 0 } },
{"DPMAIF", { 0, 1, 1, 0, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0 } },
{"SSPM", { 0, 0, 0, 1, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0 } },
{"UFS", { 0, 1, 0, 1, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0 } },
{"MSDC0", { 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
{"MSDC1", { 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 } },
{"MSDC2", { 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 } },
{"CPUEB", { 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0 } },
{"APMCU_write", { 1, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
{"APMCU_write", { 1, 2, 2, 2, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0 } },
{"APMCU_write", { 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0 } },
{"APMCU_read", { 1, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
{"APMCU_read", { 1, 2, 2, 2, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0 } },
{"APMCU_read", { 1, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 } },
{"APMCU_read", { 1, 2, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 } },
{"APMCU_read", { 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0 } },
{"APMCU_read", { 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0 } },
};
static const char *infra_mi_trans(uint32_t bus_id)
{
int master_count = ARRAY_SIZE(infra_mi_id_to_master);
const char *master = "UNKNOWN_MASTER_FROM_INFRA";
int i, j;
for (i = 0; i < master_count; i++) {
for (j = 0; j < INFRAAXI_MI_BIT_LENGTH; j++) {
if (infra_mi_id_to_master[i].bit[j] == 2)
continue;
if (((bus_id >> j) & 0x1) ==
infra_mi_id_to_master[i].bit[j])
continue;
break;
}
if (j == INFRAAXI_MI_BIT_LENGTH) {
pr_debug(PFX "%s %s %s\n",
"catch it from INFRAAXI_MI",
"Master is:",
infra_mi_id_to_master[i].master);
master = infra_mi_id_to_master[i].master;
}
}
return master;
}
static const char *peri_mi_trans(uint32_t bus_id)
{
int master_count = ARRAY_SIZE(peri_mi_id_to_master);
const char *master = "UNKNOWN_MASTER_FROM_PERI";
int i, j;
if ((bus_id & 0x3) == 0x0)
return infra_mi_trans(bus_id >> 2);
else if ((bus_id & 0x3) == 0x2)
return "MD_AP_M";
else if ((bus_id & 0x3) == 0x3)
return "AP_DMA_M";
bus_id = bus_id >> 2;
for (i = 0 ; i < master_count; i++) {
for (j = 0 ; j < PERIAXI_MI_BIT_LENGTH ; j++) {
if (peri_mi_id_to_master[i].bit[j] == 2)
continue;
if (((bus_id >> j) & 0x1) ==
peri_mi_id_to_master[i].bit[j])
continue;
break;
}
if (j == PERIAXI_MI_BIT_LENGTH) {
pr_debug(PFX "%s %s %s\n",
"catch it from PERIAXI_MI.",
"Master is:",
peri_mi_id_to_master[i].master);
master = peri_mi_id_to_master[i].master;
}
}
return master;
}
static const char *mt6873_bus_id_to_master(uint32_t bus_id, uint32_t vio_addr,
int slave_type, int shift_sta_bit, int domain)
{
uint8_t h_1byte;
pr_debug(PFX "[DEVAPC] %s:0x%x, %s:0x%x, %s:0x%x, %s:%d\n",
"bus_id", bus_id, "vio_addr", vio_addr,
"slave_type", slave_type,
"shift_sta_bit", shift_sta_bit);
if (bus_id == 0x0 && vio_addr == 0x0)
return NULL;
h_1byte = (vio_addr >> 24) & 0xFF;
if ((vio_addr >= TINYSYS_START_ADDR && vio_addr <= TINYSYS_END_ADDR) ||
(vio_addr >= MD_START_ADDR && vio_addr <= MD_END_ADDR)) {
pr_info(PFX "[DEVAPC] bus_id might be wrong\n");
if (domain == 0x1)
return "SSPM";
else if (domain == 0x2)
return "CONNSYS";
} else if (vio_addr >= CONN_START_ADDR && vio_addr <= CONN_END_ADDR) {
pr_info(PFX "[DEVAPC] bus_id might be wrong\n");
if (domain == 0x1)
return "MD";
else if (domain == 0x2)
return "ADSP";
}
if (slave_type == SLAVE_TYPE_INFRA) {
if (vio_addr <= 0x1FFFFF) {
pr_info(PFX "vio_addr is from on-chip SRAMROM\n");
if ((bus_id & 0x1) == 0)
return "EMI_L2C_M";
return infra_mi_trans(bus_id >> 1);
} else if (shift_sta_bit == 3) {
if ((bus_id & 0x1) == 0)
return "EMI_L2C_M";
return infra_mi_trans(bus_id >> 1);
} else if (shift_sta_bit == 4) {
if ((bus_id & 0x1) == 1)
return "GCE_M";
return infra_mi_trans(bus_id >> 1);
}
return infra_mi_trans(bus_id);
} else if (slave_type == SLAVE_TYPE_PERI) {
if ((h_1byte >= 0x14 && h_1byte < 0x18) ||
(h_1byte >= 0x1A && h_1byte < 0x1C) ||
(h_1byte >= 0x1F && h_1byte < 0x20)) {
pr_info(PFX "vio addr is from MM 2nd\n");
if ((bus_id & 0x1) == 1)
return "GCE_M";
return infra_mi_trans(bus_id >> 1);
}
if (shift_sta_bit == 3 || shift_sta_bit == 4 ||
shift_sta_bit == 8) {
if ((bus_id & 0x1) == 0)
return "MD_AP_M";
return peri_mi_trans(bus_id >> 1);
}
return peri_mi_trans(bus_id);
} else if (slave_type == SLAVE_TYPE_PERI2) {
return peri_mi_trans(bus_id);
} else if (slave_type == SLAVE_TYPE_PERI_PAR) {
return peri_mi_trans(bus_id);
}
return "UNKNOWN_MASTER";
}
/* violation index corresponds to subsys */
const char *index_to_subsys(int slave_type, uint32_t vio_index,
uint32_t vio_addr)
{
int i;
/* Filter by violation address */
if ((vio_addr & 0xFF000000) == CONN_START_ADDR)
return "CONNSYS";
/* Filter by violation index */
if (slave_type == SLAVE_TYPE_INFRA &&
vio_index < VIO_SLAVE_NUM_INFRA) {
for (i = 0; i < VIO_SLAVE_NUM_INFRA; i++) {
if (vio_index == mt6873_devices_infra[i].vio_index)
return mt6873_devices_infra[i].device;
}
} else if (slave_type == SLAVE_TYPE_PERI &&
vio_index < VIO_SLAVE_NUM_PERI)
for (i = 0; i < VIO_SLAVE_NUM_PERI; i++) {
if (vio_index == mt6873_devices_peri[i].vio_index)
return mt6873_devices_peri[i].device;
}
else if (slave_type == SLAVE_TYPE_PERI2 &&
vio_index < VIO_SLAVE_NUM_PERI2)
for (i = 0; i < VIO_SLAVE_NUM_PERI2; i++) {
if (vio_index == mt6873_devices_peri2[i].vio_index)
return mt6873_devices_peri2[i].device;
}
else if (slave_type == SLAVE_TYPE_PERI_PAR &&
vio_index < VIO_SLAVE_NUM_PERI_PAR)
for (i = 0; i < VIO_SLAVE_NUM_PERI_PAR; i++) {
if (vio_index == mt6873_devices_peri_par[i].vio_index)
return mt6873_devices_peri_par[i].device;
}
return "OUT_OF_BOUND";
}
static void mm2nd_vio_handler(void __iomem *infracfg,
struct mtk_devapc_vio_info *vio_info,
bool mdp_vio, bool disp2_vio, bool mmsys_vio)
{
uint32_t vio_sta, vio_dbg, rw;
uint32_t vio_sta_num;
uint32_t vio0_offset;
char mm_str[64] = {0};
void __iomem *reg;
int i;
if (!infracfg) {
pr_err(PFX "%s, param check failed, infracfg ptr is NULL\n",
__func__);
return;
}
if (mdp_vio) {
vio_sta_num = INFRACFG_MDP_VIO_STA_NUM;
vio0_offset = INFRACFG_MDP_SEC_VIO0_OFFSET;
strncpy(mm_str, "INFRACFG_MDP_SEC_VIO",
sizeof("INFRACFG_MDP_SEC_VIO"));
} else if (mmsys_vio) {
vio_sta_num = INFRACFG_MM_VIO_STA_NUM;
vio0_offset = INFRACFG_MM_SEC_VIO0_OFFSET;
strncpy(mm_str, "INFRACFG_MM_SEC_VIO",
sizeof("INFRACFG_MM_SEC_VIO"));
} else {
pr_err(PFX "%s: param check failed, %s:%s, %s:%s, %s:%s\n",
__func__,
"mdp_vio", mdp_vio ? "true" : "false",
"disp2_vio", disp2_vio ? "true" : "false",
"mmsys_vio", mmsys_vio ? "true" : "false");
return;
}
/* Get mm2nd violation status */
for (i = 0; i < vio_sta_num; i++) {
reg = infracfg + vio0_offset + i * 4;
vio_sta = readl(reg);
if (vio_sta)
pr_info(PFX "MM 2nd violation: %s%d:0x%x\n",
mm_str, i, vio_sta);
}
/* Get mm2nd violation address */
reg = infracfg + vio0_offset + i * 4;
vio_info->vio_addr = readl(reg);
/* Get mm2nd violation information */
reg = infracfg + vio0_offset + (i + 1) * 4;
vio_dbg = readl(reg);
vio_info->domain_id = (vio_dbg & INFRACFG_MM2ND_VIO_DOMAIN_MASK) >>
INFRACFG_MM2ND_VIO_DOMAIN_SHIFT;
vio_info->master_id = (vio_dbg & INFRACFG_MM2ND_VIO_ID_MASK) >>
INFRACFG_MM2ND_VIO_ID_SHIFT;
rw = (vio_dbg & INFRACFG_MM2ND_VIO_RW_MASK) >>
INFRACFG_MM2ND_VIO_RW_SHIFT;
vio_info->read = (rw == 0);
vio_info->write = (rw == 1);
}
static uint32_t mt6873_shift_group_get(int slave_type, uint32_t vio_idx)
{
if (slave_type == SLAVE_TYPE_INFRA) {
if ((vio_idx >= 0 && vio_idx <= 8) || vio_idx == 355)
return 0;
else if ((vio_idx >= 9 && vio_idx <= 14) || vio_idx == 356)
return 1;
else if ((vio_idx >= 15 && vio_idx <= 19) || vio_idx == 357)
return 2;
else if ((vio_idx >= 20 && vio_idx <= 21) || vio_idx == 358)
return 3;
else if (vio_idx >= 22 && vio_idx <= 347)
return 4;
else if ((vio_idx >= 348 && vio_idx <= 354) ||
(vio_idx >= 359 && vio_idx <= 365) ||
vio_idx == 366)
return 5;
pr_err(PFX "%s:%d Wrong vio_idx:0x%x\n",
__func__, __LINE__, vio_idx);
} else if (slave_type == SLAVE_TYPE_PERI) {
if (vio_idx >= 0 && vio_idx <= 4)
return 0;
else if (vio_idx >= 5 && vio_idx <= 6)
return 1;
else if ((vio_idx >= 7 && vio_idx <= 38) || vio_idx == 187 ||
(vio_idx >= 188 && vio_idx <= 219) ||
vio_idx == 286)
return 2;
else if ((vio_idx >= 39 && vio_idx <= 61) || vio_idx == 220)
return 3;
else if ((vio_idx >= 62 && vio_idx <= 72) || vio_idx == 221)
return 4;
else if ((vio_idx >= 73 && vio_idx <= 74) || vio_idx == 222)
return 5;
else if (vio_idx == 75 || vio_idx == 223)
return 6;
else if ((vio_idx >= 76 && vio_idx <= 118) || vio_idx == 224)
return 7;
else if ((vio_idx >= 119 && vio_idx <= 121) || vio_idx == 225)
return 8;
if (vio_idx >= 122 && vio_idx <= 125)
return 9;
else if (vio_idx == 126 || (vio_idx >= 226 && vio_idx <= 227) ||
vio_idx == 287)
return 10;
if (vio_idx >= 127 && vio_idx <= 128)
return 11;
if (vio_idx >= 129 && vio_idx <= 130)
return 12;
else if ((vio_idx >= 131 && vio_idx <= 141) ||
(vio_idx >= 228 && vio_idx <= 238) ||
vio_idx == 288)
return 13;
else if ((vio_idx >= 142 && vio_idx <= 143) ||
(vio_idx >= 239 && vio_idx <= 240) ||
vio_idx == 289)
return 14;
else if ((vio_idx >= 144 && vio_idx <= 173) || vio_idx == 241 ||
(vio_idx >= 242 && vio_idx <= 271) ||
vio_idx == 290)
return 15;
else if ((vio_idx >= 174 && vio_idx <= 186) || vio_idx == 272 ||
(vio_idx >= 273 && vio_idx <= 285) ||
vio_idx == 291)
return 16;
pr_err(PFX "%s:%d Wrong vio_idx:0x%x\n",
__func__, __LINE__, vio_idx);
} else if (slave_type == SLAVE_TYPE_PERI2) {
if ((vio_idx >= 0 && vio_idx <= 12) || vio_idx == 117 ||
(vio_idx >= 118 && vio_idx <= 130) ||
vio_idx == 234)
return 0;
else if (vio_idx >= 13 && vio_idx <= 16)
return 1;
else if (vio_idx >= 17 && vio_idx <= 20)
return 2;
else if ((vio_idx >= 21 && vio_idx <= 36) || vio_idx == 131 ||
(vio_idx >= 132 && vio_idx <= 147) ||
vio_idx == 235)
return 3;
else if ((vio_idx >= 37 && vio_idx <= 44) || vio_idx == 148 ||
(vio_idx >= 149 && vio_idx <= 156) ||
vio_idx == 236)
return 4;
else if ((vio_idx >= 45 && vio_idx <= 60) || vio_idx == 157 ||
(vio_idx >= 158 && vio_idx <= 173) ||
vio_idx == 237)
return 5;
else if ((vio_idx >= 61 && vio_idx <= 76) || vio_idx == 174 ||
(vio_idx >= 175 && vio_idx <= 190) ||
vio_idx == 238)
return 6;
else if ((vio_idx >= 77 && vio_idx <= 84) || vio_idx == 191 ||
(vio_idx >= 192 && vio_idx <= 199) ||
vio_idx == 239)
return 7;
else if ((vio_idx >= 85 && vio_idx <= 105) || vio_idx == 200 ||
(vio_idx >= 201 && vio_idx <= 221) ||
vio_idx == 240)
return 8;
else if ((vio_idx >= 106 && vio_idx <= 116) || vio_idx == 222 ||
(vio_idx >= 223 && vio_idx <= 233) ||
vio_idx == 241)
return 9;
pr_err(PFX "%s:%d Wrong vio_idx:0x%x\n",
__func__, __LINE__, vio_idx);
} else if (slave_type == SLAVE_TYPE_PERI_PAR) {
if ((vio_idx >= 0 && vio_idx <= 23) || vio_idx == 27 ||
(vio_idx >= 28 && vio_idx <= 51) ||
vio_idx == 56)
return 0;
else if ((vio_idx >= 24 && vio_idx <= 26) || vio_idx == 52 ||
(vio_idx >= 53 && vio_idx <= 55) ||
vio_idx == 57)
return 1;
pr_err(PFX "%s:%d Wrong vio_idx:0x%x\n",
__func__, __LINE__, vio_idx);
} else {
pr_err(PFX "%s:%d Wrong slave_type:0x%x\n",
__func__, __LINE__, slave_type);
}
return 31;
}
void devapc_catch_illegal_range(phys_addr_t phys_addr, size_t size)
{
/*
* Catch BROM addr mapped
*/
if (phys_addr >= 0x0 && phys_addr < SRAM_START_ADDR) {
pr_err(PFX "%s: %s %s:(%pa), %s:(0x%lx)\n",
"catch BROM address mapped!",
__func__, "phys_addr", &phys_addr,
"size", size);
BUG_ON(1);
}
}
EXPORT_SYMBOL(devapc_catch_illegal_range);
static struct mtk_devapc_dbg_status mt6873_devapc_dbg_stat = {
.enable_ut = PLAT_DBG_UT_DEFAULT,
.enable_KE = PLAT_DBG_KE_DEFAULT,
.enable_AEE = PLAT_DBG_AEE_DEFAULT,
.enable_WARN = PLAT_DBG_WARN_DEFAULT,
.enable_dapc = PLAT_DBG_DAPC_DEFAULT,
};
static const char * const slave_type_to_str[] = {
"SLAVE_TYPE_INFRA",
"SLAVE_TYPE_PERI",
"SLAVE_TYPE_PERI2",
"SLAVE_TYPE_PERI_PAR",
"WRONG_SLAVE_TYPE",
};
static int mtk_vio_mask_sta_num[] = {
VIO_MASK_STA_NUM_INFRA,
VIO_MASK_STA_NUM_PERI,
VIO_MASK_STA_NUM_PERI2,
VIO_MASK_STA_NUM_PERI_PAR,
};
static struct mtk_devapc_vio_info mt6873_devapc_vio_info = {
.vio_mask_sta_num = mtk_vio_mask_sta_num,
.sramrom_vio_idx = SRAMROM_VIO_INDEX,
.mdp_vio_idx = MDP_VIO_INDEX,
.disp2_vio_idx = MDP_VIO_INDEX,
.mmsys_vio_idx = MMSYS_VIO_INDEX,
.sramrom_slv_type = SRAMROM_SLAVE_TYPE,
.mm2nd_slv_type = MM2ND_SLAVE_TYPE,
};
static const struct mtk_infra_vio_dbg_desc mt6873_vio_dbgs = {
.vio_dbg_mstid = INFRA_VIO_DBG_MSTID,
.vio_dbg_mstid_start_bit = INFRA_VIO_DBG_MSTID_START_BIT,
.vio_dbg_dmnid = INFRA_VIO_DBG_DMNID,
.vio_dbg_dmnid_start_bit = INFRA_VIO_DBG_DMNID_START_BIT,
.vio_dbg_w_vio = INFRA_VIO_DBG_W_VIO,
.vio_dbg_w_vio_start_bit = INFRA_VIO_DBG_W_VIO_START_BIT,
.vio_dbg_r_vio = INFRA_VIO_DBG_R_VIO,
.vio_dbg_r_vio_start_bit = INFRA_VIO_DBG_R_VIO_START_BIT,
.vio_addr_high = INFRA_VIO_ADDR_HIGH,
.vio_addr_high_start_bit = INFRA_VIO_ADDR_HIGH_START_BIT,
};
static const struct mtk_sramrom_sec_vio_desc mt6873_sramrom_sec_vios = {
.vio_id_mask = SRAMROM_SEC_VIO_ID_MASK,
.vio_id_shift = SRAMROM_SEC_VIO_ID_SHIFT,
.vio_domain_mask = SRAMROM_SEC_VIO_DOMAIN_MASK,
.vio_domain_shift = SRAMROM_SEC_VIO_DOMAIN_SHIFT,
.vio_rw_mask = SRAMROM_SEC_VIO_RW_MASK,
.vio_rw_shift = SRAMROM_SEC_VIO_RW_SHIFT,
};
static const uint32_t mt6873_devapc_pds[] = {
PD_VIO_MASK_OFFSET,
PD_VIO_STA_OFFSET,
PD_VIO_DBG0_OFFSET,
PD_VIO_DBG1_OFFSET,
PD_VIO_DBG2_OFFSET,
PD_APC_CON_OFFSET,
PD_SHIFT_STA_OFFSET,
PD_SHIFT_SEL_OFFSET,
PD_SHIFT_CON_OFFSET,
};
static struct mtk_devapc_soc mt6873_data = {
.dbg_stat = &mt6873_devapc_dbg_stat,
.slave_type_arr = slave_type_to_str,
.slave_type_num = SLAVE_TYPE_NUM,
.device_info[SLAVE_TYPE_INFRA] = mt6873_devices_infra,
.device_info[SLAVE_TYPE_PERI] = mt6873_devices_peri,
.device_info[SLAVE_TYPE_PERI2] = mt6873_devices_peri2,
.device_info[SLAVE_TYPE_PERI_PAR] = mt6873_devices_peri_par,
.ndevices = mtk6873_devices_num,
.vio_info = &mt6873_devapc_vio_info,
.vio_dbgs = &mt6873_vio_dbgs,
.sramrom_sec_vios = &mt6873_sramrom_sec_vios,
.devapc_pds = mt6873_devapc_pds,
.subsys_get = &index_to_subsys,
.master_get = &mt6873_bus_id_to_master,
.mm2nd_vio_handler = &mm2nd_vio_handler,
.shift_group_get = mt6873_shift_group_get,
};
static const struct of_device_id mt6873_devapc_dt_match[] = {
{ .compatible = "mediatek,mt6873-devapc" },
{},
};
static int mt6873_devapc_probe(struct platform_device *pdev)
{
return mtk_devapc_probe(pdev, &mt6873_data);
}
static int mt6873_devapc_remove(struct platform_device *dev)
{
return mtk_devapc_remove(dev);
}
static struct platform_driver mt6873_devapc_driver = {
.probe = mt6873_devapc_probe,
.remove = mt6873_devapc_remove,
.driver = {
.name = KBUILD_MODNAME,
.of_match_table = mt6873_devapc_dt_match,
},
};
module_platform_driver(mt6873_devapc_driver);
MODULE_DESCRIPTION("Mediatek MT6873 Device APC Driver");
MODULE_AUTHOR("Neal Liu <neal.liu@mediatek.com>");
MODULE_LICENSE("GPL");
File diff suppressed because it is too large. Load diff
+599
View File
@@ -0,0 +1,599 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2021 MediaTek Inc.
*/
#include <linux/bug.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <asm-generic/io.h>
#include "devapc-mt6877.h"
static struct mtk_device_num mtk6877_devices_num[] = {
{SLAVE_TYPE_INFRA, VIO_SLAVE_NUM_INFRA},
{SLAVE_TYPE_PERI, VIO_SLAVE_NUM_PERI},
{SLAVE_TYPE_PERI2, VIO_SLAVE_NUM_PERI2},
{SLAVE_TYPE_PERI_PAR, VIO_SLAVE_NUM_PERI_PAR},
};
static struct PERIAXI_ID_INFO peri_mi_id_to_master[] = {
{"THERM", { 0, 1, 1 } },
{"SPM", { 0, 1, 0 } },
{"CCU", { 0, 0, 1 } },
{"THERM2", { 0, 0, 0 } },
{"SPM", { 1, 2, 2 } },
};
static struct INFRAAXI_ID_INFO infra_mi_id_to_master[] = {
{"CONNSYS", { 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 } },
{"Tinysys", { 0, 1, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0 } },
{"CQ_DMA", { 0, 0, 1, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0 } },
{"DebugTop", { 0, 0, 1, 0, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0 } },
{"IPU", { 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 2, 2, 0, 0 } },
{"SSUSB", { 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 2, 2 } },
{"SSUSB2", { 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 2, 2 } },
{"SPI6", { 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 2, 2 } },
{"SPI0", { 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 2, 2 } },
{"MSDC1", { 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 2, 2 } },
{"PWM", { 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 2, 2 } },
{"HWCCF", { 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 2, 2 } },
{"MSDC0", { 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 2, 2 } },
{"SPI5", { 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 2, 2 } },
{"SPI4", { 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 2, 2 } },
{"SPI3", { 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 2, 2 } },
{"SPI2", { 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 2, 2 } },
{"SPI7", { 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 2, 2 } },
{"SPI1", { 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 2, 2 } },
{"Audio", { 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 2, 2 } },
{"AP_DMA_EXT", { 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 2, 2, 2, 0 } },
{"THERM", { 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 2, 2, 0, 0 } },
{"SPM", { 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 2, 2, 0, 0 } },
{"CCU", { 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 2, 2, 0, 0 } },
{"THERM2", { 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 2, 2, 0, 0 } },
{"DX_CC", { 0, 0, 1, 0, 1, 1, 0, 2, 2, 2, 2, 0, 0, 0 } },
{"GCE", { 0, 0, 1, 0, 0, 0, 1, 2, 2, 0, 0, 0, 0, 0 } },
{"CPUEB", { 0, 0, 1, 0, 1, 0, 1, 2, 2, 2, 2, 2, 2, 0 } },
{"DPMAIF", { 0, 1, 1, 0, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0 } },
{"SCP_SSPM", { 0, 0, 0, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0 } },
{"UFS", { 0, 1, 0, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0 } },
{"CPUEB_2", { 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0 } },
{"MFG_M0_M", { 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0 } },
{"APMCU_Write", { 1, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
{"APMCU_Write", { 1, 2, 2, 2, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0 } },
{"APMCU_Write", { 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0 } },
{"APMCU_Read", { 1, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
{"APMCU_Read", { 1, 2, 2, 2, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0 } },
{"APMCU_Read", { 1, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 } },
{"APMCU_Read", { 1, 2, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 } },
{"APMCU_Read", { 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0 } },
{"APMCU_Read", { 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0 } },
};
static const char *infra_mi_trans(uint32_t bus_id)
{
int master_count = ARRAY_SIZE(infra_mi_id_to_master);
const char *master = "UNKNOWN_MASTER_FROM_INFRA";
int i, j;
for (i = 0; i < master_count; i++) {
for (j = 0; j < INFRAAXI_MI_BIT_LENGTH; j++) {
if (infra_mi_id_to_master[i].bit[j] == 2)
continue;
if (((bus_id >> j) & 0x1) ==
infra_mi_id_to_master[i].bit[j])
continue;
break;
}
if (j == INFRAAXI_MI_BIT_LENGTH) {
pr_debug(PFX "%s %s %s\n",
"catch it from INFRAAXI_MI",
"Master is:",
infra_mi_id_to_master[i].master);
master = infra_mi_id_to_master[i].master;
}
}
return master;
}
static const char *peri_mi_trans(uint32_t bus_id)
{
int master_count = ARRAY_SIZE(peri_mi_id_to_master);
const char *master = "UNKNOWN_MASTER_FROM_PERI";
int i, j;
if ((bus_id & 0x3) == 0x0)
return infra_mi_trans(bus_id >> 2);
else if ((bus_id & 0x3) == 0x2)
return "MD_AP_M";
else if ((bus_id & 0x3) == 0x3)
return "AP_DMA_M";
bus_id = bus_id >> 2;
for (i = 0 ; i < master_count; i++) {
for (j = 0 ; j < PERIAXI_MI_BIT_LENGTH ; j++) {
if (peri_mi_id_to_master[i].bit[j] == 2)
continue;
if (((bus_id >> j) & 0x1) ==
peri_mi_id_to_master[i].bit[j])
continue;
break;
}
if (j == PERIAXI_MI_BIT_LENGTH) {
pr_debug(PFX "%s %s %s\n",
"catch it from PERIAXI_MI.",
"Master is:",
peri_mi_id_to_master[i].master);
master = peri_mi_id_to_master[i].master;
}
}
return master;
}
static const char *mt6877_bus_id_to_master(uint32_t bus_id, uint32_t vio_addr,
int slave_type, int shift_sta_bit, int domain)
{
const char *err_master = "UNKNOWN_MASTER";
uint8_t h_1byte;
pr_debug(PFX "%s:0x%x, %s:0x%x, %s:0x%x, %s:%d\n",
"bus_id", bus_id, "vio_addr", vio_addr,
"slave_type", slave_type,
"shift_sta_bit", shift_sta_bit);
h_1byte = (vio_addr >> 24) & 0xFF;
if ((vio_addr >= TINYSYS_START_ADDR && vio_addr <= TINYSYS_END_ADDR) ||
(vio_addr >= MD_START_ADDR && vio_addr <= MD_END_ADDR)) {
pr_info(PFX "[DEVAPC] bus_id might be wrong\n");
if (domain == 0x1)
return "SSPM";
else if (domain == 0x2)
return "CONNSYS";
} else if (vio_addr >= CONN_START_ADDR && vio_addr <= CONN_END_ADDR) {
pr_info(PFX "[DEVAPC] bus_id might be wrong\n");
if (domain == 0x1)
return "MD";
else if (domain == 0x2)
return "ADSP";
}
if (slave_type == SLAVE_TYPE_INFRA) {
if (vio_addr <= 0x1FFFFF || shift_sta_bit == 7) {
pr_info(PFX "vio_addr is from on-chip SRAMROM\n");
if ((bus_id & 0x1) == 0)
return "EMI_L2C_M";
return infra_mi_trans(bus_id >> 1);
} else if (shift_sta_bit >= 0 && shift_sta_bit <= 3) {
return peri_mi_trans(bus_id);
} else if (shift_sta_bit >= 4 && shift_sta_bit <= 6) {
return infra_mi_trans(bus_id);
} else if (shift_sta_bit == 8) {
pr_info(PFX "vio_addr is from MMSYS_MALI\n");
if ((bus_id & 0x1) == 1)
return "GCE_M";
return infra_mi_trans(bus_id >> 1);
}
return err_master;
} else if (slave_type == SLAVE_TYPE_PERI) {
if (shift_sta_bit == 1 || shift_sta_bit == 2 ||
shift_sta_bit == 5) {
if ((bus_id & 0x1) == 0)
return "MD_AP_M";
return peri_mi_trans(bus_id >> 1);
}
return peri_mi_trans(bus_id);
} else if (slave_type == SLAVE_TYPE_PERI2) {
return peri_mi_trans(bus_id);
} else if (slave_type == SLAVE_TYPE_PERI_PAR) {
return peri_mi_trans(bus_id);
}
return err_master;
}
/* violation index corresponds to subsys */
const char *index_to_subsys(int slave_type, uint32_t vio_index,
uint32_t vio_addr)
{
int i;
/* Filter by violation address */
if ((vio_addr & 0xFF000000) == CONN_START_ADDR)
return "CONNSYS";
/* Filter by violation index */
if (slave_type == SLAVE_TYPE_INFRA &&
vio_index < VIO_SLAVE_NUM_INFRA) {
for (i = 0; i < VIO_SLAVE_NUM_INFRA; i++) {
if (vio_index == mt6877_devices_infra[i].vio_index)
return mt6877_devices_infra[i].device;
}
} else if (slave_type == SLAVE_TYPE_PERI &&
vio_index < VIO_SLAVE_NUM_PERI)
for (i = 0; i < VIO_SLAVE_NUM_PERI; i++) {
if (vio_index == mt6877_devices_peri[i].vio_index)
return mt6877_devices_peri[i].device;
}
else if (slave_type == SLAVE_TYPE_PERI2 &&
vio_index < VIO_SLAVE_NUM_PERI2)
for (i = 0; i < VIO_SLAVE_NUM_PERI2; i++) {
if (vio_index == mt6877_devices_peri2[i].vio_index)
return mt6877_devices_peri2[i].device;
}
else if (slave_type == SLAVE_TYPE_PERI_PAR &&
vio_index < VIO_SLAVE_NUM_PERI_PAR)
for (i = 0; i < VIO_SLAVE_NUM_PERI_PAR; i++) {
if (vio_index == mt6877_devices_peri_par[i].vio_index)
return mt6877_devices_peri_par[i].device;
}
return "OUT_OF_BOUND";
}
static void mm2nd_vio_handler(void __iomem *infracfg,
struct mtk_devapc_vio_info *vio_info,
bool mdp_vio, bool disp2_vio, bool mmsys_vio)
{
uint32_t vio_sta, vio_dbg, rw;
uint32_t vio_sta_num;
uint32_t vio0_offset;
char mm_str[64] = {0};
void __iomem *reg;
int i;
if (!infracfg) {
pr_err(PFX "%s, param check failed, infracfg ptr is NULL\n",
__func__);
return;
}
if (mdp_vio) {
vio_sta_num = INFRACFG_MDP_VIO_STA_NUM;
vio0_offset = INFRACFG_MDP_SEC_VIO0_OFFSET;
strncpy(mm_str, "INFRACFG_MDP_SEC_VIO", sizeof(mm_str));
} else if (mmsys_vio) {
vio_sta_num = INFRACFG_MM_VIO_STA_NUM;
vio0_offset = INFRACFG_MM_SEC_VIO0_OFFSET;
strncpy(mm_str, "INFRACFG_MM_SEC_VIO", sizeof(mm_str));
} else {
pr_err(PFX "%s: param check failed, %s:%s, %s:%s, %s:%s\n",
__func__,
"mdp_vio", mdp_vio ? "true" : "false",
"disp2_vio", disp2_vio ? "true" : "false",
"mmsys_vio", mmsys_vio ? "true" : "false");
return;
}
/* Get mm2nd violation status */
for (i = 0; i < vio_sta_num; i++) {
reg = infracfg + vio0_offset + i * 4;
vio_sta = readl(reg);
if (vio_sta)
pr_info(PFX "MM 2nd violation: %s%d:0x%x\n",
mm_str, i, vio_sta);
}
/* Get mm2nd violation address */
reg = infracfg + vio0_offset + i * 4;
vio_info->vio_addr = readl(reg);
/* Get mm2nd violation information */
reg = infracfg + vio0_offset + (i + 1) * 4;
vio_dbg = readl(reg);
vio_info->domain_id = (vio_dbg & INFRACFG_MM2ND_VIO_DOMAIN_MASK) >>
INFRACFG_MM2ND_VIO_DOMAIN_SHIFT;
vio_info->master_id = (vio_dbg & INFRACFG_MM2ND_VIO_ID_MASK) >>
INFRACFG_MM2ND_VIO_ID_SHIFT;
rw = (vio_dbg & INFRACFG_MM2ND_VIO_RW_MASK) >>
INFRACFG_MM2ND_VIO_RW_SHIFT;
vio_info->read = (rw == 0);
vio_info->write = (rw == 1);
}
static uint32_t mt6877_shift_group_get(int slave_type, uint32_t vio_idx)
{
if (slave_type == SLAVE_TYPE_INFRA) {
if (vio_idx <= 3)
return 0;
else if (vio_idx >= 4 && vio_idx <= 5)
return 1;
else if ((vio_idx >= 6 && vio_idx <= 31) ||
(vio_idx >= 416 && vio_idx <= 442) ||
vio_idx == 462)
return 2;
else if ((vio_idx >= 32 && vio_idx <= 45) ||
(vio_idx >= 443 && vio_idx <= 457) ||
vio_idx == 463)
return 3;
else if ((vio_idx >= 46 && vio_idx <= 74) ||
vio_idx == 458)
return 4;
else if ((vio_idx >= 75 && vio_idx <= 82) ||
vio_idx == 459)
return 5;
else if ((vio_idx >= 83 && vio_idx <= 87) ||
vio_idx == 460)
return 6;
else if ((vio_idx >= 88 && vio_idx <= 90) ||
vio_idx == 461)
return 7;
else if (vio_idx >= 91 && vio_idx <= 415)
return 8;
pr_err(PFX "%s:%d Wrong vio_idx:0x%x\n",
__func__, __LINE__, vio_idx);
} else if (slave_type == SLAVE_TYPE_PERI) {
if ((vio_idx <= 2) ||
(vio_idx >= 125 && vio_idx <= 128) ||
vio_idx == 175)
return 0;
else if ((vio_idx >= 3 && vio_idx <= 25) ||
vio_idx == 129)
return 1;
else if ((vio_idx >= 26 && vio_idx <= 36) ||
vio_idx == 130)
return 2;
else if ((vio_idx >= 37 && vio_idx <= 38) ||
vio_idx == 131)
return 3;
else if ((vio_idx >= 39 && vio_idx <= 81) ||
vio_idx == 132)
return 4;
else if ((vio_idx >= 82 && vio_idx <= 84) ||
vio_idx == 133)
return 5;
else if (vio_idx == 85 ||
(vio_idx >= 134 && vio_idx <= 135) ||
vio_idx == 176)
return 6;
else if (vio_idx >= 86 && vio_idx <= 87)
return 7;
else if ((vio_idx >= 88 && vio_idx <= 97) ||
(vio_idx >= 136 && vio_idx <= 145) ||
vio_idx == 177)
return 8;
else if ((vio_idx >= 98 && vio_idx <= 112) ||
(vio_idx >= 146 && vio_idx <= 161) ||
vio_idx == 178)
return 9;
else if ((vio_idx >= 113 && vio_idx <= 124) ||
(vio_idx >= 162 && vio_idx <= 174) ||
vio_idx == 179)
return 10;
pr_err(PFX "%s:%d Wrong vio_idx:0x%x\n",
__func__, __LINE__, vio_idx);
} else if (slave_type == SLAVE_TYPE_PERI2) {
if ((vio_idx <= 2) ||
(vio_idx >= 108 && vio_idx <= 111) ||
vio_idx == 216)
return 0;
else if (vio_idx >= 3 && vio_idx <= 6)
return 1;
else if (vio_idx >= 7 && vio_idx <= 10)
return 2;
else if ((vio_idx >= 11 && vio_idx <= 26) ||
(vio_idx >= 112 && vio_idx <= 128) ||
vio_idx == 217)
return 3;
else if ((vio_idx >= 27 && vio_idx <= 34) ||
(vio_idx >= 129 && vio_idx <= 137) ||
vio_idx == 218)
return 4;
else if ((vio_idx >= 35 && vio_idx <= 50) ||
(vio_idx >= 138 && vio_idx <= 154) ||
vio_idx == 219)
return 5;
else if ((vio_idx >= 51 && vio_idx <= 66) ||
(vio_idx >= 155 && vio_idx <= 171) ||
vio_idx == 220)
return 6;
else if ((vio_idx >= 67 && vio_idx <= 74) ||
(vio_idx >= 172 && vio_idx <= 180) ||
vio_idx == 221)
return 7;
else if ((vio_idx >= 75 && vio_idx <= 94) ||
(vio_idx >= 181 && vio_idx <= 201) ||
vio_idx == 222)
return 8;
else if ((vio_idx >= 95 && vio_idx <= 107) ||
(vio_idx >= 202 && vio_idx <= 215) ||
vio_idx == 223)
return 9;
pr_err(PFX "%s:%d Wrong vio_idx:0x%x\n",
__func__, __LINE__, vio_idx);
} else if (slave_type == SLAVE_TYPE_PERI_PAR) {
if (vio_idx <= 3)
return 0;
else if ((vio_idx >= 4 && vio_idx <= 6) ||
(vio_idx >= 32 && vio_idx <= 34) ||
vio_idx == 62)
return 1;
else if ((vio_idx >= 7 && vio_idx <= 28) ||
(vio_idx >= 35 && vio_idx <= 57) ||
vio_idx == 63)
return 2;
else if ((vio_idx >= 29 && vio_idx <= 31) ||
(vio_idx >= 58 && vio_idx <= 61) ||
vio_idx == 64)
return 3;
pr_err(PFX "%s:%d Wrong vio_idx:0x%x\n",
__func__, __LINE__, vio_idx);
}
pr_err(PFX "%s:%d Wrong slave_type:0x%x\n",
__func__, __LINE__, slave_type);
return 31;
}
static struct mtk_devapc_dbg_status mt6877_devapc_dbg_stat = {
.enable_ut = PLAT_DBG_UT_DEFAULT,
.enable_KE = PLAT_DBG_KE_DEFAULT,
.enable_AEE = PLAT_DBG_AEE_DEFAULT,
.enable_WARN = PLAT_DBG_WARN_DEFAULT,
.enable_dapc = PLAT_DBG_DAPC_DEFAULT,
};
void devapc_catch_illegal_range(phys_addr_t phys_addr, size_t size)
{
struct mtk_devapc_dbg_status *dbg_stat = &mt6877_devapc_dbg_stat;
/*
* Catch BROM addr mapped
*/
if (phys_addr >= 0x0 && phys_addr < SRAM_START_ADDR) {
pr_err(PFX "%s: %s %s:(%pa), %s:(0x%lx)\n",
"catch BROM address mapped!",
__func__, "phys_addr", &phys_addr,
"size", size);
if (dbg_stat->enable_KE)
BUG_ON(1);
}
}
EXPORT_SYMBOL(devapc_catch_illegal_range);
static const char * const slave_type_to_str[] = {
"SLAVE_TYPE_INFRA",
"SLAVE_TYPE_PERI",
"SLAVE_TYPE_PERI2",
"SLAVE_TYPE_PERI_PAR",
"WRONG_SLAVE_TYPE",
};
static int mtk_vio_mask_sta_num[] = {
VIO_MASK_STA_NUM_INFRA,
VIO_MASK_STA_NUM_PERI,
VIO_MASK_STA_NUM_PERI2,
VIO_MASK_STA_NUM_PERI_PAR,
};
static struct mtk_devapc_vio_info mt6877_devapc_vio_info = {
.vio_mask_sta_num = mtk_vio_mask_sta_num,
.sramrom_vio_idx = SRAMROM_VIO_INDEX,
.mdp_vio_idx = MDP_VIO_INDEX,
.disp2_vio_idx = MDP_VIO_INDEX,
.mmsys_vio_idx = MMSYS_VIO_INDEX,
.sramrom_slv_type = SRAMROM_SLAVE_TYPE,
.mm2nd_slv_type = MM2ND_SLAVE_TYPE,
};
static const struct mtk_infra_vio_dbg_desc mt6877_vio_dbgs = {
.vio_dbg_mstid = INFRA_VIO_DBG_MSTID,
.vio_dbg_mstid_start_bit = INFRA_VIO_DBG_MSTID_START_BIT,
.vio_dbg_dmnid = INFRA_VIO_DBG_DMNID,
.vio_dbg_dmnid_start_bit = INFRA_VIO_DBG_DMNID_START_BIT,
.vio_dbg_w_vio = INFRA_VIO_DBG_W_VIO,
.vio_dbg_w_vio_start_bit = INFRA_VIO_DBG_W_VIO_START_BIT,
.vio_dbg_r_vio = INFRA_VIO_DBG_R_VIO,
.vio_dbg_r_vio_start_bit = INFRA_VIO_DBG_R_VIO_START_BIT,
.vio_addr_high = INFRA_VIO_ADDR_HIGH,
.vio_addr_high_start_bit = INFRA_VIO_ADDR_HIGH_START_BIT,
};
static const struct mtk_sramrom_sec_vio_desc mt6877_sramrom_sec_vios = {
.vio_id_mask = SRAMROM_SEC_VIO_ID_MASK,
.vio_id_shift = SRAMROM_SEC_VIO_ID_SHIFT,
.vio_domain_mask = SRAMROM_SEC_VIO_DOMAIN_MASK,
.vio_domain_shift = SRAMROM_SEC_VIO_DOMAIN_SHIFT,
.vio_rw_mask = SRAMROM_SEC_VIO_RW_MASK,
.vio_rw_shift = SRAMROM_SEC_VIO_RW_SHIFT,
};
static const uint32_t mt6877_devapc_pds[] = {
PD_VIO_MASK_OFFSET,
PD_VIO_STA_OFFSET,
PD_VIO_DBG0_OFFSET,
PD_VIO_DBG1_OFFSET,
PD_VIO_DBG2_OFFSET,
PD_APC_CON_OFFSET,
PD_SHIFT_STA_OFFSET,
PD_SHIFT_SEL_OFFSET,
PD_SHIFT_CON_OFFSET,
};
static struct mtk_devapc_soc mt6877_data = {
.dbg_stat = &mt6877_devapc_dbg_stat,
.slave_type_arr = slave_type_to_str,
.slave_type_num = SLAVE_TYPE_NUM,
.device_info[SLAVE_TYPE_INFRA] = mt6877_devices_infra,
.device_info[SLAVE_TYPE_PERI] = mt6877_devices_peri,
.device_info[SLAVE_TYPE_PERI2] = mt6877_devices_peri2,
.device_info[SLAVE_TYPE_PERI_PAR] = mt6877_devices_peri_par,
.ndevices = mtk6877_devices_num,
.vio_info = &mt6877_devapc_vio_info,
.vio_dbgs = &mt6877_vio_dbgs,
.sramrom_sec_vios = &mt6877_sramrom_sec_vios,
.devapc_pds = mt6877_devapc_pds,
.subsys_get = &index_to_subsys,
.master_get = &mt6877_bus_id_to_master,
.mm2nd_vio_handler = &mm2nd_vio_handler,
.shift_group_get = mt6877_shift_group_get,
};
static const struct of_device_id mt6877_devapc_dt_match[] = {
{ .compatible = "mediatek,mt6877-devapc" },
{},
};
static int mt6877_devapc_probe(struct platform_device *pdev)
{
return mtk_devapc_probe(pdev, &mt6877_data);
}
static int mt6877_devapc_remove(struct platform_device *dev)
{
return mtk_devapc_remove(dev);
}
static struct platform_driver mt6877_devapc_driver = {
.probe = mt6877_devapc_probe,
.remove = mt6877_devapc_remove,
.driver = {
.name = KBUILD_MODNAME,
.of_match_table = mt6877_devapc_dt_match,
},
};
module_platform_driver(mt6877_devapc_driver);
MODULE_DESCRIPTION("Mediatek MT6877 Device APC Driver");
MODULE_AUTHOR("Jackson Chang <jackson-kt.chang@mediatek.com>");
MODULE_LICENSE("GPL");
File diff suppressed because it is too large. Load diff
+692
View File
@@ -0,0 +1,692 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2019 MediaTek Inc.
*/
#include <linux/bug.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <asm-generic/io.h>
#include "devapc-mt6885.h"
static struct mtk_device_num mtk6885_devices_num[] = {
{SLAVE_TYPE_INFRA, VIO_SLAVE_NUM_INFRA},
{SLAVE_TYPE_PERI, VIO_SLAVE_NUM_PERI},
{SLAVE_TYPE_PERI2, VIO_SLAVE_NUM_PERI2},
};
static struct PERIAXI_ID_INFO peri_mi_id_to_master[] = {
{"THERM2", { 0, 0, 0 } },
{"SPM", { 0, 1, 0 } },
{"CCU", { 0, 0, 1 } },
{"THERM", { 0, 1, 1 } },
{"SPM_DRAMC", { 1, 1, 0 } },
};
static struct INFRAAXI_ID_INFO infra_mi_id_to_master[] = {
{"CONNSYS_WFDMA", { 0, 0, 0, 0, 0, 1, 2, 2, 2, 2, 2, 2, 2 } },
{"CONNSYS_ICAP", { 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2 } },
{"CONNSYS_WF_MCU", { 0, 0, 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2 } },
{"CONNSYS_BT_MCU", { 0, 0, 0, 0, 1, 0, 0, 1, 2, 2, 2, 2, 2 } },
{"CONNSYS_GPS", { 0, 0, 0, 0, 1, 0, 0, 0, 2, 2, 2, 2, 2 } },
{"Tinysys", { 0, 1, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 0 } },
{"GCE_M2", { 0, 0, 1, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0 } },
{"CQ_DMA", { 0, 0, 1, 0, 1, 0, 0, 2, 2, 2, 0, 0, 0 } },
{"DebugTop", { 0, 0, 1, 0, 0, 1, 0, 2, 0, 0, 0, 0, 0 } },
{"SSUSB", { 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 2, 2 } },
{"PWM", { 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0 } },
{"MSDC1", { 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0 } },
{"SPI6", { 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1 } },
{"SPI0", { 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1 } },
{"APU", { 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 2, 2, 0 } },
{"MSDC0", { 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 2, 2, 0 } },
{"SPI2", { 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0 } },
{"SPI3", { 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0 } },
{"SPI4", { 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0 } },
{"SPI5", { 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0 } },
{"SPI7", { 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0 } },
{"Audio", { 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0 } },
{"SPI1", { 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0 } },
{"AP_DMA_EXT", { 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 2, 2, 2 } },
{"THERM2", { 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0 } },
{"SPM", { 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0 } },
{"CCU", { 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0 } },
{"THERM", { 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0 } },
{"DX_CC", { 0, 0, 1, 0, 0, 0, 1, 2, 2, 2, 2, 0, 0 } },
{"GCE_M", { 0, 0, 1, 0, 1, 0, 1, 2, 2, 0, 0, 0, 0 } },
{"DPMAIF", { 0, 1, 1, 0, 2, 2, 2, 2, 0, 0, 0, 0, 0 } },
{"MCUPM", { 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0 } },
{"SSPM", { 0, 1, 0, 1, 2, 2, 2, 0, 0, 0, 0, 0, 0 } },
{"UFS", { 0, 0, 1, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0 } },
{"APMCU_write", { 1, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0 } },
{"APMCU_write", { 1, 2, 2, 2, 2, 0, 0, 1, 0, 0, 0, 0, 0 } },
{"APMCU_write", { 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0 } },
{"APMCU_read", { 1, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0 } },
{"APMCU_read", { 1, 2, 2, 2, 2, 0, 0, 1, 0, 0, 0, 0, 0 } },
{"APMCU_read", { 1, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } },
{"APMCU_read", { 1, 2, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } },
{"APMCU_read", { 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0 } },
{"APMCU_read", { 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0 } },
};
static const char *infra_mi_trans(uint32_t bus_id)
{
int master_count = ARRAY_SIZE(infra_mi_id_to_master);
const char *master = "UNKNOWN_MASTER_FROM_INFRA";
int i, j;
for (i = 0; i < master_count; i++) {
for (j = 0; j < INFRAAXI_MI_BIT_LENGTH; j++) {
if (infra_mi_id_to_master[i].bit[j] == 2)
continue;
if (((bus_id >> j) & 0x1) ==
infra_mi_id_to_master[i].bit[j])
continue;
break;
}
if (j == INFRAAXI_MI_BIT_LENGTH) {
pr_debug(PFX "%s %s %s\n",
"catch it from INFRAAXI_MI",
"Master is:",
infra_mi_id_to_master[i].master);
master = infra_mi_id_to_master[i].master;
}
}
return master;
}
static const char *peri_mi_trans(uint32_t bus_id)
{
int master_count = ARRAY_SIZE(peri_mi_id_to_master);
const char *master = "UNKNOWN_MASTER_FROM_PERI";
int i, j;
if ((bus_id & 0x3) == 0x0)
return infra_mi_trans(bus_id >> 2);
else if ((bus_id & 0x3) == 0x2)
return "MD_AP_M";
else if ((bus_id & 0x3) == 0x3)
return "AP_DMA_M";
for (i = 0 ; i < master_count; i++) {
for (j = 0 ; j < PERIAXI_MI_BIT_LENGTH ; j++) {
if (peri_mi_id_to_master[i].bit[j] == 2)
continue;
if (((bus_id >> j) & 0x1) ==
peri_mi_id_to_master[i].bit[j])
continue;
break;
}
if (j == PERIAXI_MI_BIT_LENGTH) {
pr_debug(PFX "%s %s %s\n",
"catch it from PERIAXI_MI.",
"Master is:",
peri_mi_id_to_master[i].master);
master = peri_mi_id_to_master[i].master;
}
}
return master;
}
static const char *mt6885_bus_id_to_master(uint32_t bus_id, uint32_t vio_addr,
int slave_type, int shift_sta_bit, int domain)
{
uint16_t h_2byte;
uint8_t h_1byte;
UNUSED(slave_type);
UNUSED(shift_sta_bit);
pr_debug(PFX "[DEVAPC] bus_id:0x%x, vio_addr:0x%x\n",
bus_id, vio_addr);
if (bus_id == 0x0 && vio_addr == 0x0)
return NULL;
/* bus only reference bit 0~29 */
vio_addr = vio_addr & 0x3FFFFFFF;
h_1byte = (vio_addr >> 24) & 0xFF;
h_2byte = (vio_addr >> 16) & 0xFFFF;
if ((vio_addr >= TINYSYS_START_ADDR && vio_addr <= TINYSYS_END_ADDR) ||
(vio_addr >= MD_START_ADDR && vio_addr <= MD_END_ADDR)) {
pr_info(PFX "[DEVAPC] bus_id might be wrong\n");
if (domain == 0x1)
return "SSPM";
else if (domain == 0x2)
return "CONNSYS";
} else if (vio_addr >= CONN_START_ADDR && vio_addr <= CONN_END_ADDR) {
pr_info(PFX "[DEVAPC] bus_id might be wrong\n");
if (domain == 0x1)
return "MD";
else if (domain == 0x2)
return "ADSP";
}
if (h_2byte < 0x0C51 || (h_2byte >= 0x0C80 && h_2byte < 0x0CC0)) {
pr_debug(PFX "vio_addr is from L3C or on-chip SRAMROM\n");
if ((bus_id & 0x1) == 1)
return "EMI_L2C_M";
return infra_mi_trans(bus_id >> 1);
} else if (h_1byte == 0x15 || h_1byte == 0x1A || h_1byte == 0x1B ||
h_1byte == 0x1F) {
pr_debug(PFX "vio_addr is from MDP System\n");
if ((bus_id & 0x1) == 0)
return "GCE_M2";
return infra_mi_trans(bus_id >> 1);
} else if (h_2byte >= 0x1410 && h_2byte < 0x1420) {
pr_debug(PFX "vio_addr is from DISP-2 MM System\n");
if ((bus_id & 0x1) == 1)
return "GCE_M";
else if ((bus_id >> 3) == 0)
pr_info(PFX "Master might be %s\n", "GCE_M2");
return infra_mi_trans(bus_id >> 1);
} else if (h_1byte == 0x14 || h_1byte == 0x16 || h_1byte == 0x17) {
pr_debug(PFX "vio_addr is from DISP MM System\n");
if ((bus_id & 0x1) == 1)
return "GCE_M";
return infra_mi_trans(bus_id >> 1);
} else if (h_1byte == 0x13 || h_1byte == 0x19) {
pr_debug(PFX "vio_addr is from APU or GPU\n");
return infra_mi_trans(bus_id);
} else if (h_2byte >= 0x1050 && h_2byte < 0x1090) {
pr_debug(PFX "vio_addr is from Tinysys\n");
if ((bus_id & 0x1) == 0)
return "MD_AP_M";
return peri_mi_trans(bus_id >> 1);
} else if (h_2byte >= 0x1040 && h_2byte < 0x1050) {
pr_debug(PFX "vio_addr is from PWR_MD32\n");
if ((bus_id & 0x1) == 0)
return "MD_AP_M";
return peri_mi_trans(bus_id >> 1);
} else if (h_2byte >= 0x1120 && h_2byte < 0x1121) {
pr_debug(PFX "vio_addr is from SSUSB\n");
if ((bus_id & 0x1) == 0)
return "MD_AP_M";
return peri_mi_trans(bus_id >> 1);
} else {
return peri_mi_trans(bus_id);
}
}
/* violation index corresponds to subsys */
const char *index_to_subsys(int slave_type, uint32_t vio_index,
uint32_t vio_addr)
{
int i;
if (slave_type == SLAVE_TYPE_INFRA &&
vio_index < VIO_SLAVE_NUM_INFRA) {
/* check violation address */
if (vio_addr >= MFG_START_ADDR && vio_addr <= MFG_END_ADDR)
return "MFGSYS";
/* check violation index */
if (vio_index == SMI_LARB0_VIO_INDEX ||
vio_index == SMI_LARB1_VIO_INDEX ||
vio_index == SMI_LARB2_VIO_INDEX ||
vio_index == SMI_LARB3_VIO_INDEX ||
vio_index == SMI_LARB4_VIO_INDEX ||
vio_index == SMI_LARB5_VIO_INDEX ||
vio_index == SMI_LARB6_VIO_INDEX ||
vio_index == SMI_LARB7_VIO_INDEX ||
vio_index == SMI_LARB8_VIO_INDEX ||
vio_index == SMI_LARB9_VIO_INDEX ||
vio_index == SMI_LARB10_VIO_INDEX ||
vio_index == SMI_LARB11_VIO_INDEX ||
vio_index == SMI_LARB12_VIO_INDEX ||
vio_index == SMI_LARB13_VIO_INDEX ||
vio_index == SMI_LARB14_VIO_INDEX ||
vio_index == SMI_LARB15_VIO_INDEX ||
vio_index == SMI_LARB16_VIO_INDEX ||
vio_index == SMI_LARB17_VIO_INDEX ||
vio_index == SMI_LARB18_VIO_INDEX ||
vio_index == SMI_LARB19_VIO_INDEX ||
vio_index == SMI_LARB20_VIO_INDEX)
return "SMI";
if (vio_index == IOMMU0_VIO_INDEX ||
vio_index == IOMMU1_VIO_INDEX ||
vio_index == IOMMU0_SEC_VIO_INDEX ||
vio_index == IOMMU1_SEC_VIO_INDEX)
return "IOMMU";
else if (vio_index >= CAM_SENINF_START &&
vio_index <= CAM_SENINF_END)
return "CAMSYS_SENINF";
switch (vio_index) {
case MFG_START ... MFG_END:
return "MFGSYS";
case MM_DISP_START ... MM_DISP_END:
case MM_DISP2_START ... MM_DISP2_END:
return "MMSYS_DISP";
case MM_SSRAM_VIO_INDEX:
case MM_MDP_START ... MM_MDP_END:
return "MMSYS_MDP";
case IMG_START ... IMG_END:
return "IMGSYS";
case VDEC_START ... VDEC_END:
return "VDECSYS";
case VENC_START ... VENC_END:
return "VENCSYS";
case APU_SSRAM_VIO_INDEX:
case APU_START ... APU_END:
return "APUSYS";
case CAM_CCU_START ... CAM_CCU_END:
return "CAMSYS_CCU";
case CAM_START ... CAM_END:
return "CAMSYS";
case IPE_START ... IPE_END:
return "IPESYS";
case MDP_START ... MDP_END:
return "MMSYS_MDP";
default:
break;
}
for (i = 0; i < VIO_SLAVE_NUM_INFRA; i++) {
if (vio_index == mt6885_devices_infra[i].vio_index)
return mt6885_devices_infra[i].device;
}
} else if (slave_type == SLAVE_TYPE_PERI &&
vio_index < VIO_SLAVE_NUM_PERI) {
/* check violation index */
switch (vio_index) {
case TINY_START ... TINY_END:
return "TINYSYS";
case MD_START ... MD_END:
return "MDSYS";
case CONN_VIO_INDEX:
return "CONNSYS";
default:
break;
}
for (i = 0; i < VIO_SLAVE_NUM_PERI; i++) {
if (vio_index == mt6885_devices_peri[i].vio_index)
return mt6885_devices_peri[i].device;
}
} else if (slave_type == SLAVE_TYPE_PERI2 &&
vio_index < VIO_SLAVE_NUM_PERI2) {
/* check violation address */
if ((vio_addr >= GCE_START_ADDR && vio_addr <= GCE_END_ADDR) ||
(vio_addr >= GCE_M2_START_ADDR &&
vio_addr <= GCE_M2_END_ADDR))
return "GCE";
for (i = 0; i < VIO_SLAVE_NUM_PERI2; i++) {
if (vio_index == mt6885_devices_peri2[i].vio_index)
return mt6885_devices_peri2[i].device;
}
}
return "OUT_OF_BOUND";
}
static void mm2nd_vio_handler(void __iomem *infracfg,
struct mtk_devapc_vio_info *vio_info,
bool mdp_vio, bool disp2_vio, bool mmsys_vio)
{
uint32_t vio_sta, vio_dbg, rw;
uint32_t vio_sta_num;
uint32_t vio0_offset;
char mm_str[64] = {0};
void __iomem *reg;
int i;
if (!infracfg) {
pr_err(PFX "%s, param check failed, infracfg ptr is NULL\n",
__func__);
return;
}
if (mdp_vio) {
vio_sta_num = INFRACFG_MDP_VIO_STA_NUM;
vio0_offset = INFRACFG_MDP_SEC_VIO0_OFFSET;
strncpy(mm_str, "INFRACFG_MDP_SEC_VIO", sizeof(mm_str));
} else if (disp2_vio) {
vio_sta_num = INFRACFG_DISP2_VIO_STA_NUM;
vio0_offset = INFRACFG_DISP2_SEC_VIO0_OFFSET;
strncpy(mm_str, "INFRACFG_DISP2_SEC_VIO", sizeof(mm_str));
} else if (mmsys_vio) {
vio_sta_num = INFRACFG_MM_VIO_STA_NUM;
vio0_offset = INFRACFG_MM_SEC_VIO0_OFFSET;
strncpy(mm_str, "INFRACFG_MM_SEC_VIO", sizeof(mm_str));
} else {
pr_err(PFX "%s: param check failed, %s:%s, %s:%s, %s:%s\n",
__func__,
"mdp_vio", mdp_vio ? "true" : "false",
"disp2_vio", disp2_vio ? "true" : "false",
"mmsys_vio", mmsys_vio ? "true" : "false");
return;
}
/* Get mm2nd violation status */
for (i = 0; i < vio_sta_num; i++) {
reg = infracfg + vio0_offset + i * 4;
vio_sta = readl(reg);
if (vio_sta)
pr_info(PFX "MM 2nd violation: %s%d:0x%x\n",
mm_str, i, vio_sta);
}
/* Get mm2nd violation address */
reg = infracfg + vio0_offset + i * 4;
vio_info->vio_addr = readl(reg);
/* Get mm2nd violation information */
reg = infracfg + vio0_offset + (i + 1) * 4;
vio_dbg = readl(reg);
vio_info->domain_id = (vio_dbg & INFRACFG_MM2ND_VIO_DOMAIN_MASK) >>
INFRACFG_MM2ND_VIO_DOMAIN_SHIFT;
vio_info->master_id = (vio_dbg & INFRACFG_MM2ND_VIO_ID_MASK) >>
INFRACFG_MM2ND_VIO_ID_SHIFT;
rw = (vio_dbg & INFRACFG_MM2ND_VIO_RW_MASK) >>
INFRACFG_MM2ND_VIO_RW_SHIFT;
vio_info->read = (rw == 0);
vio_info->write = (rw == 1);
}
static uint32_t mt6885_shift_group_get(int slave_type, uint32_t vio_idx)
{
if (slave_type == SLAVE_TYPE_INFRA) {
if (vio_idx <= 8 || vio_idx == 412)
return 0;
else if ((vio_idx >= 9 && vio_idx <= 14) || vio_idx == 413)
return 1;
else if ((vio_idx >= 15 && vio_idx <= 16) || vio_idx == 414)
return 2;
else if ((vio_idx >= 17 && vio_idx <= 18) || vio_idx == 415)
return 3;
else if (vio_idx >= 19 && vio_idx <= 70)
return 4;
else if (vio_idx >= 71 && vio_idx <= 369)
return 5;
else if (vio_idx >= 370 && vio_idx <= 409)
return 6;
else if (vio_idx == 410 || vio_idx == 416)
return 7;
else if (vio_idx == 411 || vio_idx == 417)
return 8;
pr_err(PFX "%s:%d Wrong vio_idx:0x%x\n",
__func__, __LINE__, vio_idx);
} else if (slave_type == SLAVE_TYPE_PERI) {
if (vio_idx <= 4)
return 0;
else if (vio_idx >= 5 && vio_idx <= 6)
return 1;
else if ((vio_idx >= 7 && vio_idx <= 38) || vio_idx == 216 ||
(vio_idx >= 217 && vio_idx <= 248) ||
vio_idx == 346)
return 2;
else if ((vio_idx >= 39 && vio_idx <= 61) || vio_idx == 249)
return 3;
else if ((vio_idx >= 62 && vio_idx <= 72) || vio_idx == 250)
return 4;
else if ((vio_idx >= 73 && vio_idx <= 74) || vio_idx == 251)
return 5;
else if ((vio_idx >= 75 && vio_idx <= 78) || vio_idx == 252)
return 6;
else if ((vio_idx >= 79 && vio_idx <= 121) || vio_idx == 253)
return 7;
else if ((vio_idx >= 122 && vio_idx <= 124) || vio_idx == 254)
return 8;
else if (vio_idx == 125 || vio_idx == 255 ||
vio_idx == 256 || vio_idx == 347)
return 9;
else if (vio_idx == 126 || vio_idx == 257)
return 10;
else if (vio_idx == 127 || vio_idx == 128)
return 11;
else if (vio_idx == 129 || vio_idx == 130)
return 12;
else if ((vio_idx >= 131 && vio_idx <= 142) ||
(vio_idx >= 258 && vio_idx <= 269) ||
vio_idx == 348)
return 13;
else if ((vio_idx >= 143 && vio_idx <= 172) || vio_idx == 270 ||
(vio_idx >= 271 && vio_idx <= 300) ||
vio_idx == 349)
return 14;
else if ((vio_idx >= 173 && vio_idx <= 202) || vio_idx == 301 ||
(vio_idx >= 302 && vio_idx <= 331) ||
vio_idx == 350)
return 15;
else if ((vio_idx >= 203 && vio_idx <= 215) ||
(vio_idx >= 332 && vio_idx <= 345) ||
vio_idx == 351)
return 16;
pr_err(PFX "%s:%d Wrong vio_idx:0x%x\n",
__func__, __LINE__, vio_idx);
} else if (slave_type == SLAVE_TYPE_PERI2) {
if (vio_idx <= 8 ||
(vio_idx >= 130 && vio_idx <= 139) ||
vio_idx == 252)
return 0;
else if (vio_idx >= 9 && vio_idx <= 12)
return 1;
else if (vio_idx >= 13 && vio_idx <= 16)
return 2;
else if (vio_idx >= 17 && vio_idx <= 20)
return 3;
else if (vio_idx >= 21 && vio_idx <= 24)
return 4;
else if ((vio_idx >= 25 && vio_idx <= 40) ||
(vio_idx >= 140 && vio_idx <= 156) ||
vio_idx == 253)
return 5;
else if ((vio_idx >= 41 && vio_idx <= 48) ||
(vio_idx >= 157 && vio_idx <= 165) ||
vio_idx == 254)
return 6;
else if ((vio_idx >= 49 && vio_idx <= 64) ||
(vio_idx >= 166 && vio_idx <= 182) ||
vio_idx == 255)
return 7;
else if ((vio_idx >= 65 && vio_idx <= 80) ||
(vio_idx >= 183 && vio_idx <= 199) ||
vio_idx == 256)
return 8;
else if ((vio_idx >= 81 && vio_idx <= 88) ||
(vio_idx >= 200 && vio_idx <= 208) ||
vio_idx == 257)
return 9;
else if ((vio_idx >= 89 && vio_idx <= 111) ||
(vio_idx >= 209 && vio_idx <= 232) ||
vio_idx == 258)
return 10;
else if ((vio_idx >= 112 && vio_idx <= 40) ||
(vio_idx >= 233 && vio_idx <= 251) ||
vio_idx == 259)
return 11;
pr_err(PFX "%s:%d Wrong vio_idx:0x%x\n",
__func__, __LINE__, vio_idx);
} else {
pr_err(PFX "%s:%d Wrong slave_type:0x%x\n",
__func__, __LINE__, slave_type);
}
return 31;
}
void devapc_catch_illegal_range(phys_addr_t phys_addr, size_t size)
{
phys_addr_t test_pa = 0x17a54c50;
/*
* Catch BROM addr mapped
*/
if (phys_addr >= 0x0 && phys_addr < SRAM_START_ADDR) {
pr_err(PFX "%s %s:(%pa), %s:(0x%lx)\n",
"catch BROM address mapped!",
"phys_addr", &phys_addr,
"size", size);
BUG_ON(1);
}
if ((phys_addr <= test_pa) && (phys_addr + size > test_pa)) {
pr_err(PFX "%s %s:(%pa), %s:(0x%lx), %s:(%pa)\n",
"catch VENCSYS address mapped!",
"phys_addr", &phys_addr,
"size", size, "test_pa", &test_pa);
BUG_ON(1);
}
}
EXPORT_SYMBOL(devapc_catch_illegal_range);
static struct mtk_devapc_dbg_status mt6885_devapc_dbg_stat = {
.enable_ut = PLAT_DBG_UT_DEFAULT,
.enable_KE = PLAT_DBG_KE_DEFAULT,
.enable_AEE = PLAT_DBG_AEE_DEFAULT,
.enable_WARN = PLAT_DBG_WARN_DEFAULT,
.enable_dapc = PLAT_DBG_DAPC_DEFAULT,
};
static const char * const slave_type_to_str[] = {
"SLAVE_TYPE_INFRA",
"SLAVE_TYPE_PERI",
"SLAVE_TYPE_PERI2",
"WRONG_SLAVE_TYPE",
};
static int mtk_vio_mask_sta_num[] = {
VIO_MASK_STA_NUM_INFRA,
VIO_MASK_STA_NUM_PERI,
VIO_MASK_STA_NUM_PERI2,
};
static struct mtk_devapc_vio_info mt6885_devapc_vio_info = {
.vio_mask_sta_num = mtk_vio_mask_sta_num,
.sramrom_vio_idx = SRAMROM_VIO_INDEX,
.mdp_vio_idx = MDP_VIO_INDEX,
.disp2_vio_idx = DISP2_VIO_INDEX,
.mmsys_vio_idx = MMSYS_VIO_INDEX,
.sramrom_slv_type = SRAMROM_SLAVE_TYPE,
.mm2nd_slv_type = MM2ND_SLAVE_TYPE,
};
static const struct mtk_infra_vio_dbg_desc mt6885_vio_dbgs = {
.vio_dbg_mstid = INFRA_VIO_DBG_MSTID,
.vio_dbg_mstid_start_bit = INFRA_VIO_DBG_MSTID_START_BIT,
.vio_dbg_dmnid = INFRA_VIO_DBG_DMNID,
.vio_dbg_dmnid_start_bit = INFRA_VIO_DBG_DMNID_START_BIT,
.vio_dbg_w_vio = INFRA_VIO_DBG_W_VIO,
.vio_dbg_w_vio_start_bit = INFRA_VIO_DBG_W_VIO_START_BIT,
.vio_dbg_r_vio = INFRA_VIO_DBG_R_VIO,
.vio_dbg_r_vio_start_bit = INFRA_VIO_DBG_R_VIO_START_BIT,
.vio_addr_high = INFRA_VIO_ADDR_HIGH,
.vio_addr_high_start_bit = INFRA_VIO_ADDR_HIGH_START_BIT,
};
static const struct mtk_sramrom_sec_vio_desc mt6885_sramrom_sec_vios = {
.vio_id_mask = SRAMROM_SEC_VIO_ID_MASK,
.vio_id_shift = SRAMROM_SEC_VIO_ID_SHIFT,
.vio_domain_mask = SRAMROM_SEC_VIO_DOMAIN_MASK,
.vio_domain_shift = SRAMROM_SEC_VIO_DOMAIN_SHIFT,
.vio_rw_mask = SRAMROM_SEC_VIO_RW_MASK,
.vio_rw_shift = SRAMROM_SEC_VIO_RW_SHIFT,
};
static const uint32_t mt6885_devapc_pds[] = {
PD_VIO_MASK_OFFSET,
PD_VIO_STA_OFFSET,
PD_VIO_DBG0_OFFSET,
PD_VIO_DBG1_OFFSET,
PD_VIO_DBG2_OFFSET,
PD_APC_CON_OFFSET,
PD_SHIFT_STA_OFFSET,
PD_SHIFT_SEL_OFFSET,
PD_SHIFT_CON_OFFSET,
};
static struct mtk_devapc_soc mt6885_data = {
.dbg_stat = &mt6885_devapc_dbg_stat,
.slave_type_arr = slave_type_to_str,
.slave_type_num = SLAVE_TYPE_NUM,
.device_info[SLAVE_TYPE_INFRA] = mt6885_devices_infra,
.device_info[SLAVE_TYPE_PERI] = mt6885_devices_peri,
.device_info[SLAVE_TYPE_PERI2] = mt6885_devices_peri2,
.ndevices = mtk6885_devices_num,
.vio_info = &mt6885_devapc_vio_info,
.vio_dbgs = &mt6885_vio_dbgs,
.sramrom_sec_vios = &mt6885_sramrom_sec_vios,
.devapc_pds = mt6885_devapc_pds,
.subsys_get = &index_to_subsys,
.master_get = &mt6885_bus_id_to_master,
.mm2nd_vio_handler = &mm2nd_vio_handler,
.shift_group_get = mt6885_shift_group_get,
};
static const struct of_device_id mt6885_devapc_dt_match[] = {
{ .compatible = "mediatek,mt6885-devapc" },
{},
};
static int mt6885_devapc_probe(struct platform_device *pdev)
{
return mtk_devapc_probe(pdev, &mt6885_data);
}
static int mt6885_devapc_remove(struct platform_device *dev)
{
return mtk_devapc_remove(dev);
}
static struct platform_driver mt6885_devapc_driver = {
.probe = mt6885_devapc_probe,
.remove = mt6885_devapc_remove,
.driver = {
.name = KBUILD_MODNAME,
.of_match_table = mt6885_devapc_dt_match,
},
};
module_platform_driver(mt6885_devapc_driver);
MODULE_DESCRIPTION("Mediatek MT6885 Device APC Driver");
MODULE_AUTHOR("Neal Liu <neal.liu@mediatek.com>");
MODULE_LICENSE("GPL");
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,227 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2019 MediaTek Inc.
*/
#ifndef __DEVAPC_MTK_COMMON_H__
#define __DEVAPC_MTK_COMMON_H__
#include <linux/platform_device.h>
#include <linux/types.h>
/******************************************************************************
* LOG DEFINATION
******************************************************************************/
/* Debug message event */
#define DEVAPC_LOG_NONE 0x00000000
#define DEVAPC_LOG_INFO 0x00000001
#define DEVAPC_LOG_DBG 0x00000002
#ifdef DEBUG
#define DEVAPC_LOG_LEVEL (DEVAPC_LOG_DBG)
#else
#define DEVAPC_LOG_LEVEL (DEVAPC_LOG_NONE)
#endif
#define PFX KBUILD_MODNAME ": "
#define DEVAPC_DBG_MSG(fmt, args...) \
do { \
if (DEVAPC_LOG_LEVEL & DEVAPC_LOG_DBG) { \
pr_debug(PFX fmt, ##args); \
} else if (DEVAPC_LOG_LEVEL & DEVAPC_LOG_INFO) { \
pr_info(PFX fmt, ##args); \
} \
} while (0)
#define DEVAPC_VIO_LEVEL (DEVAPC_LOG_INFO)
#define DEVAPC_MSG(fmt, args...) \
do { \
if (DEVAPC_VIO_LEVEL & DEVAPC_LOG_DBG) { \
pr_debug(PFX fmt, ##args); \
} else if (DEVAPC_VIO_LEVEL & DEVAPC_LOG_INFO) { \
pr_info(PFX fmt, ##args); \
} \
} while (0)
#define log2buf(p, s, fmt, args...) \
(p += scnprintf(p, sizeof(s) - strlen(s), fmt, ##args))
#define devapc_log(fmt, args...) log2buf(p, msg_buf, fmt, ##args)
/******************************************************************************
* VARIABLE DEFINATION
******************************************************************************/
#define MOD_NO_IN_1_DEVAPC 16
#define VIOLATION_TRIGGERED 1
#define DEAD 0xdeadbeaf
/******************************************************************************
* DATA STRUCTURE & FUNCTION DEFINATION
******************************************************************************/
enum DEVAPC_DT_NODE_INDEX {
DT_DEVAPC_PD_IDX = 0,
DT_DEVAPC_AO_IDX = 1,
DT_DEVAPC_SWP_IDX = 2,
DT_SRAMROM_IDX = 3,
};
enum DEVAPC_PD_REG_TYPE {
VIO_MASK = 0,
VIO_STA,
VIO_DBG0,
VIO_DBG1,
APC_CON,
VIO_SHIFT_STA,
VIO_SHIFT_SEL,
VIO_SHIFT_CON,
};
enum DEVAPC_UT_CMD {
DEVAPC_UT_DAPC_VIO = 1,
DEVAPC_UT_SRAM_VIO,
DEVAPC_UT_DUMP_SUBSYS_CB,
};
enum DEVAPC_SLAVE_TYPE {
E_DAPC_INFRA_PERI_SLAVE = 0,
E_DAPC_MM_SLAVE,
E_DAPC_MD_SLAVE,
E_DAPC_PERI_SLAVE,
E_DAPC_MM2ND_SLAVE,
E_DAPC_OTHERS_SLAVE,
E_DAPC_SLAVE_TYPE_RESERVRD = 0x7FFFFFFF /* force enum to use 32 bits */
};
enum E_MASK_DOM {
E_DOMAIN_0 = 0,
E_DOMAIN_1,
E_DOMAIN_2,
E_DOMAIN_3,
E_DOMAIN_4,
E_DOMAIN_5,
E_DOMAIN_6,
E_DOMAIN_7,
E_DOMAIN_8,
E_DOMAIN_9,
E_DOMAIN_10,
E_DOMAIN_11,
E_DOMAIN_12,
E_DOMAIN_13,
E_DOMAIN_14,
E_DOMAIN_15,
E_DOMAIN_OTHERS,
E_MASK_DOM_RESERVRD = 0x7FFFFFFF /* force enum to use 32 bits */
};
enum SRAMROM_VIO {
ROM_VIOLATION = 0,
SRAM_VIOLATION,
};
#ifdef CONFIG_DEVAPC_SWP_SUPPORT
enum DEVAPC_SWP_REG_OFFSET {
DEVAPC_SWP_CON_OFFSET = 0x0,
DEVAPC_SWP_SA_OFFSET = 0x4,
DEVAPC_SWP_RG_OFFSET = 0x8,
DEVAPC_SWP_WR_VAL_OFFSET = 0xC,
DEVAPC_SWP_WR_MASK_OFFSET = 0x10,
};
enum DEVAPC_SWP_CON_BIT {
DEVAPC_SWP_CON_ENABLE = 0x0,
DEVAPC_SWP_CON_CLEAR,
DEVAPC_SWP_CON_RW,
};
#endif
struct mtk_devapc_dbg_status {
bool enable_ut;
bool enable_KE;
bool enable_AEE;
bool enable_dapc; /* dump APC */
};
struct mtk_device_info {
enum DEVAPC_SLAVE_TYPE slave_type;
int config_index;
const char *device;
bool enable_vio_irq;
};
struct mtk_devapc_vio_info {
uint32_t vio_dbg1;
uint32_t master_id;
uint32_t domain_id;
int vio_cfg_max_idx;
int vio_max_idx;
int vio_mask_sta_num;
int vio_shift_max_bit;
int sramrom_vio_idx;
int devapc_vio_trigger_times;
};
struct mtk_infra_vio_dbg_desc {
uint32_t infra_vio_dbg_mstid;
uint8_t infra_vio_dbg_mstid_start_bit;
uint32_t infra_vio_dbg_dmnid;
uint8_t infra_vio_dbg_dmnid_start_bit;
uint32_t infra_vio_dbg_w_vio;
uint8_t infra_vio_dbg_w_vio_start_bit;
uint32_t infra_vio_dbg_r_vio;
uint8_t infra_vio_dbg_r_vio_start_bit;
uint32_t infra_vio_addr_high;
uint8_t infra_vio_addr_high_start_bit;
};
struct mtk_sramrom_sec_vio_desc {
uint32_t sramrom_sec_vio_id_mask;
uint8_t sramrom_sec_vio_id_shift;
uint32_t sramrom_sec_vio_domain_mask;
uint8_t sramrom_sec_vio_domain_shift;
uint32_t sramrom_sec_vio_rw_mask;
uint8_t sramrom_sec_vio_rw_shift;
};
struct mtk_devapc_pd_desc {
uint32_t pd_vio_mask_offset;
uint32_t pd_vio_sta_offset;
uint32_t pd_vio_dbg0_offset;
uint32_t pd_vio_dbg1_offset;
uint32_t pd_apc_con_offset;
uint32_t pd_shift_sta_offset;
uint32_t pd_shift_sel_offset;
uint32_t pd_shift_con_offset;
};
struct mtk_devapc_soc {
struct mtk_devapc_dbg_status *dbg_stat;
const struct mtk_device_info *device_info;
uint32_t ndevices;
struct mtk_devapc_vio_info *vio_info;
const struct mtk_infra_vio_dbg_desc *vio_dbgs;
const struct mtk_sramrom_sec_vio_desc *sramrom_sec_vios;
const struct mtk_devapc_pd_desc *devapc_pds;
/* platform specific operations */
const char* (*subsys_get)(uint32_t index);
const char* (*master_get)(int bus_id, uint32_t vio_addr,
int vio_idx);
uint32_t (*shift_group_get)(uint32_t vio_idx);
};
void handle_sramrom_vio(void);
int mtk_devapc_probe(struct platform_device *pdev,
struct mtk_devapc_soc *soc);
int mtk_devapc_remove(struct platform_device *dev);
ssize_t mtk_devapc_dbg_read(struct file *file, char __user *buffer,
size_t count, loff_t *ppos);
ssize_t mtk_devapc_dbg_write(struct file *file, const char __user *buffer,
size_t count, loff_t *data);
#endif /* __DEVAPC_MTK_COMMON_H__ */
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,193 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2019 MediaTek Inc.
*/
#ifndef __DEVAPC_MTK_MULTI_4_H__
#define __DEVAPC_MTK_MULTI_4_H__
#include <linux/platform_device.h>
#include <linux/types.h>
/******************************************************************************
* VARIABLE DEFINATION
******************************************************************************/
#define MOD_NO_IN_1_DEVAPC 16
#define VIOLATION_TRIGGERED 1
#define DEAD 0xdeadbeaf
#define RANDOM_OFFSET 0x88
#define PFX "[DEVAPC]: "
#define SLAVE_TYPE_NUM_MAX 5
#define devapc_log(p, s, fmt, args...) \
(p += scnprintf(p, sizeof(s) - strlen(s), fmt, ##args))
#define UNUSED(x) (void)(x)
#define RETRY_COUNT 3
/******************************************************************************
* DATA STRUCTURE & FUNCTION DEFINATION
******************************************************************************/
enum DEVAPC_PD_REG_TYPE {
VIO_MASK = 0,
VIO_STA,
VIO_DBG0,
VIO_DBG1,
VIO_DBG2,
APC_CON,
VIO_SHIFT_STA,
VIO_SHIFT_SEL,
VIO_SHIFT_CON,
PD_REG_TYPE_NUM,
};
enum DEVAPC_UT_CMD {
DEVAPC_UT_DAPC_VIO = 1,
DEVAPC_UT_SRAM_VIO,
};
enum DEVAPC_DOM_ID {
DOMAIN_0 = 0,
DOMAIN_1,
DOMAIN_2,
DOMAIN_3,
DOMAIN_4,
DOMAIN_5,
DOMAIN_6,
DOMAIN_7,
DOMAIN_8,
DOMAIN_9,
DOMAIN_10,
DOMAIN_11,
DOMAIN_12,
DOMAIN_13,
DOMAIN_14,
DOMAIN_15,
DOMAIN_OTHERS,
};
enum SRAMROM_VIO {
ROM_VIOLATION = 0,
SRAM_VIOLATION,
};
#ifdef CONFIG_DEVAPC_SWP_SUPPORT
enum DEVAPC_SWP_REG_OFFSET {
DEVAPC_SWP_CON_OFFSET = 0x0,
DEVAPC_SWP_SA_OFFSET = 0x4,
DEVAPC_SWP_RG_OFFSET = 0x8,
DEVAPC_SWP_WR_VAL_OFFSET = 0xC,
DEVAPC_SWP_WR_MASK_OFFSET = 0x10,
};
enum DEVAPC_SWP_CON_BIT {
DEVAPC_SWP_CON_ENABLE = 0x0,
DEVAPC_SWP_CON_CLEAR,
DEVAPC_SWP_CON_RW,
};
#endif
struct mtk_devapc_dbg_status {
bool enable_ut;
bool enable_KE;
bool enable_AEE;
bool enable_WARN;
bool enable_dapc; /* dump APC */
};
struct mtk_device_info {
int sys_index;
int ctrl_index;
int vio_index;
const char *device;
bool enable_vio_irq;
};
struct mtk_device_num {
int slave_type;
uint32_t vio_slave_num;
};
struct mtk_devapc_vio_info {
bool read;
bool write;
uint32_t vio_addr;
uint32_t vio_addr_high;
uint32_t master_id;
uint32_t domain_id;
int *vio_mask_sta_num;
int sramrom_slv_type;
int sramrom_vio_idx;
int mm2nd_slv_type;
int mdp_vio_idx;
int disp2_vio_idx;
int mmsys_vio_idx;
int vio_trigger_times;
int shift_sta_bit;
};
struct mtk_infra_vio_dbg_desc {
uint32_t vio_dbg_mstid;
uint8_t vio_dbg_mstid_start_bit;
uint32_t vio_dbg_dmnid;
uint8_t vio_dbg_dmnid_start_bit;
uint32_t vio_dbg_w_vio;
uint8_t vio_dbg_w_vio_start_bit;
uint32_t vio_dbg_r_vio;
uint8_t vio_dbg_r_vio_start_bit;
uint32_t vio_addr_high;
uint8_t vio_addr_high_start_bit;
};
struct mtk_sramrom_sec_vio_desc {
uint32_t vio_id_mask;
uint8_t vio_id_shift;
uint32_t vio_domain_mask;
uint8_t vio_domain_shift;
uint32_t vio_rw_mask;
uint8_t vio_rw_shift;
};
struct mtk_devapc_pd_desc {
uint32_t pd_vio_mask_offset;
uint32_t pd_vio_sta_offset;
uint32_t pd_vio_dbg0_offset;
uint32_t pd_vio_dbg1_offset;
uint32_t pd_apc_con_offset;
uint32_t pd_shift_sta_offset;
uint32_t pd_shift_sel_offset;
uint32_t pd_shift_con_offset;
};
struct mtk_devapc_soc {
struct mtk_devapc_dbg_status *dbg_stat;
const char * const *slave_type_arr;
uint32_t slave_type_num;
const struct mtk_device_info *device_info[SLAVE_TYPE_NUM_MAX];
const struct mtk_device_num *ndevices;
struct mtk_devapc_vio_info *vio_info;
const struct mtk_infra_vio_dbg_desc *vio_dbgs;
const struct mtk_sramrom_sec_vio_desc *sramrom_sec_vios;
const uint32_t *devapc_pds;
/* platform specific operations */
const char* (*subsys_get)(int slave_type, uint32_t vio_index,
uint32_t vio_addr);
const char* (*master_get)(uint32_t bus_id, uint32_t vio_addr,
int slave_type, int shift_sta_bit, int domain);
void (*mm2nd_vio_handler)(void __iomem *infracfg,
struct mtk_devapc_vio_info *vio_info,
bool mdp_vio, bool disp2_vio, bool mmsys_vio);
uint32_t (*shift_group_get)(int slave_type, uint32_t vio_index);
};
extern int mtk_devapc_probe(struct platform_device *pdev,
struct mtk_devapc_soc *soc);
extern int mtk_devapc_remove(struct platform_device *dev);
ssize_t mtk_devapc_dbg_read(struct file *file, char __user *buffer,
size_t count, loff_t *ppos);
ssize_t mtk_devapc_dbg_write(struct file *file, const char __user *buffer,
size_t count, loff_t *data);
#endif /* __DEVAPC_MTK_MULTI_4_H__ */
@@ -0,0 +1,15 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
ccflags-y += -I$(srctree)/drivers/misc/mediatek/include/mt-plat/
obj-y += devapc.o
+875
View File
@@ -0,0 +1,875 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2017 MediaTek Inc.
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/mm.h>
#include <linux/uaccess.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/irq.h>
#include <linux/sched.h>
#include <linux/cdev.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/proc_fs.h>
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/of_platform.h>
#include <linux/of_irq.h>
#include <linux/of_address.h>
#include <linux/types.h>
#include <linux/sched/clock.h>
#include <linux/sched/debug.h>
#ifdef CONFIG_MTK_HIBERNATION
#include <mtk_hibernate_dpm.h>
#endif
/* CCF */
#include <linux/clk.h>
#include "sync_write.h"
#include "devapc.h"
#if defined(CONFIG_MTK_AEE_FEATURE) && defined(DEVAPC_ENABLE_AEE)
#include <mt-plat/aee.h>
#endif
#define PFX "[DEVAPC]: "
/* 0 for early porting */
#define DEVAPC_TURN_ON 1
#define DEVAPC_USE_CCF 1
#define DEVAPC_VIO_DEBUG 0
/* Debug message event */
#define DEVAPC_LOG_NONE 0x00000000
#define DEVAPC_LOG_ERR 0x00000001
#define DEVAPC_LOG_WARN 0x00000002
#define DEVAPC_LOG_INFO 0x00000004
#define DEVAPC_LOG_NOTICE 0x00000008
#define DEVAPC_LOG_DBG 0x00000010
#define DEVAPC_LOG_LEVEL (DEVAPC_LOG_INFO)
#define DEVAPC_MSG(fmt, args...) \
do { \
if (DEVAPC_LOG_LEVEL & DEVAPC_LOG_DBG) { \
pr_debug(fmt, ##args); \
} else if (DEVAPC_LOG_LEVEL & DEVAPC_LOG_INFO) { \
pr_info(fmt, ##args); \
} \
} while (0)
#define DEVAPC_VIO_LEVEL (DEVAPC_LOG_NOTICE)
#define DEVAPC_VIO_MSG(fmt, args...) \
do { \
if (DEVAPC_VIO_LEVEL & DEVAPC_LOG_DBG) { \
pr_debug(fmt, ##args); \
} else if (DEVAPC_VIO_LEVEL & DEVAPC_LOG_INFO) { \
pr_info(fmt, ##args); \
} else if (DEVAPC_VIO_LEVEL & DEVAPC_LOG_NOTICE) { \
pr_notice(fmt, ##args); \
} \
} while (0)
/* bypass clock! */
#if DEVAPC_USE_CCF
static struct clk *dapc_infra_clk;
#endif
static struct cdev *g_devapc_ctrl;
static unsigned int devapc_infra_irq;
static void __iomem *devapc_pd_infra_base;
static unsigned int enable_dynamic_one_core_violation_debug;
#if defined(CONFIG_MTK_AEE_FEATURE) && defined(DEVAPC_ENABLE_AEE)
unsigned long long devapc_vio_first_trigger_time[DEVAPC_TOTAL_SLAVES];
/* violation times */
unsigned int devapc_vio_count[DEVAPC_TOTAL_SLAVES];
/* show the status of whether AEE warning has been populated */
unsigned int devapc_vio_aee_shown[DEVAPC_TOTAL_SLAVES];
unsigned int devapc_vio_current_aee_trigger_times;
#endif
#if DEVAPC_TURN_ON
static struct DEVICE_INFO devapc_infra_devices[] = {
/* device name enable_vio_irq */
/* 0 */
{"INFRA_AO_TOPCKGEN", true}, /* Infra-Peri */
{"INFRA_AO_INFRASYS_CONFIG_REGS", true},
{"IO_CFG_REG", true},
{"INFRA_AO_ PERICFG", true},
{"INFRA_AO_EFUSE_AO_DEBUG", true},
{"INFRA_AO_GPIO", true},
{"INFRA_AO_SLEEP_CONTROLLER", true},
{"INFRA_AO_TOPRGU", true},
{"INFRA_AO_APXGPT", true},
{"INFRA_AO_RESERVE", true},
/* 10 */
{"INFRA_AO_SEJ", true},
{"INFRA_AO_AP_CIRQ_EINT", true},
{"INFRA_AO_APMIXEDSYS", true},
{"INFRA_AO_PMIC_WRAP", true},
{"INFRA_AO_DEVICE_APC_AO_INFRA_PERI", true},
{"INFRA_AO_SLEEP_CONTROLLER_MD", true},
{"INFRA_AO_KEYPAD", true},
{"INFRA_AO_TOP_MISC", true},
{"INFRA_AO_ DVFS_CTRL_PROC", true},
{"INFRA_AO_MBIST_AO_REG", true},
/* 20 */
{"INFRA_AO_CLDMA_AO_AP", true},
{"INFRA_AO_RESERVE", true},
{"INFRA_AO_AES_TOP_0", true},
{"INFRA_AO_SYS_TIMER", true},
{"INFRA_AO_MDEM_TEMP_SHARE", true},
{"INFRA_AO_DEVICE_APC_AO_MD", true},
{"INFRA_AO_SECURITY_AO", true},
{"INFRA_AO_TOPCKGEN_REG", true},
{"INFRA_AO_DEVICE_APC_AO_MM", true},
{"INFRA_AO_DRAMC_REG", true},
/* 30 */
{"INFRA_AO_DDRPHY_REG", true},
{"INFRA_AO_RESERVE", true},
{"INFRASYS_MCUSYS_REG0", true},
{"INFRASYS_MCUSYS_REG1", true},
{"INFRASYS_MCUSYS_REG2", true},
{"INFRASYS_MCUSYS_REG3", true},
{"INFRASYS_SYS_CIRQ", true},
{"INFRASYS_MM_IOMMU", true},
{"INFRASYS_EFUSE_PDN_DEBUG", true},
{"INFRASYS_DEVICE_APC", true},
/* 40 */
{"INFRASYS_DBG_TRACKER", true},
{"INFRASYS_CCIF0_AP", false},
{"INFRASYS_CCIF0_MD", true},
{"INFRASYS_CCIF1_MD", true},
{"INFRASYS_CLDMA_MD", true},
{"INFRASYS_MBIST", true},
{"INFRASYS_INFRA_PDN_REGISTER", true},
{"INFRASYS_TRNG", true},
{"INFRASYS_DX_CC", true},
{"INFRASYS_RESERVE", true},
/* 50 */
{"INFRASYS_CQ_DMA", true},
{"INFRASYS_RESERVE", true},
{"INFRASYS_SRAMROM", true},
{"INFRASYS_RESERVE", true},
{"INFRASYS_MCUPM_REG", true},
{"INFRASYS_MCUPM_SRAM", true},
{"INFRASYS_MCUPM_SRAM", true},
{"INFRASYS_EMI", true},
{"INFRASYS_CHN_EMI", true},
{"INFRASYS_CLDMA_PDN_AP", true},
/* 60 */
{"INFRASYS_CLDMA_PDN_MD", true},
{"INFRASYS_DRAMC_NAO", true},
{"INFRASYS_RESERVE", true},
{"INFRASYS_RESERVE", true},
{"INFRASYS_RESERVE", true},
{"INFRASYS_EMI_MPU", true},
{"INFRASYS_DVFS_PROC", true},
{"INFRASYS_GCE", true},
{"INFRA_AO_MCUCFG", true},
{"INFRASYS_DBUGSYS", true},
/* 70 */
{"PERISYS_APDMA", true},
{"PERISYS_AUXADC", true},
{"PERISYS_UART0", true},
{"PERISYS_UART1", true},
{"PERISYS_UART2", true},
{"PERISYS_UART3", true},
{"PERISYS_PWM", true},
{"PERISYS_I2C0", true},
{"PERISYS_I2C1", true},
{"PERISYS_I2C2", true},
/* 80 */
{"PERISYS_SPI0", true},
{"PERISYS_PTP", true},
{"PERISYS_BTIF", true},
{"PERISYS_IRTX", true},
{"PERISYS_DISP_PWM", true},
{"PERISYS_I2C3", true},
{"PERISYS_SPI1", true},
{"PERISYS_I2C4", true},
{"PERISYS_SPI2", true},
{"PERISYS_SPI3", true},
/* 90 */
{"PERISYS_I2C1_IMM", true},
{"PERISYS_I2C2_IMM", true},
{"PERISYS_I2C5", true},
{"PERISYS_I2C5_IMM", true},
{"PERISYS_NFI", true},
{"PERISYS_NFIECC", true},
{"PERISYS_USB", true},
{"PERISYS_USB_2.0_SUB", true},
{"PERISYS_MSDC0", true},
{"PERISYS_MSDC1", true},
/* 100 */
{"PERISYS_MSDC2", true},
{"PERISYS_MSDC3", true},
{"PERISYS_UFS", true},
{"PERISUS_USB3.0_SIF", true},
{"PERISUS_USB3.0_SIF2", true},
{"PERISYS_USB_2.0_SIF", true},
{"PERISYS_AUDIO", true},
{"EAST_EFUSE", true},
{"EAST_ CSI0_TOP_AO", true},
{"EAST_ CSI1_TOP_AO", true},
/* 110 */
{"EAST_ RESERVE", true},
{"SOUTH_MSDC1", true},
{"SOUTH_RESERVE_0", true},
{"SOUTH_RESERVE_1", true},
{"SOUTH_RESERVE_2", true},
{"WEST_MIPI_TX_CONFIG", true},
{"WEST_RESERVE_0", true},
{"WEST_RESERVE_1", true},
{"WEST_RESERVE_2", true},
{"NORTH_USBSIF_TOP", true},
/* 120 */
{"NORTH_MSDC0", true},
{"NORTH_RESERVE_0", true},
{"NORTH_RESERVE_1", true},
{"PERISYS_CONN", true},
{"PERISYS_RESERVE", true},
{"PERISYS_RESERVE", true},
{"GPU", true}, /* MM */
{"GPU CONFIG", true},
{"GPU RESERVE", true},
{"MFG_OTHERS", true},
/* 130 */
{"MMSYS_CONFIG", true},
{"DISP_MUTEX", true},
{"SMI_COMMON", true},
{"SMI_LARB0", true},
{"MDP_RDMA0", true},
{"MDP_RSZ0", true},
{"MDP_RSZ1", true},
{"MDP_WDMA0", true},
{"MDP_WROT0", true},
{"MDP_TDSHP0", true},
/* 140 */
{"DISP_OVL0", true},
{"DISP_RDMA0", true},
{"DISP_WDMA0", true},
{"DISP_COLOR0", true},
{"DISP_CCORR0", true},
{"DISP_AAL0", true},
{"DISP_GAMMA0", true},
{"DISP_DITHER0", true},
{"DSI0", true},
{"DBI0", true},
/* 150 */
{"DSI0", true},
{"DPI", true},
{"MM_MUTEX", true},
{"SMI_LARB0", true},
{"SMI_LARB1", true},
{"SMI_COMMON", true},
{"IMGSYS_CONFIG", true},
{"IMGSYS_SMI_LARB2", true},
{"IMGSYS_DISP_A0", true},
{"IMGSYS_DISP_A1", true},
/* 160 */
{"IMGSYS_DISP_A2", true},
{"IMGSYS_RESERVE", true},
{"IMGSYS_RESERVE", true},
{"IMGSYS_VAD", true},
{"IMGSYS_DPE", true},
{"IMGSYS_RSC", true},
{"IMGSYS_RESERVE", true},
{"IMGSYS_FDVT", true},
{"IMGSYS_GEPF", true},
{"IMGSYS_RESERVE", true},
/* 170 */
{"IMGSYS_DFP", true},
{"IMGSYS_RESERVE", true},
{"VCODESYS_VENC_GLOBAL_CON", true},
{"VCODESYS_SMI_LARB1", true},
{"VCODESYS_VENC", true},
{"VCODESYS_JPGENC", true},
{"VCODESYS_VDEC_FULL_TOP", true},
{"VCODESYS_MBIST_CTRL", true},
{"PERIAPB_BRIDGE_UNALIGN", true}, /* other types */
{"PERIAPB_BRIDGE_OUT_OF_BOUND", true},
/* 180 */
{"PERIAPB_BRIDGE_WAY_EN", true},
{"RESERVED", true},
{"RESERVED", true},
{"RESERVED", true},
{"RESERVED", true},
{"RESERVED", true},
{"RESERVED", true},
{"RESERVED", true},
{"RESERVED", true},
{"RESERVED", true},
/* 190 */
{"NORTH_PERIAPB_UNALIGN", true},
{"NORTH _PERIAPB _OUT_OF_BOUND", true},
{"NORTH _PERIAPB _ERR_WAY_EN", true},
{"INFRA_PDN_DECODE_ERROR", true},
{"TOPAXI_SI2_DECERR", true},
{"TOPAXI_SI1_DECERR", true},
{"TOPAXI_SI0_DECERR", true},
{"PERIAXI_SI0_DECERR", true},
{"PERIAXI_SI1_DECERR", true},
};
#endif
#ifdef CONFIG_MTK_HIBERNATION
static int devapc_pm_restore_noirq(struct device *device)
{
if (devapc_infra_irq != 0) {
mt_irq_set_sens(devapc_infra_irq, MT_LEVEL_SENSITIVE);
mt_irq_set_polarity(devapc_infra_irq, MT_POLARITY_LOW);
}
return 0;
}
#endif
#if DEVAPC_TURN_ON
static void unmask_infra_module_irq(unsigned int module)
{
unsigned int apc_index = 0;
unsigned int apc_bit_index = 0;
if (module > PD_INFRA_VIO_MASK_MAX_INDEX) {
DEVAPC_MSG("[DEVAPC] unmask infra module irq: module overflow!\n");
return;
}
apc_index = module / (MOD_NO_IN_1_DEVAPC * 2);
apc_bit_index = module % (MOD_NO_IN_1_DEVAPC * 2);
*DEVAPC_PD_INFRA_VIO_MASK(apc_index) &= (0xFFFFFFFF ^ (1 << apc_bit_index));
}
static int clear_infra_vio_status(unsigned int module)
{
unsigned int apc_index = 0;
unsigned int apc_bit_index = 0;
if (module > PD_INFRA_VIO_STA_MAX_INDEX) {
DEVAPC_MSG("[DEVAPC] clear infra vio_status: module overflow!\n");
return -1;
}
apc_index = module / (MOD_NO_IN_1_DEVAPC * 2);
apc_bit_index = module % (MOD_NO_IN_1_DEVAPC * 2);
*DEVAPC_PD_INFRA_VIO_STA(apc_index) = (0x1 << apc_bit_index);
return 0;
}
static int check_infra_vio_status(unsigned int module)
{
unsigned int apc_index = 0;
unsigned int apc_bit_index = 0;
if (module > PD_INFRA_VIO_STA_MAX_INDEX) {
DEVAPC_MSG("[DEVAPC] check infra vio_status: module overflow!\n");
return -1;
}
apc_index = module / (MOD_NO_IN_1_DEVAPC * 2);
apc_bit_index = module % (MOD_NO_IN_1_DEVAPC * 2);
if (*DEVAPC_PD_INFRA_VIO_STA(apc_index) & (0x1 << apc_bit_index))
return 1;
return 0;
}
static void start_devapc(void)
{
unsigned int i;
mt_reg_sync_writel(0x80000000, DEVAPC_PD_INFRA_APC_CON);
/* SMC call is called to set Device APC in LK instead */
DEVAPC_MSG("[DEVAPC] INFRA VIO_MASK 0:0x%x, 1:0x%x, 2:0x%x, 3:0x%x, ",
readl(DEVAPC_PD_INFRA_VIO_MASK(0)), readl(DEVAPC_PD_INFRA_VIO_MASK(1)),
readl(DEVAPC_PD_INFRA_VIO_MASK(2)), readl(DEVAPC_PD_INFRA_VIO_MASK(3)));
DEVAPC_MSG("4:0x%x, 5:0x%x, 6:0x%x, 7:0x%x, 8:0x%x, 9:0x%x\n",
readl(DEVAPC_PD_INFRA_VIO_MASK(4)), readl(DEVAPC_PD_INFRA_VIO_MASK(5)),
readl(DEVAPC_PD_INFRA_VIO_MASK(6)), readl(DEVAPC_PD_INFRA_VIO_MASK(7)),
readl(DEVAPC_PD_INFRA_VIO_MASK(8)), readl(DEVAPC_PD_INFRA_VIO_MASK(9)));
DEVAPC_MSG("[DEVAPC] INFRA VIO_STA 0:0x%x, 1:0x%x, 2:0x%x, 3:0x%x, ",
readl(DEVAPC_PD_INFRA_VIO_STA(0)), readl(DEVAPC_PD_INFRA_VIO_STA(1)),
readl(DEVAPC_PD_INFRA_VIO_STA(2)), readl(DEVAPC_PD_INFRA_VIO_STA(3)));
DEVAPC_MSG("4:0x%x, 5:0x%x, 6:0x%x, 7:0x%x, 8:0x%x, 9:0x%x\n",
readl(DEVAPC_PD_INFRA_VIO_STA(4)), readl(DEVAPC_PD_INFRA_VIO_STA(5)),
readl(DEVAPC_PD_INFRA_VIO_STA(6)), readl(DEVAPC_PD_INFRA_VIO_STA(7)),
readl(DEVAPC_PD_INFRA_VIO_STA(8)), readl(DEVAPC_PD_INFRA_VIO_STA(9)));
DEVAPC_MSG("[DEVAPC] Clear INFRA VIO_STA and unmask INFRA VIO_MASK...\n");
for (i = 0; i < ARRAY_SIZE(devapc_infra_devices); i++)
if (true == devapc_infra_devices[i].enable_vio_irq) {
clear_infra_vio_status(i);
unmask_infra_module_irq(i);
}
DEVAPC_MSG("[DEVAPC] INFRA VIO_MASK 0:0x%x, 1:0x%x, 2:0x%x, 3:0x%x, ",
readl(DEVAPC_PD_INFRA_VIO_MASK(0)), readl(DEVAPC_PD_INFRA_VIO_MASK(1)),
readl(DEVAPC_PD_INFRA_VIO_MASK(2)), readl(DEVAPC_PD_INFRA_VIO_MASK(3)));
DEVAPC_MSG("4:0x%x, 5:0x%x, 6:0x%x, 7:0x%x, 8:0x%x, 9:0x%x\n",
readl(DEVAPC_PD_INFRA_VIO_MASK(4)), readl(DEVAPC_PD_INFRA_VIO_MASK(5)),
readl(DEVAPC_PD_INFRA_VIO_MASK(6)), readl(DEVAPC_PD_INFRA_VIO_MASK(7)),
readl(DEVAPC_PD_INFRA_VIO_MASK(8)), readl(DEVAPC_PD_INFRA_VIO_MASK(9)));
DEVAPC_MSG("[DEVAPC] INFRA VIO_STA 0:0x%x, 1:0x%x, 2:0x%x, 3:0x%x, ",
readl(DEVAPC_PD_INFRA_VIO_STA(0)), readl(DEVAPC_PD_INFRA_VIO_STA(1)),
readl(DEVAPC_PD_INFRA_VIO_STA(2)), readl(DEVAPC_PD_INFRA_VIO_STA(3)));
DEVAPC_MSG("4:0x%x, 5:0x%x, 6:0x%x, 7:0x%x, 8:0x%x, 9:0x%x\n",
readl(DEVAPC_PD_INFRA_VIO_STA(4)), readl(DEVAPC_PD_INFRA_VIO_STA(5)),
readl(DEVAPC_PD_INFRA_VIO_STA(6)), readl(DEVAPC_PD_INFRA_VIO_STA(7)),
readl(DEVAPC_PD_INFRA_VIO_STA(8)), readl(DEVAPC_PD_INFRA_VIO_STA(9)));
#if defined(CONFIG_MTK_AEE_FEATURE) && defined(DEVAPC_ENABLE_AEE)
DEVAPC_MSG("[DEVAPC] initialize current aee trigger times.\n");
devapc_vio_current_aee_trigger_times = 0;
#endif
}
#if defined(CONFIG_MTK_AEE_FEATURE) && defined(DEVAPC_ENABLE_AEE)
static void execute_aee(unsigned int i, unsigned int dbg0, unsigned int dbg1)
{
char aee_str[256];
unsigned int domain_id;
int ret = 0;
DEVAPC_VIO_MSG("[DEVAPC] Executing AEE Exception...\n");
/* Mark the flag for showing AEE (AEE should be shown only once) */
devapc_vio_aee_shown[i] = 1;
if (devapc_vio_current_aee_trigger_times < DEVAPC_VIO_MAX_TOTAL_MODULE_AEE_TRIGGER_TIMES) {
devapc_vio_current_aee_trigger_times++;
ret = snprintf(aee_str, sizeof(aee_str),
"[DEVAPC] Access Violation Slave: %s (infra index=%d)\n",
devapc_infra_devices[i].device, i);
if (ret < 0 || ret >= sizeof(aee_str))
DEVAPC_VIO_MSG("[DEVAPC] snprintf failed ret = %d\n",ret);
domain_id = (dbg0 & INFRA_VIO_DBG_DMNID) >> INFRA_VIO_DBG_DMNID_START_BIT;
if (domain_id == 1) {
aee_kernel_exception(aee_str,
"%s\nAccess Violation Slave: %s\nVio Addr: 0x%x\n%s%s\n",
"Device APC Violation",
devapc_infra_devices[i].device,
dbg1,
"CRDISPATCH_KEY:Device APC Violation Issue/",
"MD_SI"
);
} else {
aee_kernel_exception(aee_str,
"%s\nAccess Violation Slave: %s\nVio Addr: 0x%x\n%s%s\n",
"Device APC Violation",
devapc_infra_devices[i].device,
dbg1,
"CRDISPATCH_KEY:Device APC Violation Issue/",
devapc_infra_devices[i].device
);
}
}
}
static void evaluate_aee_exception(unsigned int i, unsigned int dbg0, unsigned int dbg1)
{
unsigned long long current_time;
if (devapc_vio_count[i] < DEVAPC_VIO_AEE_TRIGGER_TIMES) {
devapc_vio_count[i] += i;
if (devapc_vio_count[i] == 1) {
/* this slave violation is triggered for the first time */
/* get current time from start-up in ns */
devapc_vio_first_trigger_time[i] = sched_clock();
DEVAPC_VIO_MSG("[DEVAPC] devapc_vio_first_trigger_time: %lu\n",
/*ms*/
do_div(devapc_vio_first_trigger_time[i], 1000000));
}
}
if (devapc_vio_count[i] >= DEVAPC_VIO_AEE_TRIGGER_TIMES) {
current_time = sched_clock(); /* get current time from start-up in ns */
DEVAPC_VIO_MSG("[DEVAPC] current_time: %lu\n",
do_div(current_time, 1000000)); /* ms */
DEVAPC_VIO_MSG("[DEVAPC] devapc_vio_count[%d]: %d\n",
i, devapc_vio_count[i]);
if (((current_time - devapc_vio_first_trigger_time[i]) / 1000000) <=
/*diff time by ms*/
(unsigned long long)DEVAPC_VIO_AEE_TRIGGER_FREQUENCY) {
execute_aee(i, dbg0, dbg1);
}
}
}
#endif
static irqreturn_t devapc_violation_irq(int irq_number, void *dev_id)
{
unsigned int dbg0 = 0, dbg1 = 0;
unsigned int master_id;
unsigned int domain_id;
unsigned int vio_addr_high;
unsigned int read_violation;
unsigned int write_violation;
unsigned int device_count;
unsigned int shift_done;
unsigned int i;
struct pt_regs *regs;
if (irq_number == devapc_infra_irq) {
#if DEVAPC_VIO_DEBUG
DEVAPC_VIO_MSG(
"[DEVAPC]%s0:0x%x 1:0x%x 2:0x%x 3:0x%x 4:0x%x 5:0x%x 6:0x%x 7:0x%x 8:0x%x 9:0x%x\n",
"INFRA VIO_MASK",
readl(DEVAPC_PD_INFRA_VIO_MASK(0)), readl(DEVAPC_PD_INFRA_VIO_MASK(1)),
readl(DEVAPC_PD_INFRA_VIO_MASK(2)), readl(DEVAPC_PD_INFRA_VIO_MASK(3)),
readl(DEVAPC_PD_INFRA_VIO_MASK(4)), readl(DEVAPC_PD_INFRA_VIO_MASK(5)),
readl(DEVAPC_PD_INFRA_VIO_MASK(6)), readl(DEVAPC_PD_INFRA_VIO_MASK(7)),
readl(DEVAPC_PD_INFRA_VIO_MASK(8)), readl(DEVAPC_PD_INFRA_VIO_MASK(9)));
#endif
DEVAPC_VIO_MSG(
"[DEVAPC] %s 0:0x%x 1:0x%x 2:0x%x 3:0x%x4:0x%x 5:0x%x 6:0x%x 7:0x%x 8:0x%x 9:0x%x\n",
"INFRA VIO_STA",
readl(DEVAPC_PD_INFRA_VIO_STA(0)), readl(DEVAPC_PD_INFRA_VIO_STA(1)),
readl(DEVAPC_PD_INFRA_VIO_STA(2)), readl(DEVAPC_PD_INFRA_VIO_STA(3)),
readl(DEVAPC_PD_INFRA_VIO_STA(4)), readl(DEVAPC_PD_INFRA_VIO_STA(5)),
readl(DEVAPC_PD_INFRA_VIO_STA(6)), readl(DEVAPC_PD_INFRA_VIO_STA(7)),
readl(DEVAPC_PD_INFRA_VIO_STA(8)), readl(DEVAPC_PD_INFRA_VIO_STA(9)));
DEVAPC_VIO_MSG("[DEVAPC] VIO_SHIFT_STA: 0x%x\n",
readl(DEVAPC_PD_INFRA_VIO_SHIFT_STA));
for (i = 0; i <= PD_INFRA_VIO_SHIFT_MAX_BIT; ++i)
if (readl(DEVAPC_PD_INFRA_VIO_SHIFT_STA) & (0x1 << i)) {
mt_reg_sync_writel(0x1 << i, DEVAPC_PD_INFRA_VIO_SHIFT_SEL);
mt_reg_sync_writel(0x1, DEVAPC_PD_INFRA_VIO_SHIFT_CON);
/* Use for loop instead of while loop to avoid system hang. */
for (shift_done = 0; (shift_done < 100) &&
((readl(DEVAPC_PD_INFRA_VIO_SHIFT_CON) & 0x3) != 0x3);
++shift_done)
DEVAPC_VIO_MSG("[DEVAPC] Syncing INFRA DBG0 & DBG1 (%d, %d)\n",
i, shift_done);
#if DEVAPC_VIO_DEBUG
DEVAPC_VIO_MSG("[DEVAPC] VIO_SHIFT_SEL=0x%X,VIO_SHIFT_CON=0x%X\n",
readl(DEVAPC_PD_INFRA_VIO_SHIFT_SEL),
readl(DEVAPC_PD_INFRA_VIO_SHIFT_CON));
#endif
if ((readl(DEVAPC_PD_INFRA_VIO_SHIFT_CON) & 0x3) == 0x3) {
DEVAPC_VIO_MSG("[DEVAPC] Sync INFRA DBG0 & DBG1 (%d) SUCCESS\n",
i);
shift_done = 1;
} else {
DEVAPC_VIO_MSG("[DEVAPC] Sync INFRA DBG0 & DBG1 (%d) FAIL\n",
i);
shift_done = 0;
}
mt_reg_sync_writel(0x0, DEVAPC_PD_INFRA_VIO_SHIFT_CON);
if (shift_done) {
dbg0 = readl(DEVAPC_PD_INFRA_VIO_DBG0);
dbg1 = readl(DEVAPC_PD_INFRA_VIO_DBG1);
master_id = (dbg0 & INFRA_VIO_DBG_MSTID) >>
INFRA_VIO_DBG_MSTID_START_BIT;
domain_id = (dbg0 & INFRA_VIO_DBG_DMNID) >>
INFRA_VIO_DBG_DMNID_START_BIT;
write_violation = (dbg0 & INFRA_VIO_DBG_W_VIO) >>
INFRA_VIO_DBG_W_VIO_START_BIT;
read_violation = (dbg0 & INFRA_VIO_DBG_R_VIO) >>
INFRA_VIO_DBG_R_VIO_START_BIT;
vio_addr_high = (dbg0 & INFRA_VIO_ADDR_HIGH) >>
INFRA_VIO_ADDR_HIGH_START_BIT;
}
mt_reg_sync_writel(0x0, DEVAPC_PD_INFRA_VIO_SHIFT_SEL);
mt_reg_sync_writel(0x1 << i, DEVAPC_PD_INFRA_VIO_SHIFT_STA);
#if DEVAPC_VIO_DEBUG
DEVAPC_VIO_MSG(
"[DEVAPC] VIO_SHIFT_STA=0x%X,VIO_SHIFT_SEL=0x%X, VIO_SHIFT_CON=0x%X\n",
readl(DEVAPC_PD_INFRA_VIO_SHIFT_STA),
readl(DEVAPC_PD_INFRA_VIO_SHIFT_SEL),
readl(DEVAPC_PD_INFRA_VIO_SHIFT_CON));
#endif
/* violation information improvement */
if (shift_done)
DEVAPC_VIO_MSG(
"[DEVAPC] %s%s%s - %s%s,%s%i, %s%x (%s%x), %s%x, %s%x\n",
"Violation(Infra,",
read_violation == 1 ? "R" : " ",
write_violation == 1 ? "W)" : " )",
"Process:", current->comm, "PID:", current->pid,
"Vio Addr:0x", dbg1, "High:0x", vio_addr_high,
"Bus ID:0x", master_id, "Dom ID:0x", domain_id);
}
device_count = ARRAY_SIZE(devapc_infra_devices);
/*No need to check violation of EMI & EMI MPU slaves for Infra because they will not be unmasked*/
/* checking and showing violation normal slaves */
for (i = 0; i < device_count; i++)
if (devapc_infra_devices[i].enable_vio_irq == true &&
check_infra_vio_status(i) == 1) {
clear_infra_vio_status(i);
DEVAPC_VIO_MSG(
"[DEVAPC] Access Violation Slave: %s (infra index=%d)\n",
devapc_infra_devices[i].device, i);
#if defined(CONFIG_MTK_AEE_FEATURE) && defined(DEVAPC_ENABLE_AEE)
/* Frequency-based Violation AEE Exception*/
/* it will trigger AEE if violations occur "10" times in "1000" ms*/
evaluate_aee_exception(i, dbg0, dbg1);
#endif
}
#if DEVAPC_VIO_DEBUG
DEVAPC_VIO_MSG(
"[DEVAPC] %s 0:0x%x 1:0x%x 2:0x%x 3:0x%x 4:0x%x 5:0x%x 6:0x%x 7:0x%x 8:0x%x 9:0x%x\n",
"INFRA VIO_STA",
readl(DEVAPC_PD_INFRA_VIO_STA(0)), readl(DEVAPC_PD_INFRA_VIO_STA(1)),
readl(DEVAPC_PD_INFRA_VIO_STA(2)), readl(DEVAPC_PD_INFRA_VIO_STA(3)),
readl(DEVAPC_PD_INFRA_VIO_STA(4)), readl(DEVAPC_PD_INFRA_VIO_STA(5)),
readl(DEVAPC_PD_INFRA_VIO_STA(6)), readl(DEVAPC_PD_INFRA_VIO_STA(7)),
readl(DEVAPC_PD_INFRA_VIO_STA(8)), readl(DEVAPC_PD_INFRA_VIO_STA(9)));
DEVAPC_VIO_MSG("[DEVAPC] INFRA VIO_SHIFT_STA: 0x%x\n",
readl(DEVAPC_PD_INFRA_VIO_SHIFT_STA));
#endif
} else {
DEVAPC_VIO_MSG("[DEVAPC] (ERROR) irq_number %d is not registered!\n",
irq_number);
}
if ((DEVAPC_ENABLE_ONE_CORE_VIOLATION_DEBUG) || (enable_dynamic_one_core_violation_debug)) {
DEVAPC_VIO_MSG("[DEVAPC] ====== Start dumping Device APC violation tracing ==\n");
DEVAPC_VIO_MSG("[DEVAPC] **************** [All IRQ Registers] *******\n");
regs = get_irq_regs();
show_regs(regs);
DEVAPC_VIO_MSG("[DEVAPC] **************** [All Current Task Stack]**********\n");
show_stack(current, NULL);
DEVAPC_VIO_MSG("[DEVAPC] == End of dumping Device APC violation tracing ===\n");
}
return IRQ_HANDLED;
}
#endif
static int devapc_probe(struct platform_device *pdev)
{
struct device_node *node = pdev->dev.of_node;
#if DEVAPC_TURN_ON
int ret;
#endif
DEVAPC_MSG("[DEVAPC] module probe.\n");
if (devapc_pd_infra_base == NULL) {
if (node) {
devapc_pd_infra_base = of_iomap(node,
DAPC_DEVICE_TREE_NODE_PD_INFRA_INDEX);
devapc_infra_irq = irq_of_parse_and_map(node,
DAPC_DEVICE_TREE_NODE_PD_INFRA_INDEX);
DEVAPC_MSG("[DEVAPC] PD_INFRA_ADDRESS: %p, IRQ: %d\n",
devapc_pd_infra_base, devapc_infra_irq);
} else {
pr_info(PFX "can't find DAPC_INFRA_PD compatible node\n");
return -1;
}
}
#if DEVAPC_TURN_ON
ret = request_irq(devapc_infra_irq, (irq_handler_t) devapc_violation_irq,
IRQF_TRIGGER_LOW | IRQF_SHARED, "devapc", &g_devapc_ctrl);
if (ret) {
pr_info(PFX "Failed to request infra irq! (%d)\n", ret);
return ret;
}
#endif
/* CCF */
#if DEVAPC_USE_CCF
dapc_infra_clk = devm_clk_get(&pdev->dev, "devapc-infra-clock");
if (IS_ERR(dapc_infra_clk)) {
pr_info(PFX "(Infra) Cannot get devapc clock from common clock framework.\n");
return PTR_ERR(dapc_infra_clk);
}
if (clk_prepare_enable(dapc_infra_clk)) {
pr_info(PFX "[CCF] cannot enable clock/enable MUX.\n");
return -1;
}
#endif
#ifdef CONFIG_MTK_HIBERNATION
register_swsusp_restore_noirq_func(ID_M_DEVAPC, devapc_pm_restore_noirq, NULL);
#endif
#if DEVAPC_TURN_ON
start_devapc();
#endif
return 0;
}
static int devapc_remove(struct platform_device *dev)
{
clk_disable_unprepare(dapc_infra_clk);
return 0;
}
static int devapc_suspend(struct platform_device *dev, pm_message_t state)
{
return 0;
}
static int devapc_resume(struct platform_device *dev)
{
DEVAPC_MSG("[DEVAPC] module resume.\n");
return 0;
}
static int check_debug_input_type(const char *str)
{
if (sysfs_streq(str, "1"))
return DAPC_INPUT_TYPE_DEBUG_ON;
else if (sysfs_streq(str, "0"))
return DAPC_INPUT_TYPE_DEBUG_OFF;
else
return 0;
}
static ssize_t devapc_dbg_write(struct file *file, const char __user *buffer,
size_t count, loff_t *data)
{
char desc[32];
int len = 0;
int input_type;
len = (count < (sizeof(desc) - 1)) ? count : (sizeof(desc) - 1);
if (copy_from_user(desc, buffer, len))
return -EFAULT;
desc[len] = '\0';
input_type = check_debug_input_type(desc);
if (!input_type)
return -EFAULT;
if (input_type == DAPC_INPUT_TYPE_DEBUG_ON) {
enable_dynamic_one_core_violation_debug = 1;
DEVAPC_MSG("[DEVAPC] One-Core Debugging: Enabled\n");
} else if (input_type == DAPC_INPUT_TYPE_DEBUG_OFF) {
enable_dynamic_one_core_violation_debug = 0;
DEVAPC_MSG("[DEVAPC] One-Core Debugging: Disabled\n");
}
return count;
}
static int devapc_dbg_open(struct inode *inode, struct file *file)
{
return 0;
}
static const struct file_operations devapc_dbg_fops = {
.owner = THIS_MODULE,
.open = devapc_dbg_open,
.write = devapc_dbg_write,
.read = NULL,
};
static const struct of_device_id plat_devapc_dt_match[] = {
{ .compatible = "mediatek,devapc" },
{},
};
static struct platform_driver devapc_driver = {
.probe = devapc_probe,
.remove = devapc_remove,
.suspend = devapc_suspend,
.resume = devapc_resume,
.driver = {
.name = "devapc",
.owner = THIS_MODULE,
.of_match_table = plat_devapc_dt_match,
},
};
/*
* devapc_init: module init function.
*/
static int __init devapc_init(void)
{
int ret;
DEVAPC_MSG("[DEVAPC] kernel module init.\n");
ret = platform_driver_register(&devapc_driver);
if (ret) {
pr_info(PFX "Unable to register driver (%d)\n", ret);
return ret;
}
g_devapc_ctrl = cdev_alloc();
if (!g_devapc_ctrl) {
pr_info(PFX " Failed to add devapc device! (%d)\n", ret);
platform_driver_unregister(&devapc_driver);
return ret;
}
g_devapc_ctrl->owner = THIS_MODULE;
proc_create("devapc_dbg", (00400 | 00200 | 00040 | 00020 | 00004), NULL,
&devapc_dbg_fops);
return 0;
}
/*
* devapc_exit: module exit function.
*/
static void __exit devapc_exit(void)
{
DEVAPC_MSG("[DEVAPC] DEVAPC module exit\n");
#ifdef CONFIG_MTK_HIBERNATION
unregister_swsusp_restore_noirq_func(ID_M_DEVAPC);
#endif
}
arch_initcall(devapc_init);
module_exit(devapc_exit);
MODULE_LICENSE("GPL");
@@ -0,0 +1,92 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2015 MediaTek Inc.
*/
#ifndef __DAPC_H__
#define __DAPC_H__
#include <linux/types.h>
/******************************************************************************
* CONSTANT DEFINATION
******************************************************************************/
#define MOD_NO_IN_1_DEVAPC 16
#define DEVAPC_TAG "DEVAPC"
/* 1: Force to enable enhanced one-core violation debugging */
/* 0: Enhanced one-core violation debugging can be enabled dynamically */
/* Notice: You should only use one core to debug */
#define DEVAPC_ENABLE_ONE_CORE_VIOLATION_DEBUG 0
#define DAPC_INPUT_TYPE_DEBUG_ON 200
#define DAPC_INPUT_TYPE_DEBUG_OFF 100
#define DAPC_DEVICE_TREE_NODE_PD_INFRA_INDEX 0
/* Uncomment to enable AEE */
#define DEVAPC_ENABLE_AEE 1
#if defined(CONFIG_MTK_AEE_FEATURE) && defined(DEVAPC_ENABLE_AEE)
/* This is necessary for AEE */
#define DEVAPC_TOTAL_SLAVES 199
/* AEE trigger threshold for each module. */
#define DEVAPC_VIO_AEE_TRIGGER_TIMES 10
/* AEE trigger frequency for each module (ms) */
#define DEVAPC_VIO_AEE_TRIGGER_FREQUENCY 1000
/* Maximum populating AEE times for all the modules */
#define DEVAPC_VIO_MAX_TOTAL_MODULE_AEE_TRIGGER_TIMES 3
#endif
/* For Infra VIO_DBG */
#define INFRA_VIO_DBG_MSTID 0x0000FFFF
#define INFRA_VIO_DBG_MSTID_START_BIT 0
#define INFRA_VIO_DBG_DMNID 0x003F0000
#define INFRA_VIO_DBG_DMNID_START_BIT 16
#define INFRA_VIO_DBG_W_VIO 0x00400000
#define INFRA_VIO_DBG_W_VIO_START_BIT 22
#define INFRA_VIO_DBG_R_VIO 0x00800000
#define INFRA_VIO_DBG_R_VIO_START_BIT 23
#define INFRA_VIO_ADDR_HIGH 0x0F000000
#define INFRA_VIO_ADDR_HIGH_START_BIT 24
/******************************************************************************
* REGISTER ADDRESS DEFINATION
******************************************************************************/
/* Device APC PD */
#define PD_INFRA_VIO_SHIFT_MAX_BIT 21
#define PD_INFRA_VIO_MASK_MAX_INDEX 198
#define PD_INFRA_VIO_STA_MAX_INDEX 198
#define DEVAPC_PD_INFRA_VIO_MASK(index) ((unsigned int *)(devapc_pd_infra_base + 0x4 * index))
#define DEVAPC_PD_INFRA_VIO_STA(index) \
((unsigned int *)(devapc_pd_infra_base + 0x400 + 0x4 * index))
#define DEVAPC_PD_INFRA_VIO_DBG0 ((unsigned int *)(devapc_pd_infra_base+0x900))
#define DEVAPC_PD_INFRA_VIO_DBG1 ((unsigned int *)(devapc_pd_infra_base+0x904))
#define DEVAPC_PD_INFRA_APC_CON ((unsigned int *)(devapc_pd_infra_base+0xF00))
#define DEVAPC_PD_INFRA_VIO_SHIFT_STA ((unsigned int *)(devapc_pd_infra_base+0xF10))
#define DEVAPC_PD_INFRA_VIO_SHIFT_SEL ((unsigned int *)(devapc_pd_infra_base+0xF14))
#define DEVAPC_PD_INFRA_VIO_SHIFT_CON ((unsigned int *)(devapc_pd_infra_base+0xF20))
struct DEVICE_INFO {
const char *device;
bool enable_vio_irq;
};
#ifdef CONFIG_MTK_HIBERNATION
extern void mt_irq_set_sens(unsigned int irq, unsigned int sens);
extern void mt_irq_set_polarity(unsigned int irq, unsigned int polarity);
#endif
#endif /* __DAPC_H__ */
@@ -0,0 +1,14 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
obj-y += devapc.o
File diff suppressed because it is too large. Load diff
+122
View File
@@ -0,0 +1,122 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2015-2020 MediaTek Inc.
*/
#ifndef __DAPC_H__
#define __DAPC_H__
#include <linux/types.h>
/******************************************************************************
* CONSTANT DEFINATION
******************************************************************************/
#define MOD_NO_IN_1_DEVAPC 16
#define DEVAPC_TAG "DEVAPC"
/* 1: Force to enable enhanced one-core violation debugging */
/* 0: Enhanced one-core violation debugging can be enabled dynamically */
/* Notice: You should only use one core to debug */
#ifdef DBG_ENABLE
#define DEVAPC_ENABLE_ONE_CORE_VIOLATION_DEBUG 1
#else
#define DEVAPC_ENABLE_ONE_CORE_VIOLATION_DEBUG 0
#endif
#define MTK_SIP_LK_DAPC 0x82000101
#define DAPC_DEVICE_TREE_NODE_PD_INFRA_INDEX 0
/* Uncomment to enable AEE */
#define DEVAPC_ENABLE_AEE 1
#define DEVAPC_TOTAL_SLAVES 214
#if defined(CONFIG_MTK_AEE_FEATURE) && defined(DEVAPC_ENABLE_AEE)
/* This is necessary for AEE */
#endif
/* For Infra VIO_DBG */
#define INFRA_VIO_DBG_MSTID 0x0000FFFF
#define INFRA_VIO_DBG_MSTID_START_BIT 0
#define INFRA_VIO_DBG_DMNID 0x003F0000
#define INFRA_VIO_DBG_DMNID_START_BIT 16
#define INFRA_VIO_DBG_W_VIO 0x00400000
#define INFRA_VIO_DBG_W_VIO_START_BIT 22
#define INFRA_VIO_DBG_R_VIO 0x00800000
#define INFRA_VIO_DBG_R_VIO_START_BIT 23
#define INFRA_VIO_ADDR_HIGH 0x0F000000
#define INFRA_VIO_ADDR_HIGH_START_BIT 24
/******************************************************************************
* REGISTER ADDRESS DEFINATION
******************************************************************************/
/* Device APC PD */
#define PD_INFRA_VIO_SHIFT_MAX_BIT 22
#define PD_INFRA_VIO_MASK_MAX_INDEX 276
#define PD_INFRA_VIO_STA_MAX_INDEX 276
#define DEVAPC_PD_INFRA_VIO_MASK(index) \
((unsigned int *)(devapc_pd_infra_base + 0x4 * index))
#define DEVAPC_PD_INFRA_VIO_STA(index) \
((unsigned int *)(devapc_pd_infra_base + 0x400 + 0x4 * index))
#define DEVAPC_PD_INFRA_VIO_DBG0 \
((unsigned int *)(devapc_pd_infra_base+0x900))
#define DEVAPC_PD_INFRA_VIO_DBG1 \
((unsigned int *)(devapc_pd_infra_base+0x904))
#define DEVAPC_PD_INFRA_APC_CON \
((unsigned int *)(devapc_pd_infra_base+0xF00))
#define DEVAPC_PD_INFRA_VIO_SHIFT_STA \
((unsigned int *)(devapc_pd_infra_base+0xF10))
#define DEVAPC_PD_INFRA_VIO_SHIFT_SEL \
((unsigned int *)(devapc_pd_infra_base+0xF14))
#define DEVAPC_PD_INFRA_VIO_SHIFT_CON \
((unsigned int *)(devapc_pd_infra_base+0xF20))
struct DEVICE_INFO {
const char *device;
bool enable_vio_irq;
};
#ifdef CONFIG_MTK_HIBERNATION
extern void mt_irq_set_sens(unsigned int irq, unsigned int sens);
extern void mt_irq_set_polarity(unsigned int irq, unsigned int polarity);
#endif
enum DEVAPC_SLAVE_TYPE {
E_DAPC_INFRA_PERI_SLAVE = 0,
E_DAPC_MM_SLAVE,
E_DAPC_MD_SLAVE,
E_DAPC_PERI_SLAVE,
E_DAPC_MM2ND_SLAVE,
E_DAPC_OTHERS_SLAVE,
E_DAPC_SLAVE_TYPE_RESERVRD = 0x7FFFFFFF /* force enum to use 32 bits */
};
enum E_MASK_DOM {
E_DOMAIN_0 = 0,
E_DOMAIN_1,
E_DOMAIN_2,
E_DOMAIN_3,
E_DOMAIN_4,
E_DOMAIN_5,
E_DOMAIN_6,
E_DOMAIN_7,
E_DOMAIN_8,
E_DOMAIN_9,
E_DOMAIN_10,
E_DOMAIN_11,
E_DOMAIN_12,
E_DOMAIN_13,
E_DOMAIN_14,
E_DOMAIN_15,
E_DOMAIN_OTHERS,
E_MASK_DOM_RESERVRD = 0x7FFFFFFF /* force enum to use 32 bits */
};
#endif /* __DAPC_H__ */
@@ -0,0 +1,14 @@
#
# Copyright (C) 2015 MediaTek Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
obj-y += devapc.o
File diff suppressed because it is too large. Load diff
+100
View File
@@ -0,0 +1,100 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2019 MediaTek Inc.
*/
#ifndef __DAPC_H__
#define __DAPC_H__
#include <linux/types.h>
/******************************************************************************
* CONSTANT DEFINATION
******************************************************************************/
#define MOD_NO_IN_1_DEVAPC 16
#define DEVAPC_TAG "DEVAPC"
/* 1: Force to enable enhanced one-core violation debugging */
/* 0: Enhanced one-core violation debugging can be enabled dynamically */
#ifdef DBG_ENABLE
#define DEVAPC_ENABLE_ONE_CORE_VIOLATION_DEBUG 1
#else
#define DEVAPC_ENABLE_ONE_CORE_VIOLATION_DEBUG 0
#endif
#define DAPC_INPUT_TYPE_DEBUG_OFF 100
#define DAPC_INPUT_TYPE_DEBUG_ON 200
#define DAPC_INPUT_TYPE_VIO_UT 300
#define DAPC_DEVICE_TREE_NODE_PD_INFRA_INDEX 0
#define DAPC_DEVICE_TREE_NODE_AO_INFRA_INDEX 1
/* Uncomment to enable AEE */
#define DEVAPC_ENABLE_AEE 1
#if defined(CONFIG_MTK_AEE_FEATURE) && defined(DEVAPC_ENABLE_AEE)
/* This is necessary for AEE */
#define DEVAPC_TOTAL_SLAVES 237
/* AEE trigger threshold for each module. */
#define DEVAPC_VIO_AEE_TRIGGER_TIMES 10
/* AEE trigger frequency for each module (ms) */
#define DEVAPC_VIO_AEE_TRIGGER_FREQUENCY 1000
/* Maximum populating AEE times for all the modules */
#define DEVAPC_VIO_MAX_TOTAL_AEE_TRIGGER_TIMES 3
#endif
/* For Infra VIO_DBG */
#define INFRA_VIO_DBG_MSTID 0x0000FFFF
#define INFRA_VIO_DBG_MSTID_START_BIT 0
#define INFRA_VIO_DBG_DMNID 0x003F0000
#define INFRA_VIO_DBG_DMNID_START_BIT 16
#define INFRA_VIO_DBG_W_VIO 0x00400000
#define INFRA_VIO_DBG_W_VIO_START_BIT 22
#define INFRA_VIO_DBG_R_VIO 0x00800000
#define INFRA_VIO_DBG_R_VIO_START_BIT 23
#define INFRA_VIO_ADDR_HIGH 0x0F000000
#define INFRA_VIO_ADDR_HIGH_START_BIT 24
/******************************************************************************
* REGISTER ADDRESS DEFINATION
******************************************************************************/
/* Device APC PD */
#define PD_INFRA_VIO_SHIFT_MAX_BIT 22
#define PD_INFRA_VIO_MASK_MAX_INDEX 276
#define PD_INFRA_VIO_STA_MAX_INDEX 276
#define DEVAPC_PD_INFRA_VIO_MASK(index) \
((unsigned int *)(devapc_pd_infra_base + 0x4 * index))
#define DEVAPC_PD_INFRA_VIO_STA(index) \
((unsigned int *)(devapc_pd_infra_base + 0x400 + 0x4 * index))
#define DEVAPC_PD_INFRA_VIO_DBG0 \
((unsigned int *)(devapc_pd_infra_base+0x900))
#define DEVAPC_PD_INFRA_VIO_DBG1 \
((unsigned int *)(devapc_pd_infra_base+0x904))
#define DEVAPC_PD_INFRA_APC_CON \
((unsigned int *)(devapc_pd_infra_base+0xF00))
#define DEVAPC_PD_INFRA_VIO_SHIFT_STA \
((unsigned int *)(devapc_pd_infra_base+0xF10))
#define DEVAPC_PD_INFRA_VIO_SHIFT_SEL \
((unsigned int *)(devapc_pd_infra_base+0xF14))
#define DEVAPC_PD_INFRA_VIO_SHIFT_CON \
((unsigned int *)(devapc_pd_infra_base+0xF20))
struct DEVICE_INFO {
const char *device;
bool enable_vio_irq;
};
#ifdef CONFIG_MTK_HIBERNATION
extern void mt_irq_set_sens(unsigned int irq, unsigned int sens);
extern void mt_irq_set_polarity(unsigned int irq, unsigned int polarity);
#endif
#endif /* __DAPC_H__ */