[PATCH 02/26] davinci: EDMA: restructure to support multiple channel controllers

2009-07-06 Thread Kevin Hilman
From: Sudhakar Rajashekhara 

Define a structure to store EDMA channel controller based information.
Use platform_device.id to find out the instance being configured in
probe function.

Signed-off-by: Sudhakar Rajashekhara 
Reviewed-by: David Brownell 
Signed-off-by: Kevin Hilman 
---
 arch/arm/mach-davinci/dm355.c |5 +-
 arch/arm/mach-davinci/dm644x.c|5 +-
 arch/arm/mach-davinci/dma.c   |  100 +++--
 arch/arm/mach-davinci/include/mach/edma.h |1 +
 4 files changed, 73 insertions(+), 38 deletions(-)

diff --git a/arch/arm/mach-davinci/dm355.c b/arch/arm/mach-davinci/dm355.c
index baaaf32..beda643 100644
--- a/arch/arm/mach-davinci/dm355.c
+++ b/arch/arm/mach-davinci/dm355.c
@@ -563,12 +563,13 @@ static struct edma_soc_info dm355_edma_info = {
.n_region   = 4,
.n_slot = 128,
.n_tc   = 2,
+   .n_cc   = 1,
.noevent= dma_chan_dm355_no_event,
 };
 
 static struct resource edma_resources[] = {
{
-   .name   = "edma_cc",
+   .name   = "edma_cc0",
.start  = 0x01c0,
.end= 0x01c0 + SZ_64K - 1,
.flags  = IORESOURCE_MEM,
@@ -598,7 +599,7 @@ static struct resource edma_resources[] = {
 
 static struct platform_device dm355_edma_device = {
.name   = "edma",
-   .id = -1,
+   .id = 0,
.dev.platform_data  = &dm355_edma_info,
.num_resources  = ARRAY_SIZE(edma_resources),
.resource   = edma_resources,
diff --git a/arch/arm/mach-davinci/dm644x.c b/arch/arm/mach-davinci/dm644x.c
index fb5449b..ddc1d4f 100644
--- a/arch/arm/mach-davinci/dm644x.c
+++ b/arch/arm/mach-davinci/dm644x.c
@@ -489,12 +489,13 @@ static struct edma_soc_info dm644x_edma_info = {
.n_region   = 4,
.n_slot = 128,
.n_tc   = 2,
+   .n_cc   = 1,
.noevent= dma_chan_dm644x_no_event,
 };
 
 static struct resource edma_resources[] = {
{
-   .name   = "edma_cc",
+   .name   = "edma_cc0",
.start  = 0x01c0,
.end= 0x01c0 + SZ_64K - 1,
.flags  = IORESOURCE_MEM,
@@ -524,7 +525,7 @@ static struct resource edma_resources[] = {
 
 static struct platform_device dm644x_edma_device = {
.name   = "edma",
-   .id = -1,
+   .id = 0,
.dev.platform_data  = &dm644x_edma_info,
.num_resources  = ARRAY_SIZE(edma_resources),
.resource   = edma_resources,
diff --git a/arch/arm/mach-davinci/dma.c b/arch/arm/mach-davinci/dma.c
index 15e9eb1..9afd55f 100644
--- a/arch/arm/mach-davinci/dma.c
+++ b/arch/arm/mach-davinci/dma.c
@@ -107,11 +107,12 @@
 #define EDMA_MAX_DMACH   64
 #define EDMA_MAX_PARAMENTRY 512
 #define EDMA_MAX_EVQUE2/* FIXME too small */
+#define EDMA_MAX_CC   2
 
 
 /*/
 
-static void __iomem *edmacc_regs_base;
+static void __iomem *edmacc_regs_base[EDMA_MAX_CC];
 
 static inline unsigned int edma_read(int offset)
 {
@@ -207,25 +208,39 @@ static inline void edma_parm_or(int offset, int param_no, 
unsigned or)
 /*/
 
 /* actual number of DMA channels and slots on this silicon */
-static unsigned num_channels;
-static unsigned num_slots;
+struct edma {
+   /* how many dma resources of each type */
+   unsignednum_channels;
+   unsignednum_region;
+   unsignednum_slots;
+   unsignednum_tc;
+   unsignednum_cc;
+
+   /* list of channels with no even trigger; terminated by "-1" */
+   const s8*noevent;
+
+   /* The edma_inuse bit for each PaRAM slot is clear unless the
+* channel is in use ... by ARM or DSP, for QDMA, or whatever.
+*/
+   DECLARE_BITMAP(edma_inuse, EDMA_MAX_PARAMENTRY);
 
-static struct dma_interrupt_data {
-   void (*callback)(unsigned channel, unsigned short ch_status,
-void *data);
-   void *data;
-} intr_data[EDMA_MAX_DMACH];
+   /* The edma_noevent bit for each channel is clear unless
+* it doesn't trigger DMA events on this platform.  It uses a
+* bit of SOC-specific initialization code.
+*/
+   DECLARE_BITMAP(edma_noevent, EDMA_MAX_DMACH);
 
-/* The edma_inuse bit for each PaRAM slot is clear unless the
- * channel is in use ... by ARM or DSP, for QDMA, or whatever.
- */
-static DECLARE_BITMAP(edma_inuse, EDMA_MAX_PARAMENTRY);
+   unsignedirq_res_start;
+   unsignedirq_res_end;
 
-/* The edma_noevent bit for each channel is clear unless
- * it doesn't tr

Re: [PATCH 02/26] davinci: EDMA: restructure to support multiple channel controllers

2009-07-07 Thread Kevin Hilman
Russell King - ARM Linux  writes:

> On Mon, Jul 06, 2009 at 02:14:36PM -0700, Kevin Hilman wrote:
>> From: Sudhakar Rajashekhara 
>> 
>> Define a structure to store EDMA channel controller based information.
>> Use platform_device.id to find out the instance being configured in
>> probe function.
>
> Why all this complexity?  Resources are specific to each platform
> device, so just provide the _specific_ resources for each platform
> device.

Agreed.  I've asked Sudhakar to take a look at this and rework.

Thanks for the review.

Kevin

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


Re: [PATCH 02/26] davinci: EDMA: restructure to support multiple channel controllers

2009-07-09 Thread Kevin Hilman
Kevin Hilman  writes:

> Russell King - ARM Linux  writes:
>
>> On Mon, Jul 06, 2009 at 02:14:36PM -0700, Kevin Hilman wrote:
>>> From: Sudhakar Rajashekhara 
>>> 
>>> Define a structure to store EDMA channel controller based information.
>>> Use platform_device.id to find out the instance being configured in
>>> probe function.
>>
>> Why all this complexity?  Resources are specific to each platform
>> device, so just provide the _specific_ resources for each platform
>> device.
>
> Agreed.  I've asked Sudhakar to take a look at this and rework.
>

OK, Sudhakar reworked this and I've integrated the change into DaVinci
git.  However, reworking this also touched several of the other
EDMA patches in this series in a way that was not easy to merge.

Therefore, since each of the commits was relatively small, I just
combined the main EDMA restructuring into a single commit that
includes this new rework and I combined the changelogs into an updated
summary. The EDMA support for the newer SoCs (dm646x, dm365 and da8xx)
was kept as separate commits.

Below is the new patch, which is also the 2nd commit in the updated
davinci-next branch:

  git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-davinci.git 
davinci-next

Kevin



>From 98d7d6380f68ea674bfebaeb796db70f130213fb Mon Sep 17 00:00:00 2001
From: Sudhakar Rajashekhara 
Date: Thu, 21 May 2009 07:41:35 -0400
Subject: [PATCH 02/25] davinci: EDMA: multiple CCs, channel mapping and API 
changes

- restructure to support multiple channel controllers by using
  additional struct resources for each CC

- interface changes visible to EDMA clients

  Introduce macros to build IDs from controller and channel number,
  and to extract them. Modify the edma_alloc_slot function to take an
  extra argument for the controller.

  Also update ASoC drivers to use API.  ASoC changes
  Acked-by: Mark Brown 

- Move queue related mappings to dm.c

  EDMA in DM355 and DM644x has two transfer controllers while DM646x
  has four transfer controllers. Moving the queue to tc mapping and
  queue priority mapping to dm.c will be helpful to probe these
  mappings from platform device so that the machine_is_* testing will
  be avoided.

- add channel mapping logic

  Channel mapping logic is introduced in dm646x EDMA. This implies
  that there is no fixed association for a channel number to a
  parameter entry number. In other words, using the DMA channel
  mapping registers (DCHMAPn), a PaRAM entry can be mapped to any
  channel. While in the case of dm644x and dm355 there is a fixed
  mapping between the EDMA channel and Param entry number.

Signed-off-by: Naresh Medisetty 
Signed-off-by: Sudhakar Rajashekhara 
Reviewed-by: David Brownell 
Signed-off-by: Kevin Hilman 
---
 arch/arm/mach-davinci/devices.c   |8 +-
 arch/arm/mach-davinci/dm355.c |   41 ++-
 arch/arm/mach-davinci/dm644x.c|   41 ++-
 arch/arm/mach-davinci/dm646x.c|   46 ++-
 arch/arm/mach-davinci/dma.c   |  811 +++--
 arch/arm/mach-davinci/include/mach/edma.h |9 +-
 sound/soc/davinci/davinci-evm.c   |8 +-
 sound/soc/davinci/davinci-pcm.c   |6 +-
 8 files changed, 642 insertions(+), 328 deletions(-)

diff --git a/arch/arm/mach-davinci/devices.c b/arch/arm/mach-davinci/devices.c
index de16f34..7a2f8ae 100644
--- a/arch/arm/mach-davinci/devices.c
+++ b/arch/arm/mach-davinci/devices.c
@@ -82,10 +82,10 @@ static struct resource mmcsd0_resources[] = {
},
/* DMA channels: RX, then TX */
{
-   .start = DAVINCI_DMA_MMCRXEVT,
+   .start = EDMA_CTLR_CHAN(0, DAVINCI_DMA_MMCRXEVT),
.flags = IORESOURCE_DMA,
}, {
-   .start = DAVINCI_DMA_MMCTXEVT,
+   .start = EDMA_CTLR_CHAN(0, DAVINCI_DMA_MMCTXEVT),
.flags = IORESOURCE_DMA,
},
 };
@@ -119,10 +119,10 @@ static struct resource mmcsd1_resources[] = {
},
/* DMA channels: RX, then TX */
{
-   .start = 30,/* rx */
+   .start = EDMA_CTLR_CHAN(0, 30), /* rx */
.flags = IORESOURCE_DMA,
}, {
-   .start = 31,/* tx */
+   .start = EDMA_CTLR_CHAN(0, 31), /* tx */
.flags = IORESOURCE_DMA,
},
 };
diff --git a/arch/arm/mach-davinci/dm355.c b/arch/arm/mach-davinci/dm355.c
index baaaf32..373f0c4 100644
--- a/arch/arm/mach-davinci/dm355.c
+++ b/arch/arm/mach-davinci/dm355.c
@@ -558,17 +558,38 @@ static const s8 dma_chan_dm355_no_event[] = {
-1
 };
 
-static struct edma_soc_info dm355_edma_info = {
-   .n_channel  = 64,
-   .n_region   = 4,
-   .n_slot = 128,
-   .n_tc   = 2,
-   .noevent= dma_chan_dm355_no_event,
+static const s8
+queue_tc_mapping[][2] = {
+   /* {event queue no, TC no} */
+   {0, 0},
+   {1, 1},
+   {-1, -1},
+};
+
+static const s8
+queue_priority_mappin