From: Sandeep Paulraj <[email protected]>

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 <[email protected]>
---
 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);
-- 
1.6.0.4

_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to