Skip to contentSkip to conversation

MediaTek MT8195 APU

PATCH New Flora Fu 1 participant 13 messages Dec 10, 2021

Subsystems (6)
lore
Share & tools
lore

Flora Fu

author
#0 lore raw

cover MediaTek MT8195 APU

MT8195 SOC has APU hardware and this series add support
for MT8195 APU driver. The initial APU driver is implemented in MT8192 APU driver[1] and we add MT8195 platform configuration to enable APU functions.
The MT8195 APU drivers uses the MT8195 apu power domain[2].
[1] https://patchwork.kernel.org/project/linux-mediatek/list/?series=593825
[2] https://patchwork.kernel.org/project/linux-mediatek/list/?series=593841

Flora Fu (12):
dt-bindings: memory: mediatek: Add MT8195 apu iommu bindings
dt-bindings: remoteproc: mediatek: Add MT8195 in apu rproc
dt-bindings: soc: mediatek: apu: Add MT8195 APU power bindings iommu/mediatek: Add APU iommu data for mt8195
remoteproc: mediatek: Add MT8195 APU remoteproc support
soc: mediatek: apu: Add MT8195 APU power driver
arm64: dts: mt8195: Add APU mtk-apu-mailbox node
arm64: dts: mt8195: Add APU-IOMMU nodes
arm64: dts: mt8195: Add apu tinysys node
arm64: dts: mt8195: Add APU power nodes
arm64: dts: mt8195: Add apu-sw-logger node
arm64: dts: mt8195: Set up regulators for APU subsys

 .../bindings/iommu/mediatek,iommu.yaml        |  3 +
 .../bindings/remoteproc/mediatek,apu-rv.yaml  |  1 +
 .../soc/mediatek/mediatek,apu-pwr.yaml        | 23 ++++-
 arch/arm64/boot/dts/mediatek/mt8195-evb.dts   |  5 ++
 arch/arm64/boot/dts/mediatek/mt8195.dtsi      | 84 +++++++++++++++++++
 drivers/iommu/mtk_iommu.c                     | 20 +++++
 drivers/remoteproc/mtk-apu-rproc.c            | 15 ++++
 drivers/soc/mediatek/apusys/apu-pwr.c         | 34 +++++++-
 .../dt-bindings/memory/mt8195-memory-port.h   |  4 +
 9 files changed, 187 insertions(+), 2 deletions(-)
Signature · 1 line
2.18.0
author
#1 lore raw

PATCH 1/12 dt-bindings: memory: mediatek: Add MT8195 apu iommu bindings

There are two apu iommu hardwares in MT8195.
Add MT8195 apu iommu bindings.

---
 Documentation/devicetree/bindings/iommu/mediatek,iommu.yaml | 3 +++
 include/dt-bindings/memory/mt8195-memory-port.h             | 4 ++++
 2 files changed, 7 insertions(+)
Documentation/devicetree/bindings/iommu/mediatek,iommu.yaml +3 -0
index 14fae9642ec9..ba1b3ce6cf99 100644
@@ -81,6 +81,7 @@ properties:
           - mediatek,mt8195-iommu-vdo        # generation two
           - mediatek,mt8195-iommu-vpp        # generation two
           - mediatek,mt8195-iommu-infra      # generation two
+          - mediatek,mt8195-iommu-apu        # generation two
 
       - description: mt7623 generation one
         items:
@@ -158,6 +159,7 @@ allOf:
             - mediatek,mt8192-iommu-apu
             - mediatek,mt8195-iommu-vdo
             - mediatek,mt8195-iommu-vpp
+            - mediatek,mt8195-iommu-apu
 
     then:
       required:
@@ -170,6 +172,7 @@ allOf:
             enum:
               - mediatek,mt8192-iommu-apu
               - mediatek,mt8195-iommu-infra
+              - mediatek,mt8195-iommu-apu
 
     then:
       required:
include/dt-bindings/memory/mt8195-memory-port.h +4 -0
index 9882877cda9d..438e75140717 100644
@@ -405,4 +405,8 @@
 #define IOMMU_PORT_INFRA_SSUSB_R		MTK_IFAIOMMU_PERI_ID(30)
 #define IOMMU_PORT_INFRA_SSUSB_W		MTK_IFAIOMMU_PERI_ID(31)
 
+#define IOMMU_PORT_APU_DATA			MTK_M4U_ID(0, 0)
+#define IOMMU_PORT_APU_VLM			MTK_M4U_ID(0, 1)
+#define IOMMU_PORT_APU_VPU			MTK_M4U_ID(0, 2)
+
 #endif
Signature · 1 line
2.18.0
author
#2 lore raw

PATCH 2/12 dt-bindings: remoteproc: mediatek: Add MT8195 in apu rproc

In reply to Flora Fu

Add the binding description for the MT8195 remote processor.

---
 .../devicetree/bindings/remoteproc/mediatek,apu-rv.yaml          | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/remoteproc/mediatek,apu-rv.yaml +1 -0
index c390b85040eb..cb945bc33318 100644
@@ -22,6 +22,7 @@ properties:
     items:
       - enum:
           - mediatek,mt8192-apusys-rv
+          - mediatek,mt8195-apusys-rv
       - const: simple-mfd
 
   reg:
Signature · 1 line
2.18.0
author
#3 lore raw

PATCH 3/12 dt-bindings: soc: mediatek: apu: Add MT8195 APU power bindings

In reply to Flora Fu

Add MT8195 APU power bindings.

---
 .../soc/mediatek/mediatek,apu-pwr.yaml        | 23 ++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/soc/mediatek/mediatek,apu-pwr.yaml +22 -1
index 00f67dddb162..93afb9919f1f 100644
@@ -19,6 +19,7 @@ properties:
     items:
       - enum:
           - mediatek,mt8192-apu-power
+          - mediatek,mt8195-apu-power
   reg:
     minItems: 1
 
@@ -47,7 +48,27 @@ required:
   - vvpu-supply
   - vmdla-supply
 
-additionalProperties: false
+additionalProperties:
+  if:
+    properties:
+      compatible:
+        enum:
+          - mediatek,mt8195-apu-power
+  then:
+    type: object
+    description:
+      Represent node that will trigger early probing to all iommu device.
+      The APU device all iommu device to be probed before boot remote tinysys.
+    properties:
+      compatible:
+        enum:
+          - mediatek,apu_combo_iommu0
+          - mediatek,apu_combo_iommu1
+      iommus:
+        maxItems: 1
+    required:
+      - compatible
+      - iommus
 
 examples:
   - |
Signature · 1 line
2.18.0
author
#4 lore raw

PATCH 4/12 iommu/mediatek: Add APU iommu data for mt8195

In reply to Flora Fu

Add hardware settins for support mt8195 apu iommu.

---
 drivers/iommu/mtk_iommu.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/iommu/mtk_iommu.c +20 -0
index 4bc7c76062e6..3fda9ad9f925 100644
@@ -218,6 +218,13 @@ static const struct mtk_iommu_iova_region mt8192_multi_dom_apu[] = {
 	{ .iova_base = 0x70000000ULL,	.size = 0x12600000}, /* APU REG */
 };
 
+static const struct mtk_iommu_iova_region mt8195_multi_dom_apu[] = {
+	{ .iova_base = 0x0,		.size = SZ_4G}, /* APU DATA */
+	{ .iova_base = 0x8000000ULL,	.size = 0x8000000},  /* APU VLM */
+	{ .iova_base = 0x20000000ULL,	.size = 0xe0000000}, /* APU VPU */
+	{ .iova_base = 0x70000000ULL,	.size = 0x12600000}, /* APU REG */
+};
+
 /* If 2 M4U share a domain(use the same hwlist), Put the corresponding info in first data.*/
 static struct mtk_iommu_data *mtk_iommu_get_frst_data(struct list_head *hwlist)
 {
@@ -1312,6 +1319,18 @@ static const struct mtk_iommu_plat_data mt8192_data_apu = {
 	.iova_region_nr = ARRAY_SIZE(mt8192_multi_dom_apu),
 };
 
+static const struct mtk_iommu_plat_data mt8195_data_apu = {
+	.m4u_plat       = M4U_MT8195,
+	.flags          = DCM_DISABLE | MTK_IOMMU_TYPE_APU |
+			  SHARE_PGTABLE,
+	.inv_sel_reg    = REG_MMU_INV_SEL_GEN2,
+	.hw_list        = &apulist,
+	.bank_nr	= 1,
+	.bank_enable    = {true},
+	.iova_region    = mt8195_multi_dom_apu,
+	.iova_region_nr = ARRAY_SIZE(mt8195_multi_dom_apu),
+};
+
 static const struct mtk_iommu_plat_data mt8195_data_infra = {
 	.m4u_plat	  = M4U_MT8195,
 	.flags            = WR_THROT_EN | DCM_DISABLE |
@@ -1368,6 +1387,7 @@ static const struct of_device_id mtk_iommu_of_ids[] = {
 	{ .compatible = "mediatek,mt8183-m4u", .data = &mt8183_data},
 	{ .compatible = "mediatek,mt8192-m4u", .data = &mt8192_data},
 	{ .compatible = "mediatek,mt8192-iommu-apu",   .data = &mt8192_data_apu},
+	{ .compatible = "mediatek,mt8195-iommu-apu",   .data = &mt8195_data_apu},
 	{ .compatible = "mediatek,mt8195-iommu-infra", .data = &mt8195_data_infra},
 	{ .compatible = "mediatek,mt8195-iommu-vdo",   .data = &mt8195_data_vdo},
 	{ .compatible = "mediatek,mt8195-iommu-vpp",   .data = &mt8195_data_vpp},
Signature · 1 line
2.18.0
author
#5 lore raw

PATCH 5/12 remoteproc: mediatek: Add MT8195 APU remoteproc support

In reply to Flora Fu

Add MT8195 platform data in the APU remoteproc driver.

---
 drivers/remoteproc/mtk-apu-rproc.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/remoteproc/mtk-apu-rproc.c +15 -0
index 40af8e88f41a..dc54b87ad661 100644
@@ -997,8 +997,23 @@ const struct mtk_apu_platdata mt8192_platdata = {
 	},
 };
 
+const struct mtk_apu_platdata mt8195_platdata = {
+	.flags = F_AUTO_BOOT,
+	.ipi_attrs = mt81xx_ipi_attrs,
+	.ops = {
+		.start = mt81xx_rproc_start,
+		.stop = mt81xx_rproc_stop,
+		.resume = mt81xx_rproc_resume,
+		.apu_memmap_init = mt81xx_apu_memmap_init,
+		.apu_memmap_remove = mt81xx_apu_memmap_remove,
+		.power_on = mt81xx_apu_power_on,
+		.power_off = mt81xx_apu_power_off,
+	},
+};
+
 static const struct of_device_id apu_of_match[] = {
 	{ .compatible = "mediatek,mt8192-apusys-rv", .data = &mt8192_platdata},
+	{ .compatible = "mediatek,mt8195-apusys-rv", .data = &mt8195_platdata},
 	{},
 };
 MODULE_DEVICE_TABLE(of, apu_of_match);
Signature · 1 line
2.18.0
author
#6 lore raw

PATCH 6/12 soc: mediatek: apu: Add MT8195 APU power driver

In reply to Flora Fu

Add APU power driver for MT8195 to support for
subsys clock and regulator controller.

---
 drivers/soc/mediatek/apusys/apu-pwr.c | 34 ++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)
drivers/soc/mediatek/apusys/apu-pwr.c +33 -1
index e8e54a767aff..73e08b442558 100644
@@ -578,10 +578,25 @@ static struct apupwr_plat_data mt8192_apu_power_data = {
 	.ops = &mt8192_pwr_ops,
 };
 
+static const struct apupwr_plat_reg mt8195_pwr_reg = {
+	.opp_user = 0x40,
+	.opp_thermal = 0x44,
+	.opp_curr = 0x48,
+	.opp_mask = 0xF,
+};
+
+static struct apupwr_plat_data mt8195_apu_power_data = {
+	.dvfs_user = MDLA1,
+	.plat_regs = &mt8195_pwr_reg,
+};
+
 static const struct of_device_id apu_power_of_match[] = {
 	{
 		.compatible = "mediatek,mt8192-apu-power",
 		.data = &mt8192_apu_power_data
+	}, {
+		.compatible = "mediatek,mt8195-apu-power",
+		.data = &mt8195_apu_power_data
 	}, {
 		/* Terminator */
 	},
@@ -597,13 +612,30 @@ static struct platform_driver apu_power_driver = {
 	},
 };
 
+static const struct of_device_id apu_combo_iommu[] = {
+	{ .compatible = "mediatek,apu_combo_iommu0"},
+	{ .compatible = "mediatek,apu_combo_iommu1"},
+	{},
+};
+MODULE_DEVICE_TABLE(of, apu_combo_iommu);
+
+static struct platform_driver apu_combo_iommu_driver = {
+	.driver = {
+		.name = "apu_combo_iommu",
+		.of_match_table = of_match_ptr(apu_combo_iommu),
+	},
+};
+
 static int __init apu_power_drv_init(void)
 {
-	return platform_driver_register(&apu_power_driver);
+	platform_driver_register(&apu_power_driver);
+	platform_driver_register(&apu_combo_iommu_driver);
+	return 0;
 }
 
 static void __exit apu_power_drv_exit(void)
 {
+	platform_driver_unregister(&apu_combo_iommu_driver);
 	platform_driver_unregister(&apu_power_driver);
 }
 
Signature · 1 line
2.18.0
author
#7 lore raw

PATCH 7/12 arm64: dts: mt8195: Add APU mtk-apu-mailbox node

In reply to Flora Fu

Add mtk-apu-mailbox for mt8195 SOC.

---
 arch/arm64/boot/dts/mediatek/mt8195.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm64/boot/dts/mediatek/mt8195.dtsi +7 -0
index 6e60c4a38495..7e31e64e6b39 100644
@@ -1360,6 +1360,13 @@
 			#clock-cells = <1>;
 		};
 
+		apu_mailbox: apu_mailbox@19000000 {
+			compatible = "mediatek,mtk-apu-mailbox";
+			reg = <0 0x19000000 0 0x100>;
+			interrupts = <GIC_SPI 436 IRQ_TYPE_LEVEL_HIGH 0>;
+			#mbox-cells = <1>;
+		};
+
 		apu_conn: syscon@19020000 {
 			compatible = "mediatek,mt8195-apu-conn", "syscon";
 			reg = <0 0x19020000 0 0x1000>;
Signature · 1 line
2.18.0
author
#8 lore raw

PATCH 8/12 arm64: dts: mt8195: Add APU-IOMMU nodes

In reply to Flora Fu

Add APU-IOMMI nodes.

---
 arch/arm64/boot/dts/mediatek/mt8195.dtsi | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
arch/arm64/boot/dts/mediatek/mt8195.dtsi +17 -0
index 7e31e64e6b39..2f14e3326a2c 100644
@@ -8,6 +8,7 @@
 #include <dt-bindings/clock/mt8195-clk.h>
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 #include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/memory/mt8195-memory-port.h>
 #include <dt-bindings/phy/phy.h>
 #include <dt-bindings/pinctrl/mt8195-pinfunc.h>
 #include <dt-bindings/reset/ti-syscon.h>
@@ -1367,6 +1368,22 @@
 			#mbox-cells = <1>;
 		};
 
+		iommu_apu0: iommu@19010000 {
+			compatible = "mediatek,mt8195-iommu-apu";
+			reg = <0 0x19010000 0 0x1000>;
+			interrupts = <GIC_SPI 426 IRQ_TYPE_LEVEL_HIGH 0>;
+			#iommu-cells = <1>;
+			power-domains = <&apuspm 0>;
+		};
+
+		iommu_apu1: iommu@19015000 {
+			compatible = "mediatek,mt8195-iommu-apu";
+			reg = <0 0x19015000 0 0x1000>;
+			interrupts = <GIC_SPI 431 IRQ_TYPE_LEVEL_HIGH 0>;
+			#iommu-cells = <1>;
+			power-domains = <&apuspm 0>;
+		};
+
 		apu_conn: syscon@19020000 {
 			compatible = "mediatek,mt8195-apu-conn", "syscon";
 			reg = <0 0x19020000 0 0x1000>;
Signature · 1 line
2.18.0
author
#9 lore raw

PATCH 9/12 arm64: dts: mt8195: Add apu tinysys node

In reply to Flora Fu

Add node for APU tinysys.

---
 arch/arm64/boot/dts/mediatek/mt8195.dtsi | 35 ++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
arch/arm64/boot/dts/mediatek/mt8195.dtsi +35 -0
index 2f14e3326a2c..8f4f56e2f08c 100644
@@ -1368,6 +1368,41 @@
 			#mbox-cells = <1>;
 		};
 
+		apusys_rv: apusys_rv@19001000 {
+			compatible = "mediatek,mt8195-apusys-rv", "simple-mfd";
+			reg = <0 0x19000000 0 0x1000>,
+			      <0 0x19001000 0 0x1000>,
+			      <0 0x19002000 0 0x10>;
+			reg-names = "apu_mbox",
+				    "md32_sysctrl",
+				    "apu_wdt";
+			power-domains = <&apuspm 0>;
+			iommus = <&iommu_apu0 IOMMU_PORT_APU_DATA>;
+			interrupts = <GIC_SPI 425 IRQ_TYPE_LEVEL_HIGH 0>;
+			interrupt-names = "apu_wdt";
+			mboxes = <&apu_mailbox 0>;
+
+			apu_ctrl {
+				compatible = "mediatek,apu-ctrl-rpmsg";
+				mediatek,rpmsg-name = "apu-ctrl-rpmsg";
+			};
+
+			apu_pwr_tx {
+				compatible = "mediatek,apupwr-tx-rpmsg";
+				mediatek,rpmsg-name = "apupwr-tx-rpmsg";
+			};
+
+			apu_pwr_rx {
+				compatible = "mediatek,apupwr-rx-rpmsg";
+				mediatek,rpmsg-name = "apupwr-rx-rpmsg";
+			};
+
+			apu_mdw_rpmsg {
+				compatible = "mediatek,apu-mdw-rpmsg";
+				mediatek,rpmsg-name = "apu-mdw-rpmsg";
+			};
+		};
+
 		iommu_apu0: iommu@19010000 {
 			compatible = "mediatek,mt8195-iommu-apu";
 			reg = <0 0x19010000 0 0x1000>;
Signature · 1 line
2.18.0
author
#10 lore raw

PATCH 10/12 arm64: dts: mt8195: Add APU power nodes

In reply to Flora Fu

Add APU power node for MT8195.

---
 arch/arm64/boot/dts/mediatek/mt8195.dtsi | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
arch/arm64/boot/dts/mediatek/mt8195.dtsi +19 -0
index 8f4f56e2f08c..5ab4b2fba0e9 100644
@@ -1450,6 +1450,25 @@
 			};
 		};
 
+		apusys_power: apusys_power@190f1000 {
+			compatible = "mediatek,mt8195-apu-power";
+			reg = <0 0x190f1000 0 0x1000>,
+			      <0 0x19000600 0 0x100>;
+			reg-names = "apu_pcu",
+				    "apu_spare";
+			power-domains = <&apuspm 0>;
+
+			apu_combo_iommu0 {
+				compatible = "mediatek,apu_combo_iommu0";
+				iommus = <&iommu_apu0 IOMMU_PORT_APU_DATA>;
+			};
+
+			apu_combo_iommu1 {
+				compatible = "mediatek,apu_combo_iommu1";
+				iommus = <&iommu_apu1 IOMMU_PORT_APU_DATA>;
+			};
+		};
+
 		apusys_pll: clock-controller@190f3000 {
 			compatible = "mediatek,mt8195-apusys_pll";
 			reg = <0 0x190f3000 0 0x1000>;
Signature · 1 line
2.18.0
author
#11 lore raw

PATCH 11/12 arm64: dts: mt8195: Add apu-sw-logger node

In reply to Flora Fu

Add apu-sw-logger node to enable debug into tinysys for MT8195 SOC.

---
 arch/arm64/boot/dts/mediatek/mt8195.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm64/boot/dts/mediatek/mt8195.dtsi +6 -0
index 5ab4b2fba0e9..1f915461636e 100644
@@ -1368,6 +1368,12 @@
 			#mbox-cells = <1>;
 		};
 
+		apusys_sw_logger@0x19000040 {
+			compatible = "mediatek,apu-sw-logger";
+			reg = <0 0x19000040 0 0x10>;
+			iommus = <&iommu_apu0 IOMMU_PORT_APU_DATA>;
+		};
+
 		apusys_rv: apusys_rv@19001000 {
 			compatible = "mediatek,mt8195-apusys-rv", "simple-mfd";
 			reg = <0 0x19000000 0 0x1000>,
Signature · 1 line
2.18.0
author
#12 lore raw

PATCH 12/12 arm64: dts: mt8195: Set up regulators for APU subsys

In reply to Flora Fu

Set up APU regulators for mdla and vvpu.

---
 arch/arm64/boot/dts/mediatek/mt8195-evb.dts | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm64/boot/dts/mediatek/mt8195-evb.dts +5 -0
index 6333cab7929f..f49a460a8767 100644
@@ -44,6 +44,11 @@
 	};
 };
 
+&apusys_power {
+	vvpu-supply = <&mt6359_vproc1_buck_reg>;
+	vmdla-supply = <&mt6359_vproc2_buck_reg>;
+};
+
 &i2c0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&i2c0_pin>;
Signature · 1 line
2.18.0