Commit 09f65413 authored by Sudhakar Rajashekhara's avatar Sudhakar Rajashekhara Committed by Kevin Hilman

ARM: DaVinci: 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, modify the MMC and ASoC drivers to reflect the above changes.
Signed-off-by: default avatarSudhakar Rajashekhara <sudhakar.raj@ti.com>
Reviewed-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarKevin Hilman <khilman@deeprootsystems.com>
parent 0cdc79a2
...@@ -82,10 +82,10 @@ static struct resource mmcsd0_resources[] = { ...@@ -82,10 +82,10 @@ static struct resource mmcsd0_resources[] = {
}, },
/* DMA channels: RX, then TX */ /* DMA channels: RX, then TX */
{ {
.start = DAVINCI_DMA_MMCRXEVT, .start = EDMA_CTLR_CHAN(0, DAVINCI_DMA_MMCRXEVT),
.flags = IORESOURCE_DMA, .flags = IORESOURCE_DMA,
}, { }, {
.start = DAVINCI_DMA_MMCTXEVT, .start = EDMA_CTLR_CHAN(0, DAVINCI_DMA_MMCTXEVT),
.flags = IORESOURCE_DMA, .flags = IORESOURCE_DMA,
}, },
}; };
...@@ -119,10 +119,10 @@ static struct resource mmcsd1_resources[] = { ...@@ -119,10 +119,10 @@ static struct resource mmcsd1_resources[] = {
}, },
/* DMA channels: RX, then TX */ /* DMA channels: RX, then TX */
{ {
.start = 30, /* rx */ .start = EDMA_CTLR_CHAN(0, 30), /* rx */
.flags = IORESOURCE_DMA, .flags = IORESOURCE_DMA,
}, { }, {
.start = 31, /* tx */ .start = EDMA_CTLR_CHAN(0, 31), /* tx */
.flags = IORESOURCE_DMA, .flags = IORESOURCE_DMA,
}, },
}; };
......
...@@ -573,28 +573,33 @@ EXPORT_SYMBOL(edma_free_channel); ...@@ -573,28 +573,33 @@ EXPORT_SYMBOL(edma_free_channel);
* *
* Returns the number of the slot, else negative errno. * Returns the number of the slot, else negative errno.
*/ */
int edma_alloc_slot(int slot) int edma_alloc_slot(unsigned ctlr, int slot)
{ {
if (slot >= 0)
slot = EDMA_CHAN(slot);
if (slot < 0) { if (slot < 0) {
slot = num_channels; slot = edma_info[ctlr]->num_channels;
for (;;) { for (;;) {
slot = find_next_zero_bit(edma_inuse, slot = find_next_zero_bit(edma_info[ctlr]->edma_inuse,
num_slots, slot); edma_info[ctlr]->num_slots, slot);
if (slot == num_slots) if (slot == edma_info[ctlr]->num_slots)
return -ENOMEM; return -ENOMEM;
if (!test_and_set_bit(slot, edma_inuse)) if (!test_and_set_bit(slot,
edma_info[ctlr]->edma_inuse))
break; break;
} }
} else if (slot < num_channels || slot >= num_slots) { } else if (slot < edma_info[ctlr]->num_channels ||
slot >= edma_info[ctlr]->num_slots) {
return -EINVAL; return -EINVAL;
} else if (test_and_set_bit(slot, edma_inuse)) { } else if (test_and_set_bit(slot, edma_info[ctlr]->edma_inuse)) {
return -EBUSY; return -EBUSY;
} }
memcpy_toio(edmacc_regs_base + PARM_OFFSET(slot), memcpy_toio(edmacc_regs_base[ctlr] + PARM_OFFSET(slot),
&dummy_paramset, PARM_SIZE); &dummy_paramset, PARM_SIZE);
return slot; return EDMA_CTLR_CHAN(ctlr, slot);
} }
EXPORT_SYMBOL(edma_alloc_slot); EXPORT_SYMBOL(edma_alloc_slot);
......
...@@ -170,6 +170,10 @@ enum sync_dimension { ...@@ -170,6 +170,10 @@ enum sync_dimension {
ABSYNC = 1 ABSYNC = 1
}; };
#define EDMA_CTLR_CHAN(ctlr, chan) (((ctlr) << 16) | (chan))
#define EDMA_CTLR(i) ((i) >> 16)
#define EDMA_CHAN_SLOT(i) ((i) & 0xffff)
#define EDMA_CHANNEL_ANY -1 /* for edma_alloc_channel() */ #define EDMA_CHANNEL_ANY -1 /* for edma_alloc_channel() */
#define EDMA_SLOT_ANY -1 /* for edma_alloc_slot() */ #define EDMA_SLOT_ANY -1 /* for edma_alloc_slot() */
...@@ -180,7 +184,7 @@ int edma_alloc_channel(int channel, ...@@ -180,7 +184,7 @@ int edma_alloc_channel(int channel,
void edma_free_channel(unsigned channel); void edma_free_channel(unsigned channel);
/* alloc/free parameter RAM slots */ /* alloc/free parameter RAM slots */
int edma_alloc_slot(int slot); int edma_alloc_slot(unsigned ctlr, int slot);
void edma_free_slot(unsigned slot); void edma_free_slot(unsigned slot);
/* calls that operate on part of a parameter RAM slot */ /* calls that operate on part of a parameter RAM slot */
......
...@@ -177,7 +177,7 @@ struct mmc_davinci_host { ...@@ -177,7 +177,7 @@ struct mmc_davinci_host {
u32 buffer_bytes_left; u32 buffer_bytes_left;
u32 bytes_left; u32 bytes_left;
u8 rxdma, txdma; u32 rxdma, txdma;
bool use_dma; bool use_dma;
bool do_dma; bool do_dma;
...@@ -189,7 +189,7 @@ struct mmc_davinci_host { ...@@ -189,7 +189,7 @@ struct mmc_davinci_host {
struct edmacc_param tx_template; struct edmacc_param tx_template;
struct edmacc_param rx_template; struct edmacc_param rx_template;
unsigned n_link; unsigned n_link;
u8 links[NR_SG - 1]; u32 links[NR_SG - 1];
/* For PIO we walk scatterlists one segment at a time. */ /* For PIO we walk scatterlists one segment at a time. */
unsigned int sg_len; unsigned int sg_len;
...@@ -465,7 +465,7 @@ static void __init mmc_davinci_dma_setup(struct mmc_davinci_host *host, ...@@ -465,7 +465,7 @@ static void __init mmc_davinci_dma_setup(struct mmc_davinci_host *host,
edma_read_slot(sync_dev, template); edma_read_slot(sync_dev, template);
/* don't bother with irqs or chaining */ /* don't bother with irqs or chaining */
template->opt |= sync_dev << 12; template->opt |= EDMA_CHAN_SLOT(sync_dev) << 12;
} }
static void mmc_davinci_send_dma_request(struct mmc_davinci_host *host, static void mmc_davinci_send_dma_request(struct mmc_davinci_host *host,
...@@ -499,7 +499,7 @@ static void mmc_davinci_send_dma_request(struct mmc_davinci_host *host, ...@@ -499,7 +499,7 @@ static void mmc_davinci_send_dma_request(struct mmc_davinci_host *host,
unsigned count = sg_dma_len(sg); unsigned count = sg_dma_len(sg);
template->link_bcntrld = sg_len template->link_bcntrld = sg_len
? (host->links[link] << 5) ? (EDMA_CHAN_SLOT(host->links[link]) << 5)
: 0xffff; : 0xffff;
if (count > bytes_left) if (count > bytes_left)
...@@ -593,7 +593,7 @@ static int __init davinci_acquire_dma_channels(struct mmc_davinci_host *host) ...@@ -593,7 +593,7 @@ static int __init davinci_acquire_dma_channels(struct mmc_davinci_host *host)
* channel as needed to handle a scatterlist. * channel as needed to handle a scatterlist.
*/ */
for (i = 0; i < ARRAY_SIZE(host->links); i++) { for (i = 0; i < ARRAY_SIZE(host->links); i++) {
r = edma_alloc_slot(EDMA_SLOT_ANY); r = edma_alloc_slot(EDMA_CTLR(host->txdma), EDMA_SLOT_ANY);
if (r < 0) { if (r < 0) {
dev_dbg(mmc_dev(host->mmc), "dma PaRAM alloc --> %d\n", dev_dbg(mmc_dev(host->mmc), "dma PaRAM alloc --> %d\n",
r); r);
......
...@@ -175,8 +175,8 @@ static struct resource evm_snd_resources[] = { ...@@ -175,8 +175,8 @@ static struct resource evm_snd_resources[] = {
}; };
static struct evm_snd_platform_data evm_snd_data = { static struct evm_snd_platform_data evm_snd_data = {
.tx_dma_ch = DAVINCI_DMA_ASP0_TX, .tx_dma_ch = EDMA_CTLR_CHAN(0, DAVINCI_DMA_ASP0_TX),
.rx_dma_ch = DAVINCI_DMA_ASP0_RX, .rx_dma_ch = EDMA_CTLR_CHAN(0, DAVINCI_DMA_ASP0_RX),
}; };
/* DM335 EVM uses ASP1; line-out is a stereo mini-jack */ /* DM335 EVM uses ASP1; line-out is a stereo mini-jack */
...@@ -189,8 +189,8 @@ static struct resource dm335evm_snd_resources[] = { ...@@ -189,8 +189,8 @@ static struct resource dm335evm_snd_resources[] = {
}; };
static struct evm_snd_platform_data dm335evm_snd_data = { static struct evm_snd_platform_data dm335evm_snd_data = {
.tx_dma_ch = DAVINCI_DMA_ASP1_TX, .tx_dma_ch = EDMA_CTLR_CHAN(0, DAVINCI_DMA_ASP1_TX),
.rx_dma_ch = DAVINCI_DMA_ASP1_RX, .rx_dma_ch = EDMA_CTLR_CHAN(0, DAVINCI_DMA_ASP1_RX),
}; };
static struct platform_device *evm_snd_device; static struct platform_device *evm_snd_device;
......
...@@ -143,7 +143,7 @@ static int davinci_pcm_dma_request(struct snd_pcm_substream *substream) ...@@ -143,7 +143,7 @@ static int davinci_pcm_dma_request(struct snd_pcm_substream *substream)
prtd->master_lch = ret; prtd->master_lch = ret;
/* Request parameter RAM reload slot */ /* Request parameter RAM reload slot */
ret = edma_alloc_slot(EDMA_SLOT_ANY); ret = edma_alloc_slot(EDMA_CTLR(prtd->master_lch), EDMA_SLOT_ANY);
if (ret < 0) { if (ret < 0) {
edma_free_channel(prtd->master_lch); edma_free_channel(prtd->master_lch);
return ret; return ret;
...@@ -160,8 +160,8 @@ static int davinci_pcm_dma_request(struct snd_pcm_substream *substream) ...@@ -160,8 +160,8 @@ static int davinci_pcm_dma_request(struct snd_pcm_substream *substream)
* so davinci_pcm_enqueue_dma() takes less time in IRQ. * so davinci_pcm_enqueue_dma() takes less time in IRQ.
*/ */
edma_read_slot(prtd->slave_lch, &p_ram); edma_read_slot(prtd->slave_lch, &p_ram);
p_ram.opt |= TCINTEN | EDMA_TCC(prtd->master_lch); p_ram.opt |= TCINTEN | EDMA_TCC(EDMA_CHAN_SLOT(prtd->master_lch));
p_ram.link_bcntrld = prtd->slave_lch << 5; p_ram.link_bcntrld = EDMA_CHAN_SLOT(prtd->slave_lch) << 5;
edma_write_slot(prtd->slave_lch, &p_ram); edma_write_slot(prtd->slave_lch, &p_ram);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment