Lines Matching refs:mite_chan
215 static u32 mite_device_bytes_transferred(struct mite_channel *mite_chan) in mite_device_bytes_transferred() argument
217 struct mite *mite = mite_chan->mite; in mite_device_bytes_transferred()
219 return readl(mite->mmio + MITE_DAR(mite_chan->channel)); in mite_device_bytes_transferred()
226 u32 mite_bytes_in_transit(struct mite_channel *mite_chan) in mite_bytes_in_transit() argument
228 struct mite *mite = mite_chan->mite; in mite_bytes_in_transit()
230 return readl(mite->mmio + MITE_FCR(mite_chan->channel)) & 0xff; in mite_bytes_in_transit()
235 static u32 mite_bytes_written_to_memory_lb(struct mite_channel *mite_chan) in mite_bytes_written_to_memory_lb() argument
239 device_byte_count = mite_device_bytes_transferred(mite_chan); in mite_bytes_written_to_memory_lb()
240 return device_byte_count - mite_bytes_in_transit(mite_chan); in mite_bytes_written_to_memory_lb()
244 static u32 mite_bytes_written_to_memory_ub(struct mite_channel *mite_chan) in mite_bytes_written_to_memory_ub() argument
248 in_transit_count = mite_bytes_in_transit(mite_chan); in mite_bytes_written_to_memory_ub()
249 return mite_device_bytes_transferred(mite_chan) - in_transit_count; in mite_bytes_written_to_memory_ub()
253 static u32 mite_bytes_read_from_memory_lb(struct mite_channel *mite_chan) in mite_bytes_read_from_memory_lb() argument
257 device_byte_count = mite_device_bytes_transferred(mite_chan); in mite_bytes_read_from_memory_lb()
258 return device_byte_count + mite_bytes_in_transit(mite_chan); in mite_bytes_read_from_memory_lb()
262 static u32 mite_bytes_read_from_memory_ub(struct mite_channel *mite_chan) in mite_bytes_read_from_memory_ub() argument
266 in_transit_count = mite_bytes_in_transit(mite_chan); in mite_bytes_read_from_memory_ub()
267 return mite_device_bytes_transferred(mite_chan) + in_transit_count; in mite_bytes_read_from_memory_ub()
270 static void mite_sync_input_dma(struct mite_channel *mite_chan, in mite_sync_input_dma() argument
281 nbytes = mite_bytes_written_to_memory_lb(mite_chan); in mite_sync_input_dma()
282 if ((int)(mite_bytes_written_to_memory_ub(mite_chan) - in mite_sync_input_dma()
302 static void mite_sync_output_dma(struct mite_channel *mite_chan, in mite_sync_output_dma() argument
315 nbytes_lb = mite_bytes_read_from_memory_lb(mite_chan); in mite_sync_output_dma()
318 nbytes_ub = mite_bytes_read_from_memory_ub(mite_chan); in mite_sync_output_dma()
351 void mite_sync_dma(struct mite_channel *mite_chan, struct comedi_subdevice *s) in mite_sync_dma() argument
353 if (mite_chan->dir == COMEDI_INPUT) in mite_sync_dma()
354 mite_sync_input_dma(mite_chan, s); in mite_sync_dma()
356 mite_sync_output_dma(mite_chan, s); in mite_sync_dma()
360 static unsigned int mite_get_status(struct mite_channel *mite_chan) in mite_get_status() argument
362 struct mite *mite = mite_chan->mite; in mite_get_status()
367 status = readl(mite->mmio + MITE_CHSR(mite_chan->channel)); in mite_get_status()
369 mite_chan->done = 1; in mite_get_status()
371 mite->mmio + MITE_CHOR(mite_chan->channel)); in mite_get_status()
385 void mite_ack_linkc(struct mite_channel *mite_chan, in mite_ack_linkc() argument
389 struct mite *mite = mite_chan->mite; in mite_ack_linkc()
392 status = mite_get_status(mite_chan); in mite_ack_linkc()
394 writel(CHOR_CLRLC, mite->mmio + MITE_CHOR(mite_chan->channel)); in mite_ack_linkc()
398 mite_sync_dma(mite_chan, s); in mite_ack_linkc()
414 int mite_done(struct mite_channel *mite_chan) in mite_done() argument
416 struct mite *mite = mite_chan->mite; in mite_done()
420 mite_get_status(mite_chan); in mite_done()
422 done = mite_chan->done; in mite_done()
428 static void mite_dma_reset(struct mite_channel *mite_chan) in mite_dma_reset() argument
431 mite_chan->mite->mmio + MITE_CHOR(mite_chan->channel)); in mite_dma_reset()
438 void mite_dma_arm(struct mite_channel *mite_chan) in mite_dma_arm() argument
440 struct mite *mite = mite_chan->mite; in mite_dma_arm()
449 mite_chan->done = 0; in mite_dma_arm()
451 writel(CHOR_START, mite->mmio + MITE_CHOR(mite_chan->channel)); in mite_dma_arm()
460 void mite_dma_disarm(struct mite_channel *mite_chan) in mite_dma_disarm() argument
462 struct mite *mite = mite_chan->mite; in mite_dma_disarm()
465 writel(CHOR_ABORT, mite->mmio + MITE_CHOR(mite_chan->channel)); in mite_dma_disarm()
475 void mite_prep_dma(struct mite_channel *mite_chan, in mite_prep_dma() argument
478 struct mite *mite = mite_chan->mite; in mite_prep_dma()
481 mite_dma_reset(mite_chan); in mite_prep_dma()
505 if (mite_chan->dir == COMEDI_INPUT) in mite_prep_dma()
508 writel(chcr, mite->mmio + MITE_CHCR(mite_chan->channel)); in mite_prep_dma()
526 writel(mcr, mite->mmio + MITE_MCR(mite_chan->channel)); in mite_prep_dma()
530 dcr |= CR_PORTIO | CR_AMDEVICE | mite_drq_reqs(mite_chan->channel); in mite_prep_dma()
545 writel(dcr, mite->mmio + MITE_DCR(mite_chan->channel)); in mite_prep_dma()
548 writel(0, mite->mmio + MITE_DAR(mite_chan->channel)); in mite_prep_dma()
552 writel(lkcr, mite->mmio + MITE_LKCR(mite_chan->channel)); in mite_prep_dma()
555 writel(mite_chan->ring->dma_addr, in mite_prep_dma()
556 mite->mmio + MITE_LKAR(mite_chan->channel)); in mite_prep_dma()
572 struct mite_channel *mite_chan = NULL; in mite_request_channel_in_range() local
582 mite_chan = &mite->channels[i]; in mite_request_channel_in_range()
583 if (!mite_chan->ring) { in mite_request_channel_in_range()
584 mite_chan->ring = ring; in mite_request_channel_in_range()
587 mite_chan = NULL; in mite_request_channel_in_range()
590 return mite_chan; in mite_request_channel_in_range()
611 void mite_release_channel(struct mite_channel *mite_chan) in mite_release_channel() argument
613 struct mite *mite = mite_chan->mite; in mite_release_channel()
618 if (mite_chan->ring) { in mite_release_channel()
619 mite_dma_disarm(mite_chan); in mite_release_channel()
620 mite_dma_reset(mite_chan); in mite_release_channel()
629 mite->mmio + MITE_CHCR(mite_chan->channel)); in mite_release_channel()
630 mite_chan->ring = NULL; in mite_release_channel()