137 unsigned int ul_TimerValue = 0;
138 unsigned int dw_Command;
139 double d_RealTimingInterval = 0;
141 unsigned char b_TorCounter;
142 unsigned char b_PCIInputClock;
143 unsigned char b_TimingUnit;
144 unsigned int ul_TimingInterval;
145 unsigned int ul_RealTimingInterval = 0;
147 i_ReturnValue = insn->
n;
150 b_TorCounter = (
unsigned char) data[0];
151 b_PCIInputClock = (
unsigned char) data[1];
152 b_TimingUnit = (
unsigned char) data[2];
153 ul_TimingInterval = (
unsigned int) data[3];
154 printk(
"INPUT clock %d\n", b_PCIInputClock);
160 if (b_ModulNbr < 4) {
166 dw_MolduleConfiguration[b_ModulNbr] &
172 if (b_TorCounter <= 1) {
186 if ((b_TimingUnit <= 4)
187 || (b_PCIInputClock ==
193 if (((b_PCIInputClock ==
APCI1710_30MHZ) && (b_TimingUnit == 0) && (ul_TimingInterval >= 133) && (ul_TimingInterval <= 0xFFFFFFFFUL)) || ((b_PCIInputClock ==
APCI1710_30MHZ) && (b_TimingUnit == 1) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 571230650
UL)) || ((b_PCIInputClock ==
APCI1710_30MHZ) && (b_TimingUnit == 2) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 571230
UL)) || ((b_PCIInputClock ==
APCI1710_30MHZ) && (b_TimingUnit == 3) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 571
UL)) || ((b_PCIInputClock ==
APCI1710_30MHZ) && (b_TimingUnit == 4) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 9
UL)) || ((b_PCIInputClock ==
APCI1710_33MHZ) && (b_TimingUnit == 0) && (ul_TimingInterval >= 121) && (ul_TimingInterval <= 0xFFFFFFFFUL)) || ((b_PCIInputClock ==
APCI1710_33MHZ) && (b_TimingUnit == 1) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 519691043
UL)) || ((b_PCIInputClock ==
APCI1710_33MHZ) && (b_TimingUnit == 2) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 519691
UL)) || ((b_PCIInputClock ==
APCI1710_33MHZ) && (b_TimingUnit == 3) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 520
UL)) || ((b_PCIInputClock ==
APCI1710_33MHZ) && (b_TimingUnit == 4) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 8
UL)) || ((b_PCIInputClock ==
APCI1710_40MHZ) && (b_TimingUnit == 0) && (ul_TimingInterval >= 100) && (ul_TimingInterval <= 0xFFFFFFFFUL)) || ((b_PCIInputClock ==
APCI1710_40MHZ) && (b_TimingUnit == 1) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 429496729
UL)) || ((b_PCIInputClock ==
APCI1710_40MHZ) && (b_TimingUnit == 2) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 429496
UL)) || ((b_PCIInputClock ==
APCI1710_40MHZ) && (b_TimingUnit == 3) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 429
UL)) || ((b_PCIInputClock ==
APCI1710_40MHZ) && (b_TimingUnit == 4) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 7
UL)) || ((b_PCIInputClock ==
APCI1710_GATE_INPUT) && (ul_TimingInterval >= 2))) {
215 switch (b_TimingUnit) {
231 (0.00025 * b_PCIInputClock));
237 if ((
double)((double)ul_TimingInterval * (0.00025 * (
double)b_PCIInputClock)) >= ((double)((
double)ul_TimerValue + 0.5))) {
249 ul_RealTimingInterval
254 (0.00025 * (
double)b_PCIInputClock));
265 if ((
double)((double)ul_TimerValue / (0.00025 * (
double)b_PCIInputClock)) >= (double)((
double)ul_RealTimingInterval + 0.5)) {
266 ul_RealTimingInterval
268 ul_RealTimingInterval
312 (0.25 * b_PCIInputClock));
318 if ((
double)((double)ul_TimingInterval * (0.25 * (
double)b_PCIInputClock)) >= ((double)((
double)ul_TimerValue + 0.5))) {
330 ul_RealTimingInterval
335 (0.25 * (
double)b_PCIInputClock));
348 if ((
double)((double)ul_TimerValue / (0.25 * (
double)b_PCIInputClock)) >= (double)((
double)ul_RealTimingInterval + 0.5)) {
349 ul_RealTimingInterval
351 ul_RealTimingInterval
402 if ((
double)((double)ul_TimingInterval * (250.0 * (
double)b_PCIInputClock)) >= ((double)((
double)ul_TimerValue + 0.5))) {
414 ul_RealTimingInterval
419 (250.0 * (
double)b_PCIInputClock));
430 if ((
double)((double)ul_TimerValue / (250.0 * (
double)b_PCIInputClock)) >= (double)((
double)ul_RealTimingInterval + 0.5)) {
431 ul_RealTimingInterval
433 ul_RealTimingInterval
485 if ((
double)((double)ul_TimingInterval * (250000.0 * (
double)b_PCIInputClock)) >= ((double)((
double)ul_TimerValue + 0.5))) {
497 ul_RealTimingInterval
516 if ((
double)((double)ul_TimerValue / (250000.0 * (
double)b_PCIInputClock)) >= (double)((
double)ul_RealTimingInterval + 0.5)) {
517 ul_RealTimingInterval
519 ul_RealTimingInterval
574 if ((
double)((double)(ul_TimingInterval * 60.0) * (250000.0 * (double)b_PCIInputClock)) >= ((
double)((double)ul_TimerValue + 0.5))) {
586 ul_RealTimingInterval
610 if ((
double)(((double)ul_TimerValue / (250000.0 * (
double)b_PCIInputClock)) / 60.0) >= (double)((
double)ul_RealTimingInterval + 0.5)) {
611 ul_RealTimingInterval
613 ul_RealTimingInterval
663 s_TorCounterModuleInfo.
675 s_TorCounterModuleInfo.
688 s_TorCounterModuleInfo.
693 d_RealTimingInterval;
698 s_TorCounterModuleInfo.
701 ul_RealTimingInterval
703 ul_RealTimingInterval;
718 (16 * b_TorCounter) + (64 * b_ModulNbr));
764 outl(dw_Command,
devpriv->s_BoardInfos.ui_Address + 4 + (16 * b_TorCounter) + (64 * b_ModulNbr));
770 outl(0,
devpriv->s_BoardInfos.ui_Address + 8 + (16 * b_TorCounter) + (64 * b_ModulNbr));
775 outl(ul_TimerValue,
devpriv->s_BoardInfos.ui_Address + 0 + (16 * b_TorCounter) + (64 * b_ModulNbr));
784 s_TorCounterModuleInfo.
795 DPRINTK(
"TOR version error for 40MHz clock selection\n");
805 DPRINTK(
"You can not used the 40MHz clock selection wich this board\n");
814 DPRINTK(
"Base timing selection is wrong\n");
823 DPRINTK(
"Timing unit selection is wrong\n");
832 DPRINTK(
"The selected PCI input clock is wrong\n");
841 DPRINTK(
"Tor Counter selection is wrong\n");
849 DPRINTK(
"The module is not a tor counter module\n");
857 DPRINTK(
"Module number error\n");
860 data[0] = (
unsigned int) ul_RealTimingInterval;
994 unsigned int dw_Status;
996 unsigned int dw_ConfigReg;
998 unsigned char b_TorCounter;
999 unsigned char b_InputMode;
1000 unsigned char b_ExternGate;
1001 unsigned char b_CycleMode;
1005 b_Action = (
unsigned char) data[0];
1006 b_TorCounter = (
unsigned char) data[1];
1007 b_InputMode = (
unsigned char) data[2];
1008 b_ExternGate = (
unsigned char) data[3];
1009 b_CycleMode = (
unsigned char) data[4];
1010 b_InterruptEnable = (
unsigned char) data[5];
1011 i_ReturnValue = insn->
n;
1017 if (b_ModulNbr < 4) {
1023 dw_MolduleConfiguration[b_ModulNbr] &
1029 if (b_TorCounter <= 1) {
1040 (16 * b_TorCounter) +
1043 if (dw_Status & 0x10) {
1048 if (b_InputMode == 0 ||
1061 if (b_ExternGate == 0
1084 s_TorCounterModuleInfo.
1104 (16 * b_TorCounter) + (64 * b_ModulNbr));
1118 if (b_InputMode > 1) {
1211 (16 * b_TorCounter) + (64 * b_ModulNbr));
1226 (16 * b_TorCounter) + (64 * b_ModulNbr));
1232 outl(dw_ConfigReg,
devpriv->s_BoardInfos.ui_Address + 4 + (16 * b_TorCounter) + (64 * b_ModulNbr));
1238 outl(1,
devpriv->s_BoardInfos.ui_Address + 8 + (16 * b_TorCounter) + (64 * b_ModulNbr));
1246 DPRINTK(
"Interrupt parameter is wrong\n");
1257 DPRINTK(
"Tor counter acquisition mode cycle is wrong\n");
1268 DPRINTK(
"Extern gate input mode is wrong\n");
1278 DPRINTK(
"Tor input signal selection is wrong\n");
1286 DPRINTK(
"Tor counter not initialised\n");
1298 (16 * b_TorCounter) +
1305 if (dw_Status & 0x10) {
1310 if (dw_Status & 0x1) {
1317 s_TorCounterModuleInfo.
1331 (16 * b_TorCounter) + (64 * b_ModulNbr));
1338 DPRINTK(
"Tor counter not enabled \n");
1347 DPRINTK(
"Tor counter not initialised\n");
1358 DPRINTK(
"Tor counter selection is wrong\n");
1366 DPRINTK(
"The module is not a tor counter module \n");
1374 DPRINTK(
"Module number error \n");
1467 unsigned int dw_Status;
1469 unsigned char b_TorCounter;
1470 unsigned char *pb_TimingUnit;
1471 unsigned int *pul_TimingInterval;
1472 unsigned char *pb_InputMode;
1473 unsigned char *pb_ExternGate;
1474 unsigned char *pb_CycleMode;
1475 unsigned char *pb_Enable;
1476 unsigned char *pb_InterruptEnable;
1478 i_ReturnValue = insn->
n;
1482 pb_TimingUnit = (
unsigned char *) &data[0];
1483 pul_TimingInterval = (
unsigned int *) &data[1];
1484 pb_InputMode = (
unsigned char *) &data[2];
1485 pb_ExternGate = (
unsigned char *) &data[3];
1486 pb_CycleMode = (
unsigned char *) &data[4];
1487 pb_Enable = (
unsigned char *) &data[5];
1488 pb_InterruptEnable = (
unsigned char *) &data[6];
1494 if (b_ModulNbr < 4) {
1500 dw_MolduleConfiguration[b_ModulNbr] &
1506 if (b_TorCounter <= 1) {
1513 ui_Address + 8 + (16 * b_TorCounter) +
1516 if (dw_Status & 0x10) {
1517 *pb_Enable = dw_Status & 1;
1525 (16 * b_TorCounter) +
1529 (
unsigned char) ((dw_Status >> 4) & 1);
1530 *pb_InterruptEnable =
1531 (
unsigned char) ((dw_Status >> 5) & 1);
1537 if (dw_Status & 0x600) {
1542 if (dw_Status & 0x400) {
1547 if ((dw_Status & 0x7800)
1557 if ((dw_Status & 0x7800)
1567 if ((dw_Status & 0x7800)
1585 (
unsigned char) ((dw_Status >> 6)
1588 (
unsigned char) ((dw_Status >> 7)
1595 s_TorCounterModuleInfo.
1596 s_TorCounterInfo[b_TorCounter].
1599 *pul_TimingInterval =
1602 s_TorCounterModuleInfo.
1603 s_TorCounterInfo[b_TorCounter].
1604 ul_RealTimingInterval;
1610 DPRINTK(
"Tor counter not initialised\n");
1620 DPRINTK(
"Tor counter selection is wrong \n");
1628 DPRINTK(
"The module is not a tor counter module\n");
1636 DPRINTK(
"Module number error\n");
1707 unsigned int dw_Status;
1708 unsigned int dw_TimeOut = 0;
1711 unsigned char b_TorCounter;
1712 unsigned char b_ReadType;
1713 unsigned int ui_TimeOut;
1714 unsigned char *pb_TorCounterStatus;
1715 unsigned int *pul_TorCounterValue;
1717 i_ReturnValue = insn->
n;
1719 b_ReadType = (
unsigned char) data[0];
1720 b_TorCounter = (
unsigned char) data[1];
1721 ui_TimeOut = (
unsigned int) data[2];
1722 pb_TorCounterStatus = (
unsigned char *) &data[0];
1723 pul_TorCounterValue = (
unsigned int *) &data[1];
1731 data[0] =
devpriv->s_InterruptParameters.
1732 s_FIFOInterruptParameters[
devpriv->
1733 s_InterruptParameters.ui_Read].b_OldModuleMask;
1734 data[1] =
devpriv->s_InterruptParameters.
1735 s_FIFOInterruptParameters[
devpriv->
1736 s_InterruptParameters.ui_Read].ul_OldInterruptMask;
1737 data[2] =
devpriv->s_InterruptParameters.
1738 s_FIFOInterruptParameters[
devpriv->
1739 s_InterruptParameters.ui_Read].ul_OldCounterLatchValue;
1746 s_InterruptParameters.
1748 s_InterruptParameters.
1754 if (b_ModulNbr < 4) {
1760 dw_MolduleConfiguration[b_ModulNbr] &
1766 if (b_TorCounter <= 1) {
1772 ui_Address + 8 + (16 * b_TorCounter) +
1779 if (dw_Status & 0x10) {
1784 if (dw_Status & 0x1) {
1786 switch (b_ReadType) {
1797 (16 * b_TorCounter) + (64 * b_ModulNbr));
1806 if (dw_Status & 1) {
1809 if (dw_Status & 4) {
1814 *pb_TorCounterStatus
1822 *pb_TorCounterStatus
1831 *pb_TorCounterStatus
1840 *pb_TorCounterStatus
1851 if ((ui_TimeOut >= 0)
1870 (16 * b_TorCounter) + (64 * b_ModulNbr));
1875 if ((dw_Status & 4) == 4) {
1880 *pb_TorCounterStatus
1888 *pul_TorCounterValue
1897 (16 * b_TorCounter) + (64 * b_ModulNbr));
1905 if ((dw_Status & 2) == 2) {
1910 *pb_TorCounterStatus
1918 *pul_TorCounterValue
1927 (16 * b_TorCounter) + (64 * b_ModulNbr));
1936 if ((dw_Status & 1) == 1) {
1941 *pb_TorCounterStatus
1950 *pb_TorCounterStatus
1957 if (dw_TimeOut == ui_TimeOut) {
1982 if ((*pb_TorCounterStatus != 3) && (dw_TimeOut == ui_TimeOut) && (ui_TimeOut != 0)) {
1987 *pb_TorCounterStatus
1996 DPRINTK(
"Timeout parameter is wrong\n");
2003 printk(
"Inputs wrong\n");
2011 DPRINTK(
"Tor counter not enabled\n");
2019 DPRINTK(
"Tor counter not initialised\n");
2028 DPRINTK(
"Tor counter selection is wrong\n");
2036 DPRINTK(
"The module is not a tor counter module\n");
2044 DPRINTK(
"Module number error\n");