Skip to contentSkip to conversation

Support MediaTek devapc for MT8186

PATCH In review Rex-BC Chen 5 participants 11 messages May 4, 2022 – Jun 2, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover Support MediaTek devapc for MT8186

This series is for supporting devapc implementation in MT8186.

V2:
- Add a patch to separate register offsets from mtk_devapc_data.

V1:
- Add dt-binding and add devapc data for MT8186.

Rex-BC Chen (3):
dt-bindings: soc: mediatek: devapc: Add bindings for MT8186
soc: mediatek: devapc: Separate register offsets from mtk_devapc_data
soc: mediatek: devapc: Add support for MT8186

 .../bindings/soc/mediatek/devapc.yaml         |  1 +
 drivers/soc/mediatek/mtk-devapc.c             | 45 ++++++++++++-------
 2 files changed, 31 insertions(+), 15 deletions(-)
Signature · 7 lines
2.18.0


_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
#1 lore raw

PATCH v2 1/3 dt-bindings: soc: mediatek: devapc: Add bindings for MT8186

Add the dt-binding to support MT8186 devapc.

---
 Documentation/devicetree/bindings/soc/mediatek/devapc.yaml | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/soc/mediatek/devapc.yaml +1 -0
index 31e4d3c339bf..d0a4bc3b03e9 100644
@@ -20,6 +20,7 @@ properties:
   compatible:
     enum:
       - mediatek,mt6779-devapc
+      - mediatek,mt8186-devapc
 
   reg:
     description: The base address of devapc register bank
Signature · 1 line
2.18.0
#2 lore raw

PATCH v2 2/3 soc: mediatek: devapc: Separate register offsets from mtk_devapc_data

In reply to Rex-BC Chen

The register offsets is the same between MT6779 and MT8186. To reuse the register offsets, we move these register offsets to another structure "mtk_devapc_regs_ofs".

---
 drivers/soc/mediatek/mtk-devapc.c | 37 ++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 15 deletions(-)
drivers/soc/mediatek/mtk-devapc.c +22 -15
index 7c65ad3d1f8a..f27e22cbb770 100644
@@ -31,10 +31,7 @@ struct mtk_devapc_vio_dbgs {
 	u32 vio_dbg1;
 };
 
-struct mtk_devapc_data {
-	/* numbers of violation index */
-	u32 vio_idx_num;
-
+struct mtk_devapc_regs_ofs {
 	/* reg offset */
 	u32 vio_mask_offset;
 	u32 vio_sta_offset;
@@ -46,6 +43,12 @@ struct mtk_devapc_data {
 	u32 vio_shift_con_offset;
 };
 
+struct mtk_devapc_data {
+	/* numbers of violation index */
+	u32 vio_idx_num;
+	const struct mtk_devapc_regs_ofs *regs_ofs;
+};
+
 struct mtk_devapc_context {
 	struct device *dev;
 	void __iomem *infra_base;
@@ -58,7 +61,7 @@ static void clear_vio_status(struct mtk_devapc_context *ctx)
 	void __iomem *reg;
 	int i;
 
-	reg = ctx->infra_base + ctx->data->vio_sta_offset;
+	reg = ctx->infra_base + ctx->data->regs_ofs->vio_sta_offset;
 
 	for (i = 0; i < VIO_MOD_TO_REG_IND(ctx->data->vio_idx_num) - 1; i++)
 		writel(GENMASK(31, 0), reg + 4 * i);
@@ -73,7 +76,7 @@ static void mask_module_irq(struct mtk_devapc_context *ctx, bool mask)
 	u32 val;
 	int i;
 
-	reg = ctx->infra_base + ctx->data->vio_mask_offset;
+	reg = ctx->infra_base + ctx->data->regs_ofs->vio_mask_offset;
 
 	if (mask)
 		val = GENMASK(31, 0);
@@ -116,11 +119,11 @@ static int devapc_sync_vio_dbg(struct mtk_devapc_context *ctx)
 	u32 val;
 
 	pd_vio_shift_sta_reg = ctx->infra_base +
-			       ctx->data->vio_shift_sta_offset;
+			       ctx->data->regs_ofs->vio_shift_sta_offset;
 	pd_vio_shift_sel_reg = ctx->infra_base +
-			       ctx->data->vio_shift_sel_offset;
+			       ctx->data->regs_ofs->vio_shift_sel_offset;
 	pd_vio_shift_con_reg = ctx->infra_base +
-			       ctx->data->vio_shift_con_offset;
+			       ctx->data->regs_ofs->vio_shift_con_offset;
 
 	/* Find the minimum shift group which has violation */
 	val = readl(pd_vio_shift_sta_reg);
@@ -161,8 +164,8 @@ static void devapc_extract_vio_dbg(struct mtk_devapc_context *ctx)
 	void __iomem *vio_dbg0_reg;
 	void __iomem *vio_dbg1_reg;
 
-	vio_dbg0_reg = ctx->infra_base + ctx->data->vio_dbg0_offset;
-	vio_dbg1_reg = ctx->infra_base + ctx->data->vio_dbg1_offset;
+	vio_dbg0_reg = ctx->infra_base + ctx->data->regs_ofs->vio_dbg0_offset;
+	vio_dbg1_reg = ctx->infra_base + ctx->data->regs_ofs->vio_dbg1_offset;
 
 	vio_dbgs.vio_dbg0 = readl(vio_dbg0_reg);
 	vio_dbgs.vio_dbg1 = readl(vio_dbg1_reg);
@@ -200,7 +203,7 @@ 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->apc_con_offset);
+	writel(BIT(31), ctx->infra_base + ctx->data->regs_ofs->apc_con_offset);
 
 	mask_module_irq(ctx, false);
 }
@@ -212,11 +215,10 @@ static void stop_devapc(struct mtk_devapc_context *ctx)
 {
 	mask_module_irq(ctx, true);
 
-	writel(BIT(2), ctx->infra_base + ctx->data->apc_con_offset);
+	writel(BIT(2), ctx->infra_base + ctx->data->regs_ofs->apc_con_offset);
 }
 
-static const struct mtk_devapc_data devapc_mt6779 = {
-	.vio_idx_num = 511,
+static const struct mtk_devapc_regs_ofs devapc_regs_ofs_mt6779 = {
 	.vio_mask_offset = 0x0,
 	.vio_sta_offset = 0x400,
 	.vio_dbg0_offset = 0x900,
@@ -227,6 +229,11 @@ static const struct mtk_devapc_data devapc_mt6779 = {
 	.vio_shift_con_offset = 0xF20,
 };
 
+static const struct mtk_devapc_data devapc_mt6779 = {
+	.vio_idx_num = 511,
+	.regs_ofs = &devapc_regs_ofs_mt6779,
+};
+
 static const struct of_device_id mtk_devapc_dt_match[] = {
 	{
 		.compatible = "mediatek,mt6779-devapc",
Signature · 1 line
2.18.0
maintainer Reviewed-by on v2 2/3
#3 lore raw

Re: [PATCH v2 2/3] soc: mediatek: devapc: Separate register offsets from mtk_devapc_data

Il 04/05/22 13:55, Rex-BC Chen ha scritto:

Quoted 5 lines

The register offsets is the same between MT6779 and MT8186. To reuse the register offsets, we move these register offsets to another structure "mtk_devapc_regs_ofs".

Reviewed-by
#4 lore raw

Re: [PATCH v2 2/3] soc: mediatek: devapc: Separate register offsets from mtk_devapc_data

AngeloGioacchino Del Regno <[email protected]> 於 2022年5月6日 週五 下午4:26寫道:

Quoted 9 lines

Il 04/05/22 13:55, Rex-BC Chen ha scritto:

Quoted 5 lines

The register offsets is the same between MT6779 and MT8186. To reuse the register offsets, we move these register offsets to another structure "mtk_devapc_regs_ofs".

Quoted 6 lines

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

#5 lore raw

PATCH v2 3/3 soc: mediatek: devapc: Add support for MT8186

In reply to Rex-BC Chen

Add devapc data and compatible to support MT8186 devapc.

---
 drivers/soc/mediatek/mtk-devapc.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/soc/mediatek/mtk-devapc.c +8 -0
index f27e22cbb770..fc13334db1b1 100644
@@ -234,10 +234,18 @@ static const struct mtk_devapc_data devapc_mt6779 = {
 	.regs_ofs = &devapc_regs_ofs_mt6779,
 };
 
+static const struct mtk_devapc_data devapc_mt8186 = {
+	.vio_idx_num = 519,
+	.regs_ofs = &devapc_regs_ofs_mt6779,
+};
+
 static const struct of_device_id mtk_devapc_dt_match[] = {
 	{
 		.compatible = "mediatek,mt6779-devapc",
 		.data = &devapc_mt6779,
+	}, {
+		.compatible = "mediatek,mt8186-devapc",
+		.data = &devapc_mt8186,
 	}, {
 	},
 };
Signature · 1 line
2.18.0
Reviewed-by
#7 lore raw

Re: [PATCH v2 3/3] soc: mediatek: devapc: Add support for MT8186

AngeloGioacchino Del Regno <[email protected]> 於 2022年5月6日 週五 下午4:26寫道:

Quoted 8 lines

Il 04/05/22 13:55, Rex-BC Chen ha scritto:

Quoted 4 lines

Add devapc data and compatible to support MT8186 devapc.

Quoted 6 lines

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

#8 lore raw
In reply to Rex-BC Chen
Quoted 14 lines · Rex-BC Chen

This series is for supporting devapc implementation in MT8186.

V2:
- Add a patch to separate register offsets from mtk_devapc_data.

V1:
- Add dt-binding and add devapc data for MT8186.

Rex-BC Chen (3):
dt-bindings: soc: mediatek: devapc: Add bindings for MT8186
soc: mediatek: devapc: Separate register offsets from
mtk_devapc_data
soc: mediatek: devapc: Add support for MT8186

Quoted 5 lines
 .../bindings/soc/mediatek/devapc.yaml         |  1 +
 drivers/soc/mediatek/mtk-devapc.c             | 45 ++++++++++++-----
--
 2 files changed, 31 insertions(+), 15 deletions(-)

Hello Matthias,

Could you spare some time to review this series?
Patches of this this series are reviewed.
The purpose of this series is to add support for MT8186 devapc and it just adds some driver data and compatible for mt8186.

Thanks for your support!

BRs,
Rex

Tested-by on the v2 series
#9 lore raw
In reply to Rex-BC Chen
Quoted 6 lines · Rex-BC Chen

This series is for supporting devapc implementation in MT8186.

V2:
- Add a patch to separate register offsets from mtk_devapc_data.

Quoted 7 lines

V1:
- Add dt-binding and add devapc data for MT8186.

Rex-BC Chen (3):
dt-bindings: soc: mediatek: devapc: Add bindings for MT8186
soc: mediatek: devapc: Separate register offsets from mtk_devapc_data
soc: mediatek: devapc: Add support for MT8186

Applied this on next-20220602 (with a few fixes for other section mismatch errors), booted and got:

[    1.948483] mtk-devapc 10207000.devapc: Read Violation
[    1.948488] mtk-devapc 10207000.devapc: Bus ID:0x100, Dom ID:0x0,
Vio Addr:0x13000000
[    1.948520] mtk-devapc 10207000.devapc: Read Violation
[    1.948523] mtk-devapc 10207000.devapc: Bus ID:0x200, Dom ID:0x0,
Vio Addr:0x140001a0
[    1.948537] mtk-devapc 10207000.devapc: Read Violation
[    1.948540] mtk-devapc 10207000.devapc: Bus ID:0x200, Dom ID:0x0,
Vio Addr:0x140001a0
[    1.948555] mtk-devapc 10207000.devapc: Read Violation
[    1.948558] mtk-devapc 10207000.devapc: Bus ID:0x200, Dom ID:0x0,
Vio Addr:0x14000100
[    1.948573] mtk-devapc 10207000.devapc: Read Violation
[    1.948576] mtk-devapc 10207000.devapc: Bus ID:0x200, Dom ID:0x0,
Vio Addr:0x14000100
[    1.948590] mtk-devapc 10207000.devapc: Read Violation
[    1.948593] mtk-devapc 10207000.devapc: Bus ID:0x200, Dom ID:0x0,
Vio Addr:0x14000100
[    1.948607] mtk-devapc 10207000.devapc: Read Violation
[    1.948610] mtk-devapc 10207000.devapc: Bus ID:0x200, Dom ID:0x0,
Vio Addr:0x14000100
[    1.948624] mtk-devapc 10207000.devapc: Read Violation
[    1.948627] mtk-devapc 10207000.devapc: Bus ID:0x200, Dom ID:0x0,

Vio Addr:0x14000100

during the boot process. So I think this works well. Manually reading a known secure address also triggers it:

root@hayato:~# busybox devmem 0x1000e000
0x00000000
[  135.069121] mtk-devapc 10207000.devapc: Read Violation
[  135.069132] mtk-devapc 10207000.devapc: Bus ID:0x482, Dom ID:0x0,
Vio Addr:0x1000e000

So,

BTW, looks like MT8186 support in mainline is shaping up real good. SCP firmware is still missing, so video codec stuff won't work.

maintainer
#10 lore raw
Quoted 52 lines · Chen-Yu Tsai
Quoted 6 lines · Rex-BC Chen

This series is for supporting devapc implementation in MT8186.

V2:
- Add a patch to separate register offsets from mtk_devapc_data.

Quoted 7 lines

V1:
- Add dt-binding and add devapc data for MT8186.

Rex-BC Chen (3):
dt-bindings: soc: mediatek: devapc: Add bindings for MT8186
soc: mediatek: devapc: Separate register offsets from mtk_devapc_data
soc: mediatek: devapc: Add support for MT8186

Applied this on next-20220602 (with a few fixes for other section mismatch errors), booted and got:

[    1.948483] mtk-devapc 10207000.devapc: Read Violation
[    1.948488] mtk-devapc 10207000.devapc: Bus ID:0x100, Dom ID:0x0,
Vio Addr:0x13000000
[    1.948520] mtk-devapc 10207000.devapc: Read Violation
[    1.948523] mtk-devapc 10207000.devapc: Bus ID:0x200, Dom ID:0x0,
Vio Addr:0x140001a0
[    1.948537] mtk-devapc 10207000.devapc: Read Violation
[    1.948540] mtk-devapc 10207000.devapc: Bus ID:0x200, Dom ID:0x0,
Vio Addr:0x140001a0
[    1.948555] mtk-devapc 10207000.devapc: Read Violation
[    1.948558] mtk-devapc 10207000.devapc: Bus ID:0x200, Dom ID:0x0,
Vio Addr:0x14000100
[    1.948573] mtk-devapc 10207000.devapc: Read Violation
[    1.948576] mtk-devapc 10207000.devapc: Bus ID:0x200, Dom ID:0x0,
Vio Addr:0x14000100
[    1.948590] mtk-devapc 10207000.devapc: Read Violation
[    1.948593] mtk-devapc 10207000.devapc: Bus ID:0x200, Dom ID:0x0,
Vio Addr:0x14000100
[    1.948607] mtk-devapc 10207000.devapc: Read Violation
[    1.948610] mtk-devapc 10207000.devapc: Bus ID:0x200, Dom ID:0x0,
Vio Addr:0x14000100
[    1.948624] mtk-devapc 10207000.devapc: Read Violation
[    1.948627] mtk-devapc 10207000.devapc: Bus ID:0x200, Dom ID:0x0,

Vio Addr:0x14000100

during the boot process. So I think this works well. Manually reading a known secure address also triggers it:

root@hayato:~# busybox devmem 0x1000e000
0x00000000
[  135.069121] mtk-devapc 10207000.devapc: Read Violation
[  135.069132] mtk-devapc 10207000.devapc: Bus ID:0x482, Dom ID:0x0,
Vio Addr:0x1000e000
Quoted 4 lines

So,

Whole series applied to v5.19-next/soc

Quoted 2 lines

BTW, looks like MT8186 support in mainline is shaping up real good. SCP firmware is still missing, so video codec stuff won't work.