aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/comedi/drivers/s626.c
diff options
context:
space:
mode:
authorIan Abbott <abbotti@mev.co.uk>2013-10-21 10:10:37 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-10-29 09:09:54 -0700
commit2cea19faf16304125ce12e4b5518110ef77f32a1 (patch)
tree3d9a271cef84978b62d352ff229c5322480d2184 /drivers/staging/comedi/drivers/s626.c
parentstaging: comedi: s626: make CRA and CRB setup conversions more readable (diff)
downloadlinux-dev-2cea19faf16304125ce12e4b5518110ef77f32a1.tar.xz
linux-dev-2cea19faf16304125ce12e4b5518110ef77f32a1.zip
staging: comedi: s626: expand standardized IndxSrc values
The 'IndxSrc' value for the standardized encoder setup is currently 1 bit wide and takes one of the following values: S626_INDXSRC_HARD = 0 // index source from hardware encoder S626_INDXSRC_SOFT = 1 // index source software controlled by IndxPol However the hardware 'IndxSrcA' and 'IndxSrcB' values for the 'A' and 'B' counters are 2 bits wide. The above standardized values 0 and 1 correspond to the hardware values 0 and 2. In order to simplify conversions between the standardized values and hardware values, expand the range of standardized values to cover all four possible values. The new values are as follows: S626_INDXSRC_ENCODER = 0 // index source from hardware encoder S626_INDXSRC_DIGIN = 1 // index source from digital inputs S626_INDXSRC_SOFT = 2 // index source s/w controlled by IndxPol S626_INDXSRC_DISABLED = 2 // index source disabled (Note the change in value for `S626_INDXSRC_SOFT` and the replacement of `S626_INDXSRC_HARD` with `S626_INDXSRC_ENCODER` for consistency with the `CntSrc` values.) 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>
Diffstat (limited to 'drivers/staging/comedi/drivers/s626.c')
-rw-r--r--drivers/staging/comedi/drivers/s626.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c
index 3fd544777abd..c2837da862db 100644
--- a/drivers/staging/comedi/drivers/s626.c
+++ b/drivers/staging/comedi/drivers/s626.c
@@ -708,7 +708,6 @@ static uint16_t s626_get_mode_a(struct comedi_device *dev,
/*
* Populate the standardized counter setup bit fields.
- * Note: IndexSrc is restricted to ENC_X or IndxPol.
*/
setup =
/* LoadSrc = LoadSrcA. */
@@ -717,8 +716,8 @@ static uint16_t s626_get_mode_a(struct comedi_device *dev,
S626_SET_STD_LATCHSRC(S626_GET_CRB_LATCHSRC(crb)) |
/* IntSrc = IntSrcA. */
S626_SET_STD_INTSRC(S626_GET_CRA_INTSRC_A(cra)) |
- /* IndxSrc = IndxSrcA<1>. */
- S626_SET_STD_INDXSRC(S626_GET_CRA_INDXSRC_A(cra) >> 1) |
+ /* IndxSrc = IndxSrcA. */
+ S626_SET_STD_INDXSRC(S626_GET_CRA_INDXSRC_A(cra)) |
/* IndxPol = IndxPolA. */
S626_SET_STD_INDXPOL(S626_GET_CRA_INDXPOL_A(cra)) |
/* ClkEnab = ClkEnabA. */
@@ -764,7 +763,6 @@ static uint16_t s626_get_mode_b(struct comedi_device *dev,
/*
* Populate the standardized counter setup bit fields.
- * Note: IndexSrc is restricted to ENC_X or IndxPol.
*/
setup =
/* IntSrc = IntSrcB. */
@@ -777,8 +775,8 @@ static uint16_t s626_get_mode_b(struct comedi_device *dev,
S626_SET_STD_INDXPOL(S626_GET_CRB_INDXPOL_B(crb)) |
/* ClkEnab = ClkEnabB. */
S626_SET_STD_CLKENAB(S626_GET_CRB_CLKENAB_B(crb)) |
- /* IndxSrc = IndxSrcB<1>. */
- S626_SET_STD_INDXSRC(S626_GET_CRA_INDXSRC_B(cra) >> 1);
+ /* IndxSrc = IndxSrcB. */
+ S626_SET_STD_INDXSRC(S626_GET_CRA_INDXSRC_B(cra));
/* Adjust mode-dependent parameters. */
cntsrc = S626_GET_CRA_CNTSRC_B(cra);
@@ -829,8 +827,8 @@ static void s626_set_mode_a(struct comedi_device *dev,
/* Initialize CRA and CRB images. */
/* Preload trigger is passed through. */
cra = S626_SET_CRA_LOADSRC_A(S626_GET_STD_LOADSRC(setup));
- /* IndexSrc is restricted to ENC_X or IndxPol. */
- cra |= S626_SET_CRA_INDXSRC_A(S626_GET_STD_INDXSRC(setup) << 1);
+ /* IndexSrc is passed through. */
+ cra |= S626_SET_CRA_INDXSRC_A(S626_GET_STD_INDXSRC(setup));
/* Reset any pending CounterA event captures. */
crb = S626_SET_CRB_INTRESETCMD(1) | S626_SET_CRB_INTRESET_A(1);
@@ -874,7 +872,7 @@ static void s626_set_mode_a(struct comedi_device *dev,
* Force positive index polarity if IndxSrc is software-driven only,
* otherwise pass it through.
*/
- if (S626_GET_STD_INDXSRC(setup) == S626_INDXSRC_HARD)
+ if (S626_GET_STD_INDXSRC(setup) != S626_INDXSRC_SOFT)
cra |= S626_SET_CRA_INDXPOL_A(S626_GET_STD_INDXPOL(setup));
/*
@@ -904,8 +902,8 @@ static void s626_set_mode_b(struct comedi_device *dev,
unsigned cntsrc, clkmult, clkpol;
/* Initialize CRA and CRB images. */
- /* IndexSrc field is restricted to ENC_X or IndxPol. */
- cra = S626_SET_CRA_INDXSRC_B(S626_GET_STD_INDXSRC(setup) << 1);
+ /* IndexSrc is passed through. */
+ cra = S626_SET_CRA_INDXSRC_B(S626_GET_STD_INDXSRC(setup));
/* Reset event captures and disable interrupts. */
crb = S626_SET_CRB_INTRESETCMD(1) | S626_SET_CRB_INTRESET_B(1);
@@ -958,7 +956,7 @@ static void s626_set_mode_b(struct comedi_device *dev,
* Force positive index polarity if IndxSrc is software-driven only,
* otherwise pass it through.
*/
- if (S626_GET_STD_INDXSRC(setup) == S626_INDXSRC_HARD)
+ if (S626_GET_STD_INDXSRC(setup) != S626_INDXSRC_SOFT)
crb |= S626_SET_CRB_INDXPOL_B(S626_GET_STD_INDXPOL(setup));
/*