Lines Matching full:counter
38 static void ni_tio_configure_dma(struct ni_gpct *counter, in ni_tio_configure_dma() argument
41 struct ni_gpct_device *counter_dev = counter->counter_dev; in ni_tio_configure_dma()
42 unsigned int cidx = counter->counter_index; in ni_tio_configure_dma()
55 ni_tio_set_bits(counter, NITIO_INPUT_SEL_REG(cidx), mask, bits); in ni_tio_configure_dma()
69 ni_tio_set_bits(counter, NITIO_DMA_CFG_REG(cidx), mask, bits); in ni_tio_configure_dma()
78 struct ni_gpct *counter = s->private; in ni_tio_input_inttrig() local
86 spin_lock_irqsave(&counter->lock, flags); in ni_tio_input_inttrig()
87 if (counter->mite_chan) in ni_tio_input_inttrig()
88 mite_dma_arm(counter->mite_chan); in ni_tio_input_inttrig()
91 spin_unlock_irqrestore(&counter->lock, flags); in ni_tio_input_inttrig()
94 ret = ni_tio_arm(counter, true, NI_GPCT_ARM_IMMEDIATE); in ni_tio_input_inttrig()
102 struct ni_gpct *counter = s->private; in ni_tio_input_cmd() local
103 struct ni_gpct_device *counter_dev = counter->counter_dev; in ni_tio_input_cmd()
106 unsigned int cidx = counter->counter_index; in ni_tio_input_cmd()
113 counter->mite_chan->dir = COMEDI_INPUT; in ni_tio_input_cmd()
117 mite_prep_dma(counter->mite_chan, 32, 32); in ni_tio_input_cmd()
120 mite_prep_dma(counter->mite_chan, 16, 32); in ni_tio_input_cmd()
123 ni_tio_set_bits(counter, NITIO_CMD_REG(cidx), GI_SAVE_TRACE, 0); in ni_tio_input_cmd()
124 ni_tio_configure_dma(counter, true, true); in ni_tio_input_cmd()
130 mite_dma_arm(counter->mite_chan); in ni_tio_input_cmd()
133 ret = ni_tio_arm(counter, true, NI_GPCT_ARM_IMMEDIATE); in ni_tio_input_cmd()
145 ret = ni_tio_arm(counter, true, reg); in ni_tio_input_cmd()
153 struct ni_gpct *counter = s->private; in ni_tio_output_cmd() local
155 dev_err(counter->counter_dev->dev->class_dev, in ni_tio_output_cmd()
163 struct ni_gpct *counter = s->private; in ni_tio_cmd_setup() local
164 unsigned int cidx = counter->counter_index; in ni_tio_cmd_setup()
166 counter->counter_dev->routing_tables; in ni_tio_cmd_setup()
186 retval = ni_tio_set_gate_src_raw(counter, 0, reg); in ni_tio_cmd_setup()
193 retval = ni_tio_set_gate_src(counter, 0, gate_source); in ni_tio_cmd_setup()
197 ni_tio_set_bits(counter, NITIO_INT_ENA_REG(cidx), in ni_tio_cmd_setup()
206 struct ni_gpct *counter = s->private; in ni_tio_cmd() local
212 spin_lock_irqsave(&counter->lock, flags); in ni_tio_cmd()
213 if (!counter->mite_chan) { in ni_tio_cmd()
214 dev_err(counter->counter_dev->dev->class_dev, in ni_tio_cmd()
216 dev_err(counter->counter_dev->dev->class_dev, in ni_tio_cmd()
228 spin_unlock_irqrestore(&counter->lock, flags); in ni_tio_cmd()
237 struct ni_gpct *counter = s->private; in ni_tio_cmdtest() local
238 unsigned int cidx = counter->counter_index; in ni_tio_cmdtest()
240 counter->counter_dev->routing_tables; in ni_tio_cmdtest()
247 if (ni_tio_counting_mode_registers_present(counter->counter_dev)) in ni_tio_cmdtest()
332 int ni_tio_cancel(struct ni_gpct *counter) in ni_tio_cancel() argument
334 unsigned int cidx = counter->counter_index; in ni_tio_cancel()
337 ni_tio_arm(counter, false, 0); in ni_tio_cancel()
338 spin_lock_irqsave(&counter->lock, flags); in ni_tio_cancel()
339 if (counter->mite_chan) in ni_tio_cancel()
340 mite_dma_disarm(counter->mite_chan); in ni_tio_cancel()
341 spin_unlock_irqrestore(&counter->lock, flags); in ni_tio_cancel()
342 ni_tio_configure_dma(counter, false, false); in ni_tio_cancel()
344 ni_tio_set_bits(counter, NITIO_INT_ENA_REG(cidx), in ni_tio_cancel()
350 static int should_ack_gate(struct ni_gpct *counter) in should_ack_gate() argument
355 switch (counter->counter_dev->variant) { in should_ack_gate()
365 * During buffered input counter operation for e-series, in should_ack_gate()
370 spin_lock_irqsave(&counter->lock, flags); in should_ack_gate()
372 if (!counter->mite_chan || in should_ack_gate()
373 counter->mite_chan->dir != COMEDI_INPUT || in should_ack_gate()
374 (mite_done(counter->mite_chan))) { in should_ack_gate()
378 spin_unlock_irqrestore(&counter->lock, flags); in should_ack_gate()
384 static void ni_tio_acknowledge_and_confirm(struct ni_gpct *counter, in ni_tio_acknowledge_and_confirm() argument
389 unsigned int cidx = counter->counter_index; in ni_tio_acknowledge_and_confirm()
390 const unsigned short gxx_status = ni_tio_read(counter, in ni_tio_acknowledge_and_confirm()
392 const unsigned short gi_status = ni_tio_read(counter, in ni_tio_acknowledge_and_confirm()
411 if (counter->counter_dev->variant != in ni_tio_acknowledge_and_confirm()
424 if (should_ack_gate(counter)) in ni_tio_acknowledge_and_confirm()
428 ni_tio_write(counter, ack, NITIO_INT_ACK_REG(cidx)); in ni_tio_acknowledge_and_confirm()
429 if (ni_tio_get_soft_copy(counter, NITIO_MODE_REG(cidx)) & in ni_tio_acknowledge_and_confirm()
431 if (ni_tio_read(counter, NITIO_STATUS2_REG(cidx)) & in ni_tio_acknowledge_and_confirm()
433 dev_info(counter->counter_dev->dev->class_dev, in ni_tio_acknowledge_and_confirm()
442 void ni_tio_acknowledge(struct ni_gpct *counter) in ni_tio_acknowledge() argument
444 ni_tio_acknowledge_and_confirm(counter, NULL, NULL, NULL); in ni_tio_acknowledge()
448 void ni_tio_handle_interrupt(struct ni_gpct *counter, in ni_tio_handle_interrupt() argument
451 unsigned int cidx = counter->counter_index; in ni_tio_handle_interrupt()
457 ni_tio_acknowledge_and_confirm(counter, &gate_error, &tc_error, in ni_tio_handle_interrupt()
460 dev_notice(counter->counter_dev->dev->class_dev, in ni_tio_handle_interrupt()
466 switch (counter->counter_dev->variant) { in ni_tio_handle_interrupt()
469 if (ni_tio_read(counter, NITIO_DMA_STATUS_REG(cidx)) & in ni_tio_handle_interrupt()
471 dev_notice(counter->counter_dev->dev->class_dev, in ni_tio_handle_interrupt()
479 spin_lock_irqsave(&counter->lock, flags); in ni_tio_handle_interrupt()
480 if (counter->mite_chan) in ni_tio_handle_interrupt()
481 mite_ack_linkc(counter->mite_chan, s, true); in ni_tio_handle_interrupt()
482 spin_unlock_irqrestore(&counter->lock, flags); in ni_tio_handle_interrupt()
486 void ni_tio_set_mite_channel(struct ni_gpct *counter, in ni_tio_set_mite_channel() argument
491 spin_lock_irqsave(&counter->lock, flags); in ni_tio_set_mite_channel()
492 counter->mite_chan = mite_chan; in ni_tio_set_mite_channel()
493 spin_unlock_irqrestore(&counter->lock, flags); in ni_tio_set_mite_channel()