Blame view
drivers/char/rocket.c
97.2 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
/* * RocketPort device driver for Linux * * Written by Theodore Ts'o, 1995, 1996, 1997, 1998, 1999, 2000. * * Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2003 by Comtrol, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* * Kernel Synchronization: * * This driver has 2 kernel control paths - exception handlers (calls into the driver * from user mode) and the timer bottom half (tasklet). This is a polled driver, interrupts * are not used. * * Critical data: * - rp_table[], accessed through passed "info" pointers, is a global (static) array of * serial port state information and the xmit_buf circular buffer. Protected by * a per port spinlock. * - xmit_flags[], an array of ints indexed by line (port) number, indicating that there * is data to be transmitted. Protected by atomic bit operations. * - rp_num_ports, int indicating number of open ports, protected by atomic operations. * * rp_write() and rp_write_char() functions use a per port semaphore to protect against * simultaneous access to the same port by more than one process. */ /****** Defines ******/ |
1da177e4c Linux-2.6.12-rc2 |
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
#define ROCKET_PARANOIA_CHECK #define ROCKET_DISABLE_SIMUSAGE #undef ROCKET_SOFT_FLOW #undef ROCKET_DEBUG_OPEN #undef ROCKET_DEBUG_INTR #undef ROCKET_DEBUG_WRITE #undef ROCKET_DEBUG_FLOW #undef ROCKET_DEBUG_THROTTLE #undef ROCKET_DEBUG_WAIT_UNTIL_SENT #undef ROCKET_DEBUG_RECEIVE #undef ROCKET_DEBUG_HANGUP #undef REV_PCI_ORDER #undef ROCKET_DEBUG_IO #define POLL_PERIOD HZ/100 /* Polling period .01 seconds (10ms) */ /****** Kernel includes ******/ |
1da177e4c Linux-2.6.12-rc2 |
61 62 63 64 65 66 67 68 69 70 71 72 73 |
#include <linux/module.h> #include <linux/errno.h> #include <linux/major.h> #include <linux/kernel.h> #include <linux/signal.h> #include <linux/slab.h> #include <linux/mm.h> #include <linux/sched.h> #include <linux/timer.h> #include <linux/interrupt.h> #include <linux/tty.h> #include <linux/tty_driver.h> #include <linux/tty_flip.h> |
44b7d1b37 tty: add more tty... |
74 |
#include <linux/serial.h> |
1da177e4c Linux-2.6.12-rc2 |
75 76 77 |
#include <linux/string.h> #include <linux/fcntl.h> #include <linux/ptrace.h> |
69f545ea6 use mutex instead... |
78 |
#include <linux/mutex.h> |
1da177e4c Linux-2.6.12-rc2 |
79 80 |
#include <linux/ioport.h> #include <linux/delay.h> |
8cf5a8c57 Char: rocket, swi... |
81 |
#include <linux/completion.h> |
1da177e4c Linux-2.6.12-rc2 |
82 83 |
#include <linux/wait.h> #include <linux/pci.h> |
44b7d1b37 tty: add more tty... |
84 |
#include <linux/uaccess.h> |
1da177e4c Linux-2.6.12-rc2 |
85 |
#include <asm/atomic.h> |
457fb6058 drivers/char/rock... |
86 |
#include <asm/unaligned.h> |
1da177e4c Linux-2.6.12-rc2 |
87 88 |
#include <linux/bitops.h> #include <linux/spinlock.h> |
1da177e4c Linux-2.6.12-rc2 |
89 90 91 92 93 94 95 96 97 98 99 |
#include <linux/init.h> /****** RocketPort includes ******/ #include "rocket_int.h" #include "rocket.h" #define ROCKET_VERSION "2.09" #define ROCKET_DATE "12-June-2003" /****** RocketPort Local Variables ******/ |
40565f196 [PATCH] Char: tim... |
100 |
static void rp_do_poll(unsigned long dummy); |
1da177e4c Linux-2.6.12-rc2 |
101 102 103 104 105 106 107 108 109 110 |
static struct tty_driver *rocket_driver; static struct rocket_version driver_version = { ROCKET_VERSION, ROCKET_DATE }; static struct r_port *rp_table[MAX_RP_PORTS]; /* The main repository of serial port state information. */ static unsigned int xmit_flags[NUM_BOARDS]; /* Bit significant, indicates port had data to transmit. */ /* eg. Bit 0 indicates port 0 has xmit data, ... */ static atomic_t rp_num_ports_open; /* Number of serial ports open */ |
40565f196 [PATCH] Char: tim... |
111 |
static DEFINE_TIMER(rocket_timer, rp_do_poll, 0, 0); |
1da177e4c Linux-2.6.12-rc2 |
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
static unsigned long board1; /* ISA addresses, retrieved from rocketport.conf */ static unsigned long board2; static unsigned long board3; static unsigned long board4; static unsigned long controller; static int support_low_speed; static unsigned long modem1; static unsigned long modem2; static unsigned long modem3; static unsigned long modem4; static unsigned long pc104_1[8]; static unsigned long pc104_2[8]; static unsigned long pc104_3[8]; static unsigned long pc104_4[8]; static unsigned long *pc104[4] = { pc104_1, pc104_2, pc104_3, pc104_4 }; static int rp_baud_base[NUM_BOARDS]; /* Board config info (Someday make a per-board structure) */ static unsigned long rcktpt_io_addr[NUM_BOARDS]; static int rcktpt_type[NUM_BOARDS]; static int is_PCI[NUM_BOARDS]; static rocketModel_t rocketModel[NUM_BOARDS]; static int max_board; |
31f35939d tty_port: Add a p... |
135 |
static const struct tty_port_operations rocket_port_ops; |
1da177e4c Linux-2.6.12-rc2 |
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
/* * The following arrays define the interrupt bits corresponding to each AIOP. * These bits are different between the ISA and regular PCI boards and the * Universal PCI boards. */ static Word_t aiop_intr_bits[AIOP_CTL_SIZE] = { AIOP_INTR_BIT_0, AIOP_INTR_BIT_1, AIOP_INTR_BIT_2, AIOP_INTR_BIT_3 }; static Word_t upci_aiop_intr_bits[AIOP_CTL_SIZE] = { UPCI_AIOP_INTR_BIT_0, UPCI_AIOP_INTR_BIT_1, UPCI_AIOP_INTR_BIT_2, UPCI_AIOP_INTR_BIT_3 }; |
f15313bf4 [PATCH] drivers/c... |
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
static Byte_t RData[RDATASIZE] = { 0x00, 0x09, 0xf6, 0x82, 0x02, 0x09, 0x86, 0xfb, 0x04, 0x09, 0x00, 0x0a, 0x06, 0x09, 0x01, 0x0a, 0x08, 0x09, 0x8a, 0x13, 0x0a, 0x09, 0xc5, 0x11, 0x0c, 0x09, 0x86, 0x85, 0x0e, 0x09, 0x20, 0x0a, 0x10, 0x09, 0x21, 0x0a, 0x12, 0x09, 0x41, 0xff, 0x14, 0x09, 0x82, 0x00, 0x16, 0x09, 0x82, 0x7b, 0x18, 0x09, 0x8a, 0x7d, 0x1a, 0x09, 0x88, 0x81, 0x1c, 0x09, 0x86, 0x7a, 0x1e, 0x09, 0x84, 0x81, 0x20, 0x09, 0x82, 0x7c, 0x22, 0x09, 0x0a, 0x0a }; static Byte_t RRegData[RREGDATASIZE] = { 0x00, 0x09, 0xf6, 0x82, /* 00: Stop Rx processor */ 0x08, 0x09, 0x8a, 0x13, /* 04: Tx software flow control */ 0x0a, 0x09, 0xc5, 0x11, /* 08: XON char */ 0x0c, 0x09, 0x86, 0x85, /* 0c: XANY */ 0x12, 0x09, 0x41, 0xff, /* 10: Rx mask char */ 0x14, 0x09, 0x82, 0x00, /* 14: Compare/Ignore #0 */ 0x16, 0x09, 0x82, 0x7b, /* 18: Compare #1 */ 0x18, 0x09, 0x8a, 0x7d, /* 1c: Compare #2 */ 0x1a, 0x09, 0x88, 0x81, /* 20: Interrupt #1 */ 0x1c, 0x09, 0x86, 0x7a, /* 24: Ignore/Replace #1 */ 0x1e, 0x09, 0x84, 0x81, /* 28: Interrupt #2 */ 0x20, 0x09, 0x82, 0x7c, /* 2c: Ignore/Replace #2 */ 0x22, 0x09, 0x0a, 0x0a /* 30: Rx FIFO Enable */ }; static CONTROLLER_T sController[CTL_SIZE] = { {-1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0}, {-1, -1, -1, -1}, {0, 0, 0, 0}}, {-1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0}, {-1, -1, -1, -1}, {0, 0, 0, 0}}, {-1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0}, {-1, -1, -1, -1}, {0, 0, 0, 0}}, {-1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0}, {-1, -1, -1, -1}, {0, 0, 0, 0}} }; static Byte_t sBitMapClrTbl[8] = { 0xfe, 0xfd, 0xfb, 0xf7, 0xef, 0xdf, 0xbf, 0x7f }; static Byte_t sBitMapSetTbl[8] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }; static int sClockPrescale = 0x14; |
1da177e4c Linux-2.6.12-rc2 |
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
/* * Line number is the ttySIx number (x), the Minor number. We * assign them sequentially, starting at zero. The following * array keeps track of the line number assigned to a given board/aiop/channel. */ static unsigned char lineNumbers[MAX_RP_PORTS]; static unsigned long nextLineNumber; /***** RocketPort Static Prototypes *********/ static int __init init_ISA(int i); static void rp_wait_until_sent(struct tty_struct *tty, int timeout); static void rp_flush_buffer(struct tty_struct *tty); static void rmSpeakerReset(CONTROLLER_T * CtlP, unsigned long model); static unsigned char GetLineNumber(int ctrl, int aiop, int ch); static unsigned char SetLineNumber(int ctrl, int aiop, int ch); static void rp_start(struct tty_struct *tty); |
f15313bf4 [PATCH] drivers/c... |
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
static int sInitChan(CONTROLLER_T * CtlP, CHANNEL_T * ChP, int AiopNum, int ChanNum); static void sSetInterfaceMode(CHANNEL_T * ChP, Byte_t mode); static void sFlushRxFIFO(CHANNEL_T * ChP); static void sFlushTxFIFO(CHANNEL_T * ChP); static void sEnInterrupts(CHANNEL_T * ChP, Word_t Flags); static void sDisInterrupts(CHANNEL_T * ChP, Word_t Flags); static void sModemReset(CONTROLLER_T * CtlP, int chan, int on); static void sPCIModemReset(CONTROLLER_T * CtlP, int chan, int on); static int sWriteTxPrioByte(CHANNEL_T * ChP, Byte_t Data); static int sPCIInitController(CONTROLLER_T * CtlP, int CtlNum, ByteIO_t * AiopIOList, int AiopIOListSize, WordIO_t ConfigIO, int IRQNum, Byte_t Frequency, int PeriodicOnly, int altChanRingIndicator, int UPCIRingInd); static int sInitController(CONTROLLER_T * CtlP, int CtlNum, ByteIO_t MudbacIO, ByteIO_t * AiopIOList, int AiopIOListSize, int IRQNum, Byte_t Frequency, int PeriodicOnly); static int sReadAiopID(ByteIO_t io); static int sReadAiopNumChan(WordIO_t io); |
1da177e4c Linux-2.6.12-rc2 |
249 |
|
1da177e4c Linux-2.6.12-rc2 |
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
MODULE_AUTHOR("Theodore Ts'o"); MODULE_DESCRIPTION("Comtrol RocketPort driver"); module_param(board1, ulong, 0); MODULE_PARM_DESC(board1, "I/O port for (ISA) board #1"); module_param(board2, ulong, 0); MODULE_PARM_DESC(board2, "I/O port for (ISA) board #2"); module_param(board3, ulong, 0); MODULE_PARM_DESC(board3, "I/O port for (ISA) board #3"); module_param(board4, ulong, 0); MODULE_PARM_DESC(board4, "I/O port for (ISA) board #4"); module_param(controller, ulong, 0); MODULE_PARM_DESC(controller, "I/O port for (ISA) rocketport controller"); module_param(support_low_speed, bool, 0); MODULE_PARM_DESC(support_low_speed, "1 means support 50 baud, 0 means support 460400 baud"); module_param(modem1, ulong, 0); MODULE_PARM_DESC(modem1, "1 means (ISA) board #1 is a RocketModem"); module_param(modem2, ulong, 0); MODULE_PARM_DESC(modem2, "1 means (ISA) board #2 is a RocketModem"); module_param(modem3, ulong, 0); MODULE_PARM_DESC(modem3, "1 means (ISA) board #3 is a RocketModem"); module_param(modem4, ulong, 0); MODULE_PARM_DESC(modem4, "1 means (ISA) board #4 is a RocketModem"); module_param_array(pc104_1, ulong, NULL, 0); MODULE_PARM_DESC(pc104_1, "set interface types for ISA(PC104) board #1 (e.g. pc104_1=232,232,485,485,..."); module_param_array(pc104_2, ulong, NULL, 0); MODULE_PARM_DESC(pc104_2, "set interface types for ISA(PC104) board #2 (e.g. pc104_2=232,232,485,485,..."); module_param_array(pc104_3, ulong, NULL, 0); MODULE_PARM_DESC(pc104_3, "set interface types for ISA(PC104) board #3 (e.g. pc104_3=232,232,485,485,..."); module_param_array(pc104_4, ulong, NULL, 0); MODULE_PARM_DESC(pc104_4, "set interface types for ISA(PC104) board #4 (e.g. pc104_4=232,232,485,485,..."); |
d269cdd0e [PATCH] rocketpor... |
280 |
static int rp_init(void); |
1da177e4c Linux-2.6.12-rc2 |
281 282 283 284 |
static void rp_cleanup_module(void); module_init(rp_init); module_exit(rp_cleanup_module); |
1da177e4c Linux-2.6.12-rc2 |
285 |
|
1da177e4c Linux-2.6.12-rc2 |
286 |
MODULE_LICENSE("Dual BSD/GPL"); |
1da177e4c Linux-2.6.12-rc2 |
287 288 289 290 291 292 293 294 295 296 297 |
/*************************************************************************/ /* Module code starts here */ static inline int rocket_paranoia_check(struct r_port *info, const char *routine) { #ifdef ROCKET_PARANOIA_CHECK if (!info) return 1; if (info->magic != RPORT_MAGIC) { |
68562b792 Char: rocket, pri... |
298 299 300 |
printk(KERN_WARNING "Warning: bad magic number for rocketport " "struct in %s ", routine); |
1da177e4c Linux-2.6.12-rc2 |
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
return 1; } #endif return 0; } /* Serial port receive data function. Called (from timer poll) when an AIOPIC signals * that receive data is present on a serial port. Pulls data from FIFO, moves it into the * tty layer. */ static void rp_do_receive(struct r_port *info, struct tty_struct *tty, CHANNEL_t * cp, unsigned int ChanStatus) { unsigned int CharNStat; |
cc44a817f [PATCH] fix memor... |
317 318 |
int ToRecv, wRecv, space; unsigned char *cbuf; |
1da177e4c Linux-2.6.12-rc2 |
319 320 |
ToRecv = sGetRxCnt(cp); |
1da177e4c Linux-2.6.12-rc2 |
321 |
#ifdef ROCKET_DEBUG_INTR |
68562b792 Char: rocket, pri... |
322 323 |
printk(KERN_INFO "rp_do_receive(%d)... ", ToRecv); |
1da177e4c Linux-2.6.12-rc2 |
324 |
#endif |
cc44a817f [PATCH] fix memor... |
325 326 |
if (ToRecv == 0) return; |
33f0f88f1 [PATCH] TTY layer... |
327 |
|
1da177e4c Linux-2.6.12-rc2 |
328 329 330 331 332 333 334 335 |
/* * if status indicates there are errored characters in the * FIFO, then enter status mode (a word in FIFO holds * character and status). */ if (ChanStatus & (RXFOVERFL | RXBREAK | RXFRAME | RXPARITY)) { if (!(ChanStatus & STATMODE)) { #ifdef ROCKET_DEBUG_RECEIVE |
68562b792 Char: rocket, pri... |
336 337 |
printk(KERN_INFO "Entering STATMODE... "); |
1da177e4c Linux-2.6.12-rc2 |
338 339 340 341 342 343 344 345 346 347 348 349 350 |
#endif ChanStatus |= STATMODE; sEnRxStatusMode(cp); } } /* * if we previously entered status mode, then read down the * FIFO one word at a time, pulling apart the character and * the status. Update error counters depending on status */ if (ChanStatus & STATMODE) { #ifdef ROCKET_DEBUG_RECEIVE |
68562b792 Char: rocket, pri... |
351 352 353 |
printk(KERN_INFO "Ignore %x, read %x... ", info->ignore_status_mask, info->read_status_mask); |
1da177e4c Linux-2.6.12-rc2 |
354 355 |
#endif while (ToRecv) { |
cc44a817f [PATCH] fix memor... |
356 |
char flag; |
1da177e4c Linux-2.6.12-rc2 |
357 358 |
CharNStat = sInW(sGetTxRxDataIO(cp)); #ifdef ROCKET_DEBUG_RECEIVE |
68562b792 Char: rocket, pri... |
359 360 |
printk(KERN_INFO "%x... ", CharNStat); |
1da177e4c Linux-2.6.12-rc2 |
361 362 363 364 365 366 367 368 369 |
#endif if (CharNStat & STMBREAKH) CharNStat &= ~(STMFRAMEH | STMPARITYH); if (CharNStat & info->ignore_status_mask) { ToRecv--; continue; } CharNStat &= info->read_status_mask; if (CharNStat & STMBREAKH) |
cc44a817f [PATCH] fix memor... |
370 |
flag = TTY_BREAK; |
1da177e4c Linux-2.6.12-rc2 |
371 |
else if (CharNStat & STMPARITYH) |
cc44a817f [PATCH] fix memor... |
372 |
flag = TTY_PARITY; |
1da177e4c Linux-2.6.12-rc2 |
373 |
else if (CharNStat & STMFRAMEH) |
cc44a817f [PATCH] fix memor... |
374 |
flag = TTY_FRAME; |
1da177e4c Linux-2.6.12-rc2 |
375 |
else if (CharNStat & STMRCVROVRH) |
cc44a817f [PATCH] fix memor... |
376 |
flag = TTY_OVERRUN; |
1da177e4c Linux-2.6.12-rc2 |
377 |
else |
cc44a817f [PATCH] fix memor... |
378 379 |
flag = TTY_NORMAL; tty_insert_flip_char(tty, CharNStat & 0xff, flag); |
1da177e4c Linux-2.6.12-rc2 |
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
ToRecv--; } /* * after we've emptied the FIFO in status mode, turn * status mode back off */ if (sGetRxCnt(cp) == 0) { #ifdef ROCKET_DEBUG_RECEIVE printk(KERN_INFO "Status mode off. "); #endif sDisRxStatusMode(cp); } } else { /* * we aren't in status mode, so read down the FIFO two * characters at time by doing repeated word IO * transfer. */ |
cc44a817f [PATCH] fix memor... |
400 401 402 403 404 405 406 407 408 409 |
space = tty_prepare_flip_string(tty, &cbuf, ToRecv); if (space < ToRecv) { #ifdef ROCKET_DEBUG_RECEIVE printk(KERN_INFO "rp_do_receive:insufficient space ToRecv=%d space=%d ", ToRecv, space); #endif if (space <= 0) return; ToRecv = space; } |
1da177e4c Linux-2.6.12-rc2 |
410 411 412 413 414 |
wRecv = ToRecv >> 1; if (wRecv) sInStrW(sGetTxRxDataIO(cp), (unsigned short *) cbuf, wRecv); if (ToRecv & 1) cbuf[ToRecv - 1] = sInB(sGetTxRxDataIO(cp)); |
1da177e4c Linux-2.6.12-rc2 |
415 416 |
} /* Push the data up to the tty layer */ |
cc44a817f [PATCH] fix memor... |
417 |
tty_flip_buffer_push(tty); |
1da177e4c Linux-2.6.12-rc2 |
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 |
} /* * Serial port transmit data function. Called from the timer polling loop as a * result of a bit set in xmit_flags[], indicating data (from the tty layer) is ready * to be sent out the serial port. Data is buffered in rp_table[line].xmit_buf, it is * moved to the port's xmit FIFO. *info is critical data, protected by spinlocks. */ static void rp_do_transmit(struct r_port *info) { int c; CHANNEL_t *cp = &info->channel; struct tty_struct *tty; unsigned long flags; #ifdef ROCKET_DEBUG_INTR |
68562b792 Char: rocket, pri... |
434 435 |
printk(KERN_DEBUG "%s ", __func__); |
1da177e4c Linux-2.6.12-rc2 |
436 437 438 |
#endif if (!info) return; |
e60a10844 rocket: use tty_port |
439 |
if (!info->port.tty) { |
68562b792 Char: rocket, pri... |
440 |
printk(KERN_WARNING "rp: WARNING %s called with " |
e60a10844 rocket: use tty_port |
441 442 |
"info->port.tty==NULL ", __func__); |
1da177e4c Linux-2.6.12-rc2 |
443 444 445 446 447 |
clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]); return; } spin_lock_irqsave(&info->slock, flags); |
e60a10844 rocket: use tty_port |
448 |
tty = info->port.tty; |
1da177e4c Linux-2.6.12-rc2 |
449 450 451 452 453 454 |
info->xmit_fifo_room = TXFIFO_SIZE - sGetTxCnt(cp); /* Loop sending data to FIFO until done or FIFO full */ while (1) { if (tty->stopped || tty->hw_stopped) break; |
709107fcd char: rocket.c: f... |
455 456 |
c = min(info->xmit_fifo_room, info->xmit_cnt); c = min(c, XMIT_BUF_SIZE - info->xmit_tail); |
1da177e4c Linux-2.6.12-rc2 |
457 458 459 460 461 462 463 464 465 466 |
if (c <= 0 || info->xmit_fifo_room <= 0) break; sOutStrW(sGetTxRxDataIO(cp), (unsigned short *) (info->xmit_buf + info->xmit_tail), c / 2); if (c & 1) sOutB(sGetTxRxDataIO(cp), info->xmit_buf[info->xmit_tail + c - 1]); info->xmit_tail += c; info->xmit_tail &= XMIT_BUF_SIZE - 1; info->xmit_cnt -= c; info->xmit_fifo_room -= c; #ifdef ROCKET_DEBUG_INTR |
68562b792 Char: rocket, pri... |
467 468 |
printk(KERN_INFO "tx %d chars... ", c); |
1da177e4c Linux-2.6.12-rc2 |
469 470 471 472 473 474 475 476 |
#endif } if (info->xmit_cnt == 0) clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]); if (info->xmit_cnt < WAKEUP_CHARS) { tty_wakeup(tty); |
1da177e4c Linux-2.6.12-rc2 |
477 478 479 480 481 482 483 484 |
#ifdef ROCKETPORT_HAVE_POLL_WAIT wake_up_interruptible(&tty->poll_wait); #endif } spin_unlock_irqrestore(&info->slock, flags); #ifdef ROCKET_DEBUG_INTR |
68562b792 Char: rocket, pri... |
485 486 |
printk(KERN_DEBUG "(%d,%d,%d,%d)... ", info->xmit_cnt, info->xmit_head, |
1da177e4c Linux-2.6.12-rc2 |
487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 |
info->xmit_tail, info->xmit_fifo_room); #endif } /* * Called when a serial port signals it has read data in it's RX FIFO. * It checks what interrupts are pending and services them, including * receiving serial data. */ static void rp_handle_port(struct r_port *info) { CHANNEL_t *cp; struct tty_struct *tty; unsigned int IntMask, ChanStatus; if (!info) return; |
a129909ca tty: rocketport u... |
504 |
if ((info->flags & ASYNC_INITIALIZED) == 0) { |
68562b792 Char: rocket, pri... |
505 506 507 |
printk(KERN_WARNING "rp: WARNING: rp_handle_port called with " "info->flags & NOT_INIT "); |
1da177e4c Linux-2.6.12-rc2 |
508 509 |
return; } |
e60a10844 rocket: use tty_port |
510 |
if (!info->port.tty) { |
68562b792 Char: rocket, pri... |
511 |
printk(KERN_WARNING "rp: WARNING: rp_handle_port called with " |
e60a10844 rocket: use tty_port |
512 513 |
"info->port.tty==NULL "); |
1da177e4c Linux-2.6.12-rc2 |
514 515 516 |
return; } cp = &info->channel; |
e60a10844 rocket: use tty_port |
517 |
tty = info->port.tty; |
1da177e4c Linux-2.6.12-rc2 |
518 519 520 |
IntMask = sGetChanIntID(cp) & info->intmask; #ifdef ROCKET_DEBUG_INTR |
68562b792 Char: rocket, pri... |
521 522 |
printk(KERN_INFO "rp_interrupt %02x... ", IntMask); |
1da177e4c Linux-2.6.12-rc2 |
523 524 525 526 527 528 529 |
#endif ChanStatus = sGetChanStatus(cp); if (IntMask & RXF_TRIG) { /* Rx FIFO trigger level */ rp_do_receive(info, tty, cp, ChanStatus); } if (IntMask & DELTA_CD) { /* CD change */ #if (defined(ROCKET_DEBUG_OPEN) || defined(ROCKET_DEBUG_INTR) || defined(ROCKET_DEBUG_HANGUP)) |
68562b792 Char: rocket, pri... |
530 531 |
printk(KERN_INFO "ttyR%d CD now %s... ", info->line, |
1da177e4c Linux-2.6.12-rc2 |
532 533 534 535 536 537 538 539 540 541 |
(ChanStatus & CD_ACT) ? "on" : "off"); #endif if (!(ChanStatus & CD_ACT) && info->cd_status) { #ifdef ROCKET_DEBUG_HANGUP printk(KERN_INFO "CD drop, calling hangup. "); #endif tty_hangup(tty); } info->cd_status = (ChanStatus & CD_ACT) ? 1 : 0; |
e60a10844 rocket: use tty_port |
542 |
wake_up_interruptible(&info->port.open_wait); |
1da177e4c Linux-2.6.12-rc2 |
543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 |
} #ifdef ROCKET_DEBUG_INTR if (IntMask & DELTA_CTS) { /* CTS change */ printk(KERN_INFO "CTS change... "); } if (IntMask & DELTA_DSR) { /* DSR change */ printk(KERN_INFO "DSR change... "); } #endif } /* * The top level polling routine. Repeats every 1/100 HZ (10ms). */ static void rp_do_poll(unsigned long dummy) { CONTROLLER_t *ctlp; |
6c0286b19 Char: rocket, fix... |
562 563 |
int ctrl, aiop, ch, line; unsigned int xmitmask, i; |
1da177e4c Linux-2.6.12-rc2 |
564 565 566 567 568 569 570 571 572 573 574 |
unsigned int CtlMask; unsigned char AiopMask; Word_t bit; /* Walk through all the boards (ctrl's) */ for (ctrl = 0; ctrl < max_board; ctrl++) { if (rcktpt_io_addr[ctrl] <= 0) continue; /* Get a ptr to the board's control struct */ ctlp = sCtlNumToCtlPtr(ctrl); |
3a4fa0a25 Fix misspellings ... |
575 |
/* Get the interrupt status from the board */ |
1da177e4c Linux-2.6.12-rc2 |
576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 |
#ifdef CONFIG_PCI if (ctlp->BusType == isPCI) CtlMask = sPCIGetControllerIntStatus(ctlp); else #endif CtlMask = sGetControllerIntStatus(ctlp); /* Check if any AIOP read bits are set */ for (aiop = 0; CtlMask; aiop++) { bit = ctlp->AiopIntrBits[aiop]; if (CtlMask & bit) { CtlMask &= ~bit; AiopMask = sGetAiopIntStatus(ctlp, aiop); /* Check if any port read bits are set */ for (ch = 0; AiopMask; AiopMask >>= 1, ch++) { if (AiopMask & 1) { /* Get the line number (/dev/ttyRx number). */ /* Read the data from the port. */ line = GetLineNumber(ctrl, aiop, ch); rp_handle_port(rp_table[line]); } } } } xmitmask = xmit_flags[ctrl]; /* * xmit_flags contains bit-significant flags, indicating there is data * to xmit on the port. Bit 0 is port 0 on this board, bit 1 is port * 1, ... (32 total possible). The variable i has the aiop and ch * numbers encoded in it (port 0-7 are aiop0, 8-15 are aiop1, etc). */ if (xmitmask) { for (i = 0; i < rocketModel[ctrl].numPorts; i++) { if (xmitmask & (1 << i)) { aiop = (i & 0x18) >> 3; ch = i & 0x07; line = GetLineNumber(ctrl, aiop, ch); rp_do_transmit(rp_table[line]); } } } } /* * Reset the timer so we get called at the next clock tick (10ms). */ if (atomic_read(&rp_num_ports_open)) mod_timer(&rocket_timer, jiffies + POLL_PERIOD); } /* * Initializes the r_port structure for a port, as well as enabling the port on * the board. * Inputs: board, aiop, chan numbers */ static void init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev) { unsigned rocketMode; struct r_port *info; int line; CONTROLLER_T *ctlp; /* Get the next available line number */ line = SetLineNumber(board, aiop, chan); ctlp = sCtlNumToCtlPtr(board); /* Get a r_port struct for the port, fill it in and save it globally, indexed by line number */ |
dd00cc486 some kmalloc/mems... |
648 |
info = kzalloc(sizeof (struct r_port), GFP_KERNEL); |
1da177e4c Linux-2.6.12-rc2 |
649 |
if (!info) { |
68562b792 Char: rocket, pri... |
650 651 652 |
printk(KERN_ERR "Couldn't allocate info struct for line #%d ", line); |
1da177e4c Linux-2.6.12-rc2 |
653 654 |
return; } |
1da177e4c Linux-2.6.12-rc2 |
655 656 657 658 659 660 661 |
info->magic = RPORT_MAGIC; info->line = line; info->ctlp = ctlp; info->board = board; info->aiop = aiop; info->chan = chan; |
31f35939d tty_port: Add a p... |
662 663 |
tty_port_init(&info->port); info->port.ops = &rocket_port_ops; |
8cf5a8c57 Char: rocket, swi... |
664 |
init_completion(&info->close_wait); |
1da177e4c Linux-2.6.12-rc2 |
665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 |
info->flags &= ~ROCKET_MODE_MASK; switch (pc104[board][line]) { case 422: info->flags |= ROCKET_MODE_RS422; break; case 485: info->flags |= ROCKET_MODE_RS485; break; case 232: default: info->flags |= ROCKET_MODE_RS232; break; } info->intmask = RXF_TRIG | TXFIFO_MT | SRC_INT | DELTA_CD | DELTA_CTS | DELTA_DSR; if (sInitChan(ctlp, &info->channel, aiop, chan) == 0) { |
68562b792 Char: rocket, pri... |
681 682 683 |
printk(KERN_ERR "RocketPort sInitChan(%d, %d, %d) failed! ", board, aiop, chan); |
1da177e4c Linux-2.6.12-rc2 |
684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 |
kfree(info); return; } rocketMode = info->flags & ROCKET_MODE_MASK; if ((info->flags & ROCKET_RTS_TOGGLE) || (rocketMode == ROCKET_MODE_RS485)) sEnRTSToggle(&info->channel); else sDisRTSToggle(&info->channel); if (ctlp->boardType == ROCKET_TYPE_PC104) { switch (rocketMode) { case ROCKET_MODE_RS485: sSetInterfaceMode(&info->channel, InterfaceModeRS485); break; case ROCKET_MODE_RS422: sSetInterfaceMode(&info->channel, InterfaceModeRS422); break; case ROCKET_MODE_RS232: default: if (info->flags & ROCKET_RTS_TOGGLE) sSetInterfaceMode(&info->channel, InterfaceModeRS232T); else sSetInterfaceMode(&info->channel, InterfaceModeRS232); break; } } spin_lock_init(&info->slock); |
69f545ea6 use mutex instead... |
713 |
mutex_init(&info->write_mtx); |
1da177e4c Linux-2.6.12-rc2 |
714 |
rp_table[line] = info; |
ac6aec2f5 Char: rocket, fix... |
715 716 |
tty_register_device(rocket_driver, line, pci_dev ? &pci_dev->dev : NULL); |
1da177e4c Linux-2.6.12-rc2 |
717 718 719 720 721 722 723 |
} /* * Configures a rocketport port according to its termio settings. Called from * user mode into the driver (exception handler). *info CD manipulation is spinlock protected. */ static void configure_r_port(struct r_port *info, |
606d099cd [PATCH] tty: swit... |
724 |
struct ktermios *old_termios) |
1da177e4c Linux-2.6.12-rc2 |
725 726 727 728 729 730 |
{ unsigned cflag; unsigned long flags; unsigned rocketMode; int bits, baud, divisor; CHANNEL_t *cp; |
e60a10844 rocket: use tty_port |
731 |
struct ktermios *t = info->port.tty->termios; |
1da177e4c Linux-2.6.12-rc2 |
732 |
|
1da177e4c Linux-2.6.12-rc2 |
733 |
cp = &info->channel; |
6df3526b6 rocket: first pas... |
734 |
cflag = t->c_cflag; |
1da177e4c Linux-2.6.12-rc2 |
735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 |
/* Byte size and parity */ if ((cflag & CSIZE) == CS8) { sSetData8(cp); bits = 10; } else { sSetData7(cp); bits = 9; } if (cflag & CSTOPB) { sSetStop2(cp); bits++; } else { sSetStop1(cp); } if (cflag & PARENB) { sEnParity(cp); bits++; if (cflag & PARODD) { sSetOddParity(cp); } else { sSetEvenParity(cp); } } else { sDisParity(cp); } /* baud rate */ |
e60a10844 rocket: use tty_port |
764 |
baud = tty_get_baud_rate(info->port.tty); |
1da177e4c Linux-2.6.12-rc2 |
765 766 767 768 |
if (!baud) baud = 9600; divisor = ((rp_baud_base[info->board] + (baud >> 1)) / baud) - 1; if ((divisor >= 8192 || divisor < 0) && old_termios) { |
6df3526b6 rocket: first pas... |
769 |
baud = tty_termios_baud_rate(old_termios); |
1da177e4c Linux-2.6.12-rc2 |
770 771 772 773 774 775 776 777 778 779 |
if (!baud) baud = 9600; divisor = (rp_baud_base[info->board] / baud) - 1; } if (divisor >= 8192 || divisor < 0) { baud = 9600; divisor = (rp_baud_base[info->board] / baud) - 1; } info->cps = baud / bits; sSetBaud(cp, divisor); |
6df3526b6 rocket: first pas... |
780 |
/* FIXME: Should really back compute a baud rate from the divisor */ |
e60a10844 rocket: use tty_port |
781 |
tty_encode_baud_rate(info->port.tty, baud, baud); |
6df3526b6 rocket: first pas... |
782 |
|
1da177e4c Linux-2.6.12-rc2 |
783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 |
if (cflag & CRTSCTS) { info->intmask |= DELTA_CTS; sEnCTSFlowCtl(cp); } else { info->intmask &= ~DELTA_CTS; sDisCTSFlowCtl(cp); } if (cflag & CLOCAL) { info->intmask &= ~DELTA_CD; } else { spin_lock_irqsave(&info->slock, flags); if (sGetChanStatus(cp) & CD_ACT) info->cd_status = 1; else info->cd_status = 0; info->intmask |= DELTA_CD; spin_unlock_irqrestore(&info->slock, flags); } /* * Handle software flow control in the board */ #ifdef ROCKET_SOFT_FLOW |
e60a10844 rocket: use tty_port |
806 |
if (I_IXON(info->port.tty)) { |
1da177e4c Linux-2.6.12-rc2 |
807 |
sEnTxSoftFlowCtl(cp); |
e60a10844 rocket: use tty_port |
808 |
if (I_IXANY(info->port.tty)) { |
1da177e4c Linux-2.6.12-rc2 |
809 810 811 812 |
sEnIXANY(cp); } else { sDisIXANY(cp); } |
e60a10844 rocket: use tty_port |
813 814 |
sSetTxXONChar(cp, START_CHAR(info->port.tty)); sSetTxXOFFChar(cp, STOP_CHAR(info->port.tty)); |
1da177e4c Linux-2.6.12-rc2 |
815 816 817 818 819 820 821 822 823 824 825 |
} else { sDisTxSoftFlowCtl(cp); sDisIXANY(cp); sClrTxXOFF(cp); } #endif /* * Set up ignore/read mask words */ info->read_status_mask = STMRCVROVRH | 0xFF; |
e60a10844 rocket: use tty_port |
826 |
if (I_INPCK(info->port.tty)) |
1da177e4c Linux-2.6.12-rc2 |
827 |
info->read_status_mask |= STMFRAMEH | STMPARITYH; |
e60a10844 rocket: use tty_port |
828 |
if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty)) |
1da177e4c Linux-2.6.12-rc2 |
829 830 831 832 833 834 |
info->read_status_mask |= STMBREAKH; /* * Characters to ignore */ info->ignore_status_mask = 0; |
e60a10844 rocket: use tty_port |
835 |
if (I_IGNPAR(info->port.tty)) |
1da177e4c Linux-2.6.12-rc2 |
836 |
info->ignore_status_mask |= STMFRAMEH | STMPARITYH; |
e60a10844 rocket: use tty_port |
837 |
if (I_IGNBRK(info->port.tty)) { |
1da177e4c Linux-2.6.12-rc2 |
838 839 840 841 842 |
info->ignore_status_mask |= STMBREAKH; /* * If we're ignoring parity and break indicators, * ignore overruns too. (For real raw support). */ |
e60a10844 rocket: use tty_port |
843 |
if (I_IGNPAR(info->port.tty)) |
1da177e4c Linux-2.6.12-rc2 |
844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 |
info->ignore_status_mask |= STMRCVROVRH; } rocketMode = info->flags & ROCKET_MODE_MASK; if ((info->flags & ROCKET_RTS_TOGGLE) || (rocketMode == ROCKET_MODE_RS485)) sEnRTSToggle(cp); else sDisRTSToggle(cp); sSetRTS(&info->channel); if (cp->CtlP->boardType == ROCKET_TYPE_PC104) { switch (rocketMode) { case ROCKET_MODE_RS485: sSetInterfaceMode(cp, InterfaceModeRS485); break; case ROCKET_MODE_RS422: sSetInterfaceMode(cp, InterfaceModeRS422); break; case ROCKET_MODE_RS232: default: if (info->flags & ROCKET_RTS_TOGGLE) sSetInterfaceMode(cp, InterfaceModeRS232T); else sSetInterfaceMode(cp, InterfaceModeRS232); break; } } } |
31f35939d tty_port: Add a p... |
875 876 877 878 879 |
static int carrier_raised(struct tty_port *port) { struct r_port *info = container_of(port, struct r_port, port); return (sGetChanStatusLo(&info->channel) & CD_ACT) ? 1 : 0; } |
5d951fb45 tty: Pull the dtr... |
880 881 882 883 884 885 |
static void raise_dtr_rts(struct tty_port *port) { struct r_port *info = container_of(port, struct r_port, port); sSetDTR(&info->channel); sSetRTS(&info->channel); } |
e60a10844 rocket: use tty_port |
886 |
/* info->port.count is considered critical, protected by spinlocks. */ |
1da177e4c Linux-2.6.12-rc2 |
887 888 889 890 |
static int block_til_ready(struct tty_struct *tty, struct file *filp, struct r_port *info) { DECLARE_WAITQUEUE(wait, current); |
31f35939d tty_port: Add a p... |
891 |
struct tty_port *port = &info->port; |
1da177e4c Linux-2.6.12-rc2 |
892 893 894 895 896 897 898 899 900 |
int retval; int do_clocal = 0, extra_count = 0; unsigned long flags; /* * If the device is in the middle of being closed, then block * until it's done, and then try again. */ if (tty_hung_up_p(filp)) |
a129909ca tty: rocketport u... |
901 902 |
return ((info->flags & ASYNC_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS); if (info->flags & ASYNC_CLOSING) { |
8cf5a8c57 Char: rocket, swi... |
903 904 |
if (wait_for_completion_interruptible(&info->close_wait)) return -ERESTARTSYS; |
a129909ca tty: rocketport u... |
905 |
return ((info->flags & ASYNC_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS); |
1da177e4c Linux-2.6.12-rc2 |
906 907 908 909 910 911 912 |
} /* * If non-blocking mode is set, or the port is not enabled, * then make the check up front and then exit. */ if ((filp->f_flags & O_NONBLOCK) || (tty->flags & (1 << TTY_IO_ERROR))) { |
a129909ca tty: rocketport u... |
913 |
info->flags |= ASYNC_NORMAL_ACTIVE; |
1da177e4c Linux-2.6.12-rc2 |
914 915 916 917 918 919 920 |
return 0; } if (tty->termios->c_cflag & CLOCAL) do_clocal = 1; /* * Block waiting for the carrier detect and the line to become free. While we are in |
31f35939d tty_port: Add a p... |
921 |
* this loop, port->count is dropped by one, so that rp_close() knows when to free things. |
1da177e4c Linux-2.6.12-rc2 |
922 923 924 |
* We restore it upon exit, either normal or abnormal. */ retval = 0; |
31f35939d tty_port: Add a p... |
925 |
add_wait_queue(&port->open_wait, &wait); |
1da177e4c Linux-2.6.12-rc2 |
926 |
#ifdef ROCKET_DEBUG_OPEN |
31f35939d tty_port: Add a p... |
927 928 |
printk(KERN_INFO "block_til_ready before block: ttyR%d, count = %d ", info->line, port->count); |
1da177e4c Linux-2.6.12-rc2 |
929 |
#endif |
c1314a49d tty: Redo the roc... |
930 |
spin_lock_irqsave(&port->lock, flags); |
1da177e4c Linux-2.6.12-rc2 |
931 932 |
#ifdef ROCKET_DISABLE_SIMUSAGE |
a129909ca tty: rocketport u... |
933 |
info->flags |= ASYNC_NORMAL_ACTIVE; |
1da177e4c Linux-2.6.12-rc2 |
934 935 936 |
#else if (!tty_hung_up_p(filp)) { extra_count = 1; |
31f35939d tty_port: Add a p... |
937 |
port->count--; |
1da177e4c Linux-2.6.12-rc2 |
938 939 |
} #endif |
31f35939d tty_port: Add a p... |
940 |
port->blocked_open++; |
1da177e4c Linux-2.6.12-rc2 |
941 |
|
c1314a49d tty: Redo the roc... |
942 |
spin_unlock_irqrestore(&port->lock, flags); |
1da177e4c Linux-2.6.12-rc2 |
943 944 |
while (1) { |
5d951fb45 tty: Pull the dtr... |
945 946 |
if (tty->termios->c_cflag & CBAUD) tty_port_raise_dtr_rts(port); |
1da177e4c Linux-2.6.12-rc2 |
947 |
set_current_state(TASK_INTERRUPTIBLE); |
a129909ca tty: rocketport u... |
948 949 |
if (tty_hung_up_p(filp) || !(info->flags & ASYNC_INITIALIZED)) { if (info->flags & ASYNC_HUP_NOTIFY) |
1da177e4c Linux-2.6.12-rc2 |
950 951 952 953 954 |
retval = -EAGAIN; else retval = -ERESTARTSYS; break; } |
a129909ca tty: rocketport u... |
955 |
if (!(info->flags & ASYNC_CLOSING) && |
31f35939d tty_port: Add a p... |
956 |
(do_clocal || tty_port_carrier_raised(port))) |
1da177e4c Linux-2.6.12-rc2 |
957 958 959 960 961 962 963 964 |
break; if (signal_pending(current)) { retval = -ERESTARTSYS; break; } #ifdef ROCKET_DEBUG_OPEN printk(KERN_INFO "block_til_ready blocking: ttyR%d, count = %d, flags=0x%0x ", |
31f35939d tty_port: Add a p... |
965 |
info->line, port->count, info->flags); |
1da177e4c Linux-2.6.12-rc2 |
966 967 968 |
#endif schedule(); /* Don't hold spinlock here, will hang PC */ } |
cc0a8fbb7 drivers/char: use... |
969 |
__set_current_state(TASK_RUNNING); |
31f35939d tty_port: Add a p... |
970 |
remove_wait_queue(&port->open_wait, &wait); |
1da177e4c Linux-2.6.12-rc2 |
971 |
|
c1314a49d tty: Redo the roc... |
972 |
spin_lock_irqsave(&port->lock, flags); |
1da177e4c Linux-2.6.12-rc2 |
973 974 |
if (extra_count) |
31f35939d tty_port: Add a p... |
975 976 |
port->count++; port->blocked_open--; |
1da177e4c Linux-2.6.12-rc2 |
977 |
|
c1314a49d tty: Redo the roc... |
978 |
spin_unlock_irqrestore(&port->lock, flags); |
1da177e4c Linux-2.6.12-rc2 |
979 980 981 982 |
#ifdef ROCKET_DEBUG_OPEN printk(KERN_INFO "block_til_ready after blocking: ttyR%d, count = %d ", |
31f35939d tty_port: Add a p... |
983 |
info->line, port->count); |
1da177e4c Linux-2.6.12-rc2 |
984 985 986 |
#endif if (retval) return retval; |
a129909ca tty: rocketport u... |
987 |
info->flags |= ASYNC_NORMAL_ACTIVE; |
1da177e4c Linux-2.6.12-rc2 |
988 989 990 991 992 993 994 995 996 997 998 999 1000 |
return 0; } /* * Exception handler that opens a serial port. Creates xmit_buf storage, fills in * port's r_port struct. Initializes the port hardware. */ static int rp_open(struct tty_struct *tty, struct file *filp) { struct r_port *info; int line = 0, retval; CHANNEL_t *cp; unsigned long page; |
f6de0c986 Char: rocket, rem... |
1001 |
line = tty->index; |
1da177e4c Linux-2.6.12-rc2 |
1002 1003 1004 1005 1006 1007 |
if ((line < 0) || (line >= MAX_RP_PORTS) || ((info = rp_table[line]) == NULL)) return -ENXIO; page = __get_free_page(GFP_KERNEL); if (!page) return -ENOMEM; |
a129909ca tty: rocketport u... |
1008 |
if (info->flags & ASYNC_CLOSING) { |
8cf5a8c57 Char: rocket, swi... |
1009 |
retval = wait_for_completion_interruptible(&info->close_wait); |
1da177e4c Linux-2.6.12-rc2 |
1010 |
free_page(page); |
8cf5a8c57 Char: rocket, swi... |
1011 1012 |
if (retval) return retval; |
a129909ca tty: rocketport u... |
1013 |
return ((info->flags & ASYNC_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS); |
1da177e4c Linux-2.6.12-rc2 |
1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 |
} /* * We must not sleep from here until the port is marked fully in use. */ if (info->xmit_buf) free_page(page); else info->xmit_buf = (unsigned char *) page; tty->driver_data = info; |
e60a10844 rocket: use tty_port |
1025 |
info->port.tty = tty; |
1da177e4c Linux-2.6.12-rc2 |
1026 |
|
e60a10844 rocket: use tty_port |
1027 |
if (info->port.count++ == 0) { |
1da177e4c Linux-2.6.12-rc2 |
1028 1029 1030 |
atomic_inc(&rp_num_ports_open); #ifdef ROCKET_DEBUG_OPEN |
68562b792 Char: rocket, pri... |
1031 1032 1033 |
printk(KERN_INFO "rocket mod++ = %d... ", atomic_read(&rp_num_ports_open)); |
1da177e4c Linux-2.6.12-rc2 |
1034 1035 1036 |
#endif } #ifdef ROCKET_DEBUG_OPEN |
e60a10844 rocket: use tty_port |
1037 1038 |
printk(KERN_INFO "rp_open ttyR%d, count=%d ", info->line, info->port.count); |
1da177e4c Linux-2.6.12-rc2 |
1039 1040 1041 1042 1043 |
#endif /* * Info->count is now 1; so it's safe to sleep now. */ |
a129909ca tty: rocketport u... |
1044 |
if ((info->flags & ASYNC_INITIALIZED) == 0) { |
1da177e4c Linux-2.6.12-rc2 |
1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 |
cp = &info->channel; sSetRxTrigger(cp, TRIG_1); if (sGetChanStatus(cp) & CD_ACT) info->cd_status = 1; else info->cd_status = 0; sDisRxStatusMode(cp); sFlushRxFIFO(cp); sFlushTxFIFO(cp); sEnInterrupts(cp, (TXINT_EN | MCINT_EN | RXINT_EN | SRCINT_EN | CHANINT_EN)); sSetRxTrigger(cp, TRIG_1); sGetChanStatus(cp); sDisRxStatusMode(cp); sClrTxXOFF(cp); sDisCTSFlowCtl(cp); sDisTxSoftFlowCtl(cp); sEnRxFIFO(cp); sEnTransmit(cp); |
a129909ca tty: rocketport u... |
1067 |
info->flags |= ASYNC_INITIALIZED; |
1da177e4c Linux-2.6.12-rc2 |
1068 1069 1070 1071 1072 |
/* * Set up the tty->alt_speed kludge */ if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_HI) |
e60a10844 rocket: use tty_port |
1073 |
info->port.tty->alt_speed = 57600; |
1da177e4c Linux-2.6.12-rc2 |
1074 |
if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_VHI) |
e60a10844 rocket: use tty_port |
1075 |
info->port.tty->alt_speed = 115200; |
1da177e4c Linux-2.6.12-rc2 |
1076 |
if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_SHI) |
e60a10844 rocket: use tty_port |
1077 |
info->port.tty->alt_speed = 230400; |
1da177e4c Linux-2.6.12-rc2 |
1078 |
if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_WARP) |
e60a10844 rocket: use tty_port |
1079 |
info->port.tty->alt_speed = 460800; |
1da177e4c Linux-2.6.12-rc2 |
1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 |
configure_r_port(info, NULL); if (tty->termios->c_cflag & CBAUD) { sSetDTR(cp); sSetRTS(cp); } } /* Starts (or resets) the maint polling loop */ mod_timer(&rocket_timer, jiffies + POLL_PERIOD); retval = block_til_ready(tty, filp, info); if (retval) { #ifdef ROCKET_DEBUG_OPEN printk(KERN_INFO "rp_open returning after block_til_ready with %d ", retval); #endif return retval; } return 0; } /* |
e60a10844 rocket: use tty_port |
1102 |
* Exception handler that closes a serial port. info->port.count is considered critical. |
1da177e4c Linux-2.6.12-rc2 |
1103 1104 1105 |
*/ static void rp_close(struct tty_struct *tty, struct file *filp) { |
c9f19e96a tty: Remove some ... |
1106 |
struct r_port *info = tty->driver_data; |
c1314a49d tty: Redo the roc... |
1107 |
struct tty_port *port = &info->port; |
1da177e4c Linux-2.6.12-rc2 |
1108 1109 1110 1111 1112 1113 1114 1115 |
unsigned long flags; int timeout; CHANNEL_t *cp; if (rocket_paranoia_check(info, "rp_close")) return; #ifdef ROCKET_DEBUG_OPEN |
e60a10844 rocket: use tty_port |
1116 1117 |
printk(KERN_INFO "rp_close ttyR%d, count = %d ", info->line, info->port.count); |
1da177e4c Linux-2.6.12-rc2 |
1118 1119 1120 1121 |
#endif if (tty_hung_up_p(filp)) return; |
c1314a49d tty: Redo the roc... |
1122 |
spin_lock_irqsave(&port->lock, flags); |
1da177e4c Linux-2.6.12-rc2 |
1123 |
|
c1314a49d tty: Redo the roc... |
1124 |
if (tty->count == 1 && port->count != 1) { |
1da177e4c Linux-2.6.12-rc2 |
1125 1126 1127 1128 1129 1130 1131 |
/* * Uh, oh. tty->count is 1, which means that the tty * structure will be freed. Info->count should always * be one in these conditions. If it's greater than * one, we've got real problems, since it means the * serial port won't be shutdown. */ |
68562b792 Char: rocket, pri... |
1132 |
printk(KERN_WARNING "rp_close: bad serial port count; " |
e60a10844 rocket: use tty_port |
1133 1134 |
"tty->count is 1, info->port.count is %d ", info->port.count); |
c1314a49d tty: Redo the roc... |
1135 |
port->count = 1; |
1da177e4c Linux-2.6.12-rc2 |
1136 |
} |
c1314a49d tty: Redo the roc... |
1137 |
if (--port->count < 0) { |
68562b792 Char: rocket, pri... |
1138 |
printk(KERN_WARNING "rp_close: bad serial port count for " |
e60a10844 rocket: use tty_port |
1139 1140 |
"ttyR%d: %d ", info->line, info->port.count); |
c1314a49d tty: Redo the roc... |
1141 |
port->count = 0; |
1da177e4c Linux-2.6.12-rc2 |
1142 |
} |
c1314a49d tty: Redo the roc... |
1143 1144 |
if (port->count) { spin_unlock_irqrestore(&port->lock, flags); |
1da177e4c Linux-2.6.12-rc2 |
1145 1146 |
return; } |
a129909ca tty: rocketport u... |
1147 |
info->flags |= ASYNC_CLOSING; |
c1314a49d tty: Redo the roc... |
1148 |
spin_unlock_irqrestore(&port->lock, flags); |
1da177e4c Linux-2.6.12-rc2 |
1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 |
cp = &info->channel; /* * Notify the line discpline to only process XON/XOFF characters */ tty->closing = 1; /* * If transmission was throttled by the application request, * just flush the xmit buffer. */ if (tty->flow_stopped) rp_flush_buffer(tty); /* * Wait for the transmit buffer to clear */ |
a129909ca tty: rocketport u... |
1167 |
if (info->port.closing_wait != ASYNC_CLOSING_WAIT_NONE) |
c1314a49d tty: Redo the roc... |
1168 |
tty_wait_until_sent(tty, port->closing_wait); |
1da177e4c Linux-2.6.12-rc2 |
1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 |
/* * Before we drop DTR, make sure the UART transmitter * has completely drained; this is especially * important if there is a transmit FIFO! */ timeout = (sGetTxCnt(cp) + 1) * HZ / info->cps; if (timeout == 0) timeout = 1; rp_wait_until_sent(tty, timeout); clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]); sDisTransmit(cp); sDisInterrupts(cp, (TXINT_EN | MCINT_EN | RXINT_EN | SRCINT_EN | CHANINT_EN)); sDisCTSFlowCtl(cp); sDisTxSoftFlowCtl(cp); sClrTxXOFF(cp); sFlushRxFIFO(cp); sFlushTxFIFO(cp); sClrRTS(cp); if (C_HUPCL(tty)) sClrDTR(cp); |
f6de0c986 Char: rocket, rem... |
1190 |
rp_flush_buffer(tty); |
1da177e4c Linux-2.6.12-rc2 |
1191 1192 1193 1194 |
tty_ldisc_flush(tty); clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]); |
c1314a49d tty: Redo the roc... |
1195 1196 1197 |
if (port->blocked_open) { if (port->close_delay) { msleep_interruptible(jiffies_to_msecs(port->close_delay)); |
1da177e4c Linux-2.6.12-rc2 |
1198 |
} |
c1314a49d tty: Redo the roc... |
1199 |
wake_up_interruptible(&port->open_wait); |
1da177e4c Linux-2.6.12-rc2 |
1200 1201 1202 1203 1204 1205 |
} else { if (info->xmit_buf) { free_page((unsigned long) info->xmit_buf); info->xmit_buf = NULL; } } |
a129909ca tty: rocketport u... |
1206 |
info->flags &= ~(ASYNC_INITIALIZED | ASYNC_CLOSING | ASYNC_NORMAL_ACTIVE); |
1da177e4c Linux-2.6.12-rc2 |
1207 |
tty->closing = 0; |
8cf5a8c57 Char: rocket, swi... |
1208 |
complete_all(&info->close_wait); |
1da177e4c Linux-2.6.12-rc2 |
1209 1210 1211 |
atomic_dec(&rp_num_ports_open); #ifdef ROCKET_DEBUG_OPEN |
68562b792 Char: rocket, pri... |
1212 1213 1214 |
printk(KERN_INFO "rocket mod-- = %d... ", atomic_read(&rp_num_ports_open)); |
1da177e4c Linux-2.6.12-rc2 |
1215 1216 1217 1218 1219 1220 1221 |
printk(KERN_INFO "rp_close ttyR%d complete shutdown ", info->line); #endif } static void rp_set_termios(struct tty_struct *tty, |
606d099cd [PATCH] tty: swit... |
1222 |
struct ktermios *old_termios) |
1da177e4c Linux-2.6.12-rc2 |
1223 |
{ |
c9f19e96a tty: Remove some ... |
1224 |
struct r_port *info = tty->driver_data; |
1da177e4c Linux-2.6.12-rc2 |
1225 1226 1227 1228 1229 1230 1231 |
CHANNEL_t *cp; unsigned cflag; if (rocket_paranoia_check(info, "rp_set_termios")) return; cflag = tty->termios->c_cflag; |
1da177e4c Linux-2.6.12-rc2 |
1232 1233 1234 1235 1236 1237 |
/* * This driver doesn't support CS5 or CS6 */ if (((cflag & CSIZE) == CS5) || ((cflag & CSIZE) == CS6)) tty->termios->c_cflag = ((cflag & ~CSIZE) | (old_termios->c_cflag & CSIZE)); |
6df3526b6 rocket: first pas... |
1238 1239 |
/* Or CMSPAR */ tty->termios->c_cflag &= ~CMSPAR; |
1da177e4c Linux-2.6.12-rc2 |
1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 |
configure_r_port(info, old_termios); cp = &info->channel; /* Handle transition to B0 status */ if ((old_termios->c_cflag & CBAUD) && !(tty->termios->c_cflag & CBAUD)) { sClrDTR(cp); sClrRTS(cp); } /* Handle transition away from B0 status */ if (!(old_termios->c_cflag & CBAUD) && (tty->termios->c_cflag & CBAUD)) { if (!tty->hw_stopped || !(tty->termios->c_cflag & CRTSCTS)) sSetRTS(cp); sSetDTR(cp); } if ((old_termios->c_cflag & CRTSCTS) && !(tty->termios->c_cflag & CRTSCTS)) { tty->hw_stopped = 0; rp_start(tty); } } |
9e98966c7 tty: rework break... |
1263 |
static int rp_break(struct tty_struct *tty, int break_state) |
1da177e4c Linux-2.6.12-rc2 |
1264 |
{ |
c9f19e96a tty: Remove some ... |
1265 |
struct r_port *info = tty->driver_data; |
1da177e4c Linux-2.6.12-rc2 |
1266 1267 1268 |
unsigned long flags; if (rocket_paranoia_check(info, "rp_break")) |
9e98966c7 tty: rework break... |
1269 |
return -EINVAL; |
1da177e4c Linux-2.6.12-rc2 |
1270 1271 1272 1273 1274 1275 1276 |
spin_lock_irqsave(&info->slock, flags); if (break_state == -1) sSendBreak(&info->channel); else sClrBreak(&info->channel); spin_unlock_irqrestore(&info->slock, flags); |
9e98966c7 tty: rework break... |
1277 |
return 0; |
1da177e4c Linux-2.6.12-rc2 |
1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 |
} /* * sGetChanRI used to be a macro in rocket_int.h. When the functionality for * the UPCI boards was added, it was decided to make this a function because * the macro was getting too complicated. All cases except the first one * (UPCIRingInd) are taken directly from the original macro. */ static int sGetChanRI(CHANNEL_T * ChP) { CONTROLLER_t *CtlP = ChP->CtlP; int ChanNum = ChP->ChanNum; int RingInd = 0; if (CtlP->UPCIRingInd) RingInd = !(sInB(CtlP->UPCIRingInd) & sBitMapSetTbl[ChanNum]); else if (CtlP->AltChanRingIndicator) RingInd = sInB((ByteIO_t) (ChP->ChanStat + 8)) & DSR_ACT; else if (CtlP->boardType == ROCKET_TYPE_PC104) RingInd = !(sInB(CtlP->AiopIO[3]) & sBitMapSetTbl[ChanNum]); return RingInd; } /********************************************************************************************/ /* Here are the routines used by rp_ioctl. These are all called from exception handlers. */ /* * Returns the state of the serial modem control lines. These next 2 functions * are the way kernel versions > 2.5 handle modem control lines rather than IOCTLs. */ static int rp_tiocmget(struct tty_struct *tty, struct file *file) { |
c9f19e96a tty: Remove some ... |
1311 |
struct r_port *info = tty->driver_data; |
1da177e4c Linux-2.6.12-rc2 |
1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 |
unsigned int control, result, ChanStatus; ChanStatus = sGetChanStatusLo(&info->channel); control = info->channel.TxControl[3]; result = ((control & SET_RTS) ? TIOCM_RTS : 0) | ((control & SET_DTR) ? TIOCM_DTR : 0) | ((ChanStatus & CD_ACT) ? TIOCM_CAR : 0) | (sGetChanRI(&info->channel) ? TIOCM_RNG : 0) | ((ChanStatus & DSR_ACT) ? TIOCM_DSR : 0) | ((ChanStatus & CTS_ACT) ? TIOCM_CTS : 0); return result; } /* * Sets the modem control lines */ static int rp_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { |
c9f19e96a tty: Remove some ... |
1332 |
struct r_port *info = tty->driver_data; |
1da177e4c Linux-2.6.12-rc2 |
1333 1334 1335 1336 1337 1338 1339 1340 1341 |
if (set & TIOCM_RTS) info->channel.TxControl[3] |= SET_RTS; if (set & TIOCM_DTR) info->channel.TxControl[3] |= SET_DTR; if (clear & TIOCM_RTS) info->channel.TxControl[3] &= ~SET_RTS; if (clear & TIOCM_DTR) info->channel.TxControl[3] &= ~SET_DTR; |
457fb6058 drivers/char/rock... |
1342 |
out32(info->channel.IndexAddr, info->channel.TxControl); |
1da177e4c Linux-2.6.12-rc2 |
1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 |
return 0; } static int get_config(struct r_port *info, struct rocket_config __user *retinfo) { struct rocket_config tmp; if (!retinfo) return -EFAULT; memset(&tmp, 0, sizeof (tmp)); tmp.line = info->line; tmp.flags = info->flags; |
44b7d1b37 tty: add more tty... |
1355 1356 |
tmp.close_delay = info->port.close_delay; tmp.closing_wait = info->port.closing_wait; |
1da177e4c Linux-2.6.12-rc2 |
1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 |
tmp.port = rcktpt_io_addr[(info->line >> 5) & 3]; if (copy_to_user(retinfo, &tmp, sizeof (*retinfo))) return -EFAULT; return 0; } static int set_config(struct r_port *info, struct rocket_config __user *new_info) { struct rocket_config new_serial; if (copy_from_user(&new_serial, new_info, sizeof (new_serial))) return -EFAULT; if (!capable(CAP_SYS_ADMIN)) { if ((new_serial.flags & ~ROCKET_USR_MASK) != (info->flags & ~ROCKET_USR_MASK)) return -EPERM; info->flags = ((info->flags & ~ROCKET_USR_MASK) | (new_serial.flags & ROCKET_USR_MASK)); configure_r_port(info, NULL); return 0; } info->flags = ((info->flags & ~ROCKET_FLAGS) | (new_serial.flags & ROCKET_FLAGS)); |
44b7d1b37 tty: add more tty... |
1381 1382 |
info->port.close_delay = new_serial.close_delay; info->port.closing_wait = new_serial.closing_wait; |
1da177e4c Linux-2.6.12-rc2 |
1383 1384 |
if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_HI) |
e60a10844 rocket: use tty_port |
1385 |
info->port.tty->alt_speed = 57600; |
1da177e4c Linux-2.6.12-rc2 |
1386 |
if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_VHI) |
e60a10844 rocket: use tty_port |
1387 |
info->port.tty->alt_speed = 115200; |
1da177e4c Linux-2.6.12-rc2 |
1388 |
if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_SHI) |
e60a10844 rocket: use tty_port |
1389 |
info->port.tty->alt_speed = 230400; |
1da177e4c Linux-2.6.12-rc2 |
1390 |
if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_WARP) |
e60a10844 rocket: use tty_port |
1391 |
info->port.tty->alt_speed = 460800; |
1da177e4c Linux-2.6.12-rc2 |
1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 |
configure_r_port(info, NULL); return 0; } /* * This function fills in a rocket_ports struct with information * about what boards/ports are in the system. This info is passed * to user space. See setrocket.c where the info is used to create * the /dev/ttyRx ports. */ static int get_ports(struct r_port *info, struct rocket_ports __user *retports) { struct rocket_ports tmp; int board; if (!retports) return -EFAULT; memset(&tmp, 0, sizeof (tmp)); tmp.tty_major = rocket_driver->major; for (board = 0; board < 4; board++) { tmp.rocketModel[board].model = rocketModel[board].model; strcpy(tmp.rocketModel[board].modelString, rocketModel[board].modelString); tmp.rocketModel[board].numPorts = rocketModel[board].numPorts; tmp.rocketModel[board].loadrm2 = rocketModel[board].loadrm2; tmp.rocketModel[board].startingPortNumber = rocketModel[board].startingPortNumber; } if (copy_to_user(retports, &tmp, sizeof (*retports))) return -EFAULT; return 0; } static int reset_rm2(struct r_port *info, void __user *arg) { int reset; |
4129a6454 rocket: don't let... |
1428 1429 |
if (!capable(CAP_SYS_ADMIN)) return -EPERM; |
1da177e4c Linux-2.6.12-rc2 |
1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 |
if (copy_from_user(&reset, arg, sizeof (int))) return -EFAULT; if (reset) reset = 1; if (rcktpt_type[info->board] != ROCKET_TYPE_MODEMII && rcktpt_type[info->board] != ROCKET_TYPE_MODEMIII) return -EINVAL; if (info->ctlp->BusType == isISA) sModemReset(info->ctlp, info->chan, reset); else sPCIModemReset(info->ctlp, info->chan, reset); return 0; } static int get_version(struct r_port *info, struct rocket_version __user *retvers) { if (copy_to_user(retvers, &driver_version, sizeof (*retvers))) return -EFAULT; return 0; } /* IOCTL call handler into the driver */ static int rp_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) { |
c9f19e96a tty: Remove some ... |
1458 |
struct r_port *info = tty->driver_data; |
1da177e4c Linux-2.6.12-rc2 |
1459 |
void __user *argp = (void __user *)arg; |
bdf183aa4 rocket: Prepare f... |
1460 |
int ret = 0; |
1da177e4c Linux-2.6.12-rc2 |
1461 1462 1463 |
if (cmd != RCKP_GET_PORTS && rocket_paranoia_check(info, "rp_ioctl")) return -ENXIO; |
bdf183aa4 rocket: Prepare f... |
1464 |
lock_kernel(); |
1da177e4c Linux-2.6.12-rc2 |
1465 1466 1467 |
switch (cmd) { case RCKP_GET_STRUCT: if (copy_to_user(argp, info, sizeof (struct r_port))) |
bdf183aa4 rocket: Prepare f... |
1468 1469 |
ret = -EFAULT; break; |
1da177e4c Linux-2.6.12-rc2 |
1470 |
case RCKP_GET_CONFIG: |
bdf183aa4 rocket: Prepare f... |
1471 1472 |
ret = get_config(info, argp); break; |
1da177e4c Linux-2.6.12-rc2 |
1473 |
case RCKP_SET_CONFIG: |
bdf183aa4 rocket: Prepare f... |
1474 1475 |
ret = set_config(info, argp); break; |
1da177e4c Linux-2.6.12-rc2 |
1476 |
case RCKP_GET_PORTS: |
bdf183aa4 rocket: Prepare f... |
1477 1478 |
ret = get_ports(info, argp); break; |
1da177e4c Linux-2.6.12-rc2 |
1479 |
case RCKP_RESET_RM2: |
bdf183aa4 rocket: Prepare f... |
1480 1481 |
ret = reset_rm2(info, argp); break; |
1da177e4c Linux-2.6.12-rc2 |
1482 |
case RCKP_GET_VERSION: |
bdf183aa4 rocket: Prepare f... |
1483 1484 |
ret = get_version(info, argp); break; |
1da177e4c Linux-2.6.12-rc2 |
1485 |
default: |
bdf183aa4 rocket: Prepare f... |
1486 |
ret = -ENOIOCTLCMD; |
1da177e4c Linux-2.6.12-rc2 |
1487 |
} |
bdf183aa4 rocket: Prepare f... |
1488 1489 |
unlock_kernel(); return ret; |
1da177e4c Linux-2.6.12-rc2 |
1490 1491 1492 1493 |
} static void rp_send_xchar(struct tty_struct *tty, char ch) { |
c9f19e96a tty: Remove some ... |
1494 |
struct r_port *info = tty->driver_data; |
1da177e4c Linux-2.6.12-rc2 |
1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 |
CHANNEL_t *cp; if (rocket_paranoia_check(info, "rp_send_xchar")) return; cp = &info->channel; if (sGetTxCnt(cp)) sWriteTxPrioByte(cp, ch); else sWriteTxByte(sGetTxRxDataIO(cp), ch); } static void rp_throttle(struct tty_struct *tty) { |
c9f19e96a tty: Remove some ... |
1509 |
struct r_port *info = tty->driver_data; |
1da177e4c Linux-2.6.12-rc2 |
1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 |
CHANNEL_t *cp; #ifdef ROCKET_DEBUG_THROTTLE printk(KERN_INFO "throttle %s: %d.... ", tty->name, tty->ldisc.chars_in_buffer(tty)); #endif if (rocket_paranoia_check(info, "rp_throttle")) return; cp = &info->channel; if (I_IXOFF(tty)) rp_send_xchar(tty, STOP_CHAR(tty)); sClrRTS(&info->channel); } static void rp_unthrottle(struct tty_struct *tty) { |
c9f19e96a tty: Remove some ... |
1530 |
struct r_port *info = tty->driver_data; |
1da177e4c Linux-2.6.12-rc2 |
1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 |
CHANNEL_t *cp; #ifdef ROCKET_DEBUG_THROTTLE printk(KERN_INFO "unthrottle %s: %d.... ", tty->name, tty->ldisc.chars_in_buffer(tty)); #endif if (rocket_paranoia_check(info, "rp_throttle")) return; cp = &info->channel; if (I_IXOFF(tty)) rp_send_xchar(tty, START_CHAR(tty)); sSetRTS(&info->channel); } /* * ------------------------------------------------------------ * rp_stop() and rp_start() * * This routines are called before setting or resetting tty->stopped. * They enable or disable transmitter interrupts, as necessary. * ------------------------------------------------------------ */ static void rp_stop(struct tty_struct *tty) { |
c9f19e96a tty: Remove some ... |
1558 |
struct r_port *info = tty->driver_data; |
1da177e4c Linux-2.6.12-rc2 |
1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 |
#ifdef ROCKET_DEBUG_FLOW printk(KERN_INFO "stop %s: %d %d.... ", tty->name, info->xmit_cnt, info->xmit_fifo_room); #endif if (rocket_paranoia_check(info, "rp_stop")) return; if (sGetTxCnt(&info->channel)) sDisTransmit(&info->channel); } static void rp_start(struct tty_struct *tty) { |
c9f19e96a tty: Remove some ... |
1575 |
struct r_port *info = tty->driver_data; |
1da177e4c Linux-2.6.12-rc2 |
1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 |
#ifdef ROCKET_DEBUG_FLOW printk(KERN_INFO "start %s: %d %d.... ", tty->name, info->xmit_cnt, info->xmit_fifo_room); #endif if (rocket_paranoia_check(info, "rp_stop")) return; sEnTransmit(&info->channel); set_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]); } /* * rp_wait_until_sent() --- wait until the transmitter is empty */ static void rp_wait_until_sent(struct tty_struct *tty, int timeout) { |
c9f19e96a tty: Remove some ... |
1596 |
struct r_port *info = tty->driver_data; |
1da177e4c Linux-2.6.12-rc2 |
1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 |
CHANNEL_t *cp; unsigned long orig_jiffies; int check_time, exit_time; int txcnt; if (rocket_paranoia_check(info, "rp_wait_until_sent")) return; cp = &info->channel; orig_jiffies = jiffies; #ifdef ROCKET_DEBUG_WAIT_UNTIL_SENT |
68562b792 Char: rocket, pri... |
1609 1610 |
printk(KERN_INFO "In RP_wait_until_sent(%d) (jiff=%lu)... ", timeout, |
1da177e4c Linux-2.6.12-rc2 |
1611 |
jiffies); |
68562b792 Char: rocket, pri... |
1612 1613 |
printk(KERN_INFO "cps=%d... ", info->cps); |
1da177e4c Linux-2.6.12-rc2 |
1614 |
#endif |
978e595f8 tty/serial: lay t... |
1615 |
lock_kernel(); |
1da177e4c Linux-2.6.12-rc2 |
1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 |
while (1) { txcnt = sGetTxCnt(cp); if (!txcnt) { if (sGetChanStatusLo(cp) & TXSHRMT) break; check_time = (HZ / info->cps) / 5; } else { check_time = HZ * txcnt / info->cps; } if (timeout) { exit_time = orig_jiffies + timeout - jiffies; if (exit_time <= 0) break; if (exit_time < check_time) check_time = exit_time; } if (check_time == 0) check_time = 1; #ifdef ROCKET_DEBUG_WAIT_UNTIL_SENT |
68562b792 Char: rocket, pri... |
1635 1636 1637 |
printk(KERN_INFO "txcnt = %d (jiff=%lu,check=%d)... ", txcnt, jiffies, check_time); |
1da177e4c Linux-2.6.12-rc2 |
1638 1639 1640 1641 1642 |
#endif msleep_interruptible(jiffies_to_msecs(check_time)); if (signal_pending(current)) break; } |
cc0a8fbb7 drivers/char: use... |
1643 |
__set_current_state(TASK_RUNNING); |
978e595f8 tty/serial: lay t... |
1644 |
unlock_kernel(); |
1da177e4c Linux-2.6.12-rc2 |
1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 |
#ifdef ROCKET_DEBUG_WAIT_UNTIL_SENT printk(KERN_INFO "txcnt = %d (jiff=%lu)...done ", txcnt, jiffies); #endif } /* * rp_hangup() --- called by tty_hangup() when a hangup is signaled. */ static void rp_hangup(struct tty_struct *tty) { CHANNEL_t *cp; |
c9f19e96a tty: Remove some ... |
1657 |
struct r_port *info = tty->driver_data; |
1da177e4c Linux-2.6.12-rc2 |
1658 1659 1660 1661 1662 |
if (rocket_paranoia_check(info, "rp_hangup")) return; #if (defined(ROCKET_DEBUG_OPEN) || defined(ROCKET_DEBUG_HANGUP)) |
68562b792 Char: rocket, pri... |
1663 1664 |
printk(KERN_INFO "rp_hangup of ttyR%d... ", info->line); |
1da177e4c Linux-2.6.12-rc2 |
1665 1666 |
#endif rp_flush_buffer(tty); |
a129909ca tty: rocketport u... |
1667 |
if (info->flags & ASYNC_CLOSING) |
1da177e4c Linux-2.6.12-rc2 |
1668 |
return; |
e60a10844 rocket: use tty_port |
1669 |
if (info->port.count) |
1da177e4c Linux-2.6.12-rc2 |
1670 1671 |
atomic_dec(&rp_num_ports_open); clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]); |
e60a10844 rocket: use tty_port |
1672 |
info->port.count = 0; |
a129909ca tty: rocketport u... |
1673 |
info->flags &= ~ASYNC_NORMAL_ACTIVE; |
e60a10844 rocket: use tty_port |
1674 |
info->port.tty = NULL; |
1da177e4c Linux-2.6.12-rc2 |
1675 1676 1677 1678 1679 1680 1681 1682 |
cp = &info->channel; sDisRxFIFO(cp); sDisTransmit(cp); sDisInterrupts(cp, (TXINT_EN | MCINT_EN | RXINT_EN | SRCINT_EN | CHANINT_EN)); sDisCTSFlowCtl(cp); sDisTxSoftFlowCtl(cp); sClrTxXOFF(cp); |
a129909ca tty: rocketport u... |
1683 |
info->flags &= ~ASYNC_INITIALIZED; |
1da177e4c Linux-2.6.12-rc2 |
1684 |
|
e60a10844 rocket: use tty_port |
1685 |
wake_up_interruptible(&info->port.open_wait); |
1da177e4c Linux-2.6.12-rc2 |
1686 1687 1688 1689 1690 1691 1692 1693 1694 |
} /* * Exception handler - write char routine. The RocketPort driver uses a * double-buffering strategy, with the twist that if the in-memory CPU * buffer is empty, and there's space in the transmit FIFO, the * writing routines will write directly to transmit FIFO. * Write buffer and counters protected by spinlocks */ |
bbbbb96f5 riscom/rocket: sw... |
1695 |
static int rp_put_char(struct tty_struct *tty, unsigned char ch) |
1da177e4c Linux-2.6.12-rc2 |
1696 |
{ |
c9f19e96a tty: Remove some ... |
1697 |
struct r_port *info = tty->driver_data; |
1da177e4c Linux-2.6.12-rc2 |
1698 1699 1700 1701 |
CHANNEL_t *cp; unsigned long flags; if (rocket_paranoia_check(info, "rp_put_char")) |
bbbbb96f5 riscom/rocket: sw... |
1702 |
return 0; |
1da177e4c Linux-2.6.12-rc2 |
1703 |
|
69f545ea6 use mutex instead... |
1704 1705 1706 1707 1708 |
/* * Grab the port write mutex, locking out other processes that try to * write to this port */ mutex_lock(&info->write_mtx); |
1da177e4c Linux-2.6.12-rc2 |
1709 1710 |
#ifdef ROCKET_DEBUG_WRITE |
68562b792 Char: rocket, pri... |
1711 1712 |
printk(KERN_INFO "rp_put_char %c... ", ch); |
1da177e4c Linux-2.6.12-rc2 |
1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 |
#endif spin_lock_irqsave(&info->slock, flags); cp = &info->channel; if (!tty->stopped && !tty->hw_stopped && info->xmit_fifo_room == 0) info->xmit_fifo_room = TXFIFO_SIZE - sGetTxCnt(cp); if (tty->stopped || tty->hw_stopped || info->xmit_fifo_room == 0 || info->xmit_cnt != 0) { info->xmit_buf[info->xmit_head++] = ch; info->xmit_head &= XMIT_BUF_SIZE - 1; info->xmit_cnt++; set_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]); } else { sOutB(sGetTxRxDataIO(cp), ch); info->xmit_fifo_room--; } spin_unlock_irqrestore(&info->slock, flags); |
69f545ea6 use mutex instead... |
1731 |
mutex_unlock(&info->write_mtx); |
bbbbb96f5 riscom/rocket: sw... |
1732 |
return 1; |
1da177e4c Linux-2.6.12-rc2 |
1733 1734 1735 1736 |
} /* * Exception handler - write routine, called when user app writes to the device. |
69f545ea6 use mutex instead... |
1737 |
* A per port write mutex is used to protect from another process writing to |
1da177e4c Linux-2.6.12-rc2 |
1738 1739 1740 1741 1742 1743 1744 |
* this port at the same time. This other process could be running on the other CPU * or get control of the CPU if the copy_from_user() blocks due to a page fault (swapped out). * Spinlocks protect the info xmit members. */ static int rp_write(struct tty_struct *tty, const unsigned char *buf, int count) { |
c9f19e96a tty: Remove some ... |
1745 |
struct r_port *info = tty->driver_data; |
1da177e4c Linux-2.6.12-rc2 |
1746 1747 1748 1749 1750 1751 1752 |
CHANNEL_t *cp; const unsigned char *b; int c, retval = 0; unsigned long flags; if (count <= 0 || rocket_paranoia_check(info, "rp_write")) return 0; |
1e3e8d91f rocket.c: fix unc... |
1753 1754 |
if (mutex_lock_interruptible(&info->write_mtx)) return -ERESTARTSYS; |
1da177e4c Linux-2.6.12-rc2 |
1755 1756 |
#ifdef ROCKET_DEBUG_WRITE |
68562b792 Char: rocket, pri... |
1757 1758 |
printk(KERN_INFO "rp_write %d chars... ", count); |
1da177e4c Linux-2.6.12-rc2 |
1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 |
#endif cp = &info->channel; if (!tty->stopped && !tty->hw_stopped && info->xmit_fifo_room < count) info->xmit_fifo_room = TXFIFO_SIZE - sGetTxCnt(cp); /* * If the write queue for the port is empty, and there is FIFO space, stuff bytes * into FIFO. Use the write queue for temp storage. */ if (!tty->stopped && !tty->hw_stopped && info->xmit_cnt == 0 && info->xmit_fifo_room > 0) { c = min(count, info->xmit_fifo_room); b = buf; /* Push data into FIFO, 2 bytes at a time */ sOutStrW(sGetTxRxDataIO(cp), (unsigned short *) b, c / 2); /* If there is a byte remaining, write it */ if (c & 1) sOutB(sGetTxRxDataIO(cp), b[c - 1]); retval += c; buf += c; count -= c; spin_lock_irqsave(&info->slock, flags); info->xmit_fifo_room -= c; spin_unlock_irqrestore(&info->slock, flags); } /* If count is zero, we wrote it all and are done */ if (!count) goto end; /* Write remaining data into the port's xmit_buf */ while (1) { |
e60a10844 rocket: use tty_port |
1795 |
if (!info->port.tty) /* Seemingly obligatory check... */ |
1da177e4c Linux-2.6.12-rc2 |
1796 |
goto end; |
709107fcd char: rocket.c: f... |
1797 1798 |
c = min(count, XMIT_BUF_SIZE - info->xmit_cnt - 1); c = min(c, XMIT_BUF_SIZE - info->xmit_head); |
1da177e4c Linux-2.6.12-rc2 |
1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 |
if (c <= 0) break; b = buf; memcpy(info->xmit_buf + info->xmit_head, b, c); spin_lock_irqsave(&info->slock, flags); info->xmit_head = (info->xmit_head + c) & (XMIT_BUF_SIZE - 1); info->xmit_cnt += c; spin_unlock_irqrestore(&info->slock, flags); buf += c; count -= c; retval += c; } if ((retval > 0) && !tty->stopped && !tty->hw_stopped) set_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]); end: if (info->xmit_cnt < WAKEUP_CHARS) { tty_wakeup(tty); |
1da177e4c Linux-2.6.12-rc2 |
1822 1823 1824 1825 |
#ifdef ROCKETPORT_HAVE_POLL_WAIT wake_up_interruptible(&tty->poll_wait); #endif } |
69f545ea6 use mutex instead... |
1826 |
mutex_unlock(&info->write_mtx); |
1da177e4c Linux-2.6.12-rc2 |
1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 |
return retval; } /* * Return the number of characters that can be sent. We estimate * only using the in-memory transmit buffer only, and ignore the * potential space in the transmit FIFO. */ static int rp_write_room(struct tty_struct *tty) { |
c9f19e96a tty: Remove some ... |
1837 |
struct r_port *info = tty->driver_data; |
1da177e4c Linux-2.6.12-rc2 |
1838 1839 1840 1841 1842 1843 1844 1845 1846 |
int ret; if (rocket_paranoia_check(info, "rp_write_room")) return 0; ret = XMIT_BUF_SIZE - info->xmit_cnt - 1; if (ret < 0) ret = 0; #ifdef ROCKET_DEBUG_WRITE |
68562b792 Char: rocket, pri... |
1847 1848 |
printk(KERN_INFO "rp_write_room returns %d... ", ret); |
1da177e4c Linux-2.6.12-rc2 |
1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 |
#endif return ret; } /* * Return the number of characters in the buffer. Again, this only * counts those characters in the in-memory transmit buffer. */ static int rp_chars_in_buffer(struct tty_struct *tty) { |
c9f19e96a tty: Remove some ... |
1859 |
struct r_port *info = tty->driver_data; |
1da177e4c Linux-2.6.12-rc2 |
1860 1861 1862 1863 1864 1865 1866 1867 |
CHANNEL_t *cp; if (rocket_paranoia_check(info, "rp_chars_in_buffer")) return 0; cp = &info->channel; #ifdef ROCKET_DEBUG_WRITE |
68562b792 Char: rocket, pri... |
1868 1869 |
printk(KERN_INFO "rp_chars_in_buffer returns %d... ", info->xmit_cnt); |
1da177e4c Linux-2.6.12-rc2 |
1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 |
#endif return info->xmit_cnt; } /* * Flushes the TX fifo for a port, deletes data in the xmit_buf stored in the * r_port struct for the port. Note that spinlock are used to protect info members, * do not call this function if the spinlock is already held. */ static void rp_flush_buffer(struct tty_struct *tty) { |
c9f19e96a tty: Remove some ... |
1881 |
struct r_port *info = tty->driver_data; |
1da177e4c Linux-2.6.12-rc2 |
1882 1883 1884 1885 1886 1887 1888 1889 1890 |
CHANNEL_t *cp; unsigned long flags; if (rocket_paranoia_check(info, "rp_flush_buffer")) return; spin_lock_irqsave(&info->slock, flags); info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; spin_unlock_irqrestore(&info->slock, flags); |
1da177e4c Linux-2.6.12-rc2 |
1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 |
#ifdef ROCKETPORT_HAVE_POLL_WAIT wake_up_interruptible(&tty->poll_wait); #endif tty_wakeup(tty); cp = &info->channel; sFlushTxFIFO(cp); } #ifdef CONFIG_PCI |
8d5916d3e Char: rocket, add... |
1901 1902 1903 1904 1905 |
static struct pci_device_id __devinitdata rocket_pci_ids[] = { { PCI_DEVICE(PCI_VENDOR_ID_RP, PCI_ANY_ID) }, { } }; MODULE_DEVICE_TABLE(pci, rocket_pci_ids); |
1da177e4c Linux-2.6.12-rc2 |
1906 1907 1908 1909 1910 |
/* * Called when a PCI card is found. Retrieves and stores model information, * init's aiopic and serial port hardware. * Inputs: i is the board number (0-n) */ |
f15313bf4 [PATCH] drivers/c... |
1911 |
static __init int register_PCI(int i, struct pci_dev *dev) |
1da177e4c Linux-2.6.12-rc2 |
1912 1913 1914 1915 1916 1917 1918 1919 1920 |
{ int num_aiops, aiop, max_num_aiops, num_chan, chan; unsigned int aiopio[MAX_AIOPS_PER_BOARD]; char *str, *board_type; CONTROLLER_t *ctlp; int fast_clock = 0; int altChanRingIndicator = 0; int ports_per_aiop = 8; |
1da177e4c Linux-2.6.12-rc2 |
1921 1922 1923 1924 1925 1926 1927 |
WordIO_t ConfigIO = 0; ByteIO_t UPCIRingInd = 0; if (!dev || pci_enable_device(dev)) return 0; rcktpt_io_addr[i] = pci_resource_start(dev, 0); |
1da177e4c Linux-2.6.12-rc2 |
1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 |
rcktpt_type[i] = ROCKET_TYPE_NORMAL; rocketModel[i].loadrm2 = 0; rocketModel[i].startingPortNumber = nextLineNumber; /* Depending on the model, set up some config variables */ switch (dev->device) { case PCI_DEVICE_ID_RP4QUAD: str = "Quadcable"; max_num_aiops = 1; ports_per_aiop = 4; rocketModel[i].model = MODEL_RP4QUAD; strcpy(rocketModel[i].modelString, "RocketPort 4 port w/quad cable"); rocketModel[i].numPorts = 4; break; case PCI_DEVICE_ID_RP8OCTA: str = "Octacable"; max_num_aiops = 1; rocketModel[i].model = MODEL_RP8OCTA; strcpy(rocketModel[i].modelString, "RocketPort 8 port w/octa cable"); rocketModel[i].numPorts = 8; break; case PCI_DEVICE_ID_URP8OCTA: str = "Octacable"; max_num_aiops = 1; rocketModel[i].model = MODEL_UPCI_RP8OCTA; strcpy(rocketModel[i].modelString, "RocketPort UPCI 8 port w/octa cable"); rocketModel[i].numPorts = 8; break; case PCI_DEVICE_ID_RP8INTF: str = "8"; max_num_aiops = 1; rocketModel[i].model = MODEL_RP8INTF; strcpy(rocketModel[i].modelString, "RocketPort 8 port w/external I/F"); rocketModel[i].numPorts = 8; break; case PCI_DEVICE_ID_URP8INTF: str = "8"; max_num_aiops = 1; rocketModel[i].model = MODEL_UPCI_RP8INTF; strcpy(rocketModel[i].modelString, "RocketPort UPCI 8 port w/external I/F"); rocketModel[i].numPorts = 8; break; case PCI_DEVICE_ID_RP8J: str = "8J"; max_num_aiops = 1; rocketModel[i].model = MODEL_RP8J; strcpy(rocketModel[i].modelString, "RocketPort 8 port w/RJ11 connectors"); rocketModel[i].numPorts = 8; break; case PCI_DEVICE_ID_RP4J: str = "4J"; max_num_aiops = 1; ports_per_aiop = 4; rocketModel[i].model = MODEL_RP4J; strcpy(rocketModel[i].modelString, "RocketPort 4 port w/RJ45 connectors"); rocketModel[i].numPorts = 4; break; case PCI_DEVICE_ID_RP8SNI: str = "8 (DB78 Custom)"; max_num_aiops = 1; rocketModel[i].model = MODEL_RP8SNI; strcpy(rocketModel[i].modelString, "RocketPort 8 port w/ custom DB78"); rocketModel[i].numPorts = 8; break; case PCI_DEVICE_ID_RP16SNI: str = "16 (DB78 Custom)"; max_num_aiops = 2; rocketModel[i].model = MODEL_RP16SNI; strcpy(rocketModel[i].modelString, "RocketPort 16 port w/ custom DB78"); rocketModel[i].numPorts = 16; break; case PCI_DEVICE_ID_RP16INTF: str = "16"; max_num_aiops = 2; rocketModel[i].model = MODEL_RP16INTF; strcpy(rocketModel[i].modelString, "RocketPort 16 port w/external I/F"); rocketModel[i].numPorts = 16; break; case PCI_DEVICE_ID_URP16INTF: str = "16"; max_num_aiops = 2; rocketModel[i].model = MODEL_UPCI_RP16INTF; strcpy(rocketModel[i].modelString, "RocketPort UPCI 16 port w/external I/F"); rocketModel[i].numPorts = 16; break; case PCI_DEVICE_ID_CRP16INTF: str = "16"; max_num_aiops = 2; rocketModel[i].model = MODEL_CPCI_RP16INTF; strcpy(rocketModel[i].modelString, "RocketPort Compact PCI 16 port w/external I/F"); rocketModel[i].numPorts = 16; break; case PCI_DEVICE_ID_RP32INTF: str = "32"; max_num_aiops = 4; rocketModel[i].model = MODEL_RP32INTF; strcpy(rocketModel[i].modelString, "RocketPort 32 port w/external I/F"); rocketModel[i].numPorts = 32; break; case PCI_DEVICE_ID_URP32INTF: str = "32"; max_num_aiops = 4; rocketModel[i].model = MODEL_UPCI_RP32INTF; strcpy(rocketModel[i].modelString, "RocketPort UPCI 32 port w/external I/F"); rocketModel[i].numPorts = 32; break; case PCI_DEVICE_ID_RPP4: str = "Plus Quadcable"; max_num_aiops = 1; ports_per_aiop = 4; altChanRingIndicator++; fast_clock++; rocketModel[i].model = MODEL_RPP4; strcpy(rocketModel[i].modelString, "RocketPort Plus 4 port"); rocketModel[i].numPorts = 4; break; case PCI_DEVICE_ID_RPP8: str = "Plus Octacable"; max_num_aiops = 2; ports_per_aiop = 4; altChanRingIndicator++; fast_clock++; rocketModel[i].model = MODEL_RPP8; strcpy(rocketModel[i].modelString, "RocketPort Plus 8 port"); rocketModel[i].numPorts = 8; break; case PCI_DEVICE_ID_RP2_232: str = "Plus 2 (RS-232)"; max_num_aiops = 1; ports_per_aiop = 2; altChanRingIndicator++; fast_clock++; rocketModel[i].model = MODEL_RP2_232; strcpy(rocketModel[i].modelString, "RocketPort Plus 2 port RS232"); rocketModel[i].numPorts = 2; break; case PCI_DEVICE_ID_RP2_422: str = "Plus 2 (RS-422)"; max_num_aiops = 1; ports_per_aiop = 2; altChanRingIndicator++; fast_clock++; rocketModel[i].model = MODEL_RP2_422; strcpy(rocketModel[i].modelString, "RocketPort Plus 2 port RS422"); rocketModel[i].numPorts = 2; break; case PCI_DEVICE_ID_RP6M: max_num_aiops = 1; ports_per_aiop = 6; str = "6-port"; |
57fedc7ae Char: rocket, rem... |
2080 2081 2082 |
/* If revision is 1, the rocketmodem flash must be loaded. * If it is 2 it is a "socketed" version. */ if (dev->revision == 1) { |
1da177e4c Linux-2.6.12-rc2 |
2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 |
rcktpt_type[i] = ROCKET_TYPE_MODEMII; rocketModel[i].loadrm2 = 1; } else { rcktpt_type[i] = ROCKET_TYPE_MODEM; } rocketModel[i].model = MODEL_RP6M; strcpy(rocketModel[i].modelString, "RocketModem 6 port"); rocketModel[i].numPorts = 6; break; case PCI_DEVICE_ID_RP4M: max_num_aiops = 1; ports_per_aiop = 4; str = "4-port"; |
57fedc7ae Char: rocket, rem... |
2097 |
if (dev->revision == 1) { |
1da177e4c Linux-2.6.12-rc2 |
2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 |
rcktpt_type[i] = ROCKET_TYPE_MODEMII; rocketModel[i].loadrm2 = 1; } else { rcktpt_type[i] = ROCKET_TYPE_MODEM; } rocketModel[i].model = MODEL_RP4M; strcpy(rocketModel[i].modelString, "RocketModem 4 port"); rocketModel[i].numPorts = 4; break; default: str = "(unknown/unsupported)"; max_num_aiops = 0; break; } /* * Check for UPCI boards. */ switch (dev->device) { case PCI_DEVICE_ID_URP32INTF: case PCI_DEVICE_ID_URP8INTF: case PCI_DEVICE_ID_URP16INTF: case PCI_DEVICE_ID_CRP16INTF: case PCI_DEVICE_ID_URP8OCTA: rcktpt_io_addr[i] = pci_resource_start(dev, 2); ConfigIO = pci_resource_start(dev, 1); if (dev->device == PCI_DEVICE_ID_URP8OCTA) { UPCIRingInd = rcktpt_io_addr[i] + _PCI_9030_RING_IND; /* * Check for octa or quad cable. */ if (! (sInW(ConfigIO + _PCI_9030_GPIO_CTRL) & PCI_GPIO_CTRL_8PORT)) { str = "Quadcable"; ports_per_aiop = 4; rocketModel[i].numPorts = 4; } } break; case PCI_DEVICE_ID_UPCI_RM3_8PORT: str = "8 ports"; max_num_aiops = 1; rocketModel[i].model = MODEL_UPCI_RM3_8PORT; strcpy(rocketModel[i].modelString, "RocketModem III 8 port"); rocketModel[i].numPorts = 8; rcktpt_io_addr[i] = pci_resource_start(dev, 2); UPCIRingInd = rcktpt_io_addr[i] + _PCI_9030_RING_IND; ConfigIO = pci_resource_start(dev, 1); rcktpt_type[i] = ROCKET_TYPE_MODEMIII; break; case PCI_DEVICE_ID_UPCI_RM3_4PORT: str = "4 ports"; max_num_aiops = 1; rocketModel[i].model = MODEL_UPCI_RM3_4PORT; strcpy(rocketModel[i].modelString, "RocketModem III 4 port"); rocketModel[i].numPorts = 4; rcktpt_io_addr[i] = pci_resource_start(dev, 2); UPCIRingInd = rcktpt_io_addr[i] + _PCI_9030_RING_IND; ConfigIO = pci_resource_start(dev, 1); rcktpt_type[i] = ROCKET_TYPE_MODEMIII; break; default: break; } switch (rcktpt_type[i]) { case ROCKET_TYPE_MODEM: board_type = "RocketModem"; break; case ROCKET_TYPE_MODEMII: board_type = "RocketModem II"; break; case ROCKET_TYPE_MODEMIII: board_type = "RocketModem III"; break; default: board_type = "RocketPort"; break; } if (fast_clock) { sClockPrescale = 0x12; /* mod 2 (divide by 3) */ rp_baud_base[i] = 921600; } else { /* * If support_low_speed is set, use the slow clock * prescale, which supports 50 bps */ if (support_low_speed) { /* mod 9 (divide by 10) prescale */ sClockPrescale = 0x19; rp_baud_base[i] = 230400; } else { /* mod 4 (devide by 5) prescale */ sClockPrescale = 0x14; rp_baud_base[i] = 460800; } } for (aiop = 0; aiop < max_num_aiops; aiop++) aiopio[aiop] = rcktpt_io_addr[i] + (aiop * 0x40); ctlp = sCtlNumToCtlPtr(i); num_aiops = sPCIInitController(ctlp, i, aiopio, max_num_aiops, ConfigIO, 0, FREQ_DIS, 0, altChanRingIndicator, UPCIRingInd); for (aiop = 0; aiop < max_num_aiops; aiop++) ctlp->AiopNumChan[aiop] = ports_per_aiop; |
68562b792 Char: rocket, pri... |
2207 2208 2209 2210 2211 2212 |
dev_info(&dev->dev, "comtrol PCI controller #%d found at " "address %04lx, %d AIOP(s) (%s), creating ttyR%d - %ld ", i, rcktpt_io_addr[i], num_aiops, rocketModel[i].modelString, rocketModel[i].startingPortNumber, rocketModel[i].startingPortNumber + rocketModel[i].numPorts-1); |
1da177e4c Linux-2.6.12-rc2 |
2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 |
if (num_aiops <= 0) { rcktpt_io_addr[i] = 0; return (0); } is_PCI[i] = 1; /* Reset the AIOPIC, init the serial ports */ for (aiop = 0; aiop < num_aiops; aiop++) { sResetAiopByNum(ctlp, aiop); num_chan = ports_per_aiop; for (chan = 0; chan < num_chan; chan++) init_r_port(i, aiop, chan, dev); } /* Rocket modems must be reset */ if ((rcktpt_type[i] == ROCKET_TYPE_MODEM) || (rcktpt_type[i] == ROCKET_TYPE_MODEMII) || (rcktpt_type[i] == ROCKET_TYPE_MODEMIII)) { num_chan = ports_per_aiop; for (chan = 0; chan < num_chan; chan++) sPCIModemReset(ctlp, chan, 1); |
48a67f5da Char: rocket, swi... |
2235 |
msleep(500); |
1da177e4c Linux-2.6.12-rc2 |
2236 2237 |
for (chan = 0; chan < num_chan; chan++) sPCIModemReset(ctlp, chan, 0); |
48a67f5da Char: rocket, swi... |
2238 |
msleep(500); |
1da177e4c Linux-2.6.12-rc2 |
2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 |
rmSpeakerReset(ctlp, rocketModel[i].model); } return (1); } /* * Probes for PCI cards, inits them if found * Input: board_found = number of ISA boards already found, or the * starting board number * Returns: Number of PCI boards found */ static int __init init_PCI(int boards_found) { struct pci_dev *dev = NULL; int count = 0; /* Work through the PCI device list, pulling out ours */ |
606d099cd [PATCH] tty: swit... |
2256 |
while ((dev = pci_get_device(PCI_VENDOR_ID_RP, PCI_ANY_ID, dev))) { |
1da177e4c Linux-2.6.12-rc2 |
2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 |
if (register_PCI(count + boards_found, dev)) count++; } return (count); } #endif /* CONFIG_PCI */ /* * Probes for ISA cards * Input: i = the board number to look for * Returns: 1 if board found, 0 else */ static int __init init_ISA(int i) { int num_aiops, num_chan = 0, total_num_chan = 0; int aiop, chan; unsigned int aiopio[MAX_AIOPS_PER_BOARD]; CONTROLLER_t *ctlp; char *type_string; /* If io_addr is zero, no board configured */ if (rcktpt_io_addr[i] == 0) return (0); /* Reserve the IO region */ if (!request_region(rcktpt_io_addr[i], 64, "Comtrol RocketPort")) { |
68562b792 Char: rocket, pri... |
2284 2285 2286 2287 |
printk(KERN_ERR "Unable to reserve IO region for configured " "ISA RocketPort at address 0x%lx, board not " "installed... ", rcktpt_io_addr[i]); |
1da177e4c Linux-2.6.12-rc2 |
2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 |
rcktpt_io_addr[i] = 0; return (0); } ctlp = sCtlNumToCtlPtr(i); ctlp->boardType = rcktpt_type[i]; switch (rcktpt_type[i]) { case ROCKET_TYPE_PC104: type_string = "(PC104)"; break; case ROCKET_TYPE_MODEM: type_string = "(RocketModem)"; break; case ROCKET_TYPE_MODEMII: type_string = "(RocketModem II)"; break; default: type_string = ""; break; } /* * If support_low_speed is set, use the slow clock prescale, * which supports 50 bps */ if (support_low_speed) { sClockPrescale = 0x19; /* mod 9 (divide by 10) prescale */ rp_baud_base[i] = 230400; } else { sClockPrescale = 0x14; /* mod 4 (devide by 5) prescale */ rp_baud_base[i] = 460800; } for (aiop = 0; aiop < MAX_AIOPS_PER_BOARD; aiop++) aiopio[aiop] = rcktpt_io_addr[i] + (aiop * 0x400); num_aiops = sInitController(ctlp, i, controller + (i * 0x400), aiopio, MAX_AIOPS_PER_BOARD, 0, FREQ_DIS, 0); if (ctlp->boardType == ROCKET_TYPE_PC104) { sEnAiop(ctlp, 2); /* only one AIOPIC, but these */ sEnAiop(ctlp, 3); /* CSels used for other stuff */ } /* If something went wrong initing the AIOP's release the ISA IO memory */ if (num_aiops <= 0) { release_region(rcktpt_io_addr[i], 64); rcktpt_io_addr[i] = 0; return (0); } rocketModel[i].startingPortNumber = nextLineNumber; for (aiop = 0; aiop < num_aiops; aiop++) { sResetAiopByNum(ctlp, aiop); sEnAiop(ctlp, aiop); num_chan = sGetAiopNumChan(ctlp, aiop); total_num_chan += num_chan; for (chan = 0; chan < num_chan; chan++) init_r_port(i, aiop, chan, NULL); } is_PCI[i] = 0; if ((rcktpt_type[i] == ROCKET_TYPE_MODEM) || (rcktpt_type[i] == ROCKET_TYPE_MODEMII)) { num_chan = sGetAiopNumChan(ctlp, 0); total_num_chan = num_chan; for (chan = 0; chan < num_chan; chan++) sModemReset(ctlp, chan, 1); |
48a67f5da Char: rocket, swi... |
2356 |
msleep(500); |
1da177e4c Linux-2.6.12-rc2 |
2357 2358 |
for (chan = 0; chan < num_chan; chan++) sModemReset(ctlp, chan, 0); |
48a67f5da Char: rocket, swi... |
2359 |
msleep(500); |
1da177e4c Linux-2.6.12-rc2 |
2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 |
strcpy(rocketModel[i].modelString, "RocketModem ISA"); } else { strcpy(rocketModel[i].modelString, "RocketPort ISA"); } rocketModel[i].numPorts = total_num_chan; rocketModel[i].model = MODEL_ISA; printk(KERN_INFO "RocketPort ISA card #%d found at 0x%lx - %d AIOPs %s ", i, rcktpt_io_addr[i], num_aiops, type_string); printk(KERN_INFO "Installing %s, creating /dev/ttyR%d - %ld ", rocketModel[i].modelString, rocketModel[i].startingPortNumber, rocketModel[i].startingPortNumber + rocketModel[i].numPorts - 1); return (1); } |
b68e31d0e [PATCH] const str... |
2380 |
static const struct tty_operations rocket_ops = { |
1da177e4c Linux-2.6.12-rc2 |
2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 |
.open = rp_open, .close = rp_close, .write = rp_write, .put_char = rp_put_char, .write_room = rp_write_room, .chars_in_buffer = rp_chars_in_buffer, .flush_buffer = rp_flush_buffer, .ioctl = rp_ioctl, .throttle = rp_throttle, .unthrottle = rp_unthrottle, .set_termios = rp_set_termios, .stop = rp_stop, .start = rp_start, .hangup = rp_hangup, .break_ctl = rp_break, .send_xchar = rp_send_xchar, .wait_until_sent = rp_wait_until_sent, .tiocmget = rp_tiocmget, .tiocmset = rp_tiocmset, }; |
31f35939d tty_port: Add a p... |
2401 2402 |
static const struct tty_port_operations rocket_port_ops = { .carrier_raised = carrier_raised, |
5d951fb45 tty: Pull the dtr... |
2403 |
.raise_dtr_rts = raise_dtr_rts, |
31f35939d tty_port: Add a p... |
2404 |
}; |
1da177e4c Linux-2.6.12-rc2 |
2405 2406 2407 |
/* * The module "startup" routine; it's run when the module is loaded. */ |
d269cdd0e [PATCH] rocketpor... |
2408 |
static int __init rp_init(void) |
1da177e4c Linux-2.6.12-rc2 |
2409 |
{ |
4384a3fae Char: rocket, rem... |
2410 |
int ret = -ENOMEM, pci_boards_found, isa_boards_found, i; |
1da177e4c Linux-2.6.12-rc2 |
2411 2412 2413 2414 2415 2416 2417 |
printk(KERN_INFO "RocketPort device driver module, version %s, %s ", ROCKET_VERSION, ROCKET_DATE); rocket_driver = alloc_tty_driver(MAX_RP_PORTS); if (!rocket_driver) |
4384a3fae Char: rocket, rem... |
2418 |
goto err; |
1da177e4c Linux-2.6.12-rc2 |
2419 2420 |
/* |
1da177e4c Linux-2.6.12-rc2 |
2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 |
* If board 1 is non-zero, there is at least one ISA configured. If controller is * zero, use the default controller IO address of board1 + 0x40. */ if (board1) { if (controller == 0) controller = board1 + 0x40; } else { controller = 0; /* Used as a flag, meaning no ISA boards */ } /* If an ISA card is configured, reserve the 4 byte IO space for the Mudbac controller */ if (controller && (!request_region(controller, 4, "Comtrol RocketPort"))) { |
4384a3fae Char: rocket, rem... |
2433 2434 2435 2436 2437 2438 |
printk(KERN_ERR "Unable to reserve IO region for first " "configured ISA RocketPort controller 0x%lx. " "Driver exiting ", controller); ret = -EBUSY; goto err_tty; |
1da177e4c Linux-2.6.12-rc2 |
2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 |
} /* Store ISA variable retrieved from command line or .conf file. */ rcktpt_io_addr[0] = board1; rcktpt_io_addr[1] = board2; rcktpt_io_addr[2] = board3; rcktpt_io_addr[3] = board4; rcktpt_type[0] = modem1 ? ROCKET_TYPE_MODEM : ROCKET_TYPE_NORMAL; rcktpt_type[0] = pc104_1[0] ? ROCKET_TYPE_PC104 : rcktpt_type[0]; rcktpt_type[1] = modem2 ? ROCKET_TYPE_MODEM : ROCKET_TYPE_NORMAL; rcktpt_type[1] = pc104_2[0] ? ROCKET_TYPE_PC104 : rcktpt_type[1]; rcktpt_type[2] = modem3 ? ROCKET_TYPE_MODEM : ROCKET_TYPE_NORMAL; rcktpt_type[2] = pc104_3[0] ? ROCKET_TYPE_PC104 : rcktpt_type[2]; rcktpt_type[3] = modem4 ? ROCKET_TYPE_MODEM : ROCKET_TYPE_NORMAL; rcktpt_type[3] = pc104_4[0] ? ROCKET_TYPE_PC104 : rcktpt_type[3]; /* * Set up the tty driver structure and then register this * driver with the tty layer. */ rocket_driver->owner = THIS_MODULE; |
331b83198 [PATCH] devfs: Re... |
2462 |
rocket_driver->flags = TTY_DRIVER_DYNAMIC_DEV; |
1da177e4c Linux-2.6.12-rc2 |
2463 2464 2465 2466 2467 2468 2469 2470 2471 |
rocket_driver->name = "ttyR"; rocket_driver->driver_name = "Comtrol RocketPort"; rocket_driver->major = TTY_ROCKET_MAJOR; rocket_driver->minor_start = 0; rocket_driver->type = TTY_DRIVER_TYPE_SERIAL; rocket_driver->subtype = SERIAL_TYPE_NORMAL; rocket_driver->init_termios = tty_std_termios; rocket_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; |
606d099cd [PATCH] tty: swit... |
2472 2473 |
rocket_driver->init_termios.c_ispeed = 9600; rocket_driver->init_termios.c_ospeed = 9600; |
1da177e4c Linux-2.6.12-rc2 |
2474 |
#ifdef ROCKET_SOFT_FLOW |
ac6aec2f5 Char: rocket, fix... |
2475 |
rocket_driver->flags |= TTY_DRIVER_REAL_RAW; |
1da177e4c Linux-2.6.12-rc2 |
2476 2477 |
#endif tty_set_operations(rocket_driver, &rocket_ops); |
4384a3fae Char: rocket, rem... |
2478 2479 2480 2481 2482 |
ret = tty_register_driver(rocket_driver); if (ret < 0) { printk(KERN_ERR "Couldn't install tty RocketPort driver "); goto err_tty; |
1da177e4c Linux-2.6.12-rc2 |
2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 |
} #ifdef ROCKET_DEBUG_OPEN printk(KERN_INFO "RocketPort driver is major %d ", rocket_driver.major); #endif /* * OK, let's probe each of the controllers looking for boards. Any boards found * will be initialized here. */ isa_boards_found = 0; pci_boards_found = 0; for (i = 0; i < NUM_BOARDS; i++) { if (init_ISA(i)) isa_boards_found++; } #ifdef CONFIG_PCI if (isa_boards_found < NUM_BOARDS) pci_boards_found = init_PCI(isa_boards_found); #endif max_board = pci_boards_found + isa_boards_found; if (max_board == 0) { |
4384a3fae Char: rocket, rem... |
2510 2511 2512 2513 |
printk(KERN_ERR "No rocketport ports found; unloading driver "); ret = -ENXIO; goto err_ttyu; |
1da177e4c Linux-2.6.12-rc2 |
2514 2515 2516 |
} return 0; |
4384a3fae Char: rocket, rem... |
2517 2518 2519 2520 2521 2522 |
err_ttyu: tty_unregister_driver(rocket_driver); err_tty: put_tty_driver(rocket_driver); err: return ret; |
1da177e4c Linux-2.6.12-rc2 |
2523 |
} |
1da177e4c Linux-2.6.12-rc2 |
2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 |
static void rp_cleanup_module(void) { int retval; int i; del_timer_sync(&rocket_timer); retval = tty_unregister_driver(rocket_driver); if (retval) |
68562b792 Char: rocket, pri... |
2534 |
printk(KERN_ERR "Error %d while trying to unregister " |
1da177e4c Linux-2.6.12-rc2 |
2535 2536 |
"rocketport driver ", -retval); |
1da177e4c Linux-2.6.12-rc2 |
2537 |
|
735d5661d [PATCH] kfree cle... |
2538 |
for (i = 0; i < MAX_RP_PORTS; i++) |
ac6aec2f5 Char: rocket, fix... |
2539 2540 2541 2542 2543 2544 |
if (rp_table[i]) { tty_unregister_device(rocket_driver, i); kfree(rp_table[i]); } put_tty_driver(rocket_driver); |
1da177e4c Linux-2.6.12-rc2 |
2545 2546 2547 2548 2549 2550 2551 2552 2553 |
for (i = 0; i < NUM_BOARDS; i++) { if (rcktpt_io_addr[i] <= 0 || is_PCI[i]) continue; release_region(rcktpt_io_addr[i], 64); } if (controller) release_region(controller, 4); } |
1da177e4c Linux-2.6.12-rc2 |
2554 |
|
1da177e4c Linux-2.6.12-rc2 |
2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 |
/*************************************************************************** Function: sInitController Purpose: Initialization of controller global registers and controller structure. Call: sInitController(CtlP,CtlNum,MudbacIO,AiopIOList,AiopIOListSize, IRQNum,Frequency,PeriodicOnly) CONTROLLER_T *CtlP; Ptr to controller structure int CtlNum; Controller number ByteIO_t MudbacIO; Mudbac base I/O address. ByteIO_t *AiopIOList; List of I/O addresses for each AIOP. This list must be in the order the AIOPs will be found on the controller. Once an AIOP in the list is not found, it is assumed that there are no more AIOPs on the controller. int AiopIOListSize; Number of addresses in AiopIOList int IRQNum; Interrupt Request number. Can be any of the following: 0: Disable global interrupts 3: IRQ 3 4: IRQ 4 5: IRQ 5 9: IRQ 9 10: IRQ 10 11: IRQ 11 12: IRQ 12 15: IRQ 15 Byte_t Frequency: A flag identifying the frequency of the periodic interrupt, can be any one of the following: FREQ_DIS - periodic interrupt disabled FREQ_137HZ - 137 Hertz FREQ_69HZ - 69 Hertz FREQ_34HZ - 34 Hertz FREQ_17HZ - 17 Hertz FREQ_9HZ - 9 Hertz FREQ_4HZ - 4 Hertz If IRQNum is set to 0 the Frequency parameter is overidden, it is forced to a value of FREQ_DIS. |
f15313bf4 [PATCH] drivers/c... |
2590 |
int PeriodicOnly: 1 if all interrupts except the periodic |
1da177e4c Linux-2.6.12-rc2 |
2591 |
interrupt are to be blocked. |
f15313bf4 [PATCH] drivers/c... |
2592 |
0 is both the periodic interrupt and |
1da177e4c Linux-2.6.12-rc2 |
2593 2594 |
other channel interrupts are allowed. If IRQNum is set to 0 the PeriodicOnly parameter is |
f15313bf4 [PATCH] drivers/c... |
2595 |
overidden, it is forced to a value of 0. |
1da177e4c Linux-2.6.12-rc2 |
2596 2597 2598 2599 2600 |
Return: int: Number of AIOPs on the controller, or CTLID_NULL if controller initialization failed. Comments: If periodic interrupts are to be disabled but AIOP interrupts |
f15313bf4 [PATCH] drivers/c... |
2601 |
are allowed, set Frequency to FREQ_DIS and PeriodicOnly to 0. |
1da177e4c Linux-2.6.12-rc2 |
2602 2603 |
If interrupts are to be completely disabled set IRQNum to 0. |
f15313bf4 [PATCH] drivers/c... |
2604 |
Setting Frequency to FREQ_DIS and PeriodicOnly to 1 is an |
1da177e4c Linux-2.6.12-rc2 |
2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 |
invalid combination. This function performs initialization of global interrupt modes, but it does not actually enable global interrupts. To enable and disable global interrupts use functions sEnGlobalInt() and sDisGlobalInt(). Enabling of global interrupts is normally not done until all other initializations are complete. Even if interrupts are globally enabled, they must also be individually enabled for each channel that is to generate interrupts. Warnings: No range checking on any of the parameters is done. No context switches are allowed while executing this function. After this function all AIOPs on the controller are disabled, they can be enabled with sEnAiop(). */ |
f15313bf4 [PATCH] drivers/c... |
2624 2625 2626 |
static int sInitController(CONTROLLER_T * CtlP, int CtlNum, ByteIO_t MudbacIO, ByteIO_t * AiopIOList, int AiopIOListSize, int IRQNum, Byte_t Frequency, int PeriodicOnly) |
1da177e4c Linux-2.6.12-rc2 |
2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 |
{ int i; ByteIO_t io; int done; CtlP->AiopIntrBits = aiop_intr_bits; CtlP->AltChanRingIndicator = 0; CtlP->CtlNum = CtlNum; CtlP->CtlID = CTLID_0001; /* controller release 1 */ CtlP->BusType = isISA; CtlP->MBaseIO = MudbacIO; CtlP->MReg1IO = MudbacIO + 1; CtlP->MReg2IO = MudbacIO + 2; CtlP->MReg3IO = MudbacIO + 3; #if 1 CtlP->MReg2 = 0; /* interrupt disable */ CtlP->MReg3 = 0; /* no periodic interrupts */ #else if (sIRQMap[IRQNum] == 0) { /* interrupts globally disabled */ CtlP->MReg2 = 0; /* interrupt disable */ CtlP->MReg3 = 0; /* no periodic interrupts */ } else { CtlP->MReg2 = sIRQMap[IRQNum]; /* set IRQ number */ CtlP->MReg3 = Frequency; /* set frequency */ if (PeriodicOnly) { /* periodic interrupt only */ CtlP->MReg3 |= PERIODIC_ONLY; } } #endif sOutB(CtlP->MReg2IO, CtlP->MReg2); sOutB(CtlP->MReg3IO, CtlP->MReg3); sControllerEOI(CtlP); /* clear EOI if warm init */ /* Init AIOPs */ CtlP->NumAiop = 0; for (i = done = 0; i < AiopIOListSize; i++) { io = AiopIOList[i]; CtlP->AiopIO[i] = (WordIO_t) io; CtlP->AiopIntChanIO[i] = io + _INT_CHAN; sOutB(CtlP->MReg2IO, CtlP->MReg2 | (i & 0x03)); /* AIOP index */ sOutB(MudbacIO, (Byte_t) (io >> 6)); /* set up AIOP I/O in MUDBAC */ if (done) continue; sEnAiop(CtlP, i); /* enable the AIOP */ CtlP->AiopID[i] = sReadAiopID(io); /* read AIOP ID */ if (CtlP->AiopID[i] == AIOPID_NULL) /* if AIOP does not exist */ done = 1; /* done looking for AIOPs */ else { CtlP->AiopNumChan[i] = sReadAiopNumChan((WordIO_t) io); /* num channels in AIOP */ sOutW((WordIO_t) io + _INDX_ADDR, _CLK_PRE); /* clock prescaler */ sOutB(io + _INDX_DATA, sClockPrescale); CtlP->NumAiop++; /* bump count of AIOPs */ } sDisAiop(CtlP, i); /* disable AIOP */ } if (CtlP->NumAiop == 0) return (-1); else return (CtlP->NumAiop); } /*************************************************************************** Function: sPCIInitController Purpose: Initialization of controller global registers and controller structure. Call: sPCIInitController(CtlP,CtlNum,AiopIOList,AiopIOListSize, IRQNum,Frequency,PeriodicOnly) CONTROLLER_T *CtlP; Ptr to controller structure int CtlNum; Controller number ByteIO_t *AiopIOList; List of I/O addresses for each AIOP. This list must be in the order the AIOPs will be found on the controller. Once an AIOP in the list is not found, it is assumed that there are no more AIOPs on the controller. int AiopIOListSize; Number of addresses in AiopIOList int IRQNum; Interrupt Request number. Can be any of the following: 0: Disable global interrupts 3: IRQ 3 4: IRQ 4 5: IRQ 5 9: IRQ 9 10: IRQ 10 11: IRQ 11 12: IRQ 12 15: IRQ 15 Byte_t Frequency: A flag identifying the frequency of the periodic interrupt, can be any one of the following: FREQ_DIS - periodic interrupt disabled FREQ_137HZ - 137 Hertz FREQ_69HZ - 69 Hertz FREQ_34HZ - 34 Hertz FREQ_17HZ - 17 Hertz FREQ_9HZ - 9 Hertz FREQ_4HZ - 4 Hertz If IRQNum is set to 0 the Frequency parameter is overidden, it is forced to a value of FREQ_DIS. |
f15313bf4 [PATCH] drivers/c... |
2722 |
int PeriodicOnly: 1 if all interrupts except the periodic |
1da177e4c Linux-2.6.12-rc2 |
2723 |
interrupt are to be blocked. |
f15313bf4 [PATCH] drivers/c... |
2724 |
0 is both the periodic interrupt and |
1da177e4c Linux-2.6.12-rc2 |
2725 2726 |
other channel interrupts are allowed. If IRQNum is set to 0 the PeriodicOnly parameter is |
f15313bf4 [PATCH] drivers/c... |
2727 |
overidden, it is forced to a value of 0. |
1da177e4c Linux-2.6.12-rc2 |
2728 2729 2730 2731 2732 |
Return: int: Number of AIOPs on the controller, or CTLID_NULL if controller initialization failed. Comments: If periodic interrupts are to be disabled but AIOP interrupts |
f15313bf4 [PATCH] drivers/c... |
2733 |
are allowed, set Frequency to FREQ_DIS and PeriodicOnly to 0. |
1da177e4c Linux-2.6.12-rc2 |
2734 2735 |
If interrupts are to be completely disabled set IRQNum to 0. |
f15313bf4 [PATCH] drivers/c... |
2736 |
Setting Frequency to FREQ_DIS and PeriodicOnly to 1 is an |
1da177e4c Linux-2.6.12-rc2 |
2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 |
invalid combination. This function performs initialization of global interrupt modes, but it does not actually enable global interrupts. To enable and disable global interrupts use functions sEnGlobalInt() and sDisGlobalInt(). Enabling of global interrupts is normally not done until all other initializations are complete. Even if interrupts are globally enabled, they must also be individually enabled for each channel that is to generate interrupts. Warnings: No range checking on any of the parameters is done. No context switches are allowed while executing this function. After this function all AIOPs on the controller are disabled, they can be enabled with sEnAiop(). */ |
f15313bf4 [PATCH] drivers/c... |
2756 2757 2758 2759 2760 |
static int sPCIInitController(CONTROLLER_T * CtlP, int CtlNum, ByteIO_t * AiopIOList, int AiopIOListSize, WordIO_t ConfigIO, int IRQNum, Byte_t Frequency, int PeriodicOnly, int altChanRingIndicator, int UPCIRingInd) |
1da177e4c Linux-2.6.12-rc2 |
2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 |
{ int i; ByteIO_t io; CtlP->AltChanRingIndicator = altChanRingIndicator; CtlP->UPCIRingInd = UPCIRingInd; CtlP->CtlNum = CtlNum; CtlP->CtlID = CTLID_0001; /* controller release 1 */ CtlP->BusType = isPCI; /* controller release 1 */ if (ConfigIO) { CtlP->isUPCI = 1; CtlP->PCIIO = ConfigIO + _PCI_9030_INT_CTRL; CtlP->PCIIO2 = ConfigIO + _PCI_9030_GPIO_CTRL; CtlP->AiopIntrBits = upci_aiop_intr_bits; } else { CtlP->isUPCI = 0; CtlP->PCIIO = (WordIO_t) ((ByteIO_t) AiopIOList[0] + _PCI_INT_FUNC); CtlP->AiopIntrBits = aiop_intr_bits; } sPCIControllerEOI(CtlP); /* clear EOI if warm init */ /* Init AIOPs */ CtlP->NumAiop = 0; for (i = 0; i < AiopIOListSize; i++) { io = AiopIOList[i]; CtlP->AiopIO[i] = (WordIO_t) io; CtlP->AiopIntChanIO[i] = io + _INT_CHAN; CtlP->AiopID[i] = sReadAiopID(io); /* read AIOP ID */ if (CtlP->AiopID[i] == AIOPID_NULL) /* if AIOP does not exist */ break; /* done looking for AIOPs */ CtlP->AiopNumChan[i] = sReadAiopNumChan((WordIO_t) io); /* num channels in AIOP */ sOutW((WordIO_t) io + _INDX_ADDR, _CLK_PRE); /* clock prescaler */ sOutB(io + _INDX_DATA, sClockPrescale); CtlP->NumAiop++; /* bump count of AIOPs */ } if (CtlP->NumAiop == 0) return (-1); else return (CtlP->NumAiop); } /*************************************************************************** Function: sReadAiopID Purpose: Read the AIOP idenfication number directly from an AIOP. Call: sReadAiopID(io) ByteIO_t io: AIOP base I/O address Return: int: Flag AIOPID_XXXX if a valid AIOP is found, where X is replace by an identifying number. Flag AIOPID_NULL if no valid AIOP is found Warnings: No context switches are allowed while executing this function. */ |
f15313bf4 [PATCH] drivers/c... |
2818 |
static int sReadAiopID(ByteIO_t io) |
1da177e4c Linux-2.6.12-rc2 |
2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 |
{ Byte_t AiopID; /* ID byte from AIOP */ sOutB(io + _CMD_REG, RESET_ALL); /* reset AIOP */ sOutB(io + _CMD_REG, 0x0); AiopID = sInW(io + _CHN_STAT0) & 0x07; if (AiopID == 0x06) return (1); else /* AIOP does not exist */ return (-1); } /*************************************************************************** Function: sReadAiopNumChan Purpose: Read the number of channels available in an AIOP directly from an AIOP. Call: sReadAiopNumChan(io) WordIO_t io: AIOP base I/O address Return: int: The number of channels available Comments: The number of channels is determined by write/reads from identical offsets within the SRAM address spaces for channels 0 and 4. If the channel 4 space is mirrored to channel 0 it is a 4 channel AIOP, otherwise it is an 8 channel. Warnings: No context switches are allowed while executing this function. */ |
f15313bf4 [PATCH] drivers/c... |
2844 |
static int sReadAiopNumChan(WordIO_t io) |
1da177e4c Linux-2.6.12-rc2 |
2845 2846 2847 2848 2849 |
{ Word_t x; static Byte_t R[4] = { 0x00, 0x00, 0x34, 0x12 }; /* write to chan 0 SRAM */ |
457fb6058 drivers/char/rock... |
2850 |
out32((DWordIO_t) io + _INDX_ADDR, R); |
1da177e4c Linux-2.6.12-rc2 |
2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 |
sOutW(io + _INDX_ADDR, 0); /* read from SRAM, chan 0 */ x = sInW(io + _INDX_DATA); sOutW(io + _INDX_ADDR, 0x4000); /* read from SRAM, chan 4 */ if (x != sInW(io + _INDX_DATA)) /* if different must be 8 chan */ return (8); else return (4); } /*************************************************************************** Function: sInitChan Purpose: Initialization of a channel and channel structure Call: sInitChan(CtlP,ChP,AiopNum,ChanNum) CONTROLLER_T *CtlP; Ptr to controller structure CHANNEL_T *ChP; Ptr to channel structure int AiopNum; AIOP number within controller int ChanNum; Channel number within AIOP |
f15313bf4 [PATCH] drivers/c... |
2868 |
Return: int: 1 if initialization succeeded, 0 if it fails because channel |
1da177e4c Linux-2.6.12-rc2 |
2869 2870 2871 2872 2873 2874 |
number exceeds number of channels available in AIOP. Comments: This function must be called before a channel can be used. Warnings: No range checking on any of the parameters is done. No context switches are allowed while executing this function. */ |
f15313bf4 [PATCH] drivers/c... |
2875 2876 |
static int sInitChan(CONTROLLER_T * CtlP, CHANNEL_T * ChP, int AiopNum, int ChanNum) |
1da177e4c Linux-2.6.12-rc2 |
2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 |
{ int i; WordIO_t AiopIO; WordIO_t ChIOOff; Byte_t *ChR; Word_t ChOff; static Byte_t R[4]; int brd9600; if (ChanNum >= CtlP->AiopNumChan[AiopNum]) |
f15313bf4 [PATCH] drivers/c... |
2887 |
return 0; /* exceeds num chans in AIOP */ |
1da177e4c Linux-2.6.12-rc2 |
2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 |
/* Channel, AIOP, and controller identifiers */ ChP->CtlP = CtlP; ChP->ChanID = CtlP->AiopID[AiopNum]; ChP->AiopNum = AiopNum; ChP->ChanNum = ChanNum; /* Global direct addresses */ AiopIO = CtlP->AiopIO[AiopNum]; ChP->Cmd = (ByteIO_t) AiopIO + _CMD_REG; ChP->IntChan = (ByteIO_t) AiopIO + _INT_CHAN; ChP->IntMask = (ByteIO_t) AiopIO + _INT_MASK; ChP->IndexAddr = (DWordIO_t) AiopIO + _INDX_ADDR; ChP->IndexData = AiopIO + _INDX_DATA; /* Channel direct addresses */ ChIOOff = AiopIO + ChP->ChanNum * 2; ChP->TxRxData = ChIOOff + _TD0; ChP->ChanStat = ChIOOff + _CHN_STAT0; ChP->TxRxCount = ChIOOff + _FIFO_CNT0; ChP->IntID = (ByteIO_t) AiopIO + ChP->ChanNum + _INT_ID0; /* Initialize the channel from the RData array */ for (i = 0; i < RDATASIZE; i += 4) { R[0] = RData[i]; R[1] = RData[i + 1] + 0x10 * ChanNum; R[2] = RData[i + 2]; R[3] = RData[i + 3]; |
457fb6058 drivers/char/rock... |
2916 |
out32(ChP->IndexAddr, R); |
1da177e4c Linux-2.6.12-rc2 |
2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 |
} ChR = ChP->R; for (i = 0; i < RREGDATASIZE; i += 4) { ChR[i] = RRegData[i]; ChR[i + 1] = RRegData[i + 1] + 0x10 * ChanNum; ChR[i + 2] = RRegData[i + 2]; ChR[i + 3] = RRegData[i + 3]; } /* Indexed registers */ ChOff = (Word_t) ChanNum *0x1000; if (sClockPrescale == 0x14) brd9600 = 47; else brd9600 = 23; ChP->BaudDiv[0] = (Byte_t) (ChOff + _BAUD); ChP->BaudDiv[1] = (Byte_t) ((ChOff + _BAUD) >> 8); ChP->BaudDiv[2] = (Byte_t) brd9600; ChP->BaudDiv[3] = (Byte_t) (brd9600 >> 8); |
457fb6058 drivers/char/rock... |
2939 |
out32(ChP->IndexAddr, ChP->BaudDiv); |
1da177e4c Linux-2.6.12-rc2 |
2940 2941 2942 2943 2944 |
ChP->TxControl[0] = (Byte_t) (ChOff + _TX_CTRL); ChP->TxControl[1] = (Byte_t) ((ChOff + _TX_CTRL) >> 8); ChP->TxControl[2] = 0; ChP->TxControl[3] = 0; |
457fb6058 drivers/char/rock... |
2945 |
out32(ChP->IndexAddr, ChP->TxControl); |
1da177e4c Linux-2.6.12-rc2 |
2946 2947 2948 2949 2950 |
ChP->RxControl[0] = (Byte_t) (ChOff + _RX_CTRL); ChP->RxControl[1] = (Byte_t) ((ChOff + _RX_CTRL) >> 8); ChP->RxControl[2] = 0; ChP->RxControl[3] = 0; |
457fb6058 drivers/char/rock... |
2951 |
out32(ChP->IndexAddr, ChP->RxControl); |
1da177e4c Linux-2.6.12-rc2 |
2952 2953 2954 2955 2956 |
ChP->TxEnables[0] = (Byte_t) (ChOff + _TX_ENBLS); ChP->TxEnables[1] = (Byte_t) ((ChOff + _TX_ENBLS) >> 8); ChP->TxEnables[2] = 0; ChP->TxEnables[3] = 0; |
457fb6058 drivers/char/rock... |
2957 |
out32(ChP->IndexAddr, ChP->TxEnables); |
1da177e4c Linux-2.6.12-rc2 |
2958 2959 2960 2961 2962 |
ChP->TxCompare[0] = (Byte_t) (ChOff + _TXCMP1); ChP->TxCompare[1] = (Byte_t) ((ChOff + _TXCMP1) >> 8); ChP->TxCompare[2] = 0; ChP->TxCompare[3] = 0; |
457fb6058 drivers/char/rock... |
2963 |
out32(ChP->IndexAddr, ChP->TxCompare); |
1da177e4c Linux-2.6.12-rc2 |
2964 2965 2966 2967 2968 |
ChP->TxReplace1[0] = (Byte_t) (ChOff + _TXREP1B1); ChP->TxReplace1[1] = (Byte_t) ((ChOff + _TXREP1B1) >> 8); ChP->TxReplace1[2] = 0; ChP->TxReplace1[3] = 0; |
457fb6058 drivers/char/rock... |
2969 |
out32(ChP->IndexAddr, ChP->TxReplace1); |
1da177e4c Linux-2.6.12-rc2 |
2970 2971 2972 2973 2974 |
ChP->TxReplace2[0] = (Byte_t) (ChOff + _TXREP2); ChP->TxReplace2[1] = (Byte_t) ((ChOff + _TXREP2) >> 8); ChP->TxReplace2[2] = 0; ChP->TxReplace2[3] = 0; |
457fb6058 drivers/char/rock... |
2975 |
out32(ChP->IndexAddr, ChP->TxReplace2); |
1da177e4c Linux-2.6.12-rc2 |
2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 |
ChP->TxFIFOPtrs = ChOff + _TXF_OUTP; ChP->TxFIFO = ChOff + _TX_FIFO; sOutB(ChP->Cmd, (Byte_t) ChanNum | RESTXFCNT); /* apply reset Tx FIFO count */ sOutB(ChP->Cmd, (Byte_t) ChanNum); /* remove reset Tx FIFO count */ sOutW((WordIO_t) ChP->IndexAddr, ChP->TxFIFOPtrs); /* clear Tx in/out ptrs */ sOutW(ChP->IndexData, 0); ChP->RxFIFOPtrs = ChOff + _RXF_OUTP; ChP->RxFIFO = ChOff + _RX_FIFO; sOutB(ChP->Cmd, (Byte_t) ChanNum | RESRXFCNT); /* apply reset Rx FIFO count */ sOutB(ChP->Cmd, (Byte_t) ChanNum); /* remove reset Rx FIFO count */ sOutW((WordIO_t) ChP->IndexAddr, ChP->RxFIFOPtrs); /* clear Rx out ptr */ sOutW(ChP->IndexData, 0); sOutW((WordIO_t) ChP->IndexAddr, ChP->RxFIFOPtrs + 2); /* clear Rx in ptr */ sOutW(ChP->IndexData, 0); ChP->TxPrioCnt = ChOff + _TXP_CNT; sOutW((WordIO_t) ChP->IndexAddr, ChP->TxPrioCnt); sOutB(ChP->IndexData, 0); ChP->TxPrioPtr = ChOff + _TXP_PNTR; sOutW((WordIO_t) ChP->IndexAddr, ChP->TxPrioPtr); sOutB(ChP->IndexData, 0); ChP->TxPrioBuf = ChOff + _TXP_BUF; sEnRxProcessor(ChP); /* start the Rx processor */ |
f15313bf4 [PATCH] drivers/c... |
3001 |
return 1; |
1da177e4c Linux-2.6.12-rc2 |
3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 |
} /*************************************************************************** Function: sStopRxProcessor Purpose: Stop the receive processor from processing a channel. Call: sStopRxProcessor(ChP) CHANNEL_T *ChP; Ptr to channel structure Comments: The receive processor can be started again with sStartRxProcessor(). This function causes the receive processor to skip over the stopped channel. It does not stop it from processing other channels. Warnings: No context switches are allowed while executing this function. Do not leave the receive processor stopped for more than one character time. After calling this function a delay of 4 uS is required to ensure that the receive processor is no longer processing this channel. */ |
f15313bf4 [PATCH] drivers/c... |
3022 |
static void sStopRxProcessor(CHANNEL_T * ChP) |
1da177e4c Linux-2.6.12-rc2 |
3023 3024 3025 3026 3027 3028 3029 |
{ Byte_t R[4]; R[0] = ChP->R[0]; R[1] = ChP->R[1]; R[2] = 0x0a; R[3] = ChP->R[3]; |
457fb6058 drivers/char/rock... |
3030 |
out32(ChP->IndexAddr, R); |
1da177e4c Linux-2.6.12-rc2 |
3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 |
} /*************************************************************************** Function: sFlushRxFIFO Purpose: Flush the Rx FIFO Call: sFlushRxFIFO(ChP) CHANNEL_T *ChP; Ptr to channel structure Return: void Comments: To prevent data from being enqueued or dequeued in the Tx FIFO while it is being flushed the receive processor is stopped and the transmitter is disabled. After these operations a 4 uS delay is done before clearing the pointers to allow the receive processor to stop. These items are handled inside this function. Warnings: No context switches are allowed while executing this function. */ |
f15313bf4 [PATCH] drivers/c... |
3047 |
static void sFlushRxFIFO(CHANNEL_T * ChP) |
1da177e4c Linux-2.6.12-rc2 |
3048 3049 3050 |
{ int i; Byte_t Ch; /* channel number within AIOP */ |
f15313bf4 [PATCH] drivers/c... |
3051 |
int RxFIFOEnabled; /* 1 if Rx FIFO enabled */ |
1da177e4c Linux-2.6.12-rc2 |
3052 3053 3054 |
if (sGetRxCnt(ChP) == 0) /* Rx FIFO empty */ return; /* don't need to flush */ |
f15313bf4 [PATCH] drivers/c... |
3055 |
RxFIFOEnabled = 0; |
1da177e4c Linux-2.6.12-rc2 |
3056 |
if (ChP->R[0x32] == 0x08) { /* Rx FIFO is enabled */ |
f15313bf4 [PATCH] drivers/c... |
3057 |
RxFIFOEnabled = 1; |
1da177e4c Linux-2.6.12-rc2 |
3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 |
sDisRxFIFO(ChP); /* disable it */ for (i = 0; i < 2000 / 200; i++) /* delay 2 uS to allow proc to disable FIFO */ sInB(ChP->IntChan); /* depends on bus i/o timing */ } sGetChanStatus(ChP); /* clear any pending Rx errors in chan stat */ Ch = (Byte_t) sGetChanNum(ChP); sOutB(ChP->Cmd, Ch | RESRXFCNT); /* apply reset Rx FIFO count */ sOutB(ChP->Cmd, Ch); /* remove reset Rx FIFO count */ sOutW((WordIO_t) ChP->IndexAddr, ChP->RxFIFOPtrs); /* clear Rx out ptr */ sOutW(ChP->IndexData, 0); sOutW((WordIO_t) ChP->IndexAddr, ChP->RxFIFOPtrs + 2); /* clear Rx in ptr */ sOutW(ChP->IndexData, 0); if (RxFIFOEnabled) sEnRxFIFO(ChP); /* enable Rx FIFO */ } /*************************************************************************** Function: sFlushTxFIFO Purpose: Flush the Tx FIFO Call: sFlushTxFIFO(ChP) CHANNEL_T *ChP; Ptr to channel structure Return: void Comments: To prevent data from being enqueued or dequeued in the Tx FIFO while it is being flushed the receive processor is stopped and the transmitter is disabled. After these operations a 4 uS delay is done before clearing the pointers to allow the receive processor to stop. These items are handled inside this function. Warnings: No context switches are allowed while executing this function. */ |
f15313bf4 [PATCH] drivers/c... |
3088 |
static void sFlushTxFIFO(CHANNEL_T * ChP) |
1da177e4c Linux-2.6.12-rc2 |
3089 3090 3091 |
{ int i; Byte_t Ch; /* channel number within AIOP */ |
f15313bf4 [PATCH] drivers/c... |
3092 |
int TxEnabled; /* 1 if transmitter enabled */ |
1da177e4c Linux-2.6.12-rc2 |
3093 3094 3095 |
if (sGetTxCnt(ChP) == 0) /* Tx FIFO empty */ return; /* don't need to flush */ |
f15313bf4 [PATCH] drivers/c... |
3096 |
TxEnabled = 0; |
1da177e4c Linux-2.6.12-rc2 |
3097 |
if (ChP->TxControl[3] & TX_ENABLE) { |
f15313bf4 [PATCH] drivers/c... |
3098 |
TxEnabled = 1; |
1da177e4c Linux-2.6.12-rc2 |
3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 |
sDisTransmit(ChP); /* disable transmitter */ } sStopRxProcessor(ChP); /* stop Rx processor */ for (i = 0; i < 4000 / 200; i++) /* delay 4 uS to allow proc to stop */ sInB(ChP->IntChan); /* depends on bus i/o timing */ Ch = (Byte_t) sGetChanNum(ChP); sOutB(ChP->Cmd, Ch | RESTXFCNT); /* apply reset Tx FIFO count */ sOutB(ChP->Cmd, Ch); /* remove reset Tx FIFO count */ sOutW((WordIO_t) ChP->IndexAddr, ChP->TxFIFOPtrs); /* clear Tx in/out ptrs */ sOutW(ChP->IndexData, 0); if (TxEnabled) sEnTransmit(ChP); /* enable transmitter */ sStartRxProcessor(ChP); /* restart Rx processor */ } /*************************************************************************** Function: sWriteTxPrioByte Purpose: Write a byte of priority transmit data to a channel Call: sWriteTxPrioByte(ChP,Data) CHANNEL_T *ChP; Ptr to channel structure Byte_t Data; The transmit data byte Return: int: 1 if the bytes is successfully written, otherwise 0. Comments: The priority byte is transmitted before any data in the Tx FIFO. Warnings: No context switches are allowed while executing this function. */ |
f15313bf4 [PATCH] drivers/c... |
3127 |
static int sWriteTxPrioByte(CHANNEL_T * ChP, Byte_t Data) |
1da177e4c Linux-2.6.12-rc2 |
3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 |
{ Byte_t DWBuf[4]; /* buffer for double word writes */ Word_t *WordPtr; /* must be far because Win SS != DS */ register DWordIO_t IndexAddr; if (sGetTxCnt(ChP) > 1) { /* write it to Tx priority buffer */ IndexAddr = ChP->IndexAddr; sOutW((WordIO_t) IndexAddr, ChP->TxPrioCnt); /* get priority buffer status */ if (sInB((ByteIO_t) ChP->IndexData) & PRI_PEND) /* priority buffer busy */ return (0); /* nothing sent */ WordPtr = (Word_t *) (&DWBuf[0]); *WordPtr = ChP->TxPrioBuf; /* data byte address */ DWBuf[2] = Data; /* data byte value */ |
457fb6058 drivers/char/rock... |
3143 |
out32(IndexAddr, DWBuf); /* write it out */ |
1da177e4c Linux-2.6.12-rc2 |
3144 3145 3146 3147 3148 |
*WordPtr = ChP->TxPrioCnt; /* Tx priority count address */ DWBuf[2] = PRI_PEND + 1; /* indicate 1 byte pending */ DWBuf[3] = 0; /* priority buffer pointer */ |
457fb6058 drivers/char/rock... |
3149 |
out32(IndexAddr, DWBuf); /* write it out */ |
1da177e4c Linux-2.6.12-rc2 |
3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 |
} else { /* write it to Tx FIFO */ sWriteTxByte(sGetTxRxDataIO(ChP), Data); } return (1); /* 1 byte sent */ } /*************************************************************************** Function: sEnInterrupts Purpose: Enable one or more interrupts for a channel Call: sEnInterrupts(ChP,Flags) CHANNEL_T *ChP; Ptr to channel structure Word_t Flags: Interrupt enable flags, can be any combination of the following flags: TXINT_EN: Interrupt on Tx FIFO empty RXINT_EN: Interrupt on Rx FIFO at trigger level (see sSetRxTrigger()) SRCINT_EN: Interrupt on SRC (Special Rx Condition) MCINT_EN: Interrupt on modem input change CHANINT_EN: Allow channel interrupt signal to the AIOP's Interrupt Channel Register. Return: void Comments: If an interrupt enable flag is set in Flags, that interrupt will be enabled. If an interrupt enable flag is not set in Flags, that interrupt will not be changed. Interrupts can be disabled with function sDisInterrupts(). This function sets the appropriate bit for the channel in the AIOP's Interrupt Mask Register if the CHANINT_EN flag is set. This allows this channel's bit to be set in the AIOP's Interrupt Channel Register. Interrupts must also be globally enabled before channel interrupts will be passed on to the host. This is done with function sEnGlobalInt(). In some cases it may be desirable to disable interrupts globally but enable channel interrupts. This would allow the global interrupt status register to be used to determine which AIOPs need service. */ |
f15313bf4 [PATCH] drivers/c... |
3189 |
static void sEnInterrupts(CHANNEL_T * ChP, Word_t Flags) |
1da177e4c Linux-2.6.12-rc2 |
3190 3191 3192 3193 3194 |
{ Byte_t Mask; /* Interrupt Mask Register */ ChP->RxControl[2] |= ((Byte_t) Flags & (RXINT_EN | SRCINT_EN | MCINT_EN)); |
457fb6058 drivers/char/rock... |
3195 |
out32(ChP->IndexAddr, ChP->RxControl); |
1da177e4c Linux-2.6.12-rc2 |
3196 3197 |
ChP->TxControl[2] |= ((Byte_t) Flags & TXINT_EN); |
457fb6058 drivers/char/rock... |
3198 |
out32(ChP->IndexAddr, ChP->TxControl); |
1da177e4c Linux-2.6.12-rc2 |
3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 |
if (Flags & CHANINT_EN) { Mask = sInB(ChP->IntMask) | sBitMapSetTbl[ChP->ChanNum]; sOutB(ChP->IntMask, Mask); } } /*************************************************************************** Function: sDisInterrupts Purpose: Disable one or more interrupts for a channel Call: sDisInterrupts(ChP,Flags) CHANNEL_T *ChP; Ptr to channel structure Word_t Flags: Interrupt flags, can be any combination of the following flags: TXINT_EN: Interrupt on Tx FIFO empty RXINT_EN: Interrupt on Rx FIFO at trigger level (see sSetRxTrigger()) SRCINT_EN: Interrupt on SRC (Special Rx Condition) MCINT_EN: Interrupt on modem input change CHANINT_EN: Disable channel interrupt signal to the AIOP's Interrupt Channel Register. Return: void Comments: If an interrupt flag is set in Flags, that interrupt will be disabled. If an interrupt flag is not set in Flags, that interrupt will not be changed. Interrupts can be enabled with function sEnInterrupts(). This function clears the appropriate bit for the channel in the AIOP's Interrupt Mask Register if the CHANINT_EN flag is set. This blocks this channel's bit from being set in the AIOP's Interrupt Channel Register. */ |
f15313bf4 [PATCH] drivers/c... |
3231 |
static void sDisInterrupts(CHANNEL_T * ChP, Word_t Flags) |
1da177e4c Linux-2.6.12-rc2 |
3232 3233 3234 3235 3236 |
{ Byte_t Mask; /* Interrupt Mask Register */ ChP->RxControl[2] &= ~((Byte_t) Flags & (RXINT_EN | SRCINT_EN | MCINT_EN)); |
457fb6058 drivers/char/rock... |
3237 |
out32(ChP->IndexAddr, ChP->RxControl); |
1da177e4c Linux-2.6.12-rc2 |
3238 |
ChP->TxControl[2] &= ~((Byte_t) Flags & TXINT_EN); |
457fb6058 drivers/char/rock... |
3239 |
out32(ChP->IndexAddr, ChP->TxControl); |
1da177e4c Linux-2.6.12-rc2 |
3240 3241 3242 3243 3244 3245 |
if (Flags & CHANINT_EN) { Mask = sInB(ChP->IntMask) & sBitMapClrTbl[ChP->ChanNum]; sOutB(ChP->IntMask, Mask); } } |
f15313bf4 [PATCH] drivers/c... |
3246 |
static void sSetInterfaceMode(CHANNEL_T * ChP, Byte_t mode) |
1da177e4c Linux-2.6.12-rc2 |
3247 3248 3249 3250 3251 3252 3253 3254 |
{ sOutB(ChP->CtlP->AiopIO[2], (mode & 0x18) | ChP->ChanNum); } /* * Not an official SSCI function, but how to reset RocketModems. * ISA bus version */ |
f15313bf4 [PATCH] drivers/c... |
3255 |
static void sModemReset(CONTROLLER_T * CtlP, int chan, int on) |
1da177e4c Linux-2.6.12-rc2 |
3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 |
{ ByteIO_t addr; Byte_t val; addr = CtlP->AiopIO[0] + 0x400; val = sInB(CtlP->MReg3IO); /* if AIOP[1] is not enabled, enable it */ if ((val & 2) == 0) { val = sInB(CtlP->MReg2IO); sOutB(CtlP->MReg2IO, (val & 0xfc) | (1 & 0x03)); sOutB(CtlP->MBaseIO, (unsigned char) (addr >> 6)); } sEnAiop(CtlP, 1); if (!on) addr += 8; sOutB(addr + chan, 0); /* apply or remove reset */ sDisAiop(CtlP, 1); } /* * Not an official SSCI function, but how to reset RocketModems. * PCI bus version */ |
f15313bf4 [PATCH] drivers/c... |
3280 |
static void sPCIModemReset(CONTROLLER_T * CtlP, int chan, int on) |
1da177e4c Linux-2.6.12-rc2 |
3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 |
{ ByteIO_t addr; addr = CtlP->AiopIO[0] + 0x40; /* 2nd AIOP */ if (!on) addr += 8; sOutB(addr + chan, 0); /* apply or remove reset */ } /* Resets the speaker controller on RocketModem II and III devices */ static void rmSpeakerReset(CONTROLLER_T * CtlP, unsigned long model) { ByteIO_t addr; /* RocketModem II speaker control is at the 8th port location of offset 0x40 */ if ((model == MODEL_RP4M) || (model == MODEL_RP6M)) { addr = CtlP->AiopIO[0] + 0x4F; sOutB(addr, 0); } /* RocketModem III speaker control is at the 1st port location of offset 0x80 */ if ((model == MODEL_UPCI_RM3_8PORT) || (model == MODEL_UPCI_RM3_4PORT)) { addr = CtlP->AiopIO[0] + 0x88; sOutB(addr, 0); } } /* Returns the line number given the controller (board), aiop and channel number */ static unsigned char GetLineNumber(int ctrl, int aiop, int ch) { return lineNumbers[(ctrl << 5) | (aiop << 3) | ch]; } /* * Stores the line number associated with a given controller (board), aiop * and channel number. * Returns: The line number assigned */ static unsigned char SetLineNumber(int ctrl, int aiop, int ch) { lineNumbers[(ctrl << 5) | (aiop << 3) | ch] = nextLineNumber++; return (nextLineNumber - 1); } |