18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Xsens MT USB driver 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2013 Xsens <info@xsens.com> 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#include <linux/kernel.h> 98c2ecf20Sopenharmony_ci#include <linux/tty.h> 108c2ecf20Sopenharmony_ci#include <linux/module.h> 118c2ecf20Sopenharmony_ci#include <linux/usb.h> 128c2ecf20Sopenharmony_ci#include <linux/usb/serial.h> 138c2ecf20Sopenharmony_ci#include <linux/uaccess.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#define XSENS_VID 0x2639 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#define MTi_10_IMU_PID 0x0001 188c2ecf20Sopenharmony_ci#define MTi_20_VRU_PID 0x0002 198c2ecf20Sopenharmony_ci#define MTi_30_AHRS_PID 0x0003 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#define MTi_100_IMU_PID 0x0011 228c2ecf20Sopenharmony_ci#define MTi_200_VRU_PID 0x0012 238c2ecf20Sopenharmony_ci#define MTi_300_AHRS_PID 0x0013 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci#define MTi_G_700_GPS_INS_PID 0x0017 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_cistatic const struct usb_device_id id_table[] = { 288c2ecf20Sopenharmony_ci { USB_DEVICE(XSENS_VID, MTi_10_IMU_PID) }, 298c2ecf20Sopenharmony_ci { USB_DEVICE(XSENS_VID, MTi_20_VRU_PID) }, 308c2ecf20Sopenharmony_ci { USB_DEVICE(XSENS_VID, MTi_30_AHRS_PID) }, 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci { USB_DEVICE(XSENS_VID, MTi_100_IMU_PID) }, 338c2ecf20Sopenharmony_ci { USB_DEVICE(XSENS_VID, MTi_200_VRU_PID) }, 348c2ecf20Sopenharmony_ci { USB_DEVICE(XSENS_VID, MTi_300_AHRS_PID) }, 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci { USB_DEVICE(XSENS_VID, MTi_G_700_GPS_INS_PID) }, 378c2ecf20Sopenharmony_ci { }, 388c2ecf20Sopenharmony_ci}; 398c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(usb, id_table); 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_cistatic int xsens_mt_probe(struct usb_serial *serial, 428c2ecf20Sopenharmony_ci const struct usb_device_id *id) 438c2ecf20Sopenharmony_ci{ 448c2ecf20Sopenharmony_ci if (serial->interface->cur_altsetting->desc.bInterfaceNumber == 1) 458c2ecf20Sopenharmony_ci return 0; 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci return -ENODEV; 488c2ecf20Sopenharmony_ci} 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_cistatic struct usb_serial_driver xsens_mt_device = { 518c2ecf20Sopenharmony_ci .driver = { 528c2ecf20Sopenharmony_ci .owner = THIS_MODULE, 538c2ecf20Sopenharmony_ci .name = "xsens_mt", 548c2ecf20Sopenharmony_ci }, 558c2ecf20Sopenharmony_ci .id_table = id_table, 568c2ecf20Sopenharmony_ci .num_ports = 1, 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci .probe = xsens_mt_probe, 598c2ecf20Sopenharmony_ci}; 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_cistatic struct usb_serial_driver * const serial_drivers[] = { 628c2ecf20Sopenharmony_ci &xsens_mt_device, NULL 638c2ecf20Sopenharmony_ci}; 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_cimodule_usb_serial_driver(serial_drivers, id_table); 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ciMODULE_AUTHOR("Frans Klaver <frans.klaver@xsens.com>"); 688c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("USB-serial driver for Xsens motion trackers"); 698c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL v2"); 70