Commit 026dfaf18973404a01f488d6aa556a8c466e06a4
Committed by
Greg Kroah-Hartman
1 parent
6ea12a04d2
Exists in
master
and in
6 other branches
USB: serial: add IDs for WinChipHead USB->RS232 adapter
Add ID 4348:5523 for WinChipHead USB->RS 232 adapter with Prolifec PL2303 chipset Signed-off-by: Wolfgang Denk <wd@denx.de> Cc: stable <stable@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Showing 2 changed files with 5 additions and 0 deletions Inline Diff
drivers/usb/serial/pl2303.c
1 | /* | 1 | /* |
2 | * Prolific PL2303 USB to serial adaptor driver | 2 | * Prolific PL2303 USB to serial adaptor driver |
3 | * | 3 | * |
4 | * Copyright (C) 2001-2007 Greg Kroah-Hartman (greg@kroah.com) | 4 | * Copyright (C) 2001-2007 Greg Kroah-Hartman (greg@kroah.com) |
5 | * Copyright (C) 2003 IBM Corp. | 5 | * Copyright (C) 2003 IBM Corp. |
6 | * | 6 | * |
7 | * Original driver for 2.2.x by anonymous | 7 | * Original driver for 2.2.x by anonymous |
8 | * | 8 | * |
9 | * This program is free software; you can redistribute it and/or | 9 | * This program is free software; you can redistribute it and/or |
10 | * modify it under the terms of the GNU General Public License version | 10 | * modify it under the terms of the GNU General Public License version |
11 | * 2 as published by the Free Software Foundation. | 11 | * 2 as published by the Free Software Foundation. |
12 | * | 12 | * |
13 | * See Documentation/usb/usb-serial.txt for more information on using this | 13 | * See Documentation/usb/usb-serial.txt for more information on using this |
14 | * driver | 14 | * driver |
15 | * | 15 | * |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
19 | #include <linux/errno.h> | 19 | #include <linux/errno.h> |
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
22 | #include <linux/tty.h> | 22 | #include <linux/tty.h> |
23 | #include <linux/tty_driver.h> | 23 | #include <linux/tty_driver.h> |
24 | #include <linux/tty_flip.h> | 24 | #include <linux/tty_flip.h> |
25 | #include <linux/serial.h> | 25 | #include <linux/serial.h> |
26 | #include <linux/module.h> | 26 | #include <linux/module.h> |
27 | #include <linux/moduleparam.h> | 27 | #include <linux/moduleparam.h> |
28 | #include <linux/spinlock.h> | 28 | #include <linux/spinlock.h> |
29 | #include <linux/uaccess.h> | 29 | #include <linux/uaccess.h> |
30 | #include <linux/usb.h> | 30 | #include <linux/usb.h> |
31 | #include <linux/usb/serial.h> | 31 | #include <linux/usb/serial.h> |
32 | #include "pl2303.h" | 32 | #include "pl2303.h" |
33 | 33 | ||
34 | /* | 34 | /* |
35 | * Version Information | 35 | * Version Information |
36 | */ | 36 | */ |
37 | #define DRIVER_DESC "Prolific PL2303 USB to serial adaptor driver" | 37 | #define DRIVER_DESC "Prolific PL2303 USB to serial adaptor driver" |
38 | 38 | ||
39 | static int debug; | 39 | static int debug; |
40 | 40 | ||
41 | #define PL2303_CLOSING_WAIT (30*HZ) | 41 | #define PL2303_CLOSING_WAIT (30*HZ) |
42 | 42 | ||
43 | static const struct usb_device_id id_table[] = { | 43 | static const struct usb_device_id id_table[] = { |
44 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID) }, | 44 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID) }, |
45 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ2) }, | 45 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ2) }, |
46 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_DCU11) }, | 46 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_DCU11) }, |
47 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ3) }, | 47 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ3) }, |
48 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_PHAROS) }, | 48 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_PHAROS) }, |
49 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_ALDIGA) }, | 49 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_ALDIGA) }, |
50 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_MMX) }, | 50 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_MMX) }, |
51 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_GPRS) }, | 51 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_GPRS) }, |
52 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_HCR331) }, | 52 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_HCR331) }, |
53 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_MOTOROLA) }, | 53 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_MOTOROLA) }, |
54 | { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) }, | 54 | { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) }, |
55 | { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) }, | 55 | { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) }, |
56 | { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) }, | 56 | { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) }, |
57 | { USB_DEVICE(ATEN_VENDOR_ID2, ATEN_PRODUCT_ID) }, | 57 | { USB_DEVICE(ATEN_VENDOR_ID2, ATEN_PRODUCT_ID) }, |
58 | { USB_DEVICE(ELCOM_VENDOR_ID, ELCOM_PRODUCT_ID) }, | 58 | { USB_DEVICE(ELCOM_VENDOR_ID, ELCOM_PRODUCT_ID) }, |
59 | { USB_DEVICE(ELCOM_VENDOR_ID, ELCOM_PRODUCT_ID_UCSGT) }, | 59 | { USB_DEVICE(ELCOM_VENDOR_ID, ELCOM_PRODUCT_ID_UCSGT) }, |
60 | { USB_DEVICE(ITEGNO_VENDOR_ID, ITEGNO_PRODUCT_ID) }, | 60 | { USB_DEVICE(ITEGNO_VENDOR_ID, ITEGNO_PRODUCT_ID) }, |
61 | { USB_DEVICE(ITEGNO_VENDOR_ID, ITEGNO_PRODUCT_ID_2080) }, | 61 | { USB_DEVICE(ITEGNO_VENDOR_ID, ITEGNO_PRODUCT_ID_2080) }, |
62 | { USB_DEVICE(MA620_VENDOR_ID, MA620_PRODUCT_ID) }, | 62 | { USB_DEVICE(MA620_VENDOR_ID, MA620_PRODUCT_ID) }, |
63 | { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID) }, | 63 | { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID) }, |
64 | { USB_DEVICE(TRIPP_VENDOR_ID, TRIPP_PRODUCT_ID) }, | 64 | { USB_DEVICE(TRIPP_VENDOR_ID, TRIPP_PRODUCT_ID) }, |
65 | { USB_DEVICE(RADIOSHACK_VENDOR_ID, RADIOSHACK_PRODUCT_ID) }, | 65 | { USB_DEVICE(RADIOSHACK_VENDOR_ID, RADIOSHACK_PRODUCT_ID) }, |
66 | { USB_DEVICE(DCU10_VENDOR_ID, DCU10_PRODUCT_ID) }, | 66 | { USB_DEVICE(DCU10_VENDOR_ID, DCU10_PRODUCT_ID) }, |
67 | { USB_DEVICE(SITECOM_VENDOR_ID, SITECOM_PRODUCT_ID) }, | 67 | { USB_DEVICE(SITECOM_VENDOR_ID, SITECOM_PRODUCT_ID) }, |
68 | { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_ID) }, | 68 | { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_ID) }, |
69 | { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_ID) }, | 69 | { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_ID) }, |
70 | { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_SX1) }, | 70 | { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_SX1) }, |
71 | { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_X65) }, | 71 | { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_X65) }, |
72 | { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_X75) }, | 72 | { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_X75) }, |
73 | { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_EF81) }, | 73 | { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_EF81) }, |
74 | { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_ID_S81) }, /* Benq/Siemens S81 */ | 74 | { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_ID_S81) }, /* Benq/Siemens S81 */ |
75 | { USB_DEVICE(SYNTECH_VENDOR_ID, SYNTECH_PRODUCT_ID) }, | 75 | { USB_DEVICE(SYNTECH_VENDOR_ID, SYNTECH_PRODUCT_ID) }, |
76 | { USB_DEVICE(NOKIA_CA42_VENDOR_ID, NOKIA_CA42_PRODUCT_ID) }, | 76 | { USB_DEVICE(NOKIA_CA42_VENDOR_ID, NOKIA_CA42_PRODUCT_ID) }, |
77 | { USB_DEVICE(CA_42_CA42_VENDOR_ID, CA_42_CA42_PRODUCT_ID) }, | 77 | { USB_DEVICE(CA_42_CA42_VENDOR_ID, CA_42_CA42_PRODUCT_ID) }, |
78 | { USB_DEVICE(SAGEM_VENDOR_ID, SAGEM_PRODUCT_ID) }, | 78 | { USB_DEVICE(SAGEM_VENDOR_ID, SAGEM_PRODUCT_ID) }, |
79 | { USB_DEVICE(LEADTEK_VENDOR_ID, LEADTEK_9531_PRODUCT_ID) }, | 79 | { USB_DEVICE(LEADTEK_VENDOR_ID, LEADTEK_9531_PRODUCT_ID) }, |
80 | { USB_DEVICE(SPEEDDRAGON_VENDOR_ID, SPEEDDRAGON_PRODUCT_ID) }, | 80 | { USB_DEVICE(SPEEDDRAGON_VENDOR_ID, SPEEDDRAGON_PRODUCT_ID) }, |
81 | { USB_DEVICE(DATAPILOT_U2_VENDOR_ID, DATAPILOT_U2_PRODUCT_ID) }, | 81 | { USB_DEVICE(DATAPILOT_U2_VENDOR_ID, DATAPILOT_U2_PRODUCT_ID) }, |
82 | { USB_DEVICE(BELKIN_VENDOR_ID, BELKIN_PRODUCT_ID) }, | 82 | { USB_DEVICE(BELKIN_VENDOR_ID, BELKIN_PRODUCT_ID) }, |
83 | { USB_DEVICE(ALCOR_VENDOR_ID, ALCOR_PRODUCT_ID) }, | 83 | { USB_DEVICE(ALCOR_VENDOR_ID, ALCOR_PRODUCT_ID) }, |
84 | { USB_DEVICE(WS002IN_VENDOR_ID, WS002IN_PRODUCT_ID) }, | 84 | { USB_DEVICE(WS002IN_VENDOR_ID, WS002IN_PRODUCT_ID) }, |
85 | { USB_DEVICE(COREGA_VENDOR_ID, COREGA_PRODUCT_ID) }, | 85 | { USB_DEVICE(COREGA_VENDOR_ID, COREGA_PRODUCT_ID) }, |
86 | { USB_DEVICE(YCCABLE_VENDOR_ID, YCCABLE_PRODUCT_ID) }, | 86 | { USB_DEVICE(YCCABLE_VENDOR_ID, YCCABLE_PRODUCT_ID) }, |
87 | { USB_DEVICE(SUPERIAL_VENDOR_ID, SUPERIAL_PRODUCT_ID) }, | 87 | { USB_DEVICE(SUPERIAL_VENDOR_ID, SUPERIAL_PRODUCT_ID) }, |
88 | { USB_DEVICE(HP_VENDOR_ID, HP_LD220_PRODUCT_ID) }, | 88 | { USB_DEVICE(HP_VENDOR_ID, HP_LD220_PRODUCT_ID) }, |
89 | { USB_DEVICE(CRESSI_VENDOR_ID, CRESSI_EDY_PRODUCT_ID) }, | 89 | { USB_DEVICE(CRESSI_VENDOR_ID, CRESSI_EDY_PRODUCT_ID) }, |
90 | { USB_DEVICE(ZEAGLE_VENDOR_ID, ZEAGLE_N2ITION3_PRODUCT_ID) }, | 90 | { USB_DEVICE(ZEAGLE_VENDOR_ID, ZEAGLE_N2ITION3_PRODUCT_ID) }, |
91 | { USB_DEVICE(SONY_VENDOR_ID, SONY_QN3USB_PRODUCT_ID) }, | 91 | { USB_DEVICE(SONY_VENDOR_ID, SONY_QN3USB_PRODUCT_ID) }, |
92 | { USB_DEVICE(SANWA_VENDOR_ID, SANWA_PRODUCT_ID) }, | 92 | { USB_DEVICE(SANWA_VENDOR_ID, SANWA_PRODUCT_ID) }, |
93 | { USB_DEVICE(ADLINK_VENDOR_ID, ADLINK_ND6530_PRODUCT_ID) }, | 93 | { USB_DEVICE(ADLINK_VENDOR_ID, ADLINK_ND6530_PRODUCT_ID) }, |
94 | { USB_DEVICE(WINCHIPHEAD_VENDOR_ID, WINCHIPHEAD_USBSER_PRODUCT_ID) }, | ||
94 | { } /* Terminating entry */ | 95 | { } /* Terminating entry */ |
95 | }; | 96 | }; |
96 | 97 | ||
97 | MODULE_DEVICE_TABLE(usb, id_table); | 98 | MODULE_DEVICE_TABLE(usb, id_table); |
98 | 99 | ||
99 | static struct usb_driver pl2303_driver = { | 100 | static struct usb_driver pl2303_driver = { |
100 | .name = "pl2303", | 101 | .name = "pl2303", |
101 | .probe = usb_serial_probe, | 102 | .probe = usb_serial_probe, |
102 | .disconnect = usb_serial_disconnect, | 103 | .disconnect = usb_serial_disconnect, |
103 | .id_table = id_table, | 104 | .id_table = id_table, |
104 | .suspend = usb_serial_suspend, | 105 | .suspend = usb_serial_suspend, |
105 | .resume = usb_serial_resume, | 106 | .resume = usb_serial_resume, |
106 | .no_dynamic_id = 1, | 107 | .no_dynamic_id = 1, |
107 | .supports_autosuspend = 1, | 108 | .supports_autosuspend = 1, |
108 | }; | 109 | }; |
109 | 110 | ||
110 | #define SET_LINE_REQUEST_TYPE 0x21 | 111 | #define SET_LINE_REQUEST_TYPE 0x21 |
111 | #define SET_LINE_REQUEST 0x20 | 112 | #define SET_LINE_REQUEST 0x20 |
112 | 113 | ||
113 | #define SET_CONTROL_REQUEST_TYPE 0x21 | 114 | #define SET_CONTROL_REQUEST_TYPE 0x21 |
114 | #define SET_CONTROL_REQUEST 0x22 | 115 | #define SET_CONTROL_REQUEST 0x22 |
115 | #define CONTROL_DTR 0x01 | 116 | #define CONTROL_DTR 0x01 |
116 | #define CONTROL_RTS 0x02 | 117 | #define CONTROL_RTS 0x02 |
117 | 118 | ||
118 | #define BREAK_REQUEST_TYPE 0x21 | 119 | #define BREAK_REQUEST_TYPE 0x21 |
119 | #define BREAK_REQUEST 0x23 | 120 | #define BREAK_REQUEST 0x23 |
120 | #define BREAK_ON 0xffff | 121 | #define BREAK_ON 0xffff |
121 | #define BREAK_OFF 0x0000 | 122 | #define BREAK_OFF 0x0000 |
122 | 123 | ||
123 | #define GET_LINE_REQUEST_TYPE 0xa1 | 124 | #define GET_LINE_REQUEST_TYPE 0xa1 |
124 | #define GET_LINE_REQUEST 0x21 | 125 | #define GET_LINE_REQUEST 0x21 |
125 | 126 | ||
126 | #define VENDOR_WRITE_REQUEST_TYPE 0x40 | 127 | #define VENDOR_WRITE_REQUEST_TYPE 0x40 |
127 | #define VENDOR_WRITE_REQUEST 0x01 | 128 | #define VENDOR_WRITE_REQUEST 0x01 |
128 | 129 | ||
129 | #define VENDOR_READ_REQUEST_TYPE 0xc0 | 130 | #define VENDOR_READ_REQUEST_TYPE 0xc0 |
130 | #define VENDOR_READ_REQUEST 0x01 | 131 | #define VENDOR_READ_REQUEST 0x01 |
131 | 132 | ||
132 | #define UART_STATE 0x08 | 133 | #define UART_STATE 0x08 |
133 | #define UART_STATE_TRANSIENT_MASK 0x74 | 134 | #define UART_STATE_TRANSIENT_MASK 0x74 |
134 | #define UART_DCD 0x01 | 135 | #define UART_DCD 0x01 |
135 | #define UART_DSR 0x02 | 136 | #define UART_DSR 0x02 |
136 | #define UART_BREAK_ERROR 0x04 | 137 | #define UART_BREAK_ERROR 0x04 |
137 | #define UART_RING 0x08 | 138 | #define UART_RING 0x08 |
138 | #define UART_FRAME_ERROR 0x10 | 139 | #define UART_FRAME_ERROR 0x10 |
139 | #define UART_PARITY_ERROR 0x20 | 140 | #define UART_PARITY_ERROR 0x20 |
140 | #define UART_OVERRUN_ERROR 0x40 | 141 | #define UART_OVERRUN_ERROR 0x40 |
141 | #define UART_CTS 0x80 | 142 | #define UART_CTS 0x80 |
142 | 143 | ||
143 | 144 | ||
144 | enum pl2303_type { | 145 | enum pl2303_type { |
145 | type_0, /* don't know the difference between type 0 and */ | 146 | type_0, /* don't know the difference between type 0 and */ |
146 | type_1, /* type 1, until someone from prolific tells us... */ | 147 | type_1, /* type 1, until someone from prolific tells us... */ |
147 | HX, /* HX version of the pl2303 chip */ | 148 | HX, /* HX version of the pl2303 chip */ |
148 | }; | 149 | }; |
149 | 150 | ||
150 | struct pl2303_private { | 151 | struct pl2303_private { |
151 | spinlock_t lock; | 152 | spinlock_t lock; |
152 | wait_queue_head_t delta_msr_wait; | 153 | wait_queue_head_t delta_msr_wait; |
153 | u8 line_control; | 154 | u8 line_control; |
154 | u8 line_status; | 155 | u8 line_status; |
155 | enum pl2303_type type; | 156 | enum pl2303_type type; |
156 | }; | 157 | }; |
157 | 158 | ||
158 | static int pl2303_vendor_read(__u16 value, __u16 index, | 159 | static int pl2303_vendor_read(__u16 value, __u16 index, |
159 | struct usb_serial *serial, unsigned char *buf) | 160 | struct usb_serial *serial, unsigned char *buf) |
160 | { | 161 | { |
161 | int res = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), | 162 | int res = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), |
162 | VENDOR_READ_REQUEST, VENDOR_READ_REQUEST_TYPE, | 163 | VENDOR_READ_REQUEST, VENDOR_READ_REQUEST_TYPE, |
163 | value, index, buf, 1, 100); | 164 | value, index, buf, 1, 100); |
164 | dbg("0x%x:0x%x:0x%x:0x%x %d - %x", VENDOR_READ_REQUEST_TYPE, | 165 | dbg("0x%x:0x%x:0x%x:0x%x %d - %x", VENDOR_READ_REQUEST_TYPE, |
165 | VENDOR_READ_REQUEST, value, index, res, buf[0]); | 166 | VENDOR_READ_REQUEST, value, index, res, buf[0]); |
166 | return res; | 167 | return res; |
167 | } | 168 | } |
168 | 169 | ||
169 | static int pl2303_vendor_write(__u16 value, __u16 index, | 170 | static int pl2303_vendor_write(__u16 value, __u16 index, |
170 | struct usb_serial *serial) | 171 | struct usb_serial *serial) |
171 | { | 172 | { |
172 | int res = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | 173 | int res = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), |
173 | VENDOR_WRITE_REQUEST, VENDOR_WRITE_REQUEST_TYPE, | 174 | VENDOR_WRITE_REQUEST, VENDOR_WRITE_REQUEST_TYPE, |
174 | value, index, NULL, 0, 100); | 175 | value, index, NULL, 0, 100); |
175 | dbg("0x%x:0x%x:0x%x:0x%x %d", VENDOR_WRITE_REQUEST_TYPE, | 176 | dbg("0x%x:0x%x:0x%x:0x%x %d", VENDOR_WRITE_REQUEST_TYPE, |
176 | VENDOR_WRITE_REQUEST, value, index, res); | 177 | VENDOR_WRITE_REQUEST, value, index, res); |
177 | return res; | 178 | return res; |
178 | } | 179 | } |
179 | 180 | ||
180 | static int pl2303_startup(struct usb_serial *serial) | 181 | static int pl2303_startup(struct usb_serial *serial) |
181 | { | 182 | { |
182 | struct pl2303_private *priv; | 183 | struct pl2303_private *priv; |
183 | enum pl2303_type type = type_0; | 184 | enum pl2303_type type = type_0; |
184 | unsigned char *buf; | 185 | unsigned char *buf; |
185 | int i; | 186 | int i; |
186 | 187 | ||
187 | buf = kmalloc(10, GFP_KERNEL); | 188 | buf = kmalloc(10, GFP_KERNEL); |
188 | if (buf == NULL) | 189 | if (buf == NULL) |
189 | return -ENOMEM; | 190 | return -ENOMEM; |
190 | 191 | ||
191 | if (serial->dev->descriptor.bDeviceClass == 0x02) | 192 | if (serial->dev->descriptor.bDeviceClass == 0x02) |
192 | type = type_0; | 193 | type = type_0; |
193 | else if (serial->dev->descriptor.bMaxPacketSize0 == 0x40) | 194 | else if (serial->dev->descriptor.bMaxPacketSize0 == 0x40) |
194 | type = HX; | 195 | type = HX; |
195 | else if (serial->dev->descriptor.bDeviceClass == 0x00) | 196 | else if (serial->dev->descriptor.bDeviceClass == 0x00) |
196 | type = type_1; | 197 | type = type_1; |
197 | else if (serial->dev->descriptor.bDeviceClass == 0xFF) | 198 | else if (serial->dev->descriptor.bDeviceClass == 0xFF) |
198 | type = type_1; | 199 | type = type_1; |
199 | dbg("device type: %d", type); | 200 | dbg("device type: %d", type); |
200 | 201 | ||
201 | for (i = 0; i < serial->num_ports; ++i) { | 202 | for (i = 0; i < serial->num_ports; ++i) { |
202 | priv = kzalloc(sizeof(struct pl2303_private), GFP_KERNEL); | 203 | priv = kzalloc(sizeof(struct pl2303_private), GFP_KERNEL); |
203 | if (!priv) | 204 | if (!priv) |
204 | goto cleanup; | 205 | goto cleanup; |
205 | spin_lock_init(&priv->lock); | 206 | spin_lock_init(&priv->lock); |
206 | init_waitqueue_head(&priv->delta_msr_wait); | 207 | init_waitqueue_head(&priv->delta_msr_wait); |
207 | priv->type = type; | 208 | priv->type = type; |
208 | usb_set_serial_port_data(serial->port[i], priv); | 209 | usb_set_serial_port_data(serial->port[i], priv); |
209 | } | 210 | } |
210 | 211 | ||
211 | pl2303_vendor_read(0x8484, 0, serial, buf); | 212 | pl2303_vendor_read(0x8484, 0, serial, buf); |
212 | pl2303_vendor_write(0x0404, 0, serial); | 213 | pl2303_vendor_write(0x0404, 0, serial); |
213 | pl2303_vendor_read(0x8484, 0, serial, buf); | 214 | pl2303_vendor_read(0x8484, 0, serial, buf); |
214 | pl2303_vendor_read(0x8383, 0, serial, buf); | 215 | pl2303_vendor_read(0x8383, 0, serial, buf); |
215 | pl2303_vendor_read(0x8484, 0, serial, buf); | 216 | pl2303_vendor_read(0x8484, 0, serial, buf); |
216 | pl2303_vendor_write(0x0404, 1, serial); | 217 | pl2303_vendor_write(0x0404, 1, serial); |
217 | pl2303_vendor_read(0x8484, 0, serial, buf); | 218 | pl2303_vendor_read(0x8484, 0, serial, buf); |
218 | pl2303_vendor_read(0x8383, 0, serial, buf); | 219 | pl2303_vendor_read(0x8383, 0, serial, buf); |
219 | pl2303_vendor_write(0, 1, serial); | 220 | pl2303_vendor_write(0, 1, serial); |
220 | pl2303_vendor_write(1, 0, serial); | 221 | pl2303_vendor_write(1, 0, serial); |
221 | if (type == HX) | 222 | if (type == HX) |
222 | pl2303_vendor_write(2, 0x44, serial); | 223 | pl2303_vendor_write(2, 0x44, serial); |
223 | else | 224 | else |
224 | pl2303_vendor_write(2, 0x24, serial); | 225 | pl2303_vendor_write(2, 0x24, serial); |
225 | 226 | ||
226 | kfree(buf); | 227 | kfree(buf); |
227 | return 0; | 228 | return 0; |
228 | 229 | ||
229 | cleanup: | 230 | cleanup: |
230 | kfree(buf); | 231 | kfree(buf); |
231 | for (--i; i >= 0; --i) { | 232 | for (--i; i >= 0; --i) { |
232 | priv = usb_get_serial_port_data(serial->port[i]); | 233 | priv = usb_get_serial_port_data(serial->port[i]); |
233 | kfree(priv); | 234 | kfree(priv); |
234 | usb_set_serial_port_data(serial->port[i], NULL); | 235 | usb_set_serial_port_data(serial->port[i], NULL); |
235 | } | 236 | } |
236 | return -ENOMEM; | 237 | return -ENOMEM; |
237 | } | 238 | } |
238 | 239 | ||
239 | static int set_control_lines(struct usb_device *dev, u8 value) | 240 | static int set_control_lines(struct usb_device *dev, u8 value) |
240 | { | 241 | { |
241 | int retval; | 242 | int retval; |
242 | 243 | ||
243 | retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), | 244 | retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), |
244 | SET_CONTROL_REQUEST, SET_CONTROL_REQUEST_TYPE, | 245 | SET_CONTROL_REQUEST, SET_CONTROL_REQUEST_TYPE, |
245 | value, 0, NULL, 0, 100); | 246 | value, 0, NULL, 0, 100); |
246 | dbg("%s - value = %d, retval = %d", __func__, value, retval); | 247 | dbg("%s - value = %d, retval = %d", __func__, value, retval); |
247 | return retval; | 248 | return retval; |
248 | } | 249 | } |
249 | 250 | ||
250 | static void pl2303_set_termios(struct tty_struct *tty, | 251 | static void pl2303_set_termios(struct tty_struct *tty, |
251 | struct usb_serial_port *port, struct ktermios *old_termios) | 252 | struct usb_serial_port *port, struct ktermios *old_termios) |
252 | { | 253 | { |
253 | struct usb_serial *serial = port->serial; | 254 | struct usb_serial *serial = port->serial; |
254 | struct pl2303_private *priv = usb_get_serial_port_data(port); | 255 | struct pl2303_private *priv = usb_get_serial_port_data(port); |
255 | unsigned long flags; | 256 | unsigned long flags; |
256 | unsigned int cflag; | 257 | unsigned int cflag; |
257 | unsigned char *buf; | 258 | unsigned char *buf; |
258 | int baud; | 259 | int baud; |
259 | int i; | 260 | int i; |
260 | u8 control; | 261 | u8 control; |
261 | const int baud_sup[] = { 75, 150, 300, 600, 1200, 1800, 2400, 3600, | 262 | const int baud_sup[] = { 75, 150, 300, 600, 1200, 1800, 2400, 3600, |
262 | 4800, 7200, 9600, 14400, 19200, 28800, 38400, | 263 | 4800, 7200, 9600, 14400, 19200, 28800, 38400, |
263 | 57600, 115200, 230400, 460800, 614400, | 264 | 57600, 115200, 230400, 460800, 614400, |
264 | 921600, 1228800, 2457600, 3000000, 6000000 }; | 265 | 921600, 1228800, 2457600, 3000000, 6000000 }; |
265 | int baud_floor, baud_ceil; | 266 | int baud_floor, baud_ceil; |
266 | int k; | 267 | int k; |
267 | 268 | ||
268 | dbg("%s - port %d", __func__, port->number); | 269 | dbg("%s - port %d", __func__, port->number); |
269 | 270 | ||
270 | /* The PL2303 is reported to lose bytes if you change | 271 | /* The PL2303 is reported to lose bytes if you change |
271 | serial settings even to the same values as before. Thus | 272 | serial settings even to the same values as before. Thus |
272 | we actually need to filter in this specific case */ | 273 | we actually need to filter in this specific case */ |
273 | 274 | ||
274 | if (!tty_termios_hw_change(tty->termios, old_termios)) | 275 | if (!tty_termios_hw_change(tty->termios, old_termios)) |
275 | return; | 276 | return; |
276 | 277 | ||
277 | cflag = tty->termios->c_cflag; | 278 | cflag = tty->termios->c_cflag; |
278 | 279 | ||
279 | buf = kzalloc(7, GFP_KERNEL); | 280 | buf = kzalloc(7, GFP_KERNEL); |
280 | if (!buf) { | 281 | if (!buf) { |
281 | dev_err(&port->dev, "%s - out of memory.\n", __func__); | 282 | dev_err(&port->dev, "%s - out of memory.\n", __func__); |
282 | /* Report back no change occurred */ | 283 | /* Report back no change occurred */ |
283 | *tty->termios = *old_termios; | 284 | *tty->termios = *old_termios; |
284 | return; | 285 | return; |
285 | } | 286 | } |
286 | 287 | ||
287 | i = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), | 288 | i = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), |
288 | GET_LINE_REQUEST, GET_LINE_REQUEST_TYPE, | 289 | GET_LINE_REQUEST, GET_LINE_REQUEST_TYPE, |
289 | 0, 0, buf, 7, 100); | 290 | 0, 0, buf, 7, 100); |
290 | dbg("0xa1:0x21:0:0 %d - %x %x %x %x %x %x %x", i, | 291 | dbg("0xa1:0x21:0:0 %d - %x %x %x %x %x %x %x", i, |
291 | buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]); | 292 | buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]); |
292 | 293 | ||
293 | if (cflag & CSIZE) { | 294 | if (cflag & CSIZE) { |
294 | switch (cflag & CSIZE) { | 295 | switch (cflag & CSIZE) { |
295 | case CS5: | 296 | case CS5: |
296 | buf[6] = 5; | 297 | buf[6] = 5; |
297 | break; | 298 | break; |
298 | case CS6: | 299 | case CS6: |
299 | buf[6] = 6; | 300 | buf[6] = 6; |
300 | break; | 301 | break; |
301 | case CS7: | 302 | case CS7: |
302 | buf[6] = 7; | 303 | buf[6] = 7; |
303 | break; | 304 | break; |
304 | default: | 305 | default: |
305 | case CS8: | 306 | case CS8: |
306 | buf[6] = 8; | 307 | buf[6] = 8; |
307 | break; | 308 | break; |
308 | } | 309 | } |
309 | dbg("%s - data bits = %d", __func__, buf[6]); | 310 | dbg("%s - data bits = %d", __func__, buf[6]); |
310 | } | 311 | } |
311 | 312 | ||
312 | /* For reference buf[0]:buf[3] baud rate value */ | 313 | /* For reference buf[0]:buf[3] baud rate value */ |
313 | /* NOTE: Only the values defined in baud_sup are supported ! | 314 | /* NOTE: Only the values defined in baud_sup are supported ! |
314 | * => if unsupported values are set, the PL2303 seems to use | 315 | * => if unsupported values are set, the PL2303 seems to use |
315 | * 9600 baud (at least my PL2303X always does) | 316 | * 9600 baud (at least my PL2303X always does) |
316 | */ | 317 | */ |
317 | baud = tty_get_baud_rate(tty); | 318 | baud = tty_get_baud_rate(tty); |
318 | dbg("%s - baud requested = %d", __func__, baud); | 319 | dbg("%s - baud requested = %d", __func__, baud); |
319 | if (baud) { | 320 | if (baud) { |
320 | /* Set baudrate to nearest supported value */ | 321 | /* Set baudrate to nearest supported value */ |
321 | for (k=0; k<ARRAY_SIZE(baud_sup); k++) { | 322 | for (k=0; k<ARRAY_SIZE(baud_sup); k++) { |
322 | if (baud_sup[k] / baud) { | 323 | if (baud_sup[k] / baud) { |
323 | baud_ceil = baud_sup[k]; | 324 | baud_ceil = baud_sup[k]; |
324 | if (k==0) { | 325 | if (k==0) { |
325 | baud = baud_ceil; | 326 | baud = baud_ceil; |
326 | } else { | 327 | } else { |
327 | baud_floor = baud_sup[k-1]; | 328 | baud_floor = baud_sup[k-1]; |
328 | if ((baud_ceil % baud) | 329 | if ((baud_ceil % baud) |
329 | > (baud % baud_floor)) | 330 | > (baud % baud_floor)) |
330 | baud = baud_floor; | 331 | baud = baud_floor; |
331 | else | 332 | else |
332 | baud = baud_ceil; | 333 | baud = baud_ceil; |
333 | } | 334 | } |
334 | break; | 335 | break; |
335 | } | 336 | } |
336 | } | 337 | } |
337 | if (baud > 1228800) { | 338 | if (baud > 1228800) { |
338 | /* type_0, type_1 only support up to 1228800 baud */ | 339 | /* type_0, type_1 only support up to 1228800 baud */ |
339 | if (priv->type != HX) | 340 | if (priv->type != HX) |
340 | baud = 1228800; | 341 | baud = 1228800; |
341 | else if (baud > 6000000) | 342 | else if (baud > 6000000) |
342 | baud = 6000000; | 343 | baud = 6000000; |
343 | } | 344 | } |
344 | dbg("%s - baud set = %d", __func__, baud); | 345 | dbg("%s - baud set = %d", __func__, baud); |
345 | if (baud <= 115200) { | 346 | if (baud <= 115200) { |
346 | buf[0] = baud & 0xff; | 347 | buf[0] = baud & 0xff; |
347 | buf[1] = (baud >> 8) & 0xff; | 348 | buf[1] = (baud >> 8) & 0xff; |
348 | buf[2] = (baud >> 16) & 0xff; | 349 | buf[2] = (baud >> 16) & 0xff; |
349 | buf[3] = (baud >> 24) & 0xff; | 350 | buf[3] = (baud >> 24) & 0xff; |
350 | } else { | 351 | } else { |
351 | /* apparently the formula for higher speeds is: | 352 | /* apparently the formula for higher speeds is: |
352 | * baudrate = 12M * 32 / (2^buf[1]) / buf[0] | 353 | * baudrate = 12M * 32 / (2^buf[1]) / buf[0] |
353 | */ | 354 | */ |
354 | unsigned tmp = 12*1000*1000*32 / baud; | 355 | unsigned tmp = 12*1000*1000*32 / baud; |
355 | buf[3] = 0x80; | 356 | buf[3] = 0x80; |
356 | buf[2] = 0; | 357 | buf[2] = 0; |
357 | buf[1] = (tmp >= 256); | 358 | buf[1] = (tmp >= 256); |
358 | while (tmp >= 256) { | 359 | while (tmp >= 256) { |
359 | tmp >>= 2; | 360 | tmp >>= 2; |
360 | buf[1] <<= 1; | 361 | buf[1] <<= 1; |
361 | } | 362 | } |
362 | if (tmp > 256) { | 363 | if (tmp > 256) { |
363 | tmp %= 256; | 364 | tmp %= 256; |
364 | } | 365 | } |
365 | buf[0] = tmp; | 366 | buf[0] = tmp; |
366 | } | 367 | } |
367 | } | 368 | } |
368 | 369 | ||
369 | /* For reference buf[4]=0 is 1 stop bits */ | 370 | /* For reference buf[4]=0 is 1 stop bits */ |
370 | /* For reference buf[4]=1 is 1.5 stop bits */ | 371 | /* For reference buf[4]=1 is 1.5 stop bits */ |
371 | /* For reference buf[4]=2 is 2 stop bits */ | 372 | /* For reference buf[4]=2 is 2 stop bits */ |
372 | if (cflag & CSTOPB) { | 373 | if (cflag & CSTOPB) { |
373 | /* NOTE: Comply with "real" UARTs / RS232: | 374 | /* NOTE: Comply with "real" UARTs / RS232: |
374 | * use 1.5 instead of 2 stop bits with 5 data bits | 375 | * use 1.5 instead of 2 stop bits with 5 data bits |
375 | */ | 376 | */ |
376 | if ((cflag & CSIZE) == CS5) { | 377 | if ((cflag & CSIZE) == CS5) { |
377 | buf[4] = 1; | 378 | buf[4] = 1; |
378 | dbg("%s - stop bits = 1.5", __func__); | 379 | dbg("%s - stop bits = 1.5", __func__); |
379 | } else { | 380 | } else { |
380 | buf[4] = 2; | 381 | buf[4] = 2; |
381 | dbg("%s - stop bits = 2", __func__); | 382 | dbg("%s - stop bits = 2", __func__); |
382 | } | 383 | } |
383 | } else { | 384 | } else { |
384 | buf[4] = 0; | 385 | buf[4] = 0; |
385 | dbg("%s - stop bits = 1", __func__); | 386 | dbg("%s - stop bits = 1", __func__); |
386 | } | 387 | } |
387 | 388 | ||
388 | if (cflag & PARENB) { | 389 | if (cflag & PARENB) { |
389 | /* For reference buf[5]=0 is none parity */ | 390 | /* For reference buf[5]=0 is none parity */ |
390 | /* For reference buf[5]=1 is odd parity */ | 391 | /* For reference buf[5]=1 is odd parity */ |
391 | /* For reference buf[5]=2 is even parity */ | 392 | /* For reference buf[5]=2 is even parity */ |
392 | /* For reference buf[5]=3 is mark parity */ | 393 | /* For reference buf[5]=3 is mark parity */ |
393 | /* For reference buf[5]=4 is space parity */ | 394 | /* For reference buf[5]=4 is space parity */ |
394 | if (cflag & PARODD) { | 395 | if (cflag & PARODD) { |
395 | if (cflag & CMSPAR) { | 396 | if (cflag & CMSPAR) { |
396 | buf[5] = 3; | 397 | buf[5] = 3; |
397 | dbg("%s - parity = mark", __func__); | 398 | dbg("%s - parity = mark", __func__); |
398 | } else { | 399 | } else { |
399 | buf[5] = 1; | 400 | buf[5] = 1; |
400 | dbg("%s - parity = odd", __func__); | 401 | dbg("%s - parity = odd", __func__); |
401 | } | 402 | } |
402 | } else { | 403 | } else { |
403 | if (cflag & CMSPAR) { | 404 | if (cflag & CMSPAR) { |
404 | buf[5] = 4; | 405 | buf[5] = 4; |
405 | dbg("%s - parity = space", __func__); | 406 | dbg("%s - parity = space", __func__); |
406 | } else { | 407 | } else { |
407 | buf[5] = 2; | 408 | buf[5] = 2; |
408 | dbg("%s - parity = even", __func__); | 409 | dbg("%s - parity = even", __func__); |
409 | } | 410 | } |
410 | } | 411 | } |
411 | } else { | 412 | } else { |
412 | buf[5] = 0; | 413 | buf[5] = 0; |
413 | dbg("%s - parity = none", __func__); | 414 | dbg("%s - parity = none", __func__); |
414 | } | 415 | } |
415 | 416 | ||
416 | i = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | 417 | i = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), |
417 | SET_LINE_REQUEST, SET_LINE_REQUEST_TYPE, | 418 | SET_LINE_REQUEST, SET_LINE_REQUEST_TYPE, |
418 | 0, 0, buf, 7, 100); | 419 | 0, 0, buf, 7, 100); |
419 | dbg("0x21:0x20:0:0 %d", i); | 420 | dbg("0x21:0x20:0:0 %d", i); |
420 | 421 | ||
421 | /* change control lines if we are switching to or from B0 */ | 422 | /* change control lines if we are switching to or from B0 */ |
422 | spin_lock_irqsave(&priv->lock, flags); | 423 | spin_lock_irqsave(&priv->lock, flags); |
423 | control = priv->line_control; | 424 | control = priv->line_control; |
424 | if ((cflag & CBAUD) == B0) | 425 | if ((cflag & CBAUD) == B0) |
425 | priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS); | 426 | priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS); |
426 | else | 427 | else |
427 | priv->line_control |= (CONTROL_DTR | CONTROL_RTS); | 428 | priv->line_control |= (CONTROL_DTR | CONTROL_RTS); |
428 | if (control != priv->line_control) { | 429 | if (control != priv->line_control) { |
429 | control = priv->line_control; | 430 | control = priv->line_control; |
430 | spin_unlock_irqrestore(&priv->lock, flags); | 431 | spin_unlock_irqrestore(&priv->lock, flags); |
431 | set_control_lines(serial->dev, control); | 432 | set_control_lines(serial->dev, control); |
432 | } else { | 433 | } else { |
433 | spin_unlock_irqrestore(&priv->lock, flags); | 434 | spin_unlock_irqrestore(&priv->lock, flags); |
434 | } | 435 | } |
435 | 436 | ||
436 | buf[0] = buf[1] = buf[2] = buf[3] = buf[4] = buf[5] = buf[6] = 0; | 437 | buf[0] = buf[1] = buf[2] = buf[3] = buf[4] = buf[5] = buf[6] = 0; |
437 | 438 | ||
438 | i = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), | 439 | i = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), |
439 | GET_LINE_REQUEST, GET_LINE_REQUEST_TYPE, | 440 | GET_LINE_REQUEST, GET_LINE_REQUEST_TYPE, |
440 | 0, 0, buf, 7, 100); | 441 | 0, 0, buf, 7, 100); |
441 | dbg("0xa1:0x21:0:0 %d - %x %x %x %x %x %x %x", i, | 442 | dbg("0xa1:0x21:0:0 %d - %x %x %x %x %x %x %x", i, |
442 | buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]); | 443 | buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]); |
443 | 444 | ||
444 | if (cflag & CRTSCTS) { | 445 | if (cflag & CRTSCTS) { |
445 | if (priv->type == HX) | 446 | if (priv->type == HX) |
446 | pl2303_vendor_write(0x0, 0x61, serial); | 447 | pl2303_vendor_write(0x0, 0x61, serial); |
447 | else | 448 | else |
448 | pl2303_vendor_write(0x0, 0x41, serial); | 449 | pl2303_vendor_write(0x0, 0x41, serial); |
449 | } else { | 450 | } else { |
450 | pl2303_vendor_write(0x0, 0x0, serial); | 451 | pl2303_vendor_write(0x0, 0x0, serial); |
451 | } | 452 | } |
452 | 453 | ||
453 | /* Save resulting baud rate */ | 454 | /* Save resulting baud rate */ |
454 | if (baud) | 455 | if (baud) |
455 | tty_encode_baud_rate(tty, baud, baud); | 456 | tty_encode_baud_rate(tty, baud, baud); |
456 | 457 | ||
457 | kfree(buf); | 458 | kfree(buf); |
458 | } | 459 | } |
459 | 460 | ||
460 | static void pl2303_dtr_rts(struct usb_serial_port *port, int on) | 461 | static void pl2303_dtr_rts(struct usb_serial_port *port, int on) |
461 | { | 462 | { |
462 | struct pl2303_private *priv = usb_get_serial_port_data(port); | 463 | struct pl2303_private *priv = usb_get_serial_port_data(port); |
463 | unsigned long flags; | 464 | unsigned long flags; |
464 | u8 control; | 465 | u8 control; |
465 | 466 | ||
466 | spin_lock_irqsave(&priv->lock, flags); | 467 | spin_lock_irqsave(&priv->lock, flags); |
467 | /* Change DTR and RTS */ | 468 | /* Change DTR and RTS */ |
468 | if (on) | 469 | if (on) |
469 | priv->line_control |= (CONTROL_DTR | CONTROL_RTS); | 470 | priv->line_control |= (CONTROL_DTR | CONTROL_RTS); |
470 | else | 471 | else |
471 | priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS); | 472 | priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS); |
472 | control = priv->line_control; | 473 | control = priv->line_control; |
473 | spin_unlock_irqrestore(&priv->lock, flags); | 474 | spin_unlock_irqrestore(&priv->lock, flags); |
474 | set_control_lines(port->serial->dev, control); | 475 | set_control_lines(port->serial->dev, control); |
475 | } | 476 | } |
476 | 477 | ||
477 | static void pl2303_close(struct usb_serial_port *port) | 478 | static void pl2303_close(struct usb_serial_port *port) |
478 | { | 479 | { |
479 | dbg("%s - port %d", __func__, port->number); | 480 | dbg("%s - port %d", __func__, port->number); |
480 | 481 | ||
481 | usb_serial_generic_close(port); | 482 | usb_serial_generic_close(port); |
482 | usb_kill_urb(port->interrupt_in_urb); | 483 | usb_kill_urb(port->interrupt_in_urb); |
483 | } | 484 | } |
484 | 485 | ||
485 | static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port) | 486 | static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port) |
486 | { | 487 | { |
487 | struct ktermios tmp_termios; | 488 | struct ktermios tmp_termios; |
488 | struct usb_serial *serial = port->serial; | 489 | struct usb_serial *serial = port->serial; |
489 | struct pl2303_private *priv = usb_get_serial_port_data(port); | 490 | struct pl2303_private *priv = usb_get_serial_port_data(port); |
490 | int result; | 491 | int result; |
491 | 492 | ||
492 | dbg("%s - port %d", __func__, port->number); | 493 | dbg("%s - port %d", __func__, port->number); |
493 | 494 | ||
494 | if (priv->type != HX) { | 495 | if (priv->type != HX) { |
495 | usb_clear_halt(serial->dev, port->write_urb->pipe); | 496 | usb_clear_halt(serial->dev, port->write_urb->pipe); |
496 | usb_clear_halt(serial->dev, port->read_urb->pipe); | 497 | usb_clear_halt(serial->dev, port->read_urb->pipe); |
497 | } else { | 498 | } else { |
498 | /* reset upstream data pipes */ | 499 | /* reset upstream data pipes */ |
499 | pl2303_vendor_write(8, 0, serial); | 500 | pl2303_vendor_write(8, 0, serial); |
500 | pl2303_vendor_write(9, 0, serial); | 501 | pl2303_vendor_write(9, 0, serial); |
501 | } | 502 | } |
502 | 503 | ||
503 | /* Setup termios */ | 504 | /* Setup termios */ |
504 | if (tty) | 505 | if (tty) |
505 | pl2303_set_termios(tty, port, &tmp_termios); | 506 | pl2303_set_termios(tty, port, &tmp_termios); |
506 | 507 | ||
507 | dbg("%s - submitting read urb", __func__); | 508 | dbg("%s - submitting read urb", __func__); |
508 | result = usb_serial_generic_submit_read_urb(port, GFP_KERNEL); | 509 | result = usb_serial_generic_submit_read_urb(port, GFP_KERNEL); |
509 | if (result) { | 510 | if (result) { |
510 | pl2303_close(port); | 511 | pl2303_close(port); |
511 | return -EPROTO; | 512 | return -EPROTO; |
512 | } | 513 | } |
513 | 514 | ||
514 | dbg("%s - submitting interrupt urb", __func__); | 515 | dbg("%s - submitting interrupt urb", __func__); |
515 | result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); | 516 | result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); |
516 | if (result) { | 517 | if (result) { |
517 | dev_err(&port->dev, "%s - failed submitting interrupt urb," | 518 | dev_err(&port->dev, "%s - failed submitting interrupt urb," |
518 | " error %d\n", __func__, result); | 519 | " error %d\n", __func__, result); |
519 | pl2303_close(port); | 520 | pl2303_close(port); |
520 | return -EPROTO; | 521 | return -EPROTO; |
521 | } | 522 | } |
522 | port->port.drain_delay = 256; | 523 | port->port.drain_delay = 256; |
523 | return 0; | 524 | return 0; |
524 | } | 525 | } |
525 | 526 | ||
526 | static int pl2303_tiocmset(struct tty_struct *tty, | 527 | static int pl2303_tiocmset(struct tty_struct *tty, |
527 | unsigned int set, unsigned int clear) | 528 | unsigned int set, unsigned int clear) |
528 | { | 529 | { |
529 | struct usb_serial_port *port = tty->driver_data; | 530 | struct usb_serial_port *port = tty->driver_data; |
530 | struct pl2303_private *priv = usb_get_serial_port_data(port); | 531 | struct pl2303_private *priv = usb_get_serial_port_data(port); |
531 | unsigned long flags; | 532 | unsigned long flags; |
532 | u8 control; | 533 | u8 control; |
533 | 534 | ||
534 | if (!usb_get_intfdata(port->serial->interface)) | 535 | if (!usb_get_intfdata(port->serial->interface)) |
535 | return -ENODEV; | 536 | return -ENODEV; |
536 | 537 | ||
537 | spin_lock_irqsave(&priv->lock, flags); | 538 | spin_lock_irqsave(&priv->lock, flags); |
538 | if (set & TIOCM_RTS) | 539 | if (set & TIOCM_RTS) |
539 | priv->line_control |= CONTROL_RTS; | 540 | priv->line_control |= CONTROL_RTS; |
540 | if (set & TIOCM_DTR) | 541 | if (set & TIOCM_DTR) |
541 | priv->line_control |= CONTROL_DTR; | 542 | priv->line_control |= CONTROL_DTR; |
542 | if (clear & TIOCM_RTS) | 543 | if (clear & TIOCM_RTS) |
543 | priv->line_control &= ~CONTROL_RTS; | 544 | priv->line_control &= ~CONTROL_RTS; |
544 | if (clear & TIOCM_DTR) | 545 | if (clear & TIOCM_DTR) |
545 | priv->line_control &= ~CONTROL_DTR; | 546 | priv->line_control &= ~CONTROL_DTR; |
546 | control = priv->line_control; | 547 | control = priv->line_control; |
547 | spin_unlock_irqrestore(&priv->lock, flags); | 548 | spin_unlock_irqrestore(&priv->lock, flags); |
548 | 549 | ||
549 | return set_control_lines(port->serial->dev, control); | 550 | return set_control_lines(port->serial->dev, control); |
550 | } | 551 | } |
551 | 552 | ||
552 | static int pl2303_tiocmget(struct tty_struct *tty) | 553 | static int pl2303_tiocmget(struct tty_struct *tty) |
553 | { | 554 | { |
554 | struct usb_serial_port *port = tty->driver_data; | 555 | struct usb_serial_port *port = tty->driver_data; |
555 | struct pl2303_private *priv = usb_get_serial_port_data(port); | 556 | struct pl2303_private *priv = usb_get_serial_port_data(port); |
556 | unsigned long flags; | 557 | unsigned long flags; |
557 | unsigned int mcr; | 558 | unsigned int mcr; |
558 | unsigned int status; | 559 | unsigned int status; |
559 | unsigned int result; | 560 | unsigned int result; |
560 | 561 | ||
561 | dbg("%s (%d)", __func__, port->number); | 562 | dbg("%s (%d)", __func__, port->number); |
562 | 563 | ||
563 | if (!usb_get_intfdata(port->serial->interface)) | 564 | if (!usb_get_intfdata(port->serial->interface)) |
564 | return -ENODEV; | 565 | return -ENODEV; |
565 | 566 | ||
566 | spin_lock_irqsave(&priv->lock, flags); | 567 | spin_lock_irqsave(&priv->lock, flags); |
567 | mcr = priv->line_control; | 568 | mcr = priv->line_control; |
568 | status = priv->line_status; | 569 | status = priv->line_status; |
569 | spin_unlock_irqrestore(&priv->lock, flags); | 570 | spin_unlock_irqrestore(&priv->lock, flags); |
570 | 571 | ||
571 | result = ((mcr & CONTROL_DTR) ? TIOCM_DTR : 0) | 572 | result = ((mcr & CONTROL_DTR) ? TIOCM_DTR : 0) |
572 | | ((mcr & CONTROL_RTS) ? TIOCM_RTS : 0) | 573 | | ((mcr & CONTROL_RTS) ? TIOCM_RTS : 0) |
573 | | ((status & UART_CTS) ? TIOCM_CTS : 0) | 574 | | ((status & UART_CTS) ? TIOCM_CTS : 0) |
574 | | ((status & UART_DSR) ? TIOCM_DSR : 0) | 575 | | ((status & UART_DSR) ? TIOCM_DSR : 0) |
575 | | ((status & UART_RING) ? TIOCM_RI : 0) | 576 | | ((status & UART_RING) ? TIOCM_RI : 0) |
576 | | ((status & UART_DCD) ? TIOCM_CD : 0); | 577 | | ((status & UART_DCD) ? TIOCM_CD : 0); |
577 | 578 | ||
578 | dbg("%s - result = %x", __func__, result); | 579 | dbg("%s - result = %x", __func__, result); |
579 | 580 | ||
580 | return result; | 581 | return result; |
581 | } | 582 | } |
582 | 583 | ||
583 | static int pl2303_carrier_raised(struct usb_serial_port *port) | 584 | static int pl2303_carrier_raised(struct usb_serial_port *port) |
584 | { | 585 | { |
585 | struct pl2303_private *priv = usb_get_serial_port_data(port); | 586 | struct pl2303_private *priv = usb_get_serial_port_data(port); |
586 | if (priv->line_status & UART_DCD) | 587 | if (priv->line_status & UART_DCD) |
587 | return 1; | 588 | return 1; |
588 | return 0; | 589 | return 0; |
589 | } | 590 | } |
590 | 591 | ||
591 | static int wait_modem_info(struct usb_serial_port *port, unsigned int arg) | 592 | static int wait_modem_info(struct usb_serial_port *port, unsigned int arg) |
592 | { | 593 | { |
593 | struct pl2303_private *priv = usb_get_serial_port_data(port); | 594 | struct pl2303_private *priv = usb_get_serial_port_data(port); |
594 | unsigned long flags; | 595 | unsigned long flags; |
595 | unsigned int prevstatus; | 596 | unsigned int prevstatus; |
596 | unsigned int status; | 597 | unsigned int status; |
597 | unsigned int changed; | 598 | unsigned int changed; |
598 | 599 | ||
599 | spin_lock_irqsave(&priv->lock, flags); | 600 | spin_lock_irqsave(&priv->lock, flags); |
600 | prevstatus = priv->line_status; | 601 | prevstatus = priv->line_status; |
601 | spin_unlock_irqrestore(&priv->lock, flags); | 602 | spin_unlock_irqrestore(&priv->lock, flags); |
602 | 603 | ||
603 | while (1) { | 604 | while (1) { |
604 | interruptible_sleep_on(&priv->delta_msr_wait); | 605 | interruptible_sleep_on(&priv->delta_msr_wait); |
605 | /* see if a signal did it */ | 606 | /* see if a signal did it */ |
606 | if (signal_pending(current)) | 607 | if (signal_pending(current)) |
607 | return -ERESTARTSYS; | 608 | return -ERESTARTSYS; |
608 | 609 | ||
609 | spin_lock_irqsave(&priv->lock, flags); | 610 | spin_lock_irqsave(&priv->lock, flags); |
610 | status = priv->line_status; | 611 | status = priv->line_status; |
611 | spin_unlock_irqrestore(&priv->lock, flags); | 612 | spin_unlock_irqrestore(&priv->lock, flags); |
612 | 613 | ||
613 | changed = prevstatus ^ status; | 614 | changed = prevstatus ^ status; |
614 | 615 | ||
615 | if (((arg & TIOCM_RNG) && (changed & UART_RING)) || | 616 | if (((arg & TIOCM_RNG) && (changed & UART_RING)) || |
616 | ((arg & TIOCM_DSR) && (changed & UART_DSR)) || | 617 | ((arg & TIOCM_DSR) && (changed & UART_DSR)) || |
617 | ((arg & TIOCM_CD) && (changed & UART_DCD)) || | 618 | ((arg & TIOCM_CD) && (changed & UART_DCD)) || |
618 | ((arg & TIOCM_CTS) && (changed & UART_CTS))) { | 619 | ((arg & TIOCM_CTS) && (changed & UART_CTS))) { |
619 | return 0; | 620 | return 0; |
620 | } | 621 | } |
621 | prevstatus = status; | 622 | prevstatus = status; |
622 | } | 623 | } |
623 | /* NOTREACHED */ | 624 | /* NOTREACHED */ |
624 | return 0; | 625 | return 0; |
625 | } | 626 | } |
626 | 627 | ||
627 | static int pl2303_ioctl(struct tty_struct *tty, | 628 | static int pl2303_ioctl(struct tty_struct *tty, |
628 | unsigned int cmd, unsigned long arg) | 629 | unsigned int cmd, unsigned long arg) |
629 | { | 630 | { |
630 | struct serial_struct ser; | 631 | struct serial_struct ser; |
631 | struct usb_serial_port *port = tty->driver_data; | 632 | struct usb_serial_port *port = tty->driver_data; |
632 | dbg("%s (%d) cmd = 0x%04x", __func__, port->number, cmd); | 633 | dbg("%s (%d) cmd = 0x%04x", __func__, port->number, cmd); |
633 | 634 | ||
634 | switch (cmd) { | 635 | switch (cmd) { |
635 | case TIOCGSERIAL: | 636 | case TIOCGSERIAL: |
636 | memset(&ser, 0, sizeof ser); | 637 | memset(&ser, 0, sizeof ser); |
637 | ser.type = PORT_16654; | 638 | ser.type = PORT_16654; |
638 | ser.line = port->serial->minor; | 639 | ser.line = port->serial->minor; |
639 | ser.port = port->number; | 640 | ser.port = port->number; |
640 | ser.baud_base = 460800; | 641 | ser.baud_base = 460800; |
641 | 642 | ||
642 | if (copy_to_user((void __user *)arg, &ser, sizeof ser)) | 643 | if (copy_to_user((void __user *)arg, &ser, sizeof ser)) |
643 | return -EFAULT; | 644 | return -EFAULT; |
644 | 645 | ||
645 | return 0; | 646 | return 0; |
646 | 647 | ||
647 | case TIOCMIWAIT: | 648 | case TIOCMIWAIT: |
648 | dbg("%s (%d) TIOCMIWAIT", __func__, port->number); | 649 | dbg("%s (%d) TIOCMIWAIT", __func__, port->number); |
649 | return wait_modem_info(port, arg); | 650 | return wait_modem_info(port, arg); |
650 | default: | 651 | default: |
651 | dbg("%s not supported = 0x%04x", __func__, cmd); | 652 | dbg("%s not supported = 0x%04x", __func__, cmd); |
652 | break; | 653 | break; |
653 | } | 654 | } |
654 | return -ENOIOCTLCMD; | 655 | return -ENOIOCTLCMD; |
655 | } | 656 | } |
656 | 657 | ||
657 | static void pl2303_break_ctl(struct tty_struct *tty, int break_state) | 658 | static void pl2303_break_ctl(struct tty_struct *tty, int break_state) |
658 | { | 659 | { |
659 | struct usb_serial_port *port = tty->driver_data; | 660 | struct usb_serial_port *port = tty->driver_data; |
660 | struct usb_serial *serial = port->serial; | 661 | struct usb_serial *serial = port->serial; |
661 | u16 state; | 662 | u16 state; |
662 | int result; | 663 | int result; |
663 | 664 | ||
664 | dbg("%s - port %d", __func__, port->number); | 665 | dbg("%s - port %d", __func__, port->number); |
665 | 666 | ||
666 | if (break_state == 0) | 667 | if (break_state == 0) |
667 | state = BREAK_OFF; | 668 | state = BREAK_OFF; |
668 | else | 669 | else |
669 | state = BREAK_ON; | 670 | state = BREAK_ON; |
670 | dbg("%s - turning break %s", __func__, | 671 | dbg("%s - turning break %s", __func__, |
671 | state == BREAK_OFF ? "off" : "on"); | 672 | state == BREAK_OFF ? "off" : "on"); |
672 | 673 | ||
673 | result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | 674 | result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), |
674 | BREAK_REQUEST, BREAK_REQUEST_TYPE, state, | 675 | BREAK_REQUEST, BREAK_REQUEST_TYPE, state, |
675 | 0, NULL, 0, 100); | 676 | 0, NULL, 0, 100); |
676 | if (result) | 677 | if (result) |
677 | dbg("%s - error sending break = %d", __func__, result); | 678 | dbg("%s - error sending break = %d", __func__, result); |
678 | } | 679 | } |
679 | 680 | ||
680 | static void pl2303_release(struct usb_serial *serial) | 681 | static void pl2303_release(struct usb_serial *serial) |
681 | { | 682 | { |
682 | int i; | 683 | int i; |
683 | struct pl2303_private *priv; | 684 | struct pl2303_private *priv; |
684 | 685 | ||
685 | dbg("%s", __func__); | 686 | dbg("%s", __func__); |
686 | 687 | ||
687 | for (i = 0; i < serial->num_ports; ++i) { | 688 | for (i = 0; i < serial->num_ports; ++i) { |
688 | priv = usb_get_serial_port_data(serial->port[i]); | 689 | priv = usb_get_serial_port_data(serial->port[i]); |
689 | kfree(priv); | 690 | kfree(priv); |
690 | } | 691 | } |
691 | } | 692 | } |
692 | 693 | ||
693 | static void pl2303_update_line_status(struct usb_serial_port *port, | 694 | static void pl2303_update_line_status(struct usb_serial_port *port, |
694 | unsigned char *data, | 695 | unsigned char *data, |
695 | unsigned int actual_length) | 696 | unsigned int actual_length) |
696 | { | 697 | { |
697 | 698 | ||
698 | struct pl2303_private *priv = usb_get_serial_port_data(port); | 699 | struct pl2303_private *priv = usb_get_serial_port_data(port); |
699 | struct tty_struct *tty; | 700 | struct tty_struct *tty; |
700 | unsigned long flags; | 701 | unsigned long flags; |
701 | u8 status_idx = UART_STATE; | 702 | u8 status_idx = UART_STATE; |
702 | u8 length = UART_STATE + 1; | 703 | u8 length = UART_STATE + 1; |
703 | u8 prev_line_status; | 704 | u8 prev_line_status; |
704 | u16 idv, idp; | 705 | u16 idv, idp; |
705 | 706 | ||
706 | idv = le16_to_cpu(port->serial->dev->descriptor.idVendor); | 707 | idv = le16_to_cpu(port->serial->dev->descriptor.idVendor); |
707 | idp = le16_to_cpu(port->serial->dev->descriptor.idProduct); | 708 | idp = le16_to_cpu(port->serial->dev->descriptor.idProduct); |
708 | 709 | ||
709 | 710 | ||
710 | if (idv == SIEMENS_VENDOR_ID) { | 711 | if (idv == SIEMENS_VENDOR_ID) { |
711 | if (idp == SIEMENS_PRODUCT_ID_X65 || | 712 | if (idp == SIEMENS_PRODUCT_ID_X65 || |
712 | idp == SIEMENS_PRODUCT_ID_SX1 || | 713 | idp == SIEMENS_PRODUCT_ID_SX1 || |
713 | idp == SIEMENS_PRODUCT_ID_X75) { | 714 | idp == SIEMENS_PRODUCT_ID_X75) { |
714 | 715 | ||
715 | length = 1; | 716 | length = 1; |
716 | status_idx = 0; | 717 | status_idx = 0; |
717 | } | 718 | } |
718 | } | 719 | } |
719 | 720 | ||
720 | if (actual_length < length) | 721 | if (actual_length < length) |
721 | return; | 722 | return; |
722 | 723 | ||
723 | /* Save off the uart status for others to look at */ | 724 | /* Save off the uart status for others to look at */ |
724 | spin_lock_irqsave(&priv->lock, flags); | 725 | spin_lock_irqsave(&priv->lock, flags); |
725 | prev_line_status = priv->line_status; | 726 | prev_line_status = priv->line_status; |
726 | priv->line_status = data[status_idx]; | 727 | priv->line_status = data[status_idx]; |
727 | spin_unlock_irqrestore(&priv->lock, flags); | 728 | spin_unlock_irqrestore(&priv->lock, flags); |
728 | if (priv->line_status & UART_BREAK_ERROR) | 729 | if (priv->line_status & UART_BREAK_ERROR) |
729 | usb_serial_handle_break(port); | 730 | usb_serial_handle_break(port); |
730 | wake_up_interruptible(&priv->delta_msr_wait); | 731 | wake_up_interruptible(&priv->delta_msr_wait); |
731 | 732 | ||
732 | tty = tty_port_tty_get(&port->port); | 733 | tty = tty_port_tty_get(&port->port); |
733 | if (!tty) | 734 | if (!tty) |
734 | return; | 735 | return; |
735 | if ((priv->line_status ^ prev_line_status) & UART_DCD) | 736 | if ((priv->line_status ^ prev_line_status) & UART_DCD) |
736 | usb_serial_handle_dcd_change(port, tty, | 737 | usb_serial_handle_dcd_change(port, tty, |
737 | priv->line_status & UART_DCD); | 738 | priv->line_status & UART_DCD); |
738 | tty_kref_put(tty); | 739 | tty_kref_put(tty); |
739 | } | 740 | } |
740 | 741 | ||
741 | static void pl2303_read_int_callback(struct urb *urb) | 742 | static void pl2303_read_int_callback(struct urb *urb) |
742 | { | 743 | { |
743 | struct usb_serial_port *port = urb->context; | 744 | struct usb_serial_port *port = urb->context; |
744 | unsigned char *data = urb->transfer_buffer; | 745 | unsigned char *data = urb->transfer_buffer; |
745 | unsigned int actual_length = urb->actual_length; | 746 | unsigned int actual_length = urb->actual_length; |
746 | int status = urb->status; | 747 | int status = urb->status; |
747 | int retval; | 748 | int retval; |
748 | 749 | ||
749 | dbg("%s (%d)", __func__, port->number); | 750 | dbg("%s (%d)", __func__, port->number); |
750 | 751 | ||
751 | switch (status) { | 752 | switch (status) { |
752 | case 0: | 753 | case 0: |
753 | /* success */ | 754 | /* success */ |
754 | break; | 755 | break; |
755 | case -ECONNRESET: | 756 | case -ECONNRESET: |
756 | case -ENOENT: | 757 | case -ENOENT: |
757 | case -ESHUTDOWN: | 758 | case -ESHUTDOWN: |
758 | /* this urb is terminated, clean up */ | 759 | /* this urb is terminated, clean up */ |
759 | dbg("%s - urb shutting down with status: %d", __func__, | 760 | dbg("%s - urb shutting down with status: %d", __func__, |
760 | status); | 761 | status); |
761 | return; | 762 | return; |
762 | default: | 763 | default: |
763 | dbg("%s - nonzero urb status received: %d", __func__, | 764 | dbg("%s - nonzero urb status received: %d", __func__, |
764 | status); | 765 | status); |
765 | goto exit; | 766 | goto exit; |
766 | } | 767 | } |
767 | 768 | ||
768 | usb_serial_debug_data(debug, &port->dev, __func__, | 769 | usb_serial_debug_data(debug, &port->dev, __func__, |
769 | urb->actual_length, urb->transfer_buffer); | 770 | urb->actual_length, urb->transfer_buffer); |
770 | 771 | ||
771 | pl2303_update_line_status(port, data, actual_length); | 772 | pl2303_update_line_status(port, data, actual_length); |
772 | 773 | ||
773 | exit: | 774 | exit: |
774 | retval = usb_submit_urb(urb, GFP_ATOMIC); | 775 | retval = usb_submit_urb(urb, GFP_ATOMIC); |
775 | if (retval) | 776 | if (retval) |
776 | dev_err(&urb->dev->dev, | 777 | dev_err(&urb->dev->dev, |
777 | "%s - usb_submit_urb failed with result %d\n", | 778 | "%s - usb_submit_urb failed with result %d\n", |
778 | __func__, retval); | 779 | __func__, retval); |
779 | } | 780 | } |
780 | 781 | ||
781 | static void pl2303_process_read_urb(struct urb *urb) | 782 | static void pl2303_process_read_urb(struct urb *urb) |
782 | { | 783 | { |
783 | struct usb_serial_port *port = urb->context; | 784 | struct usb_serial_port *port = urb->context; |
784 | struct pl2303_private *priv = usb_get_serial_port_data(port); | 785 | struct pl2303_private *priv = usb_get_serial_port_data(port); |
785 | struct tty_struct *tty; | 786 | struct tty_struct *tty; |
786 | unsigned char *data = urb->transfer_buffer; | 787 | unsigned char *data = urb->transfer_buffer; |
787 | char tty_flag = TTY_NORMAL; | 788 | char tty_flag = TTY_NORMAL; |
788 | unsigned long flags; | 789 | unsigned long flags; |
789 | u8 line_status; | 790 | u8 line_status; |
790 | int i; | 791 | int i; |
791 | 792 | ||
792 | /* update line status */ | 793 | /* update line status */ |
793 | spin_lock_irqsave(&priv->lock, flags); | 794 | spin_lock_irqsave(&priv->lock, flags); |
794 | line_status = priv->line_status; | 795 | line_status = priv->line_status; |
795 | priv->line_status &= ~UART_STATE_TRANSIENT_MASK; | 796 | priv->line_status &= ~UART_STATE_TRANSIENT_MASK; |
796 | spin_unlock_irqrestore(&priv->lock, flags); | 797 | spin_unlock_irqrestore(&priv->lock, flags); |
797 | wake_up_interruptible(&priv->delta_msr_wait); | 798 | wake_up_interruptible(&priv->delta_msr_wait); |
798 | 799 | ||
799 | if (!urb->actual_length) | 800 | if (!urb->actual_length) |
800 | return; | 801 | return; |
801 | 802 | ||
802 | tty = tty_port_tty_get(&port->port); | 803 | tty = tty_port_tty_get(&port->port); |
803 | if (!tty) | 804 | if (!tty) |
804 | return; | 805 | return; |
805 | 806 | ||
806 | /* break takes precedence over parity, */ | 807 | /* break takes precedence over parity, */ |
807 | /* which takes precedence over framing errors */ | 808 | /* which takes precedence over framing errors */ |
808 | if (line_status & UART_BREAK_ERROR) | 809 | if (line_status & UART_BREAK_ERROR) |
809 | tty_flag = TTY_BREAK; | 810 | tty_flag = TTY_BREAK; |
810 | else if (line_status & UART_PARITY_ERROR) | 811 | else if (line_status & UART_PARITY_ERROR) |
811 | tty_flag = TTY_PARITY; | 812 | tty_flag = TTY_PARITY; |
812 | else if (line_status & UART_FRAME_ERROR) | 813 | else if (line_status & UART_FRAME_ERROR) |
813 | tty_flag = TTY_FRAME; | 814 | tty_flag = TTY_FRAME; |
814 | dbg("%s - tty_flag = %d", __func__, tty_flag); | 815 | dbg("%s - tty_flag = %d", __func__, tty_flag); |
815 | 816 | ||
816 | /* overrun is special, not associated with a char */ | 817 | /* overrun is special, not associated with a char */ |
817 | if (line_status & UART_OVERRUN_ERROR) | 818 | if (line_status & UART_OVERRUN_ERROR) |
818 | tty_insert_flip_char(tty, 0, TTY_OVERRUN); | 819 | tty_insert_flip_char(tty, 0, TTY_OVERRUN); |
819 | 820 | ||
820 | if (port->port.console && port->sysrq) { | 821 | if (port->port.console && port->sysrq) { |
821 | for (i = 0; i < urb->actual_length; ++i) | 822 | for (i = 0; i < urb->actual_length; ++i) |
822 | if (!usb_serial_handle_sysrq_char(port, data[i])) | 823 | if (!usb_serial_handle_sysrq_char(port, data[i])) |
823 | tty_insert_flip_char(tty, data[i], tty_flag); | 824 | tty_insert_flip_char(tty, data[i], tty_flag); |
824 | } else { | 825 | } else { |
825 | tty_insert_flip_string_fixed_flag(tty, data, tty_flag, | 826 | tty_insert_flip_string_fixed_flag(tty, data, tty_flag, |
826 | urb->actual_length); | 827 | urb->actual_length); |
827 | } | 828 | } |
828 | 829 | ||
829 | tty_flip_buffer_push(tty); | 830 | tty_flip_buffer_push(tty); |
830 | tty_kref_put(tty); | 831 | tty_kref_put(tty); |
831 | } | 832 | } |
832 | 833 | ||
833 | /* All of the device info needed for the PL2303 SIO serial converter */ | 834 | /* All of the device info needed for the PL2303 SIO serial converter */ |
834 | static struct usb_serial_driver pl2303_device = { | 835 | static struct usb_serial_driver pl2303_device = { |
835 | .driver = { | 836 | .driver = { |
836 | .owner = THIS_MODULE, | 837 | .owner = THIS_MODULE, |
837 | .name = "pl2303", | 838 | .name = "pl2303", |
838 | }, | 839 | }, |
839 | .id_table = id_table, | 840 | .id_table = id_table, |
840 | .usb_driver = &pl2303_driver, | 841 | .usb_driver = &pl2303_driver, |
841 | .num_ports = 1, | 842 | .num_ports = 1, |
842 | .bulk_in_size = 256, | 843 | .bulk_in_size = 256, |
843 | .bulk_out_size = 256, | 844 | .bulk_out_size = 256, |
844 | .open = pl2303_open, | 845 | .open = pl2303_open, |
845 | .close = pl2303_close, | 846 | .close = pl2303_close, |
846 | .dtr_rts = pl2303_dtr_rts, | 847 | .dtr_rts = pl2303_dtr_rts, |
847 | .carrier_raised = pl2303_carrier_raised, | 848 | .carrier_raised = pl2303_carrier_raised, |
848 | .ioctl = pl2303_ioctl, | 849 | .ioctl = pl2303_ioctl, |
849 | .break_ctl = pl2303_break_ctl, | 850 | .break_ctl = pl2303_break_ctl, |
850 | .set_termios = pl2303_set_termios, | 851 | .set_termios = pl2303_set_termios, |
851 | .tiocmget = pl2303_tiocmget, | 852 | .tiocmget = pl2303_tiocmget, |
852 | .tiocmset = pl2303_tiocmset, | 853 | .tiocmset = pl2303_tiocmset, |
853 | .process_read_urb = pl2303_process_read_urb, | 854 | .process_read_urb = pl2303_process_read_urb, |
854 | .read_int_callback = pl2303_read_int_callback, | 855 | .read_int_callback = pl2303_read_int_callback, |
855 | .attach = pl2303_startup, | 856 | .attach = pl2303_startup, |
856 | .release = pl2303_release, | 857 | .release = pl2303_release, |
857 | }; | 858 | }; |
858 | 859 | ||
859 | static int __init pl2303_init(void) | 860 | static int __init pl2303_init(void) |
860 | { | 861 | { |
861 | int retval; | 862 | int retval; |
862 | 863 | ||
863 | retval = usb_serial_register(&pl2303_device); | 864 | retval = usb_serial_register(&pl2303_device); |
864 | if (retval) | 865 | if (retval) |
865 | goto failed_usb_serial_register; | 866 | goto failed_usb_serial_register; |
866 | retval = usb_register(&pl2303_driver); | 867 | retval = usb_register(&pl2303_driver); |
867 | if (retval) | 868 | if (retval) |
868 | goto failed_usb_register; | 869 | goto failed_usb_register; |
869 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n"); | 870 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n"); |
870 | return 0; | 871 | return 0; |
871 | failed_usb_register: | 872 | failed_usb_register: |
872 | usb_serial_deregister(&pl2303_device); | 873 | usb_serial_deregister(&pl2303_device); |
873 | failed_usb_serial_register: | 874 | failed_usb_serial_register: |
874 | return retval; | 875 | return retval; |
875 | } | 876 | } |
876 | 877 | ||
877 | static void __exit pl2303_exit(void) | 878 | static void __exit pl2303_exit(void) |
878 | { | 879 | { |
879 | usb_deregister(&pl2303_driver); | 880 | usb_deregister(&pl2303_driver); |
880 | usb_serial_deregister(&pl2303_device); | 881 | usb_serial_deregister(&pl2303_device); |
881 | } | 882 | } |
882 | 883 | ||
883 | module_init(pl2303_init); | 884 | module_init(pl2303_init); |
884 | module_exit(pl2303_exit); | 885 | module_exit(pl2303_exit); |
885 | 886 | ||
886 | MODULE_DESCRIPTION(DRIVER_DESC); | 887 | MODULE_DESCRIPTION(DRIVER_DESC); |
887 | MODULE_LICENSE("GPL"); | 888 | MODULE_LICENSE("GPL"); |
888 | 889 | ||
889 | module_param(debug, bool, S_IRUGO | S_IWUSR); | 890 | module_param(debug, bool, S_IRUGO | S_IWUSR); |
890 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | 891 | MODULE_PARM_DESC(debug, "Debug enabled or not"); |
891 | 892 | ||
892 | 893 |
drivers/usb/serial/pl2303.h
1 | /* | 1 | /* |
2 | * Prolific PL2303 USB to serial adaptor driver header file | 2 | * Prolific PL2303 USB to serial adaptor driver header file |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or modify | 4 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License as published by | 5 | * it under the terms of the GNU General Public License as published by |
6 | * the Free Software Foundation; either version 2 of the License, or | 6 | * the Free Software Foundation; either version 2 of the License, or |
7 | * (at your option) any later version. | 7 | * (at your option) any later version. |
8 | * | 8 | * |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #define BENQ_VENDOR_ID 0x04a5 | 11 | #define BENQ_VENDOR_ID 0x04a5 |
12 | #define BENQ_PRODUCT_ID_S81 0x4027 | 12 | #define BENQ_PRODUCT_ID_S81 0x4027 |
13 | 13 | ||
14 | #define PL2303_VENDOR_ID 0x067b | 14 | #define PL2303_VENDOR_ID 0x067b |
15 | #define PL2303_PRODUCT_ID 0x2303 | 15 | #define PL2303_PRODUCT_ID 0x2303 |
16 | #define PL2303_PRODUCT_ID_RSAQ2 0x04bb | 16 | #define PL2303_PRODUCT_ID_RSAQ2 0x04bb |
17 | #define PL2303_PRODUCT_ID_DCU11 0x1234 | 17 | #define PL2303_PRODUCT_ID_DCU11 0x1234 |
18 | #define PL2303_PRODUCT_ID_PHAROS 0xaaa0 | 18 | #define PL2303_PRODUCT_ID_PHAROS 0xaaa0 |
19 | #define PL2303_PRODUCT_ID_RSAQ3 0xaaa2 | 19 | #define PL2303_PRODUCT_ID_RSAQ3 0xaaa2 |
20 | #define PL2303_PRODUCT_ID_ALDIGA 0x0611 | 20 | #define PL2303_PRODUCT_ID_ALDIGA 0x0611 |
21 | #define PL2303_PRODUCT_ID_MMX 0x0612 | 21 | #define PL2303_PRODUCT_ID_MMX 0x0612 |
22 | #define PL2303_PRODUCT_ID_GPRS 0x0609 | 22 | #define PL2303_PRODUCT_ID_GPRS 0x0609 |
23 | #define PL2303_PRODUCT_ID_HCR331 0x331a | 23 | #define PL2303_PRODUCT_ID_HCR331 0x331a |
24 | #define PL2303_PRODUCT_ID_MOTOROLA 0x0307 | 24 | #define PL2303_PRODUCT_ID_MOTOROLA 0x0307 |
25 | 25 | ||
26 | #define ATEN_VENDOR_ID 0x0557 | 26 | #define ATEN_VENDOR_ID 0x0557 |
27 | #define ATEN_VENDOR_ID2 0x0547 | 27 | #define ATEN_VENDOR_ID2 0x0547 |
28 | #define ATEN_PRODUCT_ID 0x2008 | 28 | #define ATEN_PRODUCT_ID 0x2008 |
29 | 29 | ||
30 | #define IODATA_VENDOR_ID 0x04bb | 30 | #define IODATA_VENDOR_ID 0x04bb |
31 | #define IODATA_PRODUCT_ID 0x0a03 | 31 | #define IODATA_PRODUCT_ID 0x0a03 |
32 | #define IODATA_PRODUCT_ID_RSAQ5 0x0a0e | 32 | #define IODATA_PRODUCT_ID_RSAQ5 0x0a0e |
33 | 33 | ||
34 | #define ELCOM_VENDOR_ID 0x056e | 34 | #define ELCOM_VENDOR_ID 0x056e |
35 | #define ELCOM_PRODUCT_ID 0x5003 | 35 | #define ELCOM_PRODUCT_ID 0x5003 |
36 | #define ELCOM_PRODUCT_ID_UCSGT 0x5004 | 36 | #define ELCOM_PRODUCT_ID_UCSGT 0x5004 |
37 | 37 | ||
38 | #define ITEGNO_VENDOR_ID 0x0eba | 38 | #define ITEGNO_VENDOR_ID 0x0eba |
39 | #define ITEGNO_PRODUCT_ID 0x1080 | 39 | #define ITEGNO_PRODUCT_ID 0x1080 |
40 | #define ITEGNO_PRODUCT_ID_2080 0x2080 | 40 | #define ITEGNO_PRODUCT_ID_2080 0x2080 |
41 | 41 | ||
42 | #define MA620_VENDOR_ID 0x0df7 | 42 | #define MA620_VENDOR_ID 0x0df7 |
43 | #define MA620_PRODUCT_ID 0x0620 | 43 | #define MA620_PRODUCT_ID 0x0620 |
44 | 44 | ||
45 | #define RATOC_VENDOR_ID 0x0584 | 45 | #define RATOC_VENDOR_ID 0x0584 |
46 | #define RATOC_PRODUCT_ID 0xb000 | 46 | #define RATOC_PRODUCT_ID 0xb000 |
47 | 47 | ||
48 | #define TRIPP_VENDOR_ID 0x2478 | 48 | #define TRIPP_VENDOR_ID 0x2478 |
49 | #define TRIPP_PRODUCT_ID 0x2008 | 49 | #define TRIPP_PRODUCT_ID 0x2008 |
50 | 50 | ||
51 | #define RADIOSHACK_VENDOR_ID 0x1453 | 51 | #define RADIOSHACK_VENDOR_ID 0x1453 |
52 | #define RADIOSHACK_PRODUCT_ID 0x4026 | 52 | #define RADIOSHACK_PRODUCT_ID 0x4026 |
53 | 53 | ||
54 | #define DCU10_VENDOR_ID 0x0731 | 54 | #define DCU10_VENDOR_ID 0x0731 |
55 | #define DCU10_PRODUCT_ID 0x0528 | 55 | #define DCU10_PRODUCT_ID 0x0528 |
56 | 56 | ||
57 | #define SITECOM_VENDOR_ID 0x6189 | 57 | #define SITECOM_VENDOR_ID 0x6189 |
58 | #define SITECOM_PRODUCT_ID 0x2068 | 58 | #define SITECOM_PRODUCT_ID 0x2068 |
59 | 59 | ||
60 | /* Alcatel OT535/735 USB cable */ | 60 | /* Alcatel OT535/735 USB cable */ |
61 | #define ALCATEL_VENDOR_ID 0x11f7 | 61 | #define ALCATEL_VENDOR_ID 0x11f7 |
62 | #define ALCATEL_PRODUCT_ID 0x02df | 62 | #define ALCATEL_PRODUCT_ID 0x02df |
63 | 63 | ||
64 | /* Samsung I330 phone cradle */ | 64 | /* Samsung I330 phone cradle */ |
65 | #define SAMSUNG_VENDOR_ID 0x04e8 | 65 | #define SAMSUNG_VENDOR_ID 0x04e8 |
66 | #define SAMSUNG_PRODUCT_ID 0x8001 | 66 | #define SAMSUNG_PRODUCT_ID 0x8001 |
67 | 67 | ||
68 | #define SIEMENS_VENDOR_ID 0x11f5 | 68 | #define SIEMENS_VENDOR_ID 0x11f5 |
69 | #define SIEMENS_PRODUCT_ID_SX1 0x0001 | 69 | #define SIEMENS_PRODUCT_ID_SX1 0x0001 |
70 | #define SIEMENS_PRODUCT_ID_X65 0x0003 | 70 | #define SIEMENS_PRODUCT_ID_X65 0x0003 |
71 | #define SIEMENS_PRODUCT_ID_X75 0x0004 | 71 | #define SIEMENS_PRODUCT_ID_X75 0x0004 |
72 | #define SIEMENS_PRODUCT_ID_EF81 0x0005 | 72 | #define SIEMENS_PRODUCT_ID_EF81 0x0005 |
73 | 73 | ||
74 | #define SYNTECH_VENDOR_ID 0x0745 | 74 | #define SYNTECH_VENDOR_ID 0x0745 |
75 | #define SYNTECH_PRODUCT_ID 0x0001 | 75 | #define SYNTECH_PRODUCT_ID 0x0001 |
76 | 76 | ||
77 | /* Nokia CA-42 Cable */ | 77 | /* Nokia CA-42 Cable */ |
78 | #define NOKIA_CA42_VENDOR_ID 0x078b | 78 | #define NOKIA_CA42_VENDOR_ID 0x078b |
79 | #define NOKIA_CA42_PRODUCT_ID 0x1234 | 79 | #define NOKIA_CA42_PRODUCT_ID 0x1234 |
80 | 80 | ||
81 | /* CA-42 CLONE Cable www.ca-42.com chipset: Prolific Technology Inc */ | 81 | /* CA-42 CLONE Cable www.ca-42.com chipset: Prolific Technology Inc */ |
82 | #define CA_42_CA42_VENDOR_ID 0x10b5 | 82 | #define CA_42_CA42_VENDOR_ID 0x10b5 |
83 | #define CA_42_CA42_PRODUCT_ID 0xac70 | 83 | #define CA_42_CA42_PRODUCT_ID 0xac70 |
84 | 84 | ||
85 | #define SAGEM_VENDOR_ID 0x079b | 85 | #define SAGEM_VENDOR_ID 0x079b |
86 | #define SAGEM_PRODUCT_ID 0x0027 | 86 | #define SAGEM_PRODUCT_ID 0x0027 |
87 | 87 | ||
88 | /* Leadtek GPS 9531 (ID 0413:2101) */ | 88 | /* Leadtek GPS 9531 (ID 0413:2101) */ |
89 | #define LEADTEK_VENDOR_ID 0x0413 | 89 | #define LEADTEK_VENDOR_ID 0x0413 |
90 | #define LEADTEK_9531_PRODUCT_ID 0x2101 | 90 | #define LEADTEK_9531_PRODUCT_ID 0x2101 |
91 | 91 | ||
92 | /* USB GSM cable from Speed Dragon Multimedia, Ltd */ | 92 | /* USB GSM cable from Speed Dragon Multimedia, Ltd */ |
93 | #define SPEEDDRAGON_VENDOR_ID 0x0e55 | 93 | #define SPEEDDRAGON_VENDOR_ID 0x0e55 |
94 | #define SPEEDDRAGON_PRODUCT_ID 0x110b | 94 | #define SPEEDDRAGON_PRODUCT_ID 0x110b |
95 | 95 | ||
96 | /* DATAPILOT Universal-2 Phone Cable */ | 96 | /* DATAPILOT Universal-2 Phone Cable */ |
97 | #define DATAPILOT_U2_VENDOR_ID 0x0731 | 97 | #define DATAPILOT_U2_VENDOR_ID 0x0731 |
98 | #define DATAPILOT_U2_PRODUCT_ID 0x2003 | 98 | #define DATAPILOT_U2_PRODUCT_ID 0x2003 |
99 | 99 | ||
100 | /* Belkin "F5U257" Serial Adapter */ | 100 | /* Belkin "F5U257" Serial Adapter */ |
101 | #define BELKIN_VENDOR_ID 0x050d | 101 | #define BELKIN_VENDOR_ID 0x050d |
102 | #define BELKIN_PRODUCT_ID 0x0257 | 102 | #define BELKIN_PRODUCT_ID 0x0257 |
103 | 103 | ||
104 | /* Alcor Micro Corp. USB 2.0 TO RS-232 */ | 104 | /* Alcor Micro Corp. USB 2.0 TO RS-232 */ |
105 | #define ALCOR_VENDOR_ID 0x058F | 105 | #define ALCOR_VENDOR_ID 0x058F |
106 | #define ALCOR_PRODUCT_ID 0x9720 | 106 | #define ALCOR_PRODUCT_ID 0x9720 |
107 | 107 | ||
108 | /* Willcom WS002IN Data Driver (by NetIndex Inc.) */ | 108 | /* Willcom WS002IN Data Driver (by NetIndex Inc.) */ |
109 | #define WS002IN_VENDOR_ID 0x11f6 | 109 | #define WS002IN_VENDOR_ID 0x11f6 |
110 | #define WS002IN_PRODUCT_ID 0x2001 | 110 | #define WS002IN_PRODUCT_ID 0x2001 |
111 | 111 | ||
112 | /* Corega CG-USBRS232R Serial Adapter */ | 112 | /* Corega CG-USBRS232R Serial Adapter */ |
113 | #define COREGA_VENDOR_ID 0x07aa | 113 | #define COREGA_VENDOR_ID 0x07aa |
114 | #define COREGA_PRODUCT_ID 0x002a | 114 | #define COREGA_PRODUCT_ID 0x002a |
115 | 115 | ||
116 | /* Y.C. Cable U.S.A., Inc - USB to RS-232 */ | 116 | /* Y.C. Cable U.S.A., Inc - USB to RS-232 */ |
117 | #define YCCABLE_VENDOR_ID 0x05ad | 117 | #define YCCABLE_VENDOR_ID 0x05ad |
118 | #define YCCABLE_PRODUCT_ID 0x0fba | 118 | #define YCCABLE_PRODUCT_ID 0x0fba |
119 | 119 | ||
120 | /* "Superial" USB - Serial */ | 120 | /* "Superial" USB - Serial */ |
121 | #define SUPERIAL_VENDOR_ID 0x5372 | 121 | #define SUPERIAL_VENDOR_ID 0x5372 |
122 | #define SUPERIAL_PRODUCT_ID 0x2303 | 122 | #define SUPERIAL_PRODUCT_ID 0x2303 |
123 | 123 | ||
124 | /* Hewlett-Packard LD220-HP POS Pole Display */ | 124 | /* Hewlett-Packard LD220-HP POS Pole Display */ |
125 | #define HP_VENDOR_ID 0x03f0 | 125 | #define HP_VENDOR_ID 0x03f0 |
126 | #define HP_LD220_PRODUCT_ID 0x3524 | 126 | #define HP_LD220_PRODUCT_ID 0x3524 |
127 | 127 | ||
128 | /* Cressi Edy (diving computer) PC interface */ | 128 | /* Cressi Edy (diving computer) PC interface */ |
129 | #define CRESSI_VENDOR_ID 0x04b8 | 129 | #define CRESSI_VENDOR_ID 0x04b8 |
130 | #define CRESSI_EDY_PRODUCT_ID 0x0521 | 130 | #define CRESSI_EDY_PRODUCT_ID 0x0521 |
131 | 131 | ||
132 | /* Zeagle dive computer interface */ | 132 | /* Zeagle dive computer interface */ |
133 | #define ZEAGLE_VENDOR_ID 0x04b8 | 133 | #define ZEAGLE_VENDOR_ID 0x04b8 |
134 | #define ZEAGLE_N2ITION3_PRODUCT_ID 0x0522 | 134 | #define ZEAGLE_N2ITION3_PRODUCT_ID 0x0522 |
135 | 135 | ||
136 | /* Sony, USB data cable for CMD-Jxx mobile phones */ | 136 | /* Sony, USB data cable for CMD-Jxx mobile phones */ |
137 | #define SONY_VENDOR_ID 0x054c | 137 | #define SONY_VENDOR_ID 0x054c |
138 | #define SONY_QN3USB_PRODUCT_ID 0x0437 | 138 | #define SONY_QN3USB_PRODUCT_ID 0x0437 |
139 | 139 | ||
140 | /* Sanwa KB-USB2 multimeter cable (ID: 11ad:0001) */ | 140 | /* Sanwa KB-USB2 multimeter cable (ID: 11ad:0001) */ |
141 | #define SANWA_VENDOR_ID 0x11ad | 141 | #define SANWA_VENDOR_ID 0x11ad |
142 | #define SANWA_PRODUCT_ID 0x0001 | 142 | #define SANWA_PRODUCT_ID 0x0001 |
143 | 143 | ||
144 | /* ADLINK ND-6530 RS232,RS485 and RS422 adapter */ | 144 | /* ADLINK ND-6530 RS232,RS485 and RS422 adapter */ |
145 | #define ADLINK_VENDOR_ID 0x0b63 | 145 | #define ADLINK_VENDOR_ID 0x0b63 |
146 | #define ADLINK_ND6530_PRODUCT_ID 0x6530 | 146 | #define ADLINK_ND6530_PRODUCT_ID 0x6530 |
147 | |||
148 | /* WinChipHead USB->RS 232 adapter */ | ||
149 | #define WINCHIPHEAD_VENDOR_ID 0x4348 | ||
150 | #define WINCHIPHEAD_USBSER_PRODUCT_ID 0x5523 | ||
147 | 151 |