From: Frank Mori Hess Date: Tue, 24 Jul 2007 19:45:09 +0000 (+0000) Subject: Added mite_done() query to ask if mite channel is currently running, X-Git-Tag: r0_7_74~35 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=11358bb1221b5841349c371f0b06129c629ec784;p=comedi.git Added mite_done() query to ask if mite channel is currently running, handle CHSR_DONE in mite.c now (in mite_get_status() in particular). --- diff --git a/comedi/drivers/mite.c b/comedi/drivers/mite.c index 6da64c8f..46df1877 100644 --- a/comedi/drivers/mite.c +++ b/comedi/drivers/mite.c @@ -91,6 +91,7 @@ void mite_init(void) { mite->channels[i].mite = mite; mite->channels[i].channel = i; + mite->channels[i].done = 1; } mite->next=mite_devices; mite_devices=mite; @@ -284,6 +285,7 @@ void mite_dma_arm(struct mite_channel *mite_chan) { struct mite_struct *mite = mite_chan->mite; int chor; + unsigned long flags; MDPRINTK("mite_dma_arm ch%i\n", channel); /* memory barrier is intended to insure any twiddling with the buffer @@ -291,7 +293,11 @@ void mite_dma_arm(struct mite_channel *mite_chan) smp_mb(); /* arm */ chor = CHOR_START; + comedi_spin_lock_irqsave(&mite->lock, flags); + mite_chan->done = 0; writel(chor, mite->mite_io_addr + MITE_CHOR(mite_chan->channel)); + mmiowb(); + comedi_spin_unlock_irqrestore(&mite->lock, flags); // mite_dma_tcr(mite, channel); } @@ -571,6 +577,36 @@ int mite_sync_output_dma(struct mite_channel *mite_chan, comedi_async *async) return 0; } +unsigned mite_get_status(struct mite_channel *mite_chan) +{ + struct mite_struct *mite = mite_chan->mite; + unsigned status; + unsigned long flags; + + comedi_spin_lock_irqsave(&mite->lock, flags); + status = readl(mite->mite_io_addr + MITE_CHSR(mite_chan->channel)); + if(status & CHSR_DONE) + { + mite_chan->done = 1; + writel(CHOR_CLRDONE, mite->mite_io_addr + MITE_CHOR(mite_chan->channel)); + } + mmiowb(); + comedi_spin_unlock_irqrestore(&mite->lock, flags); + return status; +} + +int mite_done(const struct mite_channel *mite_chan) +{ + struct mite_struct *mite = mite_chan->mite; + unsigned long flags; + int done; + + comedi_spin_lock_irqsave(&mite->lock, flags); + done = mite_chan->done; + comedi_spin_unlock_irqrestore(&mite->lock, flags); + return done; +} + #ifdef DEBUG_MITE static void mite_decode(char **bit_str, unsigned int bits); @@ -737,6 +773,8 @@ EXPORT_SYMBOL(mite_bytes_written_to_memory_ub); EXPORT_SYMBOL(mite_bytes_read_from_memory_lb); EXPORT_SYMBOL(mite_bytes_read_from_memory_ub); EXPORT_SYMBOL(mite_bytes_in_transit); +EXPORT_SYMBOL(mite_get_status); +EXPORT_SYMBOL(mite_done); #ifdef DEBUG_MITE EXPORT_SYMBOL(mite_decode); EXPORT_SYMBOL(mite_dump_regs); diff --git a/comedi/drivers/mite.h b/comedi/drivers/mite.h index df9ff1c7..90085f84 100644 --- a/comedi/drivers/mite.h +++ b/comedi/drivers/mite.h @@ -76,6 +76,7 @@ struct mite_channel{ struct mite_struct *mite; unsigned channel; int dir; + int done; struct mite_dma_descriptor_ring *ring; }; @@ -131,6 +132,8 @@ u32 mite_bytes_written_to_memory_ub(struct mite_channel *mite_chan); u32 mite_bytes_read_from_memory_lb(struct mite_channel *mite_chan); u32 mite_bytes_read_from_memory_ub(struct mite_channel *mite_chan); u32 mite_bytes_in_transit(struct mite_channel *mite_chan); +unsigned mite_get_status(struct mite_channel *mite_chan); +int mite_done(const struct mite_channel *mite_chan); #if 0 unsigned long mite_ll_from_kvmem(struct mite_struct *mite,comedi_async *async,int len); @@ -427,12 +430,5 @@ static inline void mite_dma_reset(struct mite_channel *mite_chan) writel(CHOR_DMARESET | CHOR_FRESET, mite_chan->mite->mite_io_addr + MITE_CHOR(mite_chan->channel)); }; -static inline unsigned mite_get_status(struct mite_channel *mite_chan) -{ - struct mite_struct *mite = mite_chan->mite; - - return readl(mite->mite_io_addr + MITE_CHSR(mite_chan->channel)); -} - #endif diff --git a/comedi/drivers/ni_mio_common.c b/comedi/drivers/ni_mio_common.c index de9c653f..f415c18a 100644 --- a/comedi/drivers/ni_mio_common.c +++ b/comedi/drivers/ni_mio_common.c @@ -675,9 +675,9 @@ static irqreturn_t ni_E_interrupt(int irq, void *d PT_REGS_ARG) comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags_too); if(devpriv->ai_mite_chan) - ai_mite_status = readl(mite->mite_io_addr + MITE_CHSR(devpriv->ai_mite_chan->channel)); + ai_mite_status = mite_get_status(devpriv->ai_mite_chan); if(devpriv->ao_mite_chan) - ao_mite_status = readl(mite->mite_io_addr + MITE_CHSR(devpriv->ao_mite_chan->channel)); + ao_mite_status = mite_get_status(devpriv->ao_mite_chan); comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags_too); } g_status = devpriv->stc_readw(dev, G_Status_Register); @@ -842,15 +842,11 @@ static void handle_gpct_interrupt(comedi_device *dev, unsigned short counter_ind comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); return; } - gpct_mite_status = readl(mite_chan->mite->mite_io_addr + MITE_CHSR(mite_chan->channel)); + gpct_mite_status = mite_get_status(mite_chan); if(gpct_mite_status & CHSR_LINKC) { writel(CHOR_CLRLC, devpriv->mite->mite_io_addr + MITE_CHOR(mite_chan->channel)); } - if(gpct_mite_status & CHSR_DONE) - { - writel(CHOR_CLRDONE, devpriv->mite->mite_io_addr + MITE_CHOR(mite_chan->channel)); - } mite_sync_input_dma(mite_chan, s->async); comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); @@ -874,7 +870,7 @@ int should_ack_gate(comedi_device *dev, unsigned counter_index) if(mite_chan == NULL || mite_chan->dir != COMEDI_INPUT || - (mite_get_status(devpriv->counter_dev->counters[counter_index].mite_chan) & CHSR_DONE)) + (mite_done(devpriv->counter_dev->counters[counter_index].mite_chan))) { retval = 1; } @@ -935,16 +931,12 @@ static void handle_a_interrupt(comedi_device *dev, unsigned short status, ni_mio_print_status_a(status); #endif #ifdef PCIDMA - /* Currently, mite.c requires us to handle LINKC and DONE */ + /* Currently, mite.c requires us to handle LINKC */ if(ai_mite_status & CHSR_LINKC){ writel(CHOR_CLRLC, devpriv->mite->mite_io_addr + MITE_CHOR(devpriv->ai_mite_chan->channel)); ni_sync_ai_dma(dev); } - if(ai_mite_status & CHSR_DONE){ - writel(CHOR_CLRDONE, devpriv->mite->mite_io_addr + MITE_CHOR(devpriv->ai_mite_chan->channel)); - } - if(ai_mite_status & ~(CHSR_INT | CHSR_LINKC | CHSR_DONE | CHSR_MRDY | CHSR_DRDY | CHSR_DRQ1 | CHSR_DRQ0 | CHSR_ERROR | CHSR_SABORT | CHSR_XFERR | CHSR_LxERR_mask)){ rt_printk("unknown mite interrupt, ack! (ai_mite_status=%08x)\n", ai_mite_status); //mite_print_chsr(ai_mite_status); @@ -1077,15 +1069,11 @@ static void handle_b_interrupt(comedi_device *dev, unsigned short b_status, #endif #ifdef PCIDMA - /* Currently, mite.c requires us to handle LINKC and DONE */ + /* Currently, mite.c requires us to handle LINKC */ if(ao_mite_status & CHSR_LINKC){ mite_handle_b_linkc(devpriv->mite, dev); } - if(ao_mite_status & CHSR_DONE){ - writel(CHOR_CLRDONE, devpriv->mite->mite_io_addr + MITE_CHOR(devpriv->ao_mite_chan->channel)); - } - if(ao_mite_status & ~(CHSR_INT | CHSR_LINKC | CHSR_DONE | CHSR_MRDY | CHSR_DRDY | CHSR_DRQ1 | CHSR_DRQ0 | CHSR_ERROR | CHSR_SABORT | CHSR_XFERR | CHSR_LxERR_mask)){ rt_printk("unknown mite interrupt, ack! (ao_mite_status=%08x)\n", ao_mite_status); //mite_print_chsr(ao_mite_status); diff --git a/comedi/drivers/ni_pcidio.c b/comedi/drivers/ni_pcidio.c index f7b7de35..54ed99a4 100644 --- a/comedi/drivers/ni_pcidio.c +++ b/comedi/drivers/ni_pcidio.c @@ -513,7 +513,7 @@ static irqreturn_t nidio_interrupt(int irq, void *d PT_REGS_ARG) comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, irq_flags); if(devpriv->di_mite_chan) - m_status = readl(mite->mite_io_addr + MITE_CHSR(devpriv->di_mite_chan->channel)); + m_status = mite_get_status(devpriv->di_mite_chan); #ifdef MITE_DEBUG mite_print_chsr(m_status); #endif @@ -525,9 +525,6 @@ static irqreturn_t nidio_interrupt(int irq, void *d PT_REGS_ARG) mite_sync_input_dma(devpriv->di_mite_chan, s->async); /* XXX need to byteswap */ } - if(m_status & CHSR_DONE){ - writel(CHOR_CLRDONE, mite->mite_io_addr + MITE_CHOR(devpriv->di_mite_chan->channel)); - } if(m_status & ~(CHSR_INT | CHSR_LINKC | CHSR_DONE | CHSR_DRDY | CHSR_DRQ1 | CHSR_MRDY)){ DPRINTK("unknown mite interrupt, disabling IRQ\n"); async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;