MIPS: ralink: adds support for RT2880 SoC family
[linux-2.6/btrfs-unstable.git] / drivers / usb / serial / xsens_mt.c
blob1d5798d891bc7d5e3cea9ace61e90afe22d55658
1 /*
2 * Xsens MT USB driver
4 * Copyright (C) 2013 Xsens <info@xsens.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 */
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/tty.h>
14 #include <linux/module.h>
15 #include <linux/usb.h>
16 #include <linux/usb/serial.h>
17 #include <linux/uaccess.h>
19 #define XSENS_VID 0x2639
21 #define MTi_10_IMU_PID 0x0001
22 #define MTi_20_VRU_PID 0x0002
23 #define MTi_30_AHRS_PID 0x0003
25 #define MTi_100_IMU_PID 0x0011
26 #define MTi_200_VRU_PID 0x0012
27 #define MTi_300_AHRS_PID 0x0013
29 #define MTi_G_700_GPS_INS_PID 0x0017
31 static const struct usb_device_id id_table[] = {
32 { USB_DEVICE(XSENS_VID, MTi_10_IMU_PID) },
33 { USB_DEVICE(XSENS_VID, MTi_20_VRU_PID) },
34 { USB_DEVICE(XSENS_VID, MTi_30_AHRS_PID) },
36 { USB_DEVICE(XSENS_VID, MTi_100_IMU_PID) },
37 { USB_DEVICE(XSENS_VID, MTi_200_VRU_PID) },
38 { USB_DEVICE(XSENS_VID, MTi_300_AHRS_PID) },
40 { USB_DEVICE(XSENS_VID, MTi_G_700_GPS_INS_PID) },
41 { },
43 MODULE_DEVICE_TABLE(usb, id_table);
45 static int has_required_endpoints(const struct usb_host_interface *interface)
47 __u8 i;
48 int has_bulk_in = 0;
49 int has_bulk_out = 0;
51 for (i = 0; i < interface->desc.bNumEndpoints; ++i) {
52 if (usb_endpoint_is_bulk_in(&interface->endpoint[i].desc))
53 has_bulk_in = 1;
54 else if (usb_endpoint_is_bulk_out(&interface->endpoint[i].desc))
55 has_bulk_out = 1;
58 return has_bulk_in && has_bulk_out;
61 static int xsens_mt_probe(struct usb_serial *serial,
62 const struct usb_device_id *id)
64 if (!has_required_endpoints(serial->interface->cur_altsetting))
65 return -ENODEV;
66 return 0;
69 static struct usb_serial_driver xsens_mt_device = {
70 .driver = {
71 .owner = THIS_MODULE,
72 .name = "xsens_mt",
74 .id_table = id_table,
75 .num_ports = 1,
77 .probe = xsens_mt_probe,
80 static struct usb_serial_driver * const serial_drivers[] = {
81 &xsens_mt_device, NULL
84 module_usb_serial_driver(serial_drivers, id_table);
86 MODULE_LICENSE("GPL");