From patchwork Fri Oct 12 01:06:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Ramirez Luna X-Patchwork-Id: 1584751 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id E07CC40135 for ; Fri, 12 Oct 2012 01:11:07 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TMTkB-0001O1-Cz; Fri, 12 Oct 2012 01:08:51 +0000 Received: from mail-ob0-f177.google.com ([209.85.214.177]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TMTi9-0000O8-DC for linux-arm-kernel@lists.infradead.org; Fri, 12 Oct 2012 01:06:46 +0000 Received: by mail-ob0-f177.google.com with SMTP id wd20so2491619obb.36 for ; Thu, 11 Oct 2012 18:06:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=X7q2qjZlheZXZPcbDYY/PpJwKhR5So5AQEhjXkNogeY=; b=Oxdk5eOQHOF98suvwxKq/B3EhbBETLa0K9OI2yHDmfo30/96DfXJQGwrCEfWEhSWFj /I9K0NTOjmvUzzcC8UITDFvuJlUfxIGgiqriJaQLo/TmiXkXyW55cz+7GGQDXe8Cpqcc VKOogOzlGRDXlrTQ758lMLONHTULHJ8fFpA2jNe6Fs2pvRjwrH7xVKvu7vpHmvRrR3qz TGkS5KjBs1UtTlospDuE6EwsuJlp15ZNeKK+OWxyDlSdv3CW1SiBETNeak5fYaqM+eri tuaG/Ll/Xnx95iX3swLVsT69LkiaW6DAQlEBzERf6LaAgRq0hXLxhucyhnK/wFq3seOo vWAw== Received: by 10.60.7.226 with SMTP id m2mr2311573oea.72.1350004005154; Thu, 11 Oct 2012 18:06:45 -0700 (PDT) Received: from uda0273944.am.dhcp.ti.com (dragon.ti.com. [192.94.94.33]) by mx.google.com with ESMTPS id b7sm4291259oef.12.2012.10.11.18.06.44 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 11 Oct 2012 18:06:44 -0700 (PDT) From: Omar Ramirez Luna To: Tony Lindgren , Joerg Roedel Subject: [PATCH v3 5/6] ARM: OMAP: iommu: add device tree support Date: Thu, 11 Oct 2012 20:06:14 -0500 Message-Id: <1350003977-32744-10-git-send-email-omar.luna@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1350003977-32744-1-git-send-email-omar.luna@linaro.org> References: <1350003977-32744-1-git-send-email-omar.luna@linaro.org> X-Gm-Message-State: ALoCoQkJ/dvsHGPz3B7hMs5NOQ43AiAsoGkfIn5fW1OT+rJM4gXoz8J3GDs1++jzkZDVLr+gBm6Y X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.214.177 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Ohad Ben-Cohen , Paul Walmsley , Russell King , Benoit Cousson , linux-doc@vger.kernel.org, devicetree-discuss@lists.ozlabs.org, iommu@lists.linux-foundation.org, Laurent Pinchart , Omar Ramirez Luna , linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Adapt driver to use DT if provided. Signed-off-by: Omar Ramirez Luna --- .../devicetree/bindings/arm/omap/iommu.txt | 10 +++ arch/arm/mach-omap2/omap-iommu.c | 4 ++ drivers/iommu/omap-iommu.c | 65 +++++++++++++++++++- 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/arm/omap/iommu.txt diff --git a/Documentation/devicetree/bindings/arm/omap/iommu.txt b/Documentation/devicetree/bindings/arm/omap/iommu.txt new file mode 100644 index 0000000..2bb780f --- /dev/null +++ b/Documentation/devicetree/bindings/arm/omap/iommu.txt @@ -0,0 +1,10 @@ +* MMU (Memory Management Unit) + +MMU present in OMAP subsystems. + +Required properties: + compatible : should be "ti,omap3-iommu" for OMAP3 MMUs + compatible : should be "ti,omap4-iommu" for OMAP4 MMUs + +Optional properties: + None diff --git a/arch/arm/mach-omap2/omap-iommu.c b/arch/arm/mach-omap2/omap-iommu.c index 82a422a..4d6145d 100644 --- a/arch/arm/mach-omap2/omap-iommu.c +++ b/arch/arm/mach-omap2/omap-iommu.c @@ -11,6 +11,7 @@ */ #include +#include #include #include #include @@ -29,6 +30,9 @@ static int __init omap_iommu_dev_init(struct omap_hwmod *oh, void *unused) struct omap_mmu_dev_attr *a = (struct omap_mmu_dev_attr *)oh->dev_attr; static int i; + if (of_have_populated_dt()) + return 0; + pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); if (!pdata) return -ENOMEM; diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c index e266ad7..946366f 100644 --- a/drivers/iommu/omap-iommu.c +++ b/drivers/iommu/omap-iommu.c @@ -21,12 +21,15 @@ #include #include #include +#include #include #include #include +#include +#include #define for_each_iotlb_cr(obj, n, __i, cr) \ for (__i = 0; \ @@ -916,13 +919,63 @@ static void omap_iommu_detach(struct omap_iommu *obj) /* * OMAP Device MMU(IOMMU) detection */ +static int __devinit +iommu_add_platform_data_from_dt(struct platform_device *pdev) +{ + struct iommu_platform_data *pdata; + struct device_node *node = pdev->dev.of_node; + struct omap_hwmod *oh; + struct omap_mmu_dev_attr *a; + int ret = 0; + + pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return -ENOMEM; + + of_property_read_string(node, "ti,hwmods", &pdata->name); + oh = omap_hwmod_lookup(pdata->name); + if (!oh) { + dev_err(&pdev->dev, "Cannot lookup hwmod '%s'\n", pdata->name); + ret = -ENODEV; + goto out; + } + + a = (struct omap_mmu_dev_attr *)oh->dev_attr; + pdata->nr_tlb_entries = a->nr_tlb_entries; + pdata->da_start = a->da_start; + pdata->da_end = a->da_end; + + if (oh->rst_lines_cnt == 1) { + pdata->reset_name = oh->rst_lines->name; + pdata->assert_reset = omap_device_assert_hardreset; + pdata->deassert_reset = omap_device_deassert_hardreset; + } + + ret = platform_device_add_data(pdev, pdata, sizeof(*pdata)); + if (ret) + dev_err(&pdev->dev, "Cannot add pdata for %s\n", pdata->name); + +out: + kfree(pdata); + + return ret; +} + static int __devinit omap_iommu_probe(struct platform_device *pdev) { int err = -ENODEV; int irq; struct omap_iommu *obj; struct resource *res; - struct iommu_platform_data *pdata = pdev->dev.platform_data; + struct iommu_platform_data *pdata; + + if (of_have_populated_dt()) { + err = iommu_add_platform_data_from_dt(pdev); + if (err) + return err; + } + + pdata = pdev->dev.platform_data; obj = kzalloc(sizeof(*obj), GFP_KERNEL); if (!obj) @@ -1031,12 +1084,22 @@ static const struct dev_pm_ops iommu_pm_ops = { NULL) }; +#if defined(CONFIG_OF) +static const struct of_device_id omap_iommu_of_match[] = { + { .compatible = "ti,omap3-iommu" }, + { .compatible = "ti,omap4-iommu" }, + { }, +}; +MODULE_DEVICE_TABLE(of, omap_iommu_of_match); +#endif + static struct platform_driver omap_iommu_driver = { .probe = omap_iommu_probe, .remove = __devexit_p(omap_iommu_remove), .driver = { .name = "omap-iommu", .pm = &iommu_pm_ops, + .of_match_table = of_match_ptr(omap_iommu_of_match), }, };