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

+129
View File
@@ -0,0 +1,129 @@
#
# MediaTek SoC drivers
#
menu "MediaTek SoC drivers"
depends on ARCH_MEDIATEK || COMPILE_TEST
config MTK_CMDQ
tristate "MediaTek CMDQ Support"
depends on ARCH_MEDIATEK || COMPILE_TEST
select MAILBOX
select MTK_CMDQ_MBOX
select MTK_INFRACFG
help
Say yes here to add support for the MediaTek Command Queue (CMDQ)
driver. The CMDQ is used to help read/write registers with critical
time limitation, such as updating display configuration during the
vblank.
config MTK_INFRACFG
bool "MediaTek INFRACFG Support"
select REGMAP
help
Say yes here to add support for the MediaTek INFRACFG controller. The
INFRACFG controller contains various infrastructure registers not
directly associated to any device.
config MTK_DVFSRC
tristate "MediaTek DVFSRC Support"
depends on ARCH_MEDIATEK
help
Say yes here to add support for the MediaTek DVFSRC (dynamic voltage
and frequency scaling resource collector) found
on different MediaTek SoCs. The DVFSRC is a proprietary
hardware which is used to collect all the requests from
system and turn into the decision of minimum Vcore voltage
and minimum DRAM frequency to fulfill those requests.
config MTK_PMIC_WRAP
tristate "MediaTek PMIC Wrapper Support"
select RESET_CONTROLLER
select REGMAP
help
Say yes here to add support for MediaTek PMIC Wrapper found
on different MediaTek SoCs. The PMIC wrapper is a proprietary
hardware to connect the PMIC.
config MTK_SCPSYS
bool "MediaTek SCPSYS Support"
default ARCH_MEDIATEK
select REGMAP
select MTK_INFRACFG
select PM_GENERIC_DOMAINS if PM
help
Say yes here to add support for the MediaTek SCPSYS power domain
driver.
config MTK_SCPSYS_BRINGUP
bool "MediaTek SCPSYS bring Up Support"
depends on MTK_SCPSYS
help
Say yes here to support for MediaTek SCPSYS power domain power on
for chip bring up early stage.
This driver is used to turn on the specific power domain for chip
bringing up stage.
config MTK_MMDVFS
tristate "MediaTek MMDVFS Support"
depends on ARCH_MEDIATEK || COMPILE_TEST
depends on REGULATOR_MTK_DVFSRC
help
Say yes here to add support for the MediaTek Multimedia DVFS (MMDVFS)
driver. The MMDVFS is used to set clk for Mediatek multimedia hardwares
, such as display, camera, mdp and video codec. Say no if your device
does not need to do DVFS for Multimedia hardwares.
config MTK_IPI
tristate "MediaTek IPI Support"
depends on RPMSG_MTK
help
Say yes here to add support for the MediaTek IPI between tinysys.
MTK IPI consists of APIs to do Linux to/from uP/DSP communication
based on rpmsg. Synchronization among tasks is also handled by
this layer. If uP/DSP drivers handle by themselves, they can use
rpmsg directly.
config MTK_MBOX
tristate "MediaTek Mbox Support"
help
Say yes here to add support for the MediaTek Mbox driver.
MTK MBOX is a physical H/W which consists of configurable 128
or 256 bytes SRAM and 32 bit irq. The driver does read/write
SRAM and IRQ handling.
config MTK_LPM
bool "MediaTek Low Power Manager"
depends on ARCH_MEDIATEK
help
Say yes here to add support for the MediaTek Low Power Manager
driver. The mtk-lpm will handle the mtk low power module then
platform could enter deeper sleep mode when cpu preparing to
power down if it have sufficient time between warmboot.
config MTK_PMQOS
tristate "MediaTek PMQOS Framework support"
depends on ARCH_MEDIATEK
help
Say yes here to support for the MediaTek PMQOS framework
driver. Driver can register the Qos class notify and receive
from the devices request to adjust qos policy for power
and performance.
menu "Security"
source "drivers/soc/mediatek/devapc/Kconfig"
source "drivers/soc/mediatek/devmpu/Kconfig"
endmenu # Security
config MTK_SOCINFO
tristate "MediaTek SoCInfo Driver"
select SOC_BUS
help
Say yes here to support the MediaTek SoCInfo driver, providing
information about the SoC to user space. From Android, Google
export Soc information by unified Android property for APP
vendor, instead of sysfs which maintained by each SoC vendor.
endmenu
+25
View File
@@ -0,0 +1,25 @@
obj-$(CONFIG_MTK_PMQOS) += mtk-pm-qos.o
obj-$(CONFIG_MTK_CMDQ) += mtk-cmdq-helper.o
ccflags-$(CONFIG_MTK_CMDQ_MBOX_EXT) += -I$(srctree)/drivers/misc/mediatek/cmdq/mailbox
obj-$(CONFIG_MTK_INFRACFG) += mtk-infracfg.o mtk-scpsys-ext.o
obj-$(CONFIG_MTK_DVFSRC) += mtk-dvfsrc.o
ifneq (,$(filter $(CONFIG_MTK_PLATFORM), "mt6768" "mt6739" "mt6785" "mt6853" "mt6771" "mt6873" "mt6885"))
obj-$(CONFIG_MTK_PMIC_WRAP) += mtk-pmic-wrap_v1.o
else
obj-$(CONFIG_MTK_PMIC_WRAP) += mtk-pmic-wrap.o
endif
obj-$(CONFIG_MTK_SCPSYS) += mtk-scpsys.o
obj-$(CONFIG_MTK_SCPSYS_BRINGUP) += mtk-scpsys-bringup.o
obj-$(CONFIG_MTK_DEVAPC) += devapc/
obj-$(CONFIG_MTK_DEVMPU) += devmpu/
obj-$(CONFIG_MTK_CMDQ_MBOX) += mtk-cmdq-helper.o
obj-$(CONFIG_MTK_MBOX) += mtk-mbox.o
obj-$(CONFIG_MTK_MMDVFS) += mtk-mmdvfs.o
obj-$(CONFIG_MTK_LPM) += mtk-lpm.o
obj-$(CONFIG_MTK_SOCINFO) += mtk-socinfo.o
obj-$(CONFIG_MTK_MBOX) += mtk-mbox.o
obj-$(CONFIG_MTK_IPI) += mtk_tinysys_ipi.o
ccflags-y += -I$(srctree)/drivers/misc/mediatek/include
+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__ */
+96
View File
@@ -0,0 +1,96 @@
config MTK_DEVMPU
bool "Enable MTK Device MPU driver"
help
Device MPU is a kernel driver providing
non-continuous memory protection in the
2MB granularity. Note that the protection
is conducted in parallel with EMI MPU.
config MTK_DEVMPU_EMI
bool "Enable MTK Device MPU with EMI MPU"
select MTK_DEVMPU
help
Device MPU hardware will receive the violation
from EMI MPU hardware. Device MPU driver will
receive violation via call-back function of
EMI MPU.
config MTK_DEVMPU_SLOG
bool "Enable slog for Device MPU violation"
depends on MTK_DEVMPU
help
Say yes here to enable mtk slog. When Device
MPU violation occur, Device MPU driver will dump
violation info to slog, then slog system record
it and list as issue when offline parsing.
config DEVMPU_MT6779
bool "Mediatek MT6779 Device MPU driver"
depends on MACH_MT6779
select MTK_DEVMPU if (MTK_EMI || MEDIATEK_EMI)
select MTK_DEVMPU_EMI if (MTK_EMI || MEDIATEK_EMI)
help
Say yes here to enable support Mediatek MT6885
Device MPU driver. This driver is combined with
SUB, ACP and EMI features of Device MPU in
MT6779 platfom.
config DEVMPU_MT6781
bool "Mediatek MT6781 Device MPU driver"
depends on MACH_MT6781
select MTK_DEVMPU
help
Say yes here to enable support Mediatek MT6781
Device MPU driver. This driver is only for
Device MPU feature in MT6781 platfom without
EMI.
config DEVMPU_MT6833
bool "Mediatek MT6833 Device MPU driver"
depends on MACH_MT6833
select MTK_DEVMPU
help
Say yes here to enable support Mediatek MT6833
Device MPU driver. This driver is only for
Device MPU feature in MT6833 platfom without
EMI.
config DEVMPU_MT6853
bool "Mediatek MT6853 Device MPU driver"
depends on MACH_MT6853
select MTK_DEVMPU
help
Say yes here to enable support Mediatek MT6853
Device MPU driver. This driver is combined with
ACP features of Device MPU in MT6853 platfom
without EMI.
config DEVMPU_MT6873
bool "Mediatek MT6873 Device MPU driver"
depends on MACH_MT6873
select MTK_DEVMPU
help
Say yes here to enable support Mediatek MT6873
Device MPU driver. This driver is combined with
ACP and EMI features of Device MPU in MT6873
platfom.
config DEVMPU_MT6877
bool "Mediatek MT6877 Device MPU driver"
depends on MACH_MT6877
select MTK_DEVMPU
help
Say yes here to enable support Mediatek MT6877
Device MPU driver. This driver is only for
Device MPU feature in MT6877 platfom without
EMI.
config DEVMPU_MT6885
bool "Mediatek MT6885 Device MPU driver"
depends on MACH_MT6885 || MACH_MT6893
select MTK_DEVMPU if (MTK_EMI || MEDIATEK_EMI)
help
Say yes here to enable support Mediatek MT6885
Device MPU driver. This driver is combined with
SUB, ACP and EMI features of Device MPU in
MT6885 platfom.
+26
View File
@@ -0,0 +1,26 @@
#
# Copyright (C) 2018 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.
#
ifeq ($(CONFIG_MTK_GCOV_KERNEL),y)
GCOV_PROFILE := y
endif
PLATFORM := $(subst ",,$(CONFIG_MTK_PLATFORM))
ccflags-y += \
-I$(srctree)/drivers/misc/mediatek/emi/$(PLATFORM) \
-I$(srctree)/drivers/misc/mediatek/emi/submodule \
-I$(srctree)/include/memory/mediatek
obj-$(CONFIG_MTK_DEVMPU) += devmpu.o
obj-$(CONFIG_MTK_DEVMPU_EMI) += devmpu_emi.o
+607
View File
@@ -0,0 +1,607 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (C) 2019 MediaTek Inc.
*/
#include <asm/page.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_irq.h>
#include <linux/device.h>
#include <linux/compiler.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <linux/arm-smccc.h>
#include <linux/soc/mediatek/mtk_sip_svc.h>
#include <memory/mediatek/emi.h>
#include <devmpu.h>
#include <devmpu_emi.h>
#if IS_ENABLED(CONFIG_MTK_DEVMPU_SLOG)
#define CREATE_TRACE_POINTS
#include "devmpu_trace.h"
#endif
#if IS_ENABLED(CONFIG_MTK_AEE_FEATURE)
#include <mt-plat/aee.h>
#endif
#define LOG_TAG "[DEVMPU]"
#define DEVMPU_MAX_TAG_LEN 15
#define DUMP_TAG "dump_devmpu"
#define CHECK_TAG "violate_devmpu"
#define DEVMPU_MAX_CTX 3
#define DEVMPU_DEFAULT_CTX 0
#ifdef pr_fmt
#undef pr_fmt
#endif
#define pr_fmt(fmt) LOG_TAG " " fmt
#define switchValue(x) (((x << 24) & 0xff000000) | \
((x << 8) & 0x00ff0000) | \
((x >> 8) & 0x0000ff00) | \
((x >> 24) & 0x000000ff))
struct devmpu_context {
/* HW register mapped base */
void __iomem *reg_base;
/* DRAM (PA) space protected */
uint64_t prot_base;
uint64_t prot_size;
/* page granularity */
uint32_t page_size;
/* virtual irq number */
uint32_t virq;
/* max ctx */
uint32_t max_ctx;
} devmpu_ctx_ary[DEVMPU_MAX_CTX];
struct devmpu_vio_stat {
/* master ID */
uint16_t id;
/* master domain */
uint8_t domain;
/* is NS transaction (AxPROT[1]) */
bool is_ns;
/* is write violation */
bool is_write;
/* padding */
uint8_t padding[3];
/* physical address */
uint64_t addr;
};
static int devmpu_vio_get(struct devmpu_vio_stat *vio, bool do_clear)
{
struct arm_smccc_res res;
size_t vio_addr;
size_t vio_info;
if (unlikely(vio == NULL)) {
pr_err("%s:%d output pointer is NULL\n",
__func__, __LINE__);
return -1;
}
arm_smccc_smc(MTK_SIP_KERNEL_DEVMPU_VIO_GET,
do_clear, 0, 0, 0, 0, 0, 0, &res);
if (res.a0) {
pr_err("%s:%d failed to get violation, ret=0x%lx\n",
__func__, __LINE__, res.a0);
return -1;
}
vio_addr = res.a1;
vio_info = res.a2;
vio->addr = vio_addr;
vio->is_write = (vio_info >> 0) & 0x1;
vio->is_ns = (vio_info >> 1) & 0x1;
vio->domain = (vio_info >> 8) & 0xFF;
vio->id = (vio_info >> 16) & 0xFFFF;
return 0;
}
void devmpu_vio_clear(unsigned int emi_id)
{
struct arm_smccc_res smc_res;
/* clear hyp violation status */
arm_smccc_smc(MTK_SIP_KERNEL_DEVMPU_VIO_CLR,
emi_id, 0, 0, 0, 0, 0, 0, &smc_res);
if (smc_res.a0) {
pr_err("%s:%d failed to clear violation, ret=0x%lx\n",
__func__, __LINE__, smc_res.a0);
}
}
static int devmpu_rw_perm_get(uint64_t pa,
size_t *rd_perm, size_t *wr_perm)
{
struct arm_smccc_res res;
struct devmpu_context *devmpu_ctx;
devmpu_ctx = &devmpu_ctx_ary[DEVMPU_DEFAULT_CTX];
if (unlikely(
pa < devmpu_ctx->prot_base
|| pa >= devmpu_ctx->prot_base + devmpu_ctx->prot_size)) {
pr_err("%s:%d invalid DRAM physical address, pa=0x%llx\n",
__func__, __LINE__, pa);
return -1;
}
if (unlikely(rd_perm == NULL || wr_perm == NULL)) {
pr_err("%s:%d output pointer is NULL\n",
__func__, __LINE__);
return -1;
}
arm_smccc_smc(MTK_SIP_KERNEL_DEVMPU_PERM_GET,
pa, 0, 0, 0, 0, 0, 0, &res);
if (res.a0) {
pr_err("%s:%d failed to get permission, ret=0x%lx\n",
__func__, __LINE__, res.a0);
return -1;
}
*rd_perm = (size_t)res.a1;
*wr_perm = (size_t)res.a2;
return 0;
}
int devmpu_print_violation(uint64_t vio_addr, uint32_t vio_id,
uint32_t vio_domain, uint32_t vio_rw, bool from_emimpu)
{
size_t ret;
struct devmpu_context *devmpu_ctx;
struct devmpu_vio_stat vio = {
.id = 0,
.domain = 0,
.is_ns = false,
.is_write = false,
.addr = 0x0ULL
};
uint32_t vio_axi_id;
uint32_t vio_port_id;
uint64_t page, temp = 0;
size_t rd_perm;
size_t wr_perm;
devmpu_ctx = &devmpu_ctx_ary[DEVMPU_DEFAULT_CTX];
/* overwrite violation info. with the DeviceMPU native one */
if (!from_emimpu) {
ret = devmpu_vio_get(&vio, true);
if (ret) {
pr_err("%s:%d failed to get DeviceMPU violation\n",
__func__, __LINE__);
return -1;
}
vio_id = vio.id;
vio_addr = vio.addr;
vio_domain = vio.domain;
vio_addr += devmpu_ctx->prot_base;
/*
* use 0b01/0b10 to specify write/read violation
* to be consistent with EMI MPU violation handling
*/
vio_rw = (vio.is_write) ? 1 : 2;
}
#ifdef CONFIG_MTK_ENABLE_GENIEZONE
if (vio_rw == 2 && vio_domain == 0)
return 0;
#endif
vio_axi_id = (vio_id >> 3) & 0x1FFF;
vio_port_id = vio_id & 0x7;
pr_info("Device MPU violation\n");
pr_info("current process is \"%s \" (pid: %i)\n",
current->comm, current->pid);
pr_info("corrupted address is 0x%llx\n",
vio_addr);
pr_info("master ID: 0x%x, AXI ID: 0x%x, port ID: 0x%x\n",
vio_id, vio_axi_id, vio_port_id);
pr_info("violation domain 0x%x\n",
vio_domain);
if (vio_rw == 1)
pr_info("write violation\n");
else if (vio_rw == 2)
pr_info("read violation\n");
else
pr_info("strange read/write violation (%u)\n", vio_rw);
if (!devmpu_rw_perm_get(vio_addr, &rd_perm, &wr_perm)) {
page = vio_addr - devmpu_ctx->prot_base;
do_div(page, devmpu_ctx->page_size);
temp = page;
pr_info("Page#%llx RD/WR : %08zx/%08zx (%u)\n",
page,
switchValue(rd_perm),
switchValue(wr_perm),
do_div(temp, 4));
}
if (!from_emimpu) {
pr_info("%s transaction\n",
(vio.is_ns) ? "non-secure" : "secure");
}
#if IS_ENABLED(CONFIG_MTK_DEVMPU_SLOG)
pr_info("dump info to slog\n");
trace_devmpu_event(vio_addr, vio_id, vio_domain, vio_rw);
#endif
#if IS_ENABLED(CONFIG_MTK_AEE_FEATURE)
pr_info("trigger aee exception\n");
aee_kernel_exception("DEVMPU", "%s\n"
"%s(0x%x),%s(0x%x),%s(0x%x),%s(0x%llx)\n",
"violation",
"vio_id", vio_id,
"vio_domain", vio_domain,
"vio_rw", vio_rw,
"vio_addr", vio_addr
);
#endif
return 0;
}
EXPORT_SYMBOL(devmpu_print_violation);
/* sysfs */
static int devmpu_dump_perm(void)
{
struct devmpu_context *devmpu_ctx;
uint32_t i;
uint64_t pa, pa_dump;
uint64_t pages;
size_t rd_perm;
size_t wr_perm;
uint8_t rd_perm_bmp[16];
uint8_t wr_perm_bmp[16];
devmpu_ctx = &devmpu_ctx_ary[DEVMPU_DEFAULT_CTX];
pa = devmpu_ctx->prot_base;
pages = devmpu_ctx->prot_size;
do_div(pages, devmpu_ctx->page_size);
pr_info("Page# (bus-addr) : RD/WR permissions\n");
for (i = 0; i < pages; ++i) {
if (i && i % 16 == 0) {
pa_dump = (uint64_t)(i - 16) * devmpu_ctx->page_size;
pa_dump += devmpu_ctx->prot_base;
pr_info("%04x (%02x_%08x): %08x/%08x %08x/%08x %08x/%08x %08x/%08x\n",
i - 16,
(uint32_t)(pa_dump >> 32),
(uint32_t)(pa_dump & 0xffffffff),
*((uint32_t *)rd_perm_bmp),
*((uint32_t *)wr_perm_bmp),
*((uint32_t *)rd_perm_bmp+1),
*((uint32_t *)wr_perm_bmp+1),
*((uint32_t *)rd_perm_bmp+2),
*((uint32_t *)wr_perm_bmp+2),
*((uint32_t *)rd_perm_bmp+3),
*((uint32_t *)wr_perm_bmp+3));
}
if (devmpu_rw_perm_get(pa, &rd_perm, &wr_perm)) {
pr_err("%s:%d failed to get permission\n",
__func__, __LINE__);
return -EINVAL;
}
rd_perm_bmp[i % 16] = (uint8_t)rd_perm;
wr_perm_bmp[i % 16] = (uint8_t)wr_perm;
pa += devmpu_ctx->page_size;
}
return 0;
}
static int devmpu_check_violation(void)
{
struct devmpu_context *devmpu_ctx;
struct device_node *dn;
void __iomem *reg_base;
uint32_t prop_ary[4];
uint32_t prop_addr;
uint32_t prop_size;
uint64_t prop_value;
devmpu_ctx = &devmpu_ctx_ary[DEVMPU_DEFAULT_CTX];
/* Get property from dts */
dn = of_find_compatible_node(NULL, NULL, "mediatek,atf-reserved");
if (!dn) {
pr_err("%s:%d failed to get device node\n",
__func__, __LINE__);
return -EINVAL;
}
if (of_property_read_u32_array(dn, "reg", prop_ary, 4)) {
pr_err("%s:%d failed to get property\n",
__func__, __LINE__);
return -EINVAL;
}
prop_addr = prop_ary[1];
prop_size = prop_ary[3];
pr_info("Address 0x%x Size 0x%x\n", prop_addr, prop_size);
/* Check if 2MB addr/size alignment */
if (prop_addr % devmpu_ctx->page_size) {
pr_err("%s:%d address is not 2MB alignment 0x%x\n",
__func__, __LINE__, prop_addr);
return -EINVAL;
}
if (prop_size % devmpu_ctx->page_size) {
pr_err("%s:%d size is not 2MB alignment 0x%x\n",
__func__, __LINE__, prop_size);
return -EINVAL;
}
pr_info("Check 2MB address/size alignment correctly\n");
/* Trigger DevMPU violation */
if (prop_addr && prop_size) {
pr_info("Check if DevMPU violation is at 0x%x\n", prop_addr);
reg_base = ioremap((phys_addr_t)prop_addr, prop_size);
if (!reg_base)
return -EIO;
pr_info("Read from 0x%pK\n", reg_base);
prop_value = readq(reg_base);
pr_info("%s:%d value 0x%llx\n", __func__, __LINE__, prop_value);
if (prop_value) {
pr_info("%s:%d EMI didn't protect READ and check HP mode\n",
__func__, __LINE__);
BUG();
}
pr_info("Write to 0x%pK\n", reg_base);
writeq(prop_value | 0x5AA5AA55, reg_base);
prop_value = readq(reg_base);
pr_info("%s:%d value 0x%llx\n", __func__, __LINE__, prop_value);
if (prop_value) {
pr_info("%s:%d EMI didn't protect WRITE and check HP mode\n",
__func__, __LINE__);
BUG();
}
iounmap(reg_base);
}
return 0;
}
static ssize_t devmpu_config_show(struct device_driver *driver, char *buf)
{
return 0;
}
static ssize_t devmpu_config_store(struct device_driver *driver,
const char *buf, size_t count)
{
int ret = 0;
if (strlen(buf) > DEVMPU_MAX_TAG_LEN) {
pr_notice("%s: command overflow\n", __func__);
return -EINVAL;
}
if (!strncmp(buf, DUMP_TAG, strlen(DUMP_TAG))) {
ret = devmpu_dump_perm();
} else if (!strncmp(buf, CHECK_TAG, strlen(CHECK_TAG))) {
ret = devmpu_check_violation();
} else {
pr_notice("%s Invalid argument!!\n", __func__);
return -EINVAL;
}
if (ret) {
pr_notice("%s verificaiton fail!!\n", __func__);
return -EINVAL;
}
return count;
}
static DRIVER_ATTR_RW(devmpu_config);
static irqreturn_t devmpu_irq_handler(int irq, void *dev_id)
{
devmpu_print_violation(0, 0, 0, 0, false);
return IRQ_HANDLED;
}
/* driver registration */
static int devmpu_probe(struct platform_device *pdev)
{
int rc;
void __iomem *reg_base;
static uint32_t probe_cnt;
struct devmpu_context *devmpu_ctx = NULL;
uint64_t prot_base;
uint64_t prot_size;
uint32_t page_size;
uint32_t virq;
struct device_node *dn = pdev->dev.of_node;
struct resource *res = NULL;
pr_info("Device MPU probe: %s\n", pdev->name);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
pr_err("%s:%d failed to get resource\n",
__func__, __LINE__);
return -ENOENT;
}
reg_base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(reg_base)) {
pr_err("%s:%d unable to map DEVMPU_BASE\n",
__func__, __LINE__);
return -ENOENT;
}
if (of_property_read_u64(dn, "prot-base", &prot_base)) {
pr_err("%s:%d failed to get protected region base\n",
__func__, __LINE__);
return -ENOENT;
}
if (of_property_read_u64(dn, "prot-size", &prot_size)) {
pr_err("%s:%d failed to get protected region size\n",
__func__, __LINE__);
return -ENOENT;
}
if (of_property_read_u32(dn, "page-size", &page_size)) {
pr_err("%s:%d failed to get protected region granularity\n",
__func__, __LINE__);
return -ENOENT;
}
virq = irq_of_parse_and_map(dn, 0);
rc = request_irq(virq, (irq_handler_t)devmpu_irq_handler,
IRQF_TRIGGER_NONE, "devmpu", NULL);
if (rc) {
pr_err("%s:%d failed to request irq, rc=%d\n",
__func__, __LINE__, rc);
return -EPERM;
}
if ((probe_cnt + 1) > DEVMPU_MAX_CTX) {
pr_err("%s:%d failed to create context\n",
__func__, __LINE__);
return -EINVAL;
}
devmpu_ctx = &devmpu_ctx_ary[probe_cnt];
devmpu_ctx->reg_base = reg_base;
devmpu_ctx->prot_base = prot_base;
devmpu_ctx->prot_size = prot_size;
devmpu_ctx->page_size = page_size;
devmpu_ctx->virq = virq;
devmpu_ctx->max_ctx = (probe_cnt + 1);
pr_info("Create context [%d]\n", probe_cnt);
pr_info("reg_base=0x%pK\n", devmpu_ctx->reg_base);
pr_info("prot_base=0x%llx\n", devmpu_ctx->prot_base);
pr_info("prot_size=0x%llx\n", devmpu_ctx->prot_size);
pr_info("page_size=0x%x\n", devmpu_ctx->page_size);
pr_info("virq=0x%x\n", devmpu_ctx->virq);
probe_cnt++;
#ifdef CONFIG_MTK_DEVMPU_EMI
rc = devmpu_regist_emi();
if (rc) {
pr_err("%s:%d failed to request EMI callback, rc=%d\n",
__func__, __LINE__, rc);
return -EINVAL;
}
#endif
return 0;
}
static const struct of_device_id devmpu_of_match[] = {
{ .compatible = "mediatek,device_mpu_low" },
{ .compatible = "mediatek,device_mpu_sub" },
{ .compatible = "mediatek,device_mpu_acp" },
{},
};
static struct platform_driver devmpu_drv = {
.probe = devmpu_probe,
.driver = {
.name = "devmpu",
.owner = THIS_MODULE,
.of_match_table = devmpu_of_match,
},
};
static int __init devmpu_init(void)
{
int ret = 0;
ret = platform_driver_register(&devmpu_drv);
if (ret) {
pr_err("%s:%d failed to register devmpu driver, ret=%d\n",
__func__, __LINE__, ret);
}
#if !defined(USER_BUILD_KERNEL)
ret = driver_create_file(&devmpu_drv.driver,
&driver_attr_devmpu_config);
if (ret) {
pr_err("%s:%d failed to create driver sysfs file, ret=%d\n",
__func__, __LINE__, ret);
}
#endif
return ret;
}
static void __exit devmpu_exit(void)
{
#if !defined(USER_BUILD_KERNEL)
driver_remove_file(&devmpu_drv.driver,
&driver_attr_devmpu_config);
#endif
platform_driver_unregister(&devmpu_drv);
}
postcore_initcall(devmpu_init);
module_exit(devmpu_exit);
MODULE_DESCRIPTION("Mediatek Device MPU Driver");
MODULE_AUTHOR("Calvin Liao <calvin.liao@mediatek.com>");
MODULE_LICENSE("GPL");
+29
View File
@@ -0,0 +1,29 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Copyright (C) 2019 MediaTek Inc.
*/
#ifndef __DEVMPU_H__
#define __DEVMPU_H__
void devmpu_vio_clear(unsigned int emi_id);
/**
* Print DeviceMPU violation info.
* @vio_addr: the physical address where the access violation is raised
* @vio_id: the ID of the master triggering violation
* @vio_domain: the domain of the master triggering violation
* @vio_is_write: indicate the violation is triggered by read or write
* @from_emimpu: relies on EMI MPU for complete violation info?
* (for the compatibility to old DeviceMPU design)
* NOTE:
* when from_emimpu is set to false, the value of vio_pa/vio_id/vio_is_write
* are ignored as the true value will be retrieved from DeviceMPU instead of
* EMI MPU.
*
* Return: 0 on success, -1 if any error
*/
int devmpu_print_violation(uint64_t vio_addr, uint32_t vio_id,
uint32_t vio_domain, uint32_t vio_rw, bool from_emimpu);
#endif /* __DEVMPU_H__ */
+107
View File
@@ -0,0 +1,107 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (C) 2019 MediaTek Inc.
*/
#include <asm/page.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_irq.h>
#include <linux/device.h>
#include <linux/compiler.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <emi.h>
#include <devmpu.h>
#include <devmpu_emi.h>
#define LOG_TAG "[DEVMPU_ACP]"
#ifdef pr_fmt
#undef pr_fmt
#endif
#define pr_fmt(fmt) LOG_TAG " " fmt
static irqreturn_t devmpu_irq_handler_emi(unsigned int emi_id,
struct reg_info_t *dump, unsigned int leng)
{
unsigned int i;
unsigned int mpus = 0, mput = 0, mput_2nd = 0;
unsigned long long vio_addr;
unsigned int master_id, domain_id;
unsigned int port_id;
unsigned int wr_vio, wr_oo_vio;
unsigned int hp_wr_vio;
for (i = 0; i < leng; i++) {
if (dump[i].offset == EMI_MPUS_OFFSET)
mpus = dump[i].value;
if (dump[i].offset == EMI_MPUT_OFFSET)
mput = dump[i].value;
if (dump[i].offset == EMI_MPUT_2ND_OFFSET)
mput_2nd = dump[i].value;
}
if (!mput && !mput_2nd) {
pr_err("%s:%d failed to get violation from emi\n",
__func__, __LINE__);
return IRQ_NONE;
}
vio_addr = ((((unsigned long long)(mput_2nd & 0xF)) << 32) + mput);
hp_wr_vio = (mput_2nd >> 21) & 0x3;
master_id = mpus & 0xFFFF;
domain_id = (mpus >> 21) & 0xF;
wr_vio = (mpus >> 29) & 0x3;
wr_oo_vio = (mpus >> 27) & 0x3;
port_id = master_id & 0x7;
#ifdef CONFIG_MTK_ENABLE_GENIEZONE
if ((wr_vio == 2) && (wr_oo_vio == 0) &&
((port_id == 0) || (port_id == 1)))
return IRQ_HANDLED;
#endif
/* if is hyperviosr MPU violation, deliver to DevMPU */
if (hp_wr_vio) {
devmpu_print_violation(vio_addr, master_id, domain_id,
hp_wr_vio, true);
return IRQ_HANDLED;
}
return IRQ_NONE;
}
static void devmpu_vio_clear_emi(unsigned int emi_id)
{
devmpu_vio_clear(emi_id);
}
int devmpu_regist_emi(void)
{
int ret = 0;
ret = mtk_emimpu_prehandle_register(devmpu_irq_handler_emi);
if (ret) {
pr_err("%s:%d failed to register emi prehandle, %d\n",
__func__, __LINE__, ret);
return ret;
}
ret = mtk_emimpu_postclear_register(devmpu_vio_clear_emi);
if (ret) {
pr_err("%s:%d failed to register emi postclear, %d\n",
__func__, __LINE__, ret);
return ret;
}
return ret;
}
MODULE_DESCRIPTION("Mediatek Device MPU Driver with EMI");
MODULE_AUTHOR("Calvin Liao <calvin.liao@mediatek.com>");
MODULE_LICENSE("GPL");
+15
View File
@@ -0,0 +1,15 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Copyright (C) 2019 MediaTek Inc.
*/
#ifndef __DEVMPU_EMI_H__
#define __DEVMPU_EMI_H__
#define EMI_MPUS_OFFSET (0x1F0)
#define EMI_MPUT_OFFSET (0x1F8)
#define EMI_MPUT_2ND_OFFSET (0x1FC)
int devmpu_regist_emi(void);
#endif /* __DEVMPU_EMI_H__ */
@@ -0,0 +1,41 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2022 MediaTek Inc.
*/
#undef TRACE_SYSTEM
#define TRACE_SYSTEM devmpu
#if !defined(_TRACE_EVENT_DEVICE_MPU_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_EVENT_DEVICE_MPU_H
#include <linux/tracepoint.h>
TRACE_EVENT(devmpu_event,
TP_PROTO(unsigned long long vio_addr, unsigned int vio_id,
unsigned int vio_domain, unsigned int vio_rw),
TP_ARGS(vio_addr, vio_id, vio_domain, vio_rw),
TP_STRUCT__entry(
__field(unsigned long long, vio_addr)
__field(unsigned int, vio_id)
__field(unsigned int, vio_domain)
__field(unsigned int, vio_rw)
),
TP_fast_assign(
__entry->vio_addr = vio_addr;
__entry->vio_id = vio_id;
__entry->vio_domain = vio_domain;
__entry->vio_rw = vio_rw;
),
TP_printk("devmpu:vio_id(0x%x),vio_domain(0x%x),vio_rw(0x%x),vio_addr(0x%llx)",
__entry->vio_id, __entry->vio_domain, __entry->vio_rw, __entry->vio_addr)
);
#endif
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH .
#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_FILE devmpu_trace
#include <trace/define_trace.h>
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+87
View File
@@ -0,0 +1,87 @@
/*
* Copyright (c) 2015 Pengutronix, Sascha Hauer <kernel@pengutronix.de>
*
* 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.
*/
#include <linux/export.h>
#include <linux/jiffies.h>
#include <linux/regmap.h>
#include <linux/soc/mediatek/infracfg.h>
#include <asm/processor.h>
#define MTK_POLL_DELAY_US 10
#define MTK_POLL_TIMEOUT (jiffies_to_usecs(HZ))
#define INFRA_TOPAXI_PROTECTEN 0x0220
#define INFRA_TOPAXI_PROTECTSTA1 0x0228
#define INFRA_TOPAXI_PROTECTEN_SET 0x0260
#define INFRA_TOPAXI_PROTECTEN_CLR 0x0264
/**
* mtk_infracfg_set_bus_protection - enable bus protection
* @regmap: The infracfg regmap
* @mask: The mask containing the protection bits to be enabled.
* @reg_update: The boolean flag determines to set the protection bits
* by regmap_update_bits with enable register(PROTECTEN) or
* by regmap_write with set register(PROTECTEN_SET).
*
* This function enables the bus protection bits for disabled power
* domains so that the system does not hang when some unit accesses the
* bus while in power down.
*/
int mtk_infracfg_set_bus_protection(struct regmap *infracfg, u32 mask,
bool reg_update)
{
u32 val;
int ret;
if (reg_update)
regmap_update_bits(infracfg, INFRA_TOPAXI_PROTECTEN, mask,
mask);
else
regmap_write(infracfg, INFRA_TOPAXI_PROTECTEN_SET, mask);
ret = regmap_read_poll_timeout(infracfg, INFRA_TOPAXI_PROTECTSTA1,
val, (val & mask) == mask,
MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT);
return ret;
}
/**
* mtk_infracfg_clear_bus_protection - disable bus protection
* @regmap: The infracfg regmap
* @mask: The mask containing the protection bits to be disabled.
* @reg_update: The boolean flag determines to clear the protection bits
* by regmap_update_bits with enable register(PROTECTEN) or
* by regmap_write with clear register(PROTECTEN_CLR).
*
* This function disables the bus protection bits previously enabled with
* mtk_infracfg_set_bus_protection.
*/
int mtk_infracfg_clear_bus_protection(struct regmap *infracfg, u32 mask,
bool reg_update)
{
int ret;
u32 val;
if (reg_update)
regmap_update_bits(infracfg, INFRA_TOPAXI_PROTECTEN, mask, 0);
else
regmap_write(infracfg, INFRA_TOPAXI_PROTECTEN_CLR, mask);
ret = regmap_read_poll_timeout(infracfg, INFRA_TOPAXI_PROTECTSTA1,
val, !(val & mask),
MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT);
return ret;
}
+116
View File
@@ -0,0 +1,116 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#include <linux/kernel.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/device.h>
#include <linux/cpuidle.h>
#include <linux/soc/mediatek/mtk-lpm.h>
#define MTK_PWR_CONSERVATION_PREPARE (0)
#define MTK_PWR_CONSERVATION_RESUME (1)
typedef int (*mtk_pwr_conservation_fn)(int type,
struct cpuidle_driver *drv,
int index);
static struct mtk_cpuidle_op *mtk_lpm_ops __read_mostly;
int mtk_lpm_drv_cpuidle_ops_set(struct mtk_cpuidle_op *op)
{
int ret = 0;
cpuidle_pause_and_lock();
if ((!op && mtk_lpm_ops) || (op && !mtk_lpm_ops))
rcu_assign_pointer(mtk_lpm_ops, op);
else
ret = -EACCES;
cpuidle_resume_and_unlock();
return ret;
}
EXPORT_SYMBOL(mtk_lpm_drv_cpuidle_ops_set);
int mtk_lpm_pwr_conservation(int type,
struct cpuidle_driver *drv,
int index)
{
int ret = -EBADR;
if (!mtk_lpm_ops)
return ret;
switch (type) {
case MTK_PWR_CONSERVATION_PREPARE:
if (mtk_lpm_ops->cpuidle_prepare)
ret = mtk_lpm_ops->cpuidle_prepare(drv, index);
break;
case MTK_PWR_CONSERVATION_RESUME:
if (mtk_lpm_ops->cpuidle_resume)
mtk_lpm_ops->cpuidle_resume(drv, index);
ret = 0;
break;
default:
break;
}
return ret;
}
static int mtk_lp_pm_driver_probe(struct platform_device *pdev)
{
struct platform_device *mtk_cpuidle_pm_dev;
int ret = -ENOMEM;
mtk_pwr_conservation_fn mtk_lpm_pwr = mtk_lpm_pwr_conservation;
mtk_cpuidle_pm_dev =
platform_device_alloc(MTK_CPUIDLE_PM_NAME, -1);
if (!mtk_cpuidle_pm_dev)
goto out_probe_alloc_fail;
mtk_cpuidle_pm_dev->dev.parent = &pdev->dev;
ret = platform_device_add(mtk_cpuidle_pm_dev);
if (ret)
goto put_device;
ret = platform_device_add_data(mtk_cpuidle_pm_dev,
&mtk_lpm_pwr,
sizeof(mtk_lpm_pwr));
if (ret)
goto put_device;
device_init_wakeup(&mtk_cpuidle_pm_dev->dev, true);
return 0;
put_device:
platform_device_put(mtk_cpuidle_pm_dev);
out_probe_alloc_fail:
return ret;
}
static const struct of_device_id of_mtk_lp_pm_match[] = {
{ .compatible = "mediatek,mtk-lpm" },
{}
};
static struct platform_driver mtk_lp_pm_driver = {
.probe = mtk_lp_pm_driver_probe,
.driver = {
.name = "mtk_lpm_driver",
.owner = THIS_MODULE,
.of_match_table = of_match_ptr(of_mtk_lp_pm_match),
},
};
builtin_platform_driver(mtk_lp_pm_driver);
File diff suppressed because it is too large. Load diff
+465
View File
@@ -0,0 +1,465 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2019 MediaTek Inc.
*/
#include <linux/clk.h>
#include <linux/debugfs.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/pm_opp.h>
#include <linux/regulator/consumer.h>
static struct dentry *mmdvfs_debugfs_dir;
#define MMDVFS_DBG
#define MAX_OPP_NUM (6)
#define MAX_MUX_NUM (10)
#define MAX_HOPPING_CLK_NUM (2)
enum {
ACTION_DEFAULT,
ACTION_IHDM, /* Voltage Increase: Hopping First, Decrease: MUX First*/
};
struct mmdvfs_mux_data {
const char *mux_name;
struct clk *mux;
struct clk *clk_src[MAX_OPP_NUM];
};
struct mmdvfs_hopping_data {
const char *hopping_name;
struct clk *hopping_clk;
u32 hopping_rate[MAX_OPP_NUM];
};
struct mmdvfs_drv_data {
bool need_change_voltage;
u32 request_voltage;
u32 num_muxes;
struct mmdvfs_mux_data muxes[MAX_MUX_NUM];
u32 num_hoppings;
struct mmdvfs_hopping_data hoppings[MAX_HOPPING_CLK_NUM];
u32 action;
struct notifier_block nb;
u32 voltages[MAX_OPP_NUM];
};
static BLOCKING_NOTIFIER_HEAD(mmdvfs_notifier_list);
/**
* register_mmdvfs_notifier - register multimedia clk changing notifier
* @nb: notifier block
*
* Register notifier block to receive clk changing notification.
*/
int register_mmdvfs_notifier(struct notifier_block *nb)
{
return blocking_notifier_chain_register(&mmdvfs_notifier_list, nb);
}
EXPORT_SYMBOL_GPL(register_mmdvfs_notifier);
/**
* unregister_mmdvfs_notifier - unregister multimedia clk changing notifier
* @nb: notifier block
*
* Unregister clk changing notifier block.
*/
int unregister_mmdvfs_notifier(struct notifier_block *nb)
{
return blocking_notifier_chain_unregister(&mmdvfs_notifier_list, nb);
}
EXPORT_SYMBOL_GPL(unregister_mmdvfs_notifier);
static void set_all_muxes(struct mmdvfs_drv_data *drv_data, u32 opp_level)
{
u32 num_muxes = drv_data->num_muxes;
u32 i;
struct clk *mux, *clk_src;
s32 err;
for (i = 0; i < num_muxes; i++) {
mux = drv_data->muxes[i].mux;
clk_src = drv_data->muxes[i].clk_src[opp_level];
err = clk_prepare_enable(mux);
if (err) {
pr_notice("prepare mux(%s) fail:%d opp_level:%d\n",
drv_data->muxes[i].mux_name, err, opp_level);
continue;
}
err = clk_set_parent(mux, clk_src);
if (err)
pr_notice("set parent(%s) fail:%d opp_level:%d\n",
drv_data->muxes[i].mux_name, err, opp_level);
clk_disable_unprepare(mux);
}
}
static void set_all_hoppings(struct mmdvfs_drv_data *drv_data, u32 opp_level)
{
u32 num_hoppings = drv_data->num_hoppings;
u32 i, hopping_rate;
struct clk *hopping;
s32 err;
for (i = 0; i < num_hoppings; i++) {
hopping = drv_data->hoppings[i].hopping_clk;
hopping_rate = drv_data->hoppings[i].hopping_rate[opp_level];
err = clk_prepare_enable(hopping);
if (err) {
pr_notice("prepare hopping(%s) fail:%d opp_level:%d\n",
drv_data->hoppings[i].hopping_name,
err, opp_level);
continue;
}
err = clk_set_rate(hopping, hopping_rate);
if (err)
pr_notice("set %s rate(%u) fail:%d opp_level:%d\n",
drv_data->hoppings[i].hopping_name,
hopping_rate, err, opp_level);
clk_disable_unprepare(hopping);
}
}
static void set_all_clk(
struct mmdvfs_drv_data *drv_data, u32 voltage, bool vol_inc)
{
u32 i;
u32 opp_level;
for (i = 0; i < MAX_OPP_NUM; i++) {
if (drv_data->voltages[i] == voltage) {
opp_level = i;
break;
}
}
if (i == MAX_OPP_NUM) {
pr_notice("voltage(%d) is not found\n", voltage);
return;
}
switch (drv_data->action) {
/* Voltage Increase: Hopping First, Decrease: MUX First*/
case ACTION_IHDM:
if (vol_inc) {
set_all_hoppings(drv_data, opp_level);
set_all_muxes(drv_data, opp_level);
} else {
set_all_muxes(drv_data, opp_level);
set_all_hoppings(drv_data, opp_level);
}
break;
default:
set_all_muxes(drv_data, opp_level);
break;
}
blocking_notifier_call_chain(&mmdvfs_notifier_list, opp_level, NULL);
pr_debug("set clk to opp level:%d\n", opp_level);
}
static int regulator_event_notify(struct notifier_block *nb,
unsigned long event, void *data)
{
unsigned long uV;
struct mmdvfs_drv_data *drv_data;
struct pre_voltage_change_data *pvc_data;
drv_data = container_of(nb, struct mmdvfs_drv_data, nb);
if (event == REGULATOR_EVENT_PRE_VOLTAGE_CHANGE) {
pvc_data = data;
uV = pvc_data->min_uV;
if (uV < pvc_data->old_uV) {
set_all_clk(drv_data, uV, false);
drv_data->request_voltage = uV;
} else if (uV > pvc_data->old_uV) {
drv_data->need_change_voltage = true;
}
pr_debug("regulator event=PRE_VOLTAGE_CHANGE old=%lu new=%lu\n",
pvc_data->old_uV, pvc_data->min_uV);
} else if (event == REGULATOR_EVENT_VOLTAGE_CHANGE) {
uV = (unsigned long)data;
if (drv_data->need_change_voltage == true) {
set_all_clk(drv_data, uV, true);
drv_data->need_change_voltage = false;
drv_data->request_voltage = uV;
}
pr_debug("regulator event=VOLTAGE_CHANGE voltage=%lu\n", uV);
} else if (event == REGULATOR_EVENT_ABORT_VOLTAGE_CHANGE) {
uV = (unsigned long) data;
/* If clk was changed, restore to previous setting */
if (uV != drv_data->request_voltage) {
set_all_clk(drv_data, uV,
uV > drv_data->request_voltage);
drv_data->need_change_voltage = false;
drv_data->request_voltage = uV;
}
pr_info("regulator event=ABORT_VOLTAGE_CHANGE voltage=%lu\n",
uV);
}
return 0;
}
/*
* mmdvfs driver init
*/
static const struct of_device_id of_mmdvfs_match_tbl[] = {
{
.compatible = "mediatek,mmdvfs",
},
{}
};
static int setting_show(struct seq_file *s, void *data)
{
struct mmdvfs_drv_data *drv_data = s->private;
u32 i, j;
seq_printf(s, "mux number:%d\n", drv_data->num_muxes);
seq_puts(s, "mux:");
for (i = 0; i < drv_data->num_muxes; i++) {
seq_printf(s,
"%s ", drv_data->muxes[i].mux_name);
}
seq_puts(s, "\n");
seq_printf(s, "hopping number:%d\n", drv_data->num_hoppings);
for (i = 0; i < drv_data->num_hoppings; i++) {
seq_printf(s,
"%s: ", drv_data->hoppings[i].hopping_name);
for (j = 0; j < MAX_OPP_NUM; j++) {
if (!drv_data->hoppings[i].hopping_rate[j])
break;
seq_printf(s, "%d ",
drv_data->hoppings[i].hopping_rate[j]);
}
seq_puts(s, "\n");
}
seq_printf(s, "action: %d\n", drv_data->action);
seq_puts(s, "voltage level:");
for (i = 0; i < MAX_OPP_NUM; i++) {
if (!drv_data->voltages[i])
break;
seq_printf(s, "%d ", drv_data->voltages[i]);
}
seq_puts(s, "\n");
seq_printf(s, "request voltage:%d\n", drv_data->request_voltage);
return 0;
}
static int mmdvfs_setting_open(struct inode *inode, struct file *file)
{
return single_open(file, setting_show, inode->i_private);
}
static const struct file_operations mmdvfs_setting_fops = {
.open = mmdvfs_setting_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
#ifdef MMDVFS_DBG
struct mmdvfs_dbg_data {
struct mmdvfs_drv_data *drv_data;
struct regulator *reg;
u32 max_voltage;
};
static int force_clk_set(void *data, u64 val)
{
struct mmdvfs_dbg_data *dbg_data = (struct mmdvfs_dbg_data *)data;
struct mmdvfs_drv_data *drv_data = dbg_data->drv_data;
s32 ret;
if (val == 0) {
ret = devm_regulator_register_notifier(
dbg_data->reg, &drv_data->nb);
if (ret)
pr_notice("Failed to register notifier: %d\n", ret);
regulator_set_voltage(dbg_data->reg, 0, dbg_data->max_voltage);
} else {
devm_regulator_unregister_notifier(
dbg_data->reg, &drv_data->nb);
if (val > drv_data->request_voltage) {
regulator_set_voltage(
dbg_data->reg, val, dbg_data->max_voltage);
set_all_clk(drv_data, val, true);
} else {
set_all_clk(drv_data, val, false);
regulator_set_voltage(
dbg_data->reg, val, dbg_data->max_voltage);
}
}
pr_notice("%s: val=%llu\n", __func__, val);
return 0;
}
DEFINE_SIMPLE_ATTRIBUTE(force_clk_ops, NULL, force_clk_set, "%llu\n");
#endif /* MMDVFS_DBG */
static int mmdvfs_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct mmdvfs_drv_data *drv_data;
#ifdef MMDVFS_DBG
struct mmdvfs_dbg_data *dbg_data;
#endif
struct regulator *reg;
u32 num_mux = 0, num_hopping = 0;
u32 num_clksrc, index, hopping_rate, num_hopping_rate;
struct property *mux_prop, *clksrc_prop;
struct property *hopping_prop, *hopping_rate_prop;
const char *mux_name, *clksrc_name, *hopping_name;
char prop_name[32];
const __be32 *p;
s32 ret;
unsigned long freq;
struct dev_pm_opp *opp;
struct dentry *dentry;
drv_data = devm_kzalloc(dev, sizeof(*drv_data), GFP_KERNEL);
if (!drv_data)
return -ENOMEM;
of_property_for_each_string(
dev->of_node, "mediatek,support_mux", mux_prop, mux_name) {
if (num_mux >= MAX_MUX_NUM) {
pr_notice("Too many items in support_mux\n");
return -EINVAL;
}
drv_data->muxes[num_mux].mux = devm_clk_get(dev, mux_name);
drv_data->muxes[num_mux].mux_name = mux_name;
snprintf(prop_name, sizeof(prop_name)-1,
"mediatek,mux_%s", mux_name);
num_clksrc = 0;
of_property_for_each_string(
dev->of_node, prop_name, clksrc_prop, clksrc_name) {
if (num_clksrc >= MAX_OPP_NUM) {
pr_notice("Too many items in %s\n", prop_name);
return -EINVAL;
}
drv_data->muxes[num_mux].clk_src[num_clksrc] =
devm_clk_get(dev, clksrc_name);
num_clksrc++;
}
num_mux++;
}
drv_data->num_muxes = num_mux;
of_property_for_each_string(dev->of_node, "mediatek,support_hopping",
hopping_prop, hopping_name) {
if (num_hopping >= MAX_HOPPING_CLK_NUM) {
pr_notice("Too many items in support_hopping\n");
return -EINVAL;
}
drv_data->hoppings[num_hopping].hopping_clk =
devm_clk_get(dev, hopping_name);
drv_data->hoppings[num_hopping].hopping_name = hopping_name;
snprintf(prop_name, sizeof(prop_name)-1,
"mediatek,hopping_%s", hopping_name);
num_hopping_rate = 0;
of_property_for_each_u32(dev->of_node, prop_name,
hopping_rate_prop, p, hopping_rate) {
if (num_hopping_rate >= MAX_OPP_NUM) {
pr_notice("Too many items in %s\n", prop_name);
return -EINVAL;
}
drv_data->hoppings[num_hopping].hopping_rate[
num_hopping_rate] = hopping_rate;
num_hopping_rate++;
}
num_hopping++;
}
drv_data->num_hoppings = num_hopping;
of_property_read_u32(dev->of_node,
"mediatek,action", &drv_data->action);
/* Get voltage info from opp table */
dev_pm_opp_of_add_table(dev);
freq = 0;
index = 0;
while (!IS_ERR(opp = dev_pm_opp_find_freq_ceil(dev, &freq))) {
drv_data->voltages[index] = dev_pm_opp_get_voltage(opp);
freq++;
index++;
dev_pm_opp_put(opp);
}
reg = devm_regulator_get(dev, "dvfsrc-vcore");
if (IS_ERR(reg))
return PTR_ERR(reg);
mmdvfs_debugfs_dir = debugfs_create_dir("mmdvfs", NULL);
if (IS_ERR(mmdvfs_debugfs_dir))
pr_notice("Failed to create debugfs dir mmdvfs: %ld\n",
PTR_ERR(mmdvfs_debugfs_dir));
dentry = debugfs_create_file("setting", 0444,
mmdvfs_debugfs_dir, drv_data, &mmdvfs_setting_fops);
if (IS_ERR(dentry))
pr_notice("Failed to create debugfs setting: %ld\n",
PTR_ERR(dentry));
#ifdef MMDVFS_DBG
dbg_data = devm_kzalloc(dev, sizeof(*dbg_data), GFP_KERNEL);
if (!dbg_data)
return -ENOMEM;
dbg_data->drv_data = drv_data;
dbg_data->reg = reg;
dbg_data->max_voltage = drv_data->voltages[index-1];
dentry = debugfs_create_file("force_clk", 0200,
mmdvfs_debugfs_dir, dbg_data, &force_clk_ops);
if (IS_ERR(dentry))
pr_notice("Failed to create debugfs force_clk: %ld\n",
PTR_ERR(dentry));
#endif
drv_data->nb.notifier_call = regulator_event_notify;
ret = devm_regulator_register_notifier(reg, &drv_data->nb);
if (ret)
pr_notice("Failed to register notifier: %d\n", ret);
return ret;
}
static struct platform_driver mmdvfs_drv = {
.probe = mmdvfs_probe,
.driver = {
.name = "mtk-mmdvfs",
.owner = THIS_MODULE,
.of_match_table = of_mmdvfs_match_tbl,
},
};
static int __init mtk_mmdvfs_init(void)
{
s32 status;
status = platform_driver_register(&mmdvfs_drv);
if (status) {
pr_notice("Failed to register MMDVFS driver(%d)\n", status);
return -ENODEV;
}
return 0;
}
static void __exit mtk_mmdvfs_exit(void)
{
platform_driver_unregister(&mmdvfs_drv);
debugfs_remove_recursive(mmdvfs_debugfs_dir);
}
module_init(mtk_mmdvfs_init);
module_exit(mtk_mmdvfs_exit);
MODULE_DESCRIPTION("MTK MMDVFS driver");
MODULE_AUTHOR("Anthony Huang<anthony.huang@mediatek.com>");
MODULE_LICENSE("GPL");
+78
View File
@@ -0,0 +1,78 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#undef TRACE_SYSTEM
#define TRACE_SYSTEM mtk_pm_qos
#if !defined(_TRACE_MTK_QOS_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_MTK_QOS_H
#include <linux/ktime.h>
#include <linux/soc/mediatek/mtk-pm-qos.h>
#include <linux/tracepoint.h>
#include <linux/trace_events.h>
#define TPS(x) tracepoint_string(x)
DECLARE_EVENT_CLASS(mtk_pm_qos_request,
TP_PROTO(int mtk_pm_qos_class, s32 value, char *owner),
TP_ARGS(mtk_pm_qos_class, value, owner),
TP_STRUCT__entry(
__field(int, mtk_pm_qos_class)
__field(s32, value)
__array(char, owner, 20)
),
TP_fast_assign(
__entry->mtk_pm_qos_class = mtk_pm_qos_class;
__entry->value = value;
strncpy(__entry->owner, owner, 19);
),
TP_printk("pm_qos_class=%s value=%d owner=%s",
__print_symbolic(__entry->mtk_pm_qos_class,
{ MTK_PM_QOS_MEMORY_BANDWIDTH, "QOS_BW" },
{ MTK_PM_QOS_HRT_BANDWIDTH, "QOS_HRTBW" },
{ MTK_PM_QOS_DDR_OPP, "QOS_DDR" },
{ MTK_PM_QOS_VCORE_OPP, "QOS_VCORE" },
{ MTK_PM_QOS_SCP_VCORE_REQUEST, "QOS_SCP" }),
__entry->value, __entry->owner)
);
DEFINE_EVENT(mtk_pm_qos_request, mtk_pm_qos_add_request,
TP_PROTO(int mtk_pm_qos_class, s32 value, char *owner),
TP_ARGS(mtk_pm_qos_class, value, owner)
);
DEFINE_EVENT(mtk_pm_qos_request, mtk_pm_qos_update_request,
TP_PROTO(int mtk_pm_qos_class, s32 value, char *owner),
TP_ARGS(mtk_pm_qos_class, value, owner)
);
DEFINE_EVENT(mtk_pm_qos_request, mtk_pm_qos_remove_request,
TP_PROTO(int mtk_pm_qos_class, s32 value, char *owner),
TP_ARGS(mtk_pm_qos_class, value, owner)
);
#endif /* _TRACE_MTK_QOS_H */
/* This part must be outside protection */
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH .
#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_FILE mtk-pm-qos-trace
/* This part must be outside protection */
#include <trace/define_trace.h>
+968
View File
@@ -0,0 +1,968 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#include <linux/pm_qos.h>
#include <linux/soc/mediatek/mtk-pm-qos.h>
#include <linux/sched.h>
#include <linux/spinlock.h>
#include <linux/slab.h>
#include <linux/time.h>
#include <linux/fs.h>
#include <linux/device.h>
#include <linux/miscdevice.h>
#include <linux/string.h>
#include <linux/platform_device.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/module.h>
#include <linux/uaccess.h>
#include <linux/export.h>
#define CREATE_TRACE_POINTS
#include <mtk-pm-qos-trace.h>
struct mtk_pm_qos_object {
struct pm_qos_constraints *constraints;
struct mutex qos_lock;
struct list_head req_list;
char *name;
};
static DEFINE_SPINLOCK(mtk_pm_qos_lock);
static struct mtk_pm_qos_object null_mtk_pm_qos;
static BLOCKING_NOTIFIER_HEAD(memory_bandwidth_notifier);
static struct pm_qos_constraints memory_bw_constraints = {
.list = PLIST_HEAD_INIT(memory_bw_constraints.list),
.target_value = MTK_PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE,
.default_value = MTK_PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE,
.no_constraint_value = MTK_PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE,
.type = PM_QOS_SUM,
.notifiers = &memory_bandwidth_notifier,
};
static struct mtk_pm_qos_object memory_bandwidth_pm_qos = {
.constraints = &memory_bw_constraints,
.req_list = LIST_HEAD_INIT(memory_bandwidth_pm_qos.req_list),
.qos_lock = __MUTEX_INITIALIZER(memory_bandwidth_pm_qos.qos_lock),
.name = "memory_bandwidth",
};
static BLOCKING_NOTIFIER_HEAD(memory_ext_bandwidth_notifier);
static struct pm_qos_constraints memory_ext_bw_constraints = {
.list = PLIST_HEAD_INIT(memory_ext_bw_constraints.list),
.target_value = MTK_PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE,
.default_value = MTK_PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE,
.no_constraint_value = MTK_PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE,
.type = PM_QOS_SUM,
.notifiers = &memory_ext_bandwidth_notifier,
};
static struct mtk_pm_qos_object memory_ext_bandwidth_pm_qos = {
.constraints = &memory_ext_bw_constraints,
.req_list = LIST_HEAD_INIT(memory_ext_bandwidth_pm_qos.req_list),
.qos_lock = __MUTEX_INITIALIZER(memory_ext_bandwidth_pm_qos.qos_lock),
.name = "memory_ext_bandwidth",
};
static BLOCKING_NOTIFIER_HEAD(ddr_opp_notifier);
static struct pm_qos_constraints ddr_opp_constraints = {
.list = PLIST_HEAD_INIT(ddr_opp_constraints.list),
.target_value = MTK_PM_QOS_DDR_OPP_DEFAULT_VALUE,
.default_value = MTK_PM_QOS_DDR_OPP_DEFAULT_VALUE,
.no_constraint_value = MTK_PM_QOS_DDR_OPP_DEFAULT_VALUE,
.type = PM_QOS_MIN,
.notifiers = &ddr_opp_notifier,
};
static struct mtk_pm_qos_object ddr_opp_pm_qos = {
.constraints = &ddr_opp_constraints,
.req_list = LIST_HEAD_INIT(ddr_opp_pm_qos.req_list),
.qos_lock = __MUTEX_INITIALIZER(ddr_opp_pm_qos.qos_lock),
.name = "ddr_opp",
};
static BLOCKING_NOTIFIER_HEAD(vcore_opp_notifier);
static struct pm_qos_constraints vcore_opp_constraints = {
.list = PLIST_HEAD_INIT(vcore_opp_constraints.list),
.target_value = MTK_PM_QOS_VCORE_OPP_DEFAULT_VALUE,
.default_value = MTK_PM_QOS_VCORE_OPP_DEFAULT_VALUE,
.no_constraint_value = MTK_PM_QOS_VCORE_OPP_DEFAULT_VALUE,
.type = PM_QOS_MIN,
.notifiers = &vcore_opp_notifier,
};
static struct mtk_pm_qos_object vcore_opp_pm_qos = {
.constraints = &vcore_opp_constraints,
.req_list = LIST_HEAD_INIT(vcore_opp_pm_qos.req_list),
.qos_lock = __MUTEX_INITIALIZER(vcore_opp_pm_qos.qos_lock),
.name = "vcore_opp",
};
static BLOCKING_NOTIFIER_HEAD(scp_vcore_req_notifier);
static struct pm_qos_constraints scp_vcore_req_constraints = {
.list = PLIST_HEAD_INIT(scp_vcore_req_constraints.list),
.target_value = MTK_PM_QOS_SCP_VCORE_REQUEST_DEFAULT_VALUE,
.default_value = MTK_PM_QOS_SCP_VCORE_REQUEST_DEFAULT_VALUE,
.no_constraint_value = MTK_PM_QOS_SCP_VCORE_REQUEST_DEFAULT_VALUE,
.type = PM_QOS_MIN,
.notifiers = &scp_vcore_req_notifier,
};
static struct mtk_pm_qos_object scp_vcore_req_pm_qos = {
.constraints = &scp_vcore_req_constraints,
.req_list = LIST_HEAD_INIT(scp_vcore_req_pm_qos.req_list),
.qos_lock = __MUTEX_INITIALIZER(scp_vcore_req_pm_qos.qos_lock),
.name = "scp_vcore_req",
};
static BLOCKING_NOTIFIER_HEAD(hrt_bandwidth_notifier);
static struct pm_qos_constraints hrt_bw_constraints = {
.list = PLIST_HEAD_INIT(hrt_bw_constraints.list),
.target_value = MTK_PM_QOS_HRT_BANDWIDTH_DEFAULT_VALUE,
.default_value = MTK_PM_QOS_HRT_BANDWIDTH_DEFAULT_VALUE,
.no_constraint_value = MTK_PM_QOS_HRT_BANDWIDTH_DEFAULT_VALUE,
.type = PM_QOS_SUM,
.notifiers = &hrt_bandwidth_notifier,
};
static struct mtk_pm_qos_object hrt_bandwidth_pm_qos = {
.constraints = &hrt_bw_constraints,
.req_list = LIST_HEAD_INIT(hrt_bandwidth_pm_qos.req_list),
.qos_lock = __MUTEX_INITIALIZER(hrt_bandwidth_pm_qos.qos_lock),
.name = "hrt_bandwidth",
};
static BLOCKING_NOTIFIER_HEAD(disp_freq_notifier);
static struct pm_qos_constraints disp_freq_constraints = {
.list = PLIST_HEAD_INIT(disp_freq_constraints.list),
.target_value = PM_QOS_MM_FREQ_DEFAULT_VALUE,
.default_value = PM_QOS_MM_FREQ_DEFAULT_VALUE,
.no_constraint_value = PM_QOS_MM_FREQ_DEFAULT_VALUE,
.type = PM_QOS_MAX,
.notifiers = &disp_freq_notifier,
};
static struct mtk_pm_qos_object disp_freq_pm_qos = {
.constraints = &disp_freq_constraints,
.req_list = LIST_HEAD_INIT(disp_freq_pm_qos.req_list),
.qos_lock = __MUTEX_INITIALIZER(disp_freq_pm_qos.qos_lock),
.name = "disp_freq",
};
static BLOCKING_NOTIFIER_HEAD(mdp_freq_notifier);
static struct pm_qos_constraints mdp_freq_constraints = {
.list = PLIST_HEAD_INIT(mdp_freq_constraints.list),
.target_value = PM_QOS_MM_FREQ_DEFAULT_VALUE,
.default_value = PM_QOS_MM_FREQ_DEFAULT_VALUE,
.no_constraint_value = PM_QOS_MM_FREQ_DEFAULT_VALUE,
.type = PM_QOS_MAX,
.notifiers = &mdp_freq_notifier,
};
static struct mtk_pm_qos_object mdp_freq_pm_qos = {
.constraints = &mdp_freq_constraints,
.req_list = LIST_HEAD_INIT(mdp_freq_pm_qos.req_list),
.qos_lock = __MUTEX_INITIALIZER(mdp_freq_pm_qos.qos_lock),
.name = "mdp_freq",
};
static BLOCKING_NOTIFIER_HEAD(vdec_freq_notifier);
static struct pm_qos_constraints vdec_freq_constraints = {
.list = PLIST_HEAD_INIT(vdec_freq_constraints.list),
.target_value = PM_QOS_MM_FREQ_DEFAULT_VALUE,
.default_value = PM_QOS_MM_FREQ_DEFAULT_VALUE,
.no_constraint_value = PM_QOS_MM_FREQ_DEFAULT_VALUE,
.type = PM_QOS_MAX,
.notifiers = &vdec_freq_notifier,
};
static struct mtk_pm_qos_object vdec_freq_pm_qos = {
.constraints = &vdec_freq_constraints,
.req_list = LIST_HEAD_INIT(vdec_freq_pm_qos.req_list),
.qos_lock = __MUTEX_INITIALIZER(vdec_freq_pm_qos.qos_lock),
.name = "vdec_freq",
};
static BLOCKING_NOTIFIER_HEAD(venc_freq_notifier);
static struct pm_qos_constraints venc_freq_constraints = {
.list = PLIST_HEAD_INIT(venc_freq_constraints.list),
.target_value = PM_QOS_MM_FREQ_DEFAULT_VALUE,
.default_value = PM_QOS_MM_FREQ_DEFAULT_VALUE,
.no_constraint_value = PM_QOS_MM_FREQ_DEFAULT_VALUE,
.type = PM_QOS_MAX,
.notifiers = &venc_freq_notifier,
};
static struct mtk_pm_qos_object venc_freq_pm_qos = {
.constraints = &venc_freq_constraints,
.req_list = LIST_HEAD_INIT(venc_freq_pm_qos.req_list),
.qos_lock = __MUTEX_INITIALIZER(venc_freq_pm_qos.qos_lock),
.name = "venc_freq",
};
static BLOCKING_NOTIFIER_HEAD(img_freq_notifier);
static struct pm_qos_constraints img_freq_constraints = {
.list = PLIST_HEAD_INIT(img_freq_constraints.list),
.target_value = PM_QOS_MM_FREQ_DEFAULT_VALUE,
.default_value = PM_QOS_MM_FREQ_DEFAULT_VALUE,
.no_constraint_value = PM_QOS_MM_FREQ_DEFAULT_VALUE,
.type = PM_QOS_MAX,
.notifiers = &img_freq_notifier,
};
static struct mtk_pm_qos_object img_freq_pm_qos = {
.constraints = &img_freq_constraints,
.req_list = LIST_HEAD_INIT(img_freq_pm_qos.req_list),
.qos_lock = __MUTEX_INITIALIZER(img_freq_pm_qos.qos_lock),
.name = "img_freq",
};
static BLOCKING_NOTIFIER_HEAD(cam_freq_notifier);
static struct pm_qos_constraints cam_freq_constraints = {
.list = PLIST_HEAD_INIT(cam_freq_constraints.list),
.target_value = PM_QOS_MM_FREQ_DEFAULT_VALUE,
.default_value = PM_QOS_MM_FREQ_DEFAULT_VALUE,
.no_constraint_value = PM_QOS_MM_FREQ_DEFAULT_VALUE,
.type = PM_QOS_MAX,
.notifiers = &cam_freq_notifier,
};
static struct mtk_pm_qos_object cam_freq_pm_qos = {
.constraints = &cam_freq_constraints,
.req_list = LIST_HEAD_INIT(cam_freq_pm_qos.req_list),
.qos_lock = __MUTEX_INITIALIZER(cam_freq_pm_qos.qos_lock),
.name = "cam_freq",
};
static BLOCKING_NOTIFIER_HEAD(dpe_freq_notifier);
static struct pm_qos_constraints dpe_freq_constraints = {
.list = PLIST_HEAD_INIT(dpe_freq_constraints.list),
.target_value = PM_QOS_MM_FREQ_DEFAULT_VALUE,
.default_value = PM_QOS_MM_FREQ_DEFAULT_VALUE,
.no_constraint_value = PM_QOS_MM_FREQ_DEFAULT_VALUE,
.type = PM_QOS_MAX,
.notifiers = &dpe_freq_notifier,
};
static struct mtk_pm_qos_object dpe_freq_pm_qos = {
.constraints = &dpe_freq_constraints,
.req_list = LIST_HEAD_INIT(dpe_freq_pm_qos.req_list),
.qos_lock = __MUTEX_INITIALIZER(dpe_freq_pm_qos.qos_lock),
.name = "dpe_freq",
};
static BLOCKING_NOTIFIER_HEAD(mm0_bandwidth_limiter_notifier);
static struct pm_qos_constraints mm0_bw_limiter_constraints = {
.list = PLIST_HEAD_INIT(mm0_bw_limiter_constraints.list),
.target_value = PM_QOS_MM_BANDWIDTH_LIMITER_DEFAULT_VALUE,
.default_value = PM_QOS_MM_BANDWIDTH_LIMITER_DEFAULT_VALUE,
.no_constraint_value = PM_QOS_MM_BANDWIDTH_LIMITER_DEFAULT_VALUE,
.type = PM_QOS_SUM,
.notifiers = &mm0_bandwidth_limiter_notifier,
};
static struct mtk_pm_qos_object mm0_bandwidth_limiter = {
.constraints = &mm0_bw_limiter_constraints,
.req_list = LIST_HEAD_INIT(mm0_bandwidth_limiter.req_list),
.qos_lock = __MUTEX_INITIALIZER(mm0_bandwidth_limiter.qos_lock),
.name = "mm0_bandwidth_limiter",
};
static BLOCKING_NOTIFIER_HEAD(mm1_bandwidth_limiter_notifier);
static struct pm_qos_constraints mm1_bw_limiter_constraints = {
.target_value = PM_QOS_MM_BANDWIDTH_LIMITER_DEFAULT_VALUE,
.default_value = PM_QOS_MM_BANDWIDTH_LIMITER_DEFAULT_VALUE,
.no_constraint_value = PM_QOS_MM_BANDWIDTH_LIMITER_DEFAULT_VALUE,
.type = PM_QOS_SUM,
.notifiers = &mm1_bandwidth_limiter_notifier,
};
static struct mtk_pm_qos_object mm1_bandwidth_limiter = {
.constraints = &mm1_bw_limiter_constraints,
.req_list = LIST_HEAD_INIT(mm1_bandwidth_limiter.req_list),
.qos_lock = __MUTEX_INITIALIZER(mm1_bandwidth_limiter.qos_lock),
.name = "mm1_bandwidth_limiter",
};
static BLOCKING_NOTIFIER_HEAD(vvpu_opp_notifier);
static struct pm_qos_constraints vvpu_opp_constraints = {
.list = PLIST_HEAD_INIT(vvpu_opp_constraints.list),
.target_value = MTK_PM_QOS_VVPU_OPP_DEFAULT_VALUE,
.default_value = MTK_PM_QOS_VVPU_OPP_DEFAULT_VALUE,
.no_constraint_value = MTK_PM_QOS_VVPU_OPP_DEFAULT_VALUE,
.type = PM_QOS_MIN,
.notifiers = &vvpu_opp_notifier,
};
static struct mtk_pm_qos_object vvpu_opp_pm_qos = {
.constraints = &vvpu_opp_constraints,
.req_list = LIST_HEAD_INIT(vvpu_opp_pm_qos.req_list),
.qos_lock = __MUTEX_INITIALIZER(vvpu_opp_pm_qos.qos_lock),
.name = "vvpu_opp",
};
static BLOCKING_NOTIFIER_HEAD(vmdla_opp_notifier);
static struct pm_qos_constraints vmdla_opp_constraints = {
.list = PLIST_HEAD_INIT(vmdla_opp_constraints.list),
.target_value = MTK_PM_QOS_VMDLA_OPP_DEFAULT_VALUE,
.default_value = MTK_PM_QOS_VMDLA_OPP_DEFAULT_VALUE,
.no_constraint_value = MTK_PM_QOS_VMDLA_OPP_DEFAULT_VALUE,
.type = PM_QOS_MIN,
.notifiers = &vmdla_opp_notifier,
};
static struct mtk_pm_qos_object vmdla_opp_pm_qos = {
.constraints = &vmdla_opp_constraints,
.req_list = LIST_HEAD_INIT(vmdla_opp_pm_qos.req_list),
.qos_lock = __MUTEX_INITIALIZER(vmdla_opp_pm_qos.qos_lock),
.name = "vmdla_opp",
};
static BLOCKING_NOTIFIER_HEAD(cpu_memory_bandwidth_notifier);
static struct pm_qos_constraints cpu_memory_bw_constraints = {
.list = PLIST_HEAD_INIT(cpu_memory_bw_constraints.list),
.target_value = MTK_PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE,
.default_value = MTK_PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE,
.no_constraint_value = MTK_PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE,
.type = PM_QOS_SUM,
.notifiers = &cpu_memory_bandwidth_notifier,
};
static struct mtk_pm_qos_object cpu_memory_bandwidth_pm_qos = {
.constraints = &cpu_memory_bw_constraints,
.req_list = LIST_HEAD_INIT(cpu_memory_bandwidth_pm_qos.req_list),
.qos_lock = __MUTEX_INITIALIZER(cpu_memory_bandwidth_pm_qos.qos_lock),
.name = "cpu_memory_bandwidth",
};
static BLOCKING_NOTIFIER_HEAD(gpu_memory_bandwidth_notifier);
static struct pm_qos_constraints gpu_memory_bw_constraints = {
.list = PLIST_HEAD_INIT(gpu_memory_bw_constraints.list),
.target_value = MTK_PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE,
.default_value = MTK_PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE,
.no_constraint_value = MTK_PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE,
.type = PM_QOS_SUM,
.notifiers = &gpu_memory_bandwidth_notifier,
};
static struct mtk_pm_qos_object gpu_memory_bandwidth_pm_qos = {
.constraints = &gpu_memory_bw_constraints,
.req_list = LIST_HEAD_INIT(gpu_memory_bandwidth_pm_qos.req_list),
.qos_lock = __MUTEX_INITIALIZER(gpu_memory_bandwidth_pm_qos.qos_lock),
.name = "gpu_memory_bandwidth",
};
static BLOCKING_NOTIFIER_HEAD(other_memory_bandwidth_notifier);
static struct pm_qos_constraints other_memory_bw_constraints = {
.list = PLIST_HEAD_INIT(other_memory_bw_constraints.list),
.target_value = MTK_PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE,
.default_value = MTK_PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE,
.no_constraint_value = MTK_PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE,
.type = PM_QOS_SUM,
.notifiers = &other_memory_bandwidth_notifier,
};
static struct mtk_pm_qos_object other_memory_bandwidth_pm_qos = {
.constraints = &other_memory_bw_constraints,
.req_list = LIST_HEAD_INIT(other_memory_bandwidth_pm_qos.req_list),
.qos_lock = __MUTEX_INITIALIZER(other_memory_bandwidth_pm_qos.qos_lock),
.name = "other_memory_bandwidth",
};
static BLOCKING_NOTIFIER_HEAD(power_model_ddr_req_notifier);
static struct pm_qos_constraints power_model_ddr_req_constraints = {
.list = PLIST_HEAD_INIT(power_model_ddr_req_constraints.list),
.target_value = MTK_PM_QOS_POWER_MODEL_DDR_REQUEST_DEFAULT_VALUE,
.default_value = MTK_PM_QOS_POWER_MODEL_DDR_REQUEST_DEFAULT_VALUE,
.no_constraint_value = MTK_PM_QOS_POWER_MODEL_DDR_REQUEST_DEFAULT_VALUE,
.type = PM_QOS_SUM,
.notifiers = &power_model_ddr_req_notifier,
};
static struct mtk_pm_qos_object power_model_ddr_req_pm_qos = {
.constraints = &power_model_ddr_req_constraints,
.req_list = LIST_HEAD_INIT(power_model_ddr_req_pm_qos.req_list),
.qos_lock = __MUTEX_INITIALIZER(power_model_ddr_req_pm_qos.qos_lock),
.name = "power_model_ddr_req",
};
static BLOCKING_NOTIFIER_HEAD(power_model_vcore_req_notifier);
static struct pm_qos_constraints power_model_vcore_req_constraints = {
.list = PLIST_HEAD_INIT(power_model_vcore_req_constraints.list),
.target_value = MTK_PM_QOS_POWER_MODEL_VCORE_REQUEST_DEFAULT_VALUE,
.default_value = MTK_PM_QOS_POWER_MODEL_VCORE_REQUEST_DEFAULT_VALUE,
.no_constraint_value = MTK_PM_QOS_POWER_MODEL_VCORE_REQUEST_DEFAULT_VALUE,
.type = PM_QOS_SUM,
.notifiers = &power_model_vcore_req_notifier,
};
static struct mtk_pm_qos_object power_model_vcore_req_pm_qos = {
.constraints = &power_model_vcore_req_constraints,
.req_list = LIST_HEAD_INIT(power_model_vcore_req_pm_qos.req_list),
.qos_lock = __MUTEX_INITIALIZER(power_model_vcore_req_pm_qos.qos_lock),
.name = "power_model_vcore_req",
};
static BLOCKING_NOTIFIER_HEAD(vcore_dvfs_force_opp_notifier);
static struct pm_qos_constraints vcore_dvfs_force_opp_constraints = {
.list = PLIST_HEAD_INIT(vcore_dvfs_force_opp_constraints.list),
.target_value = MTK_PM_QOS_VCORE_DVFS_FORCE_OPP_DEFAULT_VALUE,
.default_value = MTK_PM_QOS_VCORE_DVFS_FORCE_OPP_DEFAULT_VALUE,
.no_constraint_value = MTK_PM_QOS_VCORE_DVFS_FORCE_OPP_DEFAULT_VALUE,
.type = PM_QOS_SUM,
.notifiers = &vcore_dvfs_force_opp_notifier,
};
static struct mtk_pm_qos_object vcore_dvfs_force_opp_pm_qos = {
.constraints = &vcore_dvfs_force_opp_constraints,
.req_list = LIST_HEAD_INIT(vcore_dvfs_force_opp_pm_qos.req_list),
.qos_lock = __MUTEX_INITIALIZER(vcore_dvfs_force_opp_pm_qos.qos_lock),
.name = "vcore_dvfs_force_opp",
};
static BLOCKING_NOTIFIER_HEAD(memory_bandwidth_test_notifier);
static struct pm_qos_constraints memory_bw_test_constraints = {
.list = PLIST_HEAD_INIT(memory_bw_test_constraints.list),
.target_value = MTK_PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE,
.default_value = MTK_PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE,
.no_constraint_value = MTK_PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE,
.type = PM_QOS_SUM,
.notifiers = &memory_bandwidth_test_notifier,
};
static struct mtk_pm_qos_object memory_bandwidth_test_pm_qos = {
.constraints = &memory_bw_test_constraints,
.req_list = LIST_HEAD_INIT(memory_bandwidth_test_pm_qos.req_list),
.qos_lock = __MUTEX_INITIALIZER(memory_bandwidth_test_pm_qos.qos_lock),
.name = "memory_bandwidth_tst",
};
static struct mtk_pm_qos_object *mtk_pm_qos_array[] = {
[MTK_PM_QOS_RESERVED] = &null_mtk_pm_qos,
[MTK_PM_QOS_MEMORY_BANDWIDTH] = &memory_bandwidth_pm_qos,
[MTK_PM_QOS_MEMORY_EXT_BANDWIDTH] = &memory_ext_bandwidth_pm_qos,
[MTK_PM_QOS_HRT_BANDWIDTH] = &hrt_bandwidth_pm_qos,
[MTK_PM_QOS_DDR_OPP] = &ddr_opp_pm_qos,
[MTK_PM_QOS_VCORE_OPP] = &vcore_opp_pm_qos,
[MTK_PM_QOS_SCP_VCORE_REQUEST] = &scp_vcore_req_pm_qos,
[MTK_PM_QOS_VVPU_OPP] = &vvpu_opp_pm_qos,
[MTK_PM_QOS_VMDLA_OPP] = &vmdla_opp_pm_qos,
[PM_QOS_DISP_FREQ] = &disp_freq_pm_qos,
[PM_QOS_MDP_FREQ] = &mdp_freq_pm_qos,
[PM_QOS_VDEC_FREQ] = &vdec_freq_pm_qos,
[PM_QOS_VENC_FREQ] = &venc_freq_pm_qos,
[PM_QOS_IMG_FREQ] = &img_freq_pm_qos,
[PM_QOS_CAM_FREQ] = &cam_freq_pm_qos,
[PM_QOS_DPE_FREQ] = &dpe_freq_pm_qos,
[PM_QOS_MM0_BANDWIDTH_LIMITER] = &mm0_bandwidth_limiter,
[PM_QOS_MM1_BANDWIDTH_LIMITER] = &mm1_bandwidth_limiter,
[MTK_PM_QOS_CPU_MEMORY_BANDWIDTH] = &cpu_memory_bandwidth_pm_qos,
[MTK_PM_QOS_GPU_MEMORY_BANDWIDTH] = &gpu_memory_bandwidth_pm_qos,
[MTK_PM_QOS_OTHER_MEMORY_BANDWIDTH] = &other_memory_bandwidth_pm_qos,
[MTK_PM_QOS_POWER_MODEL_DDR_REQUEST] = &power_model_ddr_req_pm_qos,
[MTK_PM_QOS_POWER_MODEL_VCORE_REQUEST] = &power_model_vcore_req_pm_qos,
[MTK_PM_QOS_VCORE_DVFS_FORCE_OPP] = &vcore_dvfs_force_opp_pm_qos,
[MTK_PM_QOS_MEMORY_BANDWIDTH_TEST] = &memory_bandwidth_test_pm_qos,
};
/* unlocked internal variant */
static inline int mtk_pm_qos_get_value(struct pm_qos_constraints *c)
{
struct plist_node *node;
int total_value = 0;
if (plist_head_empty(&c->list))
return c->no_constraint_value;
switch (c->type) {
case PM_QOS_MIN:
return plist_first(&c->list)->prio;
case PM_QOS_MAX:
return plist_last(&c->list)->prio;
case PM_QOS_SUM:
plist_for_each(node, &c->list)
total_value += node->prio;
return total_value;
default:
/* runtime check for not using enum */
WARN_ON(1);
return PM_QOS_DEFAULT_VALUE;
}
}
void mtk_pm_qos_trace_dbg_show_request(int pm_qos_class)
{
struct pm_qos_constraints *c;
struct mtk_pm_qos_request *req;
unsigned long flags;
if (pm_qos_class < MTK_PM_QOS_RESERVED
|| pm_qos_class >= MTK_PM_QOS_NUM_CLASSES)
return;
c = mtk_pm_qos_array[pm_qos_class]->constraints;
spin_lock_irqsave(&mtk_pm_qos_lock, flags);
plist_for_each_entry(req, &c->list, node) {
trace_mtk_pm_qos_update_request(req->pm_qos_class,
req->node.prio, req->owner);
}
spin_unlock_irqrestore(&mtk_pm_qos_lock, flags);
}
EXPORT_SYMBOL_GPL(mtk_pm_qos_trace_dbg_show_request);
static int mtk_pm_qos_dbg_show_requests(struct seq_file *s, void *unused)
{
struct mtk_pm_qos_object *qos = (struct mtk_pm_qos_object *)s->private;
struct pm_qos_constraints *c;
struct mtk_pm_qos_request *req;
char *type;
unsigned long flags;
int tot_reqs = 0;
int active_reqs = 0;
if (IS_ERR_OR_NULL(qos)) {
pr_err("%s: bad qos param!\n", __func__);
return -EINVAL;
}
c = qos->constraints;
if (IS_ERR_OR_NULL(c)) {
pr_err("%s: Bad constraints on qos?\n", __func__);
return -EINVAL;
}
/* Lock to ensure we have a snapshot */
spin_lock_irqsave(&mtk_pm_qos_lock, flags);
if (plist_head_empty(&c->list)) {
seq_puts(s, "Empty!\n");
goto out;
}
switch (c->type) {
case PM_QOS_MIN:
type = "Minimum";
break;
case PM_QOS_MAX:
type = "Maximum";
break;
case PM_QOS_SUM:
type = "Sum";
break;
default:
type = "Unknown";
}
plist_for_each_entry(req, &c->list, node) {
char *state = "Default";
if ((req->node).prio != c->default_value) {
active_reqs++;
state = "Active";
}
tot_reqs++;
seq_printf(s, "[%s] : %d: %s\n", req->owner,
(req->node).prio, state);
}
seq_printf(s, "Type=%s, Value=%d, Requests: active=%d / total=%d\n",
type, mtk_pm_qos_get_value(c), active_reqs, tot_reqs);
out:
spin_unlock_irqrestore(&mtk_pm_qos_lock, flags);
return 0;
}
static int mtk_pm_qos_dbg_open(struct inode *inode, struct file *file)
{
return single_open(file, mtk_pm_qos_dbg_show_requests,
PDE_DATA(inode));
}
static const struct file_operations mtk_pm_qos_proc_fops = {
.owner = THIS_MODULE,
.open = mtk_pm_qos_dbg_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
/**
* plist_add - add @node to @head
*
* @node: &struct plist_node pointer
* @head: &struct plist_head pointer
*/
static void mtk_pm_qos_plist_add(struct plist_node *node,
struct plist_head *head)
{
struct plist_node *first, *iter, *prev = NULL;
struct list_head *node_next = &head->node_list;
WARN_ON(!plist_node_empty(node));
WARN_ON(!list_empty(&node->prio_list));
if (plist_head_empty(head))
goto ins_node;
first = iter = plist_first(head);
do {
if (node->prio < iter->prio) {
node_next = &iter->node_list;
break;
}
prev = iter;
iter = list_entry(iter->prio_list.next,
struct plist_node, prio_list);
} while (iter != first);
if (!prev || prev->prio != node->prio)
list_add_tail(&node->prio_list, &iter->prio_list);
ins_node:
list_add_tail(&node->node_list, node_next);
}
/**
* plist_del - Remove a @node from plist.
*
* @node: &struct plist_node pointer - entry to be removed
* @head: &struct plist_head pointer - list head
*/
static void mtk_pm_qos_plist_del(struct plist_node *node,
struct plist_head *head)
{
if (!list_empty(&node->prio_list)) {
if (node->node_list.next != &head->node_list) {
struct plist_node *next;
next = list_entry(node->node_list.next,
struct plist_node, node_list);
/* add the next plist_node into prio_list */
if (list_empty(&next->prio_list))
list_add(&next->prio_list, &node->prio_list);
}
list_del_init(&node->prio_list);
}
list_del_init(&node->node_list);
}
int mtk_pm_qos_request_active(struct mtk_pm_qos_request *req)
{
return req->pm_qos_class != 0;
}
EXPORT_SYMBOL_GPL(mtk_pm_qos_request_active);
static void mtk_pm_qos_update_target_req_list(struct mtk_pm_qos_object *c,
struct mtk_pm_qos_request *req, enum pm_qos_req_action action)
{
unsigned long flags;
spin_lock_irqsave(&mtk_pm_qos_lock, flags);
switch (action) {
case PM_QOS_REMOVE_REQ:
list_del(&req->list_node);
break;
case PM_QOS_UPDATE_REQ:
/*
* to change the list, we atomically remove, reinit
* with new value and add, then see if the extremal
* changed
*/
list_del(&req->list_node);
case PM_QOS_ADD_REQ:
list_add(&req->list_node, &c->req_list);
break;
default:
/* no action */
break;
}
spin_unlock_irqrestore(&mtk_pm_qos_lock, flags);
}
static inline void mtk_pm_qos_set_value(struct pm_qos_constraints *c, s32 value)
{
c->target_value = value;
}
/**
* mtk_pm_qos_request - returns current system wide qos expectation
* @pm_qos_class: identification of which qos value is requested
*
* This function returns the current target value.
*/
int mtk_pm_qos_request(unsigned int pm_qos_class)
{
if (pm_qos_class >= MTK_PM_QOS_NUM_CLASSES) {
pr_err("%s: unknown class =%d\n", __func__, pm_qos_class);
return PM_QOS_DEFAULT_VALUE;
}
return mtk_pm_qos_array[pm_qos_class]->constraints->target_value;
}
EXPORT_SYMBOL_GPL(mtk_pm_qos_request);
/**
* pm_qos_update_target - manages the constraints list and calls the notifiers
* if needed
* @c: constraints data struct
* @node: request to add to the list, to update or to remove
* @action: action to take on the constraints list
* @value: value of the request to add or update
*
* This function returns 1 if the aggregated constraint value has changed, 0
* otherwise.
*/
static int __mtk_pm_qos_update_target(struct pm_qos_constraints *c,
struct plist_node *node, enum pm_qos_req_action action, int value)
{
unsigned long flags;
int prev_value, curr_value, new_value;
int ret;
spin_lock_irqsave(&mtk_pm_qos_lock, flags);
prev_value = mtk_pm_qos_get_value(c);
if (value == PM_QOS_DEFAULT_VALUE)
new_value = c->default_value;
else
new_value = value;
switch (action) {
case PM_QOS_REMOVE_REQ:
mtk_pm_qos_plist_del(node, &c->list);
break;
case PM_QOS_UPDATE_REQ:
/*
* to change the list, we atomically remove, reinit
* with new value and add, then see if the extremal
* changed
*/
mtk_pm_qos_plist_del(node, &c->list);
/* fall through */
case PM_QOS_ADD_REQ:
plist_node_init(node, new_value);
mtk_pm_qos_plist_add(node, &c->list);
break;
default:
/* no action */
break;
}
curr_value = mtk_pm_qos_get_value(c);
mtk_pm_qos_set_value(c, curr_value);
spin_unlock_irqrestore(&mtk_pm_qos_lock, flags);
if (prev_value != curr_value) {
ret = 1;
if (c->notifiers)
blocking_notifier_call_chain(c->notifiers,
(unsigned long)curr_value,
NULL);
} else {
ret = 0;
}
return ret;
}
static void mtk_pm_qos_update_target(struct mtk_pm_qos_object *obj,
struct plist_node *node, enum pm_qos_req_action action, int value)
{
mutex_lock(&obj->qos_lock);
__mtk_pm_qos_update_target(obj->constraints, node, action, value);
mutex_unlock(&obj->qos_lock);
}
/**
* mtk_pm_qos_add_request - inserts new qos request into the list
* @req: pointer to a preallocated handle
* @pm_qos_class: identifies which list of qos request to use
* @value: defines the qos request
*
* This function inserts a new entry in the pm_qos_class list of requested qos
* performance characteristics. It recomputes the aggregate QoS expectations
* for the pm_qos_class of parameters and initializes the pm_qos_request
* handle. Caller needs to save this handle for later use in updates and
* removal.
*/
void mtk_pm_qos_add_request(struct mtk_pm_qos_request *req,
unsigned int pm_qos_class, s32 value)
{
char owner[20];
int n;
if (!req) /*guard against callers passing in null */
return;
if (pm_qos_class >= MTK_PM_QOS_NUM_CLASSES) {
pr_err("%s: unknown class =%d\n", __func__, pm_qos_class);
return;
}
n = snprintf(owner, sizeof(owner) - 1, "%pS",
__builtin_return_address(0));
if (n < 0)
strncpy(owner, "unknown", sizeof(owner) - 1);
if (mtk_pm_qos_request_active(req)) {
pr_err("%s: called for already added request\n", __func__);
return;
}
/* name of mtk_pm_qos reqester */
strncpy(req->owner, owner, sizeof(req->owner) - 1);
req->pm_qos_class = pm_qos_class;
trace_mtk_pm_qos_add_request(pm_qos_class, value, req->owner);
mtk_pm_qos_update_target(
mtk_pm_qos_array[pm_qos_class],
&req->node, PM_QOS_ADD_REQ, value);
mtk_pm_qos_update_target_req_list(
mtk_pm_qos_array[req->pm_qos_class],
req, PM_QOS_ADD_REQ);
}
EXPORT_SYMBOL_GPL(mtk_pm_qos_add_request);
/**
* mtk_pm_qos_update_request - modifies an existing qos request
* @req : handle to list element holding a mtk_pm_qos request to use
* @value: defines the qos request
*
* Updates an existing qos request for the pm_qos_class of parameters along
* with updating the target pm_qos_class value.
*
* Attempts are made to make this code callable on hot code paths.
*/
void mtk_pm_qos_update_request(struct mtk_pm_qos_request *req,
s32 new_value)
{
if (!req) /*guard against callers passing in null */
return;
if (!mtk_pm_qos_request_active(req)) {
pr_err("%s: called for unknown object\n", __func__);
return;
}
trace_mtk_pm_qos_update_request(req->pm_qos_class,
new_value, req->owner);
if (new_value != req->node.prio) {
mtk_pm_qos_update_target(
mtk_pm_qos_array[req->pm_qos_class],
&req->node, PM_QOS_UPDATE_REQ, new_value);
mtk_pm_qos_update_target_req_list(
mtk_pm_qos_array[req->pm_qos_class],
req, PM_QOS_UPDATE_REQ);
}
}
EXPORT_SYMBOL_GPL(mtk_pm_qos_update_request);
/**
* mtk_pm_qos_remove_request - modifies an existing qos request
* @req: handle to request list element
*
* Will remove pm qos request from the list of constraints and
* recompute the current target value for the pm_qos_class. Call this
* on slow code paths.
*/
void mtk_pm_qos_remove_request(struct mtk_pm_qos_request *req)
{
if (!req) /*guard against callers passing in null */
return;
/* silent return to keep pcm code cleaner */
if (!mtk_pm_qos_request_active(req)) {
pr_err("%s: called for unknown object\n", __func__);
return;
}
trace_mtk_pm_qos_remove_request(req->pm_qos_class, PM_QOS_DEFAULT_VALUE,
req->owner);
mtk_pm_qos_update_target(
mtk_pm_qos_array[req->pm_qos_class],
&req->node, PM_QOS_REMOVE_REQ, PM_QOS_DEFAULT_VALUE);
mtk_pm_qos_update_target_req_list(
mtk_pm_qos_array[req->pm_qos_class],
req, PM_QOS_REMOVE_REQ);
memset(req, 0, sizeof(*req));
}
EXPORT_SYMBOL_GPL(mtk_pm_qos_remove_request);
/**
* mtk_pm_qos_add_notifier - sets notification entry for changes to target value
* @pm_qos_class: identifies which qos target changes should be notified.
* @notifier: notifier block managed by caller.
*
* will register the notifier into a notification chain that gets called
* upon changes to the pm_qos_class target value.
*/
int mtk_pm_qos_add_notifier(unsigned int pm_qos_class,
struct notifier_block *notifier)
{
int retval;
if (pm_qos_class >= MTK_PM_QOS_NUM_CLASSES) {
pr_err("%s: unknown class =%d\n", __func__, pm_qos_class);
return -EINVAL;
}
retval = blocking_notifier_chain_register(
mtk_pm_qos_array[pm_qos_class]->constraints->notifiers,
notifier);
return retval;
}
EXPORT_SYMBOL_GPL(mtk_pm_qos_add_notifier);
/**
* mtk_pm_qos_remove_notifier - deletes notification entry from chain.
* @pm_qos_class: identifies which qos target changes are notified.
* @notifier: notifier block to be removed.
*
* will remove the notifier from the notification chain that gets called
* upon changes to the pm_qos_class target value.
*/
int mtk_pm_qos_remove_notifier(unsigned int pm_qos_class,
struct notifier_block *notifier)
{
int retval;
if (pm_qos_class >= MTK_PM_QOS_NUM_CLASSES) {
pr_err("%s: unknown class =%d\n", __func__, pm_qos_class);
return -EINVAL;
}
retval = blocking_notifier_chain_unregister(
mtk_pm_qos_array[pm_qos_class]->constraints->notifiers,
notifier);
return retval;
}
EXPORT_SYMBOL_GPL(mtk_pm_qos_remove_notifier);
/* User space interface to PM QoS classes via misc devices */
static int register_mtk_pm_qos_procfs(struct mtk_pm_qos_object *qos,
struct proc_dir_entry *d)
{
proc_create_data(qos->name, 0444, d,
&mtk_pm_qos_proc_fops, (void *)qos);
return 0;
}
static int __init mtk_pm_qos_power_init(void)
{
int i;
struct proc_dir_entry *proc_root = NULL;
proc_root = proc_mkdir("mtk_pm_qos", NULL);
if (!proc_root)
return -1;
for (i = MTK_PM_QOS_MEMORY_BANDWIDTH; i < MTK_PM_QOS_NUM_CLASSES; i++)
register_mtk_pm_qos_procfs(mtk_pm_qos_array[i], proc_root);
return 0;
}
late_initcall(mtk_pm_qos_power_init);
MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("MediaTek PMQoS driver");
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+46
View File
@@ -0,0 +1,46 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/pm_runtime.h>
static const struct of_device_id bring_up_id_table[] = {
{ .compatible = "mediatek,scpsys-bringup",},
{ .compatible = "mediatek,scpsys-bringup-mt6779",},
{ },
};
MODULE_DEVICE_TABLE(of, bring_up_id_table);
static int bring_up_probe(struct platform_device *pdev)
{
if (!pdev->dev.pm_domain)
return -EPROBE_DEFER;
pm_runtime_enable(&pdev->dev);
/* always enabled in lifetime */
pm_runtime_get_sync(&pdev->dev);
return 0;
}
static int bring_up_remove(struct platform_device *pdev)
{
pm_runtime_put_sync(&pdev->dev);
return 0;
}
static struct platform_driver bring_up = {
.probe = bring_up_probe,
.remove = bring_up_remove,
.driver = {
.name = "bring_up",
.owner = THIS_MODULE,
.of_match_table = bring_up_id_table,
},
};
module_platform_driver(bring_up);
+160
View File
@@ -0,0 +1,160 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2018 MediaTek Inc.
* Author: Owen Chen <Owen.Chen@mediatek.com>
*/
#include <linux/ktime.h>
#include <linux/mfd/syscon.h>
#include <linux/of_device.h>
#include <linux/regmap.h>
#include <linux/soc/mediatek/scpsys-ext.h>
#define MTK_POLL_DELAY_US 10
#define MTK_POLL_TIMEOUT USEC_PER_SEC
static int enable_way_en(struct regmap *map, struct regmap *ack, u32 mask,
u32 ack_mask, u32 reg_set, u32 reg_sta,
u32 reg_en)
{
u32 val;
if (reg_set)
regmap_write(map, reg_set, mask);
else
regmap_update_bits(map, reg_en, mask, mask);
return regmap_read_poll_timeout(ack, reg_sta,
val, (val & ack_mask) == ack_mask,
MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT);
}
static int disable_way_en(struct regmap *map, struct regmap *ack, u32 mask,
u32 ack_mask, u32 reg_clr, u32 reg_sta,
u32 reg_en)
{
u32 val;
if (reg_clr)
regmap_write(map, reg_clr, mask);
else
regmap_update_bits(map, reg_en, mask, 0);
return regmap_read_poll_timeout(ack, reg_sta,
val, (val & ack_mask) == ack_mask,
MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT);
}
static int set_bus_protection(struct regmap *map, u32 mask, u32 ack_mask,
u32 reg_set, u32 reg_sta, u32 reg_en)
{
u32 val;
if (reg_set)
regmap_write(map, reg_set, mask);
else
regmap_update_bits(map, reg_en, mask, mask);
return regmap_read_poll_timeout(map, reg_sta,
val, (val & ack_mask) == ack_mask,
MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT);
}
static int clear_bus_protection(struct regmap *map, u32 mask, u32 ack_mask,
u32 reg_clr, u32 reg_sta, u32 reg_en)
{
u32 val;
if (reg_clr)
regmap_write(map, reg_clr, mask);
else
regmap_update_bits(map, reg_en, mask, 0);
return regmap_read_poll_timeout(map, reg_sta,
val, !(val & ack_mask),
MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT);
}
int mtk_scpsys_ext_set_bus_protection(const struct bus_prot *bp_table,
struct regmap *infracfg, struct regmap *smi_common,
struct regmap *infracfg_nao)
{
int i;
for (i = 0; i < MAX_STEPS && bp_table[i].mask; i++) {
int ret;
switch (bp_table[i].type) {
case IFR_TYPE:
ret = set_bus_protection(infracfg, bp_table[i].mask,
bp_table[i].mask, bp_table[i].set_ofs,
bp_table[i].sta_ofs,
bp_table[i].en_ofs);
break;
case SMI_TYPE:
ret = set_bus_protection(smi_common, bp_table[i].mask,
bp_table[i].mask, bp_table[i].set_ofs,
bp_table[i].sta_ofs,
bp_table[i].en_ofs);
break;
case IFR_WAYEN_TYPE:
ret = disable_way_en(infracfg, infracfg_nao,
bp_table[i].mask,
bp_table[i].clr_ack_mask,
bp_table[i].clr_ofs,
bp_table[i].sta_ofs,
bp_table[i].en_ofs);
break;
default:
return -EINVAL;
}
if (ret)
return ret;
}
return 0;
}
int mtk_scpsys_ext_clear_bus_protection(const struct bus_prot *bp_table,
struct regmap *infracfg, struct regmap *smi_common,
struct regmap *infracfg_nao)
{
int i;
for (i = MAX_STEPS - 1; i >= 0; i--) {
int ret;
switch (bp_table[i].type) {
case IFR_TYPE:
ret = clear_bus_protection(infracfg, bp_table[i].mask,
bp_table[i].clr_ack_mask,
bp_table[i].clr_ofs,
bp_table[i].sta_ofs,
bp_table[i].en_ofs);
break;
case SMI_TYPE:
ret = clear_bus_protection(smi_common,
bp_table[i].mask,
bp_table[i].clr_ack_mask,
bp_table[i].clr_ofs,
bp_table[i].sta_ofs,
bp_table[i].en_ofs);
break;
case IFR_WAYEN_TYPE:
ret = enable_way_en(infracfg, infracfg_nao,
bp_table[i].mask,
bp_table[i].set_ack_mask,
bp_table[i].set_ofs,
bp_table[i].sta_ofs,
bp_table[i].en_ofs);
break;
default:
return -EINVAL;
}
if (ret)
return ret;
}
return 0;
}
File diff suppressed because it is too large. Load diff
+23
View File
@@ -0,0 +1,23 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef __MTK_SCPSYS_H__
#define __MTK_SCPSYS_H__
struct scp_event_data {
int event_type;
int domain_id;
struct generic_pm_domain *genpd;
};
enum scp_event_type {
MTK_SCPSYS_PSTATE,
};
int register_scpsys_notifier(struct notifier_block *nb);
int unregister_scpsys_notifier(struct notifier_block *nb);
#endif /* __MTK_SCPSYS_H__ */
+54
View File
@@ -0,0 +1,54 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2021 MediaTek Inc.
* Author: Po-Kai Chi <pk.chi@mediatek.com>
*/
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/printk.h>
#include <linux/slab.h>
#include <linux/sys_soc.h>
static struct soc_device *soc_dev;
static struct soc_device_attribute *attrs;
static int __init mediatek_socinfo_init(void)
{
struct device_node *np;
attrs = kzalloc(sizeof(*attrs), GFP_KERNEL);
if (!attrs)
return -ENODEV;
attrs->family = "Mediatek";
np = of_find_node_by_path("/");
of_property_read_string(np, "model", &attrs->soc_id);
of_node_put(np);
soc_dev = soc_device_register(attrs);
if (IS_ERR(soc_dev)) {
kfree(attrs);
return PTR_ERR(soc_dev);
}
pr_info("%s SoC detected.\n", attrs->soc_id);
return 0;
}
module_init(mediatek_socinfo_init);
static void __exit mediatek_socinfo_exit(void)
{
if (soc_dev)
soc_device_unregister(soc_dev);
kfree(attrs);
}
module_exit(mediatek_socinfo_exit);
MODULE_DESCRIPTION("MediaTek SoC Info Sysfs Interface");
MODULE_LICENSE("GPL v2");
+661
View File
@@ -0,0 +1,661 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#include <linux/platform_device.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/delay.h>
#include <linux/spinlock.h>
#include <linux/sched/clock.h>
#include <linux/rpmsg.h>
#include <linux/rpmsg/mtk_rpmsg.h>
#include <linux/soc/mediatek/mtk-mbox.h>
#include <linux/soc/mediatek/mtk_tinysys_ipi.h>
#define IPI_POLLING_INTERVAL_US 10
#define MS_TO_US(x) ((x)*1000)
#define ipi_echo(en, fmt, args...) \
({ if (en) pr_info(fmt, ##args); })
static void ipi_isr_cb(struct mtk_mbox_pin_recv *pin, void *priv);
static void ipi_monitor(struct mtk_ipi_device *ipidev, int id, int stage)
{
unsigned long flags = 0;
struct mtk_ipi_chan_table *chan;
chan = &ipidev->table[id];
spin_lock_irqsave(&ipidev->lock_monitor, flags);
switch (stage) {
case SEND_MSG:
chan->ipi_seqno++;
chan->ipi_record[0].idx = 0;
chan->ipi_record[0].ts = cpu_clock(0);
chan->ipi_record[1].idx = 4;
chan->ipi_record[1].ts = 0;
chan->ipi_record[2].idx = 5;
chan->ipi_record[2].ts = 0;
ipi_echo(ipidev->mbdev->log_enable,
"%s: IPI_%d send msg (#%d)\n",
ipidev->name, id, chan->ipi_seqno);
break;
case ISR_RECV_MSGV:
chan->ipi_seqno++;
chan->ipi_record[0].idx = 1;
chan->ipi_record[0].ts = cpu_clock(0);
chan->ipi_record[1].idx = 2;
chan->ipi_record[1].ts = 0;
chan->ipi_record[2].idx = 3;
chan->ipi_record[2].ts = 0;
break;
case RECV_MSG:
chan->ipi_record[1].ts = cpu_clock(0);
ipi_echo(ipidev->mbdev->log_enable,
"%s: IPI_%d recv msg (#%d)\n",
ipidev->name, id, chan->ipi_seqno);
break;
case RECV_ACK:
chan->ipi_record[2].ts = cpu_clock(0);
ipi_echo(ipidev->mbdev->log_enable,
"%s: IPI_%d recv ack (#%d)\n",
ipidev->name, id, chan->ipi_seqno);
break;
case ISR_RECV_ACK:
chan->ipi_record[1].ts = cpu_clock(0);
break;
case SEND_ACK:
chan->ipi_record[2].ts = cpu_clock(0);
ipi_echo(ipidev->mbdev->log_enable,
"%s: IPI_%d send ack (#%d)\n",
ipidev->name, id, chan->ipi_seqno);
break;
default:
break;
}
chan->ipi_stage = stage;
spin_unlock_irqrestore(&ipidev->lock_monitor, flags);
}
static void ipi_timeout_dump(struct mtk_ipi_device *ipidev, int ipi_id)
{
unsigned long flags = 0;
struct mtk_ipi_chan_table *chan;
chan = &ipidev->table[ipi_id];
spin_lock_irqsave(&ipidev->lock_monitor, flags);
pr_err("Error: %s IPI %d timeout at %lld (last done is IPI %d)\n",
ipidev->name, ipi_id, cpu_clock(0), ipidev->ipi_last_done);
pr_err("IPI %d: seqno=%d, state=%d, t%d=%lld, t%d=%lld, t%d=%lld (trysend %d, polling %d\n",
ipi_id, chan->ipi_seqno, chan->ipi_stage,
chan->ipi_record[0].idx, chan->ipi_record[0].ts,
chan->ipi_record[1].idx, chan->ipi_record[1].ts,
chan->ipi_record[2].idx, chan->ipi_record[2].ts,
chan->trysend_count, chan->polling_count);
spin_unlock_irqrestore(&ipidev->lock_monitor, flags);
}
void ipi_monitor_dump(struct mtk_ipi_device *ipidev)
{
int i;
unsigned int ipi_chan_count;
unsigned long flags = 0;
struct mtk_ipi_chan_table *chan;
ipi_chan_count = ipidev->mrpdev->rpdev.src;
pr_info("%s dump IPIMonitor:\n", ipidev->name);
spin_lock_irqsave(&ipidev->lock_monitor, flags);
for (i = 0; i < ipi_chan_count; i++) {
chan = &ipidev->table[i];
if (chan->ipi_stage == UNUSED)
continue;
pr_info("IPI %d: seqno=%d, state=%d, t%d=%lld, t%d=%lld, t%d=%lld\n",
i, chan->ipi_seqno, chan->ipi_stage,
chan->ipi_record[0].idx, chan->ipi_record[0].ts,
chan->ipi_record[1].idx, chan->ipi_record[1].ts,
chan->ipi_record[2].idx, chan->ipi_record[2].ts);
}
spin_unlock_irqrestore(&ipidev->lock_monitor, flags);
}
EXPORT_SYMBOL(ipi_monitor_dump);
int mtk_ipi_device_register(struct mtk_ipi_device *ipidev,
struct platform_device *pdev, struct mtk_mbox_device *mbox,
unsigned int ipi_chan_count)
{
int index;
char chan_name[RPMSG_NAME_SIZE];
struct mtk_ipi_chan_table *ipi_chan_table;
struct mtk_rpmsg_device *mtk_rpdev;
struct mtk_rpmsg_channel_info *mtk_rpchan;
if (!mbox || !ipi_chan_count)
return -EINVAL;
if (!ipidev->name)
return -ENXIO;
ipi_chan_table = kcalloc(ipi_chan_count,
sizeof(struct mtk_ipi_chan_table), GFP_KERNEL);
if (!ipi_chan_table)
return -ENOMEM;
mtk_rpdev = mtk_rpmsg_create_device(pdev, mbox, ipi_chan_count);
if (!mtk_rpdev) {
pr_err("%s create mtk rpmsg device fail.\n", ipidev->name);
kfree(ipi_chan_table);
return IPI_RPMSG_ERR;
}
for (index = 0; index < ipi_chan_count; index++) {
snprintf(chan_name, RPMSG_NAME_SIZE, "%s_ipi#%d",
ipidev->name, index);
mtk_rpchan = mtk_rpmsg_create_channel(mtk_rpdev, index,
chan_name);
if (!mtk_rpchan) {
pr_info("%s create rpmsg channel %d fail.\n",
ipidev->name, index);
goto error_handle;
}
ipi_chan_table[index].rpchan = mtk_rpchan;
ipi_chan_table[index].ept =
rpmsg_create_ept(&(mtk_rpdev->rpdev),
NULL, mtk_rpchan, mtk_rpchan->info);
if (!ipi_chan_table[index].ept)
goto error_handle;
ipi_chan_table[index].ipi_stage = UNUSED;
ipi_chan_table[index].ipi_seqno = 0;
atomic_set(&ipi_chan_table[index].holder, 0);
}
mutex_init(&ipidev->mutex_ipi_reg);
spin_lock_init(&ipidev->lock_monitor);
ipidev->ipi_last_done = -1;
for (index = 0; index < mbox->send_count; index++) {
mutex_init(&mbox->pin_send_table[index].mutex_send);
init_completion(&mbox->pin_send_table[index].comp_ack);
spin_lock_init(&mbox->pin_send_table[index].pin_lock);
ipi_chan_table[mbox->pin_send_table[index].chan_id].pin_send =
&mbox->pin_send_table[index];
}
for (index = 0; index < mbox->recv_count; index++) {
init_completion(&mbox->pin_recv_table[index].notify);
spin_lock_init(&mbox->pin_recv_table[index].pin_lock);
ipi_chan_table[mbox->pin_recv_table[index].chan_id].pin_recv =
&mbox->pin_recv_table[index];
}
mbox->ipi_cb = ipi_isr_cb;
mbox->ipi_priv = (void *)ipidev;
ipidev->mrpdev = mtk_rpdev;
ipidev->table = ipi_chan_table;
ipidev->mbdev = mbox;
ipidev->ipi_inited = 1;
pr_info("%s (with %d IPI) has registered.\n",
ipidev->name, ipi_chan_count);
return IPI_ACTION_DONE;
error_handle:
for (index = 0; index < ipi_chan_count; index++) {
if (ipi_chan_table[index].rpchan != NULL) {
kfree(ipi_chan_table[index].rpchan);
ipi_chan_table[index].rpchan = NULL;
}
if (ipi_chan_table[index].ept != NULL) {
rpmsg_destroy_ept(ipi_chan_table[index].ept);
ipi_chan_table[index].ept = NULL;
}
}
if (mtk_rpdev != NULL) {
device_unregister(&mtk_rpdev->rpdev.dev);
put_device(&mtk_rpdev->rpdev.dev);
mtk_rpdev = NULL;
}
if (ipi_chan_table != NULL) {
kfree(ipi_chan_table);
ipi_chan_table = NULL;
}
return IPI_RPMSG_ERR;
}
EXPORT_SYMBOL(mtk_ipi_device_register);
int mtk_ipi_device_reset(struct mtk_ipi_device *ipidev)
{
int index, chan_count;
unsigned long flags = 0;
struct mtk_ipi_chan_table *chan_table;
if (!ipidev->table)
return -ENXIO;
ipidev->ipi_inited = 0;
chan_count = ipidev->mrpdev->rpdev.src;
chan_table = ipidev->table;
spin_lock_irqsave(&ipidev->lock_monitor, flags);
for (index = 0; index < chan_count; index++) {
chan_table[index].ipi_stage = UNUSED;
chan_table[index].ipi_seqno = 0;
}
ipidev->ipi_last_done = -1;
spin_unlock_irqrestore(&ipidev->lock_monitor, flags);
mtk_mbox_reset_record(ipidev->mbdev);
ipidev->ipi_inited = 1;
pr_info("%s (with %d IPI) has reset.\n", ipidev->name, chan_count);
return IPI_ACTION_DONE;
}
EXPORT_SYMBOL(mtk_ipi_device_reset);
int mtk_ipi_register(struct mtk_ipi_device *ipidev, int ipi_id,
mbox_pin_cb_t cb, void *prdata, void *msg)
{
struct mtk_mbox_pin_recv *pin_recv;
if (!ipidev->ipi_inited)
return IPI_DEV_ILLEGAL;
if (!msg)
return IPI_NO_MSGBUF;
pin_recv = ipidev->table[ipi_id].pin_recv;
if (!pin_recv)
return IPI_UNAVAILABLE;
mutex_lock(&ipidev->mutex_ipi_reg);
if (pin_recv->pin_buf != NULL) {
mutex_unlock(&ipidev->mutex_ipi_reg);
return IPI_DUPLEX;
}
pin_recv->mbox_pin_cb = cb;
pin_recv->pin_buf = msg;
pin_recv->prdata = prdata;
mutex_unlock(&ipidev->mutex_ipi_reg);
return IPI_ACTION_DONE;
}
EXPORT_SYMBOL(mtk_ipi_register);
int mtk_ipi_unregister(struct mtk_ipi_device *ipidev, int ipi_id)
{
struct mtk_mbox_pin_recv *pin_recv;
if (!ipidev->ipi_inited)
return IPI_DEV_ILLEGAL;
pin_recv = ipidev->table[ipi_id].pin_recv;
if (!pin_recv)
return IPI_UNAVAILABLE;
mutex_lock(&ipidev->mutex_ipi_reg);
pin_recv->mbox_pin_cb = NULL;
pin_recv->pin_buf = NULL;
pin_recv->prdata = NULL;
mutex_unlock(&ipidev->mutex_ipi_reg);
return IPI_ACTION_DONE;
}
EXPORT_SYMBOL(mtk_ipi_unregister);
int mtk_ipi_send(struct mtk_ipi_device *ipidev, int ipi_id,
int opt, void *data, int len, int retry_timeout)
{
struct mtk_mbox_pin_send *pin;
unsigned long flags = 0;
int wait_us, ret = 1;
if (!ipidev->ipi_inited)
return IPI_DEV_ILLEGAL;
pin = ipidev->table[ipi_id].pin_send;
if (!pin)
return IPI_UNAVAILABLE;
if (len > pin->msg_size)
return IPI_NO_MEMORY;
else if (!len)
len = pin->msg_size;
wait_us = MS_TO_US(retry_timeout);
if (ipidev->pre_cb && ipidev->pre_cb(ipidev->prdata)) {
pr_notice("Error: IPI [%s] pre_cb fail\n", ipidev->table[ipi_id].rpchan->info.name);
return IPI_PRE_CB_FAIL;
}
if (opt == IPI_SEND_POLLING) {
if (mutex_is_locked(&pin->mutex_send)) {
pr_err("Error: IPI '%s' has been used in WAIT mode\n",
ipidev->table[ipi_id].rpchan->info.name);
BUG_ON(1);
}
spin_lock_irqsave(&pin->pin_lock, flags);
} else {
/* WAIT Mode: NOT be allowed in atomic/interrupt/IRQ disabled */
if (preempt_count() || in_interrupt() || irqs_disabled()) {
pr_err("IPI Panic: %s pin# %d, atomic=%d, interrupt=%ld, irq disabled=%d\n",
ipidev->name, ipi_id, preempt_count(),
in_interrupt(), irqs_disabled());
BUG_ON(1);
}
mutex_lock(&pin->mutex_send);
}
ret = rpmsg_trysend(ipidev->table[ipi_id].ept, data, len);
ipidev->table[ipi_id].trysend_count = 1;
while (wait_us > 0 && ret) {
udelay(IPI_POLLING_INTERVAL_US);
wait_us -= IPI_POLLING_INTERVAL_US;
ret = rpmsg_trysend(ipidev->table[ipi_id].ept, data, len);
ipidev->table[ipi_id].trysend_count++;
}
if (!ret) {
ipi_monitor(ipidev, ipi_id, SEND_MSG);
ipidev->ipi_last_done = ipi_id;
}
if (opt == IPI_SEND_POLLING)
spin_unlock_irqrestore(&pin->pin_lock, flags);
else
mutex_unlock(&pin->mutex_send);
if (ipidev->post_cb && ipidev->post_cb(ipidev->prdata)) {
pr_notice("Error: IPI [%s] post_cb fail\n",
ipidev->table[ipi_id].rpchan->info.name);
return IPI_POST_CB_FAIL;
}
if (ret == MBOX_PIN_BUSY) {
ipi_timeout_dump(ipidev, ipi_id);
return IPI_PIN_BUSY;
} else if (ret != IPI_ACTION_DONE) {
pr_warn("%s IPI %d send fail (%d)\n",
ipidev->name, ipi_id, ret);
return IPI_RPMSG_ERR;
}
return IPI_ACTION_DONE;
}
EXPORT_SYMBOL(mtk_ipi_send);
int mtk_ipi_recv(struct mtk_ipi_device *ipidev, int ipi_id)
{
struct mtk_mbox_pin_recv *pin;
if (!ipidev->ipi_inited)
return IPI_DEV_ILLEGAL;
pin = ipidev->table[ipi_id].pin_recv;
if (!pin)
return IPI_UNAVAILABLE;
/* receive the ipi from ISR */
wait_for_completion_interruptible(&pin->notify);
ipi_monitor(ipidev, ipi_id, RECV_MSG);
ipidev->ipi_last_done = ipi_id;
if (pin->mbox_pin_cb && pin->cb_ctx_opt == MBOX_CB_IN_PROCESS)
pin->mbox_pin_cb(ipi_id, pin->prdata, pin->pin_buf,
pin->msg_size);
return IPI_ACTION_DONE;
}
EXPORT_SYMBOL(mtk_ipi_recv);
int mtk_ipi_send_compl(struct mtk_ipi_device *ipidev, int ipi_id,
int opt, void *data, int len, unsigned long timeout)
{
struct mtk_mbox_pin_send *pin_s;
struct mtk_mbox_pin_recv *pin_r;
unsigned long flags = 0;
int wait, ret;
if (!ipidev->ipi_inited)
return IPI_DEV_ILLEGAL;
pin_s = ipidev->table[ipi_id].pin_send;
pin_r = ipidev->table[ipi_id].pin_recv;
if (!pin_s || !pin_r)
return IPI_UNAVAILABLE;
if (len > pin_s->msg_size)
return IPI_NO_MEMORY;
else if (!len)
len = pin_s->msg_size;
wait = MS_TO_US(timeout);
if (ipidev->pre_cb && ipidev->pre_cb(ipidev->prdata)) {
pr_notice("Error: IPI [%s] pre_cb fail\n", ipidev->table[ipi_id].rpchan->info.name);
return IPI_PRE_CB_FAIL;
}
if (opt == IPI_SEND_POLLING) {
if (mutex_is_locked(&pin_s->mutex_send)) {
pr_err("Error: IPI '%s' has been used in WAIT mode\n",
ipidev->table[ipi_id].rpchan->info.name);
BUG_ON(1);
}
spin_lock_irqsave(&pin_s->pin_lock, flags);
} else {
/* WAIT Mode: NOT be allowed in atomic/interrupt/IRQ disabled */
if (preempt_count() || in_interrupt() || irqs_disabled()) {
pr_err("IPI Panic: %s pin# %d, atomic=%d, interrupt=%ld, irq disabled=%d\n",
ipidev->name, ipi_id, preempt_count(),
in_interrupt(), irqs_disabled());
BUG_ON(1);
}
mutex_lock(&pin_s->mutex_send);
}
atomic_inc(&ipidev->table[ipi_id].holder);
ret = rpmsg_trysend(ipidev->table[ipi_id].ept, data, len);
ipidev->table[ipi_id].trysend_count = 1;
ipidev->table[ipi_id].polling_count = 0;
while (ret && wait > 0) {
udelay(IPI_POLLING_INTERVAL_US);
wait -= IPI_POLLING_INTERVAL_US;
ret = rpmsg_trysend(ipidev->table[ipi_id].ept, data, len);
ipidev->table[ipi_id].trysend_count++;
}
if (ret) {
if (opt == IPI_SEND_POLLING)
spin_unlock_irqrestore(&pin_s->pin_lock, flags);
else
mutex_unlock(&pin_s->mutex_send);
atomic_set(&ipidev->table[ipi_id].holder, 0);
if (ipidev->post_cb && ipidev->post_cb(ipidev->prdata)) {
pr_notice("Error: IPI [%s] post_cb fail\n",
ipidev->table[ipi_id].rpchan->info.name);
return IPI_POST_CB_FAIL;
}
pr_warn("%s IPI %d send fail (%d)\n",
ipidev->name, ipi_id, ret);
return (ret == MBOX_PIN_BUSY) ? IPI_PIN_BUSY : IPI_RPMSG_ERR;
}
ipi_monitor(ipidev, ipi_id, SEND_MSG);
/* Run receive at least once */
wait = (wait < 1) ? IPI_POLLING_INTERVAL_US : wait;
if (opt == IPI_SEND_POLLING) {
while (wait > 0) {
ipidev->table[ipi_id].polling_count++;
if (mtk_mbox_polling(ipidev->mbdev, pin_r->mbox,
pin_r->pin_buf, pin_r) == MBOX_DONE)
break;
if (try_wait_for_completion(&pin_r->notify))
break;
udelay(IPI_POLLING_INTERVAL_US);
wait -= IPI_POLLING_INTERVAL_US;
}
} else {
/* WAIT Mode */
wait = wait_for_completion_timeout(&pin_r->notify,
usecs_to_jiffies(wait));
}
atomic_set(&ipidev->table[ipi_id].holder, 0);
if (wait > 0) {
ipi_monitor(ipidev, ipi_id, RECV_ACK);
ipidev->ipi_last_done = ipi_id;
ret = IPI_ACTION_DONE;
} else {
mtk_mbox_dump_recv_pin(ipidev->mbdev, pin_r);
ipi_timeout_dump(ipidev, ipi_id);
if (ipidev->timeout_handler)
ipidev->timeout_handler(ipi_id);
ret = IPI_COMPL_TIMEOUT;
}
if (opt == IPI_SEND_POLLING)
spin_unlock_irqrestore(&pin_s->pin_lock, flags);
else
mutex_unlock(&pin_s->mutex_send);
if (ipidev->post_cb && ipidev->post_cb(ipidev->prdata)) {
pr_notice("Error: IPI [%s] post_cb fail\n",
ipidev->table[ipi_id].rpchan->info.name);
return IPI_POST_CB_FAIL;
}
return ret;
}
EXPORT_SYMBOL(mtk_ipi_send_compl);
int mtk_ipi_recv_reply(struct mtk_ipi_device *ipidev, int ipi_id,
void *reply_data, int len)
{
struct mtk_mbox_pin_send *pin_s;
struct mtk_mbox_pin_recv *pin_r;
unsigned long flags = 0;
int ret;
if (!ipidev->ipi_inited)
return IPI_DEV_ILLEGAL;
pin_r = ipidev->table[ipi_id].pin_recv;
pin_s = ipidev->table[ipi_id].pin_send;
if (!pin_r || !pin_s)
return IPI_UNAVAILABLE;
if (len > pin_s->msg_size)
return IPI_NO_MEMORY;
else if (len == 0)
len = pin_s->msg_size;
/* recvice the IPI message*/
wait_for_completion_interruptible(&pin_r->notify);
ipi_monitor(ipidev, ipi_id, RECV_MSG);
if (pin_r->mbox_pin_cb && pin_r->cb_ctx_opt == MBOX_CB_IN_PROCESS)
pin_r->mbox_pin_cb(ipi_id, pin_r->prdata, pin_r->pin_buf,
pin_r->msg_size);
/* send the response*/
if (ipidev->pre_cb && ipidev->pre_cb(ipidev->prdata)) {
pr_notice("Error: IPI [%s] pre_cb fail\n", ipidev->table[ipi_id].rpchan->info.name);
return IPI_PRE_CB_FAIL;
}
/* lock this pin until send ack*/
spin_lock_irqsave(&pin_s->pin_lock, flags);
ret = rpmsg_trysend(ipidev->table[ipi_id].ept, reply_data, len);
if (ret == IPI_ACTION_DONE) {
ipi_monitor(ipidev, ipi_id, SEND_ACK);
ipidev->ipi_last_done = ipi_id;
}
spin_unlock_irqrestore(&pin_s->pin_lock, flags);
if (ipidev->post_cb && ipidev->post_cb(ipidev->prdata)) {
pr_notice("Error: IPI [%s] post_cb fail\n",
ipidev->table[ipi_id].rpchan->info.name);
return IPI_POST_CB_FAIL;
}
if (ret == MBOX_PIN_BUSY)
return IPI_PIN_BUSY;
else if (ret != IPI_ACTION_DONE) {
pr_warn("%s IPI %d reply fail (%d)\n",
ipidev->name, ipi_id, ret);
return IPI_RPMSG_ERR;
}
return ret;
}
EXPORT_SYMBOL(mtk_ipi_recv_reply);
void mtk_ipi_tracking(struct mtk_ipi_device *ipidev, bool en)
{
ipidev->mbdev->log_enable = en;
pr_info("%s IPI tracking %s\n", ipidev->name, en ? "on" : "off");
}
EXPORT_SYMBOL(mtk_ipi_tracking);
static void ipi_isr_cb(struct mtk_mbox_pin_recv *pin, void *priv)
{
struct mtk_ipi_device *ipidev = priv;
int ipi_id = pin->chan_id;
atomic_t holder = ipidev->table[ipi_id].holder;
if (pin->recv_opt == MBOX_RECV_MESSAGE) {
ipi_monitor(ipidev, ipi_id, ISR_RECV_MSGV);
complete(&pin->notify);
} else if (atomic_read(&holder)) {
ipi_monitor(ipidev, ipi_id, ISR_RECV_ACK);
complete(&pin->notify);
}
}
MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("MediaTek Tinysys IPI driver");