Commit f5ee0557 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge tag 'usb-serial-4.4-rc1' of...

Merge tag 'usb-serial-4.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial into usb-next

Johan writes:

USB-serial updates for v4.4-rc1

These updates generalise the option DTR/RTS handling so that all
usb-wwan-based drivers can use it. This is specifically needed by some
Sierra modems, which can now all be handled by qcserial again.

Included are also some clean ups of the io_ti firmware handling.
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
parents 9e43643b 92944c45
This diff is collapsed.
...@@ -48,7 +48,6 @@ static int option_probe(struct usb_serial *serial, ...@@ -48,7 +48,6 @@ static int option_probe(struct usb_serial *serial,
const struct usb_device_id *id); const struct usb_device_id *id);
static int option_attach(struct usb_serial *serial); static int option_attach(struct usb_serial *serial);
static void option_release(struct usb_serial *serial); static void option_release(struct usb_serial *serial);
static int option_send_setup(struct usb_serial_port *port);
static void option_instat_callback(struct urb *urb); static void option_instat_callback(struct urb *urb);
/* Vendor and product IDs */ /* Vendor and product IDs */
...@@ -234,8 +233,6 @@ static void option_instat_callback(struct urb *urb); ...@@ -234,8 +233,6 @@ static void option_instat_callback(struct urb *urb);
#define QUALCOMM_VENDOR_ID 0x05C6 #define QUALCOMM_VENDOR_ID 0x05C6
#define SIERRA_VENDOR_ID 0x1199
#define CMOTECH_VENDOR_ID 0x16d8 #define CMOTECH_VENDOR_ID 0x16d8
#define CMOTECH_PRODUCT_6001 0x6001 #define CMOTECH_PRODUCT_6001 0x6001
#define CMOTECH_PRODUCT_CMU_300 0x6002 #define CMOTECH_PRODUCT_CMU_300 0x6002
...@@ -611,11 +608,6 @@ static const struct option_blacklist_info telit_le920_blacklist = { ...@@ -611,11 +608,6 @@ static const struct option_blacklist_info telit_le920_blacklist = {
.reserved = BIT(1) | BIT(5), .reserved = BIT(1) | BIT(5),
}; };
static const struct option_blacklist_info sierra_mc73xx_blacklist = {
.sendsetup = BIT(0) | BIT(2),
.reserved = BIT(8) | BIT(10) | BIT(11),
};
static const struct usb_device_id option_ids[] = { static const struct usb_device_id option_ids[] = {
{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
...@@ -1113,10 +1105,6 @@ static const struct usb_device_id option_ids[] = { ...@@ -1113,10 +1105,6 @@ static const struct usb_device_id option_ids[] = {
{ USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */
{ USB_DEVICE(QUALCOMM_VENDOR_ID, 0x0023)}, /* ONYX 3G device */ { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x0023)}, /* ONYX 3G device */
{ USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000)}, /* SIMCom SIM5218 */ { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000)}, /* SIMCom SIM5218 */
{ USB_DEVICE_INTERFACE_CLASS(SIERRA_VENDOR_ID, 0x68c0, 0xff),
.driver_info = (kernel_ulong_t)&sierra_mc73xx_blacklist }, /* MC73xx */
{ USB_DEVICE_INTERFACE_CLASS(SIERRA_VENDOR_ID, 0x9041, 0xff),
.driver_info = (kernel_ulong_t)&sierra_mc73xx_blacklist }, /* MC7305/MC7355 */
{ USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) }, { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) },
{ USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) }, { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) },
{ USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6003), { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6003),
...@@ -1835,10 +1823,6 @@ static struct usb_serial_driver * const serial_drivers[] = { ...@@ -1835,10 +1823,6 @@ static struct usb_serial_driver * const serial_drivers[] = {
&option_1port_device, NULL &option_1port_device, NULL
}; };
struct option_private {
u8 bInterfaceNumber;
};
module_usb_serial_driver(serial_drivers, option_ids); module_usb_serial_driver(serial_drivers, option_ids);
static int option_probe(struct usb_serial *serial, static int option_probe(struct usb_serial *serial,
...@@ -1882,29 +1866,19 @@ static int option_attach(struct usb_serial *serial) ...@@ -1882,29 +1866,19 @@ static int option_attach(struct usb_serial *serial)
struct usb_interface_descriptor *iface_desc; struct usb_interface_descriptor *iface_desc;
const struct option_blacklist_info *blacklist; const struct option_blacklist_info *blacklist;
struct usb_wwan_intf_private *data; struct usb_wwan_intf_private *data;
struct option_private *priv;
data = kzalloc(sizeof(struct usb_wwan_intf_private), GFP_KERNEL); data = kzalloc(sizeof(struct usb_wwan_intf_private), GFP_KERNEL);
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv) {
kfree(data);
return -ENOMEM;
}
/* Retrieve blacklist info stored at probe. */ /* Retrieve blacklist info stored at probe. */
blacklist = usb_get_serial_data(serial); blacklist = usb_get_serial_data(serial);
iface_desc = &serial->interface->cur_altsetting->desc; iface_desc = &serial->interface->cur_altsetting->desc;
priv->bInterfaceNumber = iface_desc->bInterfaceNumber;
data->private = priv;
if (!blacklist || !test_bit(iface_desc->bInterfaceNumber, if (!blacklist || !test_bit(iface_desc->bInterfaceNumber,
&blacklist->sendsetup)) { &blacklist->sendsetup)) {
data->send_setup = option_send_setup; data->use_send_setup = 1;
} }
spin_lock_init(&data->susp_lock); spin_lock_init(&data->susp_lock);
...@@ -1916,9 +1890,7 @@ static int option_attach(struct usb_serial *serial) ...@@ -1916,9 +1890,7 @@ static int option_attach(struct usb_serial *serial)
static void option_release(struct usb_serial *serial) static void option_release(struct usb_serial *serial)
{ {
struct usb_wwan_intf_private *intfdata = usb_get_serial_data(serial); struct usb_wwan_intf_private *intfdata = usb_get_serial_data(serial);
struct option_private *priv = intfdata->private;
kfree(priv);
kfree(intfdata); kfree(intfdata);
} }
...@@ -1977,40 +1949,6 @@ static void option_instat_callback(struct urb *urb) ...@@ -1977,40 +1949,6 @@ static void option_instat_callback(struct urb *urb)
} }
} }
/** send RTS/DTR state to the port.
*
* This is exactly the same as SET_CONTROL_LINE_STATE from the PSTN
* CDC.
*/
static int option_send_setup(struct usb_serial_port *port)
{
struct usb_serial *serial = port->serial;
struct usb_wwan_intf_private *intfdata = usb_get_serial_data(serial);
struct option_private *priv = intfdata->private;
struct usb_wwan_port_private *portdata;
int val = 0;
int res;
portdata = usb_get_serial_port_data(port);
if (portdata->dtr_state)
val |= 0x01;
if (portdata->rts_state)
val |= 0x02;
res = usb_autopm_get_interface(serial->interface);
if (res)
return res;
res = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
0x22, 0x21, val, priv->bInterfaceNumber, NULL,
0, USB_CTRL_SET_TIMEOUT);
usb_autopm_put_interface(serial->interface);
return res;
}
MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC); MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -143,9 +143,11 @@ static const struct usb_device_id id_table[] = { ...@@ -143,9 +143,11 @@ static const struct usb_device_id id_table[] = {
{DEVICE_SWI(0x0f3d, 0x68a2)}, /* Sierra Wireless MC7700 */ {DEVICE_SWI(0x0f3d, 0x68a2)}, /* Sierra Wireless MC7700 */
{DEVICE_SWI(0x114f, 0x68a2)}, /* Sierra Wireless MC7750 */ {DEVICE_SWI(0x114f, 0x68a2)}, /* Sierra Wireless MC7750 */
{DEVICE_SWI(0x1199, 0x68a2)}, /* Sierra Wireless MC7710 */ {DEVICE_SWI(0x1199, 0x68a2)}, /* Sierra Wireless MC7710 */
{DEVICE_SWI(0x1199, 0x68c0)}, /* Sierra Wireless MC7304/MC7354 */
{DEVICE_SWI(0x1199, 0x901c)}, /* Sierra Wireless EM7700 */ {DEVICE_SWI(0x1199, 0x901c)}, /* Sierra Wireless EM7700 */
{DEVICE_SWI(0x1199, 0x901f)}, /* Sierra Wireless EM7355 */ {DEVICE_SWI(0x1199, 0x901f)}, /* Sierra Wireless EM7355 */
{DEVICE_SWI(0x1199, 0x9040)}, /* Sierra Wireless Modem */ {DEVICE_SWI(0x1199, 0x9040)}, /* Sierra Wireless Modem */
{DEVICE_SWI(0x1199, 0x9041)}, /* Sierra Wireless MC7305/MC7355 */
{DEVICE_SWI(0x1199, 0x9051)}, /* Netgear AirCard 340U */ {DEVICE_SWI(0x1199, 0x9051)}, /* Netgear AirCard 340U */
{DEVICE_SWI(0x1199, 0x9053)}, /* Sierra Wireless Modem */ {DEVICE_SWI(0x1199, 0x9053)}, /* Sierra Wireless Modem */
{DEVICE_SWI(0x1199, 0x9054)}, /* Sierra Wireless Modem */ {DEVICE_SWI(0x1199, 0x9054)}, /* Sierra Wireless Modem */
...@@ -175,6 +177,7 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id) ...@@ -175,6 +177,7 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
__u8 nintf; __u8 nintf;
__u8 ifnum; __u8 ifnum;
int altsetting = -1; int altsetting = -1;
bool sendsetup = false;
nintf = serial->dev->actconfig->desc.bNumInterfaces; nintf = serial->dev->actconfig->desc.bNumInterfaces;
dev_dbg(dev, "Num Interfaces = %d\n", nintf); dev_dbg(dev, "Num Interfaces = %d\n", nintf);
...@@ -286,6 +289,7 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id) ...@@ -286,6 +289,7 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
break; break;
case 3: case 3:
dev_dbg(dev, "Modem port found\n"); dev_dbg(dev, "Modem port found\n");
sendsetup = true;
break; break;
default: default:
/* don't claim any unsupported interface */ /* don't claim any unsupported interface */
...@@ -337,17 +341,25 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id) ...@@ -337,17 +341,25 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
} }
} }
if (!retval)
usb_set_serial_data(serial, (void *)(unsigned long)sendsetup);
return retval; return retval;
} }
static int qc_attach(struct usb_serial *serial) static int qc_attach(struct usb_serial *serial)
{ {
struct usb_wwan_intf_private *data; struct usb_wwan_intf_private *data;
bool sendsetup;
data = kzalloc(sizeof(*data), GFP_KERNEL); data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
sendsetup = !!(unsigned long)(usb_get_serial_data(serial));
if (sendsetup)
data->use_send_setup = 1;
spin_lock_init(&data->susp_lock); spin_lock_init(&data->susp_lock);
usb_set_serial_data(serial, data); usb_set_serial_data(serial, data);
...@@ -374,6 +386,7 @@ static struct usb_serial_driver qcdevice = { ...@@ -374,6 +386,7 @@ static struct usb_serial_driver qcdevice = {
.probe = qcprobe, .probe = qcprobe,
.open = usb_wwan_open, .open = usb_wwan_open,
.close = usb_wwan_close, .close = usb_wwan_close,
.dtr_rts = usb_wwan_dtr_rts,
.write = usb_wwan_write, .write = usb_wwan_write,
.write_room = usb_wwan_write_room, .write_room = usb_wwan_write_room,
.chars_in_buffer = usb_wwan_chars_in_buffer, .chars_in_buffer = usb_wwan_chars_in_buffer,
......
...@@ -34,9 +34,9 @@ extern int usb_wwan_resume(struct usb_serial *serial); ...@@ -34,9 +34,9 @@ extern int usb_wwan_resume(struct usb_serial *serial);
struct usb_wwan_intf_private { struct usb_wwan_intf_private {
spinlock_t susp_lock; spinlock_t susp_lock;
unsigned int suspended:1; unsigned int suspended:1;
unsigned int use_send_setup:1;
int in_flight; int in_flight;
unsigned int open_ports; unsigned int open_ports;
int (*send_setup) (struct usb_serial_port *port);
void *private; void *private;
}; };
......
...@@ -36,6 +36,40 @@ ...@@ -36,6 +36,40 @@
#include <linux/serial.h> #include <linux/serial.h>
#include "usb-wwan.h" #include "usb-wwan.h"
/*
* Generate DTR/RTS signals on the port using the SET_CONTROL_LINE_STATE request
* in CDC ACM.
*/
static int usb_wwan_send_setup(struct usb_serial_port *port)
{
struct usb_serial *serial = port->serial;
struct usb_wwan_port_private *portdata;
int val = 0;
int ifnum;
int res;
portdata = usb_get_serial_port_data(port);
if (portdata->dtr_state)
val |= 0x01;
if (portdata->rts_state)
val |= 0x02;
ifnum = serial->interface->cur_altsetting->desc.bInterfaceNumber;
res = usb_autopm_get_interface(serial->interface);
if (res)
return res;
res = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
0x22, 0x21, val, ifnum, NULL, 0,
USB_CTRL_SET_TIMEOUT);
usb_autopm_put_interface(port->serial->interface);
return res;
}
void usb_wwan_dtr_rts(struct usb_serial_port *port, int on) void usb_wwan_dtr_rts(struct usb_serial_port *port, int on)
{ {
struct usb_wwan_port_private *portdata; struct usb_wwan_port_private *portdata;
...@@ -43,7 +77,7 @@ void usb_wwan_dtr_rts(struct usb_serial_port *port, int on) ...@@ -43,7 +77,7 @@ void usb_wwan_dtr_rts(struct usb_serial_port *port, int on)
intfdata = usb_get_serial_data(port->serial); intfdata = usb_get_serial_data(port->serial);
if (!intfdata->send_setup) if (!intfdata->use_send_setup)
return; return;
portdata = usb_get_serial_port_data(port); portdata = usb_get_serial_port_data(port);
...@@ -51,7 +85,7 @@ void usb_wwan_dtr_rts(struct usb_serial_port *port, int on) ...@@ -51,7 +85,7 @@ void usb_wwan_dtr_rts(struct usb_serial_port *port, int on)
portdata->rts_state = on; portdata->rts_state = on;
portdata->dtr_state = on; portdata->dtr_state = on;
intfdata->send_setup(port); usb_wwan_send_setup(port);
} }
EXPORT_SYMBOL(usb_wwan_dtr_rts); EXPORT_SYMBOL(usb_wwan_dtr_rts);
...@@ -84,7 +118,7 @@ int usb_wwan_tiocmset(struct tty_struct *tty, ...@@ -84,7 +118,7 @@ int usb_wwan_tiocmset(struct tty_struct *tty,
portdata = usb_get_serial_port_data(port); portdata = usb_get_serial_port_data(port);
intfdata = usb_get_serial_data(port->serial); intfdata = usb_get_serial_data(port->serial);
if (!intfdata->send_setup) if (!intfdata->use_send_setup)
return -EINVAL; return -EINVAL;
/* FIXME: what locks portdata fields ? */ /* FIXME: what locks portdata fields ? */
...@@ -97,7 +131,7 @@ int usb_wwan_tiocmset(struct tty_struct *tty, ...@@ -97,7 +131,7 @@ int usb_wwan_tiocmset(struct tty_struct *tty,
portdata->rts_state = 0; portdata->rts_state = 0;
if (clear & TIOCM_DTR) if (clear & TIOCM_DTR)
portdata->dtr_state = 0; portdata->dtr_state = 0;
return intfdata->send_setup(port); return usb_wwan_send_setup(port);
} }
EXPORT_SYMBOL(usb_wwan_tiocmset); EXPORT_SYMBOL(usb_wwan_tiocmset);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment