From patchwork Wed Sep 12 19:45:51 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: 1446131 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id BD0FFDFFD0 for ; Wed, 12 Sep 2012 19:46:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752701Ab2ILTqW (ORCPT ); Wed, 12 Sep 2012 15:46:22 -0400 Received: from mail-oa0-f46.google.com ([209.85.219.46]:49809 "EHLO mail-oa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752410Ab2ILTqT (ORCPT ); Wed, 12 Sep 2012 15:46:19 -0400 Received: by mail-oa0-f46.google.com with SMTP id o6so1280291oag.19 for ; Wed, 12 Sep 2012 12:46:19 -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=+IfPt6Gvy8xXaEj+GLqVQW7fXav0+WDM3bBRSlfRRkw=; b=I7oEFKz5nDZ078cKolfRAnWtA16DrfOXsdvRRFW7PYlGx7HnQJPhSDwYR2slMD33uu zA/Ln9WLHi6KjHxFvGvenkdJtuHNWRV7briX9A5TdnQLfZztDS/0RZStLt4G2yRZSNB7 78CmSmUvNTdNgRwILbocO3fw1Wwm6SSrZPERRTmMVeixI5Lvsw2IT2zNuVQfmBhUsFZ6 /7iKKNrl6zA+jphIQj3PNYZUqlmAiW1qI31uwk8E8KkFcP2Grq83vz7zys8D20PEnkoV aqYfgfFMwP6jmrCjvv0n7B8ZMsHyQpha4YKGq7wCQvlae/gbgXC7yd+cEI/v49M8siIM 6VWA== Received: by 10.182.169.105 with SMTP id ad9mr23916570obc.90.1347479178901; Wed, 12 Sep 2012 12:46:18 -0700 (PDT) Received: from uda0273944.am.dhcp.ti.com (dragon.ti.com. [192.94.94.33]) by mx.google.com with ESMTPS id a6sm17041227oeh.1.2012.09.12.12.46.17 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 12 Sep 2012 12:46:18 -0700 (PDT) From: Omar Ramirez Luna To: Tony Lindgren , Benoit Cousson , Ohad Ben-Cohen , Joerg Roedel Cc: Russell King , Omar Ramirez Luna , Rajendra Nayak , Peter Ujfalusi , Laurent Pinchart , devicetree-discuss@lists.ozlabs.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org Subject: [PATCH v2 8/9] ARM: OMAP: iommu: add device tree support Date: Wed, 12 Sep 2012 14:45:51 -0500 Message-Id: <1347479152-588-9-git-send-email-omar.luna@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1347479152-588-1-git-send-email-omar.luna@linaro.org> References: <1347479152-588-1-git-send-email-omar.luna@linaro.org> X-Gm-Message-State: ALoCoQltXl3IVKj37Q9OYopLWUaGsgtuoeUwas8Zwh3L1cduCDNYYcjtA3JfJIDzaD3JyaRh/HZj Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.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 e8f88dc..4b7912b 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 @@ -27,6 +28,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 3f8eb04..fbfec44 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; \ @@ -909,13 +912,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) @@ -1024,12 +1077,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), }, };