linux/drivers/net/can/usb/peak_usb/pcan_usb_fd.c

// 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 <[email protected]>
 */
#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
#define PCAN_USBFD_CHANNEL_COUNT

/* PCAN-USB Pro FD adapter internal clock (Hz) */
#define PCAN_UFD_CRYSTAL_HZ

#define PCAN_UFD_CMD_BUFFER_SIZE
#define PCAN_UFD_LOSPD_PKT_SIZE

/* PCAN-USB Pro FD command timeout (ms.) */
#define PCAN_UFD_CMD_TIMEOUT_MS

/* PCAN-USB Pro FD rx/tx buffers size */
#define PCAN_UFD_RX_BUFFER_SIZE
#define PCAN_UFD_TX_BUFFER_SIZE

/* struct pcan_ufd_fw_info::type */
#define PCAN_USBFD_TYPE_STD
#define PCAN_USBFD_TYPE_EXT

/* read some versions info from the hw device */
struct __packed pcan_ufd_fw_info {};

/* handle device specific info used by the netdevices */
struct pcan_usb_fd_if {};

/* device information */
struct pcan_usb_fd_device {};

/* Extended USB commands (non uCAN commands) */

/* Clock Modes command */
#define PCAN_UFD_CMD_CLK_SET

#define PCAN_UFD_CLK_80MHZ
#define PCAN_UFD_CLK_60MHZ
#define PCAN_UFD_CLK_40MHZ
#define PCAN_UFD_CLK_30MHZ
#define PCAN_UFD_CLK_24MHZ
#define PCAN_UFD_CLK_20MHZ
#define PCAN_UFD_CLK_DEF

struct __packed pcan_ufd_clock {};

/* LED control command */
#define PCAN_UFD_CMD_LED_SET

#define PCAN_UFD_LED_DEV
#define PCAN_UFD_LED_FAST
#define PCAN_UFD_LED_SLOW
#define PCAN_UFD_LED_ON
#define PCAN_UFD_LED_OFF
#define PCAN_UFD_LED_DEF

struct __packed pcan_ufd_led {};

/* Extended usage of uCAN commands CMD_xxx_xx_OPTION for PCAN-USB Pro FD */
#define PCAN_UFD_FLTEXT_CALIBRATION

struct __packed pcan_ufd_options {};

/* Extended usage of uCAN messages for PCAN-USB Pro FD */
#define PCAN_UFD_MSG_CALIBRATION

struct __packed pcan_ufd_ts_msg {};

#define PCAN_UFD_MSG_OVERRUN

#define PCAN_UFD_OVMSG_CHANNEL(o)

struct __packed pcan_ufd_ovr_msg {};

#define PCAN_UFD_CMD_DEVID_SET

struct __packed pcan_ufd_device_id {};

static inline int pufd_omsg_get_channel(struct pcan_ufd_ovr_msg *om)
{}

/* Clock mode frequency values */
static const u32 pcan_usb_fd_clk_freq[6] =;

/* return a device USB interface */
static inline
struct pcan_usb_fd_if *pcan_usb_fd_dev_if(struct peak_usb_device *dev)
{}

/* return a device USB commands buffer */
static inline void *pcan_usb_fd_cmd_buffer(struct peak_usb_device *dev)
{}

/* send PCAN-USB Pro FD commands synchronously */
static int pcan_usb_fd_send_cmd(struct peak_usb_device *dev, void *cmd_tail)
{}

static int pcan_usb_fd_read_fwinfo(struct peak_usb_device *dev,
				   struct pcan_ufd_fw_info *fw_info)
{}

/* build the commands list in the given buffer, to enter operational mode */
static int pcan_usb_fd_build_restart_cmd(struct peak_usb_device *dev, u8 *buf)
{}

/* set CAN bus on/off */
static int pcan_usb_fd_set_bus(struct peak_usb_device *dev, u8 onoff)
{}

/* set filtering masks:
 *
 *	idx  in range [0..63] selects a row #idx, all rows otherwise
 *	mask in range [0..0xffffffff] defines up to 32 CANIDs in the row(s)
 *
 *	Each bit of this 64 x 32 bits array defines a CANID value:
 *
 *	bit[i,j] = 1 implies that CANID=(i x 32)+j will be received, while
 *	bit[i,j] = 0 implies that CANID=(i x 32)+j will be discarded.
 */
static int pcan_usb_fd_set_filter_std(struct peak_usb_device *dev, int idx,
				      u32 mask)
{}

/* set/unset options
 *
 *	onoff	set(1)/unset(0) options
 *	mask	each bit defines a kind of options to set/unset
 */
static int pcan_usb_fd_set_options(struct peak_usb_device *dev,
				   bool onoff, u16 ucan_mask, u16 usb_mask)
{}

/* setup LED control */
static int pcan_usb_fd_set_can_led(struct peak_usb_device *dev, u8 led_mode)
{}

/* set CAN clock domain */
static int pcan_usb_fd_set_clock_domain(struct peak_usb_device *dev,
					u8 clk_mode)
{}

/* set bittiming for CAN and CAN-FD header */
static int pcan_usb_fd_set_bittiming_slow(struct peak_usb_device *dev,
					  struct can_bittiming *bt)
{}

/* set CAN-FD bittiming for data */
static int pcan_usb_fd_set_bittiming_fast(struct peak_usb_device *dev,
					  struct can_bittiming *bt)
{}

/* read user CAN channel id from device */
static int pcan_usb_fd_get_can_channel_id(struct peak_usb_device *dev,
					  u32 *can_ch_id)
{}

/* set a new CAN channel id in the flash memory of the device */
static int pcan_usb_fd_set_can_channel_id(struct peak_usb_device *dev, u32 can_ch_id)
{}

/* handle restart but in asynchronously way
 * (uses PCAN-USB Pro code to complete asynchronous request)
 */
static int pcan_usb_fd_restart_async(struct peak_usb_device *dev,
				     struct urb *urb, u8 *buf)
{}

static int pcan_usb_fd_drv_loaded(struct peak_usb_device *dev, bool loaded)
{}

static int pcan_usb_fd_decode_canmsg(struct pcan_usb_fd_if *usb_if,
				     struct pucan_msg *rx_msg)
{}

/* handle uCAN status message */
static int pcan_usb_fd_decode_status(struct pcan_usb_fd_if *usb_if,
				     struct pucan_msg *rx_msg)
{}

/* handle uCAN error message */
static int pcan_usb_fd_decode_error(struct pcan_usb_fd_if *usb_if,
				    struct pucan_msg *rx_msg)
{}

/* handle uCAN overrun message */
static int pcan_usb_fd_decode_overrun(struct pcan_usb_fd_if *usb_if,
				      struct pucan_msg *rx_msg)
{}

/* handle USB calibration message */
static void pcan_usb_fd_decode_ts(struct pcan_usb_fd_if *usb_if,
				  struct pucan_msg *rx_msg)
{}

/* callback for bulk IN urb */
static int pcan_usb_fd_decode_buf(struct peak_usb_device *dev, struct urb *urb)
{}

/* CAN/CANFD frames encoding callback */
static int pcan_usb_fd_encode_msg(struct peak_usb_device *dev,
				  struct sk_buff *skb, u8 *obuf, size_t *size)
{}

/* start the interface (last chance before set bus on) */
static int pcan_usb_fd_start(struct peak_usb_device *dev)
{}

/* socket callback used to copy berr counters values received through USB */
static int pcan_usb_fd_get_berr_counter(const struct net_device *netdev,
					struct can_berr_counter *bec)
{}

/* probe function for all PCAN-USB FD family usb interfaces */
static int pcan_usb_fd_probe(struct usb_interface *intf)
{}

/* stop interface (last chance before set bus off) */
static int pcan_usb_fd_stop(struct peak_usb_device *dev)
{}

/* called when probing, to initialize a device object */
static int pcan_usb_fd_init(struct peak_usb_device *dev)
{}

/* called when driver module is being unloaded */
static void pcan_usb_fd_exit(struct peak_usb_device *dev)
{}

/* called when the USB adapter is unplugged */
static void pcan_usb_fd_free(struct peak_usb_device *dev)
{}

/* blink LED's */
static int pcan_usb_fd_set_phys_id(struct net_device *netdev,
				   enum ethtool_phys_id_state state)
{}

static const struct ethtool_ops pcan_usb_fd_ethtool_ops =;

/* describes the PCAN-USB FD adapter */
static const struct can_bittiming_const pcan_usb_fd_const =;

static const struct can_bittiming_const pcan_usb_fd_data_const =;

const struct peak_usb_adapter pcan_usb_fd =;

/* describes the PCAN-CHIP USB */
static const struct can_bittiming_const pcan_usb_chip_const =;

static const struct can_bittiming_const pcan_usb_chip_data_const =;

const struct peak_usb_adapter pcan_usb_chip =;

/* describes the PCAN-USB Pro FD adapter */
static const struct can_bittiming_const pcan_usb_pro_fd_const =;

static const struct can_bittiming_const pcan_usb_pro_fd_data_const =;

const struct peak_usb_adapter pcan_usb_pro_fd =;

/* describes the PCAN-USB X6 adapter */
static const struct can_bittiming_const pcan_usb_x6_const =;

static const struct can_bittiming_const pcan_usb_x6_data_const =;

const struct peak_usb_adapter pcan_usb_x6 =;