phonepad:add usiserial.c for usi modem
author赵子初 <zzc@rock-chips.com>
Thu, 19 Jul 2012 09:21:31 +0000 (17:21 +0800)
committer赵子初 <zzc@rock-chips.com>
Thu, 19 Jul 2012 09:21:31 +0000 (17:21 +0800)
drivers/usb/serial/Kconfig
drivers/usb/serial/Makefile
drivers/usb/serial/usiserial.c [new file with mode: 0755]

index b71e309116a304c37ea462762ab5bdb89a240185..0b70da3518d955bd4236836a4fb444ade648ff1b 100644 (file)
@@ -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
index 9e536eefb32c32e96d45a993a919b97d865a1bfa..991cc047a41ab32e82bb5a357459b5274fd57442 100644 (file)
@@ -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 (executable)
index 0000000..33a250c
--- /dev/null
@@ -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 <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/tty.h>
+#include <linux/module.h>
+#include <linux/usb.h>
+#include <linux/usb/serial.h>
+
+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");