From nobody Fri Dec 19 20:19:29 2025 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9140B313E24; Wed, 17 Dec 2025 06:34:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.61.82.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765953285; cv=none; b=LaOekPFbAcUEqVjfwtq35jEd1b8TQBI6aQ/wmH5a4tYs2owLj2NUz16hJuwY6nYfwbtrD/uor9R+WhCaTaPHAzpo0d0BuM5qL3TIG90KAZb3eZ8Cm9QB0nujaY7rqpmV6oii2FKOTGkc5EN2TC1okT271hsbnV1C/jnOJnFEY+w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765953285; c=relaxed/simple; bh=cXvcE/4zusvgEWHDn8JmMoO++lvEC69nMBVm7PuWaVg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=U4zpAG+EZsU/t9pHl774iOSLeQr9xDzqC5JAiWf+C/cW2vx0hcFGAJOwdGkULOHqZs4ddhZbpjNDim34KDHPp0rPqr5vmqyddEVVKAdJQ8ibWt54Jh8Jy5bLgIR3guj+ff+OnpWS+e5Sh1YzXjzHEkukYYkFvOBpstAx1ZesidE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=reject dis=none) header.from=mediatek.corp-partner.google.com; spf=fail smtp.mailfrom=mediatek.corp-partner.google.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=LThlTPv9; arc=none smtp.client-ip=210.61.82.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=reject dis=none) header.from=mediatek.corp-partner.google.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=mediatek.corp-partner.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="LThlTPv9" X-UUID: 75aff014db1211f0b33aeb1e7f16c2b6-20251217 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=Qa0rG+HkH4eerZc8wp6OWcbR/ghiOeq880uZtF8zOjI=; b=LThlTPv9K/hN9gEN1Ibo9U0F/GOjosVouSmkrj3N6+fFNJ0txaXH4tIWZDh9844XlXj+Da3qg9eD4PCtoA6DnboNR6scoFKwhCOko6nAPkVNa//PNwJWcie201jpQDSoTpap4HAF6kMCqyIcBfA90eT67spbBjkJhJHxfItvWwQ=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.6,REQID:4821d03e-67d4-4dcf-b580-10793e0e094c,IP:0,UR L:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION:r elease,TS:0 X-CID-META: VersionHash:a9d874c,CLOUDID:983288c6-8a73-4871-aac2-7b886d064f36,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|888|898,TC:-5,Content:0|15 |50,EDM:-3,IP:nil,URL:0,File:130,RT:0,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0, OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 75aff014db1211f0b33aeb1e7f16c2b6-20251217 Received: from mtkmbs09n2.mediatek.inc [(172.21.101.94)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 810163785; Wed, 17 Dec 2025 14:34:37 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs13n1.mediatek.inc (172.21.101.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Wed, 17 Dec 2025 14:34:36 +0800 Received: from mtksitap99.mediatek.inc (10.233.130.16) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Wed, 17 Dec 2025 14:34:36 +0800 From: Xiaoshun Xu To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Xiaoshun Xu CC: , , , , Sirius Wang , Vince-wl Liu , Subject: [PATCH v2 1/4] dt-bindings: soc: mediatek: devapc: Add bindings for MT8189 Date: Wed, 17 Dec 2025 14:34:10 +0800 Message-ID: <20251217063429.1157084-2-xiaoshun.xu@mediatek.corp-partner.google.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20251217063429.1157084-1-xiaoshun.xu@mediatek.corp-partner.google.com> References: <20251217063429.1157084-1-xiaoshun.xu@mediatek.corp-partner.google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" External email : Please do not click links or open attachments until you ha= ve verified the sender or the content. From: Xiaoshun Xu Extend the devapc device tree bindings to support the MediaTek MT8189 SoC. This includes: - Adding "mediatek,mt8189-devapc" to the list of compatible strings. - Introducing the "vio-idx-num" property to specify the number of bus slaves managed by devapc. These changes enable proper configuration and integration of devapc on MT8189 platforms, ensuring accurate device matching and resource allocation in the device tree. Signed-off-by: Xiaoshun Xu --- .../devicetree/bindings/soc/mediatek/devapc.yaml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/soc/mediatek/devapc.yaml b/D= ocumentation/devicetree/bindings/soc/mediatek/devapc.yaml index 99e2caafeadf..06a096440331 100644 --- a/Documentation/devicetree/bindings/soc/mediatek/devapc.yaml +++ b/Documentation/devicetree/bindings/soc/mediatek/devapc.yaml @@ -14,13 +14,14 @@ description: | analysis and countermeasures. maintainers: - - Neal Liu + - Xiaoshun Xu properties: compatible: enum: - mediatek,mt6779-devapc - mediatek,mt8186-devapc + - mediatek,mt8189-devapc reg: description: The base address of devapc register bank @@ -30,6 +31,10 @@ properties: description: A single interrupt specifier maxItems: 1 + vio-idx-num: + description: Describe the number of bus slaves controlled by devapc + $ref: /schemas/types.yaml#/definitions/uint32 + clocks: description: Contains module clock source and clock names maxItems: 1 @@ -42,8 +47,6 @@ required: - compatible - reg - interrupts - - clocks - - clock-names additionalProperties: false @@ -55,6 +58,7 @@ examples: devapc: devapc@10207000 { compatible =3D "mediatek,mt6779-devapc"; reg =3D <0x10207000 0x1000>; + vio-idx-num =3D <132>; interrupts =3D ; clocks =3D <&infracfg_ao CLK_INFRA_DEVICE_APC>; clock-names =3D "devapc-infra-clock"; -- 2.45.2 From nobody Fri Dec 19 20:19:29 2025 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0118B25485A; Wed, 17 Dec 2025 06:34:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765953302; cv=none; b=NsyrpV5XLZyL/B1c9+NtepYLwcrFzMUaUMXwCl/dLUFbDAz822N8VCYdP8k09nRww/hHdFC9Td3U5+tKF/jRCVcJ7ctB0767x6s9r3MwEjmP7NuhMniHOjJenayI9F/IZHY7QU19xSAXr+1McbQlaOjsCCTHed06yUfTRLAFUrk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765953302; c=relaxed/simple; bh=UyC4B+XxPdDZJ+CRqibUqJGvvcuIXtzlOMrC64Zfke0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ODuoezWDRPnXtCVmYr/v9OTU5cC4QJ/lDoYodqUkX8bHCd/cGc8RVo0NoWTMRGoNkkkN6yoSM3fLuI5AmZnnCuerwNTc+wD7F20OT/7QB0EZUdGbhwYx/cMQkxoplRiQcfxerMO98ZNCO+0gI/0zigNDPbIqsNndiWIUM9PLw6g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=reject dis=none) header.from=mediatek.corp-partner.google.com; spf=fail smtp.mailfrom=mediatek.corp-partner.google.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=ZDomgyhv; arc=none smtp.client-ip=60.244.123.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=reject dis=none) header.from=mediatek.corp-partner.google.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=mediatek.corp-partner.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="ZDomgyhv" X-UUID: 7674252edb1211f0b2bf0b349165d6e0-20251217 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=o/nlJlqbdiGhfPfY4f+LJ5vDXmGoCV/uzbKbEd32oYc=; b=ZDomgyhvD/O9l4nGjyBo5SsMy5Za7K99XRa7ag+aP1Ax6JxIJokBoS3QK4E/SmTWzp3Jzw3YqpmPwjKtiKxGzQMv7Y/V2BpWFyQhx0iAY/0WE4PMOXBYZG0WQn2D3NPHroK9dswk+tl/GrlC1YntJpy03fPyih/cIAdhSF7vmrk=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.6,REQID:baa1ac68-b3b7-4296-9a2f-07f845f8d47c,IP:0,UR L:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION:r elease,TS:0 X-CID-META: VersionHash:a9d874c,CLOUDID:2595dc02-1fa9-44eb-b231-4afc61466396,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|888|898,TC:-5,Content:0|15 |50,EDM:-3,IP:nil,URL:0,File:130,RT:0,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0, OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 7674252edb1211f0b2bf0b349165d6e0-20251217 Received: from mtkmbs14n1.mediatek.inc [(172.21.101.75)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1432863842; Wed, 17 Dec 2025 14:34:39 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by MTKMBS14N1.mediatek.inc (172.21.101.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.26; Wed, 17 Dec 2025 14:34:37 +0800 Received: from mtksitap99.mediatek.inc (10.233.130.16) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Wed, 17 Dec 2025 14:34:37 +0800 From: Xiaoshun Xu To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Xiaoshun Xu CC: , , , , Sirius Wang , Vince-wl Liu , Subject: [PATCH v2 2/4] soc: mediatek: mtk-devapc: Add support for MT8189 devapc Date: Wed, 17 Dec 2025 14:34:11 +0800 Message-ID: <20251217063429.1157084-3-xiaoshun.xu@mediatek.corp-partner.google.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20251217063429.1157084-1-xiaoshun.xu@mediatek.corp-partner.google.com> References: <20251217063429.1157084-1-xiaoshun.xu@mediatek.corp-partner.google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" External email : Please do not click links or open attachments until you ha= ve verified the sender or the content. From: Xiaoshun Xu Add support for MT8189 devapc, devapc debug registers have new version, so refine the structure of devapc_regs_ofs_xxxx to devapc_regs_ofs_verX, and rename the infra_base to base in mtk_devapc_context because devapc not only access the infra_base to dump debug information when violation happens Signed-off-by: Xiaoshun Xu --- drivers/soc/mediatek/mtk-devapc.c | 158 ++++++++++++++++++++++++------ 1 file changed, 127 insertions(+), 31 deletions(-) diff --git a/drivers/soc/mediatek/mtk-devapc.c b/drivers/soc/mediatek/mtk-d= evapc.c index f54c966138b5..b91df4cf7a61 100644 --- a/drivers/soc/mediatek/mtk-devapc.c +++ b/drivers/soc/mediatek/mtk-devapc.c @@ -26,9 +26,19 @@ struct mtk_devapc_vio_dbgs { u32 addr_h:4; u32 resv:4; } dbg0_bits; + + struct { + u32 dmnid:6; + u32 vio_w:1; + u32 vio_r:1; + u32 addr_h:4; + u32 resv:20; + } dbg0_bits_ver2; }; u32 vio_dbg1; + u32 vio_dbg2; + u32 vio_dbg3; }; struct mtk_devapc_regs_ofs { @@ -37,6 +47,8 @@ struct mtk_devapc_regs_ofs { u32 vio_sta_offset; u32 vio_dbg0_offset; u32 vio_dbg1_offset; + u32 vio_dbg2_offset; + u32 vio_dbg3_offset; u32 apc_con_offset; u32 vio_shift_sta_offset; u32 vio_shift_sel_offset; @@ -44,16 +56,20 @@ struct mtk_devapc_regs_ofs { }; struct mtk_devapc_data { - /* numbers of violation index */ - u32 vio_idx_num; + u32 version; + /* Default numbers of violation index */ + u32 default_vio_idx_num; const struct mtk_devapc_regs_ofs *regs_ofs; }; struct mtk_devapc_context { struct device *dev; - void __iomem *infra_base; + void __iomem *base; struct clk *infra_clk; const struct mtk_devapc_data *data; + + /* numbers of violation index */ + u32 vio_idx_num; }; static void clear_vio_status(struct mtk_devapc_context *ctx) @@ -61,12 +77,12 @@ static void clear_vio_status(struct mtk_devapc_context = *ctx) void __iomem *reg; int i; - reg =3D ctx->infra_base + ctx->data->regs_ofs->vio_sta_offset; + reg =3D ctx->base + ctx->data->regs_ofs->vio_sta_offset; - for (i =3D 0; i < VIO_MOD_TO_REG_IND(ctx->data->vio_idx_num) - 1; i= ++) + for (i =3D 0; i < VIO_MOD_TO_REG_IND(ctx->vio_idx_num - 1); i++) writel(GENMASK(31, 0), reg + 4 * i); - writel(GENMASK(VIO_MOD_TO_REG_OFF(ctx->data->vio_idx_num) - 1, 0), + writel(GENMASK(VIO_MOD_TO_REG_OFF(ctx->vio_idx_num - 1), 0), reg + 4 * i); } @@ -76,22 +92,22 @@ static void mask_module_irq(struct mtk_devapc_context *= ctx, bool mask) u32 val; int i; - reg =3D ctx->infra_base + ctx->data->regs_ofs->vio_mask_offset; + reg =3D ctx->base + ctx->data->regs_ofs->vio_mask_offset; if (mask) val =3D GENMASK(31, 0); else val =3D 0; - for (i =3D 0; i < VIO_MOD_TO_REG_IND(ctx->data->vio_idx_num) - 1; i= ++) + for (i =3D 0; i < VIO_MOD_TO_REG_IND(ctx->vio_idx_num - 1); i++) writel(val, reg + 4 * i); val =3D readl(reg + 4 * i); if (mask) - val |=3D GENMASK(VIO_MOD_TO_REG_OFF(ctx->data->vio_idx_num)= - 1, + val |=3D GENMASK(VIO_MOD_TO_REG_OFF(ctx->vio_idx_num - 1), 0); else - val &=3D ~GENMASK(VIO_MOD_TO_REG_OFF(ctx->data->vio_idx_num= ) - 1, + val &=3D ~GENMASK(VIO_MOD_TO_REG_OFF(ctx->vio_idx_num - 1), 0); writel(val, reg + 4 * i); @@ -118,11 +134,11 @@ static int devapc_sync_vio_dbg(struct mtk_devapc_cont= ext *ctx) int ret; u32 val; - pd_vio_shift_sta_reg =3D ctx->infra_base + + pd_vio_shift_sta_reg =3D ctx->base + ctx->data->regs_ofs->vio_shift_sta_offset; - pd_vio_shift_sel_reg =3D ctx->infra_base + + pd_vio_shift_sel_reg =3D ctx->base + ctx->data->regs_ofs->vio_shift_sel_offset; - pd_vio_shift_con_reg =3D ctx->infra_base + + pd_vio_shift_con_reg =3D ctx->base + ctx->data->regs_ofs->vio_shift_con_offset; /* Find the minimum shift group which has violation */ @@ -163,22 +179,52 @@ static void devapc_extract_vio_dbg(struct mtk_devapc_= context *ctx) struct mtk_devapc_vio_dbgs vio_dbgs; void __iomem *vio_dbg0_reg; void __iomem *vio_dbg1_reg; + void __iomem *vio_dbg2_reg; + void __iomem *vio_dbg3_reg; + u32 vio_addr_l, vio_addr_h, bus_id, domain_id; + u32 vio_w, vio_r; + u64 vio_addr; - vio_dbg0_reg =3D ctx->infra_base + ctx->data->regs_ofs->vio_dbg0_of= fset; - vio_dbg1_reg =3D ctx->infra_base + ctx->data->regs_ofs->vio_dbg1_of= fset; + vio_dbg0_reg =3D ctx->base + ctx->data->regs_ofs->vio_dbg0_offset; + vio_dbg1_reg =3D ctx->base + ctx->data->regs_ofs->vio_dbg1_offset; + vio_dbg2_reg =3D ctx->base + ctx->data->regs_ofs->vio_dbg2_offset; + vio_dbg3_reg =3D ctx->base + ctx->data->regs_ofs->vio_dbg3_offset; vio_dbgs.vio_dbg0 =3D readl(vio_dbg0_reg); vio_dbgs.vio_dbg1 =3D readl(vio_dbg1_reg); + if (ctx->data->version >=3D 2U) + vio_dbgs.vio_dbg2 =3D readl(vio_dbg2_reg); + if (ctx->data->version =3D=3D 3U) + vio_dbgs.vio_dbg3 =3D readl(vio_dbg3_reg); + + if (ctx->data->version =3D=3D 1U) { + /* arch version 1 */ + bus_id =3D vio_dbgs.dbg0_bits.mstid; + vio_addr =3D vio_dbgs.vio_dbg1; + domain_id =3D vio_dbgs.dbg0_bits.dmnid; + vio_w =3D vio_dbgs.dbg0_bits.vio_w; + vio_r =3D vio_dbgs.dbg0_bits.vio_r; + } else { + /* arch version 2 & 3 */ + bus_id =3D vio_dbgs.vio_dbg1; + + vio_addr_l =3D vio_dbgs.vio_dbg2; + vio_addr_h =3D ctx->data->version =3D=3D 2U ? vio_dbgs.dbg0= _bits_ver2.addr_h : + vio_dbgs.vio_dbg3; + vio_addr =3D ((u64)vio_addr_h << 32) + vio_addr_l; + domain_id =3D vio_dbgs.dbg0_bits_ver2.dmnid; + vio_w =3D vio_dbgs.dbg0_bits_ver2.vio_w; + vio_r =3D vio_dbgs.dbg0_bits_ver2.vio_r; + } /* Print violation information */ - if (vio_dbgs.dbg0_bits.vio_w) + if (vio_w) dev_info(ctx->dev, "Write Violation\n"); - else if (vio_dbgs.dbg0_bits.vio_r) + else if (vio_r) dev_info(ctx->dev, "Read Violation\n"); - dev_info(ctx->dev, "Bus ID:0x%x, Dom ID:0x%x, Vio Addr:0x%x\n", - vio_dbgs.dbg0_bits.mstid, vio_dbgs.dbg0_bits.dmnid, - vio_dbgs.vio_dbg1); + dev_info(ctx->dev, "Bus ID:0x%x, Dom ID:0x%x, Vio Addr:0x%llx\n", + bus_id, domain_id, vio_addr); } /* @@ -203,7 +249,8 @@ static irqreturn_t devapc_violation_irq(int irq_number,= void *data) */ static void start_devapc(struct mtk_devapc_context *ctx) { - writel(BIT(31), ctx->infra_base + ctx->data->regs_ofs->apc_con_offs= et); + + writel(BIT(31), ctx->base + ctx->data->regs_ofs->apc_con_offset); mask_module_irq(ctx, false); } @@ -215,10 +262,10 @@ static void stop_devapc(struct mtk_devapc_context *ct= x) { mask_module_irq(ctx, true); - writel(BIT(2), ctx->infra_base + ctx->data->regs_ofs->apc_con_offse= t); + writel(BIT(2), ctx->base + ctx->data->regs_ofs->apc_con_offset); } -static const struct mtk_devapc_regs_ofs devapc_regs_ofs_mt6779 =3D { +static const struct mtk_devapc_regs_ofs devapc_regs_ofs_ver1 =3D { .vio_mask_offset =3D 0x0, .vio_sta_offset =3D 0x400, .vio_dbg0_offset =3D 0x900, @@ -229,14 +276,46 @@ static const struct mtk_devapc_regs_ofs devapc_regs_o= fs_mt6779 =3D { .vio_shift_con_offset =3D 0xF20, }; +static const struct mtk_devapc_regs_ofs devapc_regs_ofs_ver2 =3D { + .vio_mask_offset =3D 0x0, + .vio_sta_offset =3D 0x400, + .vio_dbg0_offset =3D 0x900, + .vio_dbg1_offset =3D 0x904, + .vio_dbg2_offset =3D 0x908, + .apc_con_offset =3D 0xF00, + .vio_shift_sta_offset =3D 0xF20, + .vio_shift_sel_offset =3D 0xF30, + .vio_shift_con_offset =3D 0xF10, +}; + +static const struct mtk_devapc_regs_ofs devapc_regs_ofs_ver3 =3D { + .vio_mask_offset =3D 0x0, + .vio_sta_offset =3D 0x400, + .vio_dbg0_offset =3D 0x900, + .vio_dbg1_offset =3D 0x904, + .vio_dbg2_offset =3D 0x908, + .vio_dbg3_offset =3D 0x90c, + .apc_con_offset =3D 0xF00, + .vio_shift_sta_offset =3D 0xF20, + .vio_shift_sel_offset =3D 0xF30, + .vio_shift_con_offset =3D 0xF10, +}; + static const struct mtk_devapc_data devapc_mt6779 =3D { - .vio_idx_num =3D 511, - .regs_ofs =3D &devapc_regs_ofs_mt6779, + .version =3D 1, + .default_vio_idx_num =3D 511, + .regs_ofs =3D &devapc_regs_ofs_ver1, }; static const struct mtk_devapc_data devapc_mt8186 =3D { - .vio_idx_num =3D 519, - .regs_ofs =3D &devapc_regs_ofs_mt6779, + .version =3D 1, + .default_vio_idx_num =3D 519, + .regs_ofs =3D &devapc_regs_ofs_ver1, +}; + +static const struct mtk_devapc_data devapc_mt8189 =3D { + .version =3D 3, + .regs_ofs =3D &devapc_regs_ofs_ver3, }; static const struct of_device_id mtk_devapc_dt_match[] =3D { @@ -246,6 +325,9 @@ static const struct of_device_id mtk_devapc_dt_match[] = =3D { }, { .compatible =3D "mediatek,mt8186-devapc", .data =3D &devapc_mt8186, + }, { + .compatible =3D "mediatek,mt8189-devapc", + .data =3D &devapc_mt8189, }, { }, }; @@ -268,10 +350,23 @@ static int mtk_devapc_probe(struct platform_device *p= dev) ctx->data =3D of_device_get_match_data(&pdev->dev); ctx->dev =3D &pdev->dev; - ctx->infra_base =3D of_iomap(node, 0); - if (!ctx->infra_base) + ctx->base =3D of_iomap(node, 0); + if (!ctx->base) return -EINVAL; + /* + * Set effective vio_idx_num from default value. + * If vio_idx_num is 0, get the info from DT. + */ + ctx->vio_idx_num =3D ctx->data->default_vio_idx_num; + if (ctx->vio_idx_num =3D=3D 0) + if (of_property_read_u32(node, + "vio-idx-num", + &ctx->vio_idx_num)) { + ret =3D -EINVAL; + goto err; + } + devapc_irq =3D irq_of_parse_and_map(node, 0); if (!devapc_irq) { ret =3D -EINVAL; @@ -296,7 +391,7 @@ static int mtk_devapc_probe(struct platform_device *pde= v) return 0; err: - iounmap(ctx->infra_base); + iounmap(ctx->base); return ret; } @@ -305,7 +400,8 @@ static void mtk_devapc_remove(struct platform_device *p= dev) struct mtk_devapc_context *ctx =3D platform_get_drvdata(pdev); stop_devapc(ctx); - iounmap(ctx->infra_base); + + iounmap(ctx->base); } static struct platform_driver mtk_devapc_driver =3D { -- 2.45.2 From nobody Fri Dec 19 20:19:29 2025 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 29609313545; Wed, 17 Dec 2025 06:34:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765953298; cv=none; b=t71POvEAF2VYu3oDoupWLz2olfQM9/JREQdaClT1/EY0q2Z+VzeQcjYkCetNX13s113mZywJyAwcC5f8j3dM3BIcgmP0Nt847ps9lwln5PFMwfQmVHuZsqFFH3K6teTCQ4hBN9sq3+yQDC6JvT6VBRgLf6ESir/qxfytdZqyxfY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765953298; c=relaxed/simple; bh=Zhq+hf1n0iuomTfYP5MRMLtfw78DDdWKcLXDOuHG9QI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FMe83TNhuolMkaBdzQELUqzf7LownpK8ncWcwQiUaDuUgPa4vWxJbAxRVTgz8sQkHqVkLy1G5b+HllfFVDqbO4UkiTiMzoJdSYbxT6Gty192UzMfwLuJYpEuzjsxTH04cSIwOPbo5vazIPOWuJBJo2PAFaVeHoM/R6tuvjUeCMY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=reject dis=none) header.from=mediatek.corp-partner.google.com; spf=fail smtp.mailfrom=mediatek.corp-partner.google.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=YPyJXAW/; arc=none smtp.client-ip=60.244.123.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=reject dis=none) header.from=mediatek.corp-partner.google.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=mediatek.corp-partner.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="YPyJXAW/" X-UUID: 76f7e2cedb1211f0b2bf0b349165d6e0-20251217 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=W7qCkDiJi277CRsbGMDpiTs3LY7mUx0Vc/wlc2oMoAk=; b=YPyJXAW/C96FKJcyHedPPFGMHNqlxq4tbrOgzTwO2JUJnNk5s63x0DleU0zO+myeoMJwn75FKl/jeQo8IPaSKhbsqtBqPyZYj0pVYnhcvv6gffuLTdls0Zvc02MFECW9rwaJoM6LgG2/Lzf3nbiVtuEHmYqMKVbOsIJznkyccg4=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.6,REQID:cbbd70c9-e2c7-406c-a7d4-2c571c11ff6e,IP:0,UR L:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION:r elease,TS:0 X-CID-META: VersionHash:a9d874c,CLOUDID:1ab348aa-6421-45b1-b8b8-e73e3dc9a90f,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|888|898,TC:-5,Content:0|15 |50,EDM:-3,IP:nil,URL:0,File:130,RT:0,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0, OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 76f7e2cedb1211f0b2bf0b349165d6e0-20251217 Received: from mtkmbs13n2.mediatek.inc [(172.21.101.108)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 530067056; Wed, 17 Dec 2025 14:34:40 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Wed, 17 Dec 2025 14:34:38 +0800 Received: from mtksitap99.mediatek.inc (10.233.130.16) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Wed, 17 Dec 2025 14:34:38 +0800 From: Xiaoshun Xu To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Xiaoshun Xu CC: , , , , Sirius Wang , Vince-wl Liu , Subject: [PATCH v2 3/4] soc: mediatek: mtk-devapc: refine devapc clock control Date: Wed, 17 Dec 2025 14:34:12 +0800 Message-ID: <20251217063429.1157084-4-xiaoshun.xu@mediatek.corp-partner.google.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20251217063429.1157084-1-xiaoshun.xu@mediatek.corp-partner.google.com> References: <20251217063429.1157084-1-xiaoshun.xu@mediatek.corp-partner.google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" External email : Please do not click links or open attachments until you ha= ve verified the sender or the content. From: Xiaoshun Xu Because the new devapc design, devapc clock is controlled by HW power domains, the control flow of devapc clock is not necessary, but to maintain compatibility with legacy ICs, keep this part of code. Signed-off-by: Xiaoshun Xu --- drivers/soc/mediatek/mtk-devapc.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/soc/mediatek/mtk-devapc.c b/drivers/soc/mediatek/mtk-d= evapc.c index b91df4cf7a61..61628b941d92 100644 --- a/drivers/soc/mediatek/mtk-devapc.c +++ b/drivers/soc/mediatek/mtk-devapc.c @@ -373,16 +373,27 @@ static int mtk_devapc_probe(struct platform_device *p= dev) goto err; } - ctx->infra_clk =3D devm_clk_get_enabled(&pdev->dev, "devapc-infra-c= lock"); + /* + * The new design of DAPC clock is controlled by HW power domains, + * making it unnecessary to provide the clock control driver. + */ + ctx->infra_clk =3D devm_clk_get_optional(&pdev->dev, "devapc-infra-= clock"); if (IS_ERR(ctx->infra_clk)) { - ret =3D -EINVAL; - goto err; + dev_err(ctx->dev, "Cannot get devapc clock from CCF\n"); + ctx->infra_clk =3D NULL; + } else { + if (clk_prepare_enable(ctx->infra_clk)) { + ret =3D -EINVAL; + goto err; + } } ret =3D devm_request_irq(&pdev->dev, devapc_irq, devapc_violation_i= rq, - IRQF_TRIGGER_NONE, "devapc", ctx); - if (ret) + IRQF_TRIGGER_NONE | IRQF_SHARED, "devapc", c= tx); + if (ret) { + clk_disable_unprepare(ctx->infra_clk); goto err; + } platform_set_drvdata(pdev, ctx); @@ -401,6 +412,8 @@ static void mtk_devapc_remove(struct platform_device *p= dev) stop_devapc(ctx); + clk_disable_unprepare(ctx->infra_clk); + iounmap(ctx->base); } -- 2.45.2 From nobody Fri Dec 19 20:19:29 2025 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB19F314A7F; Wed, 17 Dec 2025 06:34:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765953297; cv=none; b=eSopcEbk6IXiKZ2M8sHxH356819Q9Dt/UjYoamnJTR378Tve+H3+qbcIogkVbt5aSWW+1kkKHEVsCZOwgnpyMjZDi3sJj3DX/RMyPSf8/fQr7tg+EaiVn7ZBhybruBEV1nXPfQItmfdtHoSkPdPlC6vHq/Yj+xFH/WaJHtS5ZNU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765953297; c=relaxed/simple; bh=I60O0gXMPyR9kAZBitzz3X4RdYftgEhOU2VjbxfzZbc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bvgNSst462cLHhqHSRSyEfizMoQD3u4sUE/2B6tmYusqXnRO3+xGWbYEeWFO0hgGcZ8cOFz7X+4UwTuUZFCFJqBDfZeg7d4iU/pVDcaXbLUH7VN5TMaZtR6mRgvAIpvO5qS5kN92JKMOxUKa99N0iWzI9lPMr3rmNoIFscSg6hM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=reject dis=none) header.from=mediatek.corp-partner.google.com; spf=fail smtp.mailfrom=mediatek.corp-partner.google.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=Ly4FPhxG; arc=none smtp.client-ip=60.244.123.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=reject dis=none) header.from=mediatek.corp-partner.google.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=mediatek.corp-partner.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="Ly4FPhxG" X-UUID: 777ca824db1211f0b2bf0b349165d6e0-20251217 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=U26zkVH5d+38dGjc9TpfhT1XgnH0NEu83IWC3L9CNRg=; b=Ly4FPhxGFVkV7/oLlmXX5lTQRZjLKr1XIP7GK8LrChOUWPqw1vKf4BoO7ewMvEUtoThtHaRbAFdquuenUJZa6ff+WZyo7wlQgPowTu+yqZmnBd5z6uvh7xusItKPCANC3vEY3ktRA9Q4SRlsC+mX3iXGzhz+WclJNB1PYLB3q2Q=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.6,REQID:22e063e4-85b1-4bf1-a664-a1a3facdc503,IP:0,UR L:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION:r elease,TS:0 X-CID-META: VersionHash:a9d874c,CLOUDID:b93288c6-8a73-4871-aac2-7b886d064f36,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|888|898,TC:-5,Content:0|15 |50,EDM:-3,IP:nil,URL:0,File:130,RT:0,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0, OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 777ca824db1211f0b2bf0b349165d6e0-20251217 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 2129783388; Wed, 17 Dec 2025 14:34:40 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs11n1.mediatek.inc (172.21.101.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Wed, 17 Dec 2025 14:34:39 +0800 Received: from mtksitap99.mediatek.inc (10.233.130.16) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Wed, 17 Dec 2025 14:34:39 +0800 From: Xiaoshun Xu To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Xiaoshun Xu CC: , , , , Sirius Wang , Vince-wl Liu , Subject: [PATCH v2 4/4] soc: mediatek: mtk-devapc: refine devapc interrupt handler Date: Wed, 17 Dec 2025 14:34:13 +0800 Message-ID: <20251217063429.1157084-5-xiaoshun.xu@mediatek.corp-partner.google.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20251217063429.1157084-1-xiaoshun.xu@mediatek.corp-partner.google.com> References: <20251217063429.1157084-1-xiaoshun.xu@mediatek.corp-partner.google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" External email : Please do not click links or open attachments until you ha= ve verified the sender or the content. From: Xiaoshun Xu Because the violation IRQ uses a while loop, it might cause the system to remain in the interrupt handler indefinitely. We are currently optimizing this part of the process to handle only 20 violations for debug violation issues, and then exit the loop Signed-off-by: Xiaoshun Xu --- drivers/soc/mediatek/mtk-devapc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/soc/mediatek/mtk-devapc.c b/drivers/soc/mediatek/mtk-d= evapc.c index 61628b941d92..ea38086c5554 100644 --- a/drivers/soc/mediatek/mtk-devapc.c +++ b/drivers/soc/mediatek/mtk-devapc.c @@ -12,6 +12,7 @@ #include #include +#define MAX_VIO_NUM 20 #define VIO_MOD_TO_REG_IND(m) ((m) / 32) #define VIO_MOD_TO_REG_OFF(m) ((m) % 32) @@ -234,13 +235,18 @@ static void devapc_extract_vio_dbg(struct mtk_devapc_= context *ctx) */ static irqreturn_t devapc_violation_irq(int irq_number, void *data) { + u32 vio_num =3D 0; struct mtk_devapc_context *ctx =3D data; - while (devapc_sync_vio_dbg(ctx)) + mask_module_irq(ctx, true); + + for (vio_num =3D 0; (vio_num < MAX_VIO_NUM) && (devapc_sync_vio_dbg= (ctx)); ++vio_num) devapc_extract_vio_dbg(ctx); clear_vio_status(ctx); + mask_module_irq(ctx, false); + return IRQ_HANDLED; } -- 2.45.2