1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * CAN driver for PEAK System PCAN-USB Pro adapter
4 * Derived from the PCAN project file driver/src/pcan_usbpro_fw.h
6 * Copyright (C) 2003-2011 PEAK System-Technik GmbH
10 #define PCAN_USB_PRO_H
13 * USB Vendor request data types
15 #define PCAN_USBPRO_REQ_INFO 0
16 #define PCAN_USBPRO_REQ_FCT 2
18 /* Vendor Request value for XXX_INFO */
19 #define PCAN_USBPRO_INFO_BL 0
20 #define PCAN_USBPRO_INFO_FW 1
22 /* PCAN-USB Pro (FD) Endpoints */
23 #define PCAN_USBPRO_EP_CMDOUT 1
24 #define PCAN_USBPRO_EP_CMDIN (PCAN_USBPRO_EP_CMDOUT | USB_DIR_IN)
25 #define PCAN_USBPRO_EP_MSGOUT_0 2
26 #define PCAN_USBPRO_EP_MSGIN (PCAN_USBPRO_EP_MSGOUT_0 | USB_DIR_IN)
27 #define PCAN_USBPRO_EP_MSGOUT_1 3
28 #define PCAN_USBPRO_EP_UNUSED (PCAN_USBPRO_EP_MSGOUT_1 | USB_DIR_IN)
30 /* Vendor Request value for XXX_FCT */
31 #define PCAN_USBPRO_FCT_DRVLD 5 /* tell device driver is loaded */
32 #define PCAN_USBPRO_FCT_DRVLD_REQ_LEN 16
34 /* PCAN_USBPRO_INFO_BL vendor request record type */
35 struct __packed pcan_usb_pro_blinfo {
48 /* PCAN_USBPRO_INFO_FW vendor request record type */
49 struct __packed pcan_usb_pro_fwinfo {
60 * USB Command record types
62 #define PCAN_USBPRO_SETBTR 0x02
63 #define PCAN_USBPRO_SETBUSACT 0x04
64 #define PCAN_USBPRO_SETSILENT 0x05
65 #define PCAN_USBPRO_SETDEVID 0x06
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
80 /* record structures */
81 struct __packed pcan_usb_pro_btr {
88 struct __packed pcan_usb_pro_busact {
94 struct __packed pcan_usb_pro_silent {
100 struct __packed pcan_usb_pro_filter {
106 struct __packed pcan_usb_pro_setts {
112 struct __packed pcan_usb_pro_devid {
119 #define PCAN_USBPRO_LED_DEVICE 0x00
120 #define PCAN_USBPRO_LED_BLINK_FAST 0x01
121 #define PCAN_USBPRO_LED_BLINK_SLOW 0x02
122 #define PCAN_USBPRO_LED_ON 0x03
123 #define PCAN_USBPRO_LED_OFF 0x04
125 struct __packed pcan_usb_pro_setled {
132 struct __packed pcan_usb_pro_rxmsg {
143 #define PCAN_USBPRO_STATUS_ERROR 0x0001
144 #define PCAN_USBPRO_STATUS_BUS 0x0002
145 #define PCAN_USBPRO_STATUS_OVERRUN 0x0004
146 #define PCAN_USBPRO_STATUS_QOVERRUN 0x0008
148 struct __packed pcan_usb_pro_rxstatus {
156 struct __packed pcan_usb_pro_rxts {
162 struct __packed pcan_usb_pro_txmsg {
171 union pcan_usb_pro_rec {
173 struct pcan_usb_pro_btr btr;
174 struct pcan_usb_pro_busact bus_act;
175 struct pcan_usb_pro_silent silent_mode;
176 struct pcan_usb_pro_filter filter_mode;
177 struct pcan_usb_pro_setts ts;
178 struct pcan_usb_pro_devid dev_id;
179 struct pcan_usb_pro_setled set_led;
180 struct pcan_usb_pro_rxmsg rx_msg;
181 struct pcan_usb_pro_rxstatus rx_status;
182 struct pcan_usb_pro_rxts rx_ts;
183 struct pcan_usb_pro_txmsg tx_msg;
186 int pcan_usb_pro_probe(struct usb_interface *intf);
187 int pcan_usb_pro_send_req(struct peak_usb_device *dev, int req_id,
188 int req_value, void *req_addr, int req_size);
189 void pcan_usb_pro_restart_complete(struct urb *urb);