aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c119
1 files changed, 46 insertions, 73 deletions
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 07123fd766a3..f93ddd4eb06c 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -45,7 +45,7 @@ You should also find the complete GPL in the COPYING file accompanying this sour
45*/ 45*/
46 46
47#include "hwdrv_apci3120.h" 47#include "hwdrv_apci3120.h"
48static unsigned int ui_Temp = 0; 48static unsigned int ui_Temp;
49 49
50/* FUNCTION DEFINITIONS */ 50/* FUNCTION DEFINITIONS */
51 51
@@ -98,25 +98,22 @@ int i_APCI3120_InsnConfigAnalogInput(struct comedi_device *dev, struct comedi_su
98 98
99 devpriv->b_InterruptMode = APCI3120_EOS_MODE; 99 devpriv->b_InterruptMode = APCI3120_EOS_MODE;
100 100
101 if (data[1]) { 101 if (data[1])
102 devpriv->b_EocEosInterrupt = APCI3120_ENABLE; 102 devpriv->b_EocEosInterrupt = APCI3120_ENABLE;
103 } else 103 else
104 devpriv->b_EocEosInterrupt = APCI3120_DISABLE; 104 devpriv->b_EocEosInterrupt = APCI3120_DISABLE;
105 /* Copy channel list and Range List to devpriv */ 105 /* Copy channel list and Range List to devpriv */
106 106
107 devpriv->ui_AiNbrofChannels = data[3]; 107 devpriv->ui_AiNbrofChannels = data[3];
108 for (i = 0; i < devpriv->ui_AiNbrofChannels; i++) { 108 for (i = 0; i < devpriv->ui_AiNbrofChannels; i++)
109 devpriv->ui_AiChannelList[i] = data[4 + i]; 109 devpriv->ui_AiChannelList[i] = data[4 + i];
110 }
111 110
112 } else /* EOC */ 111 } else { /* EOC */
113 {
114 devpriv->b_InterruptMode = APCI3120_EOC_MODE; 112 devpriv->b_InterruptMode = APCI3120_EOC_MODE;
115 if (data[1]) { 113 if (data[1])
116 devpriv->b_EocEosInterrupt = APCI3120_ENABLE; 114 devpriv->b_EocEosInterrupt = APCI3120_ENABLE;
117 } else { 115 else
118 devpriv->b_EocEosInterrupt = APCI3120_DISABLE; 116 devpriv->b_EocEosInterrupt = APCI3120_DISABLE;
119 }
120 } 117 }
121 118
122 return insn->n; 119 return insn->n;
@@ -166,13 +163,9 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device *dev, struct comedi_subd
166 devpriv->us_OutputRegister = 0; 163 devpriv->us_OutputRegister = 0;
167/* devpriv->b_DigitalOutputRegister=0; */ 164/* devpriv->b_DigitalOutputRegister=0; */
168 165
169 if (insn->unused[0] == 222) /* second insn read */ 166 if (insn->unused[0] == 222) { /* second insn read */
170 { 167 for (i = 0; i < insn->n; i++)
171
172 for (i = 0; i < insn->n; i++) {
173 data[i] = devpriv->ui_AiReadData[i]; 168 data[i] = devpriv->ui_AiReadData[i];
174 }
175
176 } else { 169 } else {
177 devpriv->tsk_Current = current; /* Save the current process task structure */ 170 devpriv->tsk_Current = current; /* Save the current process task structure */
178/* 171/*
@@ -519,9 +512,8 @@ int i_APCI3120_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_s
519 512
520 /* step 2: make sure trigger sources are unique and mutually compatible */ 513 /* step 2: make sure trigger sources are unique and mutually compatible */
521 514
522 if (cmd->start_src != TRIG_NOW && cmd->start_src != TRIG_EXT) { 515 if (cmd->start_src != TRIG_NOW && cmd->start_src != TRIG_EXT)
523 err++; 516 err++;
524 }
525 517
526 if (cmd->scan_begin_src != TRIG_TIMER && 518 if (cmd->scan_begin_src != TRIG_TIMER &&
527 cmd->scan_begin_src != TRIG_FOLLOW) 519 cmd->scan_begin_src != TRIG_FOLLOW)
@@ -548,16 +540,14 @@ int i_APCI3120_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_s
548 err++; 540 err++;
549 } 541 }
550 542
551 if (cmd->scan_begin_src == TRIG_TIMER) /* Test Delay timing */ 543 if (cmd->scan_begin_src == TRIG_TIMER) { /* Test Delay timing */
552 {
553 if (cmd->scan_begin_arg < this_board->ui_MinDelaytimeNs) { 544 if (cmd->scan_begin_arg < this_board->ui_MinDelaytimeNs) {
554 cmd->scan_begin_arg = this_board->ui_MinDelaytimeNs; 545 cmd->scan_begin_arg = this_board->ui_MinDelaytimeNs;
555 err++; 546 err++;
556 } 547 }
557 } 548 }
558 549
559 if (cmd->convert_src == TRIG_TIMER) /* Test Acquisition timing */ 550 if (cmd->convert_src == TRIG_TIMER) { /* Test Acquisition timing */
560 {
561 if (cmd->scan_begin_src == TRIG_TIMER) { 551 if (cmd->scan_begin_src == TRIG_TIMER) {
562 if ((cmd->convert_arg) 552 if ((cmd->convert_arg)
563 && (cmd->convert_arg < 553 && (cmd->convert_arg <
@@ -653,11 +643,10 @@ int i_APCI3120_CommandAnalogInput(struct comedi_device *dev, struct comedi_subde
653 /* UPDATE-0.7.57->0.7.68devpriv->ui_AiDataLength=s->async->data_len; */ 643 /* UPDATE-0.7.57->0.7.68devpriv->ui_AiDataLength=s->async->data_len; */
654 devpriv->ui_AiDataLength = s->async->prealloc_bufsz; 644 devpriv->ui_AiDataLength = s->async->prealloc_bufsz;
655 645
656 if (cmd->stop_src == TRIG_COUNT) { 646 if (cmd->stop_src == TRIG_COUNT)
657 devpriv->ui_AiNbrofScans = cmd->stop_arg; 647 devpriv->ui_AiNbrofScans = cmd->stop_arg;
658 } else { 648 else
659 devpriv->ui_AiNbrofScans = 0; 649 devpriv->ui_AiNbrofScans = 0;
660 }
661 650
662 devpriv->ui_AiTimer0 = 0; /* variables changed to timer0,timer1 */ 651 devpriv->ui_AiTimer0 = 0; /* variables changed to timer0,timer1 */
663 devpriv->ui_AiTimer1 = 0; 652 devpriv->ui_AiTimer1 = 0;
@@ -849,9 +838,8 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device *dev,
849 } 838 }
850/*** EL241003 End ******************************************************************************/ 839/*** EL241003 End ******************************************************************************/
851 840
852 if (devpriv->b_ExttrigEnable == APCI3120_ENABLE) { 841 if (devpriv->b_ExttrigEnable == APCI3120_ENABLE)
853 i_APCI3120_ExttrigEnable(dev); /* activate EXT trigger */ 842 i_APCI3120_ExttrigEnable(dev); /* activate EXT trigger */
854 }
855 switch (mode) { 843 switch (mode) {
856 case 1: 844 case 1:
857 /* init timer0 in mode 2 */ 845 /* init timer0 in mode 2 */
@@ -1049,12 +1037,10 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device *dev,
1049 dmalen1 = 4; 1037 dmalen1 = 4;
1050 } 1038 }
1051 } else { /* isn't output buff smaller that our DMA buff? */ 1039 } else { /* isn't output buff smaller that our DMA buff? */
1052 if (dmalen0 > (devpriv->ui_AiDataLength)) { 1040 if (dmalen0 > (devpriv->ui_AiDataLength))
1053 dmalen0 = devpriv->ui_AiDataLength; 1041 dmalen0 = devpriv->ui_AiDataLength;
1054 } 1042 if (dmalen1 > (devpriv->ui_AiDataLength))
1055 if (dmalen1 > (devpriv->ui_AiDataLength)) {
1056 dmalen1 = devpriv->ui_AiDataLength; 1043 dmalen1 = devpriv->ui_AiDataLength;
1057 }
1058 } 1044 }
1059 devpriv->ui_DmaBufferUsesize[0] = dmalen0; 1045 devpriv->ui_DmaBufferUsesize[0] = dmalen0;
1060 devpriv->ui_DmaBufferUsesize[1] = dmalen1; 1046 devpriv->ui_DmaBufferUsesize[1] = dmalen1;
@@ -1356,11 +1342,10 @@ int i_APCI3120_SetupChannelList(struct comedi_device *dev, struct comedi_subdevi
1356 /* store range list to card */ 1342 /* store range list to card */
1357 us_TmpValue = CR_CHAN(chanlist[i]); /* get channel number; */ 1343 us_TmpValue = CR_CHAN(chanlist[i]); /* get channel number; */
1358 1344
1359 if (CR_RANGE(chanlist[i]) < APCI3120_BIPOLAR_RANGES) { 1345 if (CR_RANGE(chanlist[i]) < APCI3120_BIPOLAR_RANGES)
1360 us_TmpValue &= ((~APCI3120_UNIPOLAR) & 0xff); /* set bipolar */ 1346 us_TmpValue &= ((~APCI3120_UNIPOLAR) & 0xff); /* set bipolar */
1361 } else { 1347 else
1362 us_TmpValue |= APCI3120_UNIPOLAR; /* enable unipolar...... */ 1348 us_TmpValue |= APCI3120_UNIPOLAR; /* enable unipolar...... */
1363 }
1364 1349
1365 gain = CR_RANGE(chanlist[i]); /* get gain number */ 1350 gain = CR_RANGE(chanlist[i]); /* get gain number */
1366 us_TmpValue |= ((gain & 0x03) << 4); /* <<4 for G0 and G1 bit in RAM */ 1351 us_TmpValue |= ((gain & 0x03) << 4); /* <<4 for G0 and G1 bit in RAM */
@@ -1514,8 +1499,7 @@ void v_APCI3120_Interrupt(int irq, void *d)
1514 /* Check If EOS interrupt */ 1499 /* Check If EOS interrupt */
1515 if ((int_daq & 0x2) && (devpriv->b_InterruptMode == APCI3120_EOS_MODE)) { 1500 if ((int_daq & 0x2) && (devpriv->b_InterruptMode == APCI3120_EOS_MODE)) {
1516 1501
1517 if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) /* enable this in without DMA ??? */ 1502 if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) { /* enable this in without DMA ??? */
1518 {
1519 1503
1520 if (devpriv->b_AiCyclicAcquisition == APCI3120_ENABLE) { 1504 if (devpriv->b_AiCyclicAcquisition == APCI3120_ENABLE) {
1521 ui_Check = 0; 1505 ui_Check = 0;
@@ -1966,8 +1950,7 @@ int i_APCI3120_InsnConfigTimer(struct comedi_device *dev, struct comedi_subdevic
1966 APCI3120_DISABLE_EOS_INT; 1950 APCI3120_DISABLE_EOS_INT;
1967 outb(devpriv->b_ModeSelectRegister, 1951 outb(devpriv->b_ModeSelectRegister,
1968 devpriv->iobase + APCI3120_WRITE_MODE_SELECT); 1952 devpriv->iobase + APCI3120_WRITE_MODE_SELECT);
1969 if (data[0] == APCI3120_TIMER) /* initialize timer */ 1953 if (data[0] == APCI3120_TIMER) { /* initialize timer */
1970 {
1971 /* devpriv->b_ModeSelectRegister=devpriv->b_ModeSelectRegister | 1954 /* devpriv->b_ModeSelectRegister=devpriv->b_ModeSelectRegister |
1972 * APCI3120_ENABLE_TIMER_INT; */ 1955 * APCI3120_ENABLE_TIMER_INT; */
1973 1956
@@ -2006,8 +1989,7 @@ int i_APCI3120_InsnConfigTimer(struct comedi_device *dev, struct comedi_subdevic
2006 /* timer2 in Timer mode enabled */ 1989 /* timer2 in Timer mode enabled */
2007 devpriv->b_Timer2Mode = APCI3120_TIMER; 1990 devpriv->b_Timer2Mode = APCI3120_TIMER;
2008 1991
2009 } else /* Initialize Watch dog */ 1992 } else { /* Initialize Watch dog */
2010 {
2011 1993
2012 /* Set the Timer 2 in mode 5(Watchdog) */ 1994 /* Set the Timer 2 in mode 5(Watchdog) */
2013 1995
@@ -2092,8 +2074,7 @@ int i_APCI3120_InsnWriteTimer(struct comedi_device *dev, struct comedi_subdevice
2092 return -EINVAL; 2074 return -EINVAL;
2093 } 2075 }
2094 2076
2095 if (data[0] == 2) /* write new value */ 2077 if (data[0] == 2) { /* write new value */
2096 {
2097 if (devpriv->b_Timer2Mode != APCI3120_TIMER) { 2078 if (devpriv->b_Timer2Mode != APCI3120_TIMER) {
2098 comedi_error(dev, 2079 comedi_error(dev,
2099 "write :timer2 not configured in TIMER MODE"); 2080 "write :timer2 not configured in TIMER MODE");
@@ -2113,13 +2094,11 @@ int i_APCI3120_InsnWriteTimer(struct comedi_device *dev, struct comedi_subdevice
2113 2094
2114 /* Reset FC_TIMER BIT */ 2095 /* Reset FC_TIMER BIT */
2115 inb(devpriv->iobase + APCI3120_TIMER_STATUS_REGISTER); 2096 inb(devpriv->iobase + APCI3120_TIMER_STATUS_REGISTER);
2116 if (devpriv->b_Timer2Mode == APCI3120_TIMER) /* start timer */ 2097 if (devpriv->b_Timer2Mode == APCI3120_TIMER) { /* start timer */
2117 {
2118 /* Enable Timer */ 2098 /* Enable Timer */
2119 devpriv->b_ModeSelectRegister = 2099 devpriv->b_ModeSelectRegister =
2120 devpriv->b_ModeSelectRegister & 0x0B; 2100 devpriv->b_ModeSelectRegister & 0x0B;
2121 } else /* start watch dog */ 2101 } else { /* start watch dog */
2122 {
2123 /* Enable WatchDog */ 2102 /* Enable WatchDog */
2124 devpriv->b_ModeSelectRegister = 2103 devpriv->b_ModeSelectRegister =
2125 (devpriv-> 2104 (devpriv->
@@ -2146,8 +2125,7 @@ int i_APCI3120_InsnWriteTimer(struct comedi_device *dev, struct comedi_subdevice
2146 outb(devpriv->b_ModeSelectRegister, 2125 outb(devpriv->b_ModeSelectRegister,
2147 devpriv->iobase + APCI3120_WRITE_MODE_SELECT); 2126 devpriv->iobase + APCI3120_WRITE_MODE_SELECT);
2148 2127
2149 if (devpriv->b_Timer2Mode == APCI3120_TIMER) /* start timer */ 2128 if (devpriv->b_Timer2Mode == APCI3120_TIMER) { /* start timer */
2150 {
2151 /* For Timer mode is Gate2 must be activated **timer started */ 2129 /* For Timer mode is Gate2 must be activated **timer started */
2152 devpriv->us_OutputRegister = 2130 devpriv->us_OutputRegister =
2153 devpriv-> 2131 devpriv->
@@ -2299,8 +2277,7 @@ int i_APCI3120_InsnReadTimer(struct comedi_device *dev, struct comedi_subdevice
2299 /* combining both words */ 2277 /* combining both words */
2300 data[0] = (unsigned int) ((us_TmpValue) | ((us_TmpValue_2) << 16)); 2278 data[0] = (unsigned int) ((us_TmpValue) | ((us_TmpValue_2) << 16));
2301 2279
2302 } else /* Read watch dog status */ 2280 } else { /* Read watch dog status */
2303 {
2304 2281
2305 us_StatusValue = inw(devpriv->iobase + APCI3120_RD_STATUS); 2282 us_StatusValue = inw(devpriv->iobase + APCI3120_RD_STATUS);
2306 us_StatusValue = 2283 us_StatusValue =
@@ -2441,10 +2418,9 @@ int i_APCI3120_InsnConfigDigitalOutput(struct comedi_device *dev,
2441 devpriv->b_OutputMemoryStatus = APCI3120_DISABLE; 2418 devpriv->b_OutputMemoryStatus = APCI3120_DISABLE;
2442 devpriv->b_DigitalOutputRegister = 0; 2419 devpriv->b_DigitalOutputRegister = 0;
2443 } 2420 }
2444 if (!devpriv->b_OutputMemoryStatus) { 2421 if (!devpriv->b_OutputMemoryStatus)
2445 ui_Temp = 0; 2422 ui_Temp = 0;
2446 2423 /* if(!devpriv->b_OutputMemoryStatus ) */
2447 } /* if(!devpriv->b_OutputMemoryStatus ) */
2448 2424
2449 return insn->n; 2425 return insn->n;
2450} 2426}
@@ -2504,23 +2480,23 @@ int i_APCI3120_InsnBitsDigitalOutput(struct comedi_device *dev,
2504 2480
2505/* 2481/*
2506+----------------------------------------------------------------------------+ 2482+----------------------------------------------------------------------------+
2507| Function name :int i_APCI3120_InsnWriteDigitalOutput(struct comedi_device *dev,| 2483| Function name :int i_APCI3120_InsnWriteDigitalOutput(struct comedi_device *dev,|
2508|struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) | 2484|struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) |
2509| | 2485| |
2510+----------------------------------------------------------------------------+ 2486+----------------------------------------------------------------------------+
2511| Task : Write digiatl output | 2487| Task : Write digiatl output |
2512| | 2488| |
2513+----------------------------------------------------------------------------+ 2489+----------------------------------------------------------------------------+
2514| Input Parameters : struct comedi_device *dev | 2490| Input Parameters : struct comedi_device *dev |
2515| struct comedi_subdevice *s | 2491| struct comedi_subdevice *s |
2516| struct comedi_insn *insn | 2492| struct comedi_insn *insn |
2517| unsigned int *data | 2493| unsigned int *data |
2518 data[0] Value to be written 2494 data[0] Value to be written
2519 data[1] :1 Set digital o/p ON 2495 data[1] :1 Set digital o/p ON
2520 data[1] 2 Set digital o/p OFF with memory ON 2496 data[1] 2 Set digital o/p OFF with memory ON
2521+----------------------------------------------------------------------------+ 2497+----------------------------------------------------------------------------+
2522| Return Value : | 2498| Return Value : |
2523| | 2499| |
2524+----------------------------------------------------------------------------+ 2500+----------------------------------------------------------------------------+
2525*/ 2501*/
2526 2502
@@ -2615,8 +2591,7 @@ int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev,
2615 ui_Channel = CR_CHAN(insn->chanspec); 2591 ui_Channel = CR_CHAN(insn->chanspec);
2616 2592
2617 /* this_board->i_hwdrv_InsnWriteAnalogOutput(dev, ui_Range, ui_Channel,data[0]); */ 2593 /* this_board->i_hwdrv_InsnWriteAnalogOutput(dev, ui_Range, ui_Channel,data[0]); */
2618 if (ui_Range) /* if 1 then unipolar */ 2594 if (ui_Range) { /* if 1 then unipolar */
2619 {
2620 2595
2621 if (data[0] != 0) 2596 if (data[0] != 0)
2622 data[0] = 2597 data[0] =
@@ -2627,8 +2602,7 @@ int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev,
2627 ((((ui_Channel & 0x03) << 14) & 0xC000) | (1 << 2602 ((((ui_Channel & 0x03) << 14) & 0xC000) | (1 <<
2628 13) | 8192); 2603 13) | 8192);
2629 2604
2630 } else /* if 0 then bipolar */ 2605 } else { /* if 0 then bipolar */
2631 {
2632 data[0] = 2606 data[0] =
2633 ((((ui_Channel & 0x03) << 14) & 0xC000) | (0 << 13) | 2607 ((((ui_Channel & 0x03) << 14) & 0xC000) | (0 << 13) |
2634 data[0]); 2608 data[0]);
@@ -2639,8 +2613,7 @@ int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev,
2639 * out put n values at the given channel. printk("\nwaiting for 2613 * out put n values at the given channel. printk("\nwaiting for
2640 * DA_READY BIT"); 2614 * DA_READY BIT");
2641 */ 2615 */
2642 do /* Waiting of DA_READY BIT */ 2616 do { /* Waiting of DA_READY BIT */
2643 {
2644 us_TmpValue = 2617 us_TmpValue =
2645 ((unsigned short) inw(devpriv->iobase + 2618 ((unsigned short) inw(devpriv->iobase +
2646 APCI3120_RD_STATUS)) & 0x0001; 2619 APCI3120_RD_STATUS)) & 0x0001;