Skip to contentSkip to conversation

Problems compiling Davinci ASoC driver in 2.6.26-rc6

DISCUSSION Felix Radensky 5 participants 6 messages Jun 20, 2008 – Jun 25, 2008

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

Hi,

I wanted to test Davinci ASoC driver on Davinci EVM evaluation board, but encountered the following compilation errors:

CC sound/soc/codecs/tlv320aic3x.o
sound/soc/codecs/tlv320aic3x.c:1012: warning: 'aic3x_init' defined but not used

  LD      sound/soc/codecs/snd-soc-tlv320aic3x.o
  LD      sound/soc/codecs/built-in.o
  CC      sound/soc/davinci/davinci-i2s.o

sound/soc/davinci/davinci-i2s.c:402: warning: initialization from incompatible pointer type
CC sound/soc/davinci/davinci-pcm.o
sound/soc/davinci/davinci-pcm.c: In function `davinci_pcm_enqueue_dma':
sound/soc/davinci/davinci-pcm.c:99: error: implicit declaration of function davinci_set_dma_src_params' sound/soc/davinci/davinci-pcm.c:99: error: INCR' undeclared (first use in this function)
sound/soc/davinci/davinci-pcm.c:99: error: (Each undeclared identifier is reported only once
sound/soc/davinci/davinci-pcm.c:99: error: for each function it appears in.) sound/soc/davinci/davinci-pcm.c:99: error: `W8BIT' undeclared (first use in this function)
sound/soc/davinci/davinci-pcm.c:100: error: implicit declaration of function davinci_set_dma_dest_params' sound/soc/davinci/davinci-pcm.c:101: error: implicit declaration of function davinci_set_dma_src_index' sound/soc/davinci/davinci-pcm.c:102: error: implicit declaration of function davinci_set_dma_dest_index' sound/soc/davinci/davinci-pcm.c:103: error: implicit declaration of function davinci_set_dma_transfer_params' sound/soc/davinci/davinci-pcm.c:103: error: `ASYNC' undeclared (first use in this function)
sound/soc/davinci/davinci-pcm.c: In function `davinci_pcm_dma_irq':
sound/soc/davinci/davinci-pcm.c:117: error: `DMA_COMPLETE' undeclared (first use in this function)
sound/soc/davinci/davinci-pcm.c: In function `davinci_pcm_dma_request':
sound/soc/davinci/davinci-pcm.c:134: error: `TCC_ANY' undeclared (first use in this function)
sound/soc/davinci/davinci-pcm.c:143: error: implicit declaration of function davinci_request_dma' sound/soc/davinci/davinci-pcm.c:145: error: EVENTQ_0' undeclared (first use in this function)
sound/soc/davinci/davinci-pcm.c:150: error: PARAM_ANY' undeclared (first use in this function) sound/soc/davinci/davinci-pcm.c:153: error: implicit declaration of function davinci_free_dma'
sound/soc/davinci/davinci-pcm.c:158: error: implicit declaration of function `davinci_dma_link_lch'
sound/soc/davinci/davinci-pcm.c: In function `davinci_pcm_trigger':
sound/soc/davinci/davinci-pcm.c:174: error: implicit declaration of function davinci_start_dma' sound/soc/davinci/davinci-pcm.c:179: error: implicit declaration of function davinci_stop_dma'
sound/soc/davinci/davinci-pcm.c: In function `davinci_pcm_prepare':
sound/soc/davinci/davinci-pcm.c:194: error: storage size of 'temp' isn't known
sound/soc/davinci/davinci-pcm.c:200: error: implicit declaration of function davinci_get_dma_params' sound/soc/davinci/davinci-pcm.c:201: error: implicit declaration of function davinci_set_dma_params' sound/soc/davinci/davinci-pcm.c:194: warning: unused variable temp' sound/soc/davinci/davinci-pcm.c: In function davinci_pcm_pointer':
sound/soc/davinci/davinci-pcm.c:217: error: implicit declaration of function davinci_dma_getposition' sound/soc/davinci/davinci-pcm.c: In function davinci_pcm_close':
sound/soc/davinci/davinci-pcm.c:262: error: implicit declaration of function `davinci_dma_unlink_lch'
make[3]: *** [sound/soc/davinci/davinci-pcm.o] Error 1
make[2]: *** [sound/soc/davinci] Error 2
make[1]: *** [sound/soc] Error 2
make: *** [sound] Error 2

Are there plans to fix this before release of 2.6.26 ?

Thanks.

Felix.

#1 lore raw
Quoted 74 lines · Felix Radensky

Hi,

I wanted to test Davinci ASoC driver on Davinci EVM evaluation board, but encountered the following compilation errors:

CC sound/soc/codecs/tlv320aic3x.o
sound/soc/codecs/tlv320aic3x.c:1012: warning: 'aic3x_init' defined but not used

  LD      sound/soc/codecs/snd-soc-tlv320aic3x.o
  LD      sound/soc/codecs/built-in.o
  CC      sound/soc/davinci/davinci-i2s.o

sound/soc/davinci/davinci-i2s.c:402: warning: initialization from incompatible pointer type
CC sound/soc/davinci/davinci-pcm.o
sound/soc/davinci/davinci-pcm.c: In function `davinci_pcm_enqueue_dma':
sound/soc/davinci/davinci-pcm.c:99: error: implicit declaration of function davinci_set_dma_src_params' sound/soc/davinci/davinci-pcm.c:99: error: INCR' undeclared (first use in this function)
sound/soc/davinci/davinci-pcm.c:99: error: (Each undeclared identifier is reported only once
sound/soc/davinci/davinci-pcm.c:99: error: for each function it appears in.) sound/soc/davinci/davinci-pcm.c:99: error: `W8BIT' undeclared (first use in this function)
sound/soc/davinci/davinci-pcm.c:100: error: implicit declaration of function davinci_set_dma_dest_params' sound/soc/davinci/davinci-pcm.c:101: error: implicit declaration of function davinci_set_dma_src_index' sound/soc/davinci/davinci-pcm.c:102: error: implicit declaration of function davinci_set_dma_dest_index' sound/soc/davinci/davinci-pcm.c:103: error: implicit declaration of function davinci_set_dma_transfer_params' sound/soc/davinci/davinci-pcm.c:103: error: `ASYNC' undeclared (first use in this function)
sound/soc/davinci/davinci-pcm.c: In function `davinci_pcm_dma_irq':
sound/soc/davinci/davinci-pcm.c:117: error: `DMA_COMPLETE' undeclared (first use in this function)
sound/soc/davinci/davinci-pcm.c: In function `davinci_pcm_dma_request':
sound/soc/davinci/davinci-pcm.c:134: error: `TCC_ANY' undeclared (first use in this function)
sound/soc/davinci/davinci-pcm.c:143: error: implicit declaration of function davinci_request_dma' sound/soc/davinci/davinci-pcm.c:145: error: EVENTQ_0' undeclared (first use in this function)
sound/soc/davinci/davinci-pcm.c:150: error: PARAM_ANY' undeclared (first use in this function) sound/soc/davinci/davinci-pcm.c:153: error: implicit declaration of function davinci_free_dma'
sound/soc/davinci/davinci-pcm.c:158: error: implicit declaration of function `davinci_dma_link_lch'
sound/soc/davinci/davinci-pcm.c: In function `davinci_pcm_trigger':
sound/soc/davinci/davinci-pcm.c:174: error: implicit declaration of function davinci_start_dma' sound/soc/davinci/davinci-pcm.c:179: error: implicit declaration of function davinci_stop_dma'
sound/soc/davinci/davinci-pcm.c: In function `davinci_pcm_prepare':
sound/soc/davinci/davinci-pcm.c:194: error: storage size of 'temp' isn't known
sound/soc/davinci/davinci-pcm.c:200: error: implicit declaration of function davinci_get_dma_params' sound/soc/davinci/davinci-pcm.c:201: error: implicit declaration of function davinci_set_dma_params' sound/soc/davinci/davinci-pcm.c:194: warning: unused variable temp' sound/soc/davinci/davinci-pcm.c: In function davinci_pcm_pointer':
sound/soc/davinci/davinci-pcm.c:217: error: implicit declaration of function davinci_dma_getposition' sound/soc/davinci/davinci-pcm.c: In function davinci_pcm_close':
sound/soc/davinci/davinci-pcm.c:262: error: implicit declaration of function `davinci_dma_unlink_lch'
make[3]: *** [sound/soc/davinci/davinci-pcm.o] Error 1
make[2]: *** [sound/soc/davinci] Error 2
make[1]: *** [sound/soc] Error 2
make: *** [sound] Error 2

Quoted 1 line

Are there plans to fix this before release of 2.6.26 ?

It looks like we are missing some DaVinci DMA definitions for audio. They are not anywhere in the current HEAD or in include/asm-arm/arch-davinci history.

Vladimir, is this something you could help with.

Thanks

Liam

#2 lore raw

Hi Freix,

I see that you use upstream kernel but you should use now davinci git tree that at 2.6.26-rc5.
I'm not familiar with it's current status. Kevin Hilman is a maintainer and possible that he can answer about ASoC support there and about Davinci upstream status too.
FYI: I can't see that Davinci DMA used in Davinci PCM is not in git tree. Not sure but possible that Kevin adapted ASoC for git DMA stuff.
You can try the attached required patch that was sent to arm-linux mailing list some time ago and patch for i2c hack that is needed for Davinici but is not acceptable upstream.

Also I'm no more with MV. So have nothing access to h/w.

Vladimir

Quoted 58 lines · Liam Girdwood
Quoted 49 lines · Felix Radensky

Hi,

I wanted to test Davinci ASoC driver on Davinci EVM evaluation board, but encountered the following compilation errors:

CC sound/soc/codecs/tlv320aic3x.o
sound/soc/codecs/tlv320aic3x.c:1012: warning: 'aic3x_init' defined but not used

  LD      sound/soc/codecs/snd-soc-tlv320aic3x.o
  LD      sound/soc/codecs/built-in.o
  CC      sound/soc/davinci/davinci-i2s.o

sound/soc/davinci/davinci-i2s.c:402: warning: initialization from incompatible pointer type
CC sound/soc/davinci/davinci-pcm.o
sound/soc/davinci/davinci-pcm.c: In function `davinci_pcm_enqueue_dma':
sound/soc/davinci/davinci-pcm.c:99: error: implicit declaration of function davinci_set_dma_src_params' sound/soc/davinci/davinci-pcm.c:99: error: INCR' undeclared (first use in this function) sound/soc/davinci/davinci-pcm.c:99: error: (Each undeclared identifier is reported only once sound/soc/davinci/davinci-pcm.c:99: error: for each function it appears in.) sound/soc/davinci/davinci-pcm.c:99: error: W8BIT' undeclared (first use in this function) sound/soc/davinci/davinci-pcm.c:100: error: implicit declaration of function davinci_set_dma_dest_params' sound/soc/davinci/davinci-pcm.c:101: error: implicit declaration of function davinci_set_dma_src_index' sound/soc/davinci/davinci-pcm.c:102: error: implicit declaration of function davinci_set_dma_dest_index' sound/soc/davinci/davinci-pcm.c:103: error: implicit declaration of function davinci_set_dma_transfer_params' sound/soc/davinci/davinci-pcm.c:103: error: ASYNC' undeclared (first use in this function) sound/soc/davinci/davinci-pcm.c: In function `davinci_pcm_dma_irq':
sound/soc/davinci/davinci-pcm.c:117: error: DMA_COMPLETE' undeclared (first use in this function) sound/soc/davinci/davinci-pcm.c: In function davinci_pcm_dma_request':
sound/soc/davinci/davinci-pcm.c:134: error: TCC_ANY' undeclared (first use in this function) sound/soc/davinci/davinci-pcm.c:143: error: implicit declaration of function davinci_request_dma' sound/soc/davinci/davinci-pcm.c:145: error: EVENTQ_0' undeclared (first use in this function) sound/soc/davinci/davinci-pcm.c:150: error: PARAM_ANY' undeclared (first use in this function) sound/soc/davinci/davinci-pcm.c:153: error: implicit declaration of function davinci_free_dma' sound/soc/davinci/davinci-pcm.c:158: error: implicit declaration of function davinci_dma_link_lch' sound/soc/davinci/davinci-pcm.c: In function `davinci_pcm_trigger':
sound/soc/davinci/davinci-pcm.c:174: error: implicit declaration of function davinci_start_dma' sound/soc/davinci/davinci-pcm.c:179: error: implicit declaration of function davinci_stop_dma' sound/soc/davinci/davinci-pcm.c: In function `davinci_pcm_prepare':
sound/soc/davinci/davinci-pcm.c:194: error: storage size of 'temp' isn't known sound/soc/davinci/davinci-pcm.c:200: error: implicit declaration of function davinci_get_dma_params' sound/soc/davinci/davinci-pcm.c:201: error: implicit declaration of function davinci_set_dma_params' sound/soc/davinci/davinci-pcm.c:194: warning: unused variable temp' sound/soc/davinci/davinci-pcm.c: In function davinci_pcm_pointer':
sound/soc/davinci/davinci-pcm.c:217: error: implicit declaration of function davinci_dma_getposition' sound/soc/davinci/davinci-pcm.c: In function davinci_pcm_close':
sound/soc/davinci/davinci-pcm.c:262: error: implicit declaration of function `davinci_dma_unlink_lch' make[3]: *** [sound/soc/davinci/davinci-pcm.o] Error 1
make[2]: *** [sound/soc/davinci] Error 2
make[1]: *** [sound/soc] Error 2
make: *** [sound] Error 2

Quoted 2 lines

Are there plans to fix this before release of 2.6.26 ?

It looks like we are missing some DaVinci DMA definitions for audio. They are not anywhere in the current HEAD or in include/asm-arm/arch-davinci history.

Quoted 8 lines

Vladimir, is this something you could help with.

Thanks

Liam

arch/arm/mach-davinci/dma.c new file +919 -0
Index: linux-2.6.25-rc1/arch/arm/mach-davinci/dma.c
===================================================================
@@ -0,0 +1,919 @@
+/*
+
+ * TI DaVinci DMA Support
+ *
+ * Copyright (C) 2006 Texas Instruments.
+ * Copyright (c) 2007, MontaVista Software, Inc. <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+
+#include <asm/hardware.h>
+#include <asm/dma.h>
+
+#define DAVINCI_EDMA_DEBUG 0
+#if DAVINCI_EDMA_DEBUG
+#define DBG(x...) printk(KERN_DEBUG x)
+#else
+#define DBG(x...)
+#endif
+
+static struct davinci_dma_lch {
+	int dev_id;
+	int in_use;
+	int param_no;
+	int tcc;
+} dma_chan[EDMA_NUM_PARAMENTRY];
+
+static struct davinci_dma_lch_intr {
+	void (*callback) (int lch, u16 ch_status, void *data);
+	void *data;
+} intr_data[EDMA_NUM_DMACH];
+
+#define dma_handle_cb(lch, status)	do { \
+	if (intr_data[lch].callback) \
+		intr_data[lch].callback(lch, status, intr_data[lch].data); \
+} while (0)
+
+/*
+ * Each bit field of the elements bellow indicate the corresponding
+ * (EDMA + QDMA) channel availability on arm side events
+ */
+static unsigned int dma2arm_map[3] = {
+	0xffffffff, 0xffffffff, 0x0
+};
+
+/*
+ * Each bit field of the elements bellow indicate corresponding PARAM entry
+ * availibility on arm side events
+ */
+static unsigned int param2arm_map[] = {
+	0xffffffff, 0xffffffff, 0x0000ffff, 0xffffffff,
+};
+
+static int evtqueue_tc_map[EDMA_NUM_EVQUE][2] = {
+	/* {event queue no, TC no} */
+	{0, 0},
+	{1, 1},
+};
+
+static int evtqueue_priority_map[EDMA_NUM_EVQUE][2] = {
+	/* {event queue no, Priority} */
+	{0, 0},
+	{1, 1},
+};
+
+static unsigned int qdma2param_map[8];
+static unsigned int edma2event_map[EDMA_NUM_DMACH / 32];
+static unsigned int dma_intr_reseved[EDMA_NUM_DMACH / 32];
+static unsigned int param_entry_reserved[EDMA_NUM_PARAMENTRY / 32];
+
+static void map_edmach2evt_queue(int lch, int eventq)
+{
+	u32 reg = EDMA_DMAQNUM(lch >> 3);
+	int bit = (lch % 8) << 2;
+
+	CLEAR_REG_VAL(0x7 << bit, reg);
+	SET_REG_VAL((eventq & 0x7) << bit, reg);
+}
+
+static void map_qdmach2evt_queue(int lch, int eventq)
+{
+	u32 reg = EDMA_QDMAQNUM;
+	int bit = (lch - EDMA_NUM_DMACH) << 2;
+
+	CLEAR_REG_VAL(0x7 << bit, reg);
+	SET_REG_VAL((eventq & 0x7) << bit, reg);
+}
+
+static void map_qdmach2param(int lch, int param_no)
+{
+	u32 reg;
+
+	reg = EDMA_QCHMAP(lch - EDMA_NUM_DMACH);
+	CLEAR_REG_VAL(PAENTRY | TRWORD, reg);
+	SET_REG_VAL(((param_no & 0x1ff) << 5) | (QDMA_TRWORD << 2), reg);
+}
+
+static int reserve_param(int lch)
+{
+	int i;
+
+	/* The EDMA Channels are mapped to the first PARAM entries */
+	if (dma_is_edmach(lch)) {
+		param_reserve(lch);
+		return lch;
+	}
+
+	for (i = EDMA_NUM_DMACH; i < EDMA_NUM_PARAMENTRY; i++) {
+		if (param_is_free(i) && param_is_valid(i)) {
+			param_reserve(i);
+			return i;
+		}
+	}
+
+	/* there is no free PaRam */
+	return -EBUSY;
+}
+
+static void free_param(int param_no)
+{
+	param_free(param_no);
+}
+
+static int reserve_dma_interrupt(int lch, int tcc)
+{
+	if (dma_is_edmach(lch)) {
+		if (interrupt_is_free(lch)) {
+			interrupt_reserve(lch);
+			return lch;
+		}
+	} else if (dma_is_qdmach(lch)) {
+		int i = 0;
+
+		if (tcc != TCC_ANY) {
+			if (!interrupt_is_free(tcc))
+				return -EBUSY;
+			if (edmach_has_event(tcc))
+				return -EINVAL;
+			interrupt_reserve(tcc);
+			return tcc;
+		}
+
+		while (i < EDMA_NUM_DMACH) {
+			if (interrupt_is_free(i) && !edmach_has_event(i)) {
+				interrupt_reserve(i);
+				return i;
+			}
+			i++;
+		}
+	}
+
+	/* there is no free interrupt channels */
+	return -EBUSY;
+}
+
+static void free_dma_interrupt(int ch_irq)
+{
+	interrupt_free(ch_irq);
+}
+
+static int request_dma_interrupt(void (*callback) (int lch, u16 ch_status,
+						   void *data),
+				 void *data, int *lch, int *tcc)
+{
+	int ch_irq;
+	u32 reg, mask;
+
+	if (callback) {
+		ch_irq = reserve_dma_interrupt(*lch, *tcc);
+		if (ch_irq < 0)
+			return ch_irq;
+
+		reg = ch_irq < 32 ?  EDMA_SH_IESR(0) : EDMA_SH_IESRH(0);
+		mask = 1 << (ch_irq < 32 ? ch_irq : ch_irq - 32);
+		SET_REG_VAL(mask, reg);
+
+		dma_chan[*lch].tcc = ch_irq;
+		*tcc = ch_irq;
+		intr_data[*tcc].callback = callback;
+		intr_data[*tcc].data = data;
+	} else {
+		dma_chan[*lch].tcc = -1;
+	}
+
+	return 0;
+}
+
+/**
+ * DMA transfer completion interrupt handler
+ */
+static irqreturn_t davinci_dma_irq_handler(int irq, void *dev_id)
+{
+	if (!(dma_read(EDMA_SH_IPR(0)) || dma_read(EDMA_SH_IPRH(0))))
+		return IRQ_NONE;
+
+	while (1) {
+		u32 status_l = dma_read(EDMA_SH_IPR(0));
+		u32 status_h = dma_read(EDMA_SH_IPRH(0));
+		int lch;
+		int i;
+
+		if (!(status_l || status_h))
+			break;
+
+		lch = 0;
+		while (status_l) {
+			i = ffs(status_l);
+			lch += i;
+			/* Clear the corresponding IPR bits */
+			SET_REG_VAL(1 << (lch - 1), EDMA_SH_ICR(0));
+			dma_handle_cb(lch - 1, DMA_COMPLETE);
+			status_l >>= i;
+		}
+
+		lch = 32;
+		while (status_h) {
+			i = ffs(status_h);
+			lch += i;
+			/* Clear the corresponding IPR bits */
+			SET_REG_VAL(1 << (lch - 33), EDMA_SH_ICRH(0));
+			dma_handle_cb(lch - 1, DMA_COMPLETE);
+			status_h >>= i;
+		}
+	}
+	dma_write(0x1, EDMA_SH_IEVAL(0));
+
+	return IRQ_HANDLED;
+}
+
+/**
+ * DMA error interrupt handler
+ */
+static irqreturn_t davinci_dma_ccerr_handler(int irq, void *dev_id)
+{
+	if (!(dma_read(EDMA_EMR) || dma_read(EDMA_EMRH) ||
+	    dma_read(EDMA_QEMR) || dma_read(EDMA_CCERR)))
+		return IRQ_NONE;
+
+	while (1) {
+		u32 status_emr = dma_read(EDMA_EMR);
+		u32 status_emrh = dma_read(EDMA_EMRH);
+		u32 status_qemr = dma_read(EDMA_QEMR);
+		u32 status_ccerr = dma_read(EDMA_CCERR);
+		int lch;
+		int i;
+
+		if (!(status_emr || status_emrh || status_qemr || status_ccerr))
+			break;
+
+		lch = 0;
+		while (status_emr) {
+			i = ffs(status_emr);
+			lch += i;
+			/* Clear the corresponding EMR bits */
+			SET_REG_VAL(1 << (lch - 1), EDMA_EMCR);
+			/* Clear any SER */
+			SET_REG_VAL(1 << (lch - 1), EDMA_SH_SECR(0));
+			dma_handle_cb(lch - 1, DMA_CC_ERROR);
+			status_emr >>= i;
+		}
+
+		lch = 32;
+		while (status_emrh) {
+			i = ffs(status_emrh);
+			lch += i;
+			/* Clear the corresponding IPR bits */
+			SET_REG_VAL(1 << (lch - 1), EDMA_EMCRH);
+			/* Clear any SER */
+			SET_REG_VAL(1 << (lch - 1), EDMA_SH_SECRH(0));
+			dma_handle_cb(lch - 1, DMA_CC_ERROR);
+			status_emrh >>= i;
+		}
+
+		lch = 0;
+		while (status_qemr) {
+			i = ffs(status_qemr);
+			lch += i;
+			/* Clear the corresponding IPR bits */
+			SET_REG_VAL(1 << (lch - 1), EDMA_QEMCR);
+			SET_REG_VAL(1 << (lch - 1), EDMA_SH_QSECR(0));
+			status_qemr >>= i;
+		}
+
+		lch = 0;
+		while (status_ccerr) {
+			i = ffs(status_ccerr);
+			lch += i;
+			/* Clear the corresponding IPR bits */
+			SET_REG_VAL(1 << (lch - 1), EDMA_CCERRCLR);
+			status_ccerr >>= i;
+		}
+	}
+	dma_write(0x1, EDMA_EEVAL);
+
+	return IRQ_HANDLED;
+}
+
+/**
+ * DMA channel request - request for the Davinci DMA channel
+ *
+ * dev_id - DMA channel number
+ *
+ * EX: DAVINCI_DMA_MCBSP_TX - For requesting a DMA MasterChannel with MCBSP_TX
+ *     event association
+ *
+ *     EDMA_DMA_CHANNEL_ANY - For requesting a DMA Master channel which does
+ *                            not has event association
+ *
+ *     DAVINCI_EDMA_PARAM_ANY - for requesting a DMA Slave Channel
+ *
+ * dev_name   - name of the dma channel in human readable format
+ * callback   - channel callback function (valied only if you are requesting
+ *              for a DMA MasterChannel)
+ * data       - private data for the channel to be requested
+ * lch        - contains the device id allocated
+ * tcc        - specifies the channel number on which the interrupt is generated
+ *              Valid for QDMA and PARAM channes
+ * eventq_no  - Event Queue no to which the channel will be associated with
+ *              (valied only if you are requesting for a DMA MasterChannel)
+ *              Values : EVENTQ_0/EVENTQ_1 for event queue 0/1.
+ *
+ * Return: zero on success or error on failure
+ */
+int davinci_request_dma(int dev_id, const char *dev_name,
+			void (*callback) (int lch, u16 ch_status, void *data),
+			void *data, int *lch, int *tcc,
+			enum dma_event_q eventq_no)
+{
+	int ret_val = 0;
+	int temp_ch = 0;
+	int i;
+	u32 reg, mask;
+
+	if (dma_is_edmach(dev_id)) {
+		*lch = dev_id;
+		temp_ch = *lch;
+
+		if (!dmach_is_valid(dev_id))
+			return -EINVAL;
+
+		if (dma_chan[dev_id].in_use)
+			return -EBUSY;
+
+		dma_chan[*lch].param_no = reserve_param(*lch);
+		if (dma_chan[*lch].param_no == -1)
+			return -EBUSY;
+
+		reg = dev_id < 32 ? EDMA_DRAE(0) : EDMA_DRAEH(0);
+		mask = 1 << (dev_id < 32 ? dev_id : dev_id - 32);
+		SET_REG_VAL(mask, reg);
+
+		ret_val = request_dma_interrupt(callback, data, lch, tcc);
+		if (ret_val)
+			return ret_val;
+
+		/* Map EDMA channel to event queue */
+		map_edmach2evt_queue(dev_id, eventq_no);
+	} else if (dma_is_qdmach(dev_id)) {
+		*lch = dev_id;
+
+		if (!dmach_is_valid(dev_id))
+			return -EINVAL;
+
+		dma_chan[*lch].param_no = reserve_param(*lch);
+		if (dma_chan[*lch].param_no == -1)
+			return -EBUSY;
+
+		temp_ch = dev_id - EDMA_NUM_DMACH;
+		qdma2param_map[temp_ch] = dma_chan[*lch].param_no;
+		temp_ch = qdma2param_map[temp_ch];
+
+		if (dma_chan[temp_ch].in_use)
+			return -EBUSY;
+
+		SET_REG_VAL(1 << (dev_id - EDMA_NUM_DMACH), EDMA_QRAE(0));
+
+		ret_val = request_dma_interrupt(callback, data, lch, tcc);
+		if (ret_val)
+			return ret_val;
+
+		/* Map QDMA channel to event queue */
+		map_qdmach2evt_queue(*lch, eventq_no);
+		/* Map QDMA channel to PaRAM Set */
+		map_qdmach2param(*lch, dma_chan[*lch].param_no);
+
+		dma_chan[temp_ch].tcc = dma_chan[*lch].tcc;
+		dma_chan[temp_ch].param_no = dma_chan[*lch].param_no;
+	} else if (dev_id == PARAM_ANY) {
+		for (i = (EDMA_NUM_DMACH + EDMA_NUM_QDMACH);
+		     i < EDMA_NUM_PARAMENTRY; i++) {
+			if (!dma_chan[i].in_use) {
+				*lch = i;
+				temp_ch = *lch;
+
+				dma_chan[*lch].param_no = reserve_param(*lch);
+				if (dma_chan[*lch].param_no == -1)
+					return -EBUSY;
+
+				dma_chan[*lch].tcc = *tcc;
+				break;
+			}
+		}
+	}
+
+	dma_chan[temp_ch].in_use = 1;
+	dma_chan[temp_ch].dev_id = *lch;
+
+	reg = EDMA_PARAM_OPT(dma_chan[temp_ch].param_no);
+	if (dma_chan[*lch].tcc != TCC_ANY) {
+		CLEAR_REG_VAL(TCC, reg);
+		SET_REG_VAL((0x3f & dma_chan[*lch].tcc) << 12, reg);
+		/* set TCINTEN bit in PARAM entry */
+		SET_REG_VAL(TCINTEN, reg);
+	} else {
+		CLEAR_REG_VAL(TCINTEN, reg);
+	}
+	/* assign the link field to no link. i.e 0xffff */
+	SET_REG_VAL(0xffff,
+		    EDMA_PARAM_LINK_BCNTRLD(dma_chan[temp_ch].param_no));
+
+	return 0;
+}
+EXPORT_SYMBOL(davinci_request_dma);
+
+void davinci_free_dma(int lch)
+{
+	u32 reg, mask;
+	int tcc;
+
+	if (dma_is_qdmach(lch))
+		lch = qdma2param_map[lch - EDMA_NUM_DMACH];
+
+	free_param(dma_chan[lch].param_no);
+
+	if (lch >= 0 && lch < (EDMA_NUM_DMACH + EDMA_NUM_QDMACH)) {
+		tcc = dma_chan[lch].tcc;
+		free_dma_interrupt(tcc);
+
+		if (lch < EDMA_NUM_DMACH) {
+			/* Clear the corresponding IPR bits */
+			reg = tcc < 32 ? EDMA_SH_ICR(0) : EDMA_SH_ICRH(0);
+			mask = 1 << (tcc < 32 ? tcc : tcc - 32);
+			SET_REG_VAL(mask, reg);
+		}
+
+		intr_data[tcc].callback = NULL;
+		intr_data[tcc].data = NULL;
+	}
+
+	dma_chan[lch].in_use = 0;
+}
+EXPORT_SYMBOL(davinci_free_dma);
+
+/**
+ * DMA source parameters setup
+ * Arguments:
+ *     lch - logical channel number
+ *     src_port - Source port address
+ *     mode - indicates wether addressing mode is fifo.
+ */
+void davinci_set_dma_src_params(int lch, u32 src_port,
+				enum address_mode mode, enum fifo_width width)
+{
+	u32 reg;
+
+	if (dma_is_qdmach(lch))
+		lch = qdma2param_map[lch - EDMA_NUM_DMACH];
+
+	if (!(lch >= 0 && lch < EDMA_NUM_PARAMENTRY))
+		return;
+
+	dma_write(src_port, EDMA_PARAM_SRC(dma_chan[lch].param_no));
+	/* set the fifo addressing mode */
+	if (mode) {
+		reg = EDMA_PARAM_OPT(dma_chan[lch].param_no);
+		/* reset SAM and FWID */
+		CLEAR_REG_VAL(SAM | EDMA_FWID, reg);
+		/* set SAM and program FWID */
+		SET_REG_VAL(mode | ((width & 0x7) << 8), reg);
+	}
+}
+EXPORT_SYMBOL(davinci_set_dma_src_params);
+
+/**
+ * DMA destination parameters setup
+ * Arguments:
+ *     lch - logical channel number or param device
+ *     dest_port - destination port address
+ *     mode - indicates wether addressing mode is fifo.
+ */
+void davinci_set_dma_dest_params(int lch, u32 dest_port,
+				 enum address_mode mode, enum fifo_width width)
+{
+	u32 reg;
+
+	if (dma_is_qdmach(lch))
+		lch = qdma2param_map[lch - EDMA_NUM_DMACH];
+
+	if (!(lch >= 0 && lch < EDMA_NUM_PARAMENTRY))
+		return;
+
+	dma_write(dest_port, EDMA_PARAM_DST(dma_chan[lch].param_no));
+	/* set the fifo addressing mode */
+	if (mode) {
+		reg = EDMA_PARAM_OPT(dma_chan[lch].param_no);
+		/* reset DAM and FWID */
+		CLEAR_REG_VAL(DAM | EDMA_FWID, reg);
+		/* set DAM and program FWID */
+		SET_REG_VAL((mode << 1) | ((width & 0x7) << 8), reg);
+	}
+}
+EXPORT_SYMBOL(davinci_set_dma_dest_params);
+
+/**
+ * DMA source index setup
+ * Arguments:
+ *     lch - logical channel number or param device
+ *     srcbidx - source B-register index
+ *     srccidx - source C-register index
+ */
+void davinci_set_dma_src_index(int lch, u16 src_bidx, u16 src_cidx)
+{
+	u32 reg;
+
+	if (dma_is_qdmach(lch))
+		lch = qdma2param_map[lch - EDMA_NUM_DMACH];
+
+	if (!(lch >= 0 && lch < EDMA_NUM_PARAMENTRY))
+		return;
+
+	reg = EDMA_PARAM_SRC_DST_BIDX(dma_chan[lch].param_no);
+	CLEAR_REG_VAL(0xffff, reg);
+	SET_REG_VAL(src_bidx, reg);
+
+	reg = EDMA_PARAM_SRC_DST_CIDX(dma_chan[lch].param_no);
+	CLEAR_REG_VAL(0xffff, reg);
+	SET_REG_VAL(src_cidx, reg);
+}
+EXPORT_SYMBOL(davinci_set_dma_src_index);
+
+/**
+ * DMA destination index setup
+ * Arguments:
+ *     lch - logical channel number or param device
+ *     srcbidx - dest B-register index
+ *     srccidx - dest C-register index
+ */
+void davinci_set_dma_dest_index(int lch, u16 dest_bidx, u16 dest_cidx)
+{
+	u32 reg;
+
+	if (dma_is_qdmach(lch))
+		lch = qdma2param_map[lch - EDMA_NUM_DMACH];
+
+	if (!(lch >= 0 && lch < EDMA_NUM_PARAMENTRY))
+		return;
+
+	reg = EDMA_PARAM_SRC_DST_BIDX(dma_chan[lch].param_no);
+	CLEAR_REG_VAL(0xffff0000, reg);
+	SET_REG_VAL((u32)dest_bidx << 16, reg);
+
+	reg = EDMA_PARAM_SRC_DST_CIDX(dma_chan[lch].param_no);
+	CLEAR_REG_VAL(0xffff0000, reg);
+	SET_REG_VAL((u32)dest_cidx << 16, reg);
+}
+EXPORT_SYMBOL(davinci_set_dma_dest_index);
+
+/**
+ * DMA transfer parameters setup
+ * Arguments:
+ *     lch - logical channel number or param device
+ *     acnt - acnt register value to be configured
+ *     bcnt - bcnt register value to be configured
+ *     ccnt - ccnt register value to be configured
+ */
+void davinci_set_dma_transfer_params(int lch, u16 acnt, u16 bcnt, u16 ccnt,
+				     u16 bcntrld, enum sync_dimension sync_mode)
+{
+	u32 reg;
+
+	if (dma_is_qdmach(lch))
+		lch = qdma2param_map[lch - EDMA_NUM_DMACH];
+
+	if (!(lch >= 0 && lch < EDMA_NUM_PARAMENTRY))
+		return;
+
+	reg = EDMA_PARAM_LINK_BCNTRLD(dma_chan[lch].param_no);
+	CLEAR_REG_VAL(0xffff0000, reg);
+	SET_REG_VAL((u32)bcntrld << 16, reg);
+
+	reg = EDMA_PARAM_OPT(dma_chan[lch].param_no);
+	if (sync_mode == ASYNC)
+		CLEAR_REG_VAL(SYNCDIM, reg);
+	else
+		SET_REG_VAL(SYNCDIM, reg);
+
+	/* Set the acount, bcount, ccount registers */
+	dma_write(((u32)bcnt << 16) | acnt,
+		  EDMA_PARAM_A_B_CNT(dma_chan[lch].param_no));
+	dma_write(ccnt, EDMA_PARAM_CCNT(dma_chan[lch].param_no));
+}
+EXPORT_SYMBOL(davinci_set_dma_transfer_params);
+
+void davinci_set_dma_params(int lch, struct paramentry_descriptor *d)
+{
+	if (dma_is_qdmach(lch))
+		lch = qdma2param_map[lch - EDMA_NUM_DMACH];
+
+	if (!(lch >= 0 && lch < EDMA_NUM_PARAMENTRY))
+		return;
+
+	dma_write(d->opt, EDMA_PARAM_OPT(dma_chan[lch].param_no));
+	dma_write(d->src, EDMA_PARAM_SRC(dma_chan[lch].param_no));
+	dma_write(d->a_b_cnt, EDMA_PARAM_A_B_CNT(dma_chan[lch].param_no));
+	dma_write(d->dst, EDMA_PARAM_DST(dma_chan[lch].param_no));
+	dma_write(d->src_dst_bidx,
+		      EDMA_PARAM_SRC_DST_BIDX(dma_chan[lch].param_no));
+	dma_write(d->link_bcntrld,
+		      EDMA_PARAM_LINK_BCNTRLD(dma_chan[lch].param_no));
+	dma_write(d->src_dst_cidx,
+		      EDMA_PARAM_SRC_DST_CIDX(dma_chan[lch].param_no));
+	dma_write(d->ccnt, EDMA_PARAM_CCNT(dma_chan[lch].param_no));
+}
+EXPORT_SYMBOL(davinci_set_dma_params);
+
+void davinci_get_dma_params(int lch, struct paramentry_descriptor *d)
+{
+	if (dma_is_qdmach(lch))
+		lch = qdma2param_map[lch - EDMA_NUM_DMACH];
+
+	if (!(lch >= 0 && lch < EDMA_NUM_PARAMENTRY))
+		return;
+
+	d->opt = dma_read(EDMA_PARAM_OPT(dma_chan[lch].param_no));
+	d->src = dma_read(EDMA_PARAM_SRC(dma_chan[lch].param_no));
+	d->a_b_cnt = dma_read(EDMA_PARAM_A_B_CNT(dma_chan[lch].param_no));
+	d->dst = dma_read(EDMA_PARAM_DST(dma_chan[lch].param_no));
+	d->src_dst_bidx =
+	    dma_read(EDMA_PARAM_SRC_DST_BIDX(dma_chan[lch].param_no));
+	d->link_bcntrld =
+	    dma_read(EDMA_PARAM_LINK_BCNTRLD(dma_chan[lch].param_no));
+	d->src_dst_cidx =
+	    dma_read(EDMA_PARAM_SRC_DST_CIDX(dma_chan[lch].param_no));
+	d->ccnt = dma_read(EDMA_PARAM_CCNT(dma_chan[lch].param_no));
+}
+EXPORT_SYMBOL(davinci_get_dma_params);
+
+/**
+ * DMA start - starts the dma on the channel passed
+ * Arguments:
+ *     lch - logical channel number
+ */
+int davinci_start_dma(int lch)
+{
+	int ret = 0;
+	u32 mask;
+
+	if (dma_is_edmach(lch)) {
+		/* Check is EDMA channel with event association */
+		if (!edmach_has_event(lch)) {
+			DBG("ESR=%x\n", dma_read(EDMA_SH_ESR(0)));
+
+			if (lch < 32)
+				SET_REG_VAL(1 << lch, EDMA_SH_ESR(0));
+			else
+				SET_REG_VAL(1 << (lch - 32), EDMA_SH_ESRH(0));
+
+			return ret;
+		}
+
+		DBG("ER=%d\n", dma_read(EDMA_SH_ER(0)));
+		if (lch < 32) {
+			mask = 1 << lch;
+			/* Clear any pedning error */
+			SET_REG_VAL(mask, EDMA_EMCR);
+			/* Clear any SER */
+			SET_REG_VAL(mask, EDMA_SH_SECR(0));
+			SET_REG_VAL(mask, EDMA_SH_EESR(0));
+		} else {
+			mask = 1 << (lch - 32);
+			/* Clear any pedning error */
+			SET_REG_VAL(mask, EDMA_EMCRH);
+			/* Clear any SER */
+			SET_REG_VAL(mask, EDMA_SH_SECRH(0));
+			SET_REG_VAL(mask, EDMA_SH_EESRH(0));
+		}
+		DBG("EER=%d\n", dma_read(EDMA_SH_EER(0)));
+	} else if (dma_is_qdmach(lch)) {
+		SET_REG_VAL(1 << (lch - EDMA_NUM_DMACH), EDMA_SH_QEESR(0));
+	} else {
+		/* for Slave Channels */
+		ret = -EINVAL;
+	}
+
+	return ret;
+}
+EXPORT_SYMBOL(davinci_start_dma);
+
+/**
+ * DMA stop - stops the dma on the channel passed
+ * Arguments:
+ *     lch - logical channel number
+ */
+void davinci_stop_dma(int lch)
+{
+	u32 reg, mask;
+
+	if (lch < EDMA_NUM_DMACH) {
+		/* Check is EDMA channel with event association */
+		if (!edmach_has_event(lch))
+			return;
+
+		if (lch < 32) {
+			reg = EDMA_SH_EECR(0);
+			mask = 1 << lch;
+			CLEAR_EVENT(mask, EDMA_SH_ER(0), EDMA_SH_ECR(0));
+			CLEAR_EVENT(mask, EDMA_SH_SER(0), EDMA_SH_SECR(0));
+			CLEAR_EVENT(mask, EDMA_EMR, EDMA_EMCR);
+		} else {
+			reg = EDMA_SH_EECRH(0);
+			mask = 1 << (lch - 32);
+			CLEAR_EVENT(mask, EDMA_SH_ERH(0), EDMA_SH_ECRH(0));
+			CLEAR_EVENT(mask, EDMA_SH_SERH(0), EDMA_SH_SECRH(0));
+			CLEAR_EVENT(mask, EDMA_EMRH, EDMA_EMCRH);
+		}
+		SET_REG_VAL(mask, reg);
+		DBG("EER=%d\n", dma_read(EDMA_SH_EER(0)));
+	} else if (dma_is_qdmach(lch)) {
+		/* for QDMA channels */
+		SET_REG_VAL(1 << (lch - EDMA_NUM_DMACH), EDMA_QEECR);
+		DBG("QER=%d\n", dma_read(EDMA_QER));
+		DBG("QEER=%d\n", dma_read(EDMA_QEER));
+	} else if ((lch >= (EDMA_NUM_DMACH + EDMA_NUM_QDMACH)) &&
+		   lch < EDMA_NUM_PARAMENTRY) {
+		/* for slaveChannels */
+		CLEAR_REG_VAL(0xffff, EDMA_PARAM_LINK_BCNTRLD(lch));
+		SET_REG_VAL(0xffff, EDMA_PARAM_LINK_BCNTRLD(lch));
+	}
+}
+EXPORT_SYMBOL(davinci_stop_dma);
+
+/**
+ * DMA channel link - link the two logical channels passed through by linking
+ *                    the link field of head to the param pointed by the
+ *                    lch_queue.
+ * Arguments:
+ *     lch_head  - logical channel number, in which the link field is linked
+ *                 to the param pointed to by lch_queue
+ *     lch_queue - logical channel number or the param entry number, which is
+ *                 to be linked to the lch_head
+ */
+void davinci_dma_link_lch(int lch_head, int lch_queue)
+{
+	u16 link;
+	u32 reg;
+
+	if (dma_is_qdmach(lch_head))
+		lch_head = qdma2param_map[lch_head - EDMA_NUM_DMACH];
+
+	if (dma_is_qdmach(lch_queue))
+		lch_queue = qdma2param_map[lch_queue - EDMA_NUM_DMACH];
+
+	if ((lch_head >= 0 && lch_head < EDMA_NUM_PARAMENTRY) &&
+	    (lch_queue >= 0 && lch_queue < EDMA_NUM_PARAMENTRY)) {
+		/* program LINK */
+		link = (u16)
+		       IO_ADDRESS(EDMA_PARAM_OPT(dma_chan[lch_queue].param_no));
+		reg = EDMA_PARAM_LINK_BCNTRLD(dma_chan[lch_head].param_no);
+		CLEAR_REG_VAL(0xffff, reg);
+		SET_REG_VAL(link, reg);
+	}
+}
+EXPORT_SYMBOL(davinci_dma_link_lch);
+
+/**
+ * DMA channel unlink - unlink the two logical channels passed through by
+ *                      setting the link field of head to 0xffff.
+ * Arguments:
+ *     lch_head - logical channel number, from which the link field is
+ *                to be removed
+ *     lch_queue - logical channel number or the param entry number,
+ *                 which is to be unlinked from lch_head
+ */
+void davinci_dma_unlink_lch(int lch_head, int lch_queue)
+{
+	u32 reg;
+
+	if (dma_is_qdmach(lch_head))
+		lch_head = qdma2param_map[lch_head - EDMA_NUM_DMACH];
+
+	if (dma_is_qdmach(lch_queue))
+		lch_queue = qdma2param_map[lch_queue - EDMA_NUM_DMACH];
+
+	if ((lch_head >= 0 && lch_head < EDMA_NUM_PARAMENTRY) &&
+	    (lch_queue >= 0 && lch_queue < EDMA_NUM_PARAMENTRY)) {
+		reg = EDMA_PARAM_LINK_BCNTRLD(dma_chan[lch_head].param_no);
+		SET_REG_VAL(0xffff, reg);
+	}
+}
+EXPORT_SYMBOL(davinci_dma_unlink_lch);
+
+/**
+ * DMA clean channel - cleans Paramentry and bring back EDMA to initial state
+ * if media has been removed before EDMA has finished. It is usedful for
+ * removable media.
+ * Arguments:
+ *     lch - logical channel number
+ */
+void davinci_clean_channel(int lch)
+{
+	u32 mask;
+
+	if (lch < 32) {
+		DBG("EMR =%d\n", dma_read(EDMA_EMR));
+		mask = 1 << lch;
+		SET_REG_VAL(mask, EDMA_SH_ECR(0));
+		/* Clear the corresponding EMR bits */
+		SET_REG_VAL(mask, EDMA_EMCR);
+		/* Clear any SER */
+		SET_REG_VAL(mask, EDMA_SH_SECR(0));
+	} else {
+		DBG("EMRH =%d\n", dma_read(EDMA_EMRH));
+		mask = 1 << (lch - 32);
+		SET_REG_VAL(mask, EDMA_SH_ECRH(0));
+		/* Clear the corresponding EMRH bits */
+		SET_REG_VAL(mask, EDMA_EMCRH);
+		/* Clear any SER */
+		SET_REG_VAL(mask, EDMA_SH_SECRH(0));
+	}
+
+	SET_REG_VAL((1 << 16) | 0x3, EDMA_CCERRCLR);
+}
+EXPORT_SYMBOL(davinci_clean_channel);
+
+/**
+ * DMA transfer position - returns the current transfer points for the dma
+ * source and destination
+ * Arguments:
+ *     lch - logical channel number
+ *     src - source port position
+ *     dst - destination port position
+ */
+void davinci_dma_getposition(int lch, dma_addr_t *src, dma_addr_t *dst)
+{
+	struct paramentry_descriptor temp;
+
+	davinci_get_dma_params(lch, &temp);
+	if (src != NULL)
+		*src = temp.src;
+	if (dst != NULL)
+		*dst = temp.dst;
+}
+EXPORT_SYMBOL(davinci_dma_getposition);
+
+static int __init davinci_dma_init(void)
+{
+	int i, ret;
+	u32 mask;
+
+	DBG("DMA BASE ADDR=%x\n", (unsigned int)IO_ADDRESS(EDMA_BASE));
+
+	memset((void *)IO_ADDRESS(EDMA_PARAM_OPT(0)), 0x00, EDMA_PARAM_SIZE);
+
+	/* Event queue to TC mapping */
+	for (i = 0; i < EDMA_NUM_EVQUE; i++) {
+		mask = evtqueue_tc_map[i][0] << 2;
+		CLEAR_REG_VAL(0x7 << mask, EDMA_QUETCMAP);
+		mask = (evtqueue_tc_map[i][1] & 0x7) << mask;
+		SET_REG_VAL(mask, EDMA_QUETCMAP);
+	}
+
+	/* Assign priority to event queue */
+	for (i = 0; i < EDMA_NUM_EVQUE; i++) {
+		mask = evtqueue_priority_map[i][0] << 2;
+		CLEAR_REG_VAL(0x7 << mask, EDMA_QUEPRI);
+		mask = (evtqueue_priority_map[i][1] & 0x7) << mask;
+		SET_REG_VAL(mask, EDMA_QUEPRI);
+	}
+
+	for (i = 0; i < EDMA_NUM_REGIONS; i++) {
+		dma_write(0x0, EDMA_DRAE(i));
+		dma_write(0x0, EDMA_DRAEH(i));
+		dma_write(0x0, EDMA_QRAE(i));
+	}
+
+	ret = request_irq(IRQ_CCINT0, davinci_dma_irq_handler, 0, "EDMA", NULL);
+	if (ret) {
+		printk(KERN_ERR "unable to request IRQ %d for DMA (error %d)\n",
+		       IRQ_CCINT0, ret);
+		DBG("request_irq failed\n");
+		return ret;
+	}
+
+	ret = request_irq(IRQ_CCERRINT, davinci_dma_ccerr_handler, 0,
+			  "EDMA CC Err", NULL);
+	if (ret) {
+		printk(KERN_ERR "unable to request IRQ %d for DMA (error %d)\n",
+		       IRQ_CCERRINT, ret);
+		free_irq(IRQ_CCINT0, NULL);
+		return ret;
+	}
+
+	/* TODO: add cpu_is_xxx() check for different Davinci SoCs */
+	edma2event_map[0] = DM644X_DMACH2EVENT_MAP0;
+	edma2event_map[1] = DM644X_DMACH2EVENT_MAP1;
+
+	return 0;
+}
+
+arch_initcall(davinci_dma_init);
include/asm-arm/arch-davinci/edma.h new file +370 -0

370 lines not on this page · raw message

arch/arm/mach-davinci/Makefile +1 -1
Index: linux-2.6.25-rc1/arch/arm/mach-davinci/Makefile
===================================================================
@@ -5,7 +5,7 @@
 
 # Common objects
 obj-y 			:= time.o irq.o clock.o serial.o io.o id.o psc.o \
-			   gpio.o mux.o mux_cfg.o devices.o
+			   gpio.o mux.o mux_cfg.o devices.o dma.o
 
 # Board specific
 obj-$(CONFIG_MACH_DAVINCI_EVM)  += board-evm.o
include/asm-arm/arch-davinci/dma.h +2 -0
Index: linux-2.6.25-rc1/include/asm-arm/arch-davinci/dma.h
===================================================================
@@ -13,4 +13,6 @@
 
 #define MAX_DMA_ADDRESS			0xffffffff
 
+#include "edma.h"
+
 #endif /* __ASM_ARCH_DMA_H */
drivers/i2c/busses/i2c-davinci.c +24 -0
Index: linux-2.6.24.rc8.alsa/drivers/i2c/busses/i2c-davinci.c
===================================================================
@@ -41,6 +41,11 @@
 
 #include <asm/arch/i2c.h>
 
+/* Hack to enable zero length transfers and smbus quick until clean fix
+ * is available
+ */
+#define DAVINCI_HACK
+
 /* ----- global defines ----------------------------------------------- */
 
 #define DAVINCI_I2C_TIMEOUT	(1*HZ)
@@ -236,9 +241,14 @@ i2c_davinci_xfer_msg(struct i2c_adapter 
 	u32 stat;
 	u16 w;
 	int r;
+#ifdef DAVINCI_HACK
+	u8 zero_byte = 0;
+#endif
 
+#ifndef DAVINCI_HACK
 	if (msg->len == 0)
 		return -EINVAL;
+#endif
 
 	if (!pdata)
 		pdata = &davinci_i2c_platform_data_default;
@@ -249,8 +259,18 @@ i2c_davinci_xfer_msg(struct i2c_adapter 
 	/* set the slave address */
 	davinci_i2c_write_reg(dev, DAVINCI_I2C_SAR_REG, msg->addr);
 
+#ifndef DAVINCI_HACK
 	dev->buf = msg->buf;
 	dev->buf_len = msg->len;
+#else
+	if (msg->len == 0) {
+		dev->buf = &zero_byte;
+		dev->buf_len = 1;
+	} else {
+		dev->buf = msg->buf;
+		dev->buf_len = msg->len;
+	}
+#endif
 
 	davinci_i2c_write_reg(dev, DAVINCI_I2C_CNT_REG, dev->buf_len);
 
@@ -349,7 +369,11 @@ i2c_davinci_xfer(struct i2c_adapter *ada
 
 static u32 i2c_davinci_func(struct i2c_adapter *adap)
 {
+#ifndef DAVINCI_HACK
 	return I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL & ~I2C_FUNC_SMBUS_QUICK);
+#else
+	return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
+#endif
 }
 
 /*

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#3 lore raw

Hi, Vova

I've tried Davinci git tree and had the same compilation errors as with upstream 2.6.26-rc6.

Felix.

Quoted 109 lines · Vova Barinov

Hi Freix,

I see that you use upstream kernel but you should use now davinci git tree that at 2.6.26-rc5.
I'm not familiar with it's current status. Kevin Hilman is a maintainer and possible that he can answer about ASoC support there and about Davinci upstream status too.
FYI: I can't see that Davinci DMA used in Davinci PCM is not in git tree. Not sure but possible that Kevin adapted ASoC for git DMA stuff. You can try the attached required patch that was sent to arm-linux mailing list some time ago and patch for i2c hack that is needed for Davinici but is not acceptable upstream.

Also I'm no more with MV. So have nothing access to h/w.

Vladimir

Quoted 91 lines · Liam Girdwood
Quoted 75 lines · Felix Radensky

Hi,

I wanted to test Davinci ASoC driver on Davinci EVM evaluation board, but encountered the following compilation errors:

CC sound/soc/codecs/tlv320aic3x.o
sound/soc/codecs/tlv320aic3x.c:1012: warning: 'aic3x_init' defined but not used

  LD      sound/soc/codecs/snd-soc-tlv320aic3x.o
  LD      sound/soc/codecs/built-in.o
  CC      sound/soc/davinci/davinci-i2s.o

sound/soc/davinci/davinci-i2s.c:402: warning: initialization from incompatible pointer type
CC sound/soc/davinci/davinci-pcm.o
sound/soc/davinci/davinci-pcm.c: In function `davinci_pcm_enqueue_dma':
sound/soc/davinci/davinci-pcm.c:99: error: implicit declaration of function davinci_set_dma_src_params' sound/soc/davinci/davinci-pcm.c:99: error: INCR' undeclared (first use in this function)
sound/soc/davinci/davinci-pcm.c:99: error: (Each undeclared identifier is reported only once sound/soc/davinci/davinci-pcm.c:99: error: for each function it appears in.)
sound/soc/davinci/davinci-pcm.c:99: error: `W8BIT' undeclared (first use in this function)
sound/soc/davinci/davinci-pcm.c:100: error: implicit declaration of function davinci_set_dma_dest_params' sound/soc/davinci/davinci-pcm.c:101: error: implicit declaration of function davinci_set_dma_src_index' sound/soc/davinci/davinci-pcm.c:102: error: implicit declaration of function davinci_set_dma_dest_index' sound/soc/davinci/davinci-pcm.c:103: error: implicit declaration of function davinci_set_dma_transfer_params' sound/soc/davinci/davinci-pcm.c:103: error: ASYNC' undeclared (first use in this function) sound/soc/davinci/davinci-pcm.c: In function davinci_pcm_dma_irq':
sound/soc/davinci/davinci-pcm.c:117: error: DMA_COMPLETE' undeclared (first use in this function) sound/soc/davinci/davinci-pcm.c: In function davinci_pcm_dma_request':
sound/soc/davinci/davinci-pcm.c:134: error: TCC_ANY' undeclared (first use in this function) sound/soc/davinci/davinci-pcm.c:143: error: implicit declaration of function davinci_request_dma' sound/soc/davinci/davinci-pcm.c:145: error: EVENTQ_0' undeclared (first use in this function) sound/soc/davinci/davinci-pcm.c:150: error: PARAM_ANY' undeclared (first use in this function) sound/soc/davinci/davinci-pcm.c:153: error: implicit declaration of function davinci_free_dma' sound/soc/davinci/davinci-pcm.c:158: error: implicit declaration of function davinci_dma_link_lch' sound/soc/davinci/davinci-pcm.c: In function `davinci_pcm_trigger':
sound/soc/davinci/davinci-pcm.c:174: error: implicit declaration of function davinci_start_dma' sound/soc/davinci/davinci-pcm.c:179: error: implicit declaration of function davinci_stop_dma'
sound/soc/davinci/davinci-pcm.c: In function `davinci_pcm_prepare':
sound/soc/davinci/davinci-pcm.c:194: error: storage size of 'temp' isn't known
sound/soc/davinci/davinci-pcm.c:200: error: implicit declaration of function davinci_get_dma_params' sound/soc/davinci/davinci-pcm.c:201: error: implicit declaration of function davinci_set_dma_params' sound/soc/davinci/davinci-pcm.c:194: warning: unused variable temp' sound/soc/davinci/davinci-pcm.c: In function davinci_pcm_pointer':
sound/soc/davinci/davinci-pcm.c:217: error: implicit declaration of function davinci_dma_getposition' sound/soc/davinci/davinci-pcm.c: In function davinci_pcm_close':
sound/soc/davinci/davinci-pcm.c:262: error: implicit declaration of function `davinci_dma_unlink_lch'
make[3]: *** [sound/soc/davinci/davinci-pcm.o] Error 1 make[2]: *** [sound/soc/davinci] Error 2
make[1]: *** [sound/soc] Error 2
make: *** [sound] Error 2

Quoted 2 lines

Are there plans to fix this before release of 2.6.26 ?

It looks like we are missing some DaVinci DMA definitions for audio. They are not anywhere in the current HEAD or in include/asm-arm/arch-davinci history.

Vladimir, is this something you could help with.

Thanks

Liam

#4 lore raw

Yes, unfortunately the DaVinci ASoC changes were done based on DMA work that is not yet available in DaVinci git or mainline.

A month or so back, I posted to the davinci list saying I have a branch available where folks can play with ASoC until I get the DMA merge sorted out. That branch is here[1], but has not been updated to the latest asoc-dev tree.

Kevin

[1] http://linux.omap.com/pipermail/davinci-linux-open-source/2008-April/006008.html

Quoted 118 lines · Felix Radensky

Hi, Vova

I've tried Davinci git tree and had the same compilation errors as with upstream 2.6.26-rc6.

Felix.

Quoted 110 lines · Vova Barinov

Hi Freix,

I see that you use upstream kernel but you should use now davinci git tree that at 2.6.26-rc5.
I'm not familiar with it's current status. Kevin Hilman is a maintainer and possible that he can answer about ASoC support there and about Davinci upstream status too.
FYI: I can't see that Davinci DMA used in Davinci PCM is not in git tree. Not sure but possible that Kevin adapted ASoC for git DMA stuff.
You can try the attached required patch that was sent to arm-linux mailing list some time ago and patch for i2c hack that is needed for Davinici but is not acceptable upstream.

Also I'm no more with MV. So have nothing access to h/w.

Vladimir

Quoted 91 lines · Liam Girdwood
Quoted 75 lines · Felix Radensky

Hi,

I wanted to test Davinci ASoC driver on Davinci EVM evaluation board, but encountered the following compilation errors:

CC sound/soc/codecs/tlv320aic3x.o
sound/soc/codecs/tlv320aic3x.c:1012: warning: 'aic3x_init' defined but not used

  LD      sound/soc/codecs/snd-soc-tlv320aic3x.o
  LD      sound/soc/codecs/built-in.o
  CC      sound/soc/davinci/davinci-i2s.o

sound/soc/davinci/davinci-i2s.c:402: warning: initialization from incompatible pointer type
CC sound/soc/davinci/davinci-pcm.o
sound/soc/davinci/davinci-pcm.c: In function `davinci_pcm_enqueue_dma':
sound/soc/davinci/davinci-pcm.c:99: error: implicit declaration of function davinci_set_dma_src_params' sound/soc/davinci/davinci-pcm.c:99: error: INCR' undeclared (first use in this function) sound/soc/davinci/davinci-pcm.c:99: error: (Each undeclared identifier is reported only once sound/soc/davinci/davinci-pcm.c:99: error: for each function it appears in.)
sound/soc/davinci/davinci-pcm.c:99: error: W8BIT' undeclared (first use in this function) sound/soc/davinci/davinci-pcm.c:100: error: implicit declaration of function davinci_set_dma_dest_params' sound/soc/davinci/davinci-pcm.c:101: error: implicit declaration of function davinci_set_dma_src_index' sound/soc/davinci/davinci-pcm.c:102: error: implicit declaration of function davinci_set_dma_dest_index' sound/soc/davinci/davinci-pcm.c:103: error: implicit declaration of function davinci_set_dma_transfer_params' sound/soc/davinci/davinci-pcm.c:103: error: ASYNC' undeclared (first use in this function) sound/soc/davinci/davinci-pcm.c: In function `davinci_pcm_dma_irq':
sound/soc/davinci/davinci-pcm.c:117: error: DMA_COMPLETE' undeclared (first use in this function) sound/soc/davinci/davinci-pcm.c: In function davinci_pcm_dma_request':
sound/soc/davinci/davinci-pcm.c:134: error: TCC_ANY' undeclared (first use in this function) sound/soc/davinci/davinci-pcm.c:143: error: implicit declaration of function davinci_request_dma' sound/soc/davinci/davinci-pcm.c:145: error: EVENTQ_0' undeclared (first use in this function) sound/soc/davinci/davinci-pcm.c:150: error: PARAM_ANY' undeclared (first use in this function) sound/soc/davinci/davinci-pcm.c:153: error: implicit declaration of function davinci_free_dma' sound/soc/davinci/davinci-pcm.c:158: error: implicit declaration of function davinci_dma_link_lch' sound/soc/davinci/davinci-pcm.c: In function `davinci_pcm_trigger':
sound/soc/davinci/davinci-pcm.c:174: error: implicit declaration of function davinci_start_dma' sound/soc/davinci/davinci-pcm.c:179: error: implicit declaration of function davinci_stop_dma' sound/soc/davinci/davinci-pcm.c: In function `davinci_pcm_prepare':
sound/soc/davinci/davinci-pcm.c:194: error: storage size of 'temp' isn't known
sound/soc/davinci/davinci-pcm.c:200: error: implicit declaration of function davinci_get_dma_params' sound/soc/davinci/davinci-pcm.c:201: error: implicit declaration of function davinci_set_dma_params' sound/soc/davinci/davinci-pcm.c:194: warning: unused variable temp' sound/soc/davinci/davinci-pcm.c: In function davinci_pcm_pointer':
sound/soc/davinci/davinci-pcm.c:217: error: implicit declaration of function davinci_dma_getposition' sound/soc/davinci/davinci-pcm.c: In function davinci_pcm_close':
sound/soc/davinci/davinci-pcm.c:262: error: implicit declaration of function `davinci_dma_unlink_lch'
make[3]: *** [sound/soc/davinci/davinci-pcm.o] Error 1 make[2]: *** [sound/soc/davinci] Error 2
make[1]: *** [sound/soc] Error 2
make: *** [sound] Error 2

Quoted 2 lines

Are there plans to fix this before release of 2.6.26 ?

It looks like we are missing some DaVinci DMA definitions for audio. They are not anywhere in the current HEAD or in include/asm-arm/arch-davinci history.

Vladimir, is this something you could help with.

Thanks

Liam

#5 lore raw

At Mon, 23 Jun 2008 09:40:47 -0700,

Quoted 8 lines · Kevin Hilman

Yes, unfortunately the DaVinci ASoC changes were done based on DMA work that is not yet available in DaVinci git or mainline.

A month or so back, I posted to the davinci list saying I have a branch available where folks can play with ASoC until I get the DMA merge sorted out. That branch is here[1], but has not been updated to the latest asoc-dev tree.

Could you try to make it merged at least in the next kernel release?

thanks,

Takashi

Quoted 131 lines

Kevin

[1] http://linux.omap.com/pipermail/davinci-linux-open-source/2008-April/006008.html

Quoted 118 lines · Felix Radensky

Hi, Vova

I've tried Davinci git tree and had the same compilation errors as with upstream 2.6.26-rc6.

Felix.

Quoted 110 lines · Vova Barinov

Hi Freix,

I see that you use upstream kernel but you should use now davinci git tree that at 2.6.26-rc5.
I'm not familiar with it's current status. Kevin Hilman is a maintainer and possible that he can answer about ASoC support there and about Davinci upstream status too.
FYI: I can't see that Davinci DMA used in Davinci PCM is not in git tree. Not sure but possible that Kevin adapted ASoC for git DMA stuff.
You can try the attached required patch that was sent to arm-linux mailing list some time ago and patch for i2c hack that is needed for Davinici but is not acceptable upstream.

Also I'm no more with MV. So have nothing access to h/w.

Vladimir

Quoted 91 lines · Liam Girdwood
Quoted 75 lines · Felix Radensky

Hi,

I wanted to test Davinci ASoC driver on Davinci EVM evaluation board, but encountered the following compilation errors:

CC sound/soc/codecs/tlv320aic3x.o
sound/soc/codecs/tlv320aic3x.c:1012: warning: 'aic3x_init' defined but not used

  LD      sound/soc/codecs/snd-soc-tlv320aic3x.o
  LD      sound/soc/codecs/built-in.o
  CC      sound/soc/davinci/davinci-i2s.o

sound/soc/davinci/davinci-i2s.c:402: warning: initialization from incompatible pointer type
CC sound/soc/davinci/davinci-pcm.o
sound/soc/davinci/davinci-pcm.c: In function `davinci_pcm_enqueue_dma':
sound/soc/davinci/davinci-pcm.c:99: error: implicit declaration of function davinci_set_dma_src_params' sound/soc/davinci/davinci-pcm.c:99: error: INCR' undeclared (first use in this function) sound/soc/davinci/davinci-pcm.c:99: error: (Each undeclared identifier is reported only once sound/soc/davinci/davinci-pcm.c:99: error: for each function it appears in.)
sound/soc/davinci/davinci-pcm.c:99: error: W8BIT' undeclared (first use in this function) sound/soc/davinci/davinci-pcm.c:100: error: implicit declaration of function davinci_set_dma_dest_params' sound/soc/davinci/davinci-pcm.c:101: error: implicit declaration of function davinci_set_dma_src_index' sound/soc/davinci/davinci-pcm.c:102: error: implicit declaration of function davinci_set_dma_dest_index' sound/soc/davinci/davinci-pcm.c:103: error: implicit declaration of function davinci_set_dma_transfer_params' sound/soc/davinci/davinci-pcm.c:103: error: ASYNC' undeclared (first use in this function) sound/soc/davinci/davinci-pcm.c: In function `davinci_pcm_dma_irq':
sound/soc/davinci/davinci-pcm.c:117: error: DMA_COMPLETE' undeclared (first use in this function) sound/soc/davinci/davinci-pcm.c: In function davinci_pcm_dma_request':
sound/soc/davinci/davinci-pcm.c:134: error: TCC_ANY' undeclared (first use in this function) sound/soc/davinci/davinci-pcm.c:143: error: implicit declaration of function davinci_request_dma' sound/soc/davinci/davinci-pcm.c:145: error: EVENTQ_0' undeclared (first use in this function) sound/soc/davinci/davinci-pcm.c:150: error: PARAM_ANY' undeclared (first use in this function) sound/soc/davinci/davinci-pcm.c:153: error: implicit declaration of function davinci_free_dma' sound/soc/davinci/davinci-pcm.c:158: error: implicit declaration of function davinci_dma_link_lch' sound/soc/davinci/davinci-pcm.c: In function `davinci_pcm_trigger':
sound/soc/davinci/davinci-pcm.c:174: error: implicit declaration of function davinci_start_dma' sound/soc/davinci/davinci-pcm.c:179: error: implicit declaration of function davinci_stop_dma' sound/soc/davinci/davinci-pcm.c: In function `davinci_pcm_prepare':
sound/soc/davinci/davinci-pcm.c:194: error: storage size of 'temp' isn't known
sound/soc/davinci/davinci-pcm.c:200: error: implicit declaration of function davinci_get_dma_params' sound/soc/davinci/davinci-pcm.c:201: error: implicit declaration of function davinci_set_dma_params' sound/soc/davinci/davinci-pcm.c:194: warning: unused variable temp' sound/soc/davinci/davinci-pcm.c: In function davinci_pcm_pointer':
sound/soc/davinci/davinci-pcm.c:217: error: implicit declaration of function davinci_dma_getposition' sound/soc/davinci/davinci-pcm.c: In function davinci_pcm_close':
sound/soc/davinci/davinci-pcm.c:262: error: implicit declaration of function `davinci_dma_unlink_lch'
make[3]: *** [sound/soc/davinci/davinci-pcm.o] Error 1 make[2]: *** [sound/soc/davinci] Error 2
make[1]: *** [sound/soc] Error 2
make: *** [sound] Error 2

Quoted 2 lines

Are there plans to fix this before release of 2.6.26 ?

It looks like we are missing some DaVinci DMA definitions for audio. They are not anywhere in the current HEAD or in include/asm-arm/arch-davinci history.

Vladimir, is this something you could help with.

Thanks

Liam

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel