Commit graph

6839 commits

Author SHA1 Message Date
H Hartley Sweeten 5081162d6c staging: comedi: adv_pci1724: use subdevice readback for 'gain_value'
Use the comedi_subdevice 'readback' member and the core provided (*insn_read)
to handle the readback of the write-only gain calib subdevice. Remove the
then unused 'gain_value' member from the private data.

The private data is now unnecessary. Remove it and the allocation.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:36:40 -08:00
H Hartley Sweeten 38020b55e7 staging: comedi: adv_pci1724: use subdevice readback for 'offset_value'
Use the comedi_subdevice 'readback' member and the core provided (*insn_read)
to handle the readback of the write-only offset calib subdevice. Remove the
then unused 'offset_value' member from the private data.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:36:40 -08:00
H Hartley Sweeten 388674e0a9 staging: comedi: adv_pci1724: use subdevice readback for 'ao_value'
Use the comedi_subdevice 'readback' member and the core provided (*insn_read)
to handle the readback of the write-only analog output subdevice. Remove the
then unused 'ao_value' member from the private data.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:36:40 -08:00
Marcus Hufvudsson 864b52c4ae staging: comedi: me4000: Fixed code style issue
Fixed checkpatch.pl error message. Space prohibited before that ','

Signed-off-by: Marcus Hufvudsson <marcushuf@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:35:24 -08:00
H Hartley Sweeten 1fe6a03ac8 staging: comedi: das6402: add (*do_cmd) for AI async commands
Flesh out the (*do_cmd) function to support timed analog input
acquisitions.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:35:24 -08:00
H Hartley Sweeten d1d24cb65e staging: comedi: das6402: read analog input samples in interrupt handler
Currently the interrupt handler just clears the interrupt.

Add the code necessary to read the analog input samples when running
an async command.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:35:24 -08:00
H Hartley Sweeten 3e0a738099 staging: comedi: das6402: introduce das6402_ai_set_mode()
Introduce a helper function to set the analog input acquisition mode.
This will be needed when the (*do_cmd) function is completed to support
async commands.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:35:24 -08:00
H Hartley Sweeten 594e400a2c staging: comedi: das6402: add basic (*do_cmdtest) for AI async commands
Currently the async command support in this driver consists of just the
stubbed in functions.

Flesh out the (*do_cmdtest) function for basic support of timed analog
input acquisitions.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:35:24 -08:00
Ian Abbott af57d89e16 staging: comedi: fix scan_end_arg == chanlist_len assumption
Some comedi drivers allow the `scan_end_arg` value of an asynchronous
command to be a multiple (> 1) of the `chanlist_len` although most
require them to be the same value.

`comedi_bytes_per_scan()` is incorrectly using `chanlist_len` as the
length of the scan.  Change it to use `scan_end_arg`.

`comedi_nsamples_left()` is incorrectly using `cur_chan` as the current
sample position in the scan (it is actually the current position in the
channel list).  Change it to use the actual sample position in the scan.
(Unfortunately we only have the current scan position in bytes currently,
so convert that to a sample position.)

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:35:24 -08:00
H Hartley Sweeten 921890b0d6 staging: comedi: dmm32at: update the MODULE_DESCRIPTION
Change the MODULE_DESCRIPTION to something more useful than the generic
"Comedi low-level driver".

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:33:25 -08:00
H Hartley Sweeten a26f3d3274 staging: comedi: dmm32at: tidy up multi-line comments
Reformat the multi-line comments for follow the CodingStyle.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:33:25 -08:00
H Hartley Sweeten fc7e1c0884 staging: comedi: dmm32at: rename DMM32AT_AIRBACK
For aesthetics, rename this define used for the Analog I/O Readback register.
Define the bits of the register.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:33:25 -08:00
H Hartley Sweeten 06d0ac3664 staging: comedi: dmm32at: rename DMM32AT_AICONF
For aesthetics, rename this define used for the Analog Configuration register.
Define the bits of the register.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:33:25 -08:00
H Hartley Sweeten bbf0a305fe staging: comedi: dmm32at: rename DMM32AT_CNTRDIO
For aesthetics, rename this define used for the Counter and Digital I/O
Configuration register. Define the bits of the register.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:33:25 -08:00
H Hartley Sweeten 990c96d15e staging: comedi: dmm32at: rename DMM32AT_INTCLOCK
For aesthetics, rename this define used for the Interrupt and A/D Clock Control
and Status register. Also, rename the defines for the bits of the register.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:33:25 -08:00
H Hartley Sweeten 4b82531e27 staging: comedi: dmm32at: rename DMM32AT_AISTAT
For aesthetics, rename this define used for the A/D Status register. Also,
rename the defines for the bits of the register.

The probe code in dmm32at_reset() checks this register to make sure the
S/D1 and S/D0 bits are set. This check actually verifies that the board is
configured (with jumpers on the board) with all the Analog Input channels
operating in single-ended mode. Add a comment about this.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:33:25 -08:00
H Hartley Sweeten d900a48841 staging: comedi: dmm32at: rename DMM32AT_CNTRL
For aesthetics, rename this define used for the Miscellaneous Control
register. Also, rename the defines for the bits of the register.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:33:25 -08:00
H Hartley Sweeten 7586f90784 staging: comedi: dmm32at: rename DMM32AT_FIFOSTAT
For aesthetics, rename this define used for the FIFO Status register.
Define the bits of the register.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:33:25 -08:00
H Hartley Sweeten b8c17c479a staging: comedi: dmm32at: rename DMM32AT_FIFOCNTRL
For aesthetics, rename this define used for the FIFO Control register.
Also, rename the defines used for the bits of this register.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:33:25 -08:00
H Hartley Sweeten d18f166773 staging: comedi: dmm32at: define the FIFO Depth register
This driver currently does not use the FIFO. For completeness, define
the offset to the FIFO Depth register.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:33:24 -08:00
H Hartley Sweeten e46f7651d0 staging: comedi: dmm32at: rename DMM32AT_DACMSB_CHAN
For aesthetics, rename this define used to set the DACH[10] bits in
the DAC MSB register to select the D/A channel.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:33:24 -08:00
H Hartley Sweeten 668a02d1c8 staging: comedi: dmm32at: rename DMM32AT_DACSTAT
For aesthetics, rename this define used for the Status / Auxillary Digital
Inputs register. Document the bits in the register.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:33:24 -08:00
H Hartley Sweeten 0db01ed89e staging: comedi: dmm32at: rename DMM32AT_DAC[LM]SB
For aesthetics, rename these defines used for the D/A LSB/MSB registers.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:33:24 -08:00
H Hartley Sweeten d443fae234 staging: comedi: dmm32at: rename DMM32AT_AI{LOW,HIGH}
For aesthetics, rename these defines used for the A/D Low/High Channel
registers.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:33:24 -08:00
H Hartley Sweeten 02a173eefb staging: comedi: dmm32at: rename DMM32AT_AUXDOUT
For aesthetics, rename this define used for the Auxillary Digital Output
register. This register is currently not used in the driver. Document the
bits of the register for completeness.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:33:24 -08:00
H Hartley Sweeten 3f4beddff3 staging: comedi: dmm32at: rename DMM32AT_AI[LM]SB
For aesthetics, rename these defines used for the A/D LSB/MSB registers.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:33:24 -08:00
H Hartley Sweeten 32b994eaee staging: comedi: dmm32at: rename DMM32AT_CONV
For aesthetics, rename this define used for the Start A/D Conversion register.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:33:24 -08:00
H Hartley Sweeten 387ca51f7c staging: comedi: dmm32at: use 8255 module for Digital I/O subdevice
The Dimond-MM-32-AT board uses an internal 82C55-type digital I/O circuit to
provide the 24 digital I/O lines. The only quirk is the need to set the page
selection bits in the control register to select page 1 addresses.

Instead of duplicating the 8255 code, provide an (*io) callback and use the
8255 module to support this subdevice.

This also removes the need for the private data in this driver.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:33:24 -08:00
H Hartley Sweeten c5f1b1e552 staging: comedi: dmm32at: introduce dmm32at_ai_set_chanspec()
Introduce a helper function to set the analog input channel scan and range
control registers. Use the new helper in the analog input (*insn_read) and
(*do_cmd) functions.

The extra sanity checks in the (*do_cmd) are not necessary. The cmd->chanlist
will always be valid and the (*do_cmdtest) validates the channel list in
Step 5.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:33:24 -08:00
H Hartley Sweeten 2dd9681196 staging: comedi: dmm32at: remove unused members of the private data
The 'data' and 'ai_inuse' members in the private data are not used in the
driver. Remove them.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:33:23 -08:00
H Hartley Sweeten ec1b232000 staging: comedi: dmm32at: remove dmm32at_ns_to_timer()
This function is not necessary. It simply returns the 'ns' value that was
passed to it.

Remove it as well as the unnecessary Step 4 check of the cmd->convert_arg.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:33:23 -08:00
H Hartley Sweeten 85b0e7668a staging: comedi: dmm32at: tidy up cmd->convert_{src, arg} validation
This driver only supports a single convert_src, TRIG_TIMER. Tidy up
the (*do_cmdtest) validation of the cmd->convert_{src,arg}.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:33:23 -08:00
H Hartley Sweeten e5d44e8c8b staging: comedi: dmm32at: tidy up cmd->scan_begin_{src, arg} validation
This driver only supports a single scan_begin_src, TRIG_TIMER. Tidy up
the (*do_cmdtest) validation of the cmd->scan_begin_{src,arg}.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:33:23 -08:00
H Hartley Sweeten 646b55ee64 staging: comedi: dmm32at: tidy up subdevice initialization
For aesthetics, add some whitespace to the subdevice initialization.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:33:23 -08:00
H Hartley Sweeten 593ea59de7 staging: comedi: dmm32at: introduce dmm32at_reset()
For aesthetics, factor the board reset and detection code out of the
(*attach) function.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:33:23 -08:00
H Hartley Sweeten 01b7ecdd95 staging: comedi: dmm32at: tidy up dmm32at_ai_rinsn()
For aesthetics, rename this function to dmm32at_ai_insn_read().

Get the 'chan' and 'range' from the chanspec when declaring the local
variables. Remove the unecessary masking of the 'chan'.

Remove some unnecessary comments.

Change the final return to 'insn->n' to clarify the return value.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:33:23 -08:00
H Hartley Sweeten 0c0eadadcb staging: comedi: dmm32at: introduce dmm32_ai_get_sample()
Introduce a helper function to read the two's complement analog input
sample from the hardware and munge it to the offset binary (unsigned)
format that comedi expects. Use the comedi_offset_munge() helper to
munge the data.

Use the new helper in the analog input (*insn_read) and in the interrupt
handler for the async command.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:33:23 -08:00
H Hartley Sweeten 933fca13a0 staging: comedi: dmm32at: use comedi_async 'scans_done' to detect EOA
Remove the private data member 'ai_scans_left' and use the comedi_async
'scans_done' to detect the end-of-acquisition.

This also removes the artifical max limit on the cmd->stop_arg.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:33:23 -08:00
H Hartley Sweeten 4d9b0714a2 staging: comedi: dmm32at: make AI (*cancel) actually cancel async command
Currently the AI (*cancel) changes a private data member to cause the
interrupt handler to cancel the async command after the next interrupt.

Move the code that disables the interrupt and terminates the acquisition
from the interrunt handler into dmm32at_ai_cancel() so that the async
command is terminated instantly.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:33:23 -08:00
H Hartley Sweeten b6bc224f33 staging: comedi: adl_pci9111: use comedi_async 'scans_done' to detect EOA
The comedi core now counts the number of samples added to the async buffer and
detects the end-of-scan and increments the comedi_async 'scans_done' counter.

Remove the private data member 'stop_counter' and use the 'scans_done' member
to detect the end-of-acquisition.

This fixes a possible interger overflow when calculating the value of the
'stop_counter' and removes the need to accumulate the 'total' number of
samples added to the async buffer in pci9111_handle_fifo_half_full().

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:31:45 -08:00
H Hartley Sweeten f6266a41d8 staging: comedi: adl_pci9118: use comedi_bytes_to_samples()
Remove the assumption of the sample size by using the comedi_bytes_to_samples()
helper function to convert the number of bytes to the number of samples.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:31:45 -08:00
H Hartley Sweeten e57bfa673c staging: comedi: adl_pci9118: absorb move_block_from_dma()
Absorb this simple helper function into interrupt_pci9118_ai_dma().

Remove the unnecessary local variables 'sampls' and 'm'.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:31:45 -08:00
H Hartley Sweeten 6250d982ee staging: comedi: adl_pci9118: use comedi_async 'scans_done' to detect EOA
The comedi core now counts the number of samples added to the async buffer and
detects the end-of-scan and increments the comedi_async 'scans_done' counter.

Remove the private data member 'ai_act_scan' and use the 'scans_done' member
to detect the end-of-acquisition.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:31:44 -08:00
H Hartley Sweeten a3e0316c16 staging: comedi: addi_watchdog: use addi_tcw.h defines for watchdog
Use the generic TCW (timer/counter/watchdog) defines for the 8-bit watchdog.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:31:34 -08:00
H Hartley Sweeten e8dbe0c4c2 staging: comedi: addi_apci_1564: enable support for PLD Rev 1.0 I/O mapping
Remove the error return in the (*auto_attach) and allow the driver to
attach to APC-1564 boards that use the PLD Rev 1.0 I/O mapping.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:31:34 -08:00
H Hartley Sweeten 7d6156ed3b staging: comedi: addi_apci_1564: use addi_tcw.h defines for counters
Use the generic TCW (timer/counter/watchdog) defines for the 32-bit counters.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:31:33 -08:00
H Hartley Sweeten e23337dcbb staging: comedi: addi_apci_1564: use addi_tcw.h defines for timer
Use the generic TCW (timer/counter/watchdog) defines for the 12-bit timer.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:31:33 -08:00
H Hartley Sweeten 1b4bcf1fed staging: comedi: addi_tcw.h: provide generic defines for the ADDI-DATA TCW
The TCW (timer/counter/watchdog) devices in the various ADDI-DATA drivers
use a common register map definition. Provide a common generic define for
these registers so they don't have to be replicated in each driver.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:31:33 -08:00
H Hartley Sweeten 0658d6de9c staging: comedi: addi_apci_1564: split timer and counter subdevices
The timer subdevice is currently broken in this driver.

The Rev 1.0 and 2.x versions of the board both have a 12-bit timer. But only
the Rev 2.x boards have the 3 32-bit counters.

Split the current timer subdevice into two separate subdevices:
  1) A single channel 12-bit timer subdevice
  2) A three channel 32-bit counter subdevice

This represents the hardware correctly and the counters can be disabled on
the Rev 1.0 boards.

Split up the current (*insn_config), (*insn_write), and (*insn_read) so they
only deal with the hardware associated with the subdevice.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:31:33 -08:00
H Hartley Sweeten 1a69a887d6 staging: comedi: addi_apci_1564: move counter register defines to driver
Move the defines for the counter registers from the included source
file to the main driver source file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:31:33 -08:00
H Hartley Sweeten 3a2cf2f971 staging: comedi: addi_apci_1564: fix counter code in main driver source
The Rev 1.0 APCI-1564 boards do not have counters.

Fix the code in the main driver source so that the I/O accesses to the
counters do not happen if the devpriv->counters member is not initialized.

This does not fix the code in hwdrv_apci1564.c. That code violates the
comedi API and is currently broken.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:31:33 -08:00
H Hartley Sweeten 6cf8ea2ebf staging: comedi: addi_apci_1564: fix timer iobase for all PLD revisions
The APCI-1564 has different I/O mapping depending on if the PLD revision
is Rev 1.0 or Rev 2.x.

Add a member, 'timer', to the private data for the base address of the
12-bit timer. Fix the register defines so they will work for all PLD
revisions and initialize the devpriv->timer appropriately.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:31:33 -08:00
H Hartley Sweeten 3743619652 staging: comedi: addi_apci_1564: fix dev->iobase for all PLD revisions
The APCI-1564 has different I/O mapping depending on if the PLD revision is
Rev 1.0 or Rev 2.x.

Fix the main register defines so they will work for all PLD revisions and
initialie the dev->iobase appropriately. Move the register defines to the
main driver source file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:31:33 -08:00
H Hartley Sweeten 951fd40b28 staging: comedi: addi_apci_1564: detect PLD revision for I/O mapping
The APCI-1564 has different I/O mapping depending on if the PLD revision is
Rev 1.0 or Rev 2.x. The revision can be determined by reading the EEPROM
register at offset 0x00 of PCI BAR 0 and checking the value of bits 7 to 4.

Add this check to apci1564_auto_attach(). Currently this driver is coded
to work with the Rev 2.x I/O mapping. For now, fail the attach if a Rev 1.0
PLD is detected. Document the I/O mapping for both revisions.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:31:33 -08:00
H Hartley Sweeten 4484a23907 staging: comedi: addi_apci_1564: use dev->iobase for main registers
According to ADDI-DATA, the PLD Revision 2.x versions of the APCI-1564 use
PCI BAR 0 for the main registers of the board.

Remove the 'amcc_iobase' member of the private data and use the dev->iobase
to store the base address of PCI BAR 1.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:31:32 -08:00
H Hartley Sweeten 63f9c51a52 staging: comedi: addi_apci_1564: store PCI BAR 1 base address in private data
According to ADDI-DATA, only the PLD Revision 2.x versions of the APCI-1564
have the 3 counters. The base address for these counters is found in PCI BAR 1.

For aesthetics, save this base address in the private data. The dev->iobase
can then be used for the main registers of the board.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:31:32 -08:00
H Hartley Sweeten 950a6f8714 staging: comedi: addi_apci_1564: use correct I/O base for APCI1564_DI_INT_STATUS_REG
The APCI1564_DI_INT_STATUS_REG is located in the PCI BAR 0 I/O space. That
base address is stored in devpriv->amcc_iobase. Use that to correctly read
the register.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:31:32 -08:00
H Hartley Sweeten aff24b9995 staging: comedi: addi_apci_1564: board does not use an AMCC PCI controller
According to ADDI-DATA, the APCI-1564 board has a FPGA with a PCI core, it
does not use an AMCC PCI controller chip.

Remove the amcc_s5933.h include as well as the read of the AMCC_OP_REG_INTCSR
register. That offset would actually read APCI1564_WDOG_STATUS_REG register
in the FPGA which has nothing to do with the interrupt status.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-26 15:31:32 -08:00
H Hartley Sweeten 34216792e0 staging: comedi: addi_apci_3120: absorb apci3120_ai_reset_fifo()
This function is only called by apci3120_set_chanlist(). Absorb it.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:06 -08:00
H Hartley Sweeten c58f9bb622 staging: comedi: addi_apci_3120: enable AI async commands
The async command support should now work. Enable the hook up of the command
support functions in apci3120_auto_attach().

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:06 -08:00
H Hartley Sweeten f50205f047 staging: comedi: addi_apci_3120: switch DMA buffers after writing samples
Currently the DMA buffers are switched before writing the current samples to
the async buffer. This works but when the EOA event happens we end up with an
outstanding DMA operation in progress that gets terminated by the (*cancel).

Avoid the outstanding DMA operation by switching the DMA buffers after writing
the samples. The driver will detect the EOA event and not retart the DMA.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:05 -08:00
H Hartley Sweeten a93a0e9a30 staging: comedi: addi_apci_3120: change params to apci3120_interrupt_dma()
Pass the comedi_device and comedi_subdevice pointers to this function instead
of the irq number and void pointer.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:05 -08:00
H Hartley Sweeten cd68e0e2d0 staging: comedi: addi_apci_3120: move apci3120_interrupt_dma() to driver
Move this function from the included source file to the main driver
source file.

Remove the now empty included source file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:05 -08:00
H Hartley Sweeten c78a1f4870 staging: comedi: addi_apci_3120: use comedi_bytes_to_samples()
Use the helper function to calculate the number of samples in the DMA
buffer. For aesthetics, tidy up the local variables.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:05 -08:00
H Hartley Sweeten 76e6047088 staging: comedi: addi_apci_3120: move apci3120_interrupt() to driver
Move this function from the included source file to the main driver
source file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:05 -08:00
H Hartley Sweeten 676caedabd staging: comedi: addi_apci_3120: move apci3120_cancel() to driver
Move this function from the included source file to the main driver
source file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:05 -08:00
H Hartley Sweeten a68809bb8d staging: comedi: addi_apci_3120: use async->events to report hardware error
In apci3120_interrupt_dma(), use the async->events to report the hardware
error and allow the core to (*cancel) the command instead of calling the
(*cancel) function directly.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:05 -08:00
H Hartley Sweeten 18e3b50367 staging: comedi: addi_apci_3120: move apci3120_ai_cmd() to driver
Move this function from the included source file to the main driver
source file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:05 -08:00
H Hartley Sweeten 4506249228 staging: comedi: addi_apci_3120: move apci3120_setup_dma() to driver
Move this function from the included source file to the main driver
source file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:05 -08:00
H Hartley Sweeten ee844c51ef staging: comedi: addi_apci_3120: move apci3120_init_dma() to driver
Move this function from the included source file to the main driver
source file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:05 -08:00
H Hartley Sweeten 0b7defa702 staging: comedi: addi_apci_3120: move apci3120_addon_write() to driver
Move this function from the included source file to the main driver
source file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:05 -08:00
H Hartley Sweeten 4ba10fc04a staging: comedi: addi_apci_3120: remove unnecessary include
The <linux/sched.h> header is not needed by this driver. Remove the
include.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:05 -08:00
H Hartley Sweeten d8cdd97c8f staging: comedi: addi_apci_3120: add copyright information
Remove the copyright info from the included source file and add it
to the main driver source file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:05 -08:00
H Hartley Sweeten d32fc427e3 staging: comedi: addi_apci_3120: move AI (*do_cmdtest) to main driver
Move apci3120_ai_cmdtest() from the included source file to the main
driver source file. Tidy up Step 4 a bit during the move.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:04 -08:00
H Hartley Sweeten 38417cc46f staging: comedi: addi_apci_3120: fix cmd->convert_arg vaildation
Regardless of the cmd->scan_begin_src, the minimum cmd->convert_arg
value is 10000 (10us). Fix the validation in apci3120_ai_cmdtest().

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:04 -08:00
H Hartley Sweeten 6d31274053 staging: comedi: addi_apci_3120: fix timer (*insn_config)
The timer subdevice in this driver does not follow the comedi API.

Fix the (*insn_config) to correctly arm, disarm, set the mode, and
get the status of the timer.

Remove the unnecessary, and broken, (*insn_write).

The new (*insn_config) does not enable the interrupt for timer 2.
Remove the interrupt support code for the timer.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:04 -08:00
H Hartley Sweeten 15cf0617c0 staging: comedi: addi_apci_3120: fix timer (*insn_read)
The timer subdevice in this driver does not follow the comedi API.
Fix the (*insn_read) to work correctly.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:04 -08:00
H Hartley Sweeten dcb5e2c4df staging: comedi: addi_apci_3120: define the AI software trigger register
Define the offset for the analog input software trigger register.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:04 -08:00
H Hartley Sweeten ecaf4c41da staging: comedi: addi_apci_3120: define the AI FIFO register
Define the offset for the analog input FIFO register.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:04 -08:00
H Hartley Sweeten 4646364cc8 staging: comedi: addi_apci_3120: don't use timer 2 to count scans
Timer 2 can be used to count the number of scans when the cmd->stop_src
is TRIG_COUNT. Unfortunately that timer can also be used by userspace and
this breaks the async command. Timer 2 also only works for counting the
number of scans when DMA is not used.

The number of scans is counted by the core using the private data membmer
'scans_done'. Use that to detect the End-Of-Scan for both DMA and none
DMA modes.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:04 -08:00
H Hartley Sweeten d895948eb8 staging: comedi: addi_apci_3120: rename private data 'ui_DmaActualBuffer'
Rename this CamelCase member of the private data and convert it to
a bit-field.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:04 -08:00
H Hartley Sweeten d65d73ff5e staging: comedi: addi_apci_3120: rename private data 'b_DmaDoubleBuffer'
Rename this CamelCase member of the private data and convert it to
a bit-field.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:04 -08:00
H Hartley Sweeten e6539bbc17 staging: comedi: addi_apci_3120: rename private data 'us_UseDma'
Rename this CamelCase member of the private data and convert it to
a bit-field.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:04 -08:00
H Hartley Sweeten ca26b42d4f staging: comedi: addi_apci_3120: move apci3120_reset() to driver source
Move this function from the included hwdrv_apci31210.c source file to
the main driver source file.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:04 -08:00
H Hartley Sweeten 884218c5a3 staging: comedi: addi_apci_3120: tidy up apci3120_reset()
This function is only called during the attach of the driver and it's
called after the private data has been kzalloc'd. There is no reason
to clear any of the private data members.

Simplify the function by just writing '0' to the necessary registers
to disable all the interrupt sources and stop the timers.

For aesthetics, change the return type to void.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:04 -08:00
H Hartley Sweeten 994211b6ff staging: comedi: addi_apci_3120: move DMA init code to apci3120_init_dma()
Move the common code used to initialize DMA to apci3120_init_dma().

This follows the programming procedure described in the APCI-3120
documentation.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:03 -08:00
H Hartley Sweeten b7d62cf812 staging: comedi: addi_apci_3120: move APCI3120_FIFO_ADVANCE_ON_BYTE_2
Move this define to the main driver source and convert it to a bit-shift.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:03 -08:00
H Hartley Sweeten 0c63bd5aea staging: comedi: addi_apci_3120: define the Add-On registers
Define the add-On registers and bits and remove the "magic" numbers in the
driver.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:03 -08:00
H Hartley Sweeten 636971fc9c staging: comedi: addi_apci_3120: use amcc_s5933.h defines
Use the defines for the AMCC 5933 PCI controller registers and bits instead
of creating private defines in this driver.

Move the generic AGCSTS_TC_ENABLE define from this driver to the header.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:03 -08:00
H Hartley Sweeten 83bec8428a staging: comedi: addi_apci_3120: introduce apci3120_addon_write()
Introduce a helper function to handle the common code that writes a 32-bit
value to the 16-bit add-on register.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:03 -08:00
H Hartley Sweeten 3ed69b98b9 staging: comedi: addi_apci_3120: introduce apci3120_init_dma()
Introduce a helper function to handle the common code that writes the DMA
start address and number of acquisitions to the AMCC Add-on registers.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:03 -08:00
H Hartley Sweeten 3431ec2ff5 staging: comedi: addi_apci_3120: remove private data 'b_ExttrigEnable'
This member of the private data is not really needed. The devpriv->ctrl
value can be checked to determine if the external trigger is enabled.
Remove the unnecessary member.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:03 -08:00
H Hartley Sweeten b278ea3cef staging: comedi: addi_apci_3120: remove private data 'b_InterruptMode'
This member of the private data is not really needed. The interrupt mode
can be determined by checking the devpriv->mode value to see if the
interrupt is enabled. Remove the unnecessary member.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:03 -08:00
H Hartley Sweeten 28215c6988 staging: comedi: addi_apci_3120: tidy up devpriv->mode in apci3120_ai_cmd()
There is no reason for the separate updates of the mode register in this
function. Refactor the code so that the mode register is only updated at
the end of the function after all the necessary bits have been set.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:03 -08:00
H Hartley Sweeten fdeb2f5487 staging: comedi: addi_apci_3120: enable chanlist scanning if needed
The 'SCAN_ENA' bit in the mode register needs to be set if the chanlist
has more than 1 channel. Set the bit in apci3120_set_chanlist() if needed.
The callers write the mode register after setting any additional bits,

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:03 -08:00
H Hartley Sweeten 1022f64e75 staging: comedi: addi_apci_3120: set scan length/start after programming chanlist
The APCI-3120 documentation says that the PR/PA bits should be set after the
chanlist sequence is programmed.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:03 -08:00
H Hartley Sweeten 15e920fb15 staging: comedi: addi_apci_3120: reset fifo after programming chanlist
The APCI-3120 documentation says that the FIFO should be reset after the
chanlist sequence is programmed.

Reset the FIFO after programming the chanlist and remove the extra FIFO
resets in the driver.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:03 -08:00
H Hartley Sweeten 502ccab2b6 staging: comedi: addi_apci_3120: tidy up timer 2 programming in apci3120_ai_cmd()
Tidy up the programming of timer 2.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:03 -08:00
H Hartley Sweeten dc0a05608d staging: comedi: addi_apci_3120: tidy up timer programming in apci3120_ai_cmd()
Tidy up the programming of timers 0 and 1 so that only one local variable is
required.

Also, remove the unnecessary clear of devpriv->timer_mode. This value will get
set correctly by each apci3120_timer_set_mode() call. It's not necessary to
clear it first.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:02 -08:00
H Hartley Sweeten aaf802fb30 staging: comedi: addi_apci_3120: absorb apci3120_cyclic_ai()
This functon is called by apci3120_ai_cmd() with one additional parameter,
'mode', The 'mode' is based on the cmd->scan_begin_src.

For aesthetics, absorb the function into apci3120_ai_cmd() and use the
cmd->scan_begin_src directly to determine the 'mode'.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-07 09:34:02 -08:00