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

@@ -0,0 +1,754 @@
// 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) {
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);
#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)
{
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,
},
};
/*
* devapc_init: module init function.
*/
static int __init mt6768_devapc_init(void)
{
int ret;
DEVAPC_MSG("module initialized\n");
ret = platform_driver_register(&mt6768_devapc_driver);
if (ret) {
pr_err("Unable to register driver, ret(%d)\n", ret);
return ret;
}
proc_create("devapc_dbg", 0664, NULL, &devapc_dbg_fops);
return 0;
}
arch_initcall(mt6768_devapc_init);
MODULE_DESCRIPTION("Mediatek MT6799 Device APC Driver");
MODULE_AUTHOR("Neal Liu <neal.liu@mediatek.com>");
MODULE_LICENSE("GPL");
@@ -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__ */
@@ -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
@@ -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 >= 0 && 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 >= 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 == 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 >= 0 && 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
@@ -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
@@ -0,0 +1,868 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 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 "mtk_io.h"
#include "sync_write.h"
#include "devapc.h"
#if defined(CONFIG_MTK_AEE_FEATURE) && defined(DEVAPC_ENABLE_AEE)
#include <mt-plat/aee.h>
#endif
/* 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
/*
* The extern functions for EMI MPU are removed because EMI MPU and Device APC
* do not share the same IRQ now.
*/
/**************************************************************************
*STATIC FUNCTION
**************************************************************************/
#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) {
pr_err("[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) {
pr_err("[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) {
pr_err("[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;
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++;
snprintf(aee_str, sizeof(aee_str), "[DEVAPC] Access Violation Slave: %s (infra index=%d)\n",
devapc_infra_devices[i].device, i);
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_aee_shown[i] == 0) {
if (devapc_vio_count[i] < DEVAPC_VIO_AEE_TRIGGER_TIMES) {
devapc_vio_count[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: %u\n",
do_div(devapc_vio_first_trigger_time[i], 1000000)); /* ms */
}
}
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: %u\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) <=
(unsigned long long)DEVAPC_VIO_AEE_TRIGGER_FREQUENCY) { /* diff time by ms */
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] %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_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%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] 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_err("[DEVAPC] 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_err("[DEVAPC] 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_err("[DEVAPC] (Infra) Cannot get devapc clock from common clock framework.\n");
return PTR_ERR(dapc_infra_clk);
}
if (clk_prepare_enable(dapc_infra_clk)) {
pr_err("[DEVAPC][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_err("[DEVAPC] Unable to register driver (%d)\n", ret);
return ret;
}
g_devapc_ctrl = cdev_alloc();
if (!g_devapc_ctrl) {
pr_err("[DEVAPC] 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", (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH), 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
}
/* Device APC no longer shares IRQ with EMI and can be changed to use the earlier "arch_initcall" */
arch_initcall(devapc_init);
module_exit(devapc_exit);
MODULE_LICENSE("GPL");
@@ -0,0 +1,92 @@
/* 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 */
/* Notice: You should only use one core to debug */
/* (Please note it may trigger PRINTK too much) */
#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__ */