Greg Kroah-Hartman | 5fd54ac | 2017-11-03 11:28:30 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Frans Klaver | 59e931c4 | 2013-01-25 17:05:44 +0100 | [diff] [blame] | 2 | /* |
| 3 | * Xsens MT USB driver |
| 4 | * |
| 5 | * Copyright (C) 2013 Xsens <info@xsens.com> |
Frans Klaver | 59e931c4 | 2013-01-25 17:05:44 +0100 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <linux/kernel.h> |
Frans Klaver | 59e931c4 | 2013-01-25 17:05:44 +0100 | [diff] [blame] | 9 | #include <linux/tty.h> |
| 10 | #include <linux/module.h> |
| 11 | #include <linux/usb.h> |
| 12 | #include <linux/usb/serial.h> |
| 13 | #include <linux/uaccess.h> |
| 14 | |
| 15 | #define XSENS_VID 0x2639 |
| 16 | |
| 17 | #define MTi_10_IMU_PID 0x0001 |
| 18 | #define MTi_20_VRU_PID 0x0002 |
| 19 | #define MTi_30_AHRS_PID 0x0003 |
| 20 | |
| 21 | #define MTi_100_IMU_PID 0x0011 |
| 22 | #define MTi_200_VRU_PID 0x0012 |
| 23 | #define MTi_300_AHRS_PID 0x0013 |
| 24 | |
| 25 | #define MTi_G_700_GPS_INS_PID 0x0017 |
| 26 | |
| 27 | static const struct usb_device_id id_table[] = { |
| 28 | { USB_DEVICE(XSENS_VID, MTi_10_IMU_PID) }, |
| 29 | { USB_DEVICE(XSENS_VID, MTi_20_VRU_PID) }, |
| 30 | { USB_DEVICE(XSENS_VID, MTi_30_AHRS_PID) }, |
| 31 | |
| 32 | { USB_DEVICE(XSENS_VID, MTi_100_IMU_PID) }, |
| 33 | { USB_DEVICE(XSENS_VID, MTi_200_VRU_PID) }, |
| 34 | { USB_DEVICE(XSENS_VID, MTi_300_AHRS_PID) }, |
| 35 | |
| 36 | { USB_DEVICE(XSENS_VID, MTi_G_700_GPS_INS_PID) }, |
| 37 | { }, |
| 38 | }; |
| 39 | MODULE_DEVICE_TABLE(usb, id_table); |
| 40 | |
Frans Klaver | 59e931c4 | 2013-01-25 17:05:44 +0100 | [diff] [blame] | 41 | static int xsens_mt_probe(struct usb_serial *serial, |
| 42 | const struct usb_device_id *id) |
| 43 | { |
Frans Klaver | adceac1 | 2014-09-04 09:25:37 +0200 | [diff] [blame] | 44 | if (serial->interface->cur_altsetting->desc.bInterfaceNumber == 1) |
| 45 | return 0; |
| 46 | |
| 47 | return -ENODEV; |
Frans Klaver | 59e931c4 | 2013-01-25 17:05:44 +0100 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | static struct usb_serial_driver xsens_mt_device = { |
| 51 | .driver = { |
| 52 | .owner = THIS_MODULE, |
| 53 | .name = "xsens_mt", |
| 54 | }, |
| 55 | .id_table = id_table, |
| 56 | .num_ports = 1, |
| 57 | |
| 58 | .probe = xsens_mt_probe, |
| 59 | }; |
| 60 | |
| 61 | static struct usb_serial_driver * const serial_drivers[] = { |
| 62 | &xsens_mt_device, NULL |
| 63 | }; |
| 64 | |
| 65 | module_usb_serial_driver(serial_drivers, id_table); |
| 66 | |
Frans Klaver | 7c13325 | 2014-09-01 11:39:21 +0200 | [diff] [blame] | 67 | MODULE_AUTHOR("Frans Klaver <frans.klaver@xsens.com>"); |
| 68 | MODULE_DESCRIPTION("USB-serial driver for Xsens motion trackers"); |
Johan Hovold | 627cfa8 | 2017-11-03 18:12:08 +0100 | [diff] [blame] | 69 | MODULE_LICENSE("GPL v2"); |