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