From: 赵子初 Date: Thu, 19 Jul 2012 09:21:31 +0000 (+0800) Subject: phonepad:add usiserial.c for usi modem X-Git-Tag: firefly_0821_release~8992 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b388cab1a5af8b29205fa938cf91902ef8840cf1;p=firefly-linux-kernel-4.4.55.git phonepad:add usiserial.c for usi modem --- diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig index b71e309116a3..0b70da3518d9 100644 --- a/drivers/usb/serial/Kconfig +++ b/drivers/usb/serial/Kconfig @@ -661,4 +661,12 @@ config USB_SERIAL_DEBUG To compile this driver as a module, choose M here: the module will be called usb-debug. +config USB_SERIAL_USI + tristate "USB USI Serial driver" + help + Say Y here if you have a USI WCDMA modem that's connected to USB. + + To compile this driver as a module, choose M here: the module will be called + module will be called option. + endif # USB_SERIAL diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile index 9e536eefb32c..991cc047a41a 100644 --- a/drivers/usb/serial/Makefile +++ b/drivers/usb/serial/Makefile @@ -60,3 +60,4 @@ obj-$(CONFIG_USB_SERIAL_WHITEHEAT) += whiteheat.o obj-$(CONFIG_USB_SERIAL_XIRCOM) += keyspan_pda.o obj-$(CONFIG_USB_SERIAL_VIVOPAY_SERIAL) += vivopay-serial.o obj-$(CONFIG_USB_SERIAL_ZIO) += zio.o +obj-$(CONFIG_USB_SERIAL_USI) += usiserial.o diff --git a/drivers/usb/serial/usiserial.c b/drivers/usb/serial/usiserial.c new file mode 100755 index 000000000000..33a250c092c6 --- /dev/null +++ b/drivers/usb/serial/usiserial.c @@ -0,0 +1,83 @@ +/* + * USI WCDMA Modem driver + * + * Copyright (C) 2011 John Tseng + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + +#include +#include +#include +#include +#include +#include + +static int usi_probe(struct usb_interface *interface, + const struct usb_device_id *id); + +static struct usb_device_id id_table [] = { + { USB_DEVICE(0x0e8d, 0x00a1) }, /* USI WCDMA modem 3COM */ + { USB_DEVICE(0x0e8d, 0x00a2) }, /* USI WCDMA modem 2COM */ + { }, +}; +MODULE_DEVICE_TABLE(usb, id_table); + +static struct usb_driver usi_driver = { + .name = "usi-modem", + .probe = usi_probe, + .disconnect = usb_serial_disconnect, + .id_table = id_table, + .suspend = usb_serial_suspend, + .resume = usb_serial_resume, + .no_dynamic_id = 1, +}; + +static struct usb_serial_driver usi_device = { + .driver = { + .owner = THIS_MODULE, + .name = "usi-modem", + }, + .usb_driver = &usi_driver, + .id_table = id_table, + .num_ports = 1, +}; + +static int usi_probe(struct usb_interface *interface, + const struct usb_device_id *id) +{ + int if_num; + + if_num = interface->altsetting->desc.bInterfaceNumber; + + if (if_num == 2) + return usb_serial_probe(interface, id); + + return -ENODEV; +} + +static int __init usi_init(void) +{ + int retval; + + retval = usb_serial_register(&usi_device); + if (retval) + return retval; + retval = usb_register(&usi_driver); + if (retval) + usb_serial_deregister(&usi_device); + return retval; +} + +static void __exit usi_exit(void) +{ + usb_deregister(&usi_driver); + usb_serial_deregister(&usi_device); +} + +module_init(usi_init); +module_exit(usi_exit); +MODULE_LICENSE("GPL");