Greg Kroah-Hartman | a78b428 | 2009-02-17 22:39:56 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Qualcomm Serial USB driver |
| 3 | * |
| 4 | * Copyright (c) 2008 QUALCOMM Incorporated. |
| 5 | * Copyright (c) 2009 Greg Kroah-Hartman <gregkh@suse.de> |
| 6 | * Copyright (c) 2009 Novell Inc. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License version |
| 10 | * 2 as published by the Free Software Foundation. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | #include <linux/tty.h> |
| 15 | #include <linux/tty_flip.h> |
| 16 | #include <linux/usb.h> |
| 17 | #include <linux/usb/serial.h> |
Matthew Garrett | 3d7e59a | 2010-04-01 12:31:09 -0400 | [diff] [blame^] | 18 | #include <linux/slab.h> |
| 19 | #include "usb-wwan.h" |
Greg Kroah-Hartman | a78b428 | 2009-02-17 22:39:56 -0800 | [diff] [blame] | 20 | |
| 21 | #define DRIVER_AUTHOR "Qualcomm Inc" |
| 22 | #define DRIVER_DESC "Qualcomm USB Serial driver" |
| 23 | |
| 24 | static int debug; |
| 25 | |
Németh Márton | 7d40d7e | 2010-01-10 15:34:24 +0100 | [diff] [blame] | 26 | static const struct usb_device_id id_table[] = { |
Greg Kroah-Hartman | a78b428 | 2009-02-17 22:39:56 -0800 | [diff] [blame] | 27 | {USB_DEVICE(0x05c6, 0x9211)}, /* Acer Gobi QDL device */ |
| 28 | {USB_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */ |
Alexander Shumakovitch | fd8345f | 2009-03-21 00:50:16 -0400 | [diff] [blame] | 29 | {USB_DEVICE(0x03f0, 0x1f1d)}, /* HP un2400 Gobi Modem Device */ |
| 30 | {USB_DEVICE(0x03f0, 0x201d)}, /* HP un2400 Gobi QDL Device */ |
Matthew Garrett | f05932c | 2009-04-04 17:24:24 +0100 | [diff] [blame] | 31 | {USB_DEVICE(0x04da, 0x250d)}, /* Panasonic Gobi Modem device */ |
| 32 | {USB_DEVICE(0x04da, 0x250c)}, /* Panasonic Gobi QDL device */ |
| 33 | {USB_DEVICE(0x413c, 0x8172)}, /* Dell Gobi Modem device */ |
| 34 | {USB_DEVICE(0x413c, 0x8171)}, /* Dell Gobi QDL device */ |
| 35 | {USB_DEVICE(0x1410, 0xa001)}, /* Novatel Gobi Modem device */ |
| 36 | {USB_DEVICE(0x1410, 0xa008)}, /* Novatel Gobi QDL device */ |
| 37 | {USB_DEVICE(0x0b05, 0x1776)}, /* Asus Gobi Modem device */ |
| 38 | {USB_DEVICE(0x0b05, 0x1774)}, /* Asus Gobi QDL device */ |
| 39 | {USB_DEVICE(0x19d2, 0xfff3)}, /* ONDA Gobi Modem device */ |
| 40 | {USB_DEVICE(0x19d2, 0xfff2)}, /* ONDA Gobi QDL device */ |
| 41 | {USB_DEVICE(0x1557, 0x0a80)}, /* OQO Gobi QDL device */ |
| 42 | {USB_DEVICE(0x05c6, 0x9001)}, /* Generic Gobi Modem device */ |
| 43 | {USB_DEVICE(0x05c6, 0x9002)}, /* Generic Gobi Modem device */ |
| 44 | {USB_DEVICE(0x05c6, 0x9202)}, /* Generic Gobi Modem device */ |
| 45 | {USB_DEVICE(0x05c6, 0x9203)}, /* Generic Gobi Modem device */ |
| 46 | {USB_DEVICE(0x05c6, 0x9222)}, /* Generic Gobi Modem device */ |
| 47 | {USB_DEVICE(0x05c6, 0x9008)}, /* Generic Gobi QDL device */ |
| 48 | {USB_DEVICE(0x05c6, 0x9201)}, /* Generic Gobi QDL device */ |
| 49 | {USB_DEVICE(0x05c6, 0x9221)}, /* Generic Gobi QDL device */ |
| 50 | {USB_DEVICE(0x05c6, 0x9231)}, /* Generic Gobi QDL device */ |
| 51 | {USB_DEVICE(0x1f45, 0x0001)}, /* Unknown Gobi QDL device */ |
Bernhard Rosenkraenzer | 0725e95 | 2010-03-10 12:36:43 +0100 | [diff] [blame] | 52 | {USB_DEVICE(0x413c, 0x8185)}, /* Dell Gobi 2000 QDL device (N0218, VU936) */ |
| 53 | {USB_DEVICE(0x413c, 0x8186)}, /* Dell Gobi 2000 Modem device (N0218, VU936) */ |
| 54 | {USB_DEVICE(0x05c6, 0x9224)}, /* Sony Gobi 2000 QDL device (N0279, VU730) */ |
| 55 | {USB_DEVICE(0x05c6, 0x9225)}, /* Sony Gobi 2000 Modem device (N0279, VU730) */ |
| 56 | {USB_DEVICE(0x05c6, 0x9244)}, /* Samsung Gobi 2000 QDL device (VL176) */ |
| 57 | {USB_DEVICE(0x05c6, 0x9245)}, /* Samsung Gobi 2000 Modem device (VL176) */ |
| 58 | {USB_DEVICE(0x03f0, 0x241d)}, /* HP Gobi 2000 QDL device (VP412) */ |
| 59 | {USB_DEVICE(0x03f0, 0x251d)}, /* HP Gobi 2000 Modem device (VP412) */ |
| 60 | {USB_DEVICE(0x05c6, 0x9214)}, /* Acer Gobi 2000 QDL device (VP413) */ |
| 61 | {USB_DEVICE(0x05c6, 0x9215)}, /* Acer Gobi 2000 Modem device (VP413) */ |
| 62 | {USB_DEVICE(0x05c6, 0x9264)}, /* Asus Gobi 2000 QDL device (VR305) */ |
| 63 | {USB_DEVICE(0x05c6, 0x9265)}, /* Asus Gobi 2000 Modem device (VR305) */ |
| 64 | {USB_DEVICE(0x05c6, 0x9234)}, /* Top Global Gobi 2000 QDL device (VR306) */ |
| 65 | {USB_DEVICE(0x05c6, 0x9235)}, /* Top Global Gobi 2000 Modem device (VR306) */ |
| 66 | {USB_DEVICE(0x05c6, 0x9274)}, /* iRex Technologies Gobi 2000 QDL device (VR307) */ |
| 67 | {USB_DEVICE(0x05c6, 0x9275)}, /* iRex Technologies Gobi 2000 Modem device (VR307) */ |
| 68 | {USB_DEVICE(0x1199, 0x9000)}, /* Sierra Wireless Gobi 2000 QDL device (VT773) */ |
| 69 | {USB_DEVICE(0x1199, 0x9001)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */ |
| 70 | {USB_DEVICE(0x1199, 0x9002)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */ |
| 71 | {USB_DEVICE(0x1199, 0x9003)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */ |
| 72 | {USB_DEVICE(0x1199, 0x9004)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */ |
| 73 | {USB_DEVICE(0x1199, 0x9005)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */ |
| 74 | {USB_DEVICE(0x1199, 0x9006)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */ |
| 75 | {USB_DEVICE(0x1199, 0x9007)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */ |
| 76 | {USB_DEVICE(0x1199, 0x9008)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */ |
| 77 | {USB_DEVICE(0x1199, 0x9009)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */ |
| 78 | {USB_DEVICE(0x1199, 0x900a)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */ |
| 79 | {USB_DEVICE(0x16d8, 0x8001)}, /* CMDTech Gobi 2000 QDL device (VU922) */ |
| 80 | {USB_DEVICE(0x16d8, 0x8002)}, /* CMDTech Gobi 2000 Modem device (VU922) */ |
Greg Kroah-Hartman | a78b428 | 2009-02-17 22:39:56 -0800 | [diff] [blame] | 81 | { } /* Terminating entry */ |
| 82 | }; |
| 83 | MODULE_DEVICE_TABLE(usb, id_table); |
| 84 | |
| 85 | static struct usb_driver qcdriver = { |
| 86 | .name = "qcserial", |
| 87 | .probe = usb_serial_probe, |
| 88 | .disconnect = usb_serial_disconnect, |
| 89 | .id_table = id_table, |
| 90 | .suspend = usb_serial_suspend, |
| 91 | .resume = usb_serial_resume, |
| 92 | .supports_autosuspend = true, |
| 93 | }; |
| 94 | |
| 95 | static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id) |
| 96 | { |
Matthew Garrett | 3d7e59a | 2010-04-01 12:31:09 -0400 | [diff] [blame^] | 97 | struct usb_wwan_intf_private *data; |
Greg Kroah-Hartman | a78b428 | 2009-02-17 22:39:56 -0800 | [diff] [blame] | 98 | int retval = -ENODEV; |
| 99 | __u8 nintf; |
| 100 | __u8 ifnum; |
| 101 | |
| 102 | dbg("%s", __func__); |
| 103 | |
| 104 | nintf = serial->dev->actconfig->desc.bNumInterfaces; |
| 105 | dbg("Num Interfaces = %d", nintf); |
| 106 | ifnum = serial->interface->cur_altsetting->desc.bInterfaceNumber; |
| 107 | dbg("This Interface = %d", ifnum); |
| 108 | |
Matthew Garrett | 3d7e59a | 2010-04-01 12:31:09 -0400 | [diff] [blame^] | 109 | data = serial->private = kzalloc(sizeof(struct usb_wwan_intf_private), |
| 110 | GFP_KERNEL); |
| 111 | if (!data) |
| 112 | return -ENOMEM; |
| 113 | |
| 114 | spin_lock_init(&data->susp_lock); |
| 115 | |
Greg Kroah-Hartman | a78b428 | 2009-02-17 22:39:56 -0800 | [diff] [blame] | 116 | switch (nintf) { |
| 117 | case 1: |
| 118 | /* QDL mode */ |
| 119 | if (serial->interface->num_altsetting == 2) { |
| 120 | struct usb_host_interface *intf; |
| 121 | |
| 122 | intf = &serial->interface->altsetting[1]; |
| 123 | if (intf->desc.bNumEndpoints == 2) { |
| 124 | if (usb_endpoint_is_bulk_in(&intf->endpoint[0].desc) && |
| 125 | usb_endpoint_is_bulk_out(&intf->endpoint[1].desc)) { |
| 126 | dbg("QDL port found"); |
| 127 | retval = usb_set_interface(serial->dev, ifnum, 1); |
| 128 | if (retval < 0) { |
| 129 | dev_err(&serial->dev->dev, |
| 130 | "Could not set interface, error %d\n", |
| 131 | retval); |
| 132 | retval = -ENODEV; |
| 133 | } |
| 134 | return retval; |
| 135 | } |
| 136 | } |
| 137 | } |
| 138 | break; |
| 139 | |
| 140 | case 4: |
| 141 | /* Composite mode */ |
| 142 | if (ifnum == 2) { |
| 143 | dbg("Modem port found"); |
| 144 | retval = usb_set_interface(serial->dev, ifnum, 0); |
| 145 | if (retval < 0) { |
| 146 | dev_err(&serial->dev->dev, |
| 147 | "Could not set interface, error %d\n", |
| 148 | retval); |
| 149 | retval = -ENODEV; |
| 150 | } |
| 151 | return retval; |
| 152 | } |
| 153 | break; |
| 154 | |
| 155 | default: |
| 156 | dev_err(&serial->dev->dev, |
| 157 | "unknown number of interfaces: %d\n", nintf); |
| 158 | return -ENODEV; |
| 159 | } |
| 160 | |
| 161 | return retval; |
| 162 | } |
| 163 | |
| 164 | static struct usb_serial_driver qcdevice = { |
| 165 | .driver = { |
| 166 | .owner = THIS_MODULE, |
| 167 | .name = "qcserial", |
| 168 | }, |
| 169 | .description = "Qualcomm USB modem", |
| 170 | .id_table = id_table, |
| 171 | .usb_driver = &qcdriver, |
| 172 | .num_ports = 1, |
| 173 | .probe = qcprobe, |
Matthew Garrett | 3d7e59a | 2010-04-01 12:31:09 -0400 | [diff] [blame^] | 174 | .open = usb_wwan_open, |
| 175 | .close = usb_wwan_close, |
| 176 | .write = usb_wwan_write, |
| 177 | .write_room = usb_wwan_write_room, |
| 178 | .chars_in_buffer = usb_wwan_chars_in_buffer, |
| 179 | .attach = usb_wwan_startup, |
| 180 | .disconnect = usb_wwan_disconnect, |
| 181 | .release = usb_wwan_release, |
| 182 | #ifdef CONFIG_PM |
| 183 | .suspend = usb_wwan_suspend, |
| 184 | .resume = usb_wwan_resume, |
| 185 | #endif |
Greg Kroah-Hartman | a78b428 | 2009-02-17 22:39:56 -0800 | [diff] [blame] | 186 | }; |
| 187 | |
| 188 | static int __init qcinit(void) |
| 189 | { |
| 190 | int retval; |
| 191 | |
| 192 | retval = usb_serial_register(&qcdevice); |
| 193 | if (retval) |
| 194 | return retval; |
| 195 | |
| 196 | retval = usb_register(&qcdriver); |
| 197 | if (retval) { |
| 198 | usb_serial_deregister(&qcdevice); |
| 199 | return retval; |
| 200 | } |
| 201 | |
| 202 | return 0; |
| 203 | } |
| 204 | |
| 205 | static void __exit qcexit(void) |
| 206 | { |
| 207 | usb_deregister(&qcdriver); |
| 208 | usb_serial_deregister(&qcdevice); |
| 209 | } |
| 210 | |
| 211 | module_init(qcinit); |
| 212 | module_exit(qcexit); |
| 213 | |
| 214 | MODULE_AUTHOR(DRIVER_AUTHOR); |
| 215 | MODULE_DESCRIPTION(DRIVER_DESC); |
| 216 | MODULE_LICENSE("GPL v2"); |
| 217 | |
| 218 | module_param(debug, bool, S_IRUGO | S_IWUSR); |
| 219 | MODULE_PARM_DESC(debug, "Debug enabled or not"); |