From patchwork Wed Feb 6 21:03:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hunter, Jon" X-Patchwork-Id: 2107821 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 D0F05DF2A1 for ; Wed, 6 Feb 2013 21:03:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758644Ab3BFVD4 (ORCPT ); Wed, 6 Feb 2013 16:03:56 -0500 Received: from comal.ext.ti.com ([198.47.26.152]:54424 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757864Ab3BFVDz (ORCPT ); Wed, 6 Feb 2013 16:03:55 -0500 Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id r16L3UNU007443; Wed, 6 Feb 2013 15:03:30 -0600 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id r16L3UWF017111; Wed, 6 Feb 2013 15:03:30 -0600 Received: from dlelxv23.itg.ti.com (172.17.1.198) by dfle73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.1.323.3; Wed, 6 Feb 2013 15:03:30 -0600 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dlelxv23.itg.ti.com (8.13.8/8.13.8) with ESMTP id r16L3UNU019910; Wed, 6 Feb 2013 15:03:30 -0600 Received: from localhost (h112-111.vpn.ti.com [172.24.112.111]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id r16L3TV05505; Wed, 6 Feb 2013 15:03:29 -0600 (CST) From: Jon Hunter To: Rob Herring , Grant Likely , Tony Lindgren , Benoit Cousson , Vinod Koul , Russell King CC: device-tree , linux-omap , linux-arm , Santosh Shilimkar , Matt Porter , Felipe Balbi , Sourav Poddar , Balaji T K , Jon Hunter Subject: [PATCH 2/2] dmaengine: OMAP: Register SDMA controller with Device Tree DMA driver Date: Wed, 6 Feb 2013 15:03:16 -0600 Message-ID: <1360184596-1603-3-git-send-email-jon-hunter@ti.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1360184596-1603-1-git-send-email-jon-hunter@ti.com> References: <1360184596-1603-1-git-send-email-jon-hunter@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org If the device-tree blob is present during boot, then register the SDMA controller with the device-tree DMA driver so that we can use device-tree to look-up DMA client information. Signed-off-by: Jon Hunter --- drivers/dma/omap-dma.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c index 5a31264..a32d81b 100644 --- a/drivers/dma/omap-dma.c +++ b/drivers/dma/omap-dma.c @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include "virt-dma.h" @@ -67,6 +69,8 @@ static const unsigned es_bytes[] = { [OMAP_DMA_DATA_TYPE_S32] = 4, }; +static struct of_dma_filter_info info; + static inline struct omap_dmadev *to_omap_dma_dev(struct dma_device *d) { return container_of(d, struct omap_dmadev, ddev); @@ -621,10 +625,25 @@ static int omap_dma_probe(struct platform_device *pdev) pr_warn("OMAP-DMA: failed to register slave DMA engine device: %d\n", rc); omap_dma_free(od); + return rc; } else { platform_set_drvdata(pdev, od); } + if (pdev->dev.of_node) { + info.dma_cap = od->ddev.cap_mask; + info.filter_fn = omap_dma_filter_fn; + + /* Device-tree DMA controller registration */ + rc = of_dma_controller_register(pdev->dev.of_node, + of_dma_simple_xlate, &info); + if (rc) { + pr_warn("OMAP-DMA: failed to register DMA controller\n"); + dma_async_device_unregister(&od->ddev); + omap_dma_free(od); + } + } + dev_info(&pdev->dev, "OMAP DMA engine driver\n"); return rc; @@ -634,18 +653,28 @@ static int omap_dma_remove(struct platform_device *pdev) { struct omap_dmadev *od = platform_get_drvdata(pdev); + if (pdev->dev.of_node) + of_dma_controller_free(pdev->dev.of_node); + dma_async_device_unregister(&od->ddev); omap_dma_free(od); return 0; } +static const struct of_device_id omap_dma_match[] = { + { .compatible = "ti,omap-sdma", }, + {}, +}; +MODULE_DEVICE_TABLE(of, omap_dma_match); + static struct platform_driver omap_dma_driver = { .probe = omap_dma_probe, .remove = omap_dma_remove, .driver = { .name = "omap-dma-engine", .owner = THIS_MODULE, + .of_match_table = of_match_ptr(omap_dma_match) }, }; @@ -673,7 +702,7 @@ static int omap_dma_init(void) { int rc = platform_driver_register(&omap_dma_driver); - if (rc == 0) { + if ((rc == 0) && (!of_have_populated_dt())) { pdev = platform_device_register_full(&omap_dma_dev_info); if (IS_ERR(pdev)) { platform_driver_unregister(&omap_dma_driver);