linux/drivers/net/can/c_can/c_can_main.c

/*
 * CAN bus driver for Bosch C_CAN controller
 *
 * Copyright (C) 2010 ST Microelectronics
 * Bhupesh Sharma <[email protected]>
 *
 * Borrowed heavily from the C_CAN driver originally written by:
 * Copyright (C) 2007
 * - Sascha Hauer, Marc Kleine-Budde, Pengutronix <[email protected]>
 * - Simon Kallweit, intefo AG <[email protected]>
 *
 * TX and RX NAPI implementation has been borrowed from at91 CAN driver
 * written by:
 * Copyright
 * (C) 2007 by Hans J. Koch <[email protected]>
 * (C) 2008, 2009 by Marc Kleine-Budde <[email protected]>
 *
 * Bosch C_CAN controller is compliant to CAN protocol version 2.0 part A and B.
 * Bosch C_CAN user manual can be obtained from:
 * http://www.semiconductors.bosch.de/media/en/pdf/ipmodules_1/c_can/
 * users_manual_c_can.pdf
 *
 * This file is licensed under the terms of the GNU General Public
 * License version 2. This program is licensed "as is" without any
 * warranty of any kind, whether express or implied.
 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/netdevice.h>
#include <linux/if_arp.h>
#include <linux/if_ether.h>
#include <linux/list.h>
#include <linux/io.h>
#include <linux/pm_runtime.h>
#include <linux/pinctrl/consumer.h>

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

#include "c_can.h"

/* Number of interface registers */
#define IF_ENUM_REG_LEN
#define C_CAN_IFACE(reg, iface)

/* control extension register D_CAN specific */
#define CONTROL_EX_PDR

/* control register */
#define CONTROL_SWR
#define CONTROL_TEST
#define CONTROL_CCE
#define CONTROL_DISABLE_AR
#define CONTROL_ENABLE_AR
#define CONTROL_EIE
#define CONTROL_SIE
#define CONTROL_IE
#define CONTROL_INIT

#define CONTROL_IRQMSK

/* test register */
#define TEST_RX
#define TEST_TX1
#define TEST_TX2
#define TEST_LBACK
#define TEST_SILENT
#define TEST_BASIC

/* status register */
#define STATUS_PDA
#define STATUS_BOFF
#define STATUS_EWARN
#define STATUS_EPASS
#define STATUS_RXOK
#define STATUS_TXOK

/* error counter register */
#define ERR_CNT_TEC_MASK
#define ERR_CNT_TEC_SHIFT
#define ERR_CNT_REC_SHIFT
#define ERR_CNT_REC_MASK
#define ERR_CNT_RP_SHIFT
#define ERR_CNT_RP_MASK

/* bit-timing register */
#define BTR_BRP_MASK
#define BTR_BRP_SHIFT
#define BTR_SJW_SHIFT
#define BTR_SJW_MASK
#define BTR_TSEG1_SHIFT
#define BTR_TSEG1_MASK
#define BTR_TSEG2_SHIFT
#define BTR_TSEG2_MASK

/* interrupt register */
#define INT_STS_PENDING

/* brp extension register */
#define BRP_EXT_BRPE_MASK
#define BRP_EXT_BRPE_SHIFT

/* IFx command request */
#define IF_COMR_BUSY

/* IFx command mask */
#define IF_COMM_WR
#define IF_COMM_MASK
#define IF_COMM_ARB
#define IF_COMM_CONTROL
#define IF_COMM_CLR_INT_PND
#define IF_COMM_TXRQST
#define IF_COMM_CLR_NEWDAT
#define IF_COMM_DATAA
#define IF_COMM_DATAB

/* TX buffer setup */
#define IF_COMM_TX

/* For the low buffers we clear the interrupt bit, but keep newdat */
#define IF_COMM_RCV_LOW

/* For the high buffers we clear the interrupt bit and newdat */
#define IF_COMM_RCV_HIGH

/* Receive setup of message objects */
#define IF_COMM_RCV_SETUP

/* Invalidation of message objects */
#define IF_COMM_INVAL

/* IFx arbitration */
#define IF_ARB_MSGVAL
#define IF_ARB_MSGXTD
#define IF_ARB_TRANSMIT

/* IFx message control */
#define IF_MCONT_NEWDAT
#define IF_MCONT_MSGLST
#define IF_MCONT_INTPND
#define IF_MCONT_UMASK
#define IF_MCONT_TXIE
#define IF_MCONT_RXIE
#define IF_MCONT_RMTEN
#define IF_MCONT_TXRQST
#define IF_MCONT_EOB
#define IF_MCONT_DLC_MASK

#define IF_MCONT_RCV
#define IF_MCONT_RCV_EOB

#define IF_MCONT_TX

/* Use IF1 in NAPI path and IF2 in TX path */
#define IF_NAPI
#define IF_TX

/* minimum timeout for checking BUSY status */
#define MIN_TIMEOUT_VALUE

/* Wait for ~1 sec for INIT bit */
#define INIT_WAIT_MS

/* c_can lec values */
enum c_can_lec_type {};

/* c_can error types:
 * Bus errors (BUS_OFF, ERROR_WARNING, ERROR_PASSIVE) are supported
 */
enum c_can_bus_error_types {};

static const struct can_bittiming_const c_can_bittiming_const =;

static inline void c_can_pm_runtime_get_sync(const struct c_can_priv *priv)
{}

static inline void c_can_pm_runtime_put_sync(const struct c_can_priv *priv)
{}

static inline void c_can_reset_ram(const struct c_can_priv *priv, bool enable)
{}

static void c_can_irq_control(struct c_can_priv *priv, bool enable)
{}

static void c_can_obj_update(struct net_device *dev, int iface, u32 cmd, u32 obj)
{}

static inline void c_can_object_get(struct net_device *dev, int iface,
				    u32 obj, u32 cmd)
{}

static inline void c_can_object_put(struct net_device *dev, int iface,
				    u32 obj, u32 cmd)
{}

/* Note: According to documentation clearing TXIE while MSGVAL is set
 * is not allowed, but works nicely on C/DCAN. And that lowers the I/O
 * load significantly.
 */
static void c_can_inval_tx_object(struct net_device *dev, int iface, int obj)
{}

static void c_can_inval_msg_object(struct net_device *dev, int iface, int obj)
{}

static void c_can_setup_tx_object(struct net_device *dev, int iface,
				  struct can_frame *frame, int idx)
{}

static int c_can_handle_lost_msg_obj(struct net_device *dev,
				     int iface, int objno, u32 ctrl)
{}

static int c_can_read_msg_object(struct net_device *dev, int iface, u32 ctrl)
{}

static void c_can_setup_receive_object(struct net_device *dev, int iface,
				       u32 obj, u32 mask, u32 id, u32 mcont)
{}

static bool c_can_tx_busy(const struct c_can_priv *priv,
			  const struct c_can_tx_ring *tx_ring)
{}

static netdev_tx_t c_can_start_xmit(struct sk_buff *skb,
				    struct net_device *dev)
{}

static int c_can_wait_for_ctrl_init(struct net_device *dev,
				    struct c_can_priv *priv, u32 init)
{}

static int c_can_set_bittiming(struct net_device *dev)
{}

/* Configure C_CAN message objects for Tx and Rx purposes:
 * C_CAN provides a total of 32 message objects that can be configured
 * either for Tx or Rx purposes. Here the first 16 message objects are used as
 * a reception FIFO. The end of reception FIFO is signified by the EoB bit
 * being SET. The remaining 16 message objects are kept aside for Tx purposes.
 * See user guide document for further details on configuring message
 * objects.
 */
static void c_can_configure_msg_objects(struct net_device *dev)
{}

static int c_can_software_reset(struct net_device *dev)
{}

/* Configure C_CAN chip:
 * - enable/disable auto-retransmission
 * - set operating mode
 * - configure message objects
 */
static int c_can_chip_config(struct net_device *dev)
{}

static int c_can_start(struct net_device *dev)
{}

static void c_can_stop(struct net_device *dev)
{}

static int c_can_set_mode(struct net_device *dev, enum can_mode mode)
{}

static int __c_can_get_berr_counter(const struct net_device *dev,
				    struct can_berr_counter *bec)
{}

static int c_can_get_berr_counter(const struct net_device *dev,
				  struct can_berr_counter *bec)
{}

static void c_can_do_tx(struct net_device *dev)
{}

/* If we have a gap in the pending bits, that means we either
 * raced with the hardware or failed to readout all upper
 * objects in the last run due to quota limit.
 */
static u32 c_can_adjust_pending(u32 pend, u32 rx_mask)
{}

static inline void c_can_rx_object_get(struct net_device *dev,
				       struct c_can_priv *priv, u32 obj)
{}

static inline void c_can_rx_finalize(struct net_device *dev,
				     struct c_can_priv *priv, u32 obj)
{}

static int c_can_read_objects(struct net_device *dev, struct c_can_priv *priv,
			      u32 pend, int quota)
{}

static inline u32 c_can_get_pending(struct c_can_priv *priv)
{}

/* theory of operation:
 *
 * c_can core saves a received CAN message into the first free message
 * object it finds free (starting with the lowest). Bits NEWDAT and
 * INTPND are set for this message object indicating that a new message
 * has arrived.
 *
 * We clear the newdat bit right away.
 *
 * This can result in packet reordering when the readout is slow.
 */
static int c_can_do_rx_poll(struct net_device *dev, int quota)
{}

static int c_can_handle_state_change(struct net_device *dev,
				     enum c_can_bus_error_types error_type)
{}

static int c_can_handle_bus_err(struct net_device *dev,
				enum c_can_lec_type lec_type)
{}

static int c_can_poll(struct napi_struct *napi, int quota)
{}

static irqreturn_t c_can_isr(int irq, void *dev_id)
{}

static int c_can_open(struct net_device *dev)
{}

static int c_can_close(struct net_device *dev)
{}

struct net_device *alloc_c_can_dev(int msg_obj_num)
{}
EXPORT_SYMBOL_GPL();

#ifdef CONFIG_PM
int c_can_power_down(struct net_device *dev)
{}
EXPORT_SYMBOL_GPL();

int c_can_power_up(struct net_device *dev)
{}
EXPORT_SYMBOL_GPL();
#endif

void free_c_can_dev(struct net_device *dev)
{}
EXPORT_SYMBOL_GPL();

static const struct net_device_ops c_can_netdev_ops =;

int register_c_can_dev(struct net_device *dev)
{}
EXPORT_SYMBOL_GPL();

void unregister_c_can_dev(struct net_device *dev)
{}
EXPORT_SYMBOL_GPL();

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