Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932514AbeAKIYt (ORCPT + 1 other); Thu, 11 Jan 2018 03:24:49 -0500 Received: from regular1.263xmail.com ([211.150.99.130]:52326 "EHLO regular1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932167AbeAKIYq (ORCPT ); Thu, 11 Jan 2018 03:24:46 -0500 X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-RL-SENDER: jeffy.chen@rock-chips.com X-FST-TO: linux-kernel@vger.kernel.org X-SENDER-IP: 103.29.142.67 X-LOGIN-NAME: jeffy.chen@rock-chips.com X-UNIQUE-TAG: X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 From: Jeffy Chen To: linux-kernel@vger.kernel.org Cc: jcliang@chromium.org, robin.murphy@arm.com, tfiga@chromium.org, Jeffy Chen , Heiko Stuebner , linux-rockchip@lists.infradead.org, iommu@lists.linux-foundation.org, Joerg Roedel , linux-arm-kernel@lists.infradead.org Subject: [PATCH 9/9] iommu/rockchip: Use OF_IOMMU to attach devices automatically Date: Thu, 11 Jan 2018 16:22:29 +0800 Message-Id: <20180111082229.24011-10-jeffy.chen@rock-chips.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180111082229.24011-1-jeffy.chen@rock-chips.com> References: <20180111082229.24011-1-jeffy.chen@rock-chips.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: Converts the rockchip-iommu driver to use the OF_IOMMU infrastructure, which allows attaching master devices to their IOMMUs automatically according to DT properties. Signed-off-by: Jeffy Chen --- drivers/iommu/rockchip-iommu.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index ab18a80fdd12..c375a2522bfd 100644 --- a/drivers/iommu/rockchip-iommu.c +++ b/drivers/iommu/rockchip-iommu.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -1091,6 +1092,13 @@ static struct iommu_group *rk_iommu_device_group(struct device *dev) return ERR_PTR(ret); } +static int rk_iommu_of_xlate(struct device *dev, + struct of_phandle_args *spec) +{ + /* We don't have any phandle args, so just return 0. */ + return 0; +} + static const struct iommu_ops rk_iommu_ops = { .domain_alloc = rk_iommu_domain_alloc, .domain_free = rk_iommu_domain_free, @@ -1104,6 +1112,7 @@ static const struct iommu_ops rk_iommu_ops = { .iova_to_phys = rk_iommu_iova_to_phys, .device_group = rk_iommu_device_group, .pgsize_bitmap = RK_IOMMU_PGSIZE_BITMAP, + .of_xlate = rk_iommu_of_xlate, }; static int rk_iommu_probe(struct platform_device *pdev) @@ -1166,6 +1175,8 @@ static int rk_iommu_probe(struct platform_device *pdev) return err; iommu_device_set_ops(&iommu->iommu, &rk_iommu_ops); + iommu_device_set_fwnode(&iommu->iommu, &dev->of_node->fwnode); + err = iommu_device_register(&iommu->iommu); if (err) { iommu_device_sysfs_remove(&iommu->iommu); @@ -1241,6 +1252,8 @@ static void __exit rk_iommu_exit(void) subsys_initcall(rk_iommu_init); module_exit(rk_iommu_exit); +IOMMU_OF_DECLARE(rk_iommu_of, "rockchip,iommu"); + MODULE_DESCRIPTION("IOMMU API for Rockchip"); MODULE_AUTHOR("Simon Xue and Daniel Kurtz "); MODULE_ALIAS("platform:rockchip-iommu"); -- 2.11.0