From patchwork Sat Sep 12 16:20:44 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: s-paulraj@ti.com X-Patchwork-Id: 47088 Received: from arroyo.ext.ti.com (arroyo.ext.ti.com [192.94.94.40]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8CGMeol006013 for ; Sat, 12 Sep 2009 16:22:41 GMT Received: from dlep35.itg.ti.com ([157.170.170.118]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id n8CGKnCX005579; Sat, 12 Sep 2009 11:20:49 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep35.itg.ti.com (8.13.7/8.13.7) with ESMTP id n8CGKmdF013271; Sat, 12 Sep 2009 11:20:48 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id D55BC80627; Sat, 12 Sep 2009 11:20:47 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dlep36.itg.ti.com (dlep36.itg.ti.com [157.170.170.91]) by linux.omap.com (Postfix) with ESMTP id 160E180626 for ; Sat, 12 Sep 2009 11:20:46 -0500 (CDT) Received: from legion.dal.design.ti.com (localhost [127.0.0.1]) by dlep36.itg.ti.com (8.13.8/8.13.8) with ESMTP id n8CGKjYb027102; Sat, 12 Sep 2009 11:20:45 -0500 (CDT) Received: from gt5d9d821.telogy.design.ti.com (gt5d9d821.telogy.design.ti.com [158.218.100.23]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id n8CGKjZ28448; Sat, 12 Sep 2009 11:20:45 -0500 (CDT) Received: from gt5d9d821.telogy.design.ti.com (localhost.localdomain [127.0.0.1]) by gt5d9d821.telogy.design.ti.com (8.13.1/8.13.1) with ESMTP id n8CGKj29025775; Sat, 12 Sep 2009 12:20:45 -0400 Received: (from a0866907@localhost) by gt5d9d821.telogy.design.ti.com (8.13.1/8.13.1/Submit) id n8CGKiF1025772; Sat, 12 Sep 2009 12:20:44 -0400 From: s-paulraj@ti.com To: davinci-linux-open-source@linux.davincidsp.com Date: Sat, 12 Sep 2009 12:20:44 -0400 Message-Id: <1252772444-25749-1-git-send-email-s-paulraj@ti.com> X-Mailer: git-send-email 1.6.0.4 Cc: Subject: [PATCH] DaVinci: EDMA: New API edma_free_resource X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.4 Precedence: list List-Id: davinci-linux-open-source.linux.davincidsp.com List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: davinci-linux-open-source-bounces@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com From: Sandeep Paulraj This API is very similar to the edma_free_slot and edma_free_channel APIs. It is actually a consolidated version of these 2 APIs. A resource can be a channel or a slot. Using this API, the EDMA driver code makes the determination to free up a channel or a slot. The user does not have to decide the correct "free" API from among edma_free_channel or edma_free_slot. This API will be used by TI codecs and the DVSDK. Signed-off-by: Sandeep Paulraj --- arch/arm/mach-davinci/dma.c | 32 +++++++++++++++++++++++++++++ arch/arm/mach-davinci/include/mach/edma.h | 3 ++ 2 files changed, 35 insertions(+), 0 deletions(-) diff --git a/arch/arm/mach-davinci/dma.c b/arch/arm/mach-davinci/dma.c index bfce4b5..97bfa6c 100644 --- a/arch/arm/mach-davinci/dma.c +++ b/arch/arm/mach-davinci/dma.c @@ -740,6 +740,38 @@ void edma_free_slot(unsigned slot) } EXPORT_SYMBOL(edma_free_slot); +/** + * edma_free_resource - deallocate DMA parameter RAM channel/resource + * @resource: Either a channel or a slot to be freed + * + * This deallocates the DMA channel and associated parameter RAM slot + * if the resource happens to be a channel, i.e if the resource number is + * less than 64 for DaVinci SOCs and less than 32 for Primus. + * Otherwise deallocate the parameter RAM slot. + * Callers are responsible for ensuring the slot is inactive, and will + * not be activated. + */ +void edma_free_resource(unsigned resource) +{ + unsigned ctlr; + + ctlr = EDMA_CTLR(resource); + resource = EDMA_CHAN_SLOT(resource); + + /* + * The resource cannot be greater than the number of slots + */ + if (resource >= edma_info[ctlr]->num_slots) + return; + + if (resource < edma_info[ctlr]->num_channels) + setup_dma_interrupt(resource, NULL, NULL); + + memcpy_toio(edmacc_regs_base[ctlr] + PARM_OFFSET(resource), + &dummy_paramset, PARM_SIZE); + clear_bit(resource, edma_info[ctlr]->edma_inuse); +} +EXPORT_SYMBOL(edma_free_resource); /** * edma_alloc_cont_slots- alloc contiguous parameter RAM slots diff --git a/arch/arm/mach-davinci/include/mach/edma.h b/arch/arm/mach-davinci/include/mach/edma.h index eb8bfd7..19d8e48 100644 --- a/arch/arm/mach-davinci/include/mach/edma.h +++ b/arch/arm/mach-davinci/include/mach/edma.h @@ -240,6 +240,9 @@ void edma_free_channel(unsigned channel); int edma_alloc_slot(unsigned ctlr, int slot); void edma_free_slot(unsigned slot); +/* free either a channel or slot */ +void edma_free_resource(unsigned resource); + /* alloc/free a set of contiguous parameter RAM slots */ int edma_alloc_cont_slots(unsigned ctlr, unsigned int id, int slot, int count); int edma_free_cont_slots(unsigned slot, int count);