pcan_usb_pro.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /*
  2. * CAN driver for PEAK System PCAN-USB Pro adapter
  3. * Derived from the PCAN project file driver/src/pcan_usbpro_fw.h
  4. *
  5. * Copyright (C) 2003-2011 PEAK System-Technik GmbH
  6. * Copyright (C) 2011-2012 Stephane Grosjean <s.grosjean@peak-system.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published
  10. * by the Free Software Foundation; version 2 of the License.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. */
  17. #ifndef PCAN_USB_PRO_H
  18. #define PCAN_USB_PRO_H
  19. /*
  20. * USB Vendor request data types
  21. */
  22. #define PCAN_USBPRO_REQ_INFO 0
  23. #define PCAN_USBPRO_REQ_FCT 2
  24. /* Vendor Request value for XXX_INFO */
  25. #define PCAN_USBPRO_INFO_BL 0
  26. #define PCAN_USBPRO_INFO_FW 1
  27. /* PCAN-USB Pro (FD) Endpoints */
  28. #define PCAN_USBPRO_EP_CMDOUT 1
  29. #define PCAN_USBPRO_EP_CMDIN (PCAN_USBPRO_EP_CMDOUT | USB_DIR_IN)
  30. #define PCAN_USBPRO_EP_MSGOUT_0 2
  31. #define PCAN_USBPRO_EP_MSGIN (PCAN_USBPRO_EP_MSGOUT_0 | USB_DIR_IN)
  32. #define PCAN_USBPRO_EP_MSGOUT_1 3
  33. #define PCAN_USBPRO_EP_UNUSED (PCAN_USBPRO_EP_MSGOUT_1 | USB_DIR_IN)
  34. /* Vendor Request value for XXX_FCT */
  35. #define PCAN_USBPRO_FCT_DRVLD 5 /* tell device driver is loaded */
  36. #define PCAN_USBPRO_FCT_DRVLD_REQ_LEN 16
  37. /* PCAN_USBPRO_INFO_BL vendor request record type */
  38. struct __packed pcan_usb_pro_blinfo {
  39. __le32 ctrl_type;
  40. u8 version[4];
  41. u8 day;
  42. u8 month;
  43. u8 year;
  44. u8 dummy;
  45. __le32 serial_num_hi;
  46. __le32 serial_num_lo;
  47. __le32 hw_type;
  48. __le32 hw_rev;
  49. };
  50. /* PCAN_USBPRO_INFO_FW vendor request record type */
  51. struct __packed pcan_usb_pro_fwinfo {
  52. __le32 ctrl_type;
  53. u8 version[4];
  54. u8 day;
  55. u8 month;
  56. u8 year;
  57. u8 dummy;
  58. __le32 fw_type;
  59. };
  60. /*
  61. * USB Command record types
  62. */
  63. #define PCAN_USBPRO_SETBTR 0x02
  64. #define PCAN_USBPRO_SETBUSACT 0x04
  65. #define PCAN_USBPRO_SETSILENT 0x05
  66. #define PCAN_USBPRO_SETFILTR 0x0a
  67. #define PCAN_USBPRO_SETTS 0x10
  68. #define PCAN_USBPRO_GETDEVID 0x12
  69. #define PCAN_USBPRO_SETLED 0x1C
  70. #define PCAN_USBPRO_RXMSG8 0x80
  71. #define PCAN_USBPRO_RXMSG4 0x81
  72. #define PCAN_USBPRO_RXMSG0 0x82
  73. #define PCAN_USBPRO_RXRTR 0x83
  74. #define PCAN_USBPRO_RXSTATUS 0x84
  75. #define PCAN_USBPRO_RXTS 0x85
  76. #define PCAN_USBPRO_TXMSG8 0x41
  77. #define PCAN_USBPRO_TXMSG4 0x42
  78. #define PCAN_USBPRO_TXMSG0 0x43
  79. /* record structures */
  80. struct __packed pcan_usb_pro_btr {
  81. u8 data_type;
  82. u8 channel;
  83. __le16 dummy;
  84. __le32 CCBT;
  85. };
  86. struct __packed pcan_usb_pro_busact {
  87. u8 data_type;
  88. u8 channel;
  89. __le16 onoff;
  90. };
  91. struct __packed pcan_usb_pro_silent {
  92. u8 data_type;
  93. u8 channel;
  94. __le16 onoff;
  95. };
  96. struct __packed pcan_usb_pro_filter {
  97. u8 data_type;
  98. u8 dummy;
  99. __le16 filter_mode;
  100. };
  101. struct __packed pcan_usb_pro_setts {
  102. u8 data_type;
  103. u8 dummy;
  104. __le16 mode;
  105. };
  106. struct __packed pcan_usb_pro_devid {
  107. u8 data_type;
  108. u8 channel;
  109. __le16 dummy;
  110. __le32 serial_num;
  111. };
  112. struct __packed pcan_usb_pro_setled {
  113. u8 data_type;
  114. u8 channel;
  115. __le16 mode;
  116. __le32 timeout;
  117. };
  118. struct __packed pcan_usb_pro_rxmsg {
  119. u8 data_type;
  120. u8 client;
  121. u8 flags;
  122. u8 len;
  123. __le32 ts32;
  124. __le32 id;
  125. u8 data[8];
  126. };
  127. #define PCAN_USBPRO_STATUS_ERROR 0x0001
  128. #define PCAN_USBPRO_STATUS_BUS 0x0002
  129. #define PCAN_USBPRO_STATUS_OVERRUN 0x0004
  130. #define PCAN_USBPRO_STATUS_QOVERRUN 0x0008
  131. struct __packed pcan_usb_pro_rxstatus {
  132. u8 data_type;
  133. u8 channel;
  134. __le16 status;
  135. __le32 ts32;
  136. __le32 err_frm;
  137. };
  138. struct __packed pcan_usb_pro_rxts {
  139. u8 data_type;
  140. u8 dummy[3];
  141. __le32 ts64[2];
  142. };
  143. struct __packed pcan_usb_pro_txmsg {
  144. u8 data_type;
  145. u8 client;
  146. u8 flags;
  147. u8 len;
  148. __le32 id;
  149. u8 data[8];
  150. };
  151. union pcan_usb_pro_rec {
  152. u8 data_type;
  153. struct pcan_usb_pro_btr btr;
  154. struct pcan_usb_pro_busact bus_act;
  155. struct pcan_usb_pro_silent silent_mode;
  156. struct pcan_usb_pro_filter filter_mode;
  157. struct pcan_usb_pro_setts ts;
  158. struct pcan_usb_pro_devid dev_id;
  159. struct pcan_usb_pro_setled set_led;
  160. struct pcan_usb_pro_rxmsg rx_msg;
  161. struct pcan_usb_pro_rxstatus rx_status;
  162. struct pcan_usb_pro_rxts rx_ts;
  163. struct pcan_usb_pro_txmsg tx_msg;
  164. };
  165. int pcan_usb_pro_probe(struct usb_interface *intf);
  166. int pcan_usb_pro_send_req(struct peak_usb_device *dev, int req_id,
  167. int req_value, void *req_addr, int req_size);
  168. void pcan_usb_pro_restart_complete(struct urb *urb);
  169. #endif