[PATCH 3/4] usb: musb: tusb6010: Add DMA Mode1 support for device mode RX

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: supriya karanth <supriya.karanth@xxxxxxxxxxxxxx>

Added support for enabling DMA Mode1. tusb will continue to
work in mode0. If needed DMA mode1 can be enabled

Signed-off-by: Supriya Karanth <supriya.karanth@xxxxxxxxxxxxxx>
Signed-off-by: Praveena NADAHALLY <praveen.nadahally@xxxxxxxxxxxxxx>
Acked-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
---
 drivers/usb/musb/tusb6010_omap.c |   67 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 67 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/musb/tusb6010_omap.c b/drivers/usb/musb/tusb6010_omap.c
index 98df17c..d0d5a38 100644
--- a/drivers/usb/musb/tusb6010_omap.c
+++ b/drivers/usb/musb/tusb6010_omap.c
@@ -452,6 +452,69 @@ static int tusb_omap_dma_abort(struct dma_channel *channel)
 	return 0;
 }
 
+
+static int tusb_omap_dma_pause(struct dma_channel *channel)
+{
+	struct tusb_omap_dma_ch	*chdat = to_chdat(channel);
+	struct tusb_omap_dma	*tusb_dma = chdat->tusb_dma;
+
+	if (!tusb_dma->multichannel) {
+		if (tusb_dma->ch >= 0)
+			omap_stop_dma(tusb_dma->ch);
+	}
+
+	return 0;
+}
+
+static int tusb_omap_dma_resume(struct dma_channel *channel)
+{
+	struct tusb_omap_dma_ch	*chdat = to_chdat(channel);
+	struct tusb_omap_dma	*tusb_dma = chdat->tusb_dma;
+
+	if (!tusb_dma->multichannel) {
+		if (tusb_dma->ch >= 0)
+			omap_start_dma(tusb_dma->ch);
+	}
+
+	return 0;
+}
+
+static int tusb_omap_dma_tx_status(struct dma_channel *channel)
+{
+	/* TODO
+	 * Get the residue of the transfer. Something similar to
+	 * omap_dma_tx_status in omap-dma.c
+	 */
+
+	return 0;
+}
+
+
+static int tusb_omap_dma_check_residue(struct dma_channel *channel, u32 residue)
+{
+	int status;
+	/* In cases where we know the transfer length and were expecting
+	 * a DMA completion we could get into the DMA busy condition
+	 * here if the next packet is short and the EP interrupt occurs
+	 * before we recieve dma_completion interrupt for current transfer
+	 * Wait for dma_completion. MUSB will interrupt us again for this
+	 * short packet when we clear the DMA bits
+	 */
+	if (!residue) {
+		/* Wait for DMA completion */
+		status = -EINPROGRESS;
+	} else if (residue == channel->prog_len) {
+		/* Nothing transferred over DMA? */
+		WARN_ON(1);
+		status = -EINVAL;
+	} else {
+		/* residue looks OK */
+		status = 0;
+	}
+
+	return status;
+}
+
 static inline int tusb_omap_dma_allocate_dmareq(struct tusb_omap_dma_ch *chdat)
 {
 	u32		reg = musb_readl(chdat->tbase, TUSB_DMA_EP_MAP);
@@ -701,6 +764,10 @@ struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *ba
 	tusb_dma->controller.channel_release = tusb_omap_dma_release;
 	tusb_dma->controller.channel_program = tusb_omap_dma_program;
 	tusb_dma->controller.channel_abort = tusb_omap_dma_abort;
+	tusb_dma->controller.channel_pause = tusb_omap_dma_pause;
+	tusb_dma->controller.channel_resume = tusb_omap_dma_resume;
+	tusb_dma->controller.tx_status = tusb_omap_dma_tx_status;
+	tusb_dma->controller.check_residue = tusb_omap_dma_check_residue;
 
 	if (tusb_get_revision(musb) >= TUSB_REV_30)
 		tusb_dma->multichannel = 1;
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux