xsens_mt.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Xsens MT USB driver
  4. *
  5. * Copyright (C) 2013 Xsens <info@xsens.com>
  6. */
  7. #include <linux/kernel.h>
  8. #include <linux/tty.h>
  9. #include <linux/module.h>
  10. #include <linux/usb.h>
  11. #include <linux/usb/serial.h>
  12. #include <linux/uaccess.h>
  13. #define XSENS_VID 0x2639
  14. #define MTi_10_IMU_PID 0x0001
  15. #define MTi_20_VRU_PID 0x0002
  16. #define MTi_30_AHRS_PID 0x0003
  17. #define MTi_100_IMU_PID 0x0011
  18. #define MTi_200_VRU_PID 0x0012
  19. #define MTi_300_AHRS_PID 0x0013
  20. #define MTi_G_700_GPS_INS_PID 0x0017
  21. static const struct usb_device_id id_table[] = {
  22. { USB_DEVICE(XSENS_VID, MTi_10_IMU_PID) },
  23. { USB_DEVICE(XSENS_VID, MTi_20_VRU_PID) },
  24. { USB_DEVICE(XSENS_VID, MTi_30_AHRS_PID) },
  25. { USB_DEVICE(XSENS_VID, MTi_100_IMU_PID) },
  26. { USB_DEVICE(XSENS_VID, MTi_200_VRU_PID) },
  27. { USB_DEVICE(XSENS_VID, MTi_300_AHRS_PID) },
  28. { USB_DEVICE(XSENS_VID, MTi_G_700_GPS_INS_PID) },
  29. { },
  30. };
  31. MODULE_DEVICE_TABLE(usb, id_table);
  32. static int xsens_mt_probe(struct usb_serial *serial,
  33. const struct usb_device_id *id)
  34. {
  35. if (serial->interface->cur_altsetting->desc.bInterfaceNumber == 1)
  36. return 0;
  37. return -ENODEV;
  38. }
  39. static struct usb_serial_driver xsens_mt_device = {
  40. .driver = {
  41. .name = "xsens_mt",
  42. },
  43. .id_table = id_table,
  44. .num_ports = 1,
  45. .probe = xsens_mt_probe,
  46. };
  47. static struct usb_serial_driver * const serial_drivers[] = {
  48. &xsens_mt_device, NULL
  49. };
  50. module_usb_serial_driver(serial_drivers, id_table);
  51. MODULE_AUTHOR("Frans Klaver <frans.klaver@xsens.com>");
  52. MODULE_DESCRIPTION("USB-serial driver for Xsens motion trackers");
  53. MODULE_LICENSE("GPL v2");