Permalink
Browse files

Unify interrupt functions, working.

Signed-off-by: Joel A Fernandes <joelagnel@ti.com>
  • Loading branch information...
1 parent e929ae7 commit be03b29aafbcd388e87a2eb5640212b1d4f8666b Joel A Fernandes committed Nov 18, 2011
Showing with 45 additions and 84 deletions.
  1. +42 −1 drivers/usb/musb/cppi41_dma.c
  2. +2 −0 drivers/usb/musb/cppi41_dma.h
  3. +1 −83 drivers/usb/musb/ti81xx.c
@@ -1288,6 +1288,47 @@ void txdma_completion_work(struct work_struct *data)
spin_unlock_irqrestore(&musb->lock, flags);
}
+void cppi41_handle_txfifo(struct musb *musb, u16 ep_mask) {
+
+ int ep_num = 1;
+ struct cppi41 *cppi;
+ struct musb_hw_ep *hw_ep;
+ struct cppi41_channel *cppi_channel;
+
+ cppi = container_of(musb->dma_controller, struct cppi41, controller);
+
+ ep_mask = ep_mask >> 1; /* Skip endpoint 0 */
+
+ while(ep_mask) {
+ void __iomem *epio;
+ u16 csr;
+
+ if(ep_mask & 0x1) {
+ hw_ep = &musb->endpoints[ep_num];
+ cppi_channel = container_of(hw_ep->tx_channel, struct cppi41_channel, channel);
+ if(!cppi_channel->tx_complete) {
+ schedule_work(&cppi->txdma_work);
+ schedule_work(&musb->txfifo_work);
+ dev_dbg(musb->controller, "INTERRUPT: cppi_channel->tx not complete for ep %d\n", ep_num);
+ }
+ else {
+ cppi_channel->tx_complete = 0;
+ epio = hw_ep->regs;
+ csr = musb_readw(epio, MUSB_TXCSR);
+
+ if ( !(csr & (MUSB_TXCSR_TXPKTRDY |
+ MUSB_TXCSR_FIFONOTEMPTY)) ) {
+ dev_dbg(musb->controller, "INTERRUPT: musb_dma_complete(%p, %d, 1) TXCSR: %x\n", musb, ep_num, csr);
+ musb_dma_completion(musb, ep_num, 1);
+ }
+ dev_dbg(musb->controller, "INTERRUPT: handling txfifo from interrupt for ep %d\n", ep_num);
+ }
+ }
+ ep_mask = ep_mask >> 1;
+ ep_num++;
+ }
+}
+
/**
* cppi41_dma_controller_create -
* instantiate an object representing DMA controller.
@@ -1311,7 +1352,7 @@ cppi41_dma_controller_create(struct musb *musb, void __iomem *mregs)
cppi->controller.channel_abort = cppi41_channel_abort;
cppi->cppi_info = (struct usb_cppi41_info *)&usb_cppi41_info[musb->id];;
cppi->en_bd_intr = cppi->cppi_info->bd_intr_ctrl;
- // INIT_WORK(&cppi->txdma_work, txdma_completion_work);
+ INIT_WORK(&cppi->txdma_work, txdma_completion_work);
/* enable infinite mode only for ti81xx silicon rev2 */
if (cpu_is_am33xx() || cpu_is_ti816x()) {
@@ -52,6 +52,8 @@ extern struct usb_cppi41_info usb_cppi41_info[];
*/
void cppi41_completion(struct musb *musb, u32 rx, u32 tx);
+void cppi41_handle_txfifo(struct musb *musb, u16 ep_mask);
+
/**
* struct cppi41_channel - DMA Channel Control Structure
*
View
@@ -818,87 +818,6 @@ static void evm_deferred_musb_restart(struct work_struct *work)
musb_babble_workaround(musb);
}
-/* Called with musb lock held from interrupt context */
-void ti81xx_txfifo(struct musb *musb, int ep_num) {
- struct musb_hw_ep *hw_ep;
- void __iomem *epio;
- u16 csr;
-
- hw_ep = &musb->endpoints[ep_num];
- epio = hw_ep->regs;
- csr = musb_readw(epio, MUSB_TXCSR);
-
- if ( !(csr & (MUSB_TXCSR_TXPKTRDY |
- MUSB_TXCSR_FIFONOTEMPTY)) ) {
- dev_dbg(musb->controller, "INTERRUPT: musb_dma_complete(%p, %d, 1) TXCSR: %x\n", musb, ep_num, csr);
- musb_dma_completion(musb, ep_num, 1);
- }
- return;
-}
-
-void ti81xx_handle_txfifo(struct musb *musb, u16 ep_mask) {
-
- int ep_num = 1;
- struct musb_hw_ep *hw_ep;
- struct cppi41_channel *cppi_channel;
-
- ep_mask = ep_mask >> 1; /* Skip endpoint 0 */
-
- while(ep_mask) {
- if(ep_mask & 0x1) {
- hw_ep = &musb->endpoints[ep_num];
- cppi_channel = container_of(hw_ep->tx_channel, struct cppi41_channel, channel);
- if(!cppi_channel->tx_complete) {
- schedule_work(&musb->txfifo_work);
- dev_dbg(musb->controller, "INTERRUPT: cppi_channel->tx not complete for ep %d\n", ep_num);
- }
- else {
- cppi_channel->tx_complete = 0;
- ti81xx_txfifo(musb, ep_num);
- dev_dbg(musb->controller, "INTERRUPT: handling txfifo from interrupt for ep %d\n", ep_num);
- }
- }
- ep_mask = ep_mask >> 1;
- ep_num++;
- }
-}
-
-void ti81xx_txfifo_work(struct work_struct *data) {
- struct musb *musb = container_of(data, struct musb, txfifo_work);
- unsigned long flags;
- unsigned index;
- struct musb_hw_ep *hw_ep;
- struct cppi41_channel *cppi_channel;
-
- spin_lock_irqsave(&musb->lock, flags);
- for (index = 1; index < MUSB_C_NUM_EPS; index++) {
- void __iomem *epio;
- u16 csr;
-
- hw_ep = &musb->endpoints[index];
-
- cppi_channel = container_of(hw_ep->tx_channel, struct cppi41_channel, channel);
- if(!cppi_channel)
- continue;
- if(cppi_channel->tx_complete) {
- epio = hw_ep->regs;
- csr = musb_readw(epio, MUSB_TXCSR);
-
- if ( !(csr & (MUSB_TXCSR_TXPKTRDY |
- MUSB_TXCSR_FIFONOTEMPTY)) ) {
- cppi_channel->tx_complete = 0;
- dev_dbg(musb->controller, "FROM WORKER: musb_dma_complete(%p, %d, 1) TXCSR: %x\n", musb, index, csr);
- musb_dma_completion(musb, index, 1);
- }
- else {
- schedule_work(&musb->txfifo_work);
- }
- }
- }
- spin_unlock_irqrestore(&musb->lock, flags);
- return;
-}
-
static irqreturn_t ti81xx_interrupt(int irq, void *hci)
{
struct musb *musb = hci;
@@ -934,7 +853,7 @@ static irqreturn_t ti81xx_interrupt(int irq, void *hci)
// printk("usbintr (%x) epintr(%x) musb->id(%d)\n", usbintr, epintr, musb->id);
if(usbintr & USB_INTR_TXFIFO_MASK) {
- ti81xx_handle_txfifo(musb, usbintr >> 16);
+ cppi41_handle_txfifo(musb, usbintr >> 16);
ret = IRQ_HANDLED;
goto eoi;
}
@@ -1153,7 +1072,6 @@ int ti81xx_musb_init(struct musb *musb)
/* enable babble workaround */
INIT_WORK(&musb->work, evm_deferred_musb_restart);
- INIT_WORK(&musb->txfifo_work, ti81xx_txfifo_work);
musb->enable_babble_work = 1;

0 comments on commit be03b29

Please sign in to comment.