Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * USB ConnectTech WhiteHEAT driver |
| 3 | * |
| 4 | * Copyright (C) 2002 |
| 5 | * Connect Tech Inc. |
| 6 | * |
| 7 | * Copyright (C) 1999 - 2001 |
| 8 | * Greg Kroah-Hartman (greg@kroah.com) |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation; either version 2 of the License, or |
| 13 | * (at your option) any later version. |
| 14 | * |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 15 | * See Documentation/usb/usb-serial.txt for more information on using this |
| 16 | * driver |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | */ |
| 18 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <linux/kernel.h> |
| 20 | #include <linux/errno.h> |
| 21 | #include <linux/init.h> |
| 22 | #include <linux/slab.h> |
| 23 | #include <linux/tty.h> |
| 24 | #include <linux/tty_driver.h> |
| 25 | #include <linux/tty_flip.h> |
| 26 | #include <linux/module.h> |
| 27 | #include <linux/spinlock.h> |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 28 | #include <linux/mutex.h> |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 29 | #include <linux/uaccess.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #include <asm/termbits.h> |
| 31 | #include <linux/usb.h> |
| 32 | #include <linux/serial_reg.h> |
| 33 | #include <linux/serial.h> |
Greg Kroah-Hartman | a969888 | 2006-07-11 21:22:58 -0700 | [diff] [blame] | 34 | #include <linux/usb/serial.h> |
David Woodhouse | ec6752f | 2008-05-31 01:35:29 +0300 | [diff] [blame] | 35 | #include <linux/firmware.h> |
| 36 | #include <linux/ihex.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | #include "whiteheat.h" /* WhiteHEAT specific commands */ |
| 38 | |
Rusty Russell | 90ab5ee | 2012-01-13 09:32:20 +1030 | [diff] [blame^] | 39 | static bool debug; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | |
| 41 | #ifndef CMSPAR |
| 42 | #define CMSPAR 0 |
| 43 | #endif |
| 44 | |
| 45 | /* |
| 46 | * Version Information |
| 47 | */ |
| 48 | #define DRIVER_VERSION "v2.0" |
| 49 | #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Stuart MacDonald <stuartm@connecttech.com>" |
| 50 | #define DRIVER_DESC "USB ConnectTech WhiteHEAT driver" |
| 51 | |
| 52 | #define CONNECT_TECH_VENDOR_ID 0x0710 |
| 53 | #define CONNECT_TECH_FAKE_WHITE_HEAT_ID 0x0001 |
| 54 | #define CONNECT_TECH_WHITE_HEAT_ID 0x8001 |
| 55 | |
| 56 | /* |
| 57 | ID tables for whiteheat are unusual, because we want to different |
| 58 | things for different versions of the device. Eventually, this |
| 59 | will be doable from a single table. But, for now, we define two |
| 60 | separate ID tables, and then a third table that combines them |
| 61 | just for the purpose of exporting the autoloading information. |
| 62 | */ |
Németh Márton | 7d40d7e | 2010-01-10 15:34:24 +0100 | [diff] [blame] | 63 | static const struct usb_device_id id_table_std[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | { USB_DEVICE(CONNECT_TECH_VENDOR_ID, CONNECT_TECH_WHITE_HEAT_ID) }, |
| 65 | { } /* Terminating entry */ |
| 66 | }; |
| 67 | |
Németh Márton | 7d40d7e | 2010-01-10 15:34:24 +0100 | [diff] [blame] | 68 | static const struct usb_device_id id_table_prerenumeration[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | { USB_DEVICE(CONNECT_TECH_VENDOR_ID, CONNECT_TECH_FAKE_WHITE_HEAT_ID) }, |
| 70 | { } /* Terminating entry */ |
| 71 | }; |
| 72 | |
Németh Márton | 7d40d7e | 2010-01-10 15:34:24 +0100 | [diff] [blame] | 73 | static const struct usb_device_id id_table_combined[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | { USB_DEVICE(CONNECT_TECH_VENDOR_ID, CONNECT_TECH_WHITE_HEAT_ID) }, |
| 75 | { USB_DEVICE(CONNECT_TECH_VENDOR_ID, CONNECT_TECH_FAKE_WHITE_HEAT_ID) }, |
| 76 | { } /* Terminating entry */ |
| 77 | }; |
| 78 | |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 79 | MODULE_DEVICE_TABLE(usb, id_table_combined); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | |
| 81 | static struct usb_driver whiteheat_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | .name = "whiteheat", |
| 83 | .probe = usb_serial_probe, |
| 84 | .disconnect = usb_serial_disconnect, |
| 85 | .id_table = id_table_combined, |
Greg Kroah-Hartman | ba9dc65 | 2005-11-16 13:41:28 -0800 | [diff] [blame] | 86 | .no_dynamic_id = 1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | }; |
| 88 | |
| 89 | /* function prototypes for the Connect Tech WhiteHEAT prerenumeration device */ |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 90 | static int whiteheat_firmware_download(struct usb_serial *serial, |
| 91 | const struct usb_device_id *id); |
| 92 | static int whiteheat_firmware_attach(struct usb_serial *serial); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | |
| 94 | /* function prototypes for the Connect Tech WhiteHEAT serial converter */ |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 95 | static int whiteheat_attach(struct usb_serial *serial); |
Alan Stern | f9c99bb | 2009-06-02 11:53:55 -0400 | [diff] [blame] | 96 | static void whiteheat_release(struct usb_serial *serial); |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 97 | static int whiteheat_open(struct tty_struct *tty, |
Alan Cox | a509a7e | 2009-09-19 13:13:26 -0700 | [diff] [blame] | 98 | struct usb_serial_port *port); |
Alan Cox | 335f851 | 2009-06-11 12:26:29 +0100 | [diff] [blame] | 99 | static void whiteheat_close(struct usb_serial_port *port); |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 100 | static int whiteheat_write(struct tty_struct *tty, |
| 101 | struct usb_serial_port *port, |
| 102 | const unsigned char *buf, int count); |
| 103 | static int whiteheat_write_room(struct tty_struct *tty); |
Alan Cox | 00a0d0d | 2011-02-14 16:27:06 +0000 | [diff] [blame] | 104 | static int whiteheat_ioctl(struct tty_struct *tty, |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 105 | unsigned int cmd, unsigned long arg); |
| 106 | static void whiteheat_set_termios(struct tty_struct *tty, |
| 107 | struct usb_serial_port *port, struct ktermios *old); |
Alan Cox | 60b33c1 | 2011-02-14 16:26:14 +0000 | [diff] [blame] | 108 | static int whiteheat_tiocmget(struct tty_struct *tty); |
Alan Cox | 20b9d17 | 2011-02-14 16:26:50 +0000 | [diff] [blame] | 109 | static int whiteheat_tiocmset(struct tty_struct *tty, |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 110 | unsigned int set, unsigned int clear); |
| 111 | static void whiteheat_break_ctl(struct tty_struct *tty, int break_state); |
| 112 | static int whiteheat_chars_in_buffer(struct tty_struct *tty); |
| 113 | static void whiteheat_throttle(struct tty_struct *tty); |
| 114 | static void whiteheat_unthrottle(struct tty_struct *tty); |
| 115 | static void whiteheat_read_callback(struct urb *urb); |
| 116 | static void whiteheat_write_callback(struct urb *urb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | |
Greg Kroah-Hartman | ea65370 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 118 | static struct usb_serial_driver whiteheat_fake_device = { |
Greg Kroah-Hartman | 18fcac3 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 119 | .driver = { |
| 120 | .owner = THIS_MODULE, |
Greg Kroah-Hartman | 269bda1 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 121 | .name = "whiteheatnofirm", |
Greg Kroah-Hartman | 18fcac3 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 122 | }, |
Greg Kroah-Hartman | 269bda1 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 123 | .description = "Connect Tech - WhiteHEAT - (prerenumeration)", |
Johannes Hölzl | d9b1b78 | 2006-12-17 21:50:24 +0100 | [diff] [blame] | 124 | .usb_driver = &whiteheat_driver, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | .id_table = id_table_prerenumeration, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | .num_ports = 1, |
| 127 | .probe = whiteheat_firmware_download, |
| 128 | .attach = whiteheat_firmware_attach, |
| 129 | }; |
| 130 | |
Greg Kroah-Hartman | ea65370 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 131 | static struct usb_serial_driver whiteheat_device = { |
Greg Kroah-Hartman | 18fcac3 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 132 | .driver = { |
| 133 | .owner = THIS_MODULE, |
Greg Kroah-Hartman | 269bda1 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 134 | .name = "whiteheat", |
Greg Kroah-Hartman | 18fcac3 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 135 | }, |
Greg Kroah-Hartman | 269bda1 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 136 | .description = "Connect Tech - WhiteHEAT", |
Johannes Hölzl | d9b1b78 | 2006-12-17 21:50:24 +0100 | [diff] [blame] | 137 | .usb_driver = &whiteheat_driver, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | .id_table = id_table_std, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | .num_ports = 4, |
| 140 | .attach = whiteheat_attach, |
Alan Stern | f9c99bb | 2009-06-02 11:53:55 -0400 | [diff] [blame] | 141 | .release = whiteheat_release, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | .open = whiteheat_open, |
| 143 | .close = whiteheat_close, |
| 144 | .write = whiteheat_write, |
| 145 | .write_room = whiteheat_write_room, |
| 146 | .ioctl = whiteheat_ioctl, |
| 147 | .set_termios = whiteheat_set_termios, |
| 148 | .break_ctl = whiteheat_break_ctl, |
| 149 | .tiocmget = whiteheat_tiocmget, |
| 150 | .tiocmset = whiteheat_tiocmset, |
| 151 | .chars_in_buffer = whiteheat_chars_in_buffer, |
| 152 | .throttle = whiteheat_throttle, |
| 153 | .unthrottle = whiteheat_unthrottle, |
| 154 | .read_bulk_callback = whiteheat_read_callback, |
| 155 | .write_bulk_callback = whiteheat_write_callback, |
| 156 | }; |
| 157 | |
| 158 | |
| 159 | struct whiteheat_command_private { |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 160 | struct mutex mutex; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | __u8 port_running; |
| 162 | __u8 command_finished; |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 163 | wait_queue_head_t wait_command; /* for handling sleeping whilst |
| 164 | waiting for a command to |
| 165 | finish */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | __u8 result_buffer[64]; |
| 167 | }; |
| 168 | |
| 169 | |
| 170 | #define THROTTLED 0x01 |
| 171 | #define ACTUALLY_THROTTLED 0x02 |
| 172 | |
| 173 | static int urb_pool_size = 8; |
| 174 | |
| 175 | struct whiteheat_urb_wrap { |
| 176 | struct list_head list; |
| 177 | struct urb *urb; |
| 178 | }; |
| 179 | |
| 180 | struct whiteheat_private { |
| 181 | spinlock_t lock; |
| 182 | __u8 flags; |
Alan Cox | a5b6f60 | 2008-04-08 17:16:06 +0100 | [diff] [blame] | 183 | __u8 mcr; /* FIXME: no locking on mcr */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | struct list_head rx_urbs_free; |
| 185 | struct list_head rx_urbs_submitted; |
| 186 | struct list_head rx_urb_q; |
| 187 | struct work_struct rx_work; |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 188 | struct usb_serial_port *port; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | struct list_head tx_urbs_free; |
| 190 | struct list_head tx_urbs_submitted; |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 191 | struct mutex deathwarrant; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | }; |
| 193 | |
| 194 | |
| 195 | /* local function prototypes */ |
| 196 | static int start_command_port(struct usb_serial *serial); |
| 197 | static void stop_command_port(struct usb_serial *serial); |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 198 | static void command_port_write_callback(struct urb *urb); |
| 199 | static void command_port_read_callback(struct urb *urb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | |
| 201 | static int start_port_read(struct usb_serial_port *port); |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 202 | static struct whiteheat_urb_wrap *urb_to_wrap(struct urb *urb, |
| 203 | struct list_head *head); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | static struct list_head *list_first(struct list_head *head); |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 205 | static void rx_data_softint(struct work_struct *work); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 207 | static int firm_send_command(struct usb_serial_port *port, __u8 command, |
| 208 | __u8 *data, __u8 datasize); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | static int firm_open(struct usb_serial_port *port); |
| 210 | static int firm_close(struct usb_serial_port *port); |
Alan Cox | fe1ae7f | 2009-09-19 13:13:33 -0700 | [diff] [blame] | 211 | static void firm_setup_port(struct tty_struct *tty); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | static int firm_set_rts(struct usb_serial_port *port, __u8 onoff); |
| 213 | static int firm_set_dtr(struct usb_serial_port *port, __u8 onoff); |
| 214 | static int firm_set_break(struct usb_serial_port *port, __u8 onoff); |
| 215 | static int firm_purge(struct usb_serial_port *port, __u8 rxtx); |
| 216 | static int firm_get_dtr_rts(struct usb_serial_port *port); |
| 217 | static int firm_report_tx_done(struct usb_serial_port *port); |
| 218 | |
| 219 | |
| 220 | #define COMMAND_PORT 4 |
| 221 | #define COMMAND_TIMEOUT (2*HZ) /* 2 second timeout for a command */ |
| 222 | #define COMMAND_TIMEOUT_MS 2000 |
| 223 | #define CLOSING_DELAY (30 * HZ) |
| 224 | |
| 225 | |
| 226 | /***************************************************************************** |
| 227 | * Connect Tech's White Heat prerenumeration driver functions |
| 228 | *****************************************************************************/ |
| 229 | |
| 230 | /* steps to download the firmware to the WhiteHEAT device: |
| 231 | - hold the reset (by writing to the reset bit of the CPUCS register) |
| 232 | - download the VEND_AX.HEX file to the chip using VENDOR_REQUEST-ANCHOR_LOAD |
| 233 | - release the reset (by writing to the CPUCS register) |
| 234 | - download the WH.HEX file for all addresses greater than 0x1b3f using |
| 235 | VENDOR_REQUEST-ANCHOR_EXTERNAL_RAM_LOAD |
| 236 | - hold the reset |
| 237 | - download the WH.HEX file for all addresses less than 0x1b40 using |
| 238 | VENDOR_REQUEST_ANCHOR_LOAD |
| 239 | - release the reset |
| 240 | - device renumerated itself and comes up as new device id with all |
| 241 | firmware download completed. |
| 242 | */ |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 243 | static int whiteheat_firmware_download(struct usb_serial *serial, |
| 244 | const struct usb_device_id *id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | { |
David Woodhouse | ec6752f | 2008-05-31 01:35:29 +0300 | [diff] [blame] | 246 | int response, ret = -ENOENT; |
| 247 | const struct firmware *loader_fw = NULL, *firmware_fw = NULL; |
| 248 | const struct ihex_binrec *record; |
| 249 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 250 | dbg("%s", __func__); |
David Woodhouse | ec6752f | 2008-05-31 01:35:29 +0300 | [diff] [blame] | 251 | |
| 252 | if (request_ihex_firmware(&firmware_fw, "whiteheat.fw", |
| 253 | &serial->dev->dev)) { |
Greg Kroah-Hartman | 194343d | 2008-08-20 16:56:34 -0700 | [diff] [blame] | 254 | dev_err(&serial->dev->dev, |
| 255 | "%s - request \"whiteheat.fw\" failed\n", __func__); |
David Woodhouse | ec6752f | 2008-05-31 01:35:29 +0300 | [diff] [blame] | 256 | goto out; |
| 257 | } |
| 258 | if (request_ihex_firmware(&loader_fw, "whiteheat_loader.fw", |
| 259 | &serial->dev->dev)) { |
Greg Kroah-Hartman | 194343d | 2008-08-20 16:56:34 -0700 | [diff] [blame] | 260 | dev_err(&serial->dev->dev, |
| 261 | "%s - request \"whiteheat_loader.fw\" failed\n", |
| 262 | __func__); |
David Woodhouse | ec6752f | 2008-05-31 01:35:29 +0300 | [diff] [blame] | 263 | goto out; |
| 264 | } |
| 265 | ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | response = ezusb_set_reset (serial, 1); |
| 267 | |
David Woodhouse | ec6752f | 2008-05-31 01:35:29 +0300 | [diff] [blame] | 268 | record = (const struct ihex_binrec *)loader_fw->data; |
| 269 | while (record) { |
| 270 | response = ezusb_writememory (serial, be32_to_cpu(record->addr), |
| 271 | (unsigned char *)record->data, |
| 272 | be16_to_cpu(record->len), 0xa0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | if (response < 0) { |
Greg Kroah-Hartman | 194343d | 2008-08-20 16:56:34 -0700 | [diff] [blame] | 274 | dev_err(&serial->dev->dev, "%s - ezusb_writememory " |
| 275 | "failed for loader (%d %04X %p %d)\n", |
| 276 | __func__, response, be32_to_cpu(record->addr), |
| 277 | record->data, be16_to_cpu(record->len)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | break; |
| 279 | } |
David Woodhouse | ec6752f | 2008-05-31 01:35:29 +0300 | [diff] [blame] | 280 | record = ihex_next_binrec(record); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | } |
| 282 | |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 283 | response = ezusb_set_reset(serial, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | |
David Woodhouse | ec6752f | 2008-05-31 01:35:29 +0300 | [diff] [blame] | 285 | record = (const struct ihex_binrec *)firmware_fw->data; |
| 286 | while (record && be32_to_cpu(record->addr) < 0x1b40) |
| 287 | record = ihex_next_binrec(record); |
| 288 | while (record) { |
| 289 | response = ezusb_writememory (serial, be32_to_cpu(record->addr), |
| 290 | (unsigned char *)record->data, |
| 291 | be16_to_cpu(record->len), 0xa3); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | if (response < 0) { |
Greg Kroah-Hartman | 194343d | 2008-08-20 16:56:34 -0700 | [diff] [blame] | 293 | dev_err(&serial->dev->dev, "%s - ezusb_writememory " |
| 294 | "failed for first firmware step " |
| 295 | "(%d %04X %p %d)\n", __func__, response, |
| 296 | be32_to_cpu(record->addr), record->data, |
| 297 | be16_to_cpu(record->len)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | break; |
| 299 | } |
| 300 | ++record; |
| 301 | } |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 302 | |
| 303 | response = ezusb_set_reset(serial, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | |
David Woodhouse | ec6752f | 2008-05-31 01:35:29 +0300 | [diff] [blame] | 305 | record = (const struct ihex_binrec *)firmware_fw->data; |
| 306 | while (record && be32_to_cpu(record->addr) < 0x1b40) { |
| 307 | response = ezusb_writememory (serial, be32_to_cpu(record->addr), |
| 308 | (unsigned char *)record->data, |
| 309 | be16_to_cpu(record->len), 0xa0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | if (response < 0) { |
Greg Kroah-Hartman | 194343d | 2008-08-20 16:56:34 -0700 | [diff] [blame] | 311 | dev_err(&serial->dev->dev, "%s - ezusb_writememory " |
| 312 | "failed for second firmware step " |
| 313 | "(%d %04X %p %d)\n", __func__, response, |
| 314 | be32_to_cpu(record->addr), record->data, |
| 315 | be16_to_cpu(record->len)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | break; |
| 317 | } |
| 318 | ++record; |
| 319 | } |
David Woodhouse | ec6752f | 2008-05-31 01:35:29 +0300 | [diff] [blame] | 320 | ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | response = ezusb_set_reset (serial, 0); |
David Woodhouse | ec6752f | 2008-05-31 01:35:29 +0300 | [diff] [blame] | 322 | out: |
| 323 | release_firmware(loader_fw); |
| 324 | release_firmware(firmware_fw); |
| 325 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 329 | static int whiteheat_firmware_attach(struct usb_serial *serial) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | { |
| 331 | /* We want this device to fail to have a driver assigned to it */ |
| 332 | return 1; |
| 333 | } |
| 334 | |
| 335 | |
| 336 | /***************************************************************************** |
| 337 | * Connect Tech's White Heat serial driver functions |
| 338 | *****************************************************************************/ |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 339 | static int whiteheat_attach(struct usb_serial *serial) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | { |
| 341 | struct usb_serial_port *command_port; |
| 342 | struct whiteheat_command_private *command_info; |
| 343 | struct usb_serial_port *port; |
| 344 | struct whiteheat_private *info; |
| 345 | struct whiteheat_hw_info *hw_info; |
| 346 | int pipe; |
| 347 | int ret; |
| 348 | int alen; |
| 349 | __u8 *command; |
| 350 | __u8 *result; |
| 351 | int i; |
| 352 | int j; |
| 353 | struct urb *urb; |
| 354 | int buf_size; |
| 355 | struct whiteheat_urb_wrap *wrap; |
| 356 | struct list_head *tmp; |
| 357 | |
| 358 | command_port = serial->port[COMMAND_PORT]; |
| 359 | |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 360 | pipe = usb_sndbulkpipe(serial->dev, |
| 361 | command_port->bulk_out_endpointAddress); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | command = kmalloc(2, GFP_KERNEL); |
| 363 | if (!command) |
| 364 | goto no_command_buffer; |
| 365 | command[0] = WHITEHEAT_GET_HW_INFO; |
| 366 | command[1] = 0; |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 367 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | result = kmalloc(sizeof(*hw_info) + 1, GFP_KERNEL); |
| 369 | if (!result) |
| 370 | goto no_result_buffer; |
| 371 | /* |
| 372 | * When the module is reloaded the firmware is still there and |
| 373 | * the endpoints are still in the usb core unchanged. This is the |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 374 | * unlinking bug in disguise. Same for the call below. |
| 375 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | usb_clear_halt(serial->dev, pipe); |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 377 | ret = usb_bulk_msg(serial->dev, pipe, command, 2, |
| 378 | &alen, COMMAND_TIMEOUT_MS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | if (ret) { |
Greg Kroah-Hartman | 194343d | 2008-08-20 16:56:34 -0700 | [diff] [blame] | 380 | dev_err(&serial->dev->dev, "%s: Couldn't send command [%d]\n", |
| 381 | serial->type->description, ret); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 382 | goto no_firmware; |
Stuart MacDonald | 09fd6bc | 2006-05-31 13:28:40 -0400 | [diff] [blame] | 383 | } else if (alen != 2) { |
Greg Kroah-Hartman | 194343d | 2008-08-20 16:56:34 -0700 | [diff] [blame] | 384 | dev_err(&serial->dev->dev, "%s: Send command incomplete [%d]\n", |
| 385 | serial->type->description, alen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | goto no_firmware; |
| 387 | } |
| 388 | |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 389 | pipe = usb_rcvbulkpipe(serial->dev, |
| 390 | command_port->bulk_in_endpointAddress); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | /* See the comment on the usb_clear_halt() above */ |
| 392 | usb_clear_halt(serial->dev, pipe); |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 393 | ret = usb_bulk_msg(serial->dev, pipe, result, |
| 394 | sizeof(*hw_info) + 1, &alen, COMMAND_TIMEOUT_MS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | if (ret) { |
Greg Kroah-Hartman | 194343d | 2008-08-20 16:56:34 -0700 | [diff] [blame] | 396 | dev_err(&serial->dev->dev, "%s: Couldn't get results [%d]\n", |
| 397 | serial->type->description, ret); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 | goto no_firmware; |
Stuart MacDonald | 09fd6bc | 2006-05-31 13:28:40 -0400 | [diff] [blame] | 399 | } else if (alen != sizeof(*hw_info) + 1) { |
Greg Kroah-Hartman | 194343d | 2008-08-20 16:56:34 -0700 | [diff] [blame] | 400 | dev_err(&serial->dev->dev, "%s: Get results incomplete [%d]\n", |
| 401 | serial->type->description, alen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 402 | goto no_firmware; |
| 403 | } else if (result[0] != command[0]) { |
Greg Kroah-Hartman | 194343d | 2008-08-20 16:56:34 -0700 | [diff] [blame] | 404 | dev_err(&serial->dev->dev, "%s: Command failed [%d]\n", |
| 405 | serial->type->description, result[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | goto no_firmware; |
| 407 | } |
| 408 | |
| 409 | hw_info = (struct whiteheat_hw_info *)&result[1]; |
| 410 | |
Greg Kroah-Hartman | c197a8d | 2008-08-18 13:21:04 -0700 | [diff] [blame] | 411 | dev_info(&serial->dev->dev, "%s: Driver %s: Firmware v%d.%02d\n", |
| 412 | serial->type->description, DRIVER_VERSION, |
| 413 | hw_info->sw_major_rev, hw_info->sw_minor_rev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | |
| 415 | for (i = 0; i < serial->num_ports; i++) { |
| 416 | port = serial->port[i]; |
| 417 | |
Robert P. J. Day | 5cbded5 | 2006-12-13 00:35:56 -0800 | [diff] [blame] | 418 | info = kmalloc(sizeof(struct whiteheat_private), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 419 | if (info == NULL) { |
Greg Kroah-Hartman | 194343d | 2008-08-20 16:56:34 -0700 | [diff] [blame] | 420 | dev_err(&port->dev, |
| 421 | "%s: Out of memory for port structures\n", |
| 422 | serial->type->description); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | goto no_private; |
| 424 | } |
| 425 | |
| 426 | spin_lock_init(&info->lock); |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 427 | mutex_init(&info->deathwarrant); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | info->flags = 0; |
| 429 | info->mcr = 0; |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 430 | INIT_WORK(&info->rx_work, rx_data_softint); |
| 431 | info->port = port; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | |
| 433 | INIT_LIST_HEAD(&info->rx_urbs_free); |
| 434 | INIT_LIST_HEAD(&info->rx_urbs_submitted); |
| 435 | INIT_LIST_HEAD(&info->rx_urb_q); |
| 436 | INIT_LIST_HEAD(&info->tx_urbs_free); |
| 437 | INIT_LIST_HEAD(&info->tx_urbs_submitted); |
| 438 | |
| 439 | for (j = 0; j < urb_pool_size; j++) { |
| 440 | urb = usb_alloc_urb(0, GFP_KERNEL); |
| 441 | if (!urb) { |
Greg Kroah-Hartman | 194343d | 2008-08-20 16:56:34 -0700 | [diff] [blame] | 442 | dev_err(&port->dev, "No free urbs available\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | goto no_rx_urb; |
| 444 | } |
| 445 | buf_size = port->read_urb->transfer_buffer_length; |
| 446 | urb->transfer_buffer = kmalloc(buf_size, GFP_KERNEL); |
| 447 | if (!urb->transfer_buffer) { |
Greg Kroah-Hartman | 194343d | 2008-08-20 16:56:34 -0700 | [diff] [blame] | 448 | dev_err(&port->dev, |
| 449 | "Couldn't allocate urb buffer\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | goto no_rx_buf; |
| 451 | } |
| 452 | wrap = kmalloc(sizeof(*wrap), GFP_KERNEL); |
| 453 | if (!wrap) { |
Greg Kroah-Hartman | 194343d | 2008-08-20 16:56:34 -0700 | [diff] [blame] | 454 | dev_err(&port->dev, |
| 455 | "Couldn't allocate urb wrapper\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | goto no_rx_wrap; |
| 457 | } |
| 458 | usb_fill_bulk_urb(urb, serial->dev, |
| 459 | usb_rcvbulkpipe(serial->dev, |
| 460 | port->bulk_in_endpointAddress), |
| 461 | urb->transfer_buffer, buf_size, |
| 462 | whiteheat_read_callback, port); |
| 463 | wrap->urb = urb; |
| 464 | list_add(&wrap->list, &info->rx_urbs_free); |
| 465 | |
| 466 | urb = usb_alloc_urb(0, GFP_KERNEL); |
| 467 | if (!urb) { |
Greg Kroah-Hartman | 194343d | 2008-08-20 16:56:34 -0700 | [diff] [blame] | 468 | dev_err(&port->dev, "No free urbs available\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | goto no_tx_urb; |
| 470 | } |
| 471 | buf_size = port->write_urb->transfer_buffer_length; |
| 472 | urb->transfer_buffer = kmalloc(buf_size, GFP_KERNEL); |
| 473 | if (!urb->transfer_buffer) { |
Greg Kroah-Hartman | 194343d | 2008-08-20 16:56:34 -0700 | [diff] [blame] | 474 | dev_err(&port->dev, |
| 475 | "Couldn't allocate urb buffer\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 476 | goto no_tx_buf; |
| 477 | } |
| 478 | wrap = kmalloc(sizeof(*wrap), GFP_KERNEL); |
| 479 | if (!wrap) { |
Greg Kroah-Hartman | 194343d | 2008-08-20 16:56:34 -0700 | [diff] [blame] | 480 | dev_err(&port->dev, |
| 481 | "Couldn't allocate urb wrapper\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | goto no_tx_wrap; |
| 483 | } |
| 484 | usb_fill_bulk_urb(urb, serial->dev, |
| 485 | usb_sndbulkpipe(serial->dev, |
| 486 | port->bulk_out_endpointAddress), |
| 487 | urb->transfer_buffer, buf_size, |
| 488 | whiteheat_write_callback, port); |
| 489 | wrap->urb = urb; |
| 490 | list_add(&wrap->list, &info->tx_urbs_free); |
| 491 | } |
| 492 | |
| 493 | usb_set_serial_port_data(port, info); |
| 494 | } |
| 495 | |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 496 | command_info = kmalloc(sizeof(struct whiteheat_command_private), |
| 497 | GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | if (command_info == NULL) { |
Greg Kroah-Hartman | 194343d | 2008-08-20 16:56:34 -0700 | [diff] [blame] | 499 | dev_err(&serial->dev->dev, |
| 500 | "%s: Out of memory for port structures\n", |
| 501 | serial->type->description); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 502 | goto no_command_private; |
| 503 | } |
| 504 | |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 505 | mutex_init(&command_info->mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 | command_info->port_running = 0; |
| 507 | init_waitqueue_head(&command_info->wait_command); |
| 508 | usb_set_serial_port_data(command_port, command_info); |
| 509 | command_port->write_urb->complete = command_port_write_callback; |
| 510 | command_port->read_urb->complete = command_port_read_callback; |
| 511 | kfree(result); |
| 512 | kfree(command); |
| 513 | |
| 514 | return 0; |
| 515 | |
| 516 | no_firmware: |
| 517 | /* Firmware likely not running */ |
Greg Kroah-Hartman | 194343d | 2008-08-20 16:56:34 -0700 | [diff] [blame] | 518 | dev_err(&serial->dev->dev, |
| 519 | "%s: Unable to retrieve firmware version, try replugging\n", |
| 520 | serial->type->description); |
| 521 | dev_err(&serial->dev->dev, |
| 522 | "%s: If the firmware is not running (status led not blinking)\n", |
| 523 | serial->type->description); |
| 524 | dev_err(&serial->dev->dev, |
| 525 | "%s: please contact support@connecttech.com\n", |
| 526 | serial->type->description); |
Jesper Juhl | 67ca028 | 2006-04-23 19:59:23 +0200 | [diff] [blame] | 527 | kfree(result); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 | return -ENODEV; |
| 529 | |
| 530 | no_command_private: |
| 531 | for (i = serial->num_ports - 1; i >= 0; i--) { |
| 532 | port = serial->port[i]; |
| 533 | info = usb_get_serial_port_data(port); |
| 534 | for (j = urb_pool_size - 1; j >= 0; j--) { |
| 535 | tmp = list_first(&info->tx_urbs_free); |
| 536 | list_del(tmp); |
| 537 | wrap = list_entry(tmp, struct whiteheat_urb_wrap, list); |
| 538 | urb = wrap->urb; |
| 539 | kfree(wrap); |
| 540 | no_tx_wrap: |
| 541 | kfree(urb->transfer_buffer); |
| 542 | no_tx_buf: |
| 543 | usb_free_urb(urb); |
| 544 | no_tx_urb: |
| 545 | tmp = list_first(&info->rx_urbs_free); |
| 546 | list_del(tmp); |
| 547 | wrap = list_entry(tmp, struct whiteheat_urb_wrap, list); |
| 548 | urb = wrap->urb; |
| 549 | kfree(wrap); |
| 550 | no_rx_wrap: |
| 551 | kfree(urb->transfer_buffer); |
| 552 | no_rx_buf: |
| 553 | usb_free_urb(urb); |
| 554 | no_rx_urb: |
| 555 | ; |
| 556 | } |
| 557 | kfree(info); |
| 558 | no_private: |
| 559 | ; |
| 560 | } |
| 561 | kfree(result); |
| 562 | no_result_buffer: |
| 563 | kfree(command); |
| 564 | no_command_buffer: |
| 565 | return -ENOMEM; |
| 566 | } |
| 567 | |
| 568 | |
Alan Stern | f9c99bb | 2009-06-02 11:53:55 -0400 | [diff] [blame] | 569 | static void whiteheat_release(struct usb_serial *serial) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 | { |
| 571 | struct usb_serial_port *command_port; |
| 572 | struct usb_serial_port *port; |
| 573 | struct whiteheat_private *info; |
| 574 | struct whiteheat_urb_wrap *wrap; |
| 575 | struct urb *urb; |
| 576 | struct list_head *tmp; |
| 577 | struct list_head *tmp2; |
| 578 | int i; |
| 579 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 580 | dbg("%s", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | |
| 582 | /* free up our private data for our command port */ |
| 583 | command_port = serial->port[COMMAND_PORT]; |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 584 | kfree(usb_get_serial_port_data(command_port)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | |
| 586 | for (i = 0; i < serial->num_ports; i++) { |
| 587 | port = serial->port[i]; |
| 588 | info = usb_get_serial_port_data(port); |
| 589 | list_for_each_safe(tmp, tmp2, &info->rx_urbs_free) { |
| 590 | list_del(tmp); |
| 591 | wrap = list_entry(tmp, struct whiteheat_urb_wrap, list); |
| 592 | urb = wrap->urb; |
| 593 | kfree(wrap); |
| 594 | kfree(urb->transfer_buffer); |
| 595 | usb_free_urb(urb); |
| 596 | } |
| 597 | list_for_each_safe(tmp, tmp2, &info->tx_urbs_free) { |
| 598 | list_del(tmp); |
| 599 | wrap = list_entry(tmp, struct whiteheat_urb_wrap, list); |
| 600 | urb = wrap->urb; |
| 601 | kfree(wrap); |
| 602 | kfree(urb->transfer_buffer); |
| 603 | usb_free_urb(urb); |
| 604 | } |
| 605 | kfree(info); |
| 606 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 607 | } |
| 608 | |
Alan Cox | a509a7e | 2009-09-19 13:13:26 -0700 | [diff] [blame] | 609 | static int whiteheat_open(struct tty_struct *tty, struct usb_serial_port *port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | { |
| 611 | int retval = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 612 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 613 | dbg("%s - port %d", __func__, port->number); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 | |
| 615 | retval = start_command_port(port->serial); |
| 616 | if (retval) |
| 617 | goto exit; |
| 618 | |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 619 | if (tty) |
| 620 | tty->low_latency = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 621 | |
| 622 | /* send an open port command */ |
| 623 | retval = firm_open(port); |
| 624 | if (retval) { |
| 625 | stop_command_port(port->serial); |
| 626 | goto exit; |
| 627 | } |
| 628 | |
| 629 | retval = firm_purge(port, WHITEHEAT_PURGE_RX | WHITEHEAT_PURGE_TX); |
| 630 | if (retval) { |
| 631 | firm_close(port); |
| 632 | stop_command_port(port->serial); |
| 633 | goto exit; |
| 634 | } |
| 635 | |
Alan Cox | 72e2741 | 2008-07-22 11:09:29 +0100 | [diff] [blame] | 636 | if (tty) |
| 637 | firm_setup_port(tty); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 638 | |
| 639 | /* Work around HCD bugs */ |
| 640 | usb_clear_halt(port->serial->dev, port->read_urb->pipe); |
| 641 | usb_clear_halt(port->serial->dev, port->write_urb->pipe); |
| 642 | |
| 643 | /* Start reading from the device */ |
| 644 | retval = start_port_read(port); |
| 645 | if (retval) { |
Greg Kroah-Hartman | 194343d | 2008-08-20 16:56:34 -0700 | [diff] [blame] | 646 | dev_err(&port->dev, |
| 647 | "%s - failed submitting read urb, error %d\n", |
| 648 | __func__, retval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | firm_close(port); |
| 650 | stop_command_port(port->serial); |
| 651 | goto exit; |
| 652 | } |
| 653 | |
| 654 | exit: |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 655 | dbg("%s - exit, retval = %d", __func__, retval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 656 | return retval; |
| 657 | } |
| 658 | |
| 659 | |
Alan Cox | 335f851 | 2009-06-11 12:26:29 +0100 | [diff] [blame] | 660 | static void whiteheat_close(struct usb_serial_port *port) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 661 | { |
| 662 | struct whiteheat_private *info = usb_get_serial_port_data(port); |
| 663 | struct whiteheat_urb_wrap *wrap; |
| 664 | struct urb *urb; |
| 665 | struct list_head *tmp; |
| 666 | struct list_head *tmp2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 667 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 668 | dbg("%s - port %d", __func__, port->number); |
Oliver Neukum | e33fe4d | 2008-01-21 17:44:10 +0100 | [diff] [blame] | 669 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 670 | firm_report_tx_done(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 671 | firm_close(port); |
| 672 | |
| 673 | /* shutdown our bulk reads and writes */ |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 674 | mutex_lock(&info->deathwarrant); |
| 675 | spin_lock_irq(&info->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 676 | list_for_each_safe(tmp, tmp2, &info->rx_urbs_submitted) { |
| 677 | wrap = list_entry(tmp, struct whiteheat_urb_wrap, list); |
| 678 | urb = wrap->urb; |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 679 | list_del(tmp); |
| 680 | spin_unlock_irq(&info->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 681 | usb_kill_urb(urb); |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 682 | spin_lock_irq(&info->lock); |
| 683 | list_add(tmp, &info->rx_urbs_free); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 684 | } |
Akinobu Mita | 179e091 | 2006-06-26 00:24:41 -0700 | [diff] [blame] | 685 | list_for_each_safe(tmp, tmp2, &info->rx_urb_q) |
| 686 | list_move(tmp, &info->rx_urbs_free); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 687 | list_for_each_safe(tmp, tmp2, &info->tx_urbs_submitted) { |
| 688 | wrap = list_entry(tmp, struct whiteheat_urb_wrap, list); |
| 689 | urb = wrap->urb; |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 690 | list_del(tmp); |
| 691 | spin_unlock_irq(&info->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 692 | usb_kill_urb(urb); |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 693 | spin_lock_irq(&info->lock); |
| 694 | list_add(tmp, &info->tx_urbs_free); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 695 | } |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 696 | spin_unlock_irq(&info->lock); |
| 697 | mutex_unlock(&info->deathwarrant); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 698 | stop_command_port(port->serial); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | } |
| 700 | |
| 701 | |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 702 | static int whiteheat_write(struct tty_struct *tty, |
| 703 | struct usb_serial_port *port, const unsigned char *buf, int count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 704 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 705 | struct whiteheat_private *info = usb_get_serial_port_data(port); |
| 706 | struct whiteheat_urb_wrap *wrap; |
| 707 | struct urb *urb; |
| 708 | int result; |
| 709 | int bytes; |
| 710 | int sent = 0; |
| 711 | unsigned long flags; |
| 712 | struct list_head *tmp; |
| 713 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 714 | dbg("%s - port %d", __func__, port->number); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 715 | |
| 716 | if (count == 0) { |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 717 | dbg("%s - write request of 0 bytes", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 718 | return (0); |
| 719 | } |
| 720 | |
| 721 | while (count) { |
| 722 | spin_lock_irqsave(&info->lock, flags); |
| 723 | if (list_empty(&info->tx_urbs_free)) { |
| 724 | spin_unlock_irqrestore(&info->lock, flags); |
| 725 | break; |
| 726 | } |
| 727 | tmp = list_first(&info->tx_urbs_free); |
| 728 | list_del(tmp); |
| 729 | spin_unlock_irqrestore(&info->lock, flags); |
| 730 | |
| 731 | wrap = list_entry(tmp, struct whiteheat_urb_wrap, list); |
| 732 | urb = wrap->urb; |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 733 | bytes = (count > port->bulk_out_size) ? |
| 734 | port->bulk_out_size : count; |
| 735 | memcpy(urb->transfer_buffer, buf + sent, bytes); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 736 | |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 737 | usb_serial_debug_data(debug, &port->dev, |
| 738 | __func__, bytes, urb->transfer_buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 739 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 740 | urb->transfer_buffer_length = bytes; |
| 741 | result = usb_submit_urb(urb, GFP_ATOMIC); |
| 742 | if (result) { |
Greg Kroah-Hartman | 194343d | 2008-08-20 16:56:34 -0700 | [diff] [blame] | 743 | dev_err(&port->dev, |
| 744 | "%s - failed submitting write urb, error %d\n", |
| 745 | __func__, result); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 746 | sent = result; |
| 747 | spin_lock_irqsave(&info->lock, flags); |
| 748 | list_add(tmp, &info->tx_urbs_free); |
| 749 | spin_unlock_irqrestore(&info->lock, flags); |
| 750 | break; |
| 751 | } else { |
| 752 | sent += bytes; |
| 753 | count -= bytes; |
| 754 | spin_lock_irqsave(&info->lock, flags); |
| 755 | list_add(tmp, &info->tx_urbs_submitted); |
| 756 | spin_unlock_irqrestore(&info->lock, flags); |
| 757 | } |
| 758 | } |
| 759 | |
| 760 | return sent; |
| 761 | } |
| 762 | |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 763 | static int whiteheat_write_room(struct tty_struct *tty) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 764 | { |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 765 | struct usb_serial_port *port = tty->driver_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 766 | struct whiteheat_private *info = usb_get_serial_port_data(port); |
| 767 | struct list_head *tmp; |
| 768 | int room = 0; |
| 769 | unsigned long flags; |
| 770 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 771 | dbg("%s - port %d", __func__, port->number); |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 772 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 773 | spin_lock_irqsave(&info->lock, flags); |
| 774 | list_for_each(tmp, &info->tx_urbs_free) |
| 775 | room++; |
| 776 | spin_unlock_irqrestore(&info->lock, flags); |
| 777 | room *= port->bulk_out_size; |
| 778 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 779 | dbg("%s - returns %d", __func__, room); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 780 | return (room); |
| 781 | } |
| 782 | |
Alan Cox | 60b33c1 | 2011-02-14 16:26:14 +0000 | [diff] [blame] | 783 | static int whiteheat_tiocmget(struct tty_struct *tty) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 784 | { |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 785 | struct usb_serial_port *port = tty->driver_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 786 | struct whiteheat_private *info = usb_get_serial_port_data(port); |
| 787 | unsigned int modem_signals = 0; |
| 788 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 789 | dbg("%s - port %d", __func__, port->number); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 790 | |
| 791 | firm_get_dtr_rts(port); |
| 792 | if (info->mcr & UART_MCR_DTR) |
| 793 | modem_signals |= TIOCM_DTR; |
| 794 | if (info->mcr & UART_MCR_RTS) |
| 795 | modem_signals |= TIOCM_RTS; |
| 796 | |
| 797 | return modem_signals; |
| 798 | } |
| 799 | |
Alan Cox | 20b9d17 | 2011-02-14 16:26:50 +0000 | [diff] [blame] | 800 | static int whiteheat_tiocmset(struct tty_struct *tty, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 801 | unsigned int set, unsigned int clear) |
| 802 | { |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 803 | struct usb_serial_port *port = tty->driver_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 804 | struct whiteheat_private *info = usb_get_serial_port_data(port); |
| 805 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 806 | dbg("%s - port %d", __func__, port->number); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 807 | |
| 808 | if (set & TIOCM_RTS) |
| 809 | info->mcr |= UART_MCR_RTS; |
| 810 | if (set & TIOCM_DTR) |
| 811 | info->mcr |= UART_MCR_DTR; |
| 812 | |
| 813 | if (clear & TIOCM_RTS) |
| 814 | info->mcr &= ~UART_MCR_RTS; |
| 815 | if (clear & TIOCM_DTR) |
| 816 | info->mcr &= ~UART_MCR_DTR; |
| 817 | |
| 818 | firm_set_dtr(port, info->mcr & UART_MCR_DTR); |
| 819 | firm_set_rts(port, info->mcr & UART_MCR_RTS); |
| 820 | return 0; |
| 821 | } |
| 822 | |
| 823 | |
Alan Cox | 00a0d0d | 2011-02-14 16:27:06 +0000 | [diff] [blame] | 824 | static int whiteheat_ioctl(struct tty_struct *tty, |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 825 | unsigned int cmd, unsigned long arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 826 | { |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 827 | struct usb_serial_port *port = tty->driver_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 828 | struct serial_struct serstruct; |
| 829 | void __user *user_arg = (void __user *)arg; |
| 830 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 831 | dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 832 | |
| 833 | switch (cmd) { |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 834 | case TIOCGSERIAL: |
| 835 | memset(&serstruct, 0, sizeof(serstruct)); |
| 836 | serstruct.type = PORT_16654; |
| 837 | serstruct.line = port->serial->minor; |
| 838 | serstruct.port = port->number; |
| 839 | serstruct.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ; |
| 840 | serstruct.xmit_fifo_size = port->bulk_out_size; |
| 841 | serstruct.custom_divisor = 0; |
| 842 | serstruct.baud_base = 460800; |
| 843 | serstruct.close_delay = CLOSING_DELAY; |
| 844 | serstruct.closing_wait = CLOSING_DELAY; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 845 | |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 846 | if (copy_to_user(user_arg, &serstruct, sizeof(serstruct))) |
| 847 | return -EFAULT; |
| 848 | break; |
| 849 | default: |
| 850 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 851 | } |
| 852 | |
| 853 | return -ENOIOCTLCMD; |
| 854 | } |
| 855 | |
| 856 | |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 857 | static void whiteheat_set_termios(struct tty_struct *tty, |
| 858 | struct usb_serial_port *port, struct ktermios *old_termios) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 859 | { |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 860 | firm_setup_port(tty); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 861 | } |
| 862 | |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 863 | static void whiteheat_break_ctl(struct tty_struct *tty, int break_state) |
| 864 | { |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 865 | struct usb_serial_port *port = tty->driver_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 866 | firm_set_break(port, break_state); |
| 867 | } |
| 868 | |
| 869 | |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 870 | static int whiteheat_chars_in_buffer(struct tty_struct *tty) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 871 | { |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 872 | struct usb_serial_port *port = tty->driver_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 873 | struct whiteheat_private *info = usb_get_serial_port_data(port); |
| 874 | struct list_head *tmp; |
| 875 | struct whiteheat_urb_wrap *wrap; |
| 876 | int chars = 0; |
| 877 | unsigned long flags; |
| 878 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 879 | dbg("%s - port %d", __func__, port->number); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 880 | |
| 881 | spin_lock_irqsave(&info->lock, flags); |
| 882 | list_for_each(tmp, &info->tx_urbs_submitted) { |
| 883 | wrap = list_entry(tmp, struct whiteheat_urb_wrap, list); |
| 884 | chars += wrap->urb->transfer_buffer_length; |
| 885 | } |
| 886 | spin_unlock_irqrestore(&info->lock, flags); |
| 887 | |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 888 | dbg("%s - returns %d", __func__, chars); |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 889 | return chars; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 890 | } |
| 891 | |
| 892 | |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 893 | static void whiteheat_throttle(struct tty_struct *tty) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 894 | { |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 895 | struct usb_serial_port *port = tty->driver_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 896 | struct whiteheat_private *info = usb_get_serial_port_data(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 897 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 898 | dbg("%s - port %d", __func__, port->number); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 899 | |
Oliver Neukum | 6383251 | 2009-10-07 10:50:23 +0200 | [diff] [blame] | 900 | spin_lock_irq(&info->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 901 | info->flags |= THROTTLED; |
Oliver Neukum | 6383251 | 2009-10-07 10:50:23 +0200 | [diff] [blame] | 902 | spin_unlock_irq(&info->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 903 | } |
| 904 | |
| 905 | |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 906 | static void whiteheat_unthrottle(struct tty_struct *tty) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 907 | { |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 908 | struct usb_serial_port *port = tty->driver_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 909 | struct whiteheat_private *info = usb_get_serial_port_data(port); |
| 910 | int actually_throttled; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 911 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 912 | dbg("%s - port %d", __func__, port->number); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 913 | |
Oliver Neukum | 6383251 | 2009-10-07 10:50:23 +0200 | [diff] [blame] | 914 | spin_lock_irq(&info->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 915 | actually_throttled = info->flags & ACTUALLY_THROTTLED; |
| 916 | info->flags &= ~(THROTTLED | ACTUALLY_THROTTLED); |
Oliver Neukum | 6383251 | 2009-10-07 10:50:23 +0200 | [diff] [blame] | 917 | spin_unlock_irq(&info->lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 918 | |
| 919 | if (actually_throttled) |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 920 | rx_data_softint(&info->rx_work); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 921 | } |
| 922 | |
| 923 | |
| 924 | /***************************************************************************** |
| 925 | * Connect Tech's White Heat callback routines |
| 926 | *****************************************************************************/ |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 927 | static void command_port_write_callback(struct urb *urb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 928 | { |
Greg Kroah-Hartman | 0540001 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 929 | int status = urb->status; |
| 930 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 931 | dbg("%s", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 932 | |
Greg Kroah-Hartman | 0540001 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 933 | if (status) { |
| 934 | dbg("nonzero urb status: %d", status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 935 | return; |
| 936 | } |
| 937 | } |
| 938 | |
| 939 | |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 940 | static void command_port_read_callback(struct urb *urb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 941 | { |
Ming Lei | cdc9779 | 2008-02-24 18:41:47 +0800 | [diff] [blame] | 942 | struct usb_serial_port *command_port = urb->context; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 943 | struct whiteheat_command_private *command_info; |
Greg Kroah-Hartman | 0540001 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 944 | int status = urb->status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 945 | unsigned char *data = urb->transfer_buffer; |
| 946 | int result; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 947 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 948 | dbg("%s", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 949 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 950 | command_info = usb_get_serial_port_data(command_port); |
| 951 | if (!command_info) { |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 952 | dbg("%s - command_info is NULL, exiting.", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 953 | return; |
| 954 | } |
Greg Kroah-Hartman | 0540001 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 955 | if (status) { |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 956 | dbg("%s - nonzero urb status: %d", __func__, status); |
Greg Kroah-Hartman | 0540001 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 957 | if (status != -ENOENT) |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 958 | command_info->command_finished = WHITEHEAT_CMD_FAILURE; |
| 959 | wake_up(&command_info->wait_command); |
| 960 | return; |
| 961 | } |
| 962 | |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 963 | usb_serial_debug_data(debug, &command_port->dev, |
| 964 | __func__, urb->actual_length, data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 965 | |
| 966 | if (data[0] == WHITEHEAT_CMD_COMPLETE) { |
| 967 | command_info->command_finished = WHITEHEAT_CMD_COMPLETE; |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 968 | wake_up(&command_info->wait_command); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 969 | } else if (data[0] == WHITEHEAT_CMD_FAILURE) { |
| 970 | command_info->command_finished = WHITEHEAT_CMD_FAILURE; |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 971 | wake_up(&command_info->wait_command); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 972 | } else if (data[0] == WHITEHEAT_EVENT) { |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 973 | /* These are unsolicited reports from the firmware, hence no |
| 974 | waiting command to wakeup */ |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 975 | dbg("%s - event received", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 976 | } else if (data[0] == WHITEHEAT_GET_DTR_RTS) { |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 977 | memcpy(command_info->result_buffer, &data[1], |
| 978 | urb->actual_length - 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 979 | command_info->command_finished = WHITEHEAT_CMD_COMPLETE; |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 980 | wake_up(&command_info->wait_command); |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 981 | } else |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 982 | dbg("%s - bad reply from firmware", __func__); |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 983 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 984 | /* Continue trying to always read */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 985 | result = usb_submit_urb(command_port->read_urb, GFP_ATOMIC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 986 | if (result) |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 987 | dbg("%s - failed resubmitting read urb, error %d", |
| 988 | __func__, result); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 989 | } |
| 990 | |
| 991 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 992 | static void whiteheat_read_callback(struct urb *urb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 993 | { |
Ming Lei | cdc9779 | 2008-02-24 18:41:47 +0800 | [diff] [blame] | 994 | struct usb_serial_port *port = urb->context; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 995 | struct whiteheat_urb_wrap *wrap; |
| 996 | unsigned char *data = urb->transfer_buffer; |
| 997 | struct whiteheat_private *info = usb_get_serial_port_data(port); |
Greg Kroah-Hartman | 0540001 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 998 | int status = urb->status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 999 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 1000 | dbg("%s - port %d", __func__, port->number); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1001 | |
| 1002 | spin_lock(&info->lock); |
| 1003 | wrap = urb_to_wrap(urb, &info->rx_urbs_submitted); |
| 1004 | if (!wrap) { |
| 1005 | spin_unlock(&info->lock); |
Greg Kroah-Hartman | 194343d | 2008-08-20 16:56:34 -0700 | [diff] [blame] | 1006 | dev_err(&port->dev, "%s - Not my urb!\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1007 | return; |
| 1008 | } |
| 1009 | list_del(&wrap->list); |
| 1010 | spin_unlock(&info->lock); |
| 1011 | |
Greg Kroah-Hartman | 0540001 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 1012 | if (status) { |
| 1013 | dbg("%s - nonzero read bulk status received: %d", |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 1014 | __func__, status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1015 | spin_lock(&info->lock); |
| 1016 | list_add(&wrap->list, &info->rx_urbs_free); |
| 1017 | spin_unlock(&info->lock); |
| 1018 | return; |
| 1019 | } |
| 1020 | |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1021 | usb_serial_debug_data(debug, &port->dev, |
| 1022 | __func__, urb->actual_length, data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1023 | |
| 1024 | spin_lock(&info->lock); |
| 1025 | list_add_tail(&wrap->list, &info->rx_urb_q); |
| 1026 | if (info->flags & THROTTLED) { |
| 1027 | info->flags |= ACTUALLY_THROTTLED; |
| 1028 | spin_unlock(&info->lock); |
| 1029 | return; |
| 1030 | } |
| 1031 | spin_unlock(&info->lock); |
| 1032 | |
| 1033 | schedule_work(&info->rx_work); |
| 1034 | } |
| 1035 | |
| 1036 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 1037 | static void whiteheat_write_callback(struct urb *urb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1038 | { |
Ming Lei | cdc9779 | 2008-02-24 18:41:47 +0800 | [diff] [blame] | 1039 | struct usb_serial_port *port = urb->context; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1040 | struct whiteheat_private *info = usb_get_serial_port_data(port); |
| 1041 | struct whiteheat_urb_wrap *wrap; |
Greg Kroah-Hartman | 0540001 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 1042 | int status = urb->status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1043 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 1044 | dbg("%s - port %d", __func__, port->number); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1045 | |
| 1046 | spin_lock(&info->lock); |
| 1047 | wrap = urb_to_wrap(urb, &info->tx_urbs_submitted); |
| 1048 | if (!wrap) { |
| 1049 | spin_unlock(&info->lock); |
Greg Kroah-Hartman | 194343d | 2008-08-20 16:56:34 -0700 | [diff] [blame] | 1050 | dev_err(&port->dev, "%s - Not my urb!\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1051 | return; |
| 1052 | } |
Akinobu Mita | 179e091 | 2006-06-26 00:24:41 -0700 | [diff] [blame] | 1053 | list_move(&wrap->list, &info->tx_urbs_free); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1054 | spin_unlock(&info->lock); |
| 1055 | |
Greg Kroah-Hartman | 0540001 | 2007-06-15 15:44:13 -0700 | [diff] [blame] | 1056 | if (status) { |
| 1057 | dbg("%s - nonzero write bulk status received: %d", |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 1058 | __func__, status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1059 | return; |
| 1060 | } |
| 1061 | |
Pete Zaitcev | cf2c748 | 2006-05-22 21:58:49 -0700 | [diff] [blame] | 1062 | usb_serial_port_softint(port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1063 | } |
| 1064 | |
| 1065 | |
| 1066 | /***************************************************************************** |
| 1067 | * Connect Tech's White Heat firmware interface |
| 1068 | *****************************************************************************/ |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1069 | static int firm_send_command(struct usb_serial_port *port, __u8 command, |
| 1070 | __u8 *data, __u8 datasize) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1071 | { |
| 1072 | struct usb_serial_port *command_port; |
| 1073 | struct whiteheat_command_private *command_info; |
| 1074 | struct whiteheat_private *info; |
| 1075 | __u8 *transfer_buffer; |
| 1076 | int retval = 0; |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 1077 | int t; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1078 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 1079 | dbg("%s - command %d", __func__, command); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1080 | |
| 1081 | command_port = port->serial->port[COMMAND_PORT]; |
| 1082 | command_info = usb_get_serial_port_data(command_port); |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 1083 | mutex_lock(&command_info->mutex); |
Richard Knutsson | 38c3cb5 | 2007-03-26 22:00:28 -0800 | [diff] [blame] | 1084 | command_info->command_finished = false; |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1085 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1086 | transfer_buffer = (__u8 *)command_port->write_urb->transfer_buffer; |
| 1087 | transfer_buffer[0] = command; |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1088 | memcpy(&transfer_buffer[1], data, datasize); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1089 | command_port->write_urb->transfer_buffer_length = datasize + 1; |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1090 | retval = usb_submit_urb(command_port->write_urb, GFP_NOIO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1091 | if (retval) { |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 1092 | dbg("%s - submit urb failed", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1093 | goto exit; |
| 1094 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1095 | |
| 1096 | /* wait for the command to complete */ |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 1097 | t = wait_event_timeout(command_info->wait_command, |
Richard Knutsson | 38c3cb5 | 2007-03-26 22:00:28 -0800 | [diff] [blame] | 1098 | (bool)command_info->command_finished, COMMAND_TIMEOUT); |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 1099 | if (!t) |
| 1100 | usb_kill_urb(command_port->write_urb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1101 | |
Richard Knutsson | 38c3cb5 | 2007-03-26 22:00:28 -0800 | [diff] [blame] | 1102 | if (command_info->command_finished == false) { |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 1103 | dbg("%s - command timed out.", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1104 | retval = -ETIMEDOUT; |
| 1105 | goto exit; |
| 1106 | } |
| 1107 | |
| 1108 | if (command_info->command_finished == WHITEHEAT_CMD_FAILURE) { |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 1109 | dbg("%s - command failed.", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1110 | retval = -EIO; |
| 1111 | goto exit; |
| 1112 | } |
| 1113 | |
| 1114 | if (command_info->command_finished == WHITEHEAT_CMD_COMPLETE) { |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 1115 | dbg("%s - command completed.", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1116 | switch (command) { |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1117 | case WHITEHEAT_GET_DTR_RTS: |
| 1118 | info = usb_get_serial_port_data(port); |
| 1119 | memcpy(&info->mcr, command_info->result_buffer, |
| 1120 | sizeof(struct whiteheat_dr_info)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1121 | break; |
| 1122 | } |
| 1123 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1124 | exit: |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 1125 | mutex_unlock(&command_info->mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1126 | return retval; |
| 1127 | } |
| 1128 | |
| 1129 | |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1130 | static int firm_open(struct usb_serial_port *port) |
| 1131 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1132 | struct whiteheat_simple open_command; |
| 1133 | |
| 1134 | open_command.port = port->number - port->serial->minor + 1; |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1135 | return firm_send_command(port, WHITEHEAT_OPEN, |
| 1136 | (__u8 *)&open_command, sizeof(open_command)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1137 | } |
| 1138 | |
| 1139 | |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1140 | static int firm_close(struct usb_serial_port *port) |
| 1141 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1142 | struct whiteheat_simple close_command; |
| 1143 | |
| 1144 | close_command.port = port->number - port->serial->minor + 1; |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1145 | return firm_send_command(port, WHITEHEAT_CLOSE, |
| 1146 | (__u8 *)&close_command, sizeof(close_command)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1147 | } |
| 1148 | |
| 1149 | |
Alan Cox | fe1ae7f | 2009-09-19 13:13:33 -0700 | [diff] [blame] | 1150 | static void firm_setup_port(struct tty_struct *tty) |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1151 | { |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 1152 | struct usb_serial_port *port = tty->driver_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1153 | struct whiteheat_port_settings port_settings; |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 1154 | unsigned int cflag = tty->termios->c_cflag; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1155 | |
| 1156 | port_settings.port = port->number + 1; |
| 1157 | |
| 1158 | /* get the byte size */ |
| 1159 | switch (cflag & CSIZE) { |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1160 | case CS5: port_settings.bits = 5; break; |
| 1161 | case CS6: port_settings.bits = 6; break; |
| 1162 | case CS7: port_settings.bits = 7; break; |
| 1163 | default: |
| 1164 | case CS8: port_settings.bits = 8; break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1165 | } |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 1166 | dbg("%s - data bits = %d", __func__, port_settings.bits); |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1167 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1168 | /* determine the parity */ |
| 1169 | if (cflag & PARENB) |
| 1170 | if (cflag & CMSPAR) |
| 1171 | if (cflag & PARODD) |
| 1172 | port_settings.parity = WHITEHEAT_PAR_MARK; |
| 1173 | else |
| 1174 | port_settings.parity = WHITEHEAT_PAR_SPACE; |
| 1175 | else |
| 1176 | if (cflag & PARODD) |
| 1177 | port_settings.parity = WHITEHEAT_PAR_ODD; |
| 1178 | else |
| 1179 | port_settings.parity = WHITEHEAT_PAR_EVEN; |
| 1180 | else |
| 1181 | port_settings.parity = WHITEHEAT_PAR_NONE; |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 1182 | dbg("%s - parity = %c", __func__, port_settings.parity); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1183 | |
| 1184 | /* figure out the stop bits requested */ |
| 1185 | if (cflag & CSTOPB) |
| 1186 | port_settings.stop = 2; |
| 1187 | else |
| 1188 | port_settings.stop = 1; |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 1189 | dbg("%s - stop bits = %d", __func__, port_settings.stop); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1190 | |
| 1191 | /* figure out the flow control settings */ |
| 1192 | if (cflag & CRTSCTS) |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1193 | port_settings.hflow = (WHITEHEAT_HFLOW_CTS | |
| 1194 | WHITEHEAT_HFLOW_RTS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1195 | else |
| 1196 | port_settings.hflow = WHITEHEAT_HFLOW_NONE; |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 1197 | dbg("%s - hardware flow control = %s %s %s %s", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1198 | (port_settings.hflow & WHITEHEAT_HFLOW_CTS) ? "CTS" : "", |
| 1199 | (port_settings.hflow & WHITEHEAT_HFLOW_RTS) ? "RTS" : "", |
| 1200 | (port_settings.hflow & WHITEHEAT_HFLOW_DSR) ? "DSR" : "", |
| 1201 | (port_settings.hflow & WHITEHEAT_HFLOW_DTR) ? "DTR" : ""); |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1202 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1203 | /* determine software flow control */ |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 1204 | if (I_IXOFF(tty)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1205 | port_settings.sflow = WHITEHEAT_SFLOW_RXTX; |
| 1206 | else |
| 1207 | port_settings.sflow = WHITEHEAT_SFLOW_NONE; |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 1208 | dbg("%s - software flow control = %c", __func__, port_settings.sflow); |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1209 | |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 1210 | port_settings.xon = START_CHAR(tty); |
| 1211 | port_settings.xoff = STOP_CHAR(tty); |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1212 | dbg("%s - XON = %2x, XOFF = %2x", |
| 1213 | __func__, port_settings.xon, port_settings.xoff); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1214 | |
| 1215 | /* get the baud rate wanted */ |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 1216 | port_settings.baud = tty_get_baud_rate(tty); |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 1217 | dbg("%s - baud rate = %d", __func__, port_settings.baud); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1218 | |
Alan Cox | 01d1df2 | 2007-10-18 01:24:23 -0700 | [diff] [blame] | 1219 | /* fixme: should set validated settings */ |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 1220 | tty_encode_baud_rate(tty, port_settings.baud, port_settings.baud); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1221 | /* handle any settings that aren't specified in the tty structure */ |
| 1222 | port_settings.lloop = 0; |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1223 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1224 | /* now send the message to the device */ |
Alan Cox | fe1ae7f | 2009-09-19 13:13:33 -0700 | [diff] [blame] | 1225 | firm_send_command(port, WHITEHEAT_SETUP_PORT, |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1226 | (__u8 *)&port_settings, sizeof(port_settings)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1227 | } |
| 1228 | |
| 1229 | |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1230 | static int firm_set_rts(struct usb_serial_port *port, __u8 onoff) |
| 1231 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1232 | struct whiteheat_set_rdb rts_command; |
| 1233 | |
| 1234 | rts_command.port = port->number - port->serial->minor + 1; |
| 1235 | rts_command.state = onoff; |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1236 | return firm_send_command(port, WHITEHEAT_SET_RTS, |
| 1237 | (__u8 *)&rts_command, sizeof(rts_command)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1238 | } |
| 1239 | |
| 1240 | |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1241 | static int firm_set_dtr(struct usb_serial_port *port, __u8 onoff) |
| 1242 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1243 | struct whiteheat_set_rdb dtr_command; |
| 1244 | |
| 1245 | dtr_command.port = port->number - port->serial->minor + 1; |
| 1246 | dtr_command.state = onoff; |
Alan Cox | 72e2741 | 2008-07-22 11:09:29 +0100 | [diff] [blame] | 1247 | return firm_send_command(port, WHITEHEAT_SET_DTR, |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1248 | (__u8 *)&dtr_command, sizeof(dtr_command)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1249 | } |
| 1250 | |
| 1251 | |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1252 | static int firm_set_break(struct usb_serial_port *port, __u8 onoff) |
| 1253 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1254 | struct whiteheat_set_rdb break_command; |
| 1255 | |
| 1256 | break_command.port = port->number - port->serial->minor + 1; |
| 1257 | break_command.state = onoff; |
Alan Cox | 72e2741 | 2008-07-22 11:09:29 +0100 | [diff] [blame] | 1258 | return firm_send_command(port, WHITEHEAT_SET_BREAK, |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1259 | (__u8 *)&break_command, sizeof(break_command)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1260 | } |
| 1261 | |
| 1262 | |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1263 | static int firm_purge(struct usb_serial_port *port, __u8 rxtx) |
| 1264 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1265 | struct whiteheat_purge purge_command; |
| 1266 | |
| 1267 | purge_command.port = port->number - port->serial->minor + 1; |
| 1268 | purge_command.what = rxtx; |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1269 | return firm_send_command(port, WHITEHEAT_PURGE, |
| 1270 | (__u8 *)&purge_command, sizeof(purge_command)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1271 | } |
| 1272 | |
| 1273 | |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1274 | static int firm_get_dtr_rts(struct usb_serial_port *port) |
| 1275 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1276 | struct whiteheat_simple get_dr_command; |
| 1277 | |
| 1278 | get_dr_command.port = port->number - port->serial->minor + 1; |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1279 | return firm_send_command(port, WHITEHEAT_GET_DTR_RTS, |
| 1280 | (__u8 *)&get_dr_command, sizeof(get_dr_command)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1281 | } |
| 1282 | |
| 1283 | |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1284 | static int firm_report_tx_done(struct usb_serial_port *port) |
| 1285 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1286 | struct whiteheat_simple close_command; |
| 1287 | |
| 1288 | close_command.port = port->number - port->serial->minor + 1; |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1289 | return firm_send_command(port, WHITEHEAT_REPORT_TX_DONE, |
| 1290 | (__u8 *)&close_command, sizeof(close_command)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1291 | } |
| 1292 | |
| 1293 | |
| 1294 | /***************************************************************************** |
| 1295 | * Connect Tech's White Heat utility functions |
| 1296 | *****************************************************************************/ |
| 1297 | static int start_command_port(struct usb_serial *serial) |
| 1298 | { |
| 1299 | struct usb_serial_port *command_port; |
| 1300 | struct whiteheat_command_private *command_info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1301 | int retval = 0; |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1302 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1303 | command_port = serial->port[COMMAND_PORT]; |
| 1304 | command_info = usb_get_serial_port_data(command_port); |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 1305 | mutex_lock(&command_info->mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1306 | if (!command_info->port_running) { |
| 1307 | /* Work around HCD bugs */ |
| 1308 | usb_clear_halt(serial->dev, command_port->read_urb->pipe); |
| 1309 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1310 | retval = usb_submit_urb(command_port->read_urb, GFP_KERNEL); |
| 1311 | if (retval) { |
Greg Kroah-Hartman | 194343d | 2008-08-20 16:56:34 -0700 | [diff] [blame] | 1312 | dev_err(&serial->dev->dev, |
| 1313 | "%s - failed submitting read urb, error %d\n", |
| 1314 | __func__, retval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1315 | goto exit; |
| 1316 | } |
| 1317 | } |
| 1318 | command_info->port_running++; |
| 1319 | |
| 1320 | exit: |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 1321 | mutex_unlock(&command_info->mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1322 | return retval; |
| 1323 | } |
| 1324 | |
| 1325 | |
| 1326 | static void stop_command_port(struct usb_serial *serial) |
| 1327 | { |
| 1328 | struct usb_serial_port *command_port; |
| 1329 | struct whiteheat_command_private *command_info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1330 | |
| 1331 | command_port = serial->port[COMMAND_PORT]; |
| 1332 | command_info = usb_get_serial_port_data(command_port); |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 1333 | mutex_lock(&command_info->mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1334 | command_info->port_running--; |
| 1335 | if (!command_info->port_running) |
| 1336 | usb_kill_urb(command_port->read_urb); |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 1337 | mutex_unlock(&command_info->mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1338 | } |
| 1339 | |
| 1340 | |
| 1341 | static int start_port_read(struct usb_serial_port *port) |
| 1342 | { |
| 1343 | struct whiteheat_private *info = usb_get_serial_port_data(port); |
| 1344 | struct whiteheat_urb_wrap *wrap; |
| 1345 | struct urb *urb; |
| 1346 | int retval = 0; |
| 1347 | unsigned long flags; |
| 1348 | struct list_head *tmp; |
| 1349 | struct list_head *tmp2; |
| 1350 | |
| 1351 | spin_lock_irqsave(&info->lock, flags); |
| 1352 | |
| 1353 | list_for_each_safe(tmp, tmp2, &info->rx_urbs_free) { |
| 1354 | list_del(tmp); |
| 1355 | wrap = list_entry(tmp, struct whiteheat_urb_wrap, list); |
| 1356 | urb = wrap->urb; |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 1357 | spin_unlock_irqrestore(&info->lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1358 | retval = usb_submit_urb(urb, GFP_KERNEL); |
| 1359 | if (retval) { |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 1360 | spin_lock_irqsave(&info->lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1361 | list_add(tmp, &info->rx_urbs_free); |
| 1362 | list_for_each_safe(tmp, tmp2, &info->rx_urbs_submitted) { |
| 1363 | wrap = list_entry(tmp, struct whiteheat_urb_wrap, list); |
| 1364 | urb = wrap->urb; |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 1365 | list_del(tmp); |
| 1366 | spin_unlock_irqrestore(&info->lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1367 | usb_kill_urb(urb); |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 1368 | spin_lock_irqsave(&info->lock, flags); |
| 1369 | list_add(tmp, &info->rx_urbs_free); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1370 | } |
| 1371 | break; |
| 1372 | } |
Oliver Neukum | 08a2b3b | 2007-05-24 13:52:51 +0200 | [diff] [blame] | 1373 | spin_lock_irqsave(&info->lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1374 | list_add(tmp, &info->rx_urbs_submitted); |
| 1375 | } |
| 1376 | |
| 1377 | spin_unlock_irqrestore(&info->lock, flags); |
| 1378 | |
| 1379 | return retval; |
| 1380 | } |
| 1381 | |
| 1382 | |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1383 | static struct whiteheat_urb_wrap *urb_to_wrap(struct urb *urb, |
| 1384 | struct list_head *head) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1385 | { |
| 1386 | struct whiteheat_urb_wrap *wrap; |
| 1387 | struct list_head *tmp; |
| 1388 | |
| 1389 | list_for_each(tmp, head) { |
| 1390 | wrap = list_entry(tmp, struct whiteheat_urb_wrap, list); |
| 1391 | if (wrap->urb == urb) |
| 1392 | return wrap; |
| 1393 | } |
| 1394 | |
| 1395 | return NULL; |
| 1396 | } |
| 1397 | |
| 1398 | |
| 1399 | static struct list_head *list_first(struct list_head *head) |
| 1400 | { |
| 1401 | return head->next; |
| 1402 | } |
| 1403 | |
| 1404 | |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 1405 | static void rx_data_softint(struct work_struct *work) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1406 | { |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 1407 | struct whiteheat_private *info = |
| 1408 | container_of(work, struct whiteheat_private, rx_work); |
| 1409 | struct usb_serial_port *port = info->port; |
Alan Cox | 4a90f09 | 2008-10-13 10:39:46 +0100 | [diff] [blame] | 1410 | struct tty_struct *tty = tty_port_tty_get(&port->port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1411 | struct whiteheat_urb_wrap *wrap; |
| 1412 | struct urb *urb; |
| 1413 | unsigned long flags; |
| 1414 | struct list_head *tmp; |
| 1415 | struct list_head *tmp2; |
| 1416 | int result; |
| 1417 | int sent = 0; |
| 1418 | |
| 1419 | spin_lock_irqsave(&info->lock, flags); |
| 1420 | if (info->flags & THROTTLED) { |
| 1421 | spin_unlock_irqrestore(&info->lock, flags); |
Alan Cox | 4a90f09 | 2008-10-13 10:39:46 +0100 | [diff] [blame] | 1422 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1423 | } |
| 1424 | |
| 1425 | list_for_each_safe(tmp, tmp2, &info->rx_urb_q) { |
| 1426 | list_del(tmp); |
| 1427 | spin_unlock_irqrestore(&info->lock, flags); |
| 1428 | |
| 1429 | wrap = list_entry(tmp, struct whiteheat_urb_wrap, list); |
| 1430 | urb = wrap->urb; |
| 1431 | |
Alan Cox | 67ccbd6 | 2010-02-17 13:06:57 +0000 | [diff] [blame] | 1432 | if (tty && urb->actual_length) |
| 1433 | sent += tty_insert_flip_string(tty, |
| 1434 | urb->transfer_buffer, urb->actual_length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1435 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1436 | result = usb_submit_urb(urb, GFP_ATOMIC); |
| 1437 | if (result) { |
Greg Kroah-Hartman | 194343d | 2008-08-20 16:56:34 -0700 | [diff] [blame] | 1438 | dev_err(&port->dev, |
| 1439 | "%s - failed resubmitting read urb, error %d\n", |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1440 | __func__, result); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1441 | spin_lock_irqsave(&info->lock, flags); |
| 1442 | list_add(tmp, &info->rx_urbs_free); |
| 1443 | continue; |
| 1444 | } |
| 1445 | |
| 1446 | spin_lock_irqsave(&info->lock, flags); |
| 1447 | list_add(tmp, &info->rx_urbs_submitted); |
| 1448 | } |
| 1449 | spin_unlock_irqrestore(&info->lock, flags); |
| 1450 | |
| 1451 | if (sent) |
| 1452 | tty_flip_buffer_push(tty); |
Alan Cox | 4a90f09 | 2008-10-13 10:39:46 +0100 | [diff] [blame] | 1453 | out: |
| 1454 | tty_kref_put(tty); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1455 | } |
| 1456 | |
| 1457 | |
| 1458 | /***************************************************************************** |
| 1459 | * Connect Tech's White Heat module functions |
| 1460 | *****************************************************************************/ |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1461 | static int __init whiteheat_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1462 | { |
| 1463 | int retval; |
| 1464 | retval = usb_serial_register(&whiteheat_fake_device); |
| 1465 | if (retval) |
| 1466 | goto failed_fake_register; |
| 1467 | retval = usb_serial_register(&whiteheat_device); |
| 1468 | if (retval) |
| 1469 | goto failed_device_register; |
| 1470 | retval = usb_register(&whiteheat_driver); |
| 1471 | if (retval) |
| 1472 | goto failed_usb_register; |
Greg Kroah-Hartman | c197a8d | 2008-08-18 13:21:04 -0700 | [diff] [blame] | 1473 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 1474 | DRIVER_DESC "\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1475 | return 0; |
| 1476 | failed_usb_register: |
| 1477 | usb_serial_deregister(&whiteheat_device); |
| 1478 | failed_device_register: |
| 1479 | usb_serial_deregister(&whiteheat_fake_device); |
| 1480 | failed_fake_register: |
| 1481 | return retval; |
| 1482 | } |
| 1483 | |
| 1484 | |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1485 | static void __exit whiteheat_exit(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1486 | { |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1487 | usb_deregister(&whiteheat_driver); |
| 1488 | usb_serial_deregister(&whiteheat_fake_device); |
| 1489 | usb_serial_deregister(&whiteheat_device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1490 | } |
| 1491 | |
| 1492 | |
| 1493 | module_init(whiteheat_init); |
| 1494 | module_exit(whiteheat_exit); |
| 1495 | |
Alan Cox | 80359a9 | 2008-07-22 11:09:16 +0100 | [diff] [blame] | 1496 | MODULE_AUTHOR(DRIVER_AUTHOR); |
| 1497 | MODULE_DESCRIPTION(DRIVER_DESC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1498 | MODULE_LICENSE("GPL"); |
| 1499 | |
David Woodhouse | ec6752f | 2008-05-31 01:35:29 +0300 | [diff] [blame] | 1500 | MODULE_FIRMWARE("whiteheat.fw"); |
| 1501 | MODULE_FIRMWARE("whiteheat_loader.fw"); |
| 1502 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1503 | module_param(urb_pool_size, int, 0); |
| 1504 | MODULE_PARM_DESC(urb_pool_size, "Number of urbs to use for buffering"); |
| 1505 | |
| 1506 | module_param(debug, bool, S_IRUGO | S_IWUSR); |
| 1507 | MODULE_PARM_DESC(debug, "Debug enabled or not"); |