linux/drivers/net/can/usb/ems_usb.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * CAN driver for EMS Dr. Thomas Wuensche CPC-USB/ARM7
 *
 * Copyright (C) 2004-2009 EMS Dr. Thomas Wuensche
 */
#include <linux/ethtool.h>
#include <linux/signal.h>
#include <linux/slab.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>

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();

/* Control-Values for CPC_Control() Command Subject Selection */
#define CONTR_CAN_MESSAGE
#define CONTR_CAN_STATE
#define CONTR_BUS_ERROR

/* Control Command Actions */
#define CONTR_CONT_OFF
#define CONTR_CONT_ON
#define CONTR_ONCE

/* Messages from CPC to PC */
#define CPC_MSG_TYPE_CAN_FRAME
#define CPC_MSG_TYPE_RTR_FRAME
#define CPC_MSG_TYPE_CAN_PARAMS
#define CPC_MSG_TYPE_CAN_STATE
#define CPC_MSG_TYPE_EXT_CAN_FRAME
#define CPC_MSG_TYPE_EXT_RTR_FRAME
#define CPC_MSG_TYPE_CONTROL
#define CPC_MSG_TYPE_CONFIRM
#define CPC_MSG_TYPE_OVERRUN
#define CPC_MSG_TYPE_CAN_FRAME_ERROR
#define CPC_MSG_TYPE_ERR_COUNTER

/* Messages from the PC to the CPC interface  */
#define CPC_CMD_TYPE_CAN_FRAME
#define CPC_CMD_TYPE_CONTROL
#define CPC_CMD_TYPE_CAN_PARAMS
#define CPC_CMD_TYPE_RTR_FRAME
#define CPC_CMD_TYPE_CAN_STATE
#define CPC_CMD_TYPE_EXT_CAN_FRAME
#define CPC_CMD_TYPE_EXT_RTR_FRAME
#define CPC_CMD_TYPE_CAN_EXIT

#define CPC_CMD_TYPE_INQ_ERR_COUNTER
#define CPC_CMD_TYPE_CLEAR_MSG_QUEUE
#define CPC_CMD_TYPE_CLEAR_CMD_QUEUE

#define CPC_CC_TYPE_SJA1000

#define CPC_CAN_ECODE_ERRFRAME

/* Overrun types */
#define CPC_OVR_EVENT_CAN
#define CPC_OVR_EVENT_CANSTATE
#define CPC_OVR_EVENT_BUSERROR

/*
 * If the CAN controller lost a message we indicate it with the highest bit
 * set in the count field.
 */
#define CPC_OVR_HW

/* Size of the "struct ems_cpc_msg" without the union */
#define CPC_MSG_HEADER_LEN
#define CPC_CAN_MSG_MIN_SIZE

/* Define these values to match your devices */
#define USB_CPCUSB_VENDOR_ID

#define USB_CPCUSB_ARM7_PRODUCT_ID

/* Mode register NXP LPC2119/SJA1000 CAN Controller */
#define SJA1000_MOD_NORMAL
#define SJA1000_MOD_RM

/* ECC register NXP LPC2119/SJA1000 CAN Controller */
#define SJA1000_ECC_SEG
#define SJA1000_ECC_DIR
#define SJA1000_ECC_ERR
#define SJA1000_ECC_BIT
#define SJA1000_ECC_FORM
#define SJA1000_ECC_STUFF
#define SJA1000_ECC_MASK

/* Status register content */
#define SJA1000_SR_BS
#define SJA1000_SR_ES

#define SJA1000_DEFAULT_OUTPUT_CONTROL

/*
 * The device actually uses a 16MHz clock to generate the CAN clock
 * but it expects SJA1000 bit settings based on 8MHz (is internally
 * converted).
 */
#define EMS_USB_ARM7_CLOCK

#define CPC_TX_QUEUE_TRIGGER_LOW
#define CPC_TX_QUEUE_TRIGGER_HIGH

/*
 * CAN-Message representation in a CPC_MSG. Message object type is
 * CPC_MSG_TYPE_CAN_FRAME or CPC_MSG_TYPE_RTR_FRAME or
 * CPC_MSG_TYPE_EXT_CAN_FRAME or CPC_MSG_TYPE_EXT_RTR_FRAME.
 */
struct cpc_can_msg {};

/* Representation of the CAN parameters for the SJA1000 controller */
struct cpc_sja1000_params {};

/* CAN params message representation */
struct cpc_can_params {};

/* Structure for confirmed message handling */
struct cpc_confirm {};

/* Structure for overrun conditions */
struct cpc_overrun {};

/* SJA1000 CAN errors (compatible to NXP LPC2119) */
struct cpc_sja1000_can_error {};

/* structure for CAN error conditions */
struct cpc_can_error {};

/*
 * Structure containing RX/TX error counter. This structure is used to request
 * the values of the CAN controllers TX and RX error counter.
 */
struct cpc_can_err_counter {};

/* Main message type used between library and application */
struct __packed ems_cpc_msg {};

/*
 * Table of devices that work with this driver
 * NOTE: This driver supports only CPC-USB/ARM7 (LPC2119) yet.
 */
static struct usb_device_id ems_usb_table[] =;

MODULE_DEVICE_TABLE(usb, ems_usb_table);

#define RX_BUFFER_SIZE
#define CPC_HEADER_SIZE
#define INTR_IN_BUFFER_SIZE

#define MAX_RX_URBS
#define MAX_TX_URBS

struct ems_usb;

struct ems_tx_urb_context {};

struct ems_usb {};

static void ems_usb_read_interrupt_callback(struct urb *urb)
{}

static void ems_usb_rx_can_msg(struct ems_usb *dev, struct ems_cpc_msg *msg)
{}

static void ems_usb_rx_err(struct ems_usb *dev, struct ems_cpc_msg *msg)
{}

/*
 * callback for bulk IN urb
 */
static void ems_usb_read_bulk_callback(struct urb *urb)
{}

/*
 * callback for bulk IN urb
 */
static void ems_usb_write_bulk_callback(struct urb *urb)
{}

/*
 * Send the given CPC command synchronously
 */
static int ems_usb_command_msg(struct ems_usb *dev, struct ems_cpc_msg *msg)
{}

/*
 * Change CAN controllers' mode register
 */
static int ems_usb_write_mode(struct ems_usb *dev, u8 mode)
{}

/*
 * Send a CPC_Control command to change behaviour when interface receives a CAN
 * message, bus error or CAN state changed notifications.
 */
static int ems_usb_control_cmd(struct ems_usb *dev, u8 val)
{}

/*
 * Start interface
 */
static int ems_usb_start(struct ems_usb *dev)
{}

static void unlink_all_urbs(struct ems_usb *dev)
{}

static int ems_usb_open(struct net_device *netdev)
{}

static netdev_tx_t ems_usb_start_xmit(struct sk_buff *skb, struct net_device *netdev)
{}

static int ems_usb_close(struct net_device *netdev)
{}

static const struct net_device_ops ems_usb_netdev_ops =;

static const struct ethtool_ops ems_usb_ethtool_ops =;

static const struct can_bittiming_const ems_usb_bittiming_const =;

static int ems_usb_set_mode(struct net_device *netdev, enum can_mode mode)
{}

static int ems_usb_set_bittiming(struct net_device *netdev)
{}

static void init_params_sja1000(struct ems_cpc_msg *msg)
{}

/*
 * probe function for new CPC-USB devices
 */
static int ems_usb_probe(struct usb_interface *intf,
			 const struct usb_device_id *id)
{}

/*
 * called by the usb core when the device is removed from the system
 */
static void ems_usb_disconnect(struct usb_interface *intf)
{}

/* usb specific object needed to register this driver with the usb subsystem */
static struct usb_driver ems_usb_driver =;

module_usb_driver();