Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | Keyspan USB to Serial Converter driver |
| 3 | |
| 4 | (C) Copyright (C) 2000-2001 |
| 5 | Hugh Blemings <hugh@blemings.org> |
| 6 | |
| 7 | This program is free software; you can redistribute it and/or modify |
| 8 | it under the terms of the GNU General Public License as published by |
| 9 | the Free Software Foundation; either version 2 of the License, or |
| 10 | (at your option) any later version. |
| 11 | |
Justin P. Mattock | 631dd1a | 2010-10-18 11:03:14 +0200 | [diff] [blame] | 12 | See http://blemings.org/hugh/keyspan.html for more information. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
| 14 | Code in this driver inspired by and in a number of places taken |
| 15 | from Brian Warner's original Keyspan-PDA driver. |
| 16 | |
| 17 | This driver has been put together with the support of Innosys, Inc. |
| 18 | and Keyspan, Inc the manufacturers of the Keyspan USB-serial products. |
| 19 | Thanks Guys :) |
| 20 | |
| 21 | Thanks to Paulus for miscellaneous tidy ups, some largish chunks |
| 22 | of much nicer and/or completely new code and (perhaps most uniquely) |
| 23 | having the patience to sit down and explain why and where he'd changed |
| 24 | stuff. |
| 25 | |
| 26 | Tip 'o the hat to IBM (and previously Linuxcare :) for supporting |
| 27 | staff in their work on open source projects. |
| 28 | |
| 29 | See keyspan.c for update history. |
| 30 | |
| 31 | */ |
| 32 | |
| 33 | #ifndef __LINUX_USB_SERIAL_KEYSPAN_H |
| 34 | #define __LINUX_USB_SERIAL_KEYSPAN_H |
| 35 | |
| 36 | |
| 37 | /* Function prototypes for Keyspan serial converter */ |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 38 | static int keyspan_open (struct tty_struct *tty, |
Alan Cox | a509a7e | 2009-09-19 13:13:26 -0700 | [diff] [blame] | 39 | struct usb_serial_port *port); |
Alan Cox | 335f851 | 2009-06-11 12:26:29 +0100 | [diff] [blame] | 40 | static void keyspan_close (struct usb_serial_port *port); |
| 41 | static void keyspan_dtr_rts (struct usb_serial_port *port, int on); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | static int keyspan_startup (struct usb_serial *serial); |
Alan Stern | f9c99bb | 2009-06-02 11:53:55 -0400 | [diff] [blame] | 43 | static void keyspan_disconnect (struct usb_serial *serial); |
| 44 | static void keyspan_release (struct usb_serial *serial); |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 45 | static int keyspan_write_room (struct tty_struct *tty); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 47 | static int keyspan_write (struct tty_struct *tty, |
| 48 | struct usb_serial_port *port, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | const unsigned char *buf, |
| 50 | int count); |
| 51 | |
| 52 | static void keyspan_send_setup (struct usb_serial_port *port, |
| 53 | int reset_port); |
| 54 | |
| 55 | |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 56 | static void keyspan_set_termios (struct tty_struct *tty, |
| 57 | struct usb_serial_port *port, |
Alan Cox | 606d099 | 2006-12-08 02:38:45 -0800 | [diff] [blame] | 58 | struct ktermios *old); |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 59 | static void keyspan_break_ctl (struct tty_struct *tty, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | int break_state); |
Alan Cox | 60b33c1 | 2011-02-14 16:26:14 +0000 | [diff] [blame] | 61 | static int keyspan_tiocmget (struct tty_struct *tty); |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 62 | static int keyspan_tiocmset (struct tty_struct *tty, |
Alan Cox | 20b9d17 | 2011-02-14 16:26:50 +0000 | [diff] [blame] | 63 | unsigned int set, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | unsigned int clear); |
| 65 | static int keyspan_fake_startup (struct usb_serial *serial); |
| 66 | |
| 67 | static int keyspan_usa19_calc_baud (u32 baud_rate, u32 baudclk, |
| 68 | u8 *rate_hi, u8 *rate_low, |
| 69 | u8 *prescaler, int portnum); |
| 70 | |
| 71 | static int keyspan_usa19w_calc_baud (u32 baud_rate, u32 baudclk, |
| 72 | u8 *rate_hi, u8 *rate_low, |
| 73 | u8 *prescaler, int portnum); |
| 74 | |
| 75 | static int keyspan_usa28_calc_baud (u32 baud_rate, u32 baudclk, |
| 76 | u8 *rate_hi, u8 *rate_low, |
| 77 | u8 *prescaler, int portnum); |
| 78 | |
| 79 | static int keyspan_usa19hs_calc_baud (u32 baud_rate, u32 baudclk, |
| 80 | u8 *rate_hi, u8 *rate_low, |
| 81 | u8 *prescaler, int portnum); |
| 82 | |
| 83 | static int keyspan_usa28_send_setup (struct usb_serial *serial, |
| 84 | struct usb_serial_port *port, |
| 85 | int reset_port); |
| 86 | static int keyspan_usa26_send_setup (struct usb_serial *serial, |
| 87 | struct usb_serial_port *port, |
| 88 | int reset_port); |
| 89 | static int keyspan_usa49_send_setup (struct usb_serial *serial, |
| 90 | struct usb_serial_port *port, |
| 91 | int reset_port); |
| 92 | |
| 93 | static int keyspan_usa90_send_setup (struct usb_serial *serial, |
| 94 | struct usb_serial_port *port, |
| 95 | int reset_port); |
| 96 | |
Lucy McCoy | 0ca1268 | 2007-05-18 12:10:41 -0700 | [diff] [blame] | 97 | static int keyspan_usa67_send_setup (struct usb_serial *serial, |
| 98 | struct usb_serial_port *port, |
| 99 | int reset_port); |
| 100 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | /* Values used for baud rate calculation - device specific */ |
| 102 | #define KEYSPAN_INVALID_BAUD_RATE (-1) |
| 103 | #define KEYSPAN_BAUD_RATE_OK (0) |
| 104 | #define KEYSPAN_USA18X_BAUDCLK (12000000L) /* a guess */ |
| 105 | #define KEYSPAN_USA19_BAUDCLK (12000000L) |
| 106 | #define KEYSPAN_USA19W_BAUDCLK (24000000L) |
| 107 | #define KEYSPAN_USA19HS_BAUDCLK (14769231L) |
| 108 | #define KEYSPAN_USA28_BAUDCLK (1843200L) |
| 109 | #define KEYSPAN_USA28X_BAUDCLK (12000000L) |
| 110 | #define KEYSPAN_USA49W_BAUDCLK (48000000L) |
| 111 | |
| 112 | /* Some constants used to characterise each device. */ |
| 113 | #define KEYSPAN_MAX_NUM_PORTS (4) |
| 114 | #define KEYSPAN_MAX_FLIPS (2) |
| 115 | |
| 116 | /* Device info for the Keyspan serial converter, used |
| 117 | by the overall usb-serial probe function */ |
| 118 | #define KEYSPAN_VENDOR_ID (0x06cd) |
| 119 | |
| 120 | /* Product IDs for the products supported, pre-renumeration */ |
| 121 | #define keyspan_usa18x_pre_product_id 0x0105 |
| 122 | #define keyspan_usa19_pre_product_id 0x0103 |
| 123 | #define keyspan_usa19qi_pre_product_id 0x010b |
| 124 | #define keyspan_mpr_pre_product_id 0x011b |
| 125 | #define keyspan_usa19qw_pre_product_id 0x0118 |
| 126 | #define keyspan_usa19w_pre_product_id 0x0106 |
| 127 | #define keyspan_usa28_pre_product_id 0x0101 |
| 128 | #define keyspan_usa28x_pre_product_id 0x0102 |
| 129 | #define keyspan_usa28xa_pre_product_id 0x0114 |
| 130 | #define keyspan_usa28xb_pre_product_id 0x0113 |
| 131 | #define keyspan_usa49w_pre_product_id 0x0109 |
| 132 | #define keyspan_usa49wlc_pre_product_id 0x011a |
| 133 | |
| 134 | /* Product IDs post-renumeration. Note that the 28x and 28xb |
| 135 | have the same id's post-renumeration but behave identically |
Ben Collins | 188d636 | 2008-06-26 20:08:16 -0400 | [diff] [blame] | 136 | so it's not an issue. As such, the 28xb is not listed in any |
| 137 | of the device tables. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | #define keyspan_usa18x_product_id 0x0112 |
| 139 | #define keyspan_usa19_product_id 0x0107 |
| 140 | #define keyspan_usa19qi_product_id 0x010c |
| 141 | #define keyspan_usa19hs_product_id 0x0121 |
| 142 | #define keyspan_mpr_product_id 0x011c |
| 143 | #define keyspan_usa19qw_product_id 0x0119 |
| 144 | #define keyspan_usa19w_product_id 0x0108 |
| 145 | #define keyspan_usa28_product_id 0x010f |
| 146 | #define keyspan_usa28x_product_id 0x0110 |
| 147 | #define keyspan_usa28xa_product_id 0x0115 |
Lucy McCoy | 0ca1268 | 2007-05-18 12:10:41 -0700 | [diff] [blame] | 148 | #define keyspan_usa28xb_product_id 0x0110 |
| 149 | #define keyspan_usa28xg_product_id 0x0135 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | #define keyspan_usa49w_product_id 0x010a |
| 151 | #define keyspan_usa49wlc_product_id 0x012a |
Lucy McCoy | 0ca1268 | 2007-05-18 12:10:41 -0700 | [diff] [blame] | 152 | #define keyspan_usa49wg_product_id 0x0131 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | |
| 154 | struct keyspan_device_details { |
| 155 | /* product ID value */ |
| 156 | int product_id; |
| 157 | |
Lucy McCoy | 0ca1268 | 2007-05-18 12:10:41 -0700 | [diff] [blame] | 158 | enum {msg_usa26, msg_usa28, msg_usa49, msg_usa90, msg_usa67} msg_format; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | |
| 160 | /* Number of physical ports */ |
| 161 | int num_ports; |
| 162 | |
| 163 | /* 1 if endpoint flipping used on input, 0 if not */ |
| 164 | int indat_endp_flip; |
| 165 | |
| 166 | /* 1 if endpoint flipping used on output, 0 if not */ |
| 167 | int outdat_endp_flip; |
| 168 | |
| 169 | /* Table mapping input data endpoint IDs to physical |
| 170 | port number and flip if used */ |
| 171 | int indat_endpoints[KEYSPAN_MAX_NUM_PORTS]; |
| 172 | |
| 173 | /* Same for output endpoints */ |
| 174 | int outdat_endpoints[KEYSPAN_MAX_NUM_PORTS]; |
| 175 | |
| 176 | /* Input acknowledge endpoints */ |
| 177 | int inack_endpoints[KEYSPAN_MAX_NUM_PORTS]; |
| 178 | |
| 179 | /* Output control endpoints */ |
| 180 | int outcont_endpoints[KEYSPAN_MAX_NUM_PORTS]; |
| 181 | |
| 182 | /* Endpoint used for input status */ |
| 183 | int instat_endpoint; |
| 184 | |
Lucy McCoy | 0ca1268 | 2007-05-18 12:10:41 -0700 | [diff] [blame] | 185 | /* Endpoint used for input data 49WG only */ |
| 186 | int indat_endpoint; |
| 187 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | /* Endpoint used for global control functions */ |
| 189 | int glocont_endpoint; |
| 190 | |
| 191 | int (*calculate_baud_rate) (u32 baud_rate, u32 baudclk, |
| 192 | u8 *rate_hi, u8 *rate_low, u8 *prescaler, int portnum); |
| 193 | u32 baudclk; |
| 194 | }; |
| 195 | |
| 196 | /* Now for each device type we setup the device detail |
| 197 | structure with the appropriate information (provided |
| 198 | in Keyspan's documentation) */ |
| 199 | |
| 200 | static const struct keyspan_device_details usa18x_device_details = { |
| 201 | .product_id = keyspan_usa18x_product_id, |
| 202 | .msg_format = msg_usa26, |
| 203 | .num_ports = 1, |
| 204 | .indat_endp_flip = 0, |
| 205 | .outdat_endp_flip = 1, |
| 206 | .indat_endpoints = {0x81}, |
| 207 | .outdat_endpoints = {0x01}, |
| 208 | .inack_endpoints = {0x85}, |
| 209 | .outcont_endpoints = {0x05}, |
| 210 | .instat_endpoint = 0x87, |
Lucy McCoy | 0ca1268 | 2007-05-18 12:10:41 -0700 | [diff] [blame] | 211 | .indat_endpoint = -1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | .glocont_endpoint = 0x07, |
| 213 | .calculate_baud_rate = keyspan_usa19w_calc_baud, |
| 214 | .baudclk = KEYSPAN_USA18X_BAUDCLK, |
| 215 | }; |
| 216 | |
| 217 | static const struct keyspan_device_details usa19_device_details = { |
| 218 | .product_id = keyspan_usa19_product_id, |
| 219 | .msg_format = msg_usa28, |
| 220 | .num_ports = 1, |
| 221 | .indat_endp_flip = 1, |
| 222 | .outdat_endp_flip = 1, |
| 223 | .indat_endpoints = {0x81}, |
| 224 | .outdat_endpoints = {0x01}, |
| 225 | .inack_endpoints = {0x83}, |
| 226 | .outcont_endpoints = {0x03}, |
| 227 | .instat_endpoint = 0x84, |
Lucy McCoy | 0ca1268 | 2007-05-18 12:10:41 -0700 | [diff] [blame] | 228 | .indat_endpoint = -1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | .glocont_endpoint = -1, |
| 230 | .calculate_baud_rate = keyspan_usa19_calc_baud, |
| 231 | .baudclk = KEYSPAN_USA19_BAUDCLK, |
| 232 | }; |
| 233 | |
| 234 | static const struct keyspan_device_details usa19qi_device_details = { |
| 235 | .product_id = keyspan_usa19qi_product_id, |
| 236 | .msg_format = msg_usa28, |
| 237 | .num_ports = 1, |
| 238 | .indat_endp_flip = 1, |
| 239 | .outdat_endp_flip = 1, |
| 240 | .indat_endpoints = {0x81}, |
| 241 | .outdat_endpoints = {0x01}, |
| 242 | .inack_endpoints = {0x83}, |
| 243 | .outcont_endpoints = {0x03}, |
| 244 | .instat_endpoint = 0x84, |
Lucy McCoy | 0ca1268 | 2007-05-18 12:10:41 -0700 | [diff] [blame] | 245 | .indat_endpoint = -1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | .glocont_endpoint = -1, |
| 247 | .calculate_baud_rate = keyspan_usa28_calc_baud, |
| 248 | .baudclk = KEYSPAN_USA19_BAUDCLK, |
| 249 | }; |
| 250 | |
| 251 | static const struct keyspan_device_details mpr_device_details = { |
| 252 | .product_id = keyspan_mpr_product_id, |
| 253 | .msg_format = msg_usa28, |
| 254 | .num_ports = 1, |
| 255 | .indat_endp_flip = 1, |
| 256 | .outdat_endp_flip = 1, |
| 257 | .indat_endpoints = {0x81}, |
| 258 | .outdat_endpoints = {0x01}, |
| 259 | .inack_endpoints = {0x83}, |
| 260 | .outcont_endpoints = {0x03}, |
| 261 | .instat_endpoint = 0x84, |
Lucy McCoy | 0ca1268 | 2007-05-18 12:10:41 -0700 | [diff] [blame] | 262 | .indat_endpoint = -1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | .glocont_endpoint = -1, |
| 264 | .calculate_baud_rate = keyspan_usa28_calc_baud, |
| 265 | .baudclk = KEYSPAN_USA19_BAUDCLK, |
| 266 | }; |
| 267 | |
| 268 | static const struct keyspan_device_details usa19qw_device_details = { |
| 269 | .product_id = keyspan_usa19qw_product_id, |
| 270 | .msg_format = msg_usa26, |
| 271 | .num_ports = 1, |
| 272 | .indat_endp_flip = 0, |
| 273 | .outdat_endp_flip = 1, |
| 274 | .indat_endpoints = {0x81}, |
| 275 | .outdat_endpoints = {0x01}, |
| 276 | .inack_endpoints = {0x85}, |
| 277 | .outcont_endpoints = {0x05}, |
| 278 | .instat_endpoint = 0x87, |
Lucy McCoy | 0ca1268 | 2007-05-18 12:10:41 -0700 | [diff] [blame] | 279 | .indat_endpoint = -1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | .glocont_endpoint = 0x07, |
| 281 | .calculate_baud_rate = keyspan_usa19w_calc_baud, |
| 282 | .baudclk = KEYSPAN_USA19W_BAUDCLK, |
| 283 | }; |
| 284 | |
| 285 | static const struct keyspan_device_details usa19w_device_details = { |
| 286 | .product_id = keyspan_usa19w_product_id, |
| 287 | .msg_format = msg_usa26, |
| 288 | .num_ports = 1, |
| 289 | .indat_endp_flip = 0, |
| 290 | .outdat_endp_flip = 1, |
| 291 | .indat_endpoints = {0x81}, |
| 292 | .outdat_endpoints = {0x01}, |
| 293 | .inack_endpoints = {0x85}, |
| 294 | .outcont_endpoints = {0x05}, |
| 295 | .instat_endpoint = 0x87, |
Lucy McCoy | 0ca1268 | 2007-05-18 12:10:41 -0700 | [diff] [blame] | 296 | .indat_endpoint = -1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | .glocont_endpoint = 0x07, |
| 298 | .calculate_baud_rate = keyspan_usa19w_calc_baud, |
| 299 | .baudclk = KEYSPAN_USA19W_BAUDCLK, |
| 300 | }; |
| 301 | |
| 302 | static const struct keyspan_device_details usa19hs_device_details = { |
| 303 | .product_id = keyspan_usa19hs_product_id, |
| 304 | .msg_format = msg_usa90, |
| 305 | .num_ports = 1, |
| 306 | .indat_endp_flip = 0, |
| 307 | .outdat_endp_flip = 0, |
| 308 | .indat_endpoints = {0x81}, |
| 309 | .outdat_endpoints = {0x01}, |
| 310 | .inack_endpoints = {-1}, |
| 311 | .outcont_endpoints = {0x02}, |
| 312 | .instat_endpoint = 0x82, |
Lucy McCoy | 0ca1268 | 2007-05-18 12:10:41 -0700 | [diff] [blame] | 313 | .indat_endpoint = -1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | .glocont_endpoint = -1, |
| 315 | .calculate_baud_rate = keyspan_usa19hs_calc_baud, |
| 316 | .baudclk = KEYSPAN_USA19HS_BAUDCLK, |
| 317 | }; |
| 318 | |
| 319 | static const struct keyspan_device_details usa28_device_details = { |
| 320 | .product_id = keyspan_usa28_product_id, |
| 321 | .msg_format = msg_usa28, |
| 322 | .num_ports = 2, |
| 323 | .indat_endp_flip = 1, |
| 324 | .outdat_endp_flip = 1, |
| 325 | .indat_endpoints = {0x81, 0x83}, |
| 326 | .outdat_endpoints = {0x01, 0x03}, |
| 327 | .inack_endpoints = {0x85, 0x86}, |
| 328 | .outcont_endpoints = {0x05, 0x06}, |
| 329 | .instat_endpoint = 0x87, |
Lucy McCoy | 0ca1268 | 2007-05-18 12:10:41 -0700 | [diff] [blame] | 330 | .indat_endpoint = -1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | .glocont_endpoint = 0x07, |
| 332 | .calculate_baud_rate = keyspan_usa28_calc_baud, |
| 333 | .baudclk = KEYSPAN_USA28_BAUDCLK, |
| 334 | }; |
| 335 | |
| 336 | static const struct keyspan_device_details usa28x_device_details = { |
| 337 | .product_id = keyspan_usa28x_product_id, |
| 338 | .msg_format = msg_usa26, |
| 339 | .num_ports = 2, |
| 340 | .indat_endp_flip = 0, |
| 341 | .outdat_endp_flip = 1, |
| 342 | .indat_endpoints = {0x81, 0x83}, |
| 343 | .outdat_endpoints = {0x01, 0x03}, |
| 344 | .inack_endpoints = {0x85, 0x86}, |
| 345 | .outcont_endpoints = {0x05, 0x06}, |
| 346 | .instat_endpoint = 0x87, |
Lucy McCoy | 0ca1268 | 2007-05-18 12:10:41 -0700 | [diff] [blame] | 347 | .indat_endpoint = -1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | .glocont_endpoint = 0x07, |
| 349 | .calculate_baud_rate = keyspan_usa19w_calc_baud, |
| 350 | .baudclk = KEYSPAN_USA28X_BAUDCLK, |
| 351 | }; |
| 352 | |
| 353 | static const struct keyspan_device_details usa28xa_device_details = { |
| 354 | .product_id = keyspan_usa28xa_product_id, |
| 355 | .msg_format = msg_usa26, |
| 356 | .num_ports = 2, |
| 357 | .indat_endp_flip = 0, |
| 358 | .outdat_endp_flip = 1, |
| 359 | .indat_endpoints = {0x81, 0x83}, |
| 360 | .outdat_endpoints = {0x01, 0x03}, |
| 361 | .inack_endpoints = {0x85, 0x86}, |
| 362 | .outcont_endpoints = {0x05, 0x06}, |
| 363 | .instat_endpoint = 0x87, |
Lucy McCoy | 0ca1268 | 2007-05-18 12:10:41 -0700 | [diff] [blame] | 364 | .indat_endpoint = -1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | .glocont_endpoint = 0x07, |
| 366 | .calculate_baud_rate = keyspan_usa19w_calc_baud, |
| 367 | .baudclk = KEYSPAN_USA28X_BAUDCLK, |
| 368 | }; |
| 369 | |
Lucy McCoy | 0ca1268 | 2007-05-18 12:10:41 -0700 | [diff] [blame] | 370 | static const struct keyspan_device_details usa28xg_device_details = { |
| 371 | .product_id = keyspan_usa28xg_product_id, |
| 372 | .msg_format = msg_usa67, |
| 373 | .num_ports = 2, |
| 374 | .indat_endp_flip = 0, |
| 375 | .outdat_endp_flip = 0, |
| 376 | .indat_endpoints = {0x84, 0x88}, |
| 377 | .outdat_endpoints = {0x02, 0x06}, |
| 378 | .inack_endpoints = {-1, -1}, |
| 379 | .outcont_endpoints = {-1, -1}, |
| 380 | .instat_endpoint = 0x81, |
| 381 | .indat_endpoint = -1, |
| 382 | .glocont_endpoint = 0x01, |
| 383 | .calculate_baud_rate = keyspan_usa19w_calc_baud, |
| 384 | .baudclk = KEYSPAN_USA28X_BAUDCLK, |
| 385 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | /* We don't need a separate entry for the usa28xb as it appears as a 28x anyway */ |
| 387 | |
| 388 | static const struct keyspan_device_details usa49w_device_details = { |
| 389 | .product_id = keyspan_usa49w_product_id, |
| 390 | .msg_format = msg_usa49, |
| 391 | .num_ports = 4, |
| 392 | .indat_endp_flip = 0, |
| 393 | .outdat_endp_flip = 0, |
| 394 | .indat_endpoints = {0x81, 0x82, 0x83, 0x84}, |
| 395 | .outdat_endpoints = {0x01, 0x02, 0x03, 0x04}, |
| 396 | .inack_endpoints = {-1, -1, -1, -1}, |
| 397 | .outcont_endpoints = {-1, -1, -1, -1}, |
| 398 | .instat_endpoint = 0x87, |
Lucy McCoy | 0ca1268 | 2007-05-18 12:10:41 -0700 | [diff] [blame] | 399 | .indat_endpoint = -1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | .glocont_endpoint = 0x07, |
| 401 | .calculate_baud_rate = keyspan_usa19w_calc_baud, |
| 402 | .baudclk = KEYSPAN_USA49W_BAUDCLK, |
| 403 | }; |
| 404 | |
| 405 | static const struct keyspan_device_details usa49wlc_device_details = { |
| 406 | .product_id = keyspan_usa49wlc_product_id, |
| 407 | .msg_format = msg_usa49, |
| 408 | .num_ports = 4, |
| 409 | .indat_endp_flip = 0, |
| 410 | .outdat_endp_flip = 0, |
| 411 | .indat_endpoints = {0x81, 0x82, 0x83, 0x84}, |
| 412 | .outdat_endpoints = {0x01, 0x02, 0x03, 0x04}, |
| 413 | .inack_endpoints = {-1, -1, -1, -1}, |
| 414 | .outcont_endpoints = {-1, -1, -1, -1}, |
| 415 | .instat_endpoint = 0x87, |
Lucy McCoy | 0ca1268 | 2007-05-18 12:10:41 -0700 | [diff] [blame] | 416 | .indat_endpoint = -1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 417 | .glocont_endpoint = 0x07, |
| 418 | .calculate_baud_rate = keyspan_usa19w_calc_baud, |
| 419 | .baudclk = KEYSPAN_USA19W_BAUDCLK, |
| 420 | }; |
| 421 | |
Lucy McCoy | 0ca1268 | 2007-05-18 12:10:41 -0700 | [diff] [blame] | 422 | static const struct keyspan_device_details usa49wg_device_details = { |
| 423 | .product_id = keyspan_usa49wg_product_id, |
| 424 | .msg_format = msg_usa49, |
| 425 | .num_ports = 4, |
| 426 | .indat_endp_flip = 0, |
| 427 | .outdat_endp_flip = 0, |
| 428 | .indat_endpoints = {-1, -1, -1, -1}, /* single 'global' data in EP */ |
| 429 | .outdat_endpoints = {0x01, 0x02, 0x04, 0x06}, |
| 430 | .inack_endpoints = {-1, -1, -1, -1}, |
| 431 | .outcont_endpoints = {-1, -1, -1, -1}, |
| 432 | .instat_endpoint = 0x81, |
| 433 | .indat_endpoint = 0x88, |
| 434 | .glocont_endpoint = 0x00, /* uses control EP */ |
| 435 | .calculate_baud_rate = keyspan_usa19w_calc_baud, |
| 436 | .baudclk = KEYSPAN_USA19W_BAUDCLK, |
| 437 | }; |
| 438 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | static const struct keyspan_device_details *keyspan_devices[] = { |
| 440 | &usa18x_device_details, |
| 441 | &usa19_device_details, |
| 442 | &usa19qi_device_details, |
| 443 | &mpr_device_details, |
| 444 | &usa19qw_device_details, |
| 445 | &usa19w_device_details, |
| 446 | &usa19hs_device_details, |
| 447 | &usa28_device_details, |
| 448 | &usa28x_device_details, |
| 449 | &usa28xa_device_details, |
Lucy McCoy | 0ca1268 | 2007-05-18 12:10:41 -0700 | [diff] [blame] | 450 | &usa28xg_device_details, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | /* 28xb not required as it renumerates as a 28x */ |
| 452 | &usa49w_device_details, |
| 453 | &usa49wlc_device_details, |
Lucy McCoy | 0ca1268 | 2007-05-18 12:10:41 -0700 | [diff] [blame] | 454 | &usa49wg_device_details, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | NULL, |
| 456 | }; |
| 457 | |
Németh Márton | 7d40d7e | 2010-01-10 15:34:24 +0100 | [diff] [blame] | 458 | static const struct usb_device_id keyspan_ids_combined[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa18x_pre_product_id) }, |
| 460 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19_pre_product_id) }, |
| 461 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19w_pre_product_id) }, |
| 462 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qi_pre_product_id) }, |
| 463 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qw_pre_product_id) }, |
| 464 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_mpr_pre_product_id) }, |
| 465 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28_pre_product_id) }, |
| 466 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28x_pre_product_id) }, |
| 467 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xa_pre_product_id) }, |
| 468 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xb_pre_product_id) }, |
| 469 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49w_pre_product_id) }, |
| 470 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wlc_pre_product_id) }, |
| 471 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa18x_product_id) }, |
| 472 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19_product_id) }, |
| 473 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19w_product_id) }, |
| 474 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qi_product_id) }, |
| 475 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qw_product_id) }, |
| 476 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19hs_product_id) }, |
| 477 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_mpr_product_id) }, |
| 478 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28_product_id) }, |
| 479 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28x_product_id) }, |
| 480 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xa_product_id) }, |
Lucy McCoy | 0ca1268 | 2007-05-18 12:10:41 -0700 | [diff] [blame] | 481 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xg_product_id) }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49w_product_id)}, |
| 483 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wlc_product_id)}, |
Lucy McCoy | 0ca1268 | 2007-05-18 12:10:41 -0700 | [diff] [blame] | 484 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wg_product_id)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | { } /* Terminating entry */ |
| 486 | }; |
| 487 | |
| 488 | MODULE_DEVICE_TABLE(usb, keyspan_ids_combined); |
| 489 | |
| 490 | static struct usb_driver keyspan_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | .name = "keyspan", |
| 492 | .probe = usb_serial_probe, |
| 493 | .disconnect = usb_serial_disconnect, |
| 494 | .id_table = keyspan_ids_combined, |
| 495 | }; |
| 496 | |
| 497 | /* usb_device_id table for the pre-firmware download keyspan devices */ |
Németh Márton | 7d40d7e | 2010-01-10 15:34:24 +0100 | [diff] [blame] | 498 | static const struct usb_device_id keyspan_pre_ids[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 499 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa18x_pre_product_id) }, |
| 500 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19_pre_product_id) }, |
| 501 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qi_pre_product_id) }, |
| 502 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qw_pre_product_id) }, |
| 503 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19w_pre_product_id) }, |
| 504 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_mpr_pre_product_id) }, |
| 505 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28_pre_product_id) }, |
| 506 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28x_pre_product_id) }, |
| 507 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xa_pre_product_id) }, |
| 508 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xb_pre_product_id) }, |
| 509 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49w_pre_product_id) }, |
| 510 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wlc_pre_product_id) }, |
| 511 | { } /* Terminating entry */ |
| 512 | }; |
| 513 | |
Németh Márton | 7d40d7e | 2010-01-10 15:34:24 +0100 | [diff] [blame] | 514 | static const struct usb_device_id keyspan_1port_ids[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 515 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa18x_product_id) }, |
| 516 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19_product_id) }, |
| 517 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qi_product_id) }, |
| 518 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qw_product_id) }, |
| 519 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19w_product_id) }, |
| 520 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19hs_product_id) }, |
| 521 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_mpr_product_id) }, |
| 522 | { } /* Terminating entry */ |
| 523 | }; |
| 524 | |
Németh Márton | 7d40d7e | 2010-01-10 15:34:24 +0100 | [diff] [blame] | 525 | static const struct usb_device_id keyspan_2port_ids[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28_product_id) }, |
| 527 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28x_product_id) }, |
| 528 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xa_product_id) }, |
Lucy McCoy | 0ca1268 | 2007-05-18 12:10:41 -0700 | [diff] [blame] | 529 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28xg_product_id) }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 530 | { } /* Terminating entry */ |
| 531 | }; |
| 532 | |
Németh Márton | 7d40d7e | 2010-01-10 15:34:24 +0100 | [diff] [blame] | 533 | static const struct usb_device_id keyspan_4port_ids[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49w_product_id) }, |
| 535 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wlc_product_id)}, |
Lucy McCoy | 0ca1268 | 2007-05-18 12:10:41 -0700 | [diff] [blame] | 536 | { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa49wg_product_id)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 537 | { } /* Terminating entry */ |
| 538 | }; |
| 539 | |
| 540 | /* Structs for the devices, pre and post renumeration. */ |
Greg Kroah-Hartman | ea65370 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 541 | static struct usb_serial_driver keyspan_pre_device = { |
Greg Kroah-Hartman | 18fcac3 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 542 | .driver = { |
| 543 | .owner = THIS_MODULE, |
Greg Kroah-Hartman | 269bda1 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 544 | .name = "keyspan_no_firm", |
Greg Kroah-Hartman | 18fcac3 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 545 | }, |
Greg Kroah-Hartman | 269bda1 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 546 | .description = "Keyspan - (without firmware)", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | .id_table = keyspan_pre_ids, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 548 | .num_ports = 1, |
| 549 | .attach = keyspan_fake_startup, |
| 550 | }; |
| 551 | |
Greg Kroah-Hartman | ea65370 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 552 | static struct usb_serial_driver keyspan_1port_device = { |
Greg Kroah-Hartman | 18fcac3 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 553 | .driver = { |
| 554 | .owner = THIS_MODULE, |
Greg Kroah-Hartman | 269bda1 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 555 | .name = "keyspan_1", |
Greg Kroah-Hartman | 18fcac3 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 556 | }, |
Greg Kroah-Hartman | 269bda1 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 557 | .description = "Keyspan 1 port adapter", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | .id_table = keyspan_1port_ids, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | .num_ports = 1, |
| 560 | .open = keyspan_open, |
| 561 | .close = keyspan_close, |
Alan Cox | 335f851 | 2009-06-11 12:26:29 +0100 | [diff] [blame] | 562 | .dtr_rts = keyspan_dtr_rts, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | .write = keyspan_write, |
| 564 | .write_room = keyspan_write_room, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | .set_termios = keyspan_set_termios, |
| 566 | .break_ctl = keyspan_break_ctl, |
| 567 | .tiocmget = keyspan_tiocmget, |
| 568 | .tiocmset = keyspan_tiocmset, |
| 569 | .attach = keyspan_startup, |
Alan Stern | f9c99bb | 2009-06-02 11:53:55 -0400 | [diff] [blame] | 570 | .disconnect = keyspan_disconnect, |
| 571 | .release = keyspan_release, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 572 | }; |
| 573 | |
Greg Kroah-Hartman | ea65370 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 574 | static struct usb_serial_driver keyspan_2port_device = { |
Greg Kroah-Hartman | 18fcac3 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 575 | .driver = { |
| 576 | .owner = THIS_MODULE, |
Greg Kroah-Hartman | 269bda1 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 577 | .name = "keyspan_2", |
Greg Kroah-Hartman | 18fcac3 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 578 | }, |
Greg Kroah-Hartman | 269bda1 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 579 | .description = "Keyspan 2 port adapter", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 580 | .id_table = keyspan_2port_ids, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | .num_ports = 2, |
| 582 | .open = keyspan_open, |
| 583 | .close = keyspan_close, |
Alan Cox | 335f851 | 2009-06-11 12:26:29 +0100 | [diff] [blame] | 584 | .dtr_rts = keyspan_dtr_rts, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | .write = keyspan_write, |
| 586 | .write_room = keyspan_write_room, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | .set_termios = keyspan_set_termios, |
| 588 | .break_ctl = keyspan_break_ctl, |
| 589 | .tiocmget = keyspan_tiocmget, |
| 590 | .tiocmset = keyspan_tiocmset, |
| 591 | .attach = keyspan_startup, |
Alan Stern | f9c99bb | 2009-06-02 11:53:55 -0400 | [diff] [blame] | 592 | .disconnect = keyspan_disconnect, |
| 593 | .release = keyspan_release, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 594 | }; |
| 595 | |
Greg Kroah-Hartman | ea65370 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 596 | static struct usb_serial_driver keyspan_4port_device = { |
Greg Kroah-Hartman | 18fcac3 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 597 | .driver = { |
| 598 | .owner = THIS_MODULE, |
Greg Kroah-Hartman | 269bda1 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 599 | .name = "keyspan_4", |
Greg Kroah-Hartman | 18fcac3 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 600 | }, |
Greg Kroah-Hartman | 269bda1 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 601 | .description = "Keyspan 4 port adapter", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | .id_table = keyspan_4port_ids, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | .num_ports = 4, |
| 604 | .open = keyspan_open, |
| 605 | .close = keyspan_close, |
Alan Cox | 335f851 | 2009-06-11 12:26:29 +0100 | [diff] [blame] | 606 | .dtr_rts = keyspan_dtr_rts, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 607 | .write = keyspan_write, |
| 608 | .write_room = keyspan_write_room, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 609 | .set_termios = keyspan_set_termios, |
| 610 | .break_ctl = keyspan_break_ctl, |
| 611 | .tiocmget = keyspan_tiocmget, |
| 612 | .tiocmset = keyspan_tiocmset, |
| 613 | .attach = keyspan_startup, |
Alan Stern | f9c99bb | 2009-06-02 11:53:55 -0400 | [diff] [blame] | 614 | .disconnect = keyspan_disconnect, |
| 615 | .release = keyspan_release, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | }; |
| 617 | |
Alan Stern | 4d2a7af | 2012-02-23 14:57:09 -0500 | [diff] [blame^] | 618 | static struct usb_serial_driver * const serial_drivers[] = { |
| 619 | &keyspan_pre_device, &keyspan_1port_device, |
| 620 | &keyspan_2port_device, &keyspan_4port_device, NULL |
| 621 | }; |
| 622 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 623 | #endif |