xref: /openbmc/linux/drivers/usb/serial/xsens_mt.c (revision 627cfa89)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Xsens MT USB driver
4  *
5  * Copyright (C) 2013 Xsens <info@xsens.com>
6  */
7 
8 #include <linux/kernel.h>
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 
xsens_mt_probe(struct usb_serial * serial,const struct usb_device_id * id)41 static int xsens_mt_probe(struct usb_serial *serial,
42 					const struct usb_device_id *id)
43 {
44 	if (serial->interface->cur_altsetting->desc.bInterfaceNumber == 1)
45 		return 0;
46 
47 	return -ENODEV;
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 
67 MODULE_AUTHOR("Frans Klaver <frans.klaver@xsens.com>");
68 MODULE_DESCRIPTION("USB-serial driver for Xsens motion trackers");
69 MODULE_LICENSE("GPL v2");
70