Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | |
| 3 | |
| 4 | Copyright (C) 1996 Digi International. |
| 5 | |
| 6 | For technical support please email digiLinux@dgii.com or |
| 7 | call Digi tech support at (612) 912-3456 |
| 8 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 9 | ** This driver is no longer supported by Digi ** |
| 10 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | Much of this design and code came from epca.c which was |
| 12 | copyright (C) 1994, 1995 Troy De Jongh, and subsquently |
| 13 | modified by David Nugent, Christoph Lameter, Mike McLagan. |
| 14 | |
| 15 | This program is free software; you can redistribute it and/or modify |
| 16 | it under the terms of the GNU General Public License as published by |
| 17 | the Free Software Foundation; either version 2 of the License, or |
| 18 | (at your option) any later version. |
| 19 | |
| 20 | This program is distributed in the hope that it will be useful, |
| 21 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 | GNU General Public License for more details. |
| 24 | |
| 25 | You should have received a copy of the GNU General Public License |
| 26 | along with this program; if not, write to the Free Software |
| 27 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 28 | |
| 29 | --------------------------------------------------------------------------- */ |
| 30 | /* See README.epca for change history --DAT*/ |
| 31 | |
| 32 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | #include <linux/module.h> |
| 34 | #include <linux/kernel.h> |
| 35 | #include <linux/types.h> |
| 36 | #include <linux/init.h> |
| 37 | #include <linux/serial.h> |
| 38 | #include <linux/delay.h> |
| 39 | #include <linux/ctype.h> |
| 40 | #include <linux/tty.h> |
| 41 | #include <linux/tty_flip.h> |
| 42 | #include <linux/slab.h> |
| 43 | #include <linux/ioport.h> |
| 44 | #include <linux/interrupt.h> |
| 45 | #include <asm/uaccess.h> |
| 46 | #include <asm/io.h> |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 47 | #include <linux/spinlock.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | #include <linux/pci.h> |
| 49 | #include "digiPCI.h" |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 50 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
| 52 | #include "digi1.h" |
| 53 | #include "digiFep1.h" |
| 54 | #include "epca.h" |
| 55 | #include "epcaconfig.h" |
| 56 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | /* ---------------------- Begin defines ------------------------ */ |
| 58 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 59 | #define VERSION "1.3.0.1-LK2.6" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | |
| 61 | /* This major needs to be submitted to Linux to join the majors list */ |
| 62 | |
| 63 | #define DIGIINFOMAJOR 35 /* For Digi specific ioctl */ |
| 64 | |
| 65 | |
| 66 | #define MAXCARDS 7 |
| 67 | #define epcaassert(x, msg) if (!(x)) epca_error(__LINE__, msg) |
| 68 | |
| 69 | #define PFX "epca: " |
| 70 | |
| 71 | /* ----------------- Begin global definitions ------------------- */ |
| 72 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | static int nbdevs, num_cards, liloconfig; |
| 74 | static int digi_poller_inhibited = 1 ; |
| 75 | |
| 76 | static int setup_error_code; |
| 77 | static int invalid_lilo_config; |
| 78 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 79 | /* The ISA boards do window flipping into the same spaces so its only sane |
| 80 | with a single lock. It's still pretty efficient */ |
| 81 | |
Ingo Molnar | 34af946 | 2006-06-27 02:53:55 -0700 | [diff] [blame] | 82 | static DEFINE_SPINLOCK(epca_lock); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 83 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | /* ----------------------------------------------------------------------- |
| 85 | MAXBOARDS is typically 12, but ISA and EISA cards are restricted to |
| 86 | 7 below. |
| 87 | --------------------------------------------------------------------------*/ |
| 88 | static struct board_info boards[MAXBOARDS]; |
| 89 | |
| 90 | |
| 91 | /* ------------- Begin structures used for driver registeration ---------- */ |
| 92 | |
| 93 | static struct tty_driver *pc_driver; |
| 94 | static struct tty_driver *pc_info; |
| 95 | |
| 96 | /* ------------------ Begin Digi specific structures -------------------- */ |
| 97 | |
| 98 | /* ------------------------------------------------------------------------ |
| 99 | digi_channels represents an array of structures that keep track of |
| 100 | each channel of the Digi product. Information such as transmit and |
| 101 | receive pointers, termio data, and signal definitions (DTR, CTS, etc ...) |
| 102 | are stored here. This structure is NOT used to overlay the cards |
| 103 | physical channel structure. |
| 104 | -------------------------------------------------------------------------- */ |
| 105 | |
| 106 | static struct channel digi_channels[MAX_ALLOC]; |
| 107 | |
| 108 | /* ------------------------------------------------------------------------ |
| 109 | card_ptr is an array used to hold the address of the |
| 110 | first channel structure of each card. This array will hold |
| 111 | the addresses of various channels located in digi_channels. |
| 112 | -------------------------------------------------------------------------- */ |
| 113 | static struct channel *card_ptr[MAXCARDS]; |
| 114 | |
| 115 | static struct timer_list epca_timer; |
| 116 | |
| 117 | /* ---------------------- Begin function prototypes --------------------- */ |
| 118 | |
| 119 | /* ---------------------------------------------------------------------- |
| 120 | Begin generic memory functions. These functions will be alias |
| 121 | (point at) more specific functions dependent on the board being |
| 122 | configured. |
| 123 | ----------------------------------------------------------------------- */ |
| 124 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 125 | static void memwinon(struct board_info *b, unsigned int win); |
| 126 | static void memwinoff(struct board_info *b, unsigned int win); |
| 127 | static void globalwinon(struct channel *ch); |
| 128 | static void rxwinon(struct channel *ch); |
| 129 | static void txwinon(struct channel *ch); |
| 130 | static void memoff(struct channel *ch); |
| 131 | static void assertgwinon(struct channel *ch); |
| 132 | static void assertmemoff(struct channel *ch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | |
| 134 | /* ---- Begin more 'specific' memory functions for cx_like products --- */ |
| 135 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 136 | static void pcxem_memwinon(struct board_info *b, unsigned int win); |
| 137 | static void pcxem_memwinoff(struct board_info *b, unsigned int win); |
| 138 | static void pcxem_globalwinon(struct channel *ch); |
| 139 | static void pcxem_rxwinon(struct channel *ch); |
| 140 | static void pcxem_txwinon(struct channel *ch); |
| 141 | static void pcxem_memoff(struct channel *ch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | |
| 143 | /* ------ Begin more 'specific' memory functions for the pcxe ------- */ |
| 144 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 145 | static void pcxe_memwinon(struct board_info *b, unsigned int win); |
| 146 | static void pcxe_memwinoff(struct board_info *b, unsigned int win); |
| 147 | static void pcxe_globalwinon(struct channel *ch); |
| 148 | static void pcxe_rxwinon(struct channel *ch); |
| 149 | static void pcxe_txwinon(struct channel *ch); |
| 150 | static void pcxe_memoff(struct channel *ch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | |
| 152 | /* ---- Begin more 'specific' memory functions for the pc64xe and pcxi ---- */ |
| 153 | /* Note : pc64xe and pcxi share the same windowing routines */ |
| 154 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 155 | static void pcxi_memwinon(struct board_info *b, unsigned int win); |
| 156 | static void pcxi_memwinoff(struct board_info *b, unsigned int win); |
| 157 | static void pcxi_globalwinon(struct channel *ch); |
| 158 | static void pcxi_rxwinon(struct channel *ch); |
| 159 | static void pcxi_txwinon(struct channel *ch); |
| 160 | static void pcxi_memoff(struct channel *ch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | |
| 162 | /* - Begin 'specific' do nothing memory functions needed for some cards - */ |
| 163 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 164 | static void dummy_memwinon(struct board_info *b, unsigned int win); |
| 165 | static void dummy_memwinoff(struct board_info *b, unsigned int win); |
| 166 | static void dummy_globalwinon(struct channel *ch); |
| 167 | static void dummy_rxwinon(struct channel *ch); |
| 168 | static void dummy_txwinon(struct channel *ch); |
| 169 | static void dummy_memoff(struct channel *ch); |
| 170 | static void dummy_assertgwinon(struct channel *ch); |
| 171 | static void dummy_assertmemoff(struct channel *ch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | |
| 173 | /* ------------------- Begin declare functions ----------------------- */ |
| 174 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 175 | static struct channel *verifyChannel(struct tty_struct *); |
| 176 | static void pc_sched_event(struct channel *, int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | static void epca_error(int, char *); |
| 178 | static void pc_close(struct tty_struct *, struct file *); |
| 179 | static void shutdown(struct channel *); |
| 180 | static void pc_hangup(struct tty_struct *); |
| 181 | static void pc_put_char(struct tty_struct *, unsigned char); |
| 182 | static int pc_write_room(struct tty_struct *); |
| 183 | static int pc_chars_in_buffer(struct tty_struct *); |
| 184 | static void pc_flush_buffer(struct tty_struct *); |
| 185 | static void pc_flush_chars(struct tty_struct *); |
| 186 | static int block_til_ready(struct tty_struct *, struct file *, |
| 187 | struct channel *); |
| 188 | static int pc_open(struct tty_struct *, struct file *); |
| 189 | static void post_fep_init(unsigned int crd); |
| 190 | static void epcapoll(unsigned long); |
| 191 | static void doevent(int); |
| 192 | static void fepcmd(struct channel *, int, int, int, int, int); |
| 193 | static unsigned termios2digi_h(struct channel *ch, unsigned); |
| 194 | static unsigned termios2digi_i(struct channel *ch, unsigned); |
| 195 | static unsigned termios2digi_c(struct channel *ch, unsigned); |
| 196 | static void epcaparam(struct tty_struct *, struct channel *); |
| 197 | static void receive_data(struct channel *); |
| 198 | static int pc_ioctl(struct tty_struct *, struct file *, |
| 199 | unsigned int, unsigned long); |
| 200 | static int info_ioctl(struct tty_struct *, struct file *, |
| 201 | unsigned int, unsigned long); |
| 202 | static void pc_set_termios(struct tty_struct *, struct termios *); |
| 203 | static void do_softint(void *); |
| 204 | static void pc_stop(struct tty_struct *); |
| 205 | static void pc_start(struct tty_struct *); |
| 206 | static void pc_throttle(struct tty_struct * tty); |
| 207 | static void pc_unthrottle(struct tty_struct *tty); |
| 208 | static void digi_send_break(struct channel *ch, int msec); |
| 209 | static void setup_empty_event(struct tty_struct *tty, struct channel *ch); |
| 210 | void epca_setup(char *, int *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | |
| 212 | static int get_termio(struct tty_struct *, struct termio __user *); |
| 213 | static int pc_write(struct tty_struct *, const unsigned char *, int); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 214 | static int pc_init(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | static int init_PCI(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | |
| 217 | |
| 218 | /* ------------------------------------------------------------------ |
| 219 | Table of functions for each board to handle memory. Mantaining |
| 220 | parallelism is a *very* good idea here. The idea is for the |
| 221 | runtime code to blindly call these functions, not knowing/caring |
| 222 | about the underlying hardware. This stuff should contain no |
| 223 | conditionals; if more functionality is needed a different entry |
| 224 | should be established. These calls are the interface calls and |
| 225 | are the only functions that should be accessed. Anyone caught |
| 226 | making direct calls deserves what they get. |
| 227 | -------------------------------------------------------------------- */ |
| 228 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 229 | static void memwinon(struct board_info *b, unsigned int win) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | { |
| 231 | (b->memwinon)(b, win); |
| 232 | } |
| 233 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 234 | static void memwinoff(struct board_info *b, unsigned int win) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | { |
| 236 | (b->memwinoff)(b, win); |
| 237 | } |
| 238 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 239 | static void globalwinon(struct channel *ch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | { |
| 241 | (ch->board->globalwinon)(ch); |
| 242 | } |
| 243 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 244 | static void rxwinon(struct channel *ch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | { |
| 246 | (ch->board->rxwinon)(ch); |
| 247 | } |
| 248 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 249 | static void txwinon(struct channel *ch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | { |
| 251 | (ch->board->txwinon)(ch); |
| 252 | } |
| 253 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 254 | static void memoff(struct channel *ch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | { |
| 256 | (ch->board->memoff)(ch); |
| 257 | } |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 258 | static void assertgwinon(struct channel *ch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | { |
| 260 | (ch->board->assertgwinon)(ch); |
| 261 | } |
| 262 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 263 | static void assertmemoff(struct channel *ch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | { |
| 265 | (ch->board->assertmemoff)(ch); |
| 266 | } |
| 267 | |
| 268 | /* --------------------------------------------------------- |
| 269 | PCXEM windowing is the same as that used in the PCXR |
| 270 | and CX series cards. |
| 271 | ------------------------------------------------------------ */ |
| 272 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 273 | static void pcxem_memwinon(struct board_info *b, unsigned int win) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | { |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 275 | outb_p(FEPWIN|win, b->port + 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | } |
| 277 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 278 | static void pcxem_memwinoff(struct board_info *b, unsigned int win) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | { |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 280 | outb_p(0, b->port + 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | } |
| 282 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 283 | static void pcxem_globalwinon(struct channel *ch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | { |
| 285 | outb_p( FEPWIN, (int)ch->board->port + 1); |
| 286 | } |
| 287 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 288 | static void pcxem_rxwinon(struct channel *ch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | { |
| 290 | outb_p(ch->rxwin, (int)ch->board->port + 1); |
| 291 | } |
| 292 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 293 | static void pcxem_txwinon(struct channel *ch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | { |
| 295 | outb_p(ch->txwin, (int)ch->board->port + 1); |
| 296 | } |
| 297 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 298 | static void pcxem_memoff(struct channel *ch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | { |
| 300 | outb_p(0, (int)ch->board->port + 1); |
| 301 | } |
| 302 | |
| 303 | /* ----------------- Begin pcxe memory window stuff ------------------ */ |
| 304 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 305 | static void pcxe_memwinon(struct board_info *b, unsigned int win) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | { |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 307 | outb_p(FEPWIN | win, b->port + 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | } |
| 309 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 310 | static void pcxe_memwinoff(struct board_info *b, unsigned int win) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | { |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 312 | outb_p(inb(b->port) & ~FEPMEM, |
| 313 | b->port + 1); |
| 314 | outb_p(0, b->port + 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | } |
| 316 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 317 | static void pcxe_globalwinon(struct channel *ch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | { |
| 319 | outb_p( FEPWIN, (int)ch->board->port + 1); |
| 320 | } |
| 321 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 322 | static void pcxe_rxwinon(struct channel *ch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | { |
| 324 | outb_p(ch->rxwin, (int)ch->board->port + 1); |
| 325 | } |
| 326 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 327 | static void pcxe_txwinon(struct channel *ch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | { |
| 329 | outb_p(ch->txwin, (int)ch->board->port + 1); |
| 330 | } |
| 331 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 332 | static void pcxe_memoff(struct channel *ch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | { |
| 334 | outb_p(0, (int)ch->board->port); |
| 335 | outb_p(0, (int)ch->board->port + 1); |
| 336 | } |
| 337 | |
| 338 | /* ------------- Begin pc64xe and pcxi memory window stuff -------------- */ |
| 339 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 340 | static void pcxi_memwinon(struct board_info *b, unsigned int win) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | { |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 342 | outb_p(inb(b->port) | FEPMEM, b->port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | } |
| 344 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 345 | static void pcxi_memwinoff(struct board_info *b, unsigned int win) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | { |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 347 | outb_p(inb(b->port) & ~FEPMEM, b->port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | } |
| 349 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 350 | static void pcxi_globalwinon(struct channel *ch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | { |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 352 | outb_p(FEPMEM, ch->board->port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | } |
| 354 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 355 | static void pcxi_rxwinon(struct channel *ch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | { |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 357 | outb_p(FEPMEM, ch->board->port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | } |
| 359 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 360 | static void pcxi_txwinon(struct channel *ch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | { |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 362 | outb_p(FEPMEM, ch->board->port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | } |
| 364 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 365 | static void pcxi_memoff(struct channel *ch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | { |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 367 | outb_p(0, ch->board->port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | } |
| 369 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 370 | static void pcxi_assertgwinon(struct channel *ch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | { |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 372 | epcaassert(inb(ch->board->port) & FEPMEM, "Global memory off"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | } |
| 374 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 375 | static void pcxi_assertmemoff(struct channel *ch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | { |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 377 | epcaassert(!(inb(ch->board->port) & FEPMEM), "Memory on"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | } |
| 379 | |
| 380 | |
| 381 | /* ---------------------------------------------------------------------- |
| 382 | Not all of the cards need specific memory windowing routines. Some |
| 383 | cards (Such as PCI) needs no windowing routines at all. We provide |
| 384 | these do nothing routines so that the same code base can be used. |
| 385 | The driver will ALWAYS call a windowing routine if it thinks it needs |
| 386 | to; regardless of the card. However, dependent on the card the routine |
| 387 | may or may not do anything. |
| 388 | ---------------------------------------------------------------------------*/ |
| 389 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 390 | static void dummy_memwinon(struct board_info *b, unsigned int win) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | { |
| 392 | } |
| 393 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 394 | static void dummy_memwinoff(struct board_info *b, unsigned int win) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | { |
| 396 | } |
| 397 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 398 | static void dummy_globalwinon(struct channel *ch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | { |
| 400 | } |
| 401 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 402 | static void dummy_rxwinon(struct channel *ch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | { |
| 404 | } |
| 405 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 406 | static void dummy_txwinon(struct channel *ch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | { |
| 408 | } |
| 409 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 410 | static void dummy_memoff(struct channel *ch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 | { |
| 412 | } |
| 413 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 414 | static void dummy_assertgwinon(struct channel *ch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | { |
| 416 | } |
| 417 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 418 | static void dummy_assertmemoff(struct channel *ch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 419 | { |
| 420 | } |
| 421 | |
| 422 | /* ----------------- Begin verifyChannel function ----------------------- */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 423 | static struct channel *verifyChannel(struct tty_struct *tty) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | { /* Begin verifyChannel */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | /* -------------------------------------------------------------------- |
| 426 | This routine basically provides a sanity check. It insures that |
| 427 | the channel returned is within the proper range of addresses as |
| 428 | well as properly initialized. If some bogus info gets passed in |
| 429 | through tty->driver_data this should catch it. |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 430 | --------------------------------------------------------------------- */ |
| 431 | if (tty) { |
| 432 | struct channel *ch = (struct channel *)tty->driver_data; |
| 433 | if ((ch >= &digi_channels[0]) && (ch < &digi_channels[nbdevs])) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 | if (ch->magic == EPCA_MAGIC) |
| 435 | return ch; |
| 436 | } |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 437 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | return NULL; |
| 439 | |
| 440 | } /* End verifyChannel */ |
| 441 | |
| 442 | /* ------------------ Begin pc_sched_event ------------------------- */ |
| 443 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 444 | static void pc_sched_event(struct channel *ch, int event) |
| 445 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | /* ---------------------------------------------------------------------- |
| 447 | We call this to schedule interrupt processing on some event. The |
| 448 | kernel sees our request and calls the related routine in OUR driver. |
| 449 | -------------------------------------------------------------------------*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | ch->event |= 1 << event; |
| 451 | schedule_work(&ch->tqueue); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | } /* End pc_sched_event */ |
| 453 | |
| 454 | /* ------------------ Begin epca_error ------------------------- */ |
| 455 | |
| 456 | static void epca_error(int line, char *msg) |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 457 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | printk(KERN_ERR "epca_error (Digi): line = %d %s\n",line,msg); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 459 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 460 | |
| 461 | /* ------------------ Begin pc_close ------------------------- */ |
| 462 | static void pc_close(struct tty_struct * tty, struct file * filp) |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 463 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | struct channel *ch; |
| 465 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | /* --------------------------------------------------------- |
| 467 | verifyChannel returns the channel from the tty struct |
| 468 | if it is valid. This serves as a sanity check. |
| 469 | ------------------------------------------------------------- */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 470 | if ((ch = verifyChannel(tty)) != NULL) { /* Begin if ch != NULL */ |
| 471 | spin_lock_irqsave(&epca_lock, flags); |
| 472 | if (tty_hung_up_p(filp)) { |
| 473 | spin_unlock_irqrestore(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | return; |
| 475 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 476 | /* Check to see if the channel is open more than once */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 477 | if (ch->count-- > 1) { |
| 478 | /* Begin channel is open more than once */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | /* ------------------------------------------------------------- |
| 480 | Return without doing anything. Someone might still be using |
| 481 | the channel. |
| 482 | ---------------------------------------------------------------- */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 483 | spin_unlock_irqrestore(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 484 | return; |
| 485 | } /* End channel is open more than once */ |
| 486 | |
| 487 | /* Port open only once go ahead with shutdown & reset */ |
Eric Sesterhenn | 56ee482 | 2006-03-26 18:17:21 +0200 | [diff] [blame] | 488 | BUG_ON(ch->count < 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | |
| 490 | /* --------------------------------------------------------------- |
| 491 | Let the rest of the driver know the channel is being closed. |
| 492 | This becomes important if an open is attempted before close |
| 493 | is finished. |
| 494 | ------------------------------------------------------------------ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 495 | ch->asyncflags |= ASYNC_CLOSING; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | tty->closing = 1; |
| 497 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 498 | spin_unlock_irqrestore(&epca_lock, flags); |
| 499 | |
| 500 | if (ch->asyncflags & ASYNC_INITIALIZED) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | /* Setup an event to indicate when the transmit buffer empties */ |
| 502 | setup_empty_event(tty, ch); |
| 503 | tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */ |
| 504 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | if (tty->driver->flush_buffer) |
| 506 | tty->driver->flush_buffer(tty); |
| 507 | |
| 508 | tty_ldisc_flush(tty); |
| 509 | shutdown(ch); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 510 | |
| 511 | spin_lock_irqsave(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | tty->closing = 0; |
| 513 | ch->event = 0; |
| 514 | ch->tty = NULL; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 515 | spin_unlock_irqrestore(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 516 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 517 | if (ch->blocked_open) { /* Begin if blocked_open */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 518 | if (ch->close_delay) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 519 | msleep_interruptible(jiffies_to_msecs(ch->close_delay)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 520 | wake_up_interruptible(&ch->open_wait); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | } /* End if blocked_open */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED | |
| 523 | ASYNC_CLOSING); |
| 524 | wake_up_interruptible(&ch->close_wait); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | } /* End if ch != NULL */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | } /* End pc_close */ |
| 527 | |
| 528 | /* ------------------ Begin shutdown ------------------------- */ |
| 529 | |
| 530 | static void shutdown(struct channel *ch) |
| 531 | { /* Begin shutdown */ |
| 532 | |
| 533 | unsigned long flags; |
| 534 | struct tty_struct *tty; |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 535 | struct board_chan __iomem *bc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | |
| 537 | if (!(ch->asyncflags & ASYNC_INITIALIZED)) |
| 538 | return; |
| 539 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 540 | spin_lock_irqsave(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 541 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 542 | globalwinon(ch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | bc = ch->brdchan; |
| 544 | |
| 545 | /* ------------------------------------------------------------------ |
| 546 | In order for an event to be generated on the receipt of data the |
| 547 | idata flag must be set. Since we are shutting down, this is not |
| 548 | necessary clear this flag. |
| 549 | --------------------------------------------------------------------- */ |
| 550 | |
| 551 | if (bc) |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 552 | writeb(0, &bc->idata); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | tty = ch->tty; |
| 554 | |
| 555 | /* ---------------------------------------------------------------- |
| 556 | If we're a modem control device and HUPCL is on, drop RTS & DTR. |
| 557 | ------------------------------------------------------------------ */ |
| 558 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 559 | if (tty->termios->c_cflag & HUPCL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | ch->omodem &= ~(ch->m_rts | ch->m_dtr); |
| 561 | fepcmd(ch, SETMODEM, 0, ch->m_dtr | ch->m_rts, 10, 1); |
| 562 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | memoff(ch); |
| 564 | |
| 565 | /* ------------------------------------------------------------------ |
| 566 | The channel has officialy been closed. The next time it is opened |
| 567 | it will have to reinitialized. Set a flag to indicate this. |
| 568 | ---------------------------------------------------------------------- */ |
| 569 | |
| 570 | /* Prevent future Digi programmed interrupts from coming active */ |
| 571 | |
| 572 | ch->asyncflags &= ~ASYNC_INITIALIZED; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 573 | spin_unlock_irqrestore(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 574 | |
| 575 | } /* End shutdown */ |
| 576 | |
| 577 | /* ------------------ Begin pc_hangup ------------------------- */ |
| 578 | |
| 579 | static void pc_hangup(struct tty_struct *tty) |
| 580 | { /* Begin pc_hangup */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | struct channel *ch; |
| 582 | |
| 583 | /* --------------------------------------------------------- |
| 584 | verifyChannel returns the channel from the tty struct |
| 585 | if it is valid. This serves as a sanity check. |
| 586 | ------------------------------------------------------------- */ |
| 587 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 588 | if ((ch = verifyChannel(tty)) != NULL) { /* Begin if ch != NULL */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | unsigned long flags; |
| 590 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 591 | if (tty->driver->flush_buffer) |
| 592 | tty->driver->flush_buffer(tty); |
| 593 | tty_ldisc_flush(tty); |
| 594 | shutdown(ch); |
| 595 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 596 | spin_lock_irqsave(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | ch->tty = NULL; |
| 598 | ch->event = 0; |
| 599 | ch->count = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 601 | spin_unlock_irqrestore(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | wake_up_interruptible(&ch->open_wait); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | } /* End if ch != NULL */ |
| 604 | |
| 605 | } /* End pc_hangup */ |
| 606 | |
| 607 | /* ------------------ Begin pc_write ------------------------- */ |
| 608 | |
| 609 | static int pc_write(struct tty_struct * tty, |
| 610 | const unsigned char *buf, int bytesAvailable) |
| 611 | { /* Begin pc_write */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 612 | unsigned int head, tail; |
| 613 | int dataLen; |
| 614 | int size; |
| 615 | int amountCopied; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | struct channel *ch; |
| 617 | unsigned long flags; |
| 618 | int remain; |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 619 | struct board_chan __iomem *bc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 | |
| 621 | /* ---------------------------------------------------------------- |
| 622 | pc_write is primarily called directly by the kernel routine |
| 623 | tty_write (Though it can also be called by put_char) found in |
| 624 | tty_io.c. pc_write is passed a line discipline buffer where |
| 625 | the data to be written out is stored. The line discipline |
| 626 | implementation itself is done at the kernel level and is not |
| 627 | brought into the driver. |
| 628 | ------------------------------------------------------------------- */ |
| 629 | |
| 630 | /* --------------------------------------------------------- |
| 631 | verifyChannel returns the channel from the tty struct |
| 632 | if it is valid. This serves as a sanity check. |
| 633 | ------------------------------------------------------------- */ |
| 634 | |
| 635 | if ((ch = verifyChannel(tty)) == NULL) |
| 636 | return 0; |
| 637 | |
| 638 | /* Make a pointer to the channel data structure found on the board. */ |
| 639 | |
| 640 | bc = ch->brdchan; |
| 641 | size = ch->txbufsize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 642 | amountCopied = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 643 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 644 | spin_lock_irqsave(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | globalwinon(ch); |
| 646 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 647 | head = readw(&bc->tin) & (size - 1); |
| 648 | tail = readw(&bc->tout); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 650 | if (tail != readw(&bc->tout)) |
| 651 | tail = readw(&bc->tout); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 652 | tail &= (size - 1); |
| 653 | |
| 654 | /* If head >= tail, head has not wrapped around. */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 655 | if (head >= tail) { /* Begin head has not wrapped */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 656 | /* --------------------------------------------------------------- |
| 657 | remain (much like dataLen above) represents the total amount of |
| 658 | space available on the card for data. Here dataLen represents |
| 659 | the space existing between the head pointer and the end of |
| 660 | buffer. This is important because a memcpy cannot be told to |
| 661 | automatically wrap around when it hits the buffer end. |
| 662 | ------------------------------------------------------------------ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | dataLen = size - head; |
| 664 | remain = size - (head - tail) - 1; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 665 | } else { /* Begin head has wrapped around */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 666 | |
| 667 | remain = tail - head - 1; |
| 668 | dataLen = remain; |
| 669 | |
| 670 | } /* End head has wrapped around */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 671 | /* ------------------------------------------------------------------- |
| 672 | Check the space on the card. If we have more data than |
| 673 | space; reduce the amount of data to fit the space. |
| 674 | ---------------------------------------------------------------------- */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | bytesAvailable = min(remain, bytesAvailable); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 676 | txwinon(ch); |
| 677 | while (bytesAvailable > 0) |
| 678 | { /* Begin while there is data to copy onto card */ |
| 679 | |
| 680 | /* ----------------------------------------------------------------- |
| 681 | If head is not wrapped, the below will make sure the first |
| 682 | data copy fills to the end of card buffer. |
| 683 | ------------------------------------------------------------------- */ |
| 684 | |
| 685 | dataLen = min(bytesAvailable, dataLen); |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 686 | memcpy_toio(ch->txptr + head, buf, dataLen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 687 | buf += dataLen; |
| 688 | head += dataLen; |
| 689 | amountCopied += dataLen; |
| 690 | bytesAvailable -= dataLen; |
| 691 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 692 | if (head >= size) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | head = 0; |
| 694 | dataLen = tail; |
| 695 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 696 | } /* End while there is data to copy onto card */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 697 | ch->statusflags |= TXBUSY; |
| 698 | globalwinon(ch); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 699 | writew(head, &bc->tin); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 700 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 701 | if ((ch->statusflags & LOWWAIT) == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 702 | ch->statusflags |= LOWWAIT; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 703 | writeb(1, &bc->ilow); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 704 | } |
| 705 | memoff(ch); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 706 | spin_unlock_irqrestore(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | return(amountCopied); |
| 708 | |
| 709 | } /* End pc_write */ |
| 710 | |
| 711 | /* ------------------ Begin pc_put_char ------------------------- */ |
| 712 | |
| 713 | static void pc_put_char(struct tty_struct *tty, unsigned char c) |
| 714 | { /* Begin pc_put_char */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 715 | pc_write(tty, &c, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 716 | } /* End pc_put_char */ |
| 717 | |
| 718 | /* ------------------ Begin pc_write_room ------------------------- */ |
| 719 | |
| 720 | static int pc_write_room(struct tty_struct *tty) |
| 721 | { /* Begin pc_write_room */ |
| 722 | |
| 723 | int remain; |
| 724 | struct channel *ch; |
| 725 | unsigned long flags; |
| 726 | unsigned int head, tail; |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 727 | struct board_chan __iomem *bc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 728 | |
| 729 | remain = 0; |
| 730 | |
| 731 | /* --------------------------------------------------------- |
| 732 | verifyChannel returns the channel from the tty struct |
| 733 | if it is valid. This serves as a sanity check. |
| 734 | ------------------------------------------------------------- */ |
| 735 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 736 | if ((ch = verifyChannel(tty)) != NULL) { |
| 737 | spin_lock_irqsave(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 738 | globalwinon(ch); |
| 739 | |
| 740 | bc = ch->brdchan; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 741 | head = readw(&bc->tin) & (ch->txbufsize - 1); |
| 742 | tail = readw(&bc->tout); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 743 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 744 | if (tail != readw(&bc->tout)) |
| 745 | tail = readw(&bc->tout); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 746 | /* Wrap tail if necessary */ |
| 747 | tail &= (ch->txbufsize - 1); |
| 748 | |
| 749 | if ((remain = tail - head - 1) < 0 ) |
| 750 | remain += ch->txbufsize; |
| 751 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 752 | if (remain && (ch->statusflags & LOWWAIT) == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 753 | ch->statusflags |= LOWWAIT; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 754 | writeb(1, &bc->ilow); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 755 | } |
| 756 | memoff(ch); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 757 | spin_unlock_irqrestore(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 758 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 759 | /* Return how much room is left on card */ |
| 760 | return remain; |
| 761 | |
| 762 | } /* End pc_write_room */ |
| 763 | |
| 764 | /* ------------------ Begin pc_chars_in_buffer ---------------------- */ |
| 765 | |
| 766 | static int pc_chars_in_buffer(struct tty_struct *tty) |
| 767 | { /* Begin pc_chars_in_buffer */ |
| 768 | |
| 769 | int chars; |
| 770 | unsigned int ctail, head, tail; |
| 771 | int remain; |
| 772 | unsigned long flags; |
| 773 | struct channel *ch; |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 774 | struct board_chan __iomem *bc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 775 | |
| 776 | /* --------------------------------------------------------- |
| 777 | verifyChannel returns the channel from the tty struct |
| 778 | if it is valid. This serves as a sanity check. |
| 779 | ------------------------------------------------------------- */ |
| 780 | |
| 781 | if ((ch = verifyChannel(tty)) == NULL) |
| 782 | return(0); |
| 783 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 784 | spin_lock_irqsave(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 785 | globalwinon(ch); |
| 786 | |
| 787 | bc = ch->brdchan; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 788 | tail = readw(&bc->tout); |
| 789 | head = readw(&bc->tin); |
| 790 | ctail = readw(&ch->mailbox->cout); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 791 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 792 | if (tail == head && readw(&ch->mailbox->cin) == ctail && readb(&bc->tbusy) == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 793 | chars = 0; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 794 | else { /* Begin if some space on the card has been used */ |
| 795 | head = readw(&bc->tin) & (ch->txbufsize - 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 796 | tail &= (ch->txbufsize - 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 797 | /* -------------------------------------------------------------- |
| 798 | The logic here is basically opposite of the above pc_write_room |
| 799 | here we are finding the amount of bytes in the buffer filled. |
| 800 | Not the amount of bytes empty. |
| 801 | ------------------------------------------------------------------- */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 802 | if ((remain = tail - head - 1) < 0 ) |
| 803 | remain += ch->txbufsize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 804 | chars = (int)(ch->txbufsize - remain); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 805 | /* ------------------------------------------------------------- |
| 806 | Make it possible to wakeup anything waiting for output |
| 807 | in tty_ioctl.c, etc. |
| 808 | |
| 809 | If not already set. Setup an event to indicate when the |
| 810 | transmit buffer empties |
| 811 | ----------------------------------------------------------------- */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 812 | if (!(ch->statusflags & EMPTYWAIT)) |
| 813 | setup_empty_event(tty,ch); |
| 814 | |
| 815 | } /* End if some space on the card has been used */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 816 | memoff(ch); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 817 | spin_unlock_irqrestore(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 818 | /* Return number of characters residing on card. */ |
| 819 | return(chars); |
| 820 | |
| 821 | } /* End pc_chars_in_buffer */ |
| 822 | |
| 823 | /* ------------------ Begin pc_flush_buffer ---------------------- */ |
| 824 | |
| 825 | static void pc_flush_buffer(struct tty_struct *tty) |
| 826 | { /* Begin pc_flush_buffer */ |
| 827 | |
| 828 | unsigned int tail; |
| 829 | unsigned long flags; |
| 830 | struct channel *ch; |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 831 | struct board_chan __iomem *bc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 832 | /* --------------------------------------------------------- |
| 833 | verifyChannel returns the channel from the tty struct |
| 834 | if it is valid. This serves as a sanity check. |
| 835 | ------------------------------------------------------------- */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 836 | if ((ch = verifyChannel(tty)) == NULL) |
| 837 | return; |
| 838 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 839 | spin_lock_irqsave(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 840 | globalwinon(ch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 841 | bc = ch->brdchan; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 842 | tail = readw(&bc->tout); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 843 | /* Have FEP move tout pointer; effectively flushing transmit buffer */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 844 | fepcmd(ch, STOUT, (unsigned) tail, 0, 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 845 | memoff(ch); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 846 | spin_unlock_irqrestore(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 847 | wake_up_interruptible(&tty->write_wait); |
| 848 | tty_wakeup(tty); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 849 | } /* End pc_flush_buffer */ |
| 850 | |
| 851 | /* ------------------ Begin pc_flush_chars ---------------------- */ |
| 852 | |
| 853 | static void pc_flush_chars(struct tty_struct *tty) |
| 854 | { /* Begin pc_flush_chars */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 855 | struct channel * ch; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 856 | /* --------------------------------------------------------- |
| 857 | verifyChannel returns the channel from the tty struct |
| 858 | if it is valid. This serves as a sanity check. |
| 859 | ------------------------------------------------------------- */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 860 | if ((ch = verifyChannel(tty)) != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 861 | unsigned long flags; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 862 | spin_lock_irqsave(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 863 | /* ---------------------------------------------------------------- |
| 864 | If not already set and the transmitter is busy setup an event |
| 865 | to indicate when the transmit empties. |
| 866 | ------------------------------------------------------------------- */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 867 | if ((ch->statusflags & TXBUSY) && !(ch->statusflags & EMPTYWAIT)) |
| 868 | setup_empty_event(tty,ch); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 869 | spin_unlock_irqrestore(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 870 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 871 | } /* End pc_flush_chars */ |
| 872 | |
| 873 | /* ------------------ Begin block_til_ready ---------------------- */ |
| 874 | |
| 875 | static int block_til_ready(struct tty_struct *tty, |
| 876 | struct file *filp, struct channel *ch) |
| 877 | { /* Begin block_til_ready */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 878 | DECLARE_WAITQUEUE(wait,current); |
| 879 | int retval, do_clocal = 0; |
| 880 | unsigned long flags; |
| 881 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 882 | if (tty_hung_up_p(filp)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 883 | if (ch->asyncflags & ASYNC_HUP_NOTIFY) |
| 884 | retval = -EAGAIN; |
| 885 | else |
| 886 | retval = -ERESTARTSYS; |
| 887 | return(retval); |
| 888 | } |
| 889 | |
| 890 | /* ----------------------------------------------------------------- |
| 891 | If the device is in the middle of being closed, then block |
| 892 | until it's done, and then try again. |
| 893 | -------------------------------------------------------------------- */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 894 | if (ch->asyncflags & ASYNC_CLOSING) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 895 | interruptible_sleep_on(&ch->close_wait); |
| 896 | |
| 897 | if (ch->asyncflags & ASYNC_HUP_NOTIFY) |
| 898 | return -EAGAIN; |
| 899 | else |
| 900 | return -ERESTARTSYS; |
| 901 | } |
| 902 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 903 | if (filp->f_flags & O_NONBLOCK) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 904 | /* ----------------------------------------------------------------- |
| 905 | If non-blocking mode is set, then make the check up front |
| 906 | and then exit. |
| 907 | -------------------------------------------------------------------- */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 908 | ch->asyncflags |= ASYNC_NORMAL_ACTIVE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 909 | return 0; |
| 910 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 911 | if (tty->termios->c_cflag & CLOCAL) |
| 912 | do_clocal = 1; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 913 | /* Block waiting for the carrier detect and the line to become free */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 914 | |
| 915 | retval = 0; |
| 916 | add_wait_queue(&ch->open_wait, &wait); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 917 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 918 | spin_lock_irqsave(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 919 | /* We dec count so that pc_close will know when to free things */ |
| 920 | if (!tty_hung_up_p(filp)) |
| 921 | ch->count--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 922 | ch->blocked_open++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 923 | while(1) |
| 924 | { /* Begin forever while */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 925 | set_current_state(TASK_INTERRUPTIBLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 926 | if (tty_hung_up_p(filp) || |
| 927 | !(ch->asyncflags & ASYNC_INITIALIZED)) |
| 928 | { |
| 929 | if (ch->asyncflags & ASYNC_HUP_NOTIFY) |
| 930 | retval = -EAGAIN; |
| 931 | else |
| 932 | retval = -ERESTARTSYS; |
| 933 | break; |
| 934 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 935 | if (!(ch->asyncflags & ASYNC_CLOSING) && |
| 936 | (do_clocal || (ch->imodem & ch->dcd))) |
| 937 | break; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 938 | if (signal_pending(current)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 939 | retval = -ERESTARTSYS; |
| 940 | break; |
| 941 | } |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 942 | spin_unlock_irqrestore(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 943 | /* --------------------------------------------------------------- |
| 944 | Allow someone else to be scheduled. We will occasionally go |
| 945 | through this loop until one of the above conditions change. |
| 946 | The below schedule call will allow other processes to enter and |
| 947 | prevent this loop from hogging the cpu. |
| 948 | ------------------------------------------------------------------ */ |
| 949 | schedule(); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 950 | spin_lock_irqsave(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 951 | |
| 952 | } /* End forever while */ |
| 953 | |
| 954 | current->state = TASK_RUNNING; |
| 955 | remove_wait_queue(&ch->open_wait, &wait); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 956 | if (!tty_hung_up_p(filp)) |
| 957 | ch->count++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 958 | ch->blocked_open--; |
| 959 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 960 | spin_unlock_irqrestore(&epca_lock, flags); |
| 961 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 962 | if (retval) |
| 963 | return retval; |
| 964 | |
| 965 | ch->asyncflags |= ASYNC_NORMAL_ACTIVE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 966 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 967 | } /* End block_til_ready */ |
| 968 | |
| 969 | /* ------------------ Begin pc_open ---------------------- */ |
| 970 | |
| 971 | static int pc_open(struct tty_struct *tty, struct file * filp) |
| 972 | { /* Begin pc_open */ |
| 973 | |
| 974 | struct channel *ch; |
| 975 | unsigned long flags; |
| 976 | int line, retval, boardnum; |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 977 | struct board_chan __iomem *bc; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 978 | unsigned int head; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 979 | |
| 980 | line = tty->index; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 981 | if (line < 0 || line >= nbdevs) |
| 982 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 983 | |
| 984 | ch = &digi_channels[line]; |
| 985 | boardnum = ch->boardnum; |
| 986 | |
| 987 | /* Check status of board configured in system. */ |
| 988 | |
| 989 | /* ----------------------------------------------------------------- |
| 990 | I check to see if the epca_setup routine detected an user error. |
| 991 | It might be better to put this in pc_init, but for the moment it |
| 992 | goes here. |
| 993 | ---------------------------------------------------------------------- */ |
| 994 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 995 | if (invalid_lilo_config) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 996 | if (setup_error_code & INVALID_BOARD_TYPE) |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 997 | printk(KERN_ERR "epca: pc_open: Invalid board type specified in kernel options.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 998 | if (setup_error_code & INVALID_NUM_PORTS) |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 999 | printk(KERN_ERR "epca: pc_open: Invalid number of ports specified in kernel options.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1000 | if (setup_error_code & INVALID_MEM_BASE) |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1001 | printk(KERN_ERR "epca: pc_open: Invalid board memory address specified in kernel options.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1002 | if (setup_error_code & INVALID_PORT_BASE) |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1003 | printk(KERN_ERR "epca; pc_open: Invalid board port address specified in kernel options.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1004 | if (setup_error_code & INVALID_BOARD_STATUS) |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1005 | printk(KERN_ERR "epca: pc_open: Invalid board status specified in kernel options.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1006 | if (setup_error_code & INVALID_ALTPIN) |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1007 | printk(KERN_ERR "epca: pc_open: Invalid board altpin specified in kernel options;\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1008 | tty->driver_data = NULL; /* Mark this device as 'down' */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1009 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1010 | } |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1011 | if (boardnum >= num_cards || boards[boardnum].status == DISABLED) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1012 | tty->driver_data = NULL; /* Mark this device as 'down' */ |
| 1013 | return(-ENODEV); |
| 1014 | } |
| 1015 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1016 | if ((bc = ch->brdchan) == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1017 | tty->driver_data = NULL; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1018 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1019 | } |
| 1020 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1021 | spin_lock_irqsave(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1022 | /* ------------------------------------------------------------------ |
| 1023 | Every time a channel is opened, increment a counter. This is |
| 1024 | necessary because we do not wish to flush and shutdown the channel |
| 1025 | until the last app holding the channel open, closes it. |
| 1026 | --------------------------------------------------------------------- */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1027 | ch->count++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1028 | /* ---------------------------------------------------------------- |
| 1029 | Set a kernel structures pointer to our local channel |
| 1030 | structure. This way we can get to it when passed only |
| 1031 | a tty struct. |
| 1032 | ------------------------------------------------------------------ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1033 | tty->driver_data = ch; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1034 | /* ---------------------------------------------------------------- |
| 1035 | If this is the first time the channel has been opened, initialize |
| 1036 | the tty->termios struct otherwise let pc_close handle it. |
| 1037 | -------------------------------------------------------------------- */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1038 | globalwinon(ch); |
| 1039 | ch->statusflags = 0; |
| 1040 | |
| 1041 | /* Save boards current modem status */ |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 1042 | ch->imodem = readb(&bc->mstat); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1043 | |
| 1044 | /* ---------------------------------------------------------------- |
| 1045 | Set receive head and tail ptrs to each other. This indicates |
| 1046 | no data available to read. |
| 1047 | ----------------------------------------------------------------- */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1048 | head = readw(&bc->rin); |
| 1049 | writew(head, &bc->rout); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1050 | |
| 1051 | /* Set the channels associated tty structure */ |
| 1052 | ch->tty = tty; |
| 1053 | |
| 1054 | /* ----------------------------------------------------------------- |
| 1055 | The below routine generally sets up parity, baud, flow control |
| 1056 | issues, etc.... It effect both control flags and input flags. |
| 1057 | -------------------------------------------------------------------- */ |
| 1058 | epcaparam(tty,ch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1059 | ch->asyncflags |= ASYNC_INITIALIZED; |
| 1060 | memoff(ch); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1061 | spin_unlock_irqrestore(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1062 | |
| 1063 | retval = block_til_ready(tty, filp, ch); |
| 1064 | if (retval) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1065 | return retval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1066 | /* ------------------------------------------------------------- |
| 1067 | Set this again in case a hangup set it to zero while this |
| 1068 | open() was waiting for the line... |
| 1069 | --------------------------------------------------------------- */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1070 | spin_lock_irqsave(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1071 | ch->tty = tty; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1072 | globalwinon(ch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1073 | /* Enable Digi Data events */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1074 | writeb(1, &bc->idata); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1075 | memoff(ch); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1076 | spin_unlock_irqrestore(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1077 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1078 | } /* End pc_open */ |
| 1079 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1080 | static int __init epca_module_init(void) |
| 1081 | { /* Begin init_module */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1082 | return pc_init(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1083 | } |
| 1084 | |
| 1085 | module_init(epca_module_init); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1086 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1087 | static struct pci_driver epca_driver; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1088 | |
| 1089 | static void __exit epca_module_exit(void) |
| 1090 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1091 | int count, crd; |
| 1092 | struct board_info *bd; |
| 1093 | struct channel *ch; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1094 | |
| 1095 | del_timer_sync(&epca_timer); |
| 1096 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1097 | if ((tty_unregister_driver(pc_driver)) || |
| 1098 | (tty_unregister_driver(pc_info))) |
| 1099 | { |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1100 | printk(KERN_WARNING "epca: cleanup_module failed to un-register tty driver\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1101 | return; |
| 1102 | } |
| 1103 | put_tty_driver(pc_driver); |
| 1104 | put_tty_driver(pc_info); |
| 1105 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1106 | for (crd = 0; crd < num_cards; crd++) { /* Begin for each card */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1107 | bd = &boards[crd]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1108 | if (!bd) |
| 1109 | { /* Begin sanity check */ |
| 1110 | printk(KERN_ERR "<Error> - Digi : cleanup_module failed\n"); |
| 1111 | return; |
| 1112 | } /* End sanity check */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1113 | ch = card_ptr[crd]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1114 | for (count = 0; count < bd->numports; count++, ch++) |
| 1115 | { /* Begin for each port */ |
Jiri Slaby | b3218a7 | 2006-10-04 02:15:27 -0700 | [diff] [blame] | 1116 | if (ch && ch->tty) |
| 1117 | tty_hangup(ch->tty); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1118 | } /* End for each port */ |
| 1119 | } /* End for each card */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1120 | pci_unregister_driver (&epca_driver); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1121 | } |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1122 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1123 | module_exit(epca_module_exit); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1124 | |
Jeff Dike | b68e31d | 2006-10-02 02:17:18 -0700 | [diff] [blame] | 1125 | static const struct tty_operations pc_ops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1126 | .open = pc_open, |
| 1127 | .close = pc_close, |
| 1128 | .write = pc_write, |
| 1129 | .write_room = pc_write_room, |
| 1130 | .flush_buffer = pc_flush_buffer, |
| 1131 | .chars_in_buffer = pc_chars_in_buffer, |
| 1132 | .flush_chars = pc_flush_chars, |
| 1133 | .put_char = pc_put_char, |
| 1134 | .ioctl = pc_ioctl, |
| 1135 | .set_termios = pc_set_termios, |
| 1136 | .stop = pc_stop, |
| 1137 | .start = pc_start, |
| 1138 | .throttle = pc_throttle, |
| 1139 | .unthrottle = pc_unthrottle, |
| 1140 | .hangup = pc_hangup, |
| 1141 | }; |
| 1142 | |
| 1143 | static int info_open(struct tty_struct *tty, struct file * filp) |
| 1144 | { |
| 1145 | return 0; |
| 1146 | } |
| 1147 | |
| 1148 | static struct tty_operations info_ops = { |
| 1149 | .open = info_open, |
| 1150 | .ioctl = info_ioctl, |
| 1151 | }; |
| 1152 | |
| 1153 | /* ------------------ Begin pc_init ---------------------- */ |
| 1154 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1155 | static int __init pc_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1156 | { /* Begin pc_init */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1157 | int crd; |
| 1158 | struct board_info *bd; |
| 1159 | unsigned char board_id = 0; |
| 1160 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1161 | int pci_boards_found, pci_count; |
| 1162 | |
| 1163 | pci_count = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1164 | |
| 1165 | pc_driver = alloc_tty_driver(MAX_ALLOC); |
| 1166 | if (!pc_driver) |
| 1167 | return -ENOMEM; |
| 1168 | |
| 1169 | pc_info = alloc_tty_driver(MAX_ALLOC); |
| 1170 | if (!pc_info) { |
| 1171 | put_tty_driver(pc_driver); |
| 1172 | return -ENOMEM; |
| 1173 | } |
| 1174 | |
| 1175 | /* ----------------------------------------------------------------------- |
| 1176 | If epca_setup has not been ran by LILO set num_cards to defaults; copy |
| 1177 | board structure defined by digiConfig into drivers board structure. |
| 1178 | Note : If LILO has ran epca_setup then epca_setup will handle defining |
| 1179 | num_cards as well as copying the data into the board structure. |
| 1180 | -------------------------------------------------------------------------- */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1181 | if (!liloconfig) { /* Begin driver has been configured via. epcaconfig */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1182 | |
| 1183 | nbdevs = NBDEVS; |
| 1184 | num_cards = NUMCARDS; |
| 1185 | memcpy((void *)&boards, (void *)&static_boards, |
| 1186 | (sizeof(struct board_info) * NUMCARDS)); |
| 1187 | } /* End driver has been configured via. epcaconfig */ |
| 1188 | |
| 1189 | /* ----------------------------------------------------------------- |
| 1190 | Note : If lilo was used to configure the driver and the |
| 1191 | ignore epcaconfig option was choosen (digiepca=2) then |
| 1192 | nbdevs and num_cards will equal 0 at this point. This is |
| 1193 | okay; PCI cards will still be picked up if detected. |
| 1194 | --------------------------------------------------------------------- */ |
| 1195 | |
| 1196 | /* ----------------------------------------------------------- |
| 1197 | Set up interrupt, we will worry about memory allocation in |
| 1198 | post_fep_init. |
| 1199 | --------------------------------------------------------------- */ |
| 1200 | |
| 1201 | |
| 1202 | printk(KERN_INFO "DIGI epca driver version %s loaded.\n",VERSION); |
| 1203 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1204 | /* ------------------------------------------------------------------ |
| 1205 | NOTE : This code assumes that the number of ports found in |
| 1206 | the boards array is correct. This could be wrong if |
| 1207 | the card in question is PCI (And therefore has no ports |
| 1208 | entry in the boards structure.) The rest of the |
| 1209 | information will be valid for PCI because the beginning |
| 1210 | of pc_init scans for PCI and determines i/o and base |
| 1211 | memory addresses. I am not sure if it is possible to |
| 1212 | read the number of ports supported by the card prior to |
| 1213 | it being booted (Since that is the state it is in when |
| 1214 | pc_init is run). Because it is not possible to query the |
| 1215 | number of supported ports until after the card has booted; |
| 1216 | we are required to calculate the card_ptrs as the card is |
| 1217 | is initialized (Inside post_fep_init). The negative thing |
| 1218 | about this approach is that digiDload's call to GET_INFO |
| 1219 | will have a bad port value. (Since this is called prior |
| 1220 | to post_fep_init.) |
| 1221 | |
| 1222 | --------------------------------------------------------------------- */ |
| 1223 | |
| 1224 | pci_boards_found = 0; |
| 1225 | if(num_cards < MAXBOARDS) |
| 1226 | pci_boards_found += init_PCI(); |
| 1227 | num_cards += pci_boards_found; |
| 1228 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1229 | pc_driver->owner = THIS_MODULE; |
| 1230 | pc_driver->name = "ttyD"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1231 | pc_driver->major = DIGI_MAJOR; |
| 1232 | pc_driver->minor_start = 0; |
| 1233 | pc_driver->type = TTY_DRIVER_TYPE_SERIAL; |
| 1234 | pc_driver->subtype = SERIAL_TYPE_NORMAL; |
| 1235 | pc_driver->init_termios = tty_std_termios; |
| 1236 | pc_driver->init_termios.c_iflag = 0; |
| 1237 | pc_driver->init_termios.c_oflag = 0; |
| 1238 | pc_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL; |
| 1239 | pc_driver->init_termios.c_lflag = 0; |
| 1240 | pc_driver->flags = TTY_DRIVER_REAL_RAW; |
| 1241 | tty_set_operations(pc_driver, &pc_ops); |
| 1242 | |
| 1243 | pc_info->owner = THIS_MODULE; |
| 1244 | pc_info->name = "digi_ctl"; |
| 1245 | pc_info->major = DIGIINFOMAJOR; |
| 1246 | pc_info->minor_start = 0; |
| 1247 | pc_info->type = TTY_DRIVER_TYPE_SERIAL; |
| 1248 | pc_info->subtype = SERIAL_TYPE_INFO; |
| 1249 | pc_info->init_termios = tty_std_termios; |
| 1250 | pc_info->init_termios.c_iflag = 0; |
| 1251 | pc_info->init_termios.c_oflag = 0; |
| 1252 | pc_info->init_termios.c_lflag = 0; |
| 1253 | pc_info->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL; |
| 1254 | pc_info->flags = TTY_DRIVER_REAL_RAW; |
| 1255 | tty_set_operations(pc_info, &info_ops); |
| 1256 | |
| 1257 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1258 | for (crd = 0; crd < num_cards; crd++) |
| 1259 | { /* Begin for each card */ |
| 1260 | |
| 1261 | /* ------------------------------------------------------------------ |
| 1262 | This is where the appropriate memory handlers for the hardware is |
| 1263 | set. Everything at runtime blindly jumps through these vectors. |
| 1264 | ---------------------------------------------------------------------- */ |
| 1265 | |
| 1266 | /* defined in epcaconfig.h */ |
| 1267 | bd = &boards[crd]; |
| 1268 | |
| 1269 | switch (bd->type) |
| 1270 | { /* Begin switch on bd->type {board type} */ |
| 1271 | case PCXEM: |
| 1272 | case EISAXEM: |
| 1273 | bd->memwinon = pcxem_memwinon ; |
| 1274 | bd->memwinoff = pcxem_memwinoff ; |
| 1275 | bd->globalwinon = pcxem_globalwinon ; |
| 1276 | bd->txwinon = pcxem_txwinon ; |
| 1277 | bd->rxwinon = pcxem_rxwinon ; |
| 1278 | bd->memoff = pcxem_memoff ; |
| 1279 | bd->assertgwinon = dummy_assertgwinon; |
| 1280 | bd->assertmemoff = dummy_assertmemoff; |
| 1281 | break; |
| 1282 | |
| 1283 | case PCIXEM: |
| 1284 | case PCIXRJ: |
| 1285 | case PCIXR: |
| 1286 | bd->memwinon = dummy_memwinon; |
| 1287 | bd->memwinoff = dummy_memwinoff; |
| 1288 | bd->globalwinon = dummy_globalwinon; |
| 1289 | bd->txwinon = dummy_txwinon; |
| 1290 | bd->rxwinon = dummy_rxwinon; |
| 1291 | bd->memoff = dummy_memoff; |
| 1292 | bd->assertgwinon = dummy_assertgwinon; |
| 1293 | bd->assertmemoff = dummy_assertmemoff; |
| 1294 | break; |
| 1295 | |
| 1296 | case PCXE: |
| 1297 | case PCXEVE: |
| 1298 | |
| 1299 | bd->memwinon = pcxe_memwinon; |
| 1300 | bd->memwinoff = pcxe_memwinoff; |
| 1301 | bd->globalwinon = pcxe_globalwinon; |
| 1302 | bd->txwinon = pcxe_txwinon; |
| 1303 | bd->rxwinon = pcxe_rxwinon; |
| 1304 | bd->memoff = pcxe_memoff; |
| 1305 | bd->assertgwinon = dummy_assertgwinon; |
| 1306 | bd->assertmemoff = dummy_assertmemoff; |
| 1307 | break; |
| 1308 | |
| 1309 | case PCXI: |
| 1310 | case PC64XE: |
| 1311 | |
| 1312 | bd->memwinon = pcxi_memwinon; |
| 1313 | bd->memwinoff = pcxi_memwinoff; |
| 1314 | bd->globalwinon = pcxi_globalwinon; |
| 1315 | bd->txwinon = pcxi_txwinon; |
| 1316 | bd->rxwinon = pcxi_rxwinon; |
| 1317 | bd->memoff = pcxi_memoff; |
| 1318 | bd->assertgwinon = pcxi_assertgwinon; |
| 1319 | bd->assertmemoff = pcxi_assertmemoff; |
| 1320 | break; |
| 1321 | |
| 1322 | default: |
| 1323 | break; |
| 1324 | |
| 1325 | } /* End switch on bd->type */ |
| 1326 | |
| 1327 | /* --------------------------------------------------------------- |
| 1328 | Some cards need a memory segment to be defined for use in |
| 1329 | transmit and receive windowing operations. These boards |
| 1330 | are listed in the below switch. In the case of the XI the |
| 1331 | amount of memory on the board is variable so the memory_seg |
| 1332 | is also variable. This code determines what they segment |
| 1333 | should be. |
| 1334 | ----------------------------------------------------------------- */ |
| 1335 | |
| 1336 | switch (bd->type) |
| 1337 | { /* Begin switch on bd->type {board type} */ |
| 1338 | |
| 1339 | case PCXE: |
| 1340 | case PCXEVE: |
| 1341 | case PC64XE: |
| 1342 | bd->memory_seg = 0xf000; |
| 1343 | break; |
| 1344 | |
| 1345 | case PCXI: |
| 1346 | board_id = inb((int)bd->port); |
| 1347 | if ((board_id & 0x1) == 0x1) |
| 1348 | { /* Begin it's an XI card */ |
| 1349 | |
| 1350 | /* Is it a 64K board */ |
| 1351 | if ((board_id & 0x30) == 0) |
| 1352 | bd->memory_seg = 0xf000; |
| 1353 | |
| 1354 | /* Is it a 128K board */ |
| 1355 | if ((board_id & 0x30) == 0x10) |
| 1356 | bd->memory_seg = 0xe000; |
| 1357 | |
| 1358 | /* Is is a 256K board */ |
| 1359 | if ((board_id & 0x30) == 0x20) |
| 1360 | bd->memory_seg = 0xc000; |
| 1361 | |
| 1362 | /* Is it a 512K board */ |
| 1363 | if ((board_id & 0x30) == 0x30) |
| 1364 | bd->memory_seg = 0x8000; |
| 1365 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1366 | } else printk(KERN_ERR "epca: Board at 0x%x doesn't appear to be an XI\n",(int)bd->port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1367 | break; |
| 1368 | |
| 1369 | } /* End switch on bd->type */ |
| 1370 | |
| 1371 | } /* End for each card */ |
| 1372 | |
| 1373 | if (tty_register_driver(pc_driver)) |
| 1374 | panic("Couldn't register Digi PC/ driver"); |
| 1375 | |
| 1376 | if (tty_register_driver(pc_info)) |
| 1377 | panic("Couldn't register Digi PC/ info "); |
| 1378 | |
| 1379 | /* ------------------------------------------------------------------- |
| 1380 | Start up the poller to check for events on all enabled boards |
| 1381 | ---------------------------------------------------------------------- */ |
| 1382 | |
| 1383 | init_timer(&epca_timer); |
| 1384 | epca_timer.function = epcapoll; |
| 1385 | mod_timer(&epca_timer, jiffies + HZ/25); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1386 | return 0; |
| 1387 | |
| 1388 | } /* End pc_init */ |
| 1389 | |
| 1390 | /* ------------------ Begin post_fep_init ---------------------- */ |
| 1391 | |
| 1392 | static void post_fep_init(unsigned int crd) |
| 1393 | { /* Begin post_fep_init */ |
| 1394 | |
| 1395 | int i; |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 1396 | void __iomem *memaddr; |
| 1397 | struct global_data __iomem *gd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1398 | struct board_info *bd; |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 1399 | struct board_chan __iomem *bc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1400 | struct channel *ch; |
| 1401 | int shrinkmem = 0, lowwater ; |
| 1402 | |
| 1403 | /* ------------------------------------------------------------- |
| 1404 | This call is made by the user via. the ioctl call DIGI_INIT. |
| 1405 | It is responsible for setting up all the card specific stuff. |
| 1406 | ---------------------------------------------------------------- */ |
| 1407 | bd = &boards[crd]; |
| 1408 | |
| 1409 | /* ----------------------------------------------------------------- |
| 1410 | If this is a PCI board, get the port info. Remember PCI cards |
| 1411 | do not have entries into the epcaconfig.h file, so we can't get |
| 1412 | the number of ports from it. Unfortunetly, this means that anyone |
| 1413 | doing a DIGI_GETINFO before the board has booted will get an invalid |
| 1414 | number of ports returned (It should return 0). Calls to DIGI_GETINFO |
| 1415 | after DIGI_INIT has been called will return the proper values. |
| 1416 | ------------------------------------------------------------------- */ |
| 1417 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1418 | if (bd->type >= PCIXEM) { /* Begin get PCI number of ports */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1419 | /* -------------------------------------------------------------------- |
| 1420 | Below we use XEMPORTS as a memory offset regardless of which PCI |
| 1421 | card it is. This is because all of the supported PCI cards have |
| 1422 | the same memory offset for the channel data. This will have to be |
| 1423 | changed if we ever develop a PCI/XE card. NOTE : The FEP manual |
| 1424 | states that the port offset is 0xC22 as opposed to 0xC02. This is |
| 1425 | only true for PC/XE, and PC/XI cards; not for the XEM, or CX series. |
| 1426 | On the PCI cards the number of ports is determined by reading a |
| 1427 | ID PROM located in the box attached to the card. The card can then |
| 1428 | determine the index the id to determine the number of ports available. |
| 1429 | (FYI - The id should be located at 0x1ac (And may use up to 4 bytes |
| 1430 | if the box in question is a XEM or CX)). |
| 1431 | ------------------------------------------------------------------------ */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1432 | /* PCI cards are already remapped at this point ISA are not */ |
| 1433 | bd->numports = readw(bd->re_map_membase + XEMPORTS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1434 | epcaassert(bd->numports <= 64,"PCI returned a invalid number of ports"); |
| 1435 | nbdevs += (bd->numports); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1436 | } else { |
| 1437 | /* Fix up the mappings for ISA/EISA etc */ |
| 1438 | /* FIXME: 64K - can we be smarter ? */ |
| 1439 | bd->re_map_membase = ioremap(bd->membase, 0x10000); |
| 1440 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1441 | |
| 1442 | if (crd != 0) |
| 1443 | card_ptr[crd] = card_ptr[crd-1] + boards[crd-1].numports; |
| 1444 | else |
| 1445 | card_ptr[crd] = &digi_channels[crd]; /* <- For card 0 only */ |
| 1446 | |
| 1447 | ch = card_ptr[crd]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1448 | epcaassert(ch <= &digi_channels[nbdevs - 1], "ch out of range"); |
| 1449 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1450 | memaddr = bd->re_map_membase; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1451 | |
| 1452 | /* ----------------------------------------------------------------- |
| 1453 | The below assignment will set bc to point at the BEGINING of |
| 1454 | the cards channel structures. For 1 card there will be between |
| 1455 | 8 and 64 of these structures. |
| 1456 | -------------------------------------------------------------------- */ |
| 1457 | |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 1458 | bc = memaddr + CHANSTRUCT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1459 | |
| 1460 | /* ------------------------------------------------------------------- |
| 1461 | The below assignment will set gd to point at the BEGINING of |
| 1462 | global memory address 0xc00. The first data in that global |
| 1463 | memory actually starts at address 0xc1a. The command in |
| 1464 | pointer begins at 0xd10. |
| 1465 | ---------------------------------------------------------------------- */ |
| 1466 | |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 1467 | gd = memaddr + GLOBAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1468 | |
| 1469 | /* -------------------------------------------------------------------- |
| 1470 | XEPORTS (address 0xc22) points at the number of channels the |
| 1471 | card supports. (For 64XE, XI, XEM, and XR use 0xc02) |
| 1472 | ----------------------------------------------------------------------- */ |
| 1473 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1474 | if ((bd->type == PCXEVE || bd->type == PCXE) && (readw(memaddr + XEPORTS) < 3)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1475 | shrinkmem = 1; |
| 1476 | if (bd->type < PCIXEM) |
| 1477 | if (!request_region((int)bd->port, 4, board_desc[bd->type])) |
| 1478 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1479 | memwinon(bd, 0); |
| 1480 | |
| 1481 | /* -------------------------------------------------------------------- |
| 1482 | Remember ch is the main drivers channels structure, while bc is |
| 1483 | the cards channel structure. |
| 1484 | ------------------------------------------------------------------------ */ |
| 1485 | |
| 1486 | /* For every port on the card do ..... */ |
| 1487 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1488 | for (i = 0; i < bd->numports; i++, ch++, bc++) { /* Begin for each port */ |
| 1489 | unsigned long flags; |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 1490 | u16 tseg, rseg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1491 | |
| 1492 | ch->brdchan = bc; |
| 1493 | ch->mailbox = gd; |
| 1494 | INIT_WORK(&ch->tqueue, do_softint, ch); |
| 1495 | ch->board = &boards[crd]; |
| 1496 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1497 | spin_lock_irqsave(&epca_lock, flags); |
| 1498 | switch (bd->type) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1499 | /* ---------------------------------------------------------------- |
| 1500 | Since some of the boards use different bitmaps for their |
| 1501 | control signals we cannot hard code these values and retain |
| 1502 | portability. We virtualize this data here. |
| 1503 | ------------------------------------------------------------------- */ |
| 1504 | case EISAXEM: |
| 1505 | case PCXEM: |
| 1506 | case PCIXEM: |
| 1507 | case PCIXRJ: |
| 1508 | case PCIXR: |
| 1509 | ch->m_rts = 0x02 ; |
| 1510 | ch->m_dcd = 0x80 ; |
| 1511 | ch->m_dsr = 0x20 ; |
| 1512 | ch->m_cts = 0x10 ; |
| 1513 | ch->m_ri = 0x40 ; |
| 1514 | ch->m_dtr = 0x01 ; |
| 1515 | break; |
| 1516 | |
| 1517 | case PCXE: |
| 1518 | case PCXEVE: |
| 1519 | case PCXI: |
| 1520 | case PC64XE: |
| 1521 | ch->m_rts = 0x02 ; |
| 1522 | ch->m_dcd = 0x08 ; |
| 1523 | ch->m_dsr = 0x10 ; |
| 1524 | ch->m_cts = 0x20 ; |
| 1525 | ch->m_ri = 0x40 ; |
| 1526 | ch->m_dtr = 0x80 ; |
| 1527 | break; |
| 1528 | |
| 1529 | } /* End switch bd->type */ |
| 1530 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1531 | if (boards[crd].altpin) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1532 | ch->dsr = ch->m_dcd; |
| 1533 | ch->dcd = ch->m_dsr; |
| 1534 | ch->digiext.digi_flags |= DIGI_ALTPIN; |
| 1535 | } |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1536 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1537 | ch->dcd = ch->m_dcd; |
| 1538 | ch->dsr = ch->m_dsr; |
| 1539 | } |
| 1540 | |
| 1541 | ch->boardnum = crd; |
| 1542 | ch->channelnum = i; |
| 1543 | ch->magic = EPCA_MAGIC; |
| 1544 | ch->tty = NULL; |
| 1545 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1546 | if (shrinkmem) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1547 | fepcmd(ch, SETBUFFER, 32, 0, 0, 0); |
| 1548 | shrinkmem = 0; |
| 1549 | } |
| 1550 | |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 1551 | tseg = readw(&bc->tseg); |
| 1552 | rseg = readw(&bc->rseg); |
| 1553 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1554 | switch (bd->type) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1555 | |
| 1556 | case PCIXEM: |
| 1557 | case PCIXRJ: |
| 1558 | case PCIXR: |
| 1559 | /* Cover all the 2MEG cards */ |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 1560 | ch->txptr = memaddr + ((tseg << 4) & 0x1fffff); |
| 1561 | ch->rxptr = memaddr + ((rseg << 4) & 0x1fffff); |
| 1562 | ch->txwin = FEPWIN | (tseg >> 11); |
| 1563 | ch->rxwin = FEPWIN | (rseg >> 11); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1564 | break; |
| 1565 | |
| 1566 | case PCXEM: |
| 1567 | case EISAXEM: |
| 1568 | /* Cover all the 32K windowed cards */ |
| 1569 | /* Mask equal to window size - 1 */ |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 1570 | ch->txptr = memaddr + ((tseg << 4) & 0x7fff); |
| 1571 | ch->rxptr = memaddr + ((rseg << 4) & 0x7fff); |
| 1572 | ch->txwin = FEPWIN | (tseg >> 11); |
| 1573 | ch->rxwin = FEPWIN | (rseg >> 11); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1574 | break; |
| 1575 | |
| 1576 | case PCXEVE: |
| 1577 | case PCXE: |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 1578 | ch->txptr = memaddr + (((tseg - bd->memory_seg) << 4) & 0x1fff); |
| 1579 | ch->txwin = FEPWIN | ((tseg - bd->memory_seg) >> 9); |
| 1580 | ch->rxptr = memaddr + (((rseg - bd->memory_seg) << 4) & 0x1fff); |
| 1581 | ch->rxwin = FEPWIN | ((rseg - bd->memory_seg) >>9 ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1582 | break; |
| 1583 | |
| 1584 | case PCXI: |
| 1585 | case PC64XE: |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 1586 | ch->txptr = memaddr + ((tseg - bd->memory_seg) << 4); |
| 1587 | ch->rxptr = memaddr + ((rseg - bd->memory_seg) << 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1588 | ch->txwin = ch->rxwin = 0; |
| 1589 | break; |
| 1590 | |
| 1591 | } /* End switch bd->type */ |
| 1592 | |
| 1593 | ch->txbufhead = 0; |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 1594 | ch->txbufsize = readw(&bc->tmax) + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1595 | |
| 1596 | ch->rxbufhead = 0; |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 1597 | ch->rxbufsize = readw(&bc->rmax) + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1598 | |
| 1599 | lowwater = ch->txbufsize >= 2000 ? 1024 : (ch->txbufsize / 2); |
| 1600 | |
| 1601 | /* Set transmitter low water mark */ |
| 1602 | fepcmd(ch, STXLWATER, lowwater, 0, 10, 0); |
| 1603 | |
| 1604 | /* Set receiver low water mark */ |
| 1605 | |
| 1606 | fepcmd(ch, SRXLWATER, (ch->rxbufsize / 4), 0, 10, 0); |
| 1607 | |
| 1608 | /* Set receiver high water mark */ |
| 1609 | |
| 1610 | fepcmd(ch, SRXHWATER, (3 * ch->rxbufsize / 4), 0, 10, 0); |
| 1611 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1612 | writew(100, &bc->edelay); |
| 1613 | writeb(1, &bc->idata); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1614 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1615 | ch->startc = readb(&bc->startc); |
| 1616 | ch->stopc = readb(&bc->stopc); |
| 1617 | ch->startca = readb(&bc->startca); |
| 1618 | ch->stopca = readb(&bc->stopca); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1619 | |
| 1620 | ch->fepcflag = 0; |
| 1621 | ch->fepiflag = 0; |
| 1622 | ch->fepoflag = 0; |
| 1623 | ch->fepstartc = 0; |
| 1624 | ch->fepstopc = 0; |
| 1625 | ch->fepstartca = 0; |
| 1626 | ch->fepstopca = 0; |
| 1627 | |
| 1628 | ch->close_delay = 50; |
| 1629 | ch->count = 0; |
| 1630 | ch->blocked_open = 0; |
| 1631 | init_waitqueue_head(&ch->open_wait); |
| 1632 | init_waitqueue_head(&ch->close_wait); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1633 | |
| 1634 | spin_unlock_irqrestore(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1635 | } /* End for each port */ |
| 1636 | |
| 1637 | printk(KERN_INFO |
| 1638 | "Digi PC/Xx Driver V%s: %s I/O = 0x%lx Mem = 0x%lx Ports = %d\n", |
| 1639 | VERSION, board_desc[bd->type], (long)bd->port, (long)bd->membase, bd->numports); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1640 | memwinoff(bd, 0); |
| 1641 | |
| 1642 | } /* End post_fep_init */ |
| 1643 | |
| 1644 | /* --------------------- Begin epcapoll ------------------------ */ |
| 1645 | |
| 1646 | static void epcapoll(unsigned long ignored) |
| 1647 | { /* Begin epcapoll */ |
| 1648 | |
| 1649 | unsigned long flags; |
| 1650 | int crd; |
| 1651 | volatile unsigned int head, tail; |
| 1652 | struct channel *ch; |
| 1653 | struct board_info *bd; |
| 1654 | |
| 1655 | /* ------------------------------------------------------------------- |
| 1656 | This routine is called upon every timer interrupt. Even though |
| 1657 | the Digi series cards are capable of generating interrupts this |
| 1658 | method of non-looping polling is more efficient. This routine |
| 1659 | checks for card generated events (Such as receive data, are transmit |
| 1660 | buffer empty) and acts on those events. |
| 1661 | ----------------------------------------------------------------------- */ |
| 1662 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1663 | for (crd = 0; crd < num_cards; crd++) |
| 1664 | { /* Begin for each card */ |
| 1665 | |
| 1666 | bd = &boards[crd]; |
| 1667 | ch = card_ptr[crd]; |
| 1668 | |
| 1669 | if ((bd->status == DISABLED) || digi_poller_inhibited) |
| 1670 | continue; /* Begin loop next interation */ |
| 1671 | |
| 1672 | /* ----------------------------------------------------------- |
| 1673 | assertmemoff is not needed here; indeed it is an empty subroutine. |
| 1674 | It is being kept because future boards may need this as well as |
| 1675 | some legacy boards. |
| 1676 | ---------------------------------------------------------------- */ |
| 1677 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1678 | spin_lock_irqsave(&epca_lock, flags); |
| 1679 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1680 | assertmemoff(ch); |
| 1681 | |
| 1682 | globalwinon(ch); |
| 1683 | |
| 1684 | /* --------------------------------------------------------------- |
| 1685 | In this case head and tail actually refer to the event queue not |
| 1686 | the transmit or receive queue. |
| 1687 | ------------------------------------------------------------------- */ |
| 1688 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1689 | head = readw(&ch->mailbox->ein); |
| 1690 | tail = readw(&ch->mailbox->eout); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1691 | |
| 1692 | /* If head isn't equal to tail we have an event */ |
| 1693 | |
| 1694 | if (head != tail) |
| 1695 | doevent(crd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1696 | memoff(ch); |
| 1697 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1698 | spin_unlock_irqrestore(&epca_lock, flags); |
| 1699 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1700 | } /* End for each card */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1701 | mod_timer(&epca_timer, jiffies + (HZ / 25)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1702 | } /* End epcapoll */ |
| 1703 | |
| 1704 | /* --------------------- Begin doevent ------------------------ */ |
| 1705 | |
| 1706 | static void doevent(int crd) |
| 1707 | { /* Begin doevent */ |
| 1708 | |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 1709 | void __iomem *eventbuf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1710 | struct channel *ch, *chan0; |
| 1711 | static struct tty_struct *tty; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1712 | struct board_info *bd; |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 1713 | struct board_chan __iomem *bc; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1714 | unsigned int tail, head; |
| 1715 | int event, channel; |
| 1716 | int mstat, lstat; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1717 | |
| 1718 | /* ------------------------------------------------------------------- |
| 1719 | This subroutine is called by epcapoll when an event is detected |
| 1720 | in the event queue. This routine responds to those events. |
| 1721 | --------------------------------------------------------------------- */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1722 | bd = &boards[crd]; |
| 1723 | |
| 1724 | chan0 = card_ptr[crd]; |
| 1725 | epcaassert(chan0 <= &digi_channels[nbdevs - 1], "ch out of range"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1726 | assertgwinon(chan0); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1727 | while ((tail = readw(&chan0->mailbox->eout)) != (head = readw(&chan0->mailbox->ein))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1728 | { /* Begin while something in event queue */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1729 | assertgwinon(chan0); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1730 | eventbuf = bd->re_map_membase + tail + ISTART; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1731 | /* Get the channel the event occurred on */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1732 | channel = readb(eventbuf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1733 | /* Get the actual event code that occurred */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1734 | event = readb(eventbuf + 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1735 | /* ---------------------------------------------------------------- |
| 1736 | The two assignments below get the current modem status (mstat) |
| 1737 | and the previous modem status (lstat). These are useful becuase |
| 1738 | an event could signal a change in modem signals itself. |
| 1739 | ------------------------------------------------------------------- */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1740 | mstat = readb(eventbuf + 2); |
| 1741 | lstat = readb(eventbuf + 3); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1742 | |
| 1743 | ch = chan0 + channel; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1744 | if ((unsigned)channel >= bd->numports || !ch) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1745 | if (channel >= bd->numports) |
| 1746 | ch = chan0; |
| 1747 | bc = ch->brdchan; |
| 1748 | goto next; |
| 1749 | } |
| 1750 | |
| 1751 | if ((bc = ch->brdchan) == NULL) |
| 1752 | goto next; |
| 1753 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1754 | if (event & DATA_IND) { /* Begin DATA_IND */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1755 | receive_data(ch); |
| 1756 | assertgwinon(ch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1757 | } /* End DATA_IND */ |
| 1758 | /* else *//* Fix for DCD transition missed bug */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1759 | if (event & MODEMCHG_IND) { /* Begin MODEMCHG_IND */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1760 | /* A modem signal change has been indicated */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1761 | ch->imodem = mstat; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1762 | if (ch->asyncflags & ASYNC_CHECK_CD) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1763 | if (mstat & ch->dcd) /* We are now receiving dcd */ |
| 1764 | wake_up_interruptible(&ch->open_wait); |
| 1765 | else |
| 1766 | pc_sched_event(ch, EPCA_EVENT_HANGUP); /* No dcd; hangup */ |
| 1767 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1768 | } /* End MODEMCHG_IND */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1769 | tty = ch->tty; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1770 | if (tty) { /* Begin if valid tty */ |
| 1771 | if (event & BREAK_IND) { /* Begin if BREAK_IND */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1772 | /* A break has been indicated */ |
Alan Cox | 33f0f88 | 2006-01-09 20:54:13 -0800 | [diff] [blame] | 1773 | tty_insert_flip_char(tty, 0, TTY_BREAK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1774 | tty_schedule_flip(tty); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1775 | } else if (event & LOWTX_IND) { /* Begin LOWTX_IND */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1776 | if (ch->statusflags & LOWWAIT) |
| 1777 | { /* Begin if LOWWAIT */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1778 | ch->statusflags &= ~LOWWAIT; |
| 1779 | tty_wakeup(tty); |
| 1780 | wake_up_interruptible(&tty->write_wait); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1781 | } /* End if LOWWAIT */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1782 | } else if (event & EMPTYTX_IND) { /* Begin EMPTYTX_IND */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1783 | /* This event is generated by setup_empty_event */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1784 | ch->statusflags &= ~TXBUSY; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1785 | if (ch->statusflags & EMPTYWAIT) { /* Begin if EMPTYWAIT */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1786 | ch->statusflags &= ~EMPTYWAIT; |
| 1787 | tty_wakeup(tty); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1788 | wake_up_interruptible(&tty->write_wait); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1789 | } /* End if EMPTYWAIT */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1790 | } /* End EMPTYTX_IND */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1791 | } /* End if valid tty */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1792 | next: |
| 1793 | globalwinon(ch); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1794 | BUG_ON(!bc); |
| 1795 | writew(1, &bc->idata); |
| 1796 | writew((tail + 4) & (IMAX - ISTART - 4), &chan0->mailbox->eout); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1797 | globalwinon(chan0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1798 | } /* End while something in event queue */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1799 | } /* End doevent */ |
| 1800 | |
| 1801 | /* --------------------- Begin fepcmd ------------------------ */ |
| 1802 | |
| 1803 | static void fepcmd(struct channel *ch, int cmd, int word_or_byte, |
| 1804 | int byte2, int ncmds, int bytecmd) |
| 1805 | { /* Begin fepcmd */ |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 1806 | unchar __iomem *memaddr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1807 | unsigned int head, cmdTail, cmdStart, cmdMax; |
| 1808 | long count; |
| 1809 | int n; |
| 1810 | |
| 1811 | /* This is the routine in which commands may be passed to the card. */ |
| 1812 | |
| 1813 | if (ch->board->status == DISABLED) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1814 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1815 | assertgwinon(ch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1816 | /* Remember head (As well as max) is just an offset not a base addr */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1817 | head = readw(&ch->mailbox->cin); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1818 | /* cmdStart is a base address */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1819 | cmdStart = readw(&ch->mailbox->cstart); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1820 | /* ------------------------------------------------------------------ |
| 1821 | We do the addition below because we do not want a max pointer |
| 1822 | relative to cmdStart. We want a max pointer that points at the |
| 1823 | physical end of the command queue. |
| 1824 | -------------------------------------------------------------------- */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1825 | cmdMax = (cmdStart + 4 + readw(&ch->mailbox->cmax)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1826 | memaddr = ch->board->re_map_membase; |
| 1827 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1828 | if (head >= (cmdMax - cmdStart) || (head & 03)) { |
| 1829 | printk(KERN_ERR "line %d: Out of range, cmd = %x, head = %x\n", __LINE__, cmd, head); |
| 1830 | printk(KERN_ERR "line %d: Out of range, cmdMax = %x, cmdStart = %x\n", __LINE__, cmdMax, cmdStart); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1831 | return; |
| 1832 | } |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1833 | if (bytecmd) { |
| 1834 | writeb(cmd, memaddr + head + cmdStart + 0); |
| 1835 | writeb(ch->channelnum, memaddr + head + cmdStart + 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1836 | /* Below word_or_byte is bits to set */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1837 | writeb(word_or_byte, memaddr + head + cmdStart + 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1838 | /* Below byte2 is bits to reset */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1839 | writeb(byte2, memaddr + head + cmdStart + 3); |
| 1840 | } else { |
| 1841 | writeb(cmd, memaddr + head + cmdStart + 0); |
| 1842 | writeb(ch->channelnum, memaddr + head + cmdStart + 1); |
| 1843 | writeb(word_or_byte, memaddr + head + cmdStart + 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1844 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1845 | head = (head + 4) & (cmdMax - cmdStart - 4); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1846 | writew(head, &ch->mailbox->cin); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1847 | count = FEPTIMEOUT; |
| 1848 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1849 | for (;;) { /* Begin forever loop */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1850 | count--; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1851 | if (count == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1852 | printk(KERN_ERR "<Error> - Fep not responding in fepcmd()\n"); |
| 1853 | return; |
| 1854 | } |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1855 | head = readw(&ch->mailbox->cin); |
| 1856 | cmdTail = readw(&ch->mailbox->cout); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1857 | n = (head - cmdTail) & (cmdMax - cmdStart - 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1858 | /* ---------------------------------------------------------- |
| 1859 | Basically this will break when the FEP acknowledges the |
| 1860 | command by incrementing cmdTail (Making it equal to head). |
| 1861 | ------------------------------------------------------------- */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1862 | if (n <= ncmds * (sizeof(short) * 4)) |
| 1863 | break; /* Well nearly forever :-) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1864 | } /* End forever loop */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1865 | } /* End fepcmd */ |
| 1866 | |
| 1867 | /* --------------------------------------------------------------------- |
| 1868 | Digi products use fields in their channels structures that are very |
| 1869 | similar to the c_cflag and c_iflag fields typically found in UNIX |
| 1870 | termios structures. The below three routines allow mappings |
| 1871 | between these hardware "flags" and their respective Linux flags. |
| 1872 | ------------------------------------------------------------------------- */ |
| 1873 | |
| 1874 | /* --------------------- Begin termios2digi_h -------------------- */ |
| 1875 | |
| 1876 | static unsigned termios2digi_h(struct channel *ch, unsigned cflag) |
| 1877 | { /* Begin termios2digi_h */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1878 | unsigned res = 0; |
| 1879 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1880 | if (cflag & CRTSCTS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1881 | ch->digiext.digi_flags |= (RTSPACE | CTSPACE); |
| 1882 | res |= ((ch->m_cts) | (ch->m_rts)); |
| 1883 | } |
| 1884 | |
| 1885 | if (ch->digiext.digi_flags & RTSPACE) |
| 1886 | res |= ch->m_rts; |
| 1887 | |
| 1888 | if (ch->digiext.digi_flags & DTRPACE) |
| 1889 | res |= ch->m_dtr; |
| 1890 | |
| 1891 | if (ch->digiext.digi_flags & CTSPACE) |
| 1892 | res |= ch->m_cts; |
| 1893 | |
| 1894 | if (ch->digiext.digi_flags & DSRPACE) |
| 1895 | res |= ch->dsr; |
| 1896 | |
| 1897 | if (ch->digiext.digi_flags & DCDPACE) |
| 1898 | res |= ch->dcd; |
| 1899 | |
| 1900 | if (res & (ch->m_rts)) |
| 1901 | ch->digiext.digi_flags |= RTSPACE; |
| 1902 | |
| 1903 | if (res & (ch->m_cts)) |
| 1904 | ch->digiext.digi_flags |= CTSPACE; |
| 1905 | |
| 1906 | return res; |
| 1907 | |
| 1908 | } /* End termios2digi_h */ |
| 1909 | |
| 1910 | /* --------------------- Begin termios2digi_i -------------------- */ |
| 1911 | static unsigned termios2digi_i(struct channel *ch, unsigned iflag) |
| 1912 | { /* Begin termios2digi_i */ |
| 1913 | |
| 1914 | unsigned res = iflag & (IGNBRK | BRKINT | IGNPAR | PARMRK | |
| 1915 | INPCK | ISTRIP|IXON|IXANY|IXOFF); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1916 | if (ch->digiext.digi_flags & DIGI_AIXON) |
| 1917 | res |= IAIXON; |
| 1918 | return res; |
| 1919 | |
| 1920 | } /* End termios2digi_i */ |
| 1921 | |
| 1922 | /* --------------------- Begin termios2digi_c -------------------- */ |
| 1923 | |
| 1924 | static unsigned termios2digi_c(struct channel *ch, unsigned cflag) |
| 1925 | { /* Begin termios2digi_c */ |
| 1926 | |
| 1927 | unsigned res = 0; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1928 | if (cflag & CBAUDEX) { /* Begin detected CBAUDEX */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1929 | ch->digiext.digi_flags |= DIGI_FAST; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1930 | /* ------------------------------------------------------------- |
| 1931 | HUPCL bit is used by FEP to indicate fast baud |
| 1932 | table is to be used. |
| 1933 | ----------------------------------------------------------------- */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1934 | res |= FEP_HUPCL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1935 | } /* End detected CBAUDEX */ |
| 1936 | else ch->digiext.digi_flags &= ~DIGI_FAST; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1937 | /* ------------------------------------------------------------------- |
| 1938 | CBAUD has bit position 0x1000 set these days to indicate Linux |
| 1939 | baud rate remap. Digi hardware can't handle the bit assignment. |
| 1940 | (We use a different bit assignment for high speed.). Clear this |
| 1941 | bit out. |
| 1942 | ---------------------------------------------------------------------- */ |
| 1943 | res |= cflag & ((CBAUD ^ CBAUDEX) | PARODD | PARENB | CSTOPB | CSIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1944 | /* ------------------------------------------------------------- |
| 1945 | This gets a little confusing. The Digi cards have their own |
| 1946 | representation of c_cflags controling baud rate. For the most |
| 1947 | part this is identical to the Linux implementation. However; |
| 1948 | Digi supports one rate (76800) that Linux doesn't. This means |
| 1949 | that the c_cflag entry that would normally mean 76800 for Digi |
| 1950 | actually means 115200 under Linux. Without the below mapping, |
| 1951 | a stty 115200 would only drive the board at 76800. Since |
| 1952 | the rate 230400 is also found after 76800, the same problem afflicts |
| 1953 | us when we choose a rate of 230400. Without the below modificiation |
| 1954 | stty 230400 would actually give us 115200. |
| 1955 | |
| 1956 | There are two additional differences. The Linux value for CLOCAL |
| 1957 | (0x800; 0004000) has no meaning to the Digi hardware. Also in |
| 1958 | later releases of Linux; the CBAUD define has CBAUDEX (0x1000; |
| 1959 | 0010000) ored into it (CBAUD = 0x100f as opposed to 0xf). CBAUDEX |
| 1960 | should be checked for a screened out prior to termios2digi_c |
| 1961 | returning. Since CLOCAL isn't used by the board this can be |
| 1962 | ignored as long as the returned value is used only by Digi hardware. |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1963 | ----------------------------------------------------------------- */ |
| 1964 | if (cflag & CBAUDEX) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1965 | /* ------------------------------------------------------------- |
| 1966 | The below code is trying to guarantee that only baud rates |
| 1967 | 115200 and 230400 are remapped. We use exclusive or because |
| 1968 | the various baud rates share common bit positions and therefore |
| 1969 | can't be tested for easily. |
| 1970 | ----------------------------------------------------------------- */ |
| 1971 | |
| 1972 | |
| 1973 | if ((!((cflag & 0x7) ^ (B115200 & ~CBAUDEX))) || |
| 1974 | (!((cflag & 0x7) ^ (B230400 & ~CBAUDEX)))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1975 | res += 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1976 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1977 | return res; |
| 1978 | |
| 1979 | } /* End termios2digi_c */ |
| 1980 | |
| 1981 | /* --------------------- Begin epcaparam ----------------------- */ |
| 1982 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1983 | /* Caller must hold the locks */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1984 | static void epcaparam(struct tty_struct *tty, struct channel *ch) |
| 1985 | { /* Begin epcaparam */ |
| 1986 | |
| 1987 | unsigned int cmdHead; |
| 1988 | struct termios *ts; |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 1989 | struct board_chan __iomem *bc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1990 | unsigned mval, hflow, cflag, iflag; |
| 1991 | |
| 1992 | bc = ch->brdchan; |
| 1993 | epcaassert(bc !=0, "bc out of range"); |
| 1994 | |
| 1995 | assertgwinon(ch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1996 | ts = tty->termios; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 1997 | if ((ts->c_cflag & CBAUD) == 0) { /* Begin CBAUD detected */ |
| 1998 | cmdHead = readw(&bc->rin); |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 1999 | writew(cmdHead, &bc->rout); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2000 | cmdHead = readw(&bc->tin); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2001 | /* Changing baud in mid-stream transmission can be wonderful */ |
| 2002 | /* --------------------------------------------------------------- |
| 2003 | Flush current transmit buffer by setting cmdTail pointer (tout) |
| 2004 | to cmdHead pointer (tin). Hopefully the transmit buffer is empty. |
| 2005 | ----------------------------------------------------------------- */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2006 | fepcmd(ch, STOUT, (unsigned) cmdHead, 0, 0, 0); |
| 2007 | mval = 0; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2008 | } else { /* Begin CBAUD not detected */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2009 | /* ------------------------------------------------------------------- |
| 2010 | c_cflags have changed but that change had nothing to do with BAUD. |
| 2011 | Propagate the change to the card. |
| 2012 | ---------------------------------------------------------------------- */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2013 | cflag = termios2digi_c(ch, ts->c_cflag); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2014 | if (cflag != ch->fepcflag) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2015 | ch->fepcflag = cflag; |
| 2016 | /* Set baud rate, char size, stop bits, parity */ |
| 2017 | fepcmd(ch, SETCTRLFLAGS, (unsigned) cflag, 0, 0, 0); |
| 2018 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2019 | /* ---------------------------------------------------------------- |
| 2020 | If the user has not forced CLOCAL and if the device is not a |
| 2021 | CALLOUT device (Which is always CLOCAL) we set flags such that |
| 2022 | the driver will wait on carrier detect. |
| 2023 | ------------------------------------------------------------------- */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2024 | if (ts->c_cflag & CLOCAL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2025 | ch->asyncflags &= ~ASYNC_CHECK_CD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2026 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2027 | ch->asyncflags |= ASYNC_CHECK_CD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2028 | mval = ch->m_dtr | ch->m_rts; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2029 | } /* End CBAUD not detected */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2030 | iflag = termios2digi_i(ch, ts->c_iflag); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2031 | /* Check input mode flags */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2032 | if (iflag != ch->fepiflag) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2033 | ch->fepiflag = iflag; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2034 | /* --------------------------------------------------------------- |
| 2035 | Command sets channels iflag structure on the board. Such things |
| 2036 | as input soft flow control, handling of parity errors, and |
| 2037 | break handling are all set here. |
| 2038 | ------------------------------------------------------------------- */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2039 | /* break handling, parity handling, input stripping, flow control chars */ |
| 2040 | fepcmd(ch, SETIFLAGS, (unsigned int) ch->fepiflag, 0, 0, 0); |
| 2041 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2042 | /* --------------------------------------------------------------- |
| 2043 | Set the board mint value for this channel. This will cause hardware |
| 2044 | events to be generated each time the DCD signal (Described in mint) |
| 2045 | changes. |
| 2046 | ------------------------------------------------------------------- */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2047 | writeb(ch->dcd, &bc->mint); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2048 | if ((ts->c_cflag & CLOCAL) || (ch->digiext.digi_flags & DIGI_FORCEDCD)) |
| 2049 | if (ch->digiext.digi_flags & DIGI_FORCEDCD) |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2050 | writeb(0, &bc->mint); |
| 2051 | ch->imodem = readb(&bc->mstat); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2052 | hflow = termios2digi_h(ch, ts->c_cflag); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2053 | if (hflow != ch->hflow) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2054 | ch->hflow = hflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2055 | /* -------------------------------------------------------------- |
| 2056 | Hard flow control has been selected but the board is not |
| 2057 | using it. Activate hard flow control now. |
| 2058 | ----------------------------------------------------------------- */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2059 | fepcmd(ch, SETHFLOW, hflow, 0xff, 0, 1); |
| 2060 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2061 | mval ^= ch->modemfake & (mval ^ ch->modem); |
| 2062 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2063 | if (ch->omodem ^ mval) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2064 | ch->omodem = mval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2065 | /* -------------------------------------------------------------- |
| 2066 | The below command sets the DTR and RTS mstat structure. If |
| 2067 | hard flow control is NOT active these changes will drive the |
| 2068 | output of the actual DTR and RTS lines. If hard flow control |
| 2069 | is active, the changes will be saved in the mstat structure and |
| 2070 | only asserted when hard flow control is turned off. |
| 2071 | ----------------------------------------------------------------- */ |
| 2072 | |
| 2073 | /* First reset DTR & RTS; then set them */ |
| 2074 | fepcmd(ch, SETMODEM, 0, ((ch->m_dtr)|(ch->m_rts)), 0, 1); |
| 2075 | fepcmd(ch, SETMODEM, mval, 0, 0, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2076 | } |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2077 | if (ch->startc != ch->fepstartc || ch->stopc != ch->fepstopc) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2078 | ch->fepstartc = ch->startc; |
| 2079 | ch->fepstopc = ch->stopc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2080 | /* ------------------------------------------------------------ |
| 2081 | The XON / XOFF characters have changed; propagate these |
| 2082 | changes to the card. |
| 2083 | --------------------------------------------------------------- */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2084 | fepcmd(ch, SONOFFC, ch->fepstartc, ch->fepstopc, 0, 1); |
| 2085 | } |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2086 | if (ch->startca != ch->fepstartca || ch->stopca != ch->fepstopca) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2087 | ch->fepstartca = ch->startca; |
| 2088 | ch->fepstopca = ch->stopca; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2089 | /* --------------------------------------------------------------- |
| 2090 | Similar to the above, this time the auxilarly XON / XOFF |
| 2091 | characters have changed; propagate these changes to the card. |
| 2092 | ------------------------------------------------------------------ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2093 | fepcmd(ch, SAUXONOFFC, ch->fepstartca, ch->fepstopca, 0, 1); |
| 2094 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2095 | } /* End epcaparam */ |
| 2096 | |
| 2097 | /* --------------------- Begin receive_data ----------------------- */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2098 | /* Caller holds lock */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2099 | static void receive_data(struct channel *ch) |
| 2100 | { /* Begin receive_data */ |
| 2101 | |
| 2102 | unchar *rptr; |
| 2103 | struct termios *ts = NULL; |
| 2104 | struct tty_struct *tty; |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 2105 | struct board_chan __iomem *bc; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2106 | int dataToRead, wrapgap, bytesAvailable; |
| 2107 | unsigned int tail, head; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2108 | unsigned int wrapmask; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2109 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2110 | /* --------------------------------------------------------------- |
| 2111 | This routine is called by doint when a receive data event |
| 2112 | has taken place. |
| 2113 | ------------------------------------------------------------------- */ |
| 2114 | |
| 2115 | globalwinon(ch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2116 | if (ch->statusflags & RXSTOPPED) |
| 2117 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2118 | tty = ch->tty; |
| 2119 | if (tty) |
| 2120 | ts = tty->termios; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2121 | bc = ch->brdchan; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2122 | BUG_ON(!bc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2123 | wrapmask = ch->rxbufsize - 1; |
| 2124 | |
| 2125 | /* --------------------------------------------------------------------- |
| 2126 | Get the head and tail pointers to the receiver queue. Wrap the |
| 2127 | head pointer if it has reached the end of the buffer. |
| 2128 | ------------------------------------------------------------------------ */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2129 | head = readw(&bc->rin); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2130 | head &= wrapmask; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2131 | tail = readw(&bc->rout) & wrapmask; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2132 | |
| 2133 | bytesAvailable = (head - tail) & wrapmask; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2134 | if (bytesAvailable == 0) |
| 2135 | return; |
| 2136 | |
| 2137 | /* ------------------------------------------------------------------ |
| 2138 | If CREAD bit is off or device not open, set TX tail to head |
| 2139 | --------------------------------------------------------------------- */ |
| 2140 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2141 | if (!tty || !ts || !(ts->c_cflag & CREAD)) { |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 2142 | writew(head, &bc->rout); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2143 | return; |
| 2144 | } |
| 2145 | |
Alan Cox | 33f0f88 | 2006-01-09 20:54:13 -0800 | [diff] [blame] | 2146 | if (tty_buffer_request_room(tty, bytesAvailable + 1) == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2147 | return; |
| 2148 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2149 | if (readb(&bc->orun)) { |
| 2150 | writeb(0, &bc->orun); |
| 2151 | printk(KERN_WARNING "epca; overrun! DigiBoard device %s\n",tty->name); |
Alan Cox | 33f0f88 | 2006-01-09 20:54:13 -0800 | [diff] [blame] | 2152 | tty_insert_flip_char(tty, 0, TTY_OVERRUN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2153 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2154 | rxwinon(ch); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2155 | while (bytesAvailable > 0) { /* Begin while there is data on the card */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2156 | wrapgap = (head >= tail) ? head - tail : ch->rxbufsize - tail; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2157 | /* --------------------------------------------------------------- |
| 2158 | Even if head has wrapped around only report the amount of |
| 2159 | data to be equal to the size - tail. Remember memcpy can't |
| 2160 | automaticly wrap around the receive buffer. |
| 2161 | ----------------------------------------------------------------- */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2162 | dataToRead = (wrapgap < bytesAvailable) ? wrapgap : bytesAvailable; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2163 | /* -------------------------------------------------------------- |
| 2164 | Make sure we don't overflow the buffer |
| 2165 | ----------------------------------------------------------------- */ |
Alan Cox | 33f0f88 | 2006-01-09 20:54:13 -0800 | [diff] [blame] | 2166 | dataToRead = tty_prepare_flip_string(tty, &rptr, dataToRead); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2167 | if (dataToRead == 0) |
| 2168 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2169 | /* --------------------------------------------------------------- |
| 2170 | Move data read from our card into the line disciplines buffer |
| 2171 | for translation if necessary. |
| 2172 | ------------------------------------------------------------------ */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2173 | memcpy_fromio(rptr, ch->rxptr + tail, dataToRead); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2174 | tail = (tail + dataToRead) & wrapmask; |
| 2175 | bytesAvailable -= dataToRead; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2176 | } /* End while there is data on the card */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2177 | globalwinon(ch); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2178 | writew(tail, &bc->rout); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2179 | /* Must be called with global data */ |
| 2180 | tty_schedule_flip(ch->tty); |
| 2181 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2182 | } /* End receive_data */ |
| 2183 | |
| 2184 | static int info_ioctl(struct tty_struct *tty, struct file * file, |
| 2185 | unsigned int cmd, unsigned long arg) |
| 2186 | { |
| 2187 | switch (cmd) |
| 2188 | { /* Begin switch cmd */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2189 | case DIGI_GETINFO: |
| 2190 | { /* Begin case DIGI_GETINFO */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2191 | struct digi_info di ; |
| 2192 | int brd; |
| 2193 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2194 | if(get_user(brd, (unsigned int __user *)arg)) |
| 2195 | return -EFAULT; |
| 2196 | if (brd < 0 || brd >= num_cards || num_cards == 0) |
| 2197 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2198 | |
| 2199 | memset(&di, 0, sizeof(di)); |
| 2200 | |
| 2201 | di.board = brd ; |
| 2202 | di.status = boards[brd].status; |
| 2203 | di.type = boards[brd].type ; |
| 2204 | di.numports = boards[brd].numports ; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2205 | /* Legacy fixups - just move along nothing to see */ |
| 2206 | di.port = (unsigned char *)boards[brd].port ; |
| 2207 | di.membase = (unsigned char *)boards[brd].membase ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2208 | |
| 2209 | if (copy_to_user((void __user *)arg, &di, sizeof (di))) |
| 2210 | return -EFAULT; |
| 2211 | break; |
| 2212 | |
| 2213 | } /* End case DIGI_GETINFO */ |
| 2214 | |
| 2215 | case DIGI_POLLER: |
| 2216 | { /* Begin case DIGI_POLLER */ |
| 2217 | |
| 2218 | int brd = arg & 0xff000000 >> 16 ; |
| 2219 | unsigned char state = arg & 0xff ; |
| 2220 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2221 | if (brd < 0 || brd >= num_cards) { |
| 2222 | printk(KERN_ERR "epca: DIGI POLLER : brd not valid!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2223 | return (-ENODEV); |
| 2224 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2225 | digi_poller_inhibited = state ; |
| 2226 | break ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2227 | } /* End case DIGI_POLLER */ |
| 2228 | |
| 2229 | case DIGI_INIT: |
| 2230 | { /* Begin case DIGI_INIT */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2231 | /* ------------------------------------------------------------ |
| 2232 | This call is made by the apps to complete the initilization |
| 2233 | of the board(s). This routine is responsible for setting |
| 2234 | the card to its initial state and setting the drivers control |
| 2235 | fields to the sutianle settings for the card in question. |
| 2236 | ---------------------------------------------------------------- */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2237 | int crd ; |
| 2238 | for (crd = 0; crd < num_cards; crd++) |
| 2239 | post_fep_init (crd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2240 | break ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2241 | } /* End case DIGI_INIT */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2242 | default: |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2243 | return -ENOTTY; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2244 | } /* End switch cmd */ |
| 2245 | return (0) ; |
| 2246 | } |
| 2247 | /* --------------------- Begin pc_ioctl ----------------------- */ |
| 2248 | |
| 2249 | static int pc_tiocmget(struct tty_struct *tty, struct file *file) |
| 2250 | { |
| 2251 | struct channel *ch = (struct channel *) tty->driver_data; |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 2252 | struct board_chan __iomem *bc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2253 | unsigned int mstat, mflag = 0; |
| 2254 | unsigned long flags; |
| 2255 | |
| 2256 | if (ch) |
| 2257 | bc = ch->brdchan; |
| 2258 | else |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2259 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2260 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2261 | spin_lock_irqsave(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2262 | globalwinon(ch); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2263 | mstat = readb(&bc->mstat); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2264 | memoff(ch); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2265 | spin_unlock_irqrestore(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2266 | |
| 2267 | if (mstat & ch->m_dtr) |
| 2268 | mflag |= TIOCM_DTR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2269 | if (mstat & ch->m_rts) |
| 2270 | mflag |= TIOCM_RTS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2271 | if (mstat & ch->m_cts) |
| 2272 | mflag |= TIOCM_CTS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2273 | if (mstat & ch->dsr) |
| 2274 | mflag |= TIOCM_DSR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2275 | if (mstat & ch->m_ri) |
| 2276 | mflag |= TIOCM_RI; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2277 | if (mstat & ch->dcd) |
| 2278 | mflag |= TIOCM_CD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2279 | return mflag; |
| 2280 | } |
| 2281 | |
| 2282 | static int pc_tiocmset(struct tty_struct *tty, struct file *file, |
| 2283 | unsigned int set, unsigned int clear) |
| 2284 | { |
| 2285 | struct channel *ch = (struct channel *) tty->driver_data; |
| 2286 | unsigned long flags; |
| 2287 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2288 | if (!ch) |
| 2289 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2290 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2291 | spin_lock_irqsave(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2292 | /* |
| 2293 | * I think this modemfake stuff is broken. It doesn't |
| 2294 | * correctly reflect the behaviour desired by the TIOCM* |
| 2295 | * ioctls. Therefore this is probably broken. |
| 2296 | */ |
| 2297 | if (set & TIOCM_RTS) { |
| 2298 | ch->modemfake |= ch->m_rts; |
| 2299 | ch->modem |= ch->m_rts; |
| 2300 | } |
| 2301 | if (set & TIOCM_DTR) { |
| 2302 | ch->modemfake |= ch->m_dtr; |
| 2303 | ch->modem |= ch->m_dtr; |
| 2304 | } |
| 2305 | if (clear & TIOCM_RTS) { |
| 2306 | ch->modemfake |= ch->m_rts; |
| 2307 | ch->modem &= ~ch->m_rts; |
| 2308 | } |
| 2309 | if (clear & TIOCM_DTR) { |
| 2310 | ch->modemfake |= ch->m_dtr; |
| 2311 | ch->modem &= ~ch->m_dtr; |
| 2312 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2313 | globalwinon(ch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2314 | /* -------------------------------------------------------------- |
| 2315 | The below routine generally sets up parity, baud, flow control |
| 2316 | issues, etc.... It effect both control flags and input flags. |
| 2317 | ------------------------------------------------------------------ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2318 | epcaparam(tty,ch); |
| 2319 | memoff(ch); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2320 | spin_unlock_irqrestore(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2321 | return 0; |
| 2322 | } |
| 2323 | |
| 2324 | static int pc_ioctl(struct tty_struct *tty, struct file * file, |
| 2325 | unsigned int cmd, unsigned long arg) |
| 2326 | { /* Begin pc_ioctl */ |
| 2327 | |
| 2328 | digiflow_t dflow; |
| 2329 | int retval; |
| 2330 | unsigned long flags; |
| 2331 | unsigned int mflag, mstat; |
| 2332 | unsigned char startc, stopc; |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 2333 | struct board_chan __iomem *bc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2334 | struct channel *ch = (struct channel *) tty->driver_data; |
| 2335 | void __user *argp = (void __user *)arg; |
| 2336 | |
| 2337 | if (ch) |
| 2338 | bc = ch->brdchan; |
| 2339 | else |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2340 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2341 | |
| 2342 | /* ------------------------------------------------------------------- |
| 2343 | For POSIX compliance we need to add more ioctls. See tty_ioctl.c |
| 2344 | in /usr/src/linux/drivers/char for a good example. In particular |
| 2345 | think about adding TCSETAF, TCSETAW, TCSETA, TCSETSF, TCSETSW, TCSETS. |
| 2346 | ---------------------------------------------------------------------- */ |
| 2347 | |
| 2348 | switch (cmd) |
| 2349 | { /* Begin switch cmd */ |
| 2350 | |
| 2351 | case TCGETS: |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2352 | if (copy_to_user(argp, tty->termios, sizeof(struct termios))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2353 | return -EFAULT; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2354 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2355 | case TCGETA: |
| 2356 | return get_termio(tty, argp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2357 | case TCSBRK: /* SVID version: non-zero arg --> no break */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2358 | retval = tty_check_change(tty); |
| 2359 | if (retval) |
| 2360 | return retval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2361 | /* Setup an event to indicate when the transmit buffer empties */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2362 | spin_lock_irqsave(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2363 | setup_empty_event(tty,ch); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2364 | spin_unlock_irqrestore(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2365 | tty_wait_until_sent(tty, 0); |
| 2366 | if (!arg) |
| 2367 | digi_send_break(ch, HZ/4); /* 1/4 second */ |
| 2368 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2369 | case TCSBRKP: /* support for POSIX tcsendbreak() */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2370 | retval = tty_check_change(tty); |
| 2371 | if (retval) |
| 2372 | return retval; |
| 2373 | |
| 2374 | /* Setup an event to indicate when the transmit buffer empties */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2375 | spin_lock_irqsave(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2376 | setup_empty_event(tty,ch); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2377 | spin_unlock_irqrestore(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2378 | tty_wait_until_sent(tty, 0); |
| 2379 | digi_send_break(ch, arg ? arg*(HZ/10) : HZ/4); |
| 2380 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2381 | case TIOCGSOFTCAR: |
| 2382 | if (put_user(C_CLOCAL(tty)?1:0, (unsigned long __user *)arg)) |
| 2383 | return -EFAULT; |
| 2384 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2385 | case TIOCSSOFTCAR: |
| 2386 | { |
| 2387 | unsigned int value; |
| 2388 | |
| 2389 | if (get_user(value, (unsigned __user *)argp)) |
| 2390 | return -EFAULT; |
| 2391 | tty->termios->c_cflag = |
| 2392 | ((tty->termios->c_cflag & ~CLOCAL) | |
| 2393 | (value ? CLOCAL : 0)); |
| 2394 | return 0; |
| 2395 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2396 | case TIOCMODG: |
| 2397 | mflag = pc_tiocmget(tty, file); |
| 2398 | if (put_user(mflag, (unsigned long __user *)argp)) |
| 2399 | return -EFAULT; |
| 2400 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2401 | case TIOCMODS: |
| 2402 | if (get_user(mstat, (unsigned __user *)argp)) |
| 2403 | return -EFAULT; |
| 2404 | return pc_tiocmset(tty, file, mstat, ~mstat); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2405 | case TIOCSDTR: |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2406 | spin_lock_irqsave(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2407 | ch->omodem |= ch->m_dtr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2408 | globalwinon(ch); |
| 2409 | fepcmd(ch, SETMODEM, ch->m_dtr, 0, 10, 1); |
| 2410 | memoff(ch); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2411 | spin_unlock_irqrestore(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2412 | break; |
| 2413 | |
| 2414 | case TIOCCDTR: |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2415 | spin_lock_irqsave(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2416 | ch->omodem &= ~ch->m_dtr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2417 | globalwinon(ch); |
| 2418 | fepcmd(ch, SETMODEM, 0, ch->m_dtr, 10, 1); |
| 2419 | memoff(ch); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2420 | spin_unlock_irqrestore(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2421 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2422 | case DIGI_GETA: |
| 2423 | if (copy_to_user(argp, &ch->digiext, sizeof(digi_t))) |
| 2424 | return -EFAULT; |
| 2425 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2426 | case DIGI_SETAW: |
| 2427 | case DIGI_SETAF: |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2428 | if (cmd == DIGI_SETAW) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2429 | /* Setup an event to indicate when the transmit buffer empties */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2430 | spin_lock_irqsave(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2431 | setup_empty_event(tty,ch); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2432 | spin_unlock_irqrestore(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2433 | tty_wait_until_sent(tty, 0); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2434 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2435 | /* ldisc lock already held in ioctl */ |
| 2436 | if (tty->ldisc.flush_buffer) |
| 2437 | tty->ldisc.flush_buffer(tty); |
| 2438 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2439 | /* Fall Thru */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2440 | case DIGI_SETA: |
| 2441 | if (copy_from_user(&ch->digiext, argp, sizeof(digi_t))) |
| 2442 | return -EFAULT; |
| 2443 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2444 | if (ch->digiext.digi_flags & DIGI_ALTPIN) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2445 | ch->dcd = ch->m_dsr; |
| 2446 | ch->dsr = ch->m_dcd; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2447 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2448 | ch->dcd = ch->m_dcd; |
| 2449 | ch->dsr = ch->m_dsr; |
| 2450 | } |
| 2451 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2452 | spin_lock_irqsave(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2453 | globalwinon(ch); |
| 2454 | |
| 2455 | /* ----------------------------------------------------------------- |
| 2456 | The below routine generally sets up parity, baud, flow control |
| 2457 | issues, etc.... It effect both control flags and input flags. |
| 2458 | ------------------------------------------------------------------- */ |
| 2459 | |
| 2460 | epcaparam(tty,ch); |
| 2461 | memoff(ch); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2462 | spin_unlock_irqrestore(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2463 | break; |
| 2464 | |
| 2465 | case DIGI_GETFLOW: |
| 2466 | case DIGI_GETAFLOW: |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2467 | spin_lock_irqsave(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2468 | globalwinon(ch); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2469 | if (cmd == DIGI_GETFLOW) { |
| 2470 | dflow.startc = readb(&bc->startc); |
| 2471 | dflow.stopc = readb(&bc->stopc); |
| 2472 | } else { |
| 2473 | dflow.startc = readb(&bc->startca); |
| 2474 | dflow.stopc = readb(&bc->stopca); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2475 | } |
| 2476 | memoff(ch); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2477 | spin_unlock_irqrestore(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2478 | |
| 2479 | if (copy_to_user(argp, &dflow, sizeof(dflow))) |
| 2480 | return -EFAULT; |
| 2481 | break; |
| 2482 | |
| 2483 | case DIGI_SETAFLOW: |
| 2484 | case DIGI_SETFLOW: |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2485 | if (cmd == DIGI_SETFLOW) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2486 | startc = ch->startc; |
| 2487 | stopc = ch->stopc; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2488 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2489 | startc = ch->startca; |
| 2490 | stopc = ch->stopca; |
| 2491 | } |
| 2492 | |
| 2493 | if (copy_from_user(&dflow, argp, sizeof(dflow))) |
| 2494 | return -EFAULT; |
| 2495 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2496 | if (dflow.startc != startc || dflow.stopc != stopc) { /* Begin if setflow toggled */ |
| 2497 | spin_lock_irqsave(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2498 | globalwinon(ch); |
| 2499 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2500 | if (cmd == DIGI_SETFLOW) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2501 | ch->fepstartc = ch->startc = dflow.startc; |
| 2502 | ch->fepstopc = ch->stopc = dflow.stopc; |
| 2503 | fepcmd(ch, SONOFFC, ch->fepstartc, ch->fepstopc, 0, 1); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2504 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2505 | ch->fepstartca = ch->startca = dflow.startc; |
| 2506 | ch->fepstopca = ch->stopca = dflow.stopc; |
| 2507 | fepcmd(ch, SAUXONOFFC, ch->fepstartca, ch->fepstopca, 0, 1); |
| 2508 | } |
| 2509 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2510 | if (ch->statusflags & TXSTOPPED) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2511 | pc_start(tty); |
| 2512 | |
| 2513 | memoff(ch); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2514 | spin_unlock_irqrestore(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2515 | } /* End if setflow toggled */ |
| 2516 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2517 | default: |
| 2518 | return -ENOIOCTLCMD; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2519 | } /* End switch cmd */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2520 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2521 | } /* End pc_ioctl */ |
| 2522 | |
| 2523 | /* --------------------- Begin pc_set_termios ----------------------- */ |
| 2524 | |
| 2525 | static void pc_set_termios(struct tty_struct *tty, struct termios *old_termios) |
| 2526 | { /* Begin pc_set_termios */ |
| 2527 | |
| 2528 | struct channel *ch; |
| 2529 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2530 | /* --------------------------------------------------------- |
| 2531 | verifyChannel returns the channel from the tty struct |
| 2532 | if it is valid. This serves as a sanity check. |
| 2533 | ------------------------------------------------------------- */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2534 | if ((ch = verifyChannel(tty)) != NULL) { /* Begin if channel valid */ |
| 2535 | spin_lock_irqsave(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2536 | globalwinon(ch); |
| 2537 | epcaparam(tty, ch); |
| 2538 | memoff(ch); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2539 | spin_unlock_irqrestore(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2540 | |
| 2541 | if ((old_termios->c_cflag & CRTSCTS) && |
| 2542 | ((tty->termios->c_cflag & CRTSCTS) == 0)) |
| 2543 | tty->hw_stopped = 0; |
| 2544 | |
| 2545 | if (!(old_termios->c_cflag & CLOCAL) && |
| 2546 | (tty->termios->c_cflag & CLOCAL)) |
| 2547 | wake_up_interruptible(&ch->open_wait); |
| 2548 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2549 | } /* End if channel valid */ |
| 2550 | |
| 2551 | } /* End pc_set_termios */ |
| 2552 | |
| 2553 | /* --------------------- Begin do_softint ----------------------- */ |
| 2554 | |
| 2555 | static void do_softint(void *private_) |
| 2556 | { /* Begin do_softint */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2557 | struct channel *ch = (struct channel *) private_; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2558 | /* Called in response to a modem change event */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2559 | if (ch && ch->magic == EPCA_MAGIC) { /* Begin EPCA_MAGIC */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2560 | struct tty_struct *tty = ch->tty; |
| 2561 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2562 | if (tty && tty->driver_data) { |
| 2563 | if (test_and_clear_bit(EPCA_EVENT_HANGUP, &ch->event)) { /* Begin if clear_bit */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2564 | tty_hangup(tty); /* FIXME: module removal race here - AKPM */ |
| 2565 | wake_up_interruptible(&ch->open_wait); |
| 2566 | ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2567 | } /* End if clear_bit */ |
| 2568 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2569 | } /* End EPCA_MAGIC */ |
| 2570 | } /* End do_softint */ |
| 2571 | |
| 2572 | /* ------------------------------------------------------------ |
| 2573 | pc_stop and pc_start provide software flow control to the |
| 2574 | routine and the pc_ioctl routine. |
| 2575 | ---------------------------------------------------------------- */ |
| 2576 | |
| 2577 | /* --------------------- Begin pc_stop ----------------------- */ |
| 2578 | |
| 2579 | static void pc_stop(struct tty_struct *tty) |
| 2580 | { /* Begin pc_stop */ |
| 2581 | |
| 2582 | struct channel *ch; |
| 2583 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2584 | /* --------------------------------------------------------- |
| 2585 | verifyChannel returns the channel from the tty struct |
| 2586 | if it is valid. This serves as a sanity check. |
| 2587 | ------------------------------------------------------------- */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2588 | if ((ch = verifyChannel(tty)) != NULL) { /* Begin if valid channel */ |
| 2589 | spin_lock_irqsave(&epca_lock, flags); |
| 2590 | if ((ch->statusflags & TXSTOPPED) == 0) { /* Begin if transmit stop requested */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2591 | globalwinon(ch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2592 | /* STOP transmitting now !! */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2593 | fepcmd(ch, PAUSETX, 0, 0, 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2594 | ch->statusflags |= TXSTOPPED; |
| 2595 | memoff(ch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2596 | } /* End if transmit stop requested */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2597 | spin_unlock_irqrestore(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2598 | } /* End if valid channel */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2599 | } /* End pc_stop */ |
| 2600 | |
| 2601 | /* --------------------- Begin pc_start ----------------------- */ |
| 2602 | |
| 2603 | static void pc_start(struct tty_struct *tty) |
| 2604 | { /* Begin pc_start */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2605 | struct channel *ch; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2606 | /* --------------------------------------------------------- |
| 2607 | verifyChannel returns the channel from the tty struct |
| 2608 | if it is valid. This serves as a sanity check. |
| 2609 | ------------------------------------------------------------- */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2610 | if ((ch = verifyChannel(tty)) != NULL) { /* Begin if channel valid */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2611 | unsigned long flags; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2612 | spin_lock_irqsave(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2613 | /* Just in case output was resumed because of a change in Digi-flow */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2614 | if (ch->statusflags & TXSTOPPED) { /* Begin transmit resume requested */ |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 2615 | struct board_chan __iomem *bc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2616 | globalwinon(ch); |
| 2617 | bc = ch->brdchan; |
| 2618 | if (ch->statusflags & LOWWAIT) |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2619 | writeb(1, &bc->ilow); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2620 | /* Okay, you can start transmitting again... */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2621 | fepcmd(ch, RESUMETX, 0, 0, 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2622 | ch->statusflags &= ~TXSTOPPED; |
| 2623 | memoff(ch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2624 | } /* End transmit resume requested */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2625 | spin_unlock_irqrestore(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2626 | } /* End if channel valid */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2627 | } /* End pc_start */ |
| 2628 | |
| 2629 | /* ------------------------------------------------------------------ |
| 2630 | The below routines pc_throttle and pc_unthrottle are used |
| 2631 | to slow (And resume) the receipt of data into the kernels |
| 2632 | receive buffers. The exact occurrence of this depends on the |
| 2633 | size of the kernels receive buffer and what the 'watermarks' |
| 2634 | are set to for that buffer. See the n_ttys.c file for more |
| 2635 | details. |
| 2636 | ______________________________________________________________________ */ |
| 2637 | /* --------------------- Begin throttle ----------------------- */ |
| 2638 | |
| 2639 | static void pc_throttle(struct tty_struct * tty) |
| 2640 | { /* Begin pc_throttle */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2641 | struct channel *ch; |
| 2642 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2643 | /* --------------------------------------------------------- |
| 2644 | verifyChannel returns the channel from the tty struct |
| 2645 | if it is valid. This serves as a sanity check. |
| 2646 | ------------------------------------------------------------- */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2647 | if ((ch = verifyChannel(tty)) != NULL) { /* Begin if channel valid */ |
| 2648 | spin_lock_irqsave(&epca_lock, flags); |
| 2649 | if ((ch->statusflags & RXSTOPPED) == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2650 | globalwinon(ch); |
| 2651 | fepcmd(ch, PAUSERX, 0, 0, 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2652 | ch->statusflags |= RXSTOPPED; |
| 2653 | memoff(ch); |
| 2654 | } |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2655 | spin_unlock_irqrestore(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2656 | } /* End if channel valid */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2657 | } /* End pc_throttle */ |
| 2658 | |
| 2659 | /* --------------------- Begin unthrottle ----------------------- */ |
| 2660 | |
| 2661 | static void pc_unthrottle(struct tty_struct *tty) |
| 2662 | { /* Begin pc_unthrottle */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2663 | struct channel *ch; |
| 2664 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2665 | /* --------------------------------------------------------- |
| 2666 | verifyChannel returns the channel from the tty struct |
| 2667 | if it is valid. This serves as a sanity check. |
| 2668 | ------------------------------------------------------------- */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2669 | if ((ch = verifyChannel(tty)) != NULL) { /* Begin if channel valid */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2670 | /* Just in case output was resumed because of a change in Digi-flow */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2671 | spin_lock_irqsave(&epca_lock, flags); |
| 2672 | if (ch->statusflags & RXSTOPPED) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2673 | globalwinon(ch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2674 | fepcmd(ch, RESUMERX, 0, 0, 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2675 | ch->statusflags &= ~RXSTOPPED; |
| 2676 | memoff(ch); |
| 2677 | } |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2678 | spin_unlock_irqrestore(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2679 | } /* End if channel valid */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2680 | } /* End pc_unthrottle */ |
| 2681 | |
| 2682 | /* --------------------- Begin digi_send_break ----------------------- */ |
| 2683 | |
| 2684 | void digi_send_break(struct channel *ch, int msec) |
| 2685 | { /* Begin digi_send_break */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2686 | unsigned long flags; |
| 2687 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2688 | spin_lock_irqsave(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2689 | globalwinon(ch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2690 | /* -------------------------------------------------------------------- |
| 2691 | Maybe I should send an infinite break here, schedule() for |
| 2692 | msec amount of time, and then stop the break. This way, |
| 2693 | the user can't screw up the FEP by causing digi_send_break() |
| 2694 | to be called (i.e. via an ioctl()) more than once in msec amount |
| 2695 | of time. Try this for now... |
| 2696 | ------------------------------------------------------------------------ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2697 | fepcmd(ch, SENDBREAK, msec, 0, 10, 0); |
| 2698 | memoff(ch); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2699 | spin_unlock_irqrestore(&epca_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2700 | } /* End digi_send_break */ |
| 2701 | |
| 2702 | /* --------------------- Begin setup_empty_event ----------------------- */ |
| 2703 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2704 | /* Caller MUST hold the lock */ |
| 2705 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2706 | static void setup_empty_event(struct tty_struct *tty, struct channel *ch) |
| 2707 | { /* Begin setup_empty_event */ |
| 2708 | |
Al Viro | bc9a515 | 2005-09-15 22:53:28 +0100 | [diff] [blame] | 2709 | struct board_chan __iomem *bc = ch->brdchan; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2710 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2711 | globalwinon(ch); |
| 2712 | ch->statusflags |= EMPTYWAIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2713 | /* ------------------------------------------------------------------ |
| 2714 | When set the iempty flag request a event to be generated when the |
| 2715 | transmit buffer is empty (If there is no BREAK in progress). |
| 2716 | --------------------------------------------------------------------- */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2717 | writeb(1, &bc->iempty); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2718 | memoff(ch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2719 | } /* End setup_empty_event */ |
| 2720 | |
| 2721 | /* --------------------- Begin get_termio ----------------------- */ |
| 2722 | |
| 2723 | static int get_termio(struct tty_struct * tty, struct termio __user * termio) |
| 2724 | { /* Begin get_termio */ |
| 2725 | return kernel_termios_to_user_termio(termio, tty->termios); |
| 2726 | } /* End get_termio */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2727 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2728 | /* ---------------------- Begin epca_setup -------------------------- */ |
| 2729 | void epca_setup(char *str, int *ints) |
| 2730 | { /* Begin epca_setup */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2731 | struct board_info board; |
| 2732 | int index, loop, last; |
| 2733 | char *temp, *t2; |
| 2734 | unsigned len; |
| 2735 | |
| 2736 | /* ---------------------------------------------------------------------- |
| 2737 | If this routine looks a little strange it is because it is only called |
| 2738 | if a LILO append command is given to boot the kernel with parameters. |
| 2739 | In this way, we can provide the user a method of changing his board |
| 2740 | configuration without rebuilding the kernel. |
| 2741 | ----------------------------------------------------------------------- */ |
| 2742 | if (!liloconfig) |
| 2743 | liloconfig = 1; |
| 2744 | |
| 2745 | memset(&board, 0, sizeof(board)); |
| 2746 | |
| 2747 | /* Assume the data is int first, later we can change it */ |
| 2748 | /* I think that array position 0 of ints holds the number of args */ |
| 2749 | for (last = 0, index = 1; index <= ints[0]; index++) |
| 2750 | switch(index) |
| 2751 | { /* Begin parse switch */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2752 | case 1: |
| 2753 | board.status = ints[index]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2754 | /* --------------------------------------------------------- |
| 2755 | We check for 2 (As opposed to 1; because 2 is a flag |
| 2756 | instructing the driver to ignore epcaconfig.) For this |
| 2757 | reason we check for 2. |
| 2758 | ------------------------------------------------------------ */ |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2759 | if (board.status == 2) { /* Begin ignore epcaconfig as well as lilo cmd line */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2760 | nbdevs = 0; |
| 2761 | num_cards = 0; |
| 2762 | return; |
| 2763 | } /* End ignore epcaconfig as well as lilo cmd line */ |
| 2764 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2765 | if (board.status > 2) { |
| 2766 | printk(KERN_ERR "epca_setup: Invalid board status 0x%x\n", board.status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2767 | invalid_lilo_config = 1; |
| 2768 | setup_error_code |= INVALID_BOARD_STATUS; |
| 2769 | return; |
| 2770 | } |
| 2771 | last = index; |
| 2772 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2773 | case 2: |
| 2774 | board.type = ints[index]; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2775 | if (board.type >= PCIXEM) { |
| 2776 | printk(KERN_ERR "epca_setup: Invalid board type 0x%x\n", board.type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2777 | invalid_lilo_config = 1; |
| 2778 | setup_error_code |= INVALID_BOARD_TYPE; |
| 2779 | return; |
| 2780 | } |
| 2781 | last = index; |
| 2782 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2783 | case 3: |
| 2784 | board.altpin = ints[index]; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2785 | if (board.altpin > 1) { |
| 2786 | printk(KERN_ERR "epca_setup: Invalid board altpin 0x%x\n", board.altpin); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2787 | invalid_lilo_config = 1; |
| 2788 | setup_error_code |= INVALID_ALTPIN; |
| 2789 | return; |
| 2790 | } |
| 2791 | last = index; |
| 2792 | break; |
| 2793 | |
| 2794 | case 4: |
| 2795 | board.numports = ints[index]; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2796 | if (board.numports < 2 || board.numports > 256) { |
| 2797 | printk(KERN_ERR "epca_setup: Invalid board numports 0x%x\n", board.numports); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2798 | invalid_lilo_config = 1; |
| 2799 | setup_error_code |= INVALID_NUM_PORTS; |
| 2800 | return; |
| 2801 | } |
| 2802 | nbdevs += board.numports; |
| 2803 | last = index; |
| 2804 | break; |
| 2805 | |
| 2806 | case 5: |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2807 | board.port = ints[index]; |
| 2808 | if (ints[index] <= 0) { |
| 2809 | printk(KERN_ERR "epca_setup: Invalid io port 0x%x\n", (unsigned int)board.port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2810 | invalid_lilo_config = 1; |
| 2811 | setup_error_code |= INVALID_PORT_BASE; |
| 2812 | return; |
| 2813 | } |
| 2814 | last = index; |
| 2815 | break; |
| 2816 | |
| 2817 | case 6: |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2818 | board.membase = ints[index]; |
| 2819 | if (ints[index] <= 0) { |
| 2820 | printk(KERN_ERR "epca_setup: Invalid memory base 0x%x\n",(unsigned int)board.membase); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2821 | invalid_lilo_config = 1; |
| 2822 | setup_error_code |= INVALID_MEM_BASE; |
| 2823 | return; |
| 2824 | } |
| 2825 | last = index; |
| 2826 | break; |
| 2827 | |
| 2828 | default: |
| 2829 | printk(KERN_ERR "<Error> - epca_setup: Too many integer parms\n"); |
| 2830 | return; |
| 2831 | |
| 2832 | } /* End parse switch */ |
| 2833 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2834 | while (str && *str) { /* Begin while there is a string arg */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2835 | /* find the next comma or terminator */ |
| 2836 | temp = str; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2837 | /* While string is not null, and a comma hasn't been found */ |
| 2838 | while (*temp && (*temp != ',')) |
| 2839 | temp++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2840 | if (!*temp) |
| 2841 | temp = NULL; |
| 2842 | else |
| 2843 | *temp++ = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2844 | /* Set index to the number of args + 1 */ |
| 2845 | index = last + 1; |
| 2846 | |
| 2847 | switch(index) |
| 2848 | { |
| 2849 | case 1: |
| 2850 | len = strlen(str); |
| 2851 | if (strncmp("Disable", str, len) == 0) |
| 2852 | board.status = 0; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2853 | else if (strncmp("Enable", str, len) == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2854 | board.status = 1; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2855 | else { |
| 2856 | printk(KERN_ERR "epca_setup: Invalid status %s\n", str); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2857 | invalid_lilo_config = 1; |
| 2858 | setup_error_code |= INVALID_BOARD_STATUS; |
| 2859 | return; |
| 2860 | } |
| 2861 | last = index; |
| 2862 | break; |
| 2863 | |
| 2864 | case 2: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2865 | for(loop = 0; loop < EPCA_NUM_TYPES; loop++) |
| 2866 | if (strcmp(board_desc[loop], str) == 0) |
| 2867 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2868 | /* --------------------------------------------------------------- |
| 2869 | If the index incremented above refers to a legitamate board |
| 2870 | type set it here. |
| 2871 | ------------------------------------------------------------------*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2872 | if (index < EPCA_NUM_TYPES) |
| 2873 | board.type = loop; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2874 | else { |
| 2875 | printk(KERN_ERR "epca_setup: Invalid board type: %s\n", str); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2876 | invalid_lilo_config = 1; |
| 2877 | setup_error_code |= INVALID_BOARD_TYPE; |
| 2878 | return; |
| 2879 | } |
| 2880 | last = index; |
| 2881 | break; |
| 2882 | |
| 2883 | case 3: |
| 2884 | len = strlen(str); |
| 2885 | if (strncmp("Disable", str, len) == 0) |
| 2886 | board.altpin = 0; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2887 | else if (strncmp("Enable", str, len) == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2888 | board.altpin = 1; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2889 | else { |
| 2890 | printk(KERN_ERR "epca_setup: Invalid altpin %s\n", str); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2891 | invalid_lilo_config = 1; |
| 2892 | setup_error_code |= INVALID_ALTPIN; |
| 2893 | return; |
| 2894 | } |
| 2895 | last = index; |
| 2896 | break; |
| 2897 | |
| 2898 | case 4: |
| 2899 | t2 = str; |
| 2900 | while (isdigit(*t2)) |
| 2901 | t2++; |
| 2902 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2903 | if (*t2) { |
| 2904 | printk(KERN_ERR "epca_setup: Invalid port count %s\n", str); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2905 | invalid_lilo_config = 1; |
| 2906 | setup_error_code |= INVALID_NUM_PORTS; |
| 2907 | return; |
| 2908 | } |
| 2909 | |
| 2910 | /* ------------------------------------------------------------ |
| 2911 | There is not a man page for simple_strtoul but the code can be |
| 2912 | found in vsprintf.c. The first argument is the string to |
| 2913 | translate (To an unsigned long obviously), the second argument |
| 2914 | can be the address of any character variable or a NULL. If a |
| 2915 | variable is given, the end pointer of the string will be stored |
| 2916 | in that variable; if a NULL is given the end pointer will |
| 2917 | not be returned. The last argument is the base to use. If |
| 2918 | a 0 is indicated, the routine will attempt to determine the |
| 2919 | proper base by looking at the values prefix (A '0' for octal, |
| 2920 | a 'x' for hex, etc ... If a value is given it will use that |
| 2921 | value as the base. |
| 2922 | ---------------------------------------------------------------- */ |
| 2923 | board.numports = simple_strtoul(str, NULL, 0); |
| 2924 | nbdevs += board.numports; |
| 2925 | last = index; |
| 2926 | break; |
| 2927 | |
| 2928 | case 5: |
| 2929 | t2 = str; |
| 2930 | while (isxdigit(*t2)) |
| 2931 | t2++; |
| 2932 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2933 | if (*t2) { |
| 2934 | printk(KERN_ERR "epca_setup: Invalid i/o address %s\n", str); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2935 | invalid_lilo_config = 1; |
| 2936 | setup_error_code |= INVALID_PORT_BASE; |
| 2937 | return; |
| 2938 | } |
| 2939 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2940 | board.port = simple_strtoul(str, NULL, 16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2941 | last = index; |
| 2942 | break; |
| 2943 | |
| 2944 | case 6: |
| 2945 | t2 = str; |
| 2946 | while (isxdigit(*t2)) |
| 2947 | t2++; |
| 2948 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2949 | if (*t2) { |
| 2950 | printk(KERN_ERR "epca_setup: Invalid memory base %s\n",str); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2951 | invalid_lilo_config = 1; |
| 2952 | setup_error_code |= INVALID_MEM_BASE; |
| 2953 | return; |
| 2954 | } |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2955 | board.membase = simple_strtoul(str, NULL, 16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2956 | last = index; |
| 2957 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2958 | default: |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2959 | printk(KERN_ERR "epca: Too many string parms\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2960 | return; |
| 2961 | } |
| 2962 | str = temp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2963 | } /* End while there is a string arg */ |
| 2964 | |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 2965 | if (last < 6) { |
| 2966 | printk(KERN_ERR "epca: Insufficient parms specified\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2967 | return; |
| 2968 | } |
| 2969 | |
| 2970 | /* I should REALLY validate the stuff here */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2971 | /* Copies our local copy of board into boards */ |
| 2972 | memcpy((void *)&boards[num_cards],(void *)&board, sizeof(board)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2973 | /* Does this get called once per lilo arg are what ? */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2974 | printk(KERN_INFO "PC/Xx: Added board %i, %s %i ports at 0x%4.4X base 0x%6.6X\n", |
| 2975 | num_cards, board_desc[board.type], |
| 2976 | board.numports, (int)board.port, (unsigned int) board.membase); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2977 | num_cards++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2978 | } /* End epca_setup */ |
| 2979 | |
| 2980 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2981 | /* ------------------------ Begin init_PCI --------------------------- */ |
| 2982 | |
| 2983 | enum epic_board_types { |
| 2984 | brd_xr = 0, |
| 2985 | brd_xem, |
| 2986 | brd_cx, |
| 2987 | brd_xrj, |
| 2988 | }; |
| 2989 | |
| 2990 | |
| 2991 | /* indexed directly by epic_board_types enum */ |
| 2992 | static struct { |
| 2993 | unsigned char board_type; |
| 2994 | unsigned bar_idx; /* PCI base address region */ |
| 2995 | } epca_info_tbl[] = { |
| 2996 | { PCIXR, 0, }, |
| 2997 | { PCIXEM, 0, }, |
| 2998 | { PCICX, 0, }, |
| 2999 | { PCIXRJ, 2, }, |
| 3000 | }; |
| 3001 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3002 | static int __devinit epca_init_one (struct pci_dev *pdev, |
| 3003 | const struct pci_device_id *ent) |
| 3004 | { |
| 3005 | static int board_num = -1; |
| 3006 | int board_idx, info_idx = ent->driver_data; |
| 3007 | unsigned long addr; |
| 3008 | |
| 3009 | if (pci_enable_device(pdev)) |
| 3010 | return -EIO; |
| 3011 | |
| 3012 | board_num++; |
| 3013 | board_idx = board_num + num_cards; |
| 3014 | if (board_idx >= MAXBOARDS) |
| 3015 | goto err_out; |
| 3016 | |
| 3017 | addr = pci_resource_start (pdev, epca_info_tbl[info_idx].bar_idx); |
| 3018 | if (!addr) { |
| 3019 | printk (KERN_ERR PFX "PCI region #%d not available (size 0)\n", |
| 3020 | epca_info_tbl[info_idx].bar_idx); |
| 3021 | goto err_out; |
| 3022 | } |
| 3023 | |
| 3024 | boards[board_idx].status = ENABLED; |
| 3025 | boards[board_idx].type = epca_info_tbl[info_idx].board_type; |
| 3026 | boards[board_idx].numports = 0x0; |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 3027 | boards[board_idx].port = addr + PCI_IO_OFFSET; |
| 3028 | boards[board_idx].membase = addr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3029 | |
| 3030 | if (!request_mem_region (addr + PCI_IO_OFFSET, 0x200000, "epca")) { |
| 3031 | printk (KERN_ERR PFX "resource 0x%x @ 0x%lx unavailable\n", |
| 3032 | 0x200000, addr + PCI_IO_OFFSET); |
| 3033 | goto err_out; |
| 3034 | } |
| 3035 | |
| 3036 | boards[board_idx].re_map_port = ioremap(addr + PCI_IO_OFFSET, 0x200000); |
| 3037 | if (!boards[board_idx].re_map_port) { |
| 3038 | printk (KERN_ERR PFX "cannot map 0x%x @ 0x%lx\n", |
| 3039 | 0x200000, addr + PCI_IO_OFFSET); |
| 3040 | goto err_out_free_pciio; |
| 3041 | } |
| 3042 | |
| 3043 | if (!request_mem_region (addr, 0x200000, "epca")) { |
| 3044 | printk (KERN_ERR PFX "resource 0x%x @ 0x%lx unavailable\n", |
| 3045 | 0x200000, addr); |
| 3046 | goto err_out_free_iounmap; |
| 3047 | } |
| 3048 | |
| 3049 | boards[board_idx].re_map_membase = ioremap(addr, 0x200000); |
| 3050 | if (!boards[board_idx].re_map_membase) { |
| 3051 | printk (KERN_ERR PFX "cannot map 0x%x @ 0x%lx\n", |
| 3052 | 0x200000, addr + PCI_IO_OFFSET); |
| 3053 | goto err_out_free_memregion; |
| 3054 | } |
| 3055 | |
| 3056 | /* -------------------------------------------------------------- |
| 3057 | I don't know what the below does, but the hardware guys say |
| 3058 | its required on everything except PLX (In this case XRJ). |
| 3059 | ---------------------------------------------------------------- */ |
| 3060 | if (info_idx != brd_xrj) { |
| 3061 | pci_write_config_byte(pdev, 0x40, 0); |
| 3062 | pci_write_config_byte(pdev, 0x46, 0); |
| 3063 | } |
| 3064 | |
| 3065 | return 0; |
| 3066 | |
| 3067 | err_out_free_memregion: |
| 3068 | release_mem_region (addr, 0x200000); |
| 3069 | err_out_free_iounmap: |
| 3070 | iounmap (boards[board_idx].re_map_port); |
| 3071 | err_out_free_pciio: |
| 3072 | release_mem_region (addr + PCI_IO_OFFSET, 0x200000); |
| 3073 | err_out: |
| 3074 | return -ENODEV; |
| 3075 | } |
| 3076 | |
| 3077 | |
| 3078 | static struct pci_device_id epca_pci_tbl[] = { |
| 3079 | { PCI_VENDOR_DIGI, PCI_DEVICE_XR, PCI_ANY_ID, PCI_ANY_ID, 0, 0, brd_xr }, |
| 3080 | { PCI_VENDOR_DIGI, PCI_DEVICE_XEM, PCI_ANY_ID, PCI_ANY_ID, 0, 0, brd_xem }, |
| 3081 | { PCI_VENDOR_DIGI, PCI_DEVICE_CX, PCI_ANY_ID, PCI_ANY_ID, 0, 0, brd_cx }, |
| 3082 | { PCI_VENDOR_DIGI, PCI_DEVICE_XRJ, PCI_ANY_ID, PCI_ANY_ID, 0, 0, brd_xrj }, |
| 3083 | { 0, } |
| 3084 | }; |
| 3085 | |
| 3086 | MODULE_DEVICE_TABLE(pci, epca_pci_tbl); |
| 3087 | |
| 3088 | int __init init_PCI (void) |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 3089 | { /* Begin init_PCI */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3090 | memset (&epca_driver, 0, sizeof (epca_driver)); |
| 3091 | epca_driver.name = "epca"; |
| 3092 | epca_driver.id_table = epca_pci_tbl; |
| 3093 | epca_driver.probe = epca_init_one; |
| 3094 | |
| 3095 | return pci_register_driver(&epca_driver); |
Alan Cox | f2cf8e2 | 2005-09-06 15:16:44 -0700 | [diff] [blame] | 3096 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3097 | |
| 3098 | MODULE_LICENSE("GPL"); |