1c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH/* 2c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. 3c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * 4c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * ADDI-DATA GmbH 5c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * Dieselstrasse 3 6c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * D-77833 Ottersweier 7c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * Tel: +19(0)7223/9493-0 8c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * Fax: +49(0)7223/9493-92 9c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * http://www.addi-data.com 10c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * info@addi-data.com 11c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * 12c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * This program is free software; you can redistribute it and/or modify it under 13c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * the terms of the GNU General Public License as published by the Free Software 14c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * Foundation; either version 2 of the License, or (at your option) any later 15c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * version. 16c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * 17c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * This program is distributed in the hope that it will be useful, but WITHOUT 18c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 20c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * details. 21c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers */ 22c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH 239b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten/* Card Specific information */ 249b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define APCI035_ADDRESS_RANGE 255 259b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten 269b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten/* Timer / Watchdog Related Defines */ 279b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define APCI035_TCW_SYNC_ENABLEDISABLE 0 289b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define APCI035_TCW_RELOAD_VALUE 4 299b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define APCI035_TCW_TIMEBASE 8 309b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define APCI035_TCW_PROG 12 319b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define APCI035_TCW_TRIG_STATUS 16 329b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define APCI035_TCW_IRQ 20 339b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define APCI035_TCW_WARN_TIMEVAL 24 349b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define APCI035_TCW_WARN_TIMEBASE 28 359b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten 369b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define ADDIDATA_TIMER 0 379b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten/* #define ADDIDATA_WATCHDOG 1 */ 389b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten 399b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define APCI035_TW1 0 409b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define APCI035_TW2 32 419b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define APCI035_TW3 64 429b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define APCI035_TW4 96 439b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten 449b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define APCI035_AI_OFFSET 0 459b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define APCI035_TEMP 128 469b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define APCI035_ALR_SEQ 4 479b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define APCI035_START_STOP_INDEX 8 489b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define APCI035_ALR_START_STOP 12 499b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define APCI035_ALR_IRQ 16 509b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define APCI035_EOS 20 519b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define APCI035_CHAN_NO 24 529b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define APCI035_CHAN_VAL 28 539b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define APCI035_CONV_TIME_TIME_BASE 36 549b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define APCI035_RELOAD_CONV_TIME_VAL 32 559b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define APCI035_DELAY_TIME_TIME_BASE 44 569b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define APCI035_RELOAD_DELAY_TIME_VAL 40 579b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define ENABLE_EXT_TRIG 1 589b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define ENABLE_EXT_GATE 2 599b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define ENABLE_EXT_TRIG_GATE 3 609b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten 619b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define ANALOG_INPUT 0 629b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define TEMPERATURE 1 639b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define RESISTANCE 2 649b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten 659b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define ADDIDATA_GREATER_THAN_TEST 0 669b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define ADDIDATA_LESS_THAN_TEST 1 679b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten 689b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define APCI035_MAXVOLT 2.5 699b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten 709b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define ADDIDATA_UNIPOLAR 1 719b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten#define ADDIDATA_BIPOLAR 2 729b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten 739b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten/* ANALOG INPUT RANGE */ 749b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweetenstatic struct comedi_lrange range_apci035_ai = { 759b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten 8, { 769b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten BIP_RANGE(10), 779b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten BIP_RANGE(5), 789b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten BIP_RANGE(2), 799b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten BIP_RANGE(1), 809b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten UNI_RANGE(10), 819b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten UNI_RANGE(5), 829b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten UNI_RANGE(2), 839b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten UNI_RANGE(1) 849b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten } 859b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten}; 869b2b9a348ec4012c6807c6648f76da03c120bd7aH Hartley Sweeten 8755761166cff31707b83d9d3282d0f77ce805ea87Chase Southwoodstatic int i_WatchdogNbr; 8855761166cff31707b83d9d3282d0f77ce805ea87Chase Southwoodstatic int i_Temp; 8908b93e7bda617a623ffae77940e4acfa31204367Greg Kroah-Hartmanstatic int i_Flag = 1; 90c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers 91c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH/* 92c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * Configures The Timer , Counter or Watchdog 93c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * 94c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * data[0] 0 = Configure As Timer, 1 = Configure As Watchdog 95c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * data[1] Watchdog number 96c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * data[2] Time base Unit 97c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * data[3] Reload Value 98c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * data[4] External Trigger, 1 = Enable, 0 = Disable 99c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * data[5] External Trigger Level 100c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * 00 = Trigger Disabled 101c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * 01 = Trigger Enabled (Low level) 102c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * 10 = Trigger Enabled (High Level) 103c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * 11 = Trigger Enabled (High/Low level) 104c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * data[6] External Gate, 1 = Enable, 0 = Disable 105c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * data[7] External Gate level 106c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * 00 = Gate Disabled 107c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * 01 = Gate Enabled (Low level) 108c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * 10 = Gate Enabled (High Level) 109c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * data[8] Warning Relay, 1 = Enable, 0 = Disable 110c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * data[9] Warning Delay available 111c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * data[10] Warning Relay Time unit 112c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * data[11] Warning Relay Time Reload value 113c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * data[12] Reset Relay, 1 = Enable, 0 = Disable 114c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * data[13] Interrupt, 1 = Enable, 0 = Disable 115c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers */ 116805077b90c5a290ec050d5003a4ea9e37be48453Fred Akersstatic int apci035_timer_config(struct comedi_device *dev, 117805077b90c5a290ec050d5003a4ea9e37be48453Fred Akers struct comedi_subdevice *s, 118805077b90c5a290ec050d5003a4ea9e37be48453Fred Akers struct comedi_insn *insn, 119805077b90c5a290ec050d5003a4ea9e37be48453Fred Akers unsigned int *data) 120c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH{ 121843690b7d9c9cd4a2cc77e04ed610d100e599a15H Hartley Sweeten struct addi_private *devpriv = dev->private; 12254e4c9ee0db1e7637e752c42efd4454ef5dc7cd4Chase Southwood unsigned int ui_Status; 12354e4c9ee0db1e7637e752c42efd4454ef5dc7cd4Chase Southwood unsigned int ui_Command; 12454e4c9ee0db1e7637e752c42efd4454ef5dc7cd4Chase Southwood unsigned int ui_Mode; 125843690b7d9c9cd4a2cc77e04ed610d100e599a15H Hartley Sweeten 126c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH i_Temp = 0; 127c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH devpriv->tsk_Current = current; 128c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH devpriv->b_TimerSelectMode = data[0]; 129c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH i_WatchdogNbr = data[1]; 13020758c5b912b47939300e7f67d6d124899caedd5Chase Southwood if (data[0] == 0) 131c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Mode = 2; 13220758c5b912b47939300e7f67d6d124899caedd5Chase Southwood else 133c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Mode = 0; 13420758c5b912b47939300e7f67d6d124899caedd5Chase Southwood 135c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = 0; 136c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); 137ea6ff788fefcb71e08fa0b1ec82c3430053bbbc2Chase Southwood 138c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); 13985b3842bd2d4f295b24254464eb103f85f9e5663Chase Southwood 140bc0be59eb6c1eb3e675a3c750478bb4cb900ea3aChase Southwood /* Set the reload value */ 141c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH outl(data[3], devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 4); 14285b3842bd2d4f295b24254464eb103f85f9e5663Chase Southwood 143bc0be59eb6c1eb3e675a3c750478bb4cb900ea3aChase Southwood /* Set the time unit */ 144c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH outl(data[2], devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 8); 145c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH if (data[0] == ADDIDATA_TIMER) { 146c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH 147c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH /* Set the mode : */ 148c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH /* - Disable the hardware */ 149c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH /* - Disable the counter mode */ 150c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH /* - Disable the warning */ 151c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH /* - Disable the reset */ 152c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH /* - Enable the timer mode */ 153c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH /* - Set the timer mode */ 154c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH 155c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = 156c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH (ui_Command & 0xFFF719E2UL) | ui_Mode << 13UL | 0x10UL; 157c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH 158711b888ea60a8002789ac04522cf38dfa7923fdcChase Southwood } else if (data[0] == ADDIDATA_WATCHDOG) { 159c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH 160711b888ea60a8002789ac04522cf38dfa7923fdcChase Southwood /* Set the mode : */ 161711b888ea60a8002789ac04522cf38dfa7923fdcChase Southwood /* - Disable the hardware */ 162711b888ea60a8002789ac04522cf38dfa7923fdcChase Southwood /* - Disable the counter mode */ 163711b888ea60a8002789ac04522cf38dfa7923fdcChase Southwood /* - Disable the warning */ 164711b888ea60a8002789ac04522cf38dfa7923fdcChase Southwood /* - Disable the reset */ 165711b888ea60a8002789ac04522cf38dfa7923fdcChase Southwood /* - Disable the timer mode */ 166c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH 167711b888ea60a8002789ac04522cf38dfa7923fdcChase Southwood ui_Command = ui_Command & 0xFFF819E2UL; 168c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH 169711b888ea60a8002789ac04522cf38dfa7923fdcChase Southwood } else { 170711b888ea60a8002789ac04522cf38dfa7923fdcChase Southwood dev_err(dev->class_dev, "The parameter for Timer/watchdog selection is in error\n"); 171711b888ea60a8002789ac04522cf38dfa7923fdcChase Southwood return -EINVAL; 172c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH } 173711b888ea60a8002789ac04522cf38dfa7923fdcChase Southwood 174c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); 175ea6ff788fefcb71e08fa0b1ec82c3430053bbbc2Chase Southwood 176c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); 17785b3842bd2d4f295b24254464eb103f85f9e5663Chase Southwood 178bc0be59eb6c1eb3e675a3c750478bb4cb900ea3aChase Southwood /* Disable the hardware trigger */ 179c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = ui_Command & 0xFFFFF89FUL; 18002dc1e78a238627a0876695b8c84deca78e4435aH Hartley Sweeten if (data[4] == 1) { 181c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH /* Set the hardware trigger level */ 182c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = ui_Command | (data[5] << 5); 183c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH } 184c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); 185ea6ff788fefcb71e08fa0b1ec82c3430053bbbc2Chase Southwood 186c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); 18785b3842bd2d4f295b24254464eb103f85f9e5663Chase Southwood 188bc0be59eb6c1eb3e675a3c750478bb4cb900ea3aChase Southwood /* Disable the hardware gate */ 189c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = ui_Command & 0xFFFFF87FUL; 19002dc1e78a238627a0876695b8c84deca78e4435aH Hartley Sweeten if (data[6] == 1) { 191bc0be59eb6c1eb3e675a3c750478bb4cb900ea3aChase Southwood /* Set the hardware gate level */ 192c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = ui_Command | (data[7] << 7); 193c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH } 194c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); 195ea6ff788fefcb71e08fa0b1ec82c3430053bbbc2Chase Southwood 196c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); 19785b3842bd2d4f295b24254464eb103f85f9e5663Chase Southwood 198bc0be59eb6c1eb3e675a3c750478bb4cb900ea3aChase Southwood /* Disable the hardware output */ 199c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = ui_Command & 0xFFFFF9FBUL; 20085b3842bd2d4f295b24254464eb103f85f9e5663Chase Southwood 201bc0be59eb6c1eb3e675a3c750478bb4cb900ea3aChase Southwood /* Set the hardware output level */ 202c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = ui_Command | (data[8] << 2); 203c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); 20402dc1e78a238627a0876695b8c84deca78e4435aH Hartley Sweeten if (data[9] == 1) { 205c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH /* Set the reload value */ 206c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH outl(data[11], 207c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 24); 20885b3842bd2d4f295b24254464eb103f85f9e5663Chase Southwood 209c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH /* Set the time unite */ 210c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH outl(data[10], 211c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 28); 212c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH } 213c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH 214c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); 21585b3842bd2d4f295b24254464eb103f85f9e5663Chase Southwood 216c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH /* Disable the hardware output */ 217c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = ui_Command & 0xFFFFF9F7UL; 21885b3842bd2d4f295b24254464eb103f85f9e5663Chase Southwood 219c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH /* Set the hardware output level */ 220c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = ui_Command | (data[12] << 3); 221c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); 22285b3842bd2d4f295b24254464eb103f85f9e5663Chase Southwood 22385b3842bd2d4f295b24254464eb103f85f9e5663Chase Southwood /* Enable the watchdog interrupt */ 224c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); 22585b3842bd2d4f295b24254464eb103f85f9e5663Chase Southwood 226bc0be59eb6c1eb3e675a3c750478bb4cb900ea3aChase Southwood /* Set the interrupt selection */ 227c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Status = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 16); 228c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH 229c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = (ui_Command & 0xFFFFF9FDUL) | (data[13] << 1); 230c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH outl(ui_Command, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); 231c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH 232c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH return insn->n; 233c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH} 234c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH 235c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH/* 236c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * Start / Stop The Selected Timer , or Watchdog 237c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * 238c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * data[0] 239c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * 0 - Stop Selected Timer/Watchdog 240c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * 1 - Start Selected Timer/Watch*dog 241c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * 2 - Trigger Selected Timer/Watchdog 242c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * 3 - Stop All Timer/Watchdog 243c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * 4 - Start All Timer/Watchdog 244c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * 5 - Trigger All Timer/Watchdog 245c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers */ 246805077b90c5a290ec050d5003a4ea9e37be48453Fred Akersstatic int apci035_timer_write(struct comedi_device *dev, 247805077b90c5a290ec050d5003a4ea9e37be48453Fred Akers struct comedi_subdevice *s, 248805077b90c5a290ec050d5003a4ea9e37be48453Fred Akers struct comedi_insn *insn, 249805077b90c5a290ec050d5003a4ea9e37be48453Fred Akers unsigned int *data) 250c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH{ 251843690b7d9c9cd4a2cc77e04ed610d100e599a15H Hartley Sweeten struct addi_private *devpriv = dev->private; 25254e4c9ee0db1e7637e752c42efd4454ef5dc7cd4Chase Southwood unsigned int ui_Command; 25354e4c9ee0db1e7637e752c42efd4454ef5dc7cd4Chase Southwood int i_Count; 254843690b7d9c9cd4a2cc77e04ed610d100e599a15H Hartley Sweeten 255c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH if (data[0] == 1) { 256c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = 257c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); 25885b3842bd2d4f295b24254464eb103f85f9e5663Chase Southwood 259c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH /* Start the hardware */ 260c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = (ui_Command & 0xFFFFF9FFUL) | 0x1UL; 261c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH outl(ui_Command, 262c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); 26385b3842bd2d4f295b24254464eb103f85f9e5663Chase Southwood } 264c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH if (data[0] == 2) { 265c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = 266c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); 26785b3842bd2d4f295b24254464eb103f85f9e5663Chase Southwood 268c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH /* Set the trigger command */ 269c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = (ui_Command & 0xFFFFF9FFUL) | 0x200UL; 270c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH outl(ui_Command, 271c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); 272c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH } 273c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH 27420758c5b912b47939300e7f67d6d124899caedd5Chase Southwood if (data[0] == 0) { 2752696fb57e6af653dd8b4df41b16754579f42fc78Bill Pemberton /* Stop The Watchdog */ 276c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = 0; 277bc0be59eb6c1eb3e675a3c750478bb4cb900ea3aChase Southwood /* 278bc0be59eb6c1eb3e675a3c750478bb4cb900ea3aChase Southwood * ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12); 279bc0be59eb6c1eb3e675a3c750478bb4cb900ea3aChase Southwood * ui_Command = ui_Command & 0xFFFFF9FEUL; 280bc0be59eb6c1eb3e675a3c750478bb4cb900ea3aChase Southwood */ 281c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH outl(ui_Command, 282c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 12); 28385b3842bd2d4f295b24254464eb103f85f9e5663Chase Southwood } 28420758c5b912b47939300e7f67d6d124899caedd5Chase Southwood if (data[0] == 3) { 28520758c5b912b47939300e7f67d6d124899caedd5Chase Southwood /* stop all Watchdogs */ 286c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = 0; 287c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH for (i_Count = 1; i_Count <= 4; i_Count++) { 28820758c5b912b47939300e7f67d6d124899caedd5Chase Southwood if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) 289c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = 0x2UL; 29020758c5b912b47939300e7f67d6d124899caedd5Chase Southwood else 291c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = 0x10UL; 29220758c5b912b47939300e7f67d6d124899caedd5Chase Southwood 293c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH i_WatchdogNbr = i_Count; 294c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH outl(ui_Command, 295c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 296c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH 0); 297c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH } 298c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH 299c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH } 30020758c5b912b47939300e7f67d6d124899caedd5Chase Southwood if (data[0] == 4) { 30120758c5b912b47939300e7f67d6d124899caedd5Chase Southwood /* start all Watchdogs */ 302c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = 0; 303c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH for (i_Count = 1; i_Count <= 4; i_Count++) { 30420758c5b912b47939300e7f67d6d124899caedd5Chase Southwood if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) 305c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = 0x1UL; 30620758c5b912b47939300e7f67d6d124899caedd5Chase Southwood else 307c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = 0x8UL; 30820758c5b912b47939300e7f67d6d124899caedd5Chase Southwood 309c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH i_WatchdogNbr = i_Count; 310c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH outl(ui_Command, 311c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 312c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH 0); 313c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH } 314c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH } 31520758c5b912b47939300e7f67d6d124899caedd5Chase Southwood if (data[0] == 5) { 31620758c5b912b47939300e7f67d6d124899caedd5Chase Southwood /* trigger all Watchdogs */ 317c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = 0; 318c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH for (i_Count = 1; i_Count <= 4; i_Count++) { 31920758c5b912b47939300e7f67d6d124899caedd5Chase Southwood if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) 320c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = 0x4UL; 32120758c5b912b47939300e7f67d6d124899caedd5Chase Southwood else 322c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Command = 0x20UL; 323c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH 324c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH i_WatchdogNbr = i_Count; 325c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH outl(ui_Command, 326c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 327c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH 0); 328c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH } 329c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH i_Temp = 1; 330c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH } 331c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH return insn->n; 332c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH} 333c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH 334c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH/* 335c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * Read The Selected Timer , Counter or Watchdog 336c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * 337c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * data[0] software trigger status 338c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * data[1] hardware trigger status 339c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * data[2] Software clear status 340c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * data[3] Overflow status 341c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * data[4] Timer actual value 342c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers */ 343805077b90c5a290ec050d5003a4ea9e37be48453Fred Akersstatic int apci035_timer_read(struct comedi_device *dev, 344805077b90c5a290ec050d5003a4ea9e37be48453Fred Akers struct comedi_subdevice *s, 345805077b90c5a290ec050d5003a4ea9e37be48453Fred Akers struct comedi_insn *insn, 346805077b90c5a290ec050d5003a4ea9e37be48453Fred Akers unsigned int *data) 347c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH{ 348843690b7d9c9cd4a2cc77e04ed610d100e599a15H Hartley Sweeten struct addi_private *devpriv = dev->private; 34954e4c9ee0db1e7637e752c42efd4454ef5dc7cd4Chase Southwood unsigned int ui_Status; /* Status register */ 350843690b7d9c9cd4a2cc77e04ed610d100e599a15H Hartley Sweeten 351c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH i_WatchdogNbr = insn->unused[0]; 352356cdbcb838ebcc234a43ec81621a39231fdcb7aBill Pemberton 353c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH /* Get the status */ 354c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_Status = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 16); 355356cdbcb838ebcc234a43ec81621a39231fdcb7aBill Pemberton 356c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH /* Get the software trigger status */ 357c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH data[0] = ((ui_Status >> 1) & 1); 35885b3842bd2d4f295b24254464eb103f85f9e5663Chase Southwood 359c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH /* Get the hardware trigger status */ 360c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH data[1] = ((ui_Status >> 2) & 1); 36185b3842bd2d4f295b24254464eb103f85f9e5663Chase Southwood 362c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH /* Get the software clear status */ 363c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH data[2] = ((ui_Status >> 3) & 1); 36485b3842bd2d4f295b24254464eb103f85f9e5663Chase Southwood 365c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH /* Get the overflow status */ 366c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH data[3] = ((ui_Status >> 0) & 1); 36720758c5b912b47939300e7f67d6d124899caedd5Chase Southwood if (devpriv->b_TimerSelectMode == ADDIDATA_TIMER) 368c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH data[4] = inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 0); 369c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH 370c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH return insn->n; 371c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH} 372c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH 373c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH/* 374c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * Configures The Analog Input Subdevice 375c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * 376c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * data[0] Warning delay value 377c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers */ 378805077b90c5a290ec050d5003a4ea9e37be48453Fred Akersstatic int apci035_ai_config(struct comedi_device *dev, 379805077b90c5a290ec050d5003a4ea9e37be48453Fred Akers struct comedi_subdevice *s, 380805077b90c5a290ec050d5003a4ea9e37be48453Fred Akers struct comedi_insn *insn, 381805077b90c5a290ec050d5003a4ea9e37be48453Fred Akers unsigned int *data) 382c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH{ 383843690b7d9c9cd4a2cc77e04ed610d100e599a15H Hartley Sweeten struct addi_private *devpriv = dev->private; 384843690b7d9c9cd4a2cc77e04ed610d100e599a15H Hartley Sweeten 385c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH devpriv->tsk_Current = current; 386c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH outl(0x200 | 0, devpriv->iobase + 128 + 0x4); 387c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH outl(0, devpriv->iobase + 128 + 0); 38885b3842bd2d4f295b24254464eb103f85f9e5663Chase Southwood 389bc0be59eb6c1eb3e675a3c750478bb4cb900ea3aChase Southwood /* Initialise the warning value */ 390c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH outl(0x300 | 0, devpriv->iobase + 128 + 0x4); 391c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH outl((data[0] << 8), devpriv->iobase + 128 + 0); 392c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH outl(0x200000UL, devpriv->iobase + 128 + 12); 393c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH 394c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH return insn->n; 395c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH} 396c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH 397c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH/* 398c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * Read value of the selected channel 399c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * 400c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers * data[0] Digital Value Of Input 401c5a20c4f5cbf1390f31f382d6fa28f592aa1914cFred Akers */ 402805077b90c5a290ec050d5003a4ea9e37be48453Fred Akersstatic int apci035_ai_read(struct comedi_device *dev, 403805077b90c5a290ec050d5003a4ea9e37be48453Fred Akers struct comedi_subdevice *s, 404805077b90c5a290ec050d5003a4ea9e37be48453Fred Akers struct comedi_insn *insn, 405805077b90c5a290ec050d5003a4ea9e37be48453Fred Akers unsigned int *data) 406c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH{ 407843690b7d9c9cd4a2cc77e04ed610d100e599a15H Hartley Sweeten struct addi_private *devpriv = dev->private; 40854e4c9ee0db1e7637e752c42efd4454ef5dc7cd4Chase Southwood unsigned int ui_CommandRegister; 409843690b7d9c9cd4a2cc77e04ed610d100e599a15H Hartley Sweeten 410bc0be59eb6c1eb3e675a3c750478bb4cb900ea3aChase Southwood /* Set the start */ 411c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_CommandRegister = 0x80000; 41285b3842bd2d4f295b24254464eb103f85f9e5663Chase Southwood 413c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH /* Write the command register */ 414c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH outl(ui_CommandRegister, devpriv->iobase + 128 + 8); 415c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH 416bc0be59eb6c1eb3e675a3c750478bb4cb900ea3aChase Southwood /* Read the digital value of the input */ 417c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH data[0] = inl(devpriv->iobase + 128 + 28); 418c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH return insn->n; 419c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH} 420c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH 421805077b90c5a290ec050d5003a4ea9e37be48453Fred Akersstatic int apci035_reset(struct comedi_device *dev) 422c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH{ 423843690b7d9c9cd4a2cc77e04ed610d100e599a15H Hartley Sweeten struct addi_private *devpriv = dev->private; 42454e4c9ee0db1e7637e752c42efd4454ef5dc7cd4Chase Southwood int i_Count; 425843690b7d9c9cd4a2cc77e04ed610d100e599a15H Hartley Sweeten 426c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH for (i_Count = 1; i_Count <= 4; i_Count++) { 427c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH i_WatchdogNbr = i_Count; 42829f813859663974296ad436c40253c40a64694a0Chase Southwood 42929f813859663974296ad436c40253c40a64694a0Chase Southwood /* stop all timers */ 43029f813859663974296ad436c40253c40a64694a0Chase Southwood outl(0x0, devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 0); 431c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH } 4322696fb57e6af653dd8b4df41b16754579f42fc78Bill Pemberton outl(0x0, devpriv->iobase + 128 + 12); /* Disable the warning delay */ 433c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH 434c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH return 0; 435c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH} 436c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH 437805077b90c5a290ec050d5003a4ea9e37be48453Fred Akersstatic void apci035_interrupt(int irq, void *d) 438c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH{ 43971b5f4f11971dea972832ad63a994c7e5b45db6bBill Pemberton struct comedi_device *dev = d; 440843690b7d9c9cd4a2cc77e04ed610d100e599a15H Hartley Sweeten struct addi_private *devpriv = dev->private; 44154e4c9ee0db1e7637e752c42efd4454ef5dc7cd4Chase Southwood unsigned int ui_StatusRegister1; 44254e4c9ee0db1e7637e752c42efd4454ef5dc7cd4Chase Southwood unsigned int ui_StatusRegister2; 44354e4c9ee0db1e7637e752c42efd4454ef5dc7cd4Chase Southwood unsigned int ui_ReadCommand; 44454e4c9ee0db1e7637e752c42efd4454ef5dc7cd4Chase Southwood unsigned int ui_ChannelNumber; 44554e4c9ee0db1e7637e752c42efd4454ef5dc7cd4Chase Southwood unsigned int ui_DigitalTemperature; 446843690b7d9c9cd4a2cc77e04ed610d100e599a15H Hartley Sweeten 447c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH if (i_Temp == 1) { 448c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH i_WatchdogNbr = i_Flag; 449c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH i_Flag = i_Flag + 1; 450c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH } 45185b3842bd2d4f295b24254464eb103f85f9e5663Chase Southwood 452c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH /* Read the interrupt status register of temperature Warning */ 453c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_StatusRegister1 = inl(devpriv->iobase + 128 + 16); 454c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH 45585b3842bd2d4f295b24254464eb103f85f9e5663Chase Southwood /* Read the interrupt status register for Watchdog/timer */ 456c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_StatusRegister2 = 457c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH inl(devpriv->iobase + ((i_WatchdogNbr - 1) * 32) + 20); 458c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH 45920758c5b912b47939300e7f67d6d124899caedd5Chase Southwood /* Test if warning relay interrupt */ 46020758c5b912b47939300e7f67d6d124899caedd5Chase Southwood if ((((ui_StatusRegister1) & 0x8) == 0x8)) { 46185b3842bd2d4f295b24254464eb103f85f9e5663Chase Southwood 462c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH /* Disable the temperature warning */ 463c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_ReadCommand = inl(devpriv->iobase + 128 + 12); 464c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_ReadCommand = ui_ReadCommand & 0xFFDF0000UL; 465c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH outl(ui_ReadCommand, devpriv->iobase + 128 + 12); 46685b3842bd2d4f295b24254464eb103f85f9e5663Chase Southwood 467c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH /* Read the channel number */ 468c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_ChannelNumber = inl(devpriv->iobase + 128 + 60); 46985b3842bd2d4f295b24254464eb103f85f9e5663Chase Southwood 470c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH /* Read the digital temperature value */ 471c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH ui_DigitalTemperature = inl(devpriv->iobase + 128 + 60); 47229f813859663974296ad436c40253c40a64694a0Chase Southwood 47329f813859663974296ad436c40253c40a64694a0Chase Southwood /* send signal to the sample */ 47429f813859663974296ad436c40253c40a64694a0Chase Southwood send_sig(SIGIO, devpriv->tsk_Current, 0); 475c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH 476711b888ea60a8002789ac04522cf38dfa7923fdcChase Southwood } else if ((ui_StatusRegister2 & 0x1) == 0x1) { 47729f813859663974296ad436c40253c40a64694a0Chase Southwood /* send signal to the sample */ 47829f813859663974296ad436c40253c40a64694a0Chase Southwood send_sig(SIGIO, devpriv->tsk_Current, 0); 47985b3842bd2d4f295b24254464eb103f85f9e5663Chase Southwood } 480c995fe9475e062bab6f5a45ed28cd2d3d955ef43ADDI-DATA GmbH} 481