From patchwork Fri Mar 7 12:16:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: R Sricharan X-Patchwork-Id: 3790491 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 281A2BF540 for ; Fri, 7 Mar 2014 12:20:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 504F6201BA for ; Fri, 7 Mar 2014 12:20:27 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 57938201B4 for ; Fri, 7 Mar 2014 12:20:26 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WLtjU-0004gv-V4; Fri, 07 Mar 2014 12:18:33 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WLtj8-000759-DK; Fri, 07 Mar 2014 12:18:10 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WLtiZ-000717-MF for linux-arm-kernel@merlin.infradead.org; Fri, 07 Mar 2014 12:17:35 +0000 Received: from arroyo.ext.ti.com ([192.94.94.40]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WLtiX-00048o-9b for linux-arm-kernel@lists.infradead.org; Fri, 07 Mar 2014 12:17:34 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id s27CH5LM004354; Fri, 7 Mar 2014 06:17:05 -0600 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s27CH5MF018082; Fri, 7 Mar 2014 06:17:05 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.174.1; Fri, 7 Mar 2014 06:17:05 -0600 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s27CGhw1003967; Fri, 7 Mar 2014 06:17:01 -0600 From: Sricharan R To: , , , , , Subject: [RFC PATCH 4/9] drivers: omap-dma: Add crossbar line as a resource to omap_chan structure Date: Fri, 7 Mar 2014 17:46:11 +0530 Message-ID: <1394194576-23741-5-git-send-email-r.sricharan@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1394194576-23741-1-git-send-email-r.sricharan@ti.com> References: <1394194576-23741-1-git-send-email-r.sricharan@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140307_121733_552082_61068C0B X-CRM114-Status: GOOD ( 15.09 ) X-Spam-Score: -6.9 (------) Cc: nm@ti.com, linux@arm.linux.org.uk, tony@atomide.com, rnayak@ti.com, nsekhar@ti.com, vinod.koul@intel.com, santosh.shilimkar@ti.com, dan.j.williams@intel.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In socs which have crossbar to route the peripheral dma request line to the dma controller, only the peripheral crossbar request line number is fixed and this is passed through the DT nodes. The dma request channel to be used is allocated dynamically. The total number of crossbar channels are registered during probe a the dma request line free is mapped using the registered router's map function during the device_alloc_chan_resource callback and freed with free_resource. When a router is not registered, the dma request number is same as the crossbar number. Signed-off-by: Sricharan R --- drivers/dma/omap-dma.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c index 38407f9..05ac480 100644 --- a/drivers/dma/omap-dma.c +++ b/drivers/dma/omap-dma.c @@ -47,6 +47,7 @@ struct omap_chan { struct dma_xbar_device *router; unsigned dma_sig; + unsigned dma_xbar; bool cyclic; bool paused; @@ -530,6 +531,11 @@ static int omap_dma_alloc_chan_resources(struct dma_chan *chan) struct omap_chan *c = to_omap_dma_chan(chan); int ret; + if (c->router) + c->dma_sig = c->router->ops->map(c->dma_xbar, c->router); + else + c->dma_sig = c->dma_xbar; + if (od->legacy) { ret = omap_request_dma(c->dma_sig, "DMA engine", omap_dma_callback, c, &c->dma_ch); @@ -539,7 +545,7 @@ static int omap_dma_alloc_chan_resources(struct dma_chan *chan) } dev_dbg(od->ddev.dev, "allocating channel %u for %u\n", - c->dma_ch, c->dma_sig); + c->dma_ch, c->dma_xbar); if (ret >= 0) { omap_dma_assign(od, c, c->dma_ch); @@ -594,9 +600,14 @@ static void omap_dma_free_chan_resources(struct dma_chan *chan) od->lch_map[c->dma_ch] = NULL; vchan_free_chan_resources(&c->vc); + if (c->router) { + c->router->ops->unmap(c->dma_sig, c->router); + c->dma_sig = 0; + } + omap_free_dma(c->dma_ch); - dev_dbg(od->ddev.dev, "freeing channel for %u\n", c->dma_sig); + dev_dbg(od->ddev.dev, "freeing channel for %u\n", c->dma_xbar); } static size_t omap_dma_sg_size(struct omap_sg *sg) @@ -1064,7 +1075,7 @@ static int omap_dma_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd, return ret; } -static int omap_dma_chan_init(struct omap_dmadev *od, int dma_sig) +static int omap_dma_chan_init(struct omap_dmadev *od, int dma_xbar) { struct omap_chan *c; @@ -1073,7 +1084,7 @@ static int omap_dma_chan_init(struct omap_dmadev *od, int dma_sig) return -ENOMEM; c->reg_map = od->reg_map; - c->dma_sig = dma_sig; + c->dma_xbar = dma_xbar; c->vc.desc_free = omap_dma_desc_free; vchan_init(&c->vc, &od->ddev); INIT_LIST_HEAD(&c->node); @@ -1263,7 +1274,7 @@ bool omap_dma_filter_fn(struct dma_chan *chan, void *param) struct omap_chan *c = to_omap_dma_chan(chan); unsigned req = args->chan; - if (req == c->dma_sig) { + if (req == c->dma_xbar) { c->router = args->router_data; return true; }