18c2ecf20Sopenharmony_ci* Mediatek IOMMU Architecture Implementation 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ci Some Mediatek SOCs contain a Multimedia Memory Management Unit (M4U), and 48c2ecf20Sopenharmony_cithis M4U have two generations of HW architecture. Generation one uses flat 58c2ecf20Sopenharmony_cipagetable, and only supports 4K size page mapping. Generation two uses the 68c2ecf20Sopenharmony_ciARM Short-Descriptor translation table format for address translation. 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci About the M4U Hardware Block Diagram, please check below: 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci EMI (External Memory Interface) 118c2ecf20Sopenharmony_ci | 128c2ecf20Sopenharmony_ci m4u (Multimedia Memory Management Unit) 138c2ecf20Sopenharmony_ci | 148c2ecf20Sopenharmony_ci +--------+ 158c2ecf20Sopenharmony_ci | | 168c2ecf20Sopenharmony_ci gals0-rx gals1-rx (Global Async Local Sync rx) 178c2ecf20Sopenharmony_ci | | 188c2ecf20Sopenharmony_ci | | 198c2ecf20Sopenharmony_ci gals0-tx gals1-tx (Global Async Local Sync tx) 208c2ecf20Sopenharmony_ci | | Some SoCs may have GALS. 218c2ecf20Sopenharmony_ci +--------+ 228c2ecf20Sopenharmony_ci | 238c2ecf20Sopenharmony_ci SMI Common(Smart Multimedia Interface Common) 248c2ecf20Sopenharmony_ci | 258c2ecf20Sopenharmony_ci +----------------+------- 268c2ecf20Sopenharmony_ci | | 278c2ecf20Sopenharmony_ci | gals-rx There may be GALS in some larbs. 288c2ecf20Sopenharmony_ci | | 298c2ecf20Sopenharmony_ci | | 308c2ecf20Sopenharmony_ci | gals-tx 318c2ecf20Sopenharmony_ci | | 328c2ecf20Sopenharmony_ci SMI larb0 SMI larb1 ... SoCs have several SMI local arbiter(larb). 338c2ecf20Sopenharmony_ci (display) (vdec) 348c2ecf20Sopenharmony_ci | | 358c2ecf20Sopenharmony_ci | | 368c2ecf20Sopenharmony_ci +-----+-----+ +----+----+ 378c2ecf20Sopenharmony_ci | | | | | | 388c2ecf20Sopenharmony_ci | | |... | | | ... There are different ports in each larb. 398c2ecf20Sopenharmony_ci | | | | | | 408c2ecf20Sopenharmony_ciOVL0 RDMA0 WDMA0 MC PP VLD 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci As above, The Multimedia HW will go through SMI and M4U while it 438c2ecf20Sopenharmony_ciaccess EMI. SMI is a bridge between m4u and the Multimedia HW. It contain 448c2ecf20Sopenharmony_cismi local arbiter and smi common. It will control whether the Multimedia 458c2ecf20Sopenharmony_ciHW should go though the m4u for translation or bypass it and talk 468c2ecf20Sopenharmony_cidirectly with EMI. And also SMI help control the power domain and clocks for 478c2ecf20Sopenharmony_cieach local arbiter. 488c2ecf20Sopenharmony_ci Normally we specify a local arbiter(larb) for each multimedia HW 498c2ecf20Sopenharmony_cilike display, video decode, and camera. And there are different ports 508c2ecf20Sopenharmony_ciin each larb. Take a example, There are many ports like MC, PP, VLD in the 518c2ecf20Sopenharmony_civideo decode local arbiter, all these ports are according to the video HW. 528c2ecf20Sopenharmony_ci In some SoCs, there may be a GALS(Global Async Local Sync) module between 538c2ecf20Sopenharmony_cismi-common and m4u, and additional GALS module between smi-larb and 548c2ecf20Sopenharmony_cismi-common. GALS can been seen as a "asynchronous fifo" which could help 558c2ecf20Sopenharmony_cisynchronize for the modules in different clock frequency. 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ciRequired properties: 588c2ecf20Sopenharmony_ci- compatible : must be one of the following string: 598c2ecf20Sopenharmony_ci "mediatek,mt2701-m4u" for mt2701 which uses generation one m4u HW. 608c2ecf20Sopenharmony_ci "mediatek,mt2712-m4u" for mt2712 which uses generation two m4u HW. 618c2ecf20Sopenharmony_ci "mediatek,mt6779-m4u" for mt6779 which uses generation two m4u HW. 628c2ecf20Sopenharmony_ci "mediatek,mt7623-m4u", "mediatek,mt2701-m4u" for mt7623 which uses 638c2ecf20Sopenharmony_ci generation one m4u HW. 648c2ecf20Sopenharmony_ci "mediatek,mt8167-m4u" for mt8167 which uses generation two m4u HW. 658c2ecf20Sopenharmony_ci "mediatek,mt8173-m4u" for mt8173 which uses generation two m4u HW. 668c2ecf20Sopenharmony_ci "mediatek,mt8183-m4u" for mt8183 which uses generation two m4u HW. 678c2ecf20Sopenharmony_ci- reg : m4u register base and size. 688c2ecf20Sopenharmony_ci- interrupts : the interrupt of m4u. 698c2ecf20Sopenharmony_ci- clocks : must contain one entry for each clock-names. 708c2ecf20Sopenharmony_ci- clock-names : Only 1 optional clock: 718c2ecf20Sopenharmony_ci - "bclk": the block clock of m4u. 728c2ecf20Sopenharmony_ci Here is the list which require this "bclk": 738c2ecf20Sopenharmony_ci - mt2701, mt2712, mt7623 and mt8173. 748c2ecf20Sopenharmony_ci Note that m4u use the EMI clock which always has been enabled before kernel 758c2ecf20Sopenharmony_ci if there is no this "bclk". 768c2ecf20Sopenharmony_ci- mediatek,larbs : List of phandle to the local arbiters in the current Socs. 778c2ecf20Sopenharmony_ci Refer to bindings/memory-controllers/mediatek,smi-larb.txt. It must sort 788c2ecf20Sopenharmony_ci according to the local arbiter index, like larb0, larb1, larb2... 798c2ecf20Sopenharmony_ci- iommu-cells : must be 1. This is the mtk_m4u_id according to the HW. 808c2ecf20Sopenharmony_ci Specifies the mtk_m4u_id as defined in 818c2ecf20Sopenharmony_ci dt-binding/memory/mt2701-larb-port.h for mt2701, mt7623 828c2ecf20Sopenharmony_ci dt-binding/memory/mt2712-larb-port.h for mt2712, 838c2ecf20Sopenharmony_ci dt-binding/memory/mt6779-larb-port.h for mt6779, 848c2ecf20Sopenharmony_ci dt-binding/memory/mt8167-larb-port.h for mt8167, 858c2ecf20Sopenharmony_ci dt-binding/memory/mt8173-larb-port.h for mt8173, and 868c2ecf20Sopenharmony_ci dt-binding/memory/mt8183-larb-port.h for mt8183. 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ciExample: 898c2ecf20Sopenharmony_ci iommu: iommu@10205000 { 908c2ecf20Sopenharmony_ci compatible = "mediatek,mt8173-m4u"; 918c2ecf20Sopenharmony_ci reg = <0 0x10205000 0 0x1000>; 928c2ecf20Sopenharmony_ci interrupts = <GIC_SPI 139 IRQ_TYPE_LEVEL_LOW>; 938c2ecf20Sopenharmony_ci clocks = <&infracfg CLK_INFRA_M4U>; 948c2ecf20Sopenharmony_ci clock-names = "bclk"; 958c2ecf20Sopenharmony_ci mediatek,larbs = <&larb0 &larb1 &larb2 &larb3 &larb4 &larb5>; 968c2ecf20Sopenharmony_ci #iommu-cells = <1>; 978c2ecf20Sopenharmony_ci }; 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ciExample for a client device: 1008c2ecf20Sopenharmony_ci display { 1018c2ecf20Sopenharmony_ci compatible = "mediatek,mt8173-disp"; 1028c2ecf20Sopenharmony_ci iommus = <&iommu M4U_PORT_DISP_OVL0>, 1038c2ecf20Sopenharmony_ci <&iommu M4U_PORT_DISP_RDMA0>; 1048c2ecf20Sopenharmony_ci ... 1058c2ecf20Sopenharmony_ci }; 106