1c66ec88fSEmmanuel Vadot* Mediatek IOMMU Architecture Implementation 2c66ec88fSEmmanuel Vadot 3c66ec88fSEmmanuel Vadot Some Mediatek SOCs contain a Multimedia Memory Management Unit (M4U), and 4c66ec88fSEmmanuel Vadotthis M4U have two generations of HW architecture. Generation one uses flat 5c66ec88fSEmmanuel Vadotpagetable, and only supports 4K size page mapping. Generation two uses the 6c66ec88fSEmmanuel VadotARM Short-Descriptor translation table format for address translation. 7c66ec88fSEmmanuel Vadot 8c66ec88fSEmmanuel Vadot About the M4U Hardware Block Diagram, please check below: 9c66ec88fSEmmanuel Vadot 10c66ec88fSEmmanuel Vadot EMI (External Memory Interface) 11c66ec88fSEmmanuel Vadot | 12c66ec88fSEmmanuel Vadot m4u (Multimedia Memory Management Unit) 13c66ec88fSEmmanuel Vadot | 14c66ec88fSEmmanuel Vadot +--------+ 15c66ec88fSEmmanuel Vadot | | 16c66ec88fSEmmanuel Vadot gals0-rx gals1-rx (Global Async Local Sync rx) 17c66ec88fSEmmanuel Vadot | | 18c66ec88fSEmmanuel Vadot | | 19c66ec88fSEmmanuel Vadot gals0-tx gals1-tx (Global Async Local Sync tx) 20c66ec88fSEmmanuel Vadot | | Some SoCs may have GALS. 21c66ec88fSEmmanuel Vadot +--------+ 22c66ec88fSEmmanuel Vadot | 23c66ec88fSEmmanuel Vadot SMI Common(Smart Multimedia Interface Common) 24c66ec88fSEmmanuel Vadot | 25c66ec88fSEmmanuel Vadot +----------------+------- 26c66ec88fSEmmanuel Vadot | | 27c66ec88fSEmmanuel Vadot | gals-rx There may be GALS in some larbs. 28c66ec88fSEmmanuel Vadot | | 29c66ec88fSEmmanuel Vadot | | 30c66ec88fSEmmanuel Vadot | gals-tx 31c66ec88fSEmmanuel Vadot | | 32c66ec88fSEmmanuel Vadot SMI larb0 SMI larb1 ... SoCs have several SMI local arbiter(larb). 33c66ec88fSEmmanuel Vadot (display) (vdec) 34c66ec88fSEmmanuel Vadot | | 35c66ec88fSEmmanuel Vadot | | 36c66ec88fSEmmanuel Vadot +-----+-----+ +----+----+ 37c66ec88fSEmmanuel Vadot | | | | | | 38c66ec88fSEmmanuel Vadot | | |... | | | ... There are different ports in each larb. 39c66ec88fSEmmanuel Vadot | | | | | | 40c66ec88fSEmmanuel VadotOVL0 RDMA0 WDMA0 MC PP VLD 41c66ec88fSEmmanuel Vadot 42c66ec88fSEmmanuel Vadot As above, The Multimedia HW will go through SMI and M4U while it 43c66ec88fSEmmanuel Vadotaccess EMI. SMI is a bridge between m4u and the Multimedia HW. It contain 44c66ec88fSEmmanuel Vadotsmi local arbiter and smi common. It will control whether the Multimedia 45c66ec88fSEmmanuel VadotHW should go though the m4u for translation or bypass it and talk 46c66ec88fSEmmanuel Vadotdirectly with EMI. And also SMI help control the power domain and clocks for 47c66ec88fSEmmanuel Vadoteach local arbiter. 48c66ec88fSEmmanuel Vadot Normally we specify a local arbiter(larb) for each multimedia HW 49c66ec88fSEmmanuel Vadotlike display, video decode, and camera. And there are different ports 50c66ec88fSEmmanuel Vadotin each larb. Take a example, There are many ports like MC, PP, VLD in the 51c66ec88fSEmmanuel Vadotvideo decode local arbiter, all these ports are according to the video HW. 52c66ec88fSEmmanuel Vadot In some SoCs, there may be a GALS(Global Async Local Sync) module between 53c66ec88fSEmmanuel Vadotsmi-common and m4u, and additional GALS module between smi-larb and 54c66ec88fSEmmanuel Vadotsmi-common. GALS can been seen as a "asynchronous fifo" which could help 55c66ec88fSEmmanuel Vadotsynchronize for the modules in different clock frequency. 56c66ec88fSEmmanuel Vadot 57c66ec88fSEmmanuel VadotRequired properties: 58c66ec88fSEmmanuel Vadot- compatible : must be one of the following string: 59c66ec88fSEmmanuel Vadot "mediatek,mt2701-m4u" for mt2701 which uses generation one m4u HW. 60c66ec88fSEmmanuel Vadot "mediatek,mt2712-m4u" for mt2712 which uses generation two m4u HW. 61c66ec88fSEmmanuel Vadot "mediatek,mt6779-m4u" for mt6779 which uses generation two m4u HW. 62c66ec88fSEmmanuel Vadot "mediatek,mt7623-m4u", "mediatek,mt2701-m4u" for mt7623 which uses 63c66ec88fSEmmanuel Vadot generation one m4u HW. 64*6be33864SEmmanuel Vadot "mediatek,mt8167-m4u" for mt8167 which uses generation two m4u HW. 65c66ec88fSEmmanuel Vadot "mediatek,mt8173-m4u" for mt8173 which uses generation two m4u HW. 66c66ec88fSEmmanuel Vadot "mediatek,mt8183-m4u" for mt8183 which uses generation two m4u HW. 67c66ec88fSEmmanuel Vadot- reg : m4u register base and size. 68c66ec88fSEmmanuel Vadot- interrupts : the interrupt of m4u. 69c66ec88fSEmmanuel Vadot- clocks : must contain one entry for each clock-names. 70c66ec88fSEmmanuel Vadot- clock-names : Only 1 optional clock: 71c66ec88fSEmmanuel Vadot - "bclk": the block clock of m4u. 72c66ec88fSEmmanuel Vadot Here is the list which require this "bclk": 73c66ec88fSEmmanuel Vadot - mt2701, mt2712, mt7623 and mt8173. 74c66ec88fSEmmanuel Vadot Note that m4u use the EMI clock which always has been enabled before kernel 75c66ec88fSEmmanuel Vadot if there is no this "bclk". 76c66ec88fSEmmanuel Vadot- mediatek,larbs : List of phandle to the local arbiters in the current Socs. 77c66ec88fSEmmanuel Vadot Refer to bindings/memory-controllers/mediatek,smi-larb.txt. It must sort 78c66ec88fSEmmanuel Vadot according to the local arbiter index, like larb0, larb1, larb2... 79c66ec88fSEmmanuel Vadot- iommu-cells : must be 1. This is the mtk_m4u_id according to the HW. 80c66ec88fSEmmanuel Vadot Specifies the mtk_m4u_id as defined in 81c66ec88fSEmmanuel Vadot dt-binding/memory/mt2701-larb-port.h for mt2701, mt7623 82c66ec88fSEmmanuel Vadot dt-binding/memory/mt2712-larb-port.h for mt2712, 83c66ec88fSEmmanuel Vadot dt-binding/memory/mt6779-larb-port.h for mt6779, 84*6be33864SEmmanuel Vadot dt-binding/memory/mt8167-larb-port.h for mt8167, 85c66ec88fSEmmanuel Vadot dt-binding/memory/mt8173-larb-port.h for mt8173, and 86c66ec88fSEmmanuel Vadot dt-binding/memory/mt8183-larb-port.h for mt8183. 87c66ec88fSEmmanuel Vadot 88c66ec88fSEmmanuel VadotExample: 89c66ec88fSEmmanuel Vadot iommu: iommu@10205000 { 90c66ec88fSEmmanuel Vadot compatible = "mediatek,mt8173-m4u"; 91c66ec88fSEmmanuel Vadot reg = <0 0x10205000 0 0x1000>; 92c66ec88fSEmmanuel Vadot interrupts = <GIC_SPI 139 IRQ_TYPE_LEVEL_LOW>; 93c66ec88fSEmmanuel Vadot clocks = <&infracfg CLK_INFRA_M4U>; 94c66ec88fSEmmanuel Vadot clock-names = "bclk"; 95c66ec88fSEmmanuel Vadot mediatek,larbs = <&larb0 &larb1 &larb2 &larb3 &larb4 &larb5>; 96c66ec88fSEmmanuel Vadot #iommu-cells = <1>; 97c66ec88fSEmmanuel Vadot }; 98c66ec88fSEmmanuel Vadot 99c66ec88fSEmmanuel VadotExample for a client device: 100c66ec88fSEmmanuel Vadot display { 101c66ec88fSEmmanuel Vadot compatible = "mediatek,mt8173-disp"; 102c66ec88fSEmmanuel Vadot iommus = <&iommu M4U_PORT_DISP_OVL0>, 103c66ec88fSEmmanuel Vadot <&iommu M4U_PORT_DISP_RDMA0>; 104c66ec88fSEmmanuel Vadot ... 105c66ec88fSEmmanuel Vadot }; 106