brintos

brintos / linux-shallow public Read only

0
0
Text · 4.1 KiB · 28e740a Raw
192 lines · c
1/* SPDX-License-Identifier: GPL-2.0-only */2/*3 * CAN driver for PEAK System PCAN-USB Pro adapter4 * Derived from the PCAN project file driver/src/pcan_usbpro_fw.h5 *6 * Copyright (C) 2003-2011 PEAK System-Technik GmbH7 * Copyright (C) 2011-2012 Stephane Grosjean <s.grosjean@peak-system.com>8 */9#ifndef PCAN_USB_PRO_H10#define PCAN_USB_PRO_H11 12/*13 * USB Vendor request data types14 */15#define PCAN_USBPRO_REQ_INFO		016#define PCAN_USBPRO_REQ_FCT		217 18/* Vendor Request value for XXX_INFO */19#define PCAN_USBPRO_INFO_BL		020#define PCAN_USBPRO_INFO_FW		121 22/* PCAN-USB Pro (FD) Endpoints */23#define PCAN_USBPRO_EP_CMDOUT		124#define PCAN_USBPRO_EP_CMDIN		(PCAN_USBPRO_EP_CMDOUT | USB_DIR_IN)25#define PCAN_USBPRO_EP_MSGOUT_0		226#define PCAN_USBPRO_EP_MSGIN		(PCAN_USBPRO_EP_MSGOUT_0 | USB_DIR_IN)27#define PCAN_USBPRO_EP_MSGOUT_1		328#define PCAN_USBPRO_EP_UNUSED		(PCAN_USBPRO_EP_MSGOUT_1 | USB_DIR_IN)29 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	1633 34/* PCAN_USBPRO_INFO_BL vendor request record type */35struct __packed pcan_usb_pro_blinfo {36	__le32 ctrl_type;37	u8 version[4];38	u8 day;39	u8 month;40	u8 year;41	u8 dummy;42	__le32 serial_num_hi;43	__le32 serial_num_lo;44	__le32 hw_type;45	__le32 hw_rev;46};47 48/* PCAN_USBPRO_INFO_FW vendor request record type */49struct __packed pcan_usb_pro_fwinfo {50	__le32 ctrl_type;51	u8 version[4];52	u8 day;53	u8 month;54	u8 year;55	u8 dummy;56	__le32 fw_type;57};58 59/*60 * USB Command record types61 */62#define PCAN_USBPRO_SETBTR	0x0263#define PCAN_USBPRO_SETBUSACT	0x0464#define PCAN_USBPRO_SETSILENT	0x0565#define PCAN_USBPRO_SETDEVID	0x0666#define PCAN_USBPRO_SETFILTR	0x0a67#define PCAN_USBPRO_SETTS	0x1068#define PCAN_USBPRO_GETDEVID	0x1269#define PCAN_USBPRO_SETLED	0x1C70#define PCAN_USBPRO_RXMSG8	0x8071#define PCAN_USBPRO_RXMSG4	0x8172#define PCAN_USBPRO_RXMSG0	0x8273#define PCAN_USBPRO_RXRTR	0x8374#define PCAN_USBPRO_RXSTATUS	0x8475#define PCAN_USBPRO_RXTS	0x8576#define PCAN_USBPRO_TXMSG8	0x4177#define PCAN_USBPRO_TXMSG4	0x4278#define PCAN_USBPRO_TXMSG0	0x4379 80/* record structures */81struct __packed pcan_usb_pro_btr {82	u8 data_type;83	u8 channel;84	__le16 dummy;85	__le32 CCBT;86};87 88struct __packed pcan_usb_pro_busact {89	u8 data_type;90	u8 channel;91	__le16 onoff;92};93 94struct __packed pcan_usb_pro_silent {95	u8 data_type;96	u8 channel;97	__le16 onoff;98};99 100struct __packed pcan_usb_pro_filter {101	u8 data_type;102	u8 dummy;103	__le16 filter_mode;104};105 106struct __packed pcan_usb_pro_setts {107	u8 data_type;108	u8 dummy;109	__le16 mode;110};111 112struct __packed pcan_usb_pro_devid {113	u8 data_type;114	u8 channel;115	__le16 dummy;116	__le32 dev_num;117};118 119#define PCAN_USBPRO_LED_DEVICE		0x00120#define PCAN_USBPRO_LED_BLINK_FAST	0x01121#define PCAN_USBPRO_LED_BLINK_SLOW	0x02122#define PCAN_USBPRO_LED_ON		0x03123#define PCAN_USBPRO_LED_OFF		0x04124 125struct __packed pcan_usb_pro_setled {126	u8 data_type;127	u8 channel;128	__le16 mode;129	__le32 timeout;130};131 132struct __packed pcan_usb_pro_rxmsg {133	u8 data_type;134	u8 client;135	u8 flags;136	u8 len;137	__le32 ts32;138	__le32 id;139 140	u8 data[8];141};142 143#define PCAN_USBPRO_STATUS_ERROR	0x0001144#define PCAN_USBPRO_STATUS_BUS		0x0002145#define PCAN_USBPRO_STATUS_OVERRUN	0x0004146#define PCAN_USBPRO_STATUS_QOVERRUN	0x0008147 148struct __packed pcan_usb_pro_rxstatus {149	u8 data_type;150	u8 channel;151	__le16 status;152	__le32 ts32;153	__le32 err_frm;154};155 156struct __packed pcan_usb_pro_rxts {157	u8 data_type;158	u8 dummy[3];159	__le32 ts64[2];160};161 162struct __packed pcan_usb_pro_txmsg {163	u8 data_type;164	u8 client;165	u8 flags;166	u8 len;167	__le32 id;168	u8 data[8];169};170 171union pcan_usb_pro_rec {172	u8				data_type;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;184};185 186int pcan_usb_pro_probe(struct usb_interface *intf);187int pcan_usb_pro_send_req(struct peak_usb_device *dev, int req_id,188			  int req_value, void *req_addr, int req_size);189void pcan_usb_pro_restart_complete(struct urb *urb);190 191#endif192