MT2701 iommu support
Subsystems (6)
v3 cover MT2701 iommu support
From: Honghui Zhang <[email protected]>
Mediatek's m4u(Multimedia Memory Management Unit) and SMI(Smart
Multimedia Interface)have two generations HW. They basically sharing the same hardware block diagram, but have some difference as below:
Generation one m4u only supports one layer, flat pagetable addressing,
and only supports 4K size page mapping. While generation two m4u supports 2 levels of pagetable which uses the ARM short-descriptor translation table format for address translation.
They have slight different register base and register offset. They have very different HW ports defines.
Generaion one SMI has additional "async" clock which transform the smi
clock into emi clock domain, this clock should be prepared and enabled for SMI generation one HW.
The register which control the iommu need to translation the address or not for a particular port is located at smi ao base(smi always on register base) for generation one SMI HW, but located at each larb's register base for generation two HW.
This patch set add mt2701 iommu support, it's based on 4.6-rc1 and James Liao's "Add clock support for Mediatek MT2701 v8[1]" and "Mediatek MT2701 SCPSYS power domain support v7[2]" patch.
v3:
-Rebase on "of: Implement iterator for phandles[3]" and take use of
of_for_each_phandle.
-Forward-declare mtk_iommu_domain and implement the struct separately. -Free the pagetable memory in mtk_iommu_domain_free
-Roll back the mapping in error case.
-Minor cleanups.
v2: https://lists.linuxfoundation.org/pipermail/iommu/2016-May/017068.html
-Fix syntax errors in dt-bindings.
-Use dma_alloc/free_coherent to allocate pagetable memory and reduce the
streaming DMA stuff.
-Make the mtk_iommu_ops.pgsize_bitmap as ~0UL << MT2701_IOMMU_PAGE_SHIFT. -Use macro instead of variable to indicate the pagetable size. -Change some macro name from MTK_XXX to MT2701_XXX.
v1: http://lists.infradead.org/pipermail/linux-mediatek/2016-May/005301.html
-initial version
[1] http://lists.infradead.org/pipermail/linux-mediatek/2016-May/005439.html
[2] http://lists.infradead.org/pipermail/linux-mediatek/2016-May/005429.html
[3] https://lists.linuxfoundation.org/pipermail/iommu/2016-April/016300.html
Honghui Zhang (5):
dt-bindings: mediatek: add descriptions for mediatek mt2701 iommu and
smi
iommu/mediatek: move the common struct into header file memory/mediatek: add support for mt2701
iommu/mediatek: add support for mtk iommu generation one HW
ARM: dts: mt2701: add iommu/smi dtsi node for mt2701
.../devicetree/bindings/iommu/mediatek,iommu.txt | 13 +- .../memory-controllers/mediatek,smi-common.txt | 21 +- .../memory-controllers/mediatek,smi-larb.txt | 4 +- arch/arm/boot/dts/mt2701.dtsi | 51 ++ drivers/iommu/Kconfig | 18 + drivers/iommu/Makefile | 1 + drivers/iommu/mtk_iommu.c | 48 +- drivers/iommu/mtk_iommu.h | 77 +++ drivers/iommu/mtk_iommu_v1.c | 728 +++++++++++++++++++++ drivers/memory/mtk-smi.c | 168 ++++- include/dt-bindings/memory/mt2701-larb-port.h | 85 +++ 11 files changed, 1140 insertions(+), 74 deletions(-) create mode 100644 drivers/iommu/mtk_iommu.h create mode 100644 drivers/iommu/mtk_iommu_v1.c create mode 100644 include/dt-bindings/memory/mt2701-larb-port.h
Signature · 1 line
1.8.1.1.dirty
PATCH v3 1/5 dt-bindings: mediatek: add descriptions for mediatek mt2701 iommu and smi
From: Honghui Zhang <[email protected]>
This patch defines the local arbitor port IDs for mediatek SoC MT2701 and add descriptions of binding for mediatek generation one iommu and smi.
--- .../devicetree/bindings/iommu/mediatek,iommu.txt | 13 +++- .../memory-controllers/mediatek,smi-common.txt | 21 +++++- .../memory-controllers/mediatek,smi-larb.txt | 4 +- include/dt-bindings/memory/mt2701-larb-port.h | 85 ++++++++++++++++++++++ 4 files changed, 115 insertions(+), 8 deletions(-) create mode 100644 include/dt-bindings/memory/mt2701-larb-port.h
Documentation/devicetree/bindings/iommu/mediatek,iommu.txt +9 -4
@@ -1,7 +1,9 @@ * Mediatek IOMMU Architecture Implementation - Some Mediatek SOCs contain a Multimedia Memory Management Unit (M4U) which -uses the ARM Short-Descriptor translation table format for address translation. + Some Mediatek SOCs contain a Multimedia Memory Management Unit (M4U), and +this M4U have two generations of HW architecture. Generation one uses flat +pagetable, and only supports 4K size page mapping. Generation two uses the +ARM Short-Descriptor translation table format for address translation. About the M4U Hardware Block Diagram, please check below:
@@ -36,7 +38,9 @@ in each larb. Take a example, There are many ports like MC, PP, VLD in the video decode local arbiter, all these ports are according to the video HW. Required properties: -- compatible : must be "mediatek,mt8173-m4u". +- compatible : must be one of the following string: + "mediatek,mt2701-m4u" for mt2701 which uses generation one m4u HW. + "mediatek,mt8173-m4u" for mt8173 which uses generation two m4u HW. - reg : m4u register base and size. - interrupts : the interrupt of m4u. - clocks : must contain one entry for each clock-names.
@@ -46,7 +50,8 @@ Required properties: according to the local arbiter index, like larb0, larb1, larb2... - iommu-cells : must be 1. This is the mtk_m4u_id according to the HW. Specifies the mtk_m4u_id as defined in - dt-binding/memory/mt8173-larb-port.h. + dt-binding/memory/mt2701-larb-port.h for mt2701 and + dt-binding/memory/mt8173-larb-port.h for mt8173 Example: iommu: iommu at 10205000 {
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-common.txt +18 -3
@@ -2,16 +2,31 @@ SMI (Smart Multimedia Interface) Common The hardware block diagram please check bindings/iommu/mediatek,iommu.txt +Mediatek SMI have two generations of HW architecture, mt8173 uses the second +generation of SMI HW while mt2701 uses the first generation HW of SMI. + +There's slight differences between the two SMI, for generation 2, the +register which control the iommu port is at each larb's register base. But +for generation 1, the register is at smi ao base(smi always on register +base). Besides that, the smi async clock should be prepared and enabled for +SMI generation 1 to transform the smi clock into emi clock domain, but that is +not needed for SMI generation 2. + Required properties: -- compatible : must be "mediatek,mt8173-smi-common" +- compatible : must be one of : + "mediatek,mt2701-smi-common" + "mediatek,mt8173-smi-common" - reg : the register and size of the SMI block. - power-domains : a phandle to the power domain of this local arbiter. - clocks : Must contain an entry for each entry in clock-names. -- clock-names : must contain 2 entries, as follows: +- clock-names : must contain 3 entries for generation 1 smi HW and 2 entries + for generation 2 smi HW as follows: - "apb" : Advanced Peripheral Bus clock, It's the clock for setting the register. - "smi" : It's the clock for transfer data and command. - They may be the same if both source clocks are the same. + They may be the same if both source clocks are the same. + - "async" : asynchronous clock, it help transform the smi clock into the emi + clock domain, this clock is only needed by generation 1 smi HW. Example: smi_common: smi at 14022000 {
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.txt +3 -1
@@ -3,7 +3,9 @@ SMI (Smart Multimedia Interface) Local Arbiter The hardware block diagram please check bindings/iommu/mediatek,iommu.txt Required properties: -- compatible : must be "mediatek,mt8173-smi-larb" +- compatible : must be one of : + "mediatek,mt8173-smi-larb" + "mediatek,mt2701-smi-larb" - reg : the register and size of this local arbiter. - mediatek,smi : a phandle to the smi_common node. - power-domains : a phandle to the power domain of this local arbiter.
include/dt-bindings/memory/mt2701-larb-port.h new file +85 -0
85 lines not on this page · raw message
Signature · 1 line
1.8.1.1.dirty
PATCH v3 2/5 iommu/mediatek: move the common struct into header file
In reply to [email protected]From: Honghui Zhang <[email protected]>
Move the struct defines of mtk iommu into a new header files for common use.
--- drivers/iommu/mtk_iommu.c | 48 +---------------------------- drivers/iommu/mtk_iommu.h | 77 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 47 deletions(-) create mode 100644 drivers/iommu/mtk_iommu.h
drivers/iommu/mtk_iommu.c +1 -47
@@ -34,7 +34,7 @@#include <dt-bindings/memory/mt8173-larb-port.h> #include <soc/mediatek/smi.h> -#include "io-pgtable.h" +#include "mtk_iommu.h" #define REG_MMU_PT_BASE_ADDR 0x000
@@ -93,20 +93,6 @@#define MTK_PROTECT_PA_ALIGN 128 -struct mtk_iommu_suspend_reg { -u32 standard_axi_mode; -u32 dcm_dis; -u32 ctrl_reg; -u32 int_control0; -u32 int_main_control; -}; - -struct mtk_iommu_client_priv { -struct list_head client; -unsigned int mtk_m4u_id; -struct device *m4udev; -}; -struct mtk_iommu_domain {spinlock_t pgtlock;/* lock for page table */
@@ -116,19 +102,6 @@ struct mtk_iommu_domain {struct iommu_domain domain; }; -struct mtk_iommu_data { -void __iomem *base; -int irq; -struct device *dev; -struct clk *bclk; -phys_addr_t protect_base;/* protect memory base */ -struct mtk_iommu_suspend_reg reg; -struct mtk_iommu_domain *m4u_dom; -struct iommu_group *m4u_group; -struct mtk_smi_iommu smi_imu;/* SMI larb iommu info */ -bool enable_4GB; -}; -static struct iommu_ops mtk_iommu_ops;static struct mtk_iommu_domain *to_mtk_domain (struct iommu_domain *dom)
@@ -552,25 +525,6 @@ static int mtk_iommu_hw_init(const struct mtk_iommu_data *data)return 0 ; } -static int compare_of (struct device *dev,void *data) -{ -return dev->of_node == data; -} - -static int mtk_iommu_bind (struct device *dev) -{ -struct mtk_iommu_data *data =dev_get_drvdata (dev); - -return component_bind_all (dev, &data->smi_imu); -} - -static void mtk_iommu_unbind (struct device *dev) -{ -struct mtk_iommu_data *data =dev_get_drvdata (dev); - -component_unbind_all (dev, &data->smi_imu); -} -static const struct component_master_ops mtk_iommu_com_ops = { .bind = mtk_iommu_bind, .unbind = mtk_iommu_unbind,
drivers/iommu/mtk_iommu.h new file +77 -0
77 lines not on this page · raw message
Signature · 1 line
1.8.1.1.dirty
PATCH v3 3/5 memory/mediatek: add support for mt2701
In reply to [email protected]From: Honghui Zhang <[email protected]>
Mediatek SMI has two generations of HW architecture, mt8173 uses the second generation of SMI HW while mt2701 uses the first generation HW of SMI.
There's slight differences between the two generations, for generation 2, the register which control the iommu port access PA or IOVA is at each larb's register base. But for generation 1, the register is at smi ao base(smi always on register base).
Besides that, the smi async clock should be prepared and enabled for SMI generation 1 HW to transform the smi clock into emi clock domain, but is not needed for SMI generation 2.
This patch add SMI driver for mt2701 which use generation 1 SMI HW.
--- drivers/memory/mtk-smi.c | 168 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 149 insertions(+), 19 deletions(-)
drivers/memory/mtk-smi.c +149 -19
@@ -21,19 +21,50 @@#include <linux/platform_device.h> #include <linux/pm_runtime.h> #include <soc/mediatek/smi.h> +#include <dt-bindings/memory/mt2701-larb-port.h> #define SMI_LARB_MMU_EN 0xf00 +#define REG_SMI_SECUR_CON_BASE 0x5c0 + +/* every register control 8 port, register offset 0x4 */ +#define REG_SMI_SECUR_CON_OFFSET (id) (((id) >> 3) << 2) +#define REG_SMI_SECUR_CON_ADDR (id) \ + (REG_SMI_SECUR_CON_BASE + REG_SMI_SECUR_CON_OFFSET(id)) + +/* +* every port have 4 bit to control, bit[port + 3] control virtual or physical, +* bit[port + 2 : port + 1] control the domain, bit[port] control the security +* or non-security. +*/ +#define SMI_SECUR_CON_VAL_MSK (id) (~(0xf << (((id) & 0x7) << 2))) +#define SMI_SECUR_CON_VAL_VIRT (id) BIT((((id) & 0x7) << 2) + 3) +/* mt2701 domain should be set to 3 */ +#define SMI_SECUR_CON_VAL_DOMAIN (id) (0x3 << ((((id) & 0x7) << 2) + 1)) + +struct mtk_smi_larb_gen { +int port_in_larb[MTK_LARB_NR_MAX +1 ]; +void (*config_port)(struct device *); +};struct mtk_smi { -struct device *dev; -struct clk *clk_apb, *clk_smi; +struct device *dev; +struct clk *clk_apb, *clk_smi; +struct clk *clk_async;/*only needed by mt2701*/ +void __iomem *smi_ao_base; };struct mtk_smi_larb {/* larb: local arbiter */ -struct mtk_smi smi; -void __iomem *base; -struct device *smi_common_dev; -u32 *mmu; +struct mtk_smi smi; +void __iomem *base; +struct device *smi_common_dev; +const struct mtk_smi_larb_gen *larb_gen; +int larbid; +u32 *mmu; +}; + +enum mtk_smi_gen { +MTK_SMI_GEN1 , +MTK_SMI_GEN2 };static int mtk_smi_enable (const struct mtk_smi *smi)
@@ -71,6 +102,7 @@ static void mtk_smi_disable(const struct mtk_smi *smi)int mtk_smi_larb_get (struct device *larbdev) {struct mtk_smi_larb *larb =dev_get_drvdata (larbdev); +const struct mtk_smi_larb_gen *larb_gen = larb->larb_gen;struct mtk_smi *common =dev_get_drvdata (larb->smi_common_dev);int ret;
@@ -87,8 +119,7 @@ int mtk_smi_larb_get(struct device *larbdev) }/* Configure the iommu info for this larb */ -writel (*larb->mmu, larb->base +SMI_LARB_MMU_EN ); - + larb_gen->config_port (larbdev);return 0 ; }
@@ -124,6 +155,45 @@ mtk_smi_larb_bind(struct device *dev, struct device *master, void *data)return -ENODEV ; } +static void mtk_smi_larb_config_port (struct device *dev) +{ +struct mtk_smi_larb *larb =dev_get_drvdata (dev); + +writel (*larb->mmu, larb->base +SMI_LARB_MMU_EN ); +} + + +static void mtk_smi_larb_config_port_gen1 (struct device *dev) +{ +struct mtk_smi_larb *larb =dev_get_drvdata (dev); +const struct mtk_smi_larb_gen *larb_gen = larb->larb_gen; +struct mtk_smi *common =dev_get_drvdata (larb->smi_common_dev); +int i, m4u_port_id, larb_port_num; +u32 sec_con_val, reg_val; + + m4u_port_id = larb_gen->port_in_larb[larb->larbid]; + larb_port_num = larb_gen->port_in_larb[larb->larbid +1 ] + - larb_gen->port_in_larb[larb->larbid]; + +for (i =0 ; i < larb_port_num; i++, m4u_port_id++) { +if (*larb->mmu &BIT (i)) { +/* bit[port + 3] controls the virtual or physical */ + sec_con_val =SMI_SECUR_CON_VAL_VIRT (m4u_port_id); + }else { +/* do not need to enable m4u for this port */ +continue ; + } + reg_val =readl (common->smi_ao_base + +REG_SMI_SECUR_CON_ADDR (m4u_port_id)); + reg_val &=SMI_SECUR_CON_VAL_MSK (m4u_port_id); + reg_val |= sec_con_val; + reg_val |=SMI_SECUR_CON_VAL_DOMAIN (m4u_port_id); +writel (reg_val, + common->smi_ao_base + +REG_SMI_SECUR_CON_ADDR (m4u_port_id)); + } +} +static void mtk_smi_larb_unbind (struct device *dev,struct device *master,void *data) {
@@ -135,6 +205,31 @@ static const struct component_ops mtk_smi_larb_component_ops = { .unbind = mtk_smi_larb_unbind, }; +static const struct mtk_smi_larb_gen mtk_smi_larb_mt8173 = { +/* mt8173 do not need the port in larb */ + .config_port = mtk_smi_larb_config_port, +}; + +static const struct mtk_smi_larb_gen mtk_smi_larb_mt2701 = { + .port_in_larb = { +LARB0_PORT_OFFSET ,LARB1_PORT_OFFSET , +LARB2_PORT_OFFSET ,LARB3_PORT_OFFSET + }, + .config_port = mtk_smi_larb_config_port_gen1, +}; + +static const struct of_device_id mtk_smi_larb_of_ids[] = { + { + .compatible ="mediatek,mt8173-smi-larb" , + .data = &mtk_smi_larb_mt8173 + }, + { + .compatible ="mediatek,mt2701-smi-larb" , + .data = &mtk_smi_larb_mt2701 + }, + {} +}; +static int mtk_smi_larb_probe (struct platform_device *pdev) {struct mtk_smi_larb *larb;
@@ -142,14 +237,20 @@ static int mtk_smi_larb_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct device_node *smi_node;struct platform_device *smi_pdev; +const struct of_device_id *of_id;if (!dev->pm_domain)return -EPROBE_DEFER ; + of_id =of_match_node (mtk_smi_larb_of_ids, pdev->dev.of_node); +if (!of_id) +return -EINVAL ; + larb =devm_kzalloc (dev,sizeof (*larb),GFP_KERNEL );if (!larb)return -ENOMEM ; + larb->larb_gen = of_id->data; res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); larb->base =devm_ioremap_resource (dev, res);if (IS_ERR (larb->base))
@@ -189,24 +290,34 @@ static int mtk_smi_larb_remove(struct platform_device *pdev)return 0 ; } -static const struct of_device_id mtk_smi_larb_of_ids[] = { - { .compatible ="mediatek,mt8173-smi-larb" ,}, - {} -}; -static struct platform_driver mtk_smi_larb_driver = { .probe = mtk_smi_larb_probe, - .remove = mtk_smi_larb_remove, + .remove = mtk_smi_larb_remove, .driver = { .name ="mtk-smi-larb" , .of_match_table = mtk_smi_larb_of_ids, } }; +static const struct of_device_id mtk_smi_common_of_ids[] = { + { + .compatible ="mediatek,mt8173-smi-common" , + .data = (void *)MTK_SMI_GEN2 + }, + { + .compatible ="mediatek,mt2701-smi-common" , + .data = (void *)MTK_SMI_GEN1 + }, + {} +}; +static int mtk_smi_common_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;struct mtk_smi *common; +struct resource *res; +const struct of_device_id *of_id; +enum mtk_smi_gen smi_gen;if (!dev->pm_domain)return -EPROBE_DEFER ;
@@ -224,6 +335,29 @@ static int mtk_smi_common_probe(struct platform_device *pdev)if (IS_ERR (common->clk_smi))return PTR_ERR (common->clk_smi); + of_id =of_match_node (mtk_smi_common_of_ids, pdev->dev.of_node); +if (!of_id) +return -EINVAL ; + +/* +* for mtk smi gen 1, we need to get the ao(always on) base to config +* m4u port, and we need to enable the aync clock for transform the smi +* clock into emi clock domain, but for mtk smi gen2, there's no smi ao +* base. +*/ + smi_gen = (enum mtk_smi_gen )of_id->data; +if (smi_gen ==MTK_SMI_GEN1 ) { + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + common->smi_ao_base =devm_ioremap_resource (dev, res); +if (IS_ERR (common->smi_ao_base)) +return PTR_ERR (common->smi_ao_base); + + common->clk_async =devm_clk_get (dev,"async" ); +if (IS_ERR (common->clk_async)) +return PTR_ERR (common->clk_async); + +clk_prepare_enable (common->clk_async); + }pm_runtime_enable (dev);platform_set_drvdata (pdev, common);return 0 ;
@@ -235,11 +369,6 @@ static int mtk_smi_common_remove(struct platform_device *pdev)return 0 ; } -static const struct of_device_id mtk_smi_common_of_ids[] = { - { .compatible ="mediatek,mt8173-smi-common" , }, - {} -}; -static struct platform_driver mtk_smi_common_driver = { .probe = mtk_smi_common_probe, .remove = mtk_smi_common_remove,
@@ -270,4 +399,5 @@ err_unreg_smi:platform_driver_unregister (&mtk_smi_common_driver);return ret; } +subsys_initcall (mtk_smi_init);
Signature · 1 line
1.8.1.1.dirty
PATCH v3 4/5 iommu/mediatek: add support for mtk iommu generation one HW
In reply to [email protected]From: Honghui Zhang <[email protected]>
Mediatek SoC's M4U has two generations of HW architcture. Generation one uses flat, one layer pagetable, and was shipped with ARM architecture, it only supports 4K size page mapping. MT2701 SoC uses this generation one m4u HW. Generation two uses the ARM short-descriptor translation table format for address translation, and was shipped with ARM64 architecture, MT8173 uses this generation two m4u HW. All the two generation iommu HW only have one iommu domain, and all its iommu clients share the same iova address.
These two generation m4u HW have slit different register groups and register offset, but most register names are the same. This patch add iommu support for mediatek SoC mt2701.
--- drivers/iommu/Kconfig | 18 ++ drivers/iommu/Makefile | 1 + drivers/iommu/mtk_iommu_v1.c | 728 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 747 insertions(+) create mode 100644 drivers/iommu/mtk_iommu_v1.c
drivers/iommu/Kconfig +18 -0
@@ -354,4 +354,22 @@ config MTK_IOMMU If unsure, say N here. +config MTK_IOMMU_V1 + bool "MTK IOMMU Version 1 (M4U gen1) Support" + depends on ARM + depends on ARCH_MEDIATEK || COMPILE_TEST + select ARM_DMA_USE_IOMMU + select IOMMU_API + select MEMORY + select MTK_SMI + select COMMON_CLK_MT2701_MMSYS + select COMMON_CLK_MT2701_IMGSYS + select COMMON_CLK_MT2701_VDECSYS + help + Support for the M4U on certain Mediatek SoCs. M4U generation 1 HW is + Multimedia Memory Managememt Unit. This option enables remapping of + DMA memory accesses for the multimedia subsystem. + + if unsure, say N here. + endif # IOMMU_SUPPORT
drivers/iommu/Makefile +1 -0
@@ -18,6 +18,7 @@ obj-$(CONFIG_INTEL_IOMMU_SVM) += intel-svm.o obj-$(CONFIG_IPMMU_VMSA) += ipmmu-vmsa.o obj-$(CONFIG_IRQ_REMAP) += intel_irq_remapping.o irq_remapping.o obj-$(CONFIG_MTK_IOMMU) += mtk_iommu.o +obj-$(CONFIG_MTK_IOMMU_V1) += mtk_iommu_v1.o obj-$(CONFIG_OMAP_IOMMU) += omap-iommu.o obj-$(CONFIG_OMAP_IOMMU_DEBUG) += omap-iommu-debug.o obj-$(CONFIG_ROCKCHIP_IOMMU) += rockchip-iommu.o
drivers/iommu/mtk_iommu_v1.c new file +728 -0
728 lines not on this page · raw message
Signature · 1 line
1.8.1.1.dirty
PATCH v3 5/5 ARM: dts: mt2701: add iommu/smi dtsi node for mt2701
In reply to [email protected]From: Honghui Zhang <[email protected]>
Add the dtsi node of iommu and smi for mt2701.
--- arch/arm/boot/dts/mt2701.dtsi | 51 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)
arch/arm/boot/dts/mt2701.dtsi +51 -0
@@ -16,6 +16,7 @@ #include <dt-bindings/power/mt2701-power.h> #include <dt-bindings/interrupt-controller/irq.h> #include <dt-bindings/interrupt-controller/arm-gic.h> +#include <dt-bindings/memory/mt2701-larb-port.h> #include "skeleton64.dtsi" #include "mt2701-pinfunc.h"
@@ -160,6 +161,16 @@ clock-names = "system-clk", "rtc-clk"; }; + smi_common: smi at 1000c000 { + compatible = "mediatek,mt2701-smi-common"; + reg = <0 0x1000c000 0 0x1000>; + clocks = <&infracfg CLK_INFRA_SMI>, + <&mmsys CLK_MM_SMI_COMMON>, + <&infracfg CLK_INFRA_SMI>; + clock-names = "apb", "smi", "async"; + power-domains = <&scpsys MT2701_POWER_DOMAIN_DISP>; + }; + sysirq: interrupt-controller at 10200100 { compatible = "mediatek,mt2701-sysirq", "mediatek,mt6577-sysirq";
@@ -169,6 +180,16 @@ reg = <0 0x10200100 0 0x1c>; }; + iommu: mmsys_iommu at 10205000 { + compatible = "mediatek,mt2701-m4u"; + reg = <0 0x10205000 0 0x1000>; + interrupts = <GIC_SPI 106 IRQ_TYPE_LEVEL_LOW>; + clocks = <&infracfg CLK_INFRA_M4U>; + clock-names = "bclk"; + mediatek,larbs = <&larb0 &larb1 &larb2>; + #iommu-cells = <1>; + }; + apmixedsys: syscon at 10209000 { compatible = "mediatek,mt2701-apmixedsys", "syscon"; reg = <0 0x10209000 0 0x1000>;
@@ -234,6 +255,16 @@ status = "disabled"; }; + larb0: larb at 14010000 { + compatible = "mediatek,mt2701-smi-larb"; + reg = <0 0x14010000 0 0x1000>; + mediatek,smi = <&smi_common>; + clocks = <&mmsys CLK_MM_SMI_LARB0>, + <&mmsys CLK_MM_SMI_LARB0>; + clock-names = "apb", "smi"; + power-domains = <&scpsys MT2701_POWER_DOMAIN_DISP>; + }; + imgsys: syscon at 15000000 { compatible = "mediatek,mt2701-imgsys", "syscon"; reg = <0 0x15000000 0 0x1000>;
@@ -241,6 +272,16 @@ status = "disabled"; }; + larb2: larb at 15001000 { + compatible = "mediatek,mt2701-smi-larb"; + reg = <0 0x15001000 0 0x1000>; + mediatek,smi = <&smi_common>; + clocks = <&imgsys CLK_IMG_SMI_COMM>, + <&imgsys CLK_IMG_SMI_COMM>; + clock-names = "apb", "smi"; + power-domains = <&scpsys MT2701_POWER_DOMAIN_ISP>; + }; + vdecsys: syscon at 16000000 { compatible = "mediatek,mt2701-vdecsys", "syscon"; reg = <0 0x16000000 0 0x1000>;
@@ -248,6 +289,16 @@ status = "disabled"; }; + larb1: larb at 16010000 { + compatible = "mediatek,mt2701-smi-larb"; + reg = <0 0x16010000 0 0x1000>; + mediatek,smi = <&smi_common>; + clocks = <&vdecsys CLK_VDEC_CKGEN>, + <&vdecsys CLK_VDEC_LARB>; + clock-names = "apb", "smi"; + power-domains = <&scpsys MT2701_POWER_DOMAIN_VDEC>; + }; + hifsys: syscon at 1a000000 { compatible = "mediatek,mt2701-hifsys", "syscon"; reg = <0 0x1a000000 0 0x1000>;
Signature · 1 line
1.8.1.1.dirty
Quoted 2 lines · honghui.zhang at mediatek.com
From: Honghui Zhang <[email protected]>
Is there will be some comments for this version patchset? Any comments is welcome.
Thanks.
Quoted 70 lines
Mediatek's m4u(Multimedia Memory Management Unit) and SMI(Smart
Multimedia Interface)have two generations HW. They basically sharing the same hardware block diagram, but have some difference as below:Generation one m4u only supports one layer, flat pagetable addressing,
and only supports 4K size page mapping. While generation two m4u supports 2 levels of pagetable which uses the ARM short-descriptor translation table format for address translation.
They have slight different register base and register offset. They have very different HW ports defines.Generaion one SMI has additional "async" clock which transform the smi
clock into emi clock domain, this clock should be prepared and enabled for SMI generation one HW.
The register which control the iommu need to translation the address or not for a particular port is located at smi ao base(smi always on register base) for generation one SMI HW, but located at each larb's register base for generation two HW.This patch set add mt2701 iommu support, it's based on 4.6-rc1 and James Liao's "Add clock support for Mediatek MT2701 v8[1]" and "Mediatek MT2701 SCPSYS power domain support v7[2]" patch.
v3:
(quoted diff) +0
-5-Rebase on "of: Implement iterator for phandles[3]" and take use of of_for_each_phandle. -Forward-declare mtk_iommu_domain and implement the struct separately. -Free the pagetable memory in mtk_iommu_domain_free -Roll back the mapping in error case. -Minor cleanups.v2: https://lists.linuxfoundation.org/pipermail/iommu/2016-May/017068.html
(quoted diff) +0
-5-Fix syntax errors in dt-bindings. -Use dma_alloc/free_coherent to allocate pagetable memory and reduce the streaming DMA stuff. -Make the mtk_iommu_ops.pgsize_bitmap as ~0UL << MT2701_IOMMU_PAGE_SHIFT. -Use macro instead of variable to indicate the pagetable size. -Change some macro name from MTK_XXX to MT2701_XXX.v1: http://lists.infradead.org/pipermail/linux-mediatek/2016-May/005301.html
-initial version[1] http://lists.infradead.org/pipermail/linux-mediatek/2016-May/005439.html
[2] http://lists.infradead.org/pipermail/linux-mediatek/2016-May/005429.html
[3] https://lists.linuxfoundation.org/pipermail/iommu/2016-April/016300.htmlHonghui Zhang (5):
dt-bindings: mediatek: add descriptions for mediatek mt2701 iommu and
smi
iommu/mediatek: move the common struct into header file memory/mediatek: add support for mt2701
iommu/mediatek: add support for mtk iommu generation one HW
ARM: dts: mt2701: add iommu/smi dtsi node for mt2701.../devicetree/bindings/iommu/mediatek,iommu.txt | 13 +- .../memory-controllers/mediatek,smi-common.txt | 21 +- .../memory-controllers/mediatek,smi-larb.txt | 4 +- arch/arm/boot/dts/mt2701.dtsi | 51 ++ drivers/iommu/Kconfig | 18 + drivers/iommu/Makefile | 1 + drivers/iommu/mtk_iommu.c | 48 +- drivers/iommu/mtk_iommu.h | 77 +++ drivers/iommu/mtk_iommu_v1.c | 728 +++++++++++++++++++++ drivers/memory/mtk-smi.c | 168 ++++- include/dt-bindings/memory/mt2701-larb-port.h | 85 +++ 11 files changed, 1140 insertions(+), 74 deletions(-) create mode 100644 drivers/iommu/mtk_iommu.h create mode 100644 drivers/iommu/mtk_iommu_v1.c create mode 100644 include/dt-bindings/memory/mt2701-larb-port.h