Add iommu support for hi6220 HiKey board
Subsystems (3)
cover Add iommu support for hi6220 HiKey board
The patch sets add iommu support for Hi6220 SoC. Current testing and support board is Hikey which is one of 96boards.
It is an arm64 open source board. For more information about this board, please access https://www.96boards.org.
The Architecture of SMMU on Hi6220 SoC:
+------------------------------------------------------------------+
| |
| +---------+ +--------+ +-------------+ +-------+ |
| | ADE | | ISP | | V/J codec | | G3D | |
| +----|----+ +---|----+ +------|------+ +---|---| |
| | | | | |
| ---------v-----------v--------------v--------------v----- |
| Media Bus |
| --------------------------------|---------------|-------- |
| | | |
| +---v---------------v--------+ |
| | SMMU | |
| +----------|---------|-------+ |
| | | |
+--------------------------------------------|---------|-----------+
| |
+------------v---------v-----------+
| DDRC |
+----------------------------------+Note:
The media system share the same smmu IP to access DDR memory. And all media IP use the same page table. The hi6220 iommu driver also uses the iova api to manage an iova allocator to ensure that the caller get different iova address.
The caller can use the follow sample code to map phy and iova address.
eg:
struct iommu_domain *domain = iommu_domain_alloc(bus); iommu_attach_device(domain, dev);
struct iova_domain *iovad = (struct iova_domain *)m_dev->archdata.iommu; struct iova * t_iova = alloc_iova(iovad, size, limit_pfn, align); iommu_map(domain, t_iova->pfn_lo << 12, phy_addr, size, port);
The patch sets are based on 4.4-RC1
Chen Feng (3):
docs: iommu: Documentation for iommu in hi6220 SoC iommu/hisilicon: Add hi6220-SoC smmu driver
arm64: dts: Add dts node for hi6220 smmu driver
.../bindings/iommu/hisi,hi6220-iommu.txt | 32 ++ arch/arm64/boot/dts/hisilicon/hi6220.dtsi | 13 + drivers/iommu/Kconfig | 11 + drivers/iommu/Makefile | 1 + drivers/iommu/hi6220_iommu.c | 492 +++++++++++++++++++++ 5 files changed, 549 insertions(+) create mode 100644 Documentation/devicetree/bindings/iommu/hisi,hi6220-iommu.txt create mode 100644 drivers/iommu/hi6220_iommu.c
Signature · 1 line
1.9.1
PATCH 1/3 docs: iommu: Documentation for iommu in hi6220 SoC
Documentation for hi6220 iommu driver.
--- .../bindings/iommu/hisi,hi6220-iommu.txt | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Documentation/devicetree/bindings/iommu/hisi,hi6220-iommu.txt
Documentation/devicetree/bindings/iommu/hisi,hi6220-iommu.txt new file +32 -0
@@ -0,0 +1,32 @@ +Hi6220 SoC SMMU Device Driver devicetree document +The media system shared the same smmu IP to access DDR memory. And all +media IP used the same page table. + +Below binding describes the system mmu for media system in hi6220 platform + +Required properties: +- compatible: should contain "hisilicon,hi6220-smmu". +- reg: A tuple of base address and size of System MMU registers. +- clocks: a list of phandle + clock-specifier pairs, one for each entry + in clock-names. +- clock-names: should contain: + * "smmu" + * "media-sc" + * "smmu-peri" +- interrupts: An interrupt specifier for interrupt signal of System MMU. +- #iommu-cells: The iommu-cells should be 0. Because no additional information + needs to be encoded in the specifier. + +Examples: + iommu@f4210000 { + compatible = "hisilicon,hi6220-smmu"; + reg = <0x0 0xf4210000 0x0 0x1000>; + interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&sys_ctrl HI6220_MMU_CLK>, + <&media_ctrl HI6220_MED_MMU>, + <&sys_ctrl HI6220_MEDIA_PLL_SRC>; + clock-names = "smmu", + "media-sc", + "smmu-peri"; + #iommu-cells = <0>; + };
Signature · 1 line
1.9.1
Re: [PATCH 1/3] docs: iommu: Documentation for iommu in hi6220 SoC
Quoted 1 line · Chen Feng
Documentation for hi6220 iommu driver.
Please use get_maintainers.pl and re-send to correct lists ([email protected]).
Quoted 48 lines
Signed-off-by Chen Feng <[email protected]>--- .../bindings/iommu/hisi,hi6220-iommu.txt | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Documentation/devicetree/bindings/iommu/hisi,hi6220-iommu.txtDocumentation/devicetree/bindings/iommu/hisi,hi6220-iommu.txt new file +32
-1@@ -0,0 +1,32 @@ +Hi6220 SoC SMMU Device Driver devicetree document +The media system shared the same smmu IP to access DDR memory. And all +media IP used the same page table. + +Below binding describes the system mmu for media system in hi6220 platform + +Required properties: +- compatible: should contain "hisilicon,hi6220-smmu". +- reg: A tuple of base address and size of System MMU registers. +- clocks: a list of phandle + clock-specifier pairs, one for each entry + in clock-names. +- clock-names: should contain: + * "smmu" + * "media-sc" + * "smmu-peri" +- interrupts: An interrupt specifier for interrupt signal of System MMU. +- #iommu-cells: The iommu-cells should be 0. Because no additional information + needs to be encoded in the specifier. + +Examples: + iommu@f4210000 { + compatible = "hisilicon,hi6220-smmu"; + reg = <0x0 0xf4210000 0x0 0x1000>; + interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&sys_ctrl HI6220_MMU_CLK>, + <&media_ctrl HI6220_MED_MMU>, + <&sys_ctrl HI6220_MEDIA_PLL_SRC>; + clock-names = "smmu", + "media-sc", + "smmu-peri"; + #iommu-cells = <0>; + }; --1.9.1
PATCH 2/3 iommu/hisilicon: Add hi6220-SoC smmu driver
In reply to Chen FengAdd iommu driver for hi6220 SoC platform.The smmu on hi6220 SoC is for media system.And the media IP use the same page-table. It supports only one-to-one mapping from iova to phys address.
--- drivers/iommu/Kconfig | 11 + drivers/iommu/Makefile | 1 + drivers/iommu/hi6220_iommu.c | 492 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 504 insertions(+) create mode 100644 drivers/iommu/hi6220_iommu.c
drivers/iommu/Kconfig +11 -0
@@ -84,6 +84,17 @@ config IOMMU_PGTABLES_L2 def_bool y depends on MSM_IOMMU && MMU && SMP && CPU_DCACHE_DISABLE=n +config HI6220_IOMMU + bool "Hi6220 IOMMU Support" + depends on ARM64 + select IOMMU_API + select IOMMU_IOVA + help + Enable IOMMU Driver for hi6220 SoC. The IOMMU API and IOMMU IOVA + is also selected. + + If unsure, say N. + # AMD IOMMU support config AMD_IOMMU bool "AMD IOMMU support"
drivers/iommu/Makefile +1 -0
@@ -12,6 +12,7 @@ obj-$(CONFIG_AMD_IOMMU_V2) += amd_iommu_v2.o obj-$(CONFIG_ARM_SMMU) += arm-smmu.o obj-$(CONFIG_ARM_SMMU_V3) += arm-smmu-v3.o obj-$(CONFIG_DMAR_TABLE) += dmar.o +obj-$(CONFIG_HI6220_IOMMU) += hi6220_iommu.o obj-$(CONFIG_INTEL_IOMMU) += intel-iommu.o obj-$(CONFIG_INTEL_IOMMU_SVM) += intel-svm.o obj-$(CONFIG_IPMMU_VMSA) += ipmmu-vmsa.o
drivers/iommu/hi6220_iommu.c new file +492 -0
492 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 3/3 arm64: dts: Add dts node for hi6220 smmu driver
In reply to Chen FengAdd iommu node for hi6220 SoC platform
--- arch/arm64/boot/dts/hisilicon/hi6220.dtsi | 13 +++++++++++++ 1 file changed, 13 insertions(+)
arch/arm64/boot/dts/hisilicon/hi6220.dtsi +13 -0
@@ -208,5 +208,18 @@ clock-names = "uartclk", "apb_pclk"; status = "disabled"; }; + + iommu: iommu@f4210000 { + compatible = "hisilicon,hi6220-smmu"; + reg = <0x0 0xf4210000 0x0 0x1000>; + interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&sys_ctrl HI6220_MMU_CLK>, + <&media_ctrl HI6220_MED_MMU>, + <&sys_ctrl HI6220_MEDIA_PLL_SRC>; + clock-names = "smmu", + "media-sc", + "smmu-peri"; + #iommu-cells = <0>; + }; }; };
Signature · 1 line
1.9.1