// SPDX-License-Identifier: GPL-2.0-only/* * CAN driver for PEAK System PCAN-USB FD / PCAN-USB Pro FD adapter * * Copyright (C) 2013-2014 Stephane Grosjean <s.grosjean@peak-system.com> */#include<linux/ethtool.h>#include<linux/module.h>#include<linux/netdevice.h>#include<linux/usb.h>#include<linux/can.h>#include<linux/can/dev.h>#include<linux/can/error.h>#include<linux/can/dev/peak_canfd.h>#include"pcan_usb_core.h"#include"pcan_usb_pro.h"#define PCAN_USBPROFD_CHANNEL_COUNT 2#define PCAN_USBFD_CHANNEL_COUNT 1/* PCAN-USB Pro FD adapter internal clock (Hz) */#define PCAN_UFD_CRYSTAL_HZ 80000000#define PCAN_UFD_CMD_BUFFER_SIZE 512#define PCAN_UFD_LOSPD_PKT_SIZE 64/* PCAN-USB Pro FD command timeout (ms.) */#define PCAN_UFD_CMD_TIMEOUT_MS 1000/* PCAN-USB Pro FD rx/tx buffers size */#define PCAN_UFD_RX_BUFFER_SIZE 2048#define PCAN_UFD_TX_BUFFER_SIZE 512/* struct pcan_ufd_fw_info::type */#define PCAN_USBFD_TYPE_STD 1#define PCAN_USBFD_TYPE_EXT 2 /* includes EP numbers *//* read some versions info from the hw device */struct__packedpcan_ufd_fw_info{__le16size_of;/* sizeof this */__le16type;/* type of this structure */u8hw_type;/* Type of hardware (HW_TYPE_xxx) */u8bl_version[3];/* Bootloader version */u8hw_version;/* Hardware version (PCB) */u8fw_version[3];/* Firmware version */__le32dev_id[2];/* "device id" per CAN */__le32ser_no;/* S/N */__le32flags;/* special functions *//* extended data when type == PCAN_USBFD_TYPE_EXT */u8cmd_out_ep;/* ep for cmd */u8cmd_in_ep;/* ep for replies */u8data_out_ep[2];/* ep for CANx TX */u8data_in_ep;/* ep for CAN RX */u8dummy[3];};/* handle device specific info used by the netdevices */structpcan_usb_fd_if{structpeak_usb_device*dev[PCAN_USB_MAX_CHANNEL];structpcan_ufd_fw_infofw_info;structpeak_time_reftime_ref;intcm_ignore_count;intdev_opened_count;};/* device information */structpcan_usb_fd_device{structpeak_usb_devicedev;structcan_berr_counterbec;structpcan_usb_fd_if*usb_if;u8*cmd_buffer_addr;};/* Extended USB commands (non uCAN commands) *//* Clock Modes command */#define PCAN_UFD_CMD_CLK_SET 0x80#define PCAN_UFD_CLK_80MHZ 0x0#define PCAN_UFD_CLK_60MHZ 0x1