linux/drivers/net/can/usb/kvaser_usb/kvaser_usb.h

/* SPDX-License-Identifier: GPL-2.0 */
/* Parts of this driver are based on the following:
 *  - Kvaser linux leaf driver (version 4.78)
 *  - CAN driver for esd CAN-USB/2
 *  - Kvaser linux usbcanII driver (version 5.3)
 *  - Kvaser linux mhydra driver (version 5.24)
 *
 * Copyright (C) 2002-2018 KVASER AB, Sweden. All rights reserved.
 * Copyright (C) 2010 Matthias Fuchs <[email protected]>, esd gmbh
 * Copyright (C) 2012 Olivier Sobrie <[email protected]>
 * Copyright (C) 2015 Valeo S.A.
 */

#ifndef KVASER_USB_H
#define KVASER_USB_H

/* Kvaser USB CAN dongles are divided into three major platforms:
 * - Hydra: Running firmware labeled as 'mhydra'
 * - Leaf: Based on Renesas M32C or Freescale i.MX28, running firmware labeled
 *         as 'filo'
 * - UsbcanII: Based on Renesas M16C, running firmware labeled as 'helios'
 */

#include <linux/completion.h>
#include <linux/spinlock.h>
#include <linux/types.h>
#include <linux/usb.h>

#include <linux/can.h>
#include <linux/can/dev.h>

#define KVASER_USB_MAX_RX_URBS
#define KVASER_USB_MAX_TX_URBS
#define KVASER_USB_TIMEOUT
#define KVASER_USB_RX_BUFFER_SIZE
#define KVASER_USB_MAX_NET_DEVICES

/* Kvaser USB device quirks */
#define KVASER_USB_QUIRK_HAS_SILENT_MODE
#define KVASER_USB_QUIRK_HAS_TXRX_ERRORS
#define KVASER_USB_QUIRK_IGNORE_CLK_FREQ
#define KVASER_USB_QUIRK_HAS_HARDWARE_TIMESTAMP

/* Device capabilities */
#define KVASER_USB_CAP_BERR_CAP
#define KVASER_USB_CAP_EXT_CAP
#define KVASER_USB_HYDRA_CAP_EXT_CMD

struct kvaser_usb_dev_cfg;

enum kvaser_usb_leaf_family {};

#define KVASER_USB_HYDRA_MAX_CMD_LEN
struct kvaser_usb_dev_card_data_hydra {};
struct kvaser_usb_dev_card_data {};

/* Context for an outstanding, not yet ACKed, transmission */
struct kvaser_usb_tx_urb_context {};

struct kvaser_usb_busparams {} __packed;

struct kvaser_usb {};

struct kvaser_usb_net_priv {};

/**
 * struct kvaser_usb_dev_ops - Device specific functions
 * @dev_set_mode:		used for can.do_set_mode
 * @dev_set_bittiming:		used for can.do_set_bittiming
 * @dev_get_busparams:		readback arbitration busparams
 * @dev_set_data_bittiming:	used for can.do_set_data_bittiming
 * @dev_get_data_busparams:	readback data busparams
 * @dev_get_berr_counter:	used for can.do_get_berr_counter
 *
 * @dev_setup_endpoints:	setup USB in and out endpoints
 * @dev_init_card:		initialize card
 * @dev_init_channel:		initialize channel
 * @dev_remove_channel:		uninitialize channel
 * @dev_get_software_info:	get software info
 * @dev_get_software_details:	get software details
 * @dev_get_card_info:		get card info
 * @dev_get_capabilities:	discover device capabilities
 *
 * @dev_set_opt_mode:		set ctrlmod
 * @dev_start_chip:		start the CAN controller
 * @dev_stop_chip:		stop the CAN controller
 * @dev_reset_chip:		reset the CAN controller
 * @dev_flush_queue:		flush outstanding CAN messages
 * @dev_read_bulk_callback:	handle incoming commands
 * @dev_frame_to_cmd:		translate struct can_frame into device command
 */
struct kvaser_usb_dev_ops {};

struct kvaser_usb_driver_info {};

struct kvaser_usb_dev_cfg {};

extern const struct kvaser_usb_dev_ops kvaser_usb_hydra_dev_ops;
extern const struct kvaser_usb_dev_ops kvaser_usb_leaf_dev_ops;

void kvaser_usb_unlink_tx_urbs(struct kvaser_usb_net_priv *priv);

int kvaser_usb_recv_cmd(const struct kvaser_usb *dev, void *cmd, int len,
			int *actual_len);

int kvaser_usb_send_cmd(const struct kvaser_usb *dev, void *cmd, int len);

int kvaser_usb_send_cmd_async(struct kvaser_usb_net_priv *priv, void *cmd,
			      int len);

int kvaser_usb_can_rx_over_error(struct net_device *netdev);

extern const struct can_bittiming_const kvaser_usb_flexc_bittiming_const;

#endif /* KVASER_USB_H */