162306a36Sopenharmony_ci# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
262306a36Sopenharmony_ci%YAML 1.2
362306a36Sopenharmony_ci---
462306a36Sopenharmony_ci$id: http://devicetree.org/schemas/iommu/mediatek,iommu.yaml#
562306a36Sopenharmony_ci$schema: http://devicetree.org/meta-schemas/core.yaml#
662306a36Sopenharmony_ci
762306a36Sopenharmony_cititle: MediaTek IOMMU Architecture Implementation
862306a36Sopenharmony_ci
962306a36Sopenharmony_cimaintainers:
1062306a36Sopenharmony_ci  - Yong Wu <yong.wu@mediatek.com>
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_cidescription: |+
1362306a36Sopenharmony_ci  Some MediaTek SOCs contain a Multimedia Memory Management Unit (M4U), and
1462306a36Sopenharmony_ci  this M4U have two generations of HW architecture. Generation one uses flat
1562306a36Sopenharmony_ci  pagetable, and only supports 4K size page mapping. Generation two uses the
1662306a36Sopenharmony_ci  ARM Short-Descriptor translation table format for address translation.
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci  About the M4U Hardware Block Diagram, please check below:
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci                EMI (External Memory Interface)
2162306a36Sopenharmony_ci                 |
2262306a36Sopenharmony_ci                m4u (Multimedia Memory Management Unit)
2362306a36Sopenharmony_ci                 |
2462306a36Sopenharmony_ci            +--------+
2562306a36Sopenharmony_ci            |        |
2662306a36Sopenharmony_ci        gals0-rx   gals1-rx    (Global Async Local Sync rx)
2762306a36Sopenharmony_ci            |        |
2862306a36Sopenharmony_ci            |        |
2962306a36Sopenharmony_ci        gals0-tx   gals1-tx    (Global Async Local Sync tx)
3062306a36Sopenharmony_ci            |        |          Some SoCs may have GALS.
3162306a36Sopenharmony_ci            +--------+
3262306a36Sopenharmony_ci                 |
3362306a36Sopenharmony_ci             SMI Common(Smart Multimedia Interface Common)
3462306a36Sopenharmony_ci                 |
3562306a36Sopenharmony_ci         +----------------+-------
3662306a36Sopenharmony_ci         |                |
3762306a36Sopenharmony_ci         |             gals-rx        There may be GALS in some larbs.
3862306a36Sopenharmony_ci         |                |
3962306a36Sopenharmony_ci         |                |
4062306a36Sopenharmony_ci         |             gals-tx
4162306a36Sopenharmony_ci         |                |
4262306a36Sopenharmony_ci     SMI larb0        SMI larb1   ... SoCs have several SMI local arbiter(larb).
4362306a36Sopenharmony_ci     (display)         (vdec)
4462306a36Sopenharmony_ci         |                |
4562306a36Sopenharmony_ci         |                |
4662306a36Sopenharmony_ci   +-----+-----+     +----+----+
4762306a36Sopenharmony_ci   |     |     |     |    |    |
4862306a36Sopenharmony_ci   |     |     |...  |    |    |  ... There are different ports in each larb.
4962306a36Sopenharmony_ci   |     |     |     |    |    |
5062306a36Sopenharmony_ci  OVL0 RDMA0 WDMA0  MC   PP   VLD
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci  As above, The Multimedia HW will go through SMI and M4U while it
5362306a36Sopenharmony_ci  access EMI. SMI is a bridge between m4u and the Multimedia HW. It contain
5462306a36Sopenharmony_ci  smi local arbiter and smi common. It will control whether the Multimedia
5562306a36Sopenharmony_ci  HW should go though the m4u for translation or bypass it and talk
5662306a36Sopenharmony_ci  directly with EMI. And also SMI help control the power domain and clocks for
5762306a36Sopenharmony_ci  each local arbiter.
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci  Normally we specify a local arbiter(larb) for each multimedia HW
6062306a36Sopenharmony_ci  like display, video decode, and camera. And there are different ports
6162306a36Sopenharmony_ci  in each larb. Take a example, There are many ports like MC, PP, VLD in the
6262306a36Sopenharmony_ci  video decode local arbiter, all these ports are according to the video HW.
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_ci  In some SoCs, there may be a GALS(Global Async Local Sync) module between
6562306a36Sopenharmony_ci  smi-common and m4u, and additional GALS module between smi-larb and
6662306a36Sopenharmony_ci  smi-common. GALS can been seen as a "asynchronous fifo" which could help
6762306a36Sopenharmony_ci  synchronize for the modules in different clock frequency.
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ciproperties:
7062306a36Sopenharmony_ci  compatible:
7162306a36Sopenharmony_ci    oneOf:
7262306a36Sopenharmony_ci      - enum:
7362306a36Sopenharmony_ci          - mediatek,mt2701-m4u  # generation one
7462306a36Sopenharmony_ci          - mediatek,mt2712-m4u  # generation two
7562306a36Sopenharmony_ci          - mediatek,mt6779-m4u  # generation two
7662306a36Sopenharmony_ci          - mediatek,mt6795-m4u  # generation two
7762306a36Sopenharmony_ci          - mediatek,mt8167-m4u  # generation two
7862306a36Sopenharmony_ci          - mediatek,mt8173-m4u  # generation two
7962306a36Sopenharmony_ci          - mediatek,mt8183-m4u  # generation two
8062306a36Sopenharmony_ci          - mediatek,mt8186-iommu-mm         # generation two
8162306a36Sopenharmony_ci          - mediatek,mt8188-iommu-vdo        # generation two
8262306a36Sopenharmony_ci          - mediatek,mt8188-iommu-vpp        # generation two
8362306a36Sopenharmony_ci          - mediatek,mt8188-iommu-infra      # generation two
8462306a36Sopenharmony_ci          - mediatek,mt8192-m4u  # generation two
8562306a36Sopenharmony_ci          - mediatek,mt8195-iommu-vdo        # generation two
8662306a36Sopenharmony_ci          - mediatek,mt8195-iommu-vpp        # generation two
8762306a36Sopenharmony_ci          - mediatek,mt8195-iommu-infra      # generation two
8862306a36Sopenharmony_ci          - mediatek,mt8365-m4u  # generation two
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_ci      - description: mt7623 generation one
9162306a36Sopenharmony_ci        items:
9262306a36Sopenharmony_ci          - const: mediatek,mt7623-m4u
9362306a36Sopenharmony_ci          - const: mediatek,mt2701-m4u
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ci  reg:
9662306a36Sopenharmony_ci    maxItems: 1
9762306a36Sopenharmony_ci
9862306a36Sopenharmony_ci  interrupts:
9962306a36Sopenharmony_ci    maxItems: 1
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_ci  clocks:
10262306a36Sopenharmony_ci    items:
10362306a36Sopenharmony_ci      - description: bclk is the block clock.
10462306a36Sopenharmony_ci
10562306a36Sopenharmony_ci  clock-names:
10662306a36Sopenharmony_ci    items:
10762306a36Sopenharmony_ci      - const: bclk
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_ci  mediatek,infracfg:
11062306a36Sopenharmony_ci    $ref: /schemas/types.yaml#/definitions/phandle
11162306a36Sopenharmony_ci    description: The phandle to the mediatek infracfg syscon
11262306a36Sopenharmony_ci
11362306a36Sopenharmony_ci  mediatek,larbs:
11462306a36Sopenharmony_ci    $ref: /schemas/types.yaml#/definitions/phandle-array
11562306a36Sopenharmony_ci    minItems: 1
11662306a36Sopenharmony_ci    maxItems: 32
11762306a36Sopenharmony_ci    items:
11862306a36Sopenharmony_ci      maxItems: 1
11962306a36Sopenharmony_ci    description: |
12062306a36Sopenharmony_ci      List of phandle to the local arbiters in the current Socs.
12162306a36Sopenharmony_ci      Refer to bindings/memory-controllers/mediatek,smi-larb.yaml. It must sort
12262306a36Sopenharmony_ci      according to the local arbiter index, like larb0, larb1, larb2...
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_ci  '#iommu-cells':
12562306a36Sopenharmony_ci    const: 1
12662306a36Sopenharmony_ci    description: |
12762306a36Sopenharmony_ci      This is the mtk_m4u_id according to the HW. Specifies the mtk_m4u_id as
12862306a36Sopenharmony_ci      defined in
12962306a36Sopenharmony_ci      dt-binding/memory/mediatek,mt8188-memory-port.h for mt8188,
13062306a36Sopenharmony_ci      dt-binding/memory/mt2701-larb-port.h for mt2701 and mt7623,
13162306a36Sopenharmony_ci      dt-binding/memory/mt2712-larb-port.h for mt2712,
13262306a36Sopenharmony_ci      dt-binding/memory/mt6779-larb-port.h for mt6779,
13362306a36Sopenharmony_ci      dt-binding/memory/mt6795-larb-port.h for mt6795,
13462306a36Sopenharmony_ci      dt-binding/memory/mt8167-larb-port.h for mt8167,
13562306a36Sopenharmony_ci      dt-binding/memory/mt8173-larb-port.h for mt8173,
13662306a36Sopenharmony_ci      dt-binding/memory/mt8183-larb-port.h for mt8183,
13762306a36Sopenharmony_ci      dt-binding/memory/mt8186-memory-port.h for mt8186,
13862306a36Sopenharmony_ci      dt-binding/memory/mt8192-larb-port.h for mt8192.
13962306a36Sopenharmony_ci      dt-binding/memory/mt8195-memory-port.h for mt8195.
14062306a36Sopenharmony_ci      dt-binding/memory/mediatek,mt8365-larb-port.h for mt8365.
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_ci  power-domains:
14362306a36Sopenharmony_ci    maxItems: 1
14462306a36Sopenharmony_ci
14562306a36Sopenharmony_cirequired:
14662306a36Sopenharmony_ci  - compatible
14762306a36Sopenharmony_ci  - reg
14862306a36Sopenharmony_ci  - interrupts
14962306a36Sopenharmony_ci  - '#iommu-cells'
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ciallOf:
15262306a36Sopenharmony_ci  - if:
15362306a36Sopenharmony_ci      properties:
15462306a36Sopenharmony_ci        compatible:
15562306a36Sopenharmony_ci          contains:
15662306a36Sopenharmony_ci            enum:
15762306a36Sopenharmony_ci              - mediatek,mt2701-m4u
15862306a36Sopenharmony_ci              - mediatek,mt2712-m4u
15962306a36Sopenharmony_ci              - mediatek,mt6795-m4u
16062306a36Sopenharmony_ci              - mediatek,mt8173-m4u
16162306a36Sopenharmony_ci              - mediatek,mt8186-iommu-mm
16262306a36Sopenharmony_ci              - mediatek,mt8188-iommu-vdo
16362306a36Sopenharmony_ci              - mediatek,mt8188-iommu-vpp
16462306a36Sopenharmony_ci              - mediatek,mt8192-m4u
16562306a36Sopenharmony_ci              - mediatek,mt8195-iommu-vdo
16662306a36Sopenharmony_ci              - mediatek,mt8195-iommu-vpp
16762306a36Sopenharmony_ci
16862306a36Sopenharmony_ci    then:
16962306a36Sopenharmony_ci      required:
17062306a36Sopenharmony_ci        - clocks
17162306a36Sopenharmony_ci
17262306a36Sopenharmony_ci  - if:
17362306a36Sopenharmony_ci      properties:
17462306a36Sopenharmony_ci        compatible:
17562306a36Sopenharmony_ci          enum:
17662306a36Sopenharmony_ci            - mediatek,mt8186-iommu-mm
17762306a36Sopenharmony_ci            - mediatek,mt8188-iommu-vdo
17862306a36Sopenharmony_ci            - mediatek,mt8188-iommu-vpp
17962306a36Sopenharmony_ci            - mediatek,mt8192-m4u
18062306a36Sopenharmony_ci            - mediatek,mt8195-iommu-vdo
18162306a36Sopenharmony_ci            - mediatek,mt8195-iommu-vpp
18262306a36Sopenharmony_ci
18362306a36Sopenharmony_ci    then:
18462306a36Sopenharmony_ci      required:
18562306a36Sopenharmony_ci        - power-domains
18662306a36Sopenharmony_ci
18762306a36Sopenharmony_ci  - if:
18862306a36Sopenharmony_ci      properties:
18962306a36Sopenharmony_ci        compatible:
19062306a36Sopenharmony_ci          contains:
19162306a36Sopenharmony_ci            enum:
19262306a36Sopenharmony_ci              - mediatek,mt2712-m4u
19362306a36Sopenharmony_ci              - mediatek,mt6795-m4u
19462306a36Sopenharmony_ci              - mediatek,mt8173-m4u
19562306a36Sopenharmony_ci
19662306a36Sopenharmony_ci    then:
19762306a36Sopenharmony_ci      required:
19862306a36Sopenharmony_ci        - mediatek,infracfg
19962306a36Sopenharmony_ci
20062306a36Sopenharmony_ci  - if: # The IOMMUs don't have larbs.
20162306a36Sopenharmony_ci      not:
20262306a36Sopenharmony_ci        properties:
20362306a36Sopenharmony_ci          compatible:
20462306a36Sopenharmony_ci            contains:
20562306a36Sopenharmony_ci              enum:
20662306a36Sopenharmony_ci                - mediatek,mt8188-iommu-infra
20762306a36Sopenharmony_ci                - mediatek,mt8195-iommu-infra
20862306a36Sopenharmony_ci
20962306a36Sopenharmony_ci    then:
21062306a36Sopenharmony_ci      required:
21162306a36Sopenharmony_ci        - mediatek,larbs
21262306a36Sopenharmony_ci
21362306a36Sopenharmony_ciadditionalProperties: false
21462306a36Sopenharmony_ci
21562306a36Sopenharmony_ciexamples:
21662306a36Sopenharmony_ci  - |
21762306a36Sopenharmony_ci    #include <dt-bindings/clock/mt8173-clk.h>
21862306a36Sopenharmony_ci    #include <dt-bindings/interrupt-controller/arm-gic.h>
21962306a36Sopenharmony_ci
22062306a36Sopenharmony_ci    iommu: iommu@10205000 {
22162306a36Sopenharmony_ci            compatible = "mediatek,mt8173-m4u";
22262306a36Sopenharmony_ci            reg = <0x10205000 0x1000>;
22362306a36Sopenharmony_ci            interrupts = <GIC_SPI 139 IRQ_TYPE_LEVEL_LOW>;
22462306a36Sopenharmony_ci            clocks = <&infracfg CLK_INFRA_M4U>;
22562306a36Sopenharmony_ci            clock-names = "bclk";
22662306a36Sopenharmony_ci            mediatek,infracfg = <&infracfg>;
22762306a36Sopenharmony_ci            mediatek,larbs = <&larb0>, <&larb1>, <&larb2>,
22862306a36Sopenharmony_ci                             <&larb3>, <&larb4>, <&larb5>;
22962306a36Sopenharmony_ci            #iommu-cells = <1>;
23062306a36Sopenharmony_ci    };
231