linux/drivers/net/can/bxcan.c

// SPDX-License-Identifier: GPL-2.0
//
// bxcan.c - STM32 Basic Extended CAN controller driver
//
// Copyright (c) 2022 Dario Binacchi <[email protected]>
//
// NOTE: The ST documentation uses the terms master/slave instead of
// primary/secondary.

#define pr_fmt(fmt)

#include <linux/bitfield.h>
#include <linux/can.h>
#include <linux/can/dev.h>
#include <linux/can/error.h>
#include <linux/can/rx-offload.h>
#include <linux/clk.h>
#include <linux/ethtool.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/iopoll.h>
#include <linux/kernel.h>
#include <linux/mfd/syscon.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>

#define BXCAN_NAPI_WEIGHT
#define BXCAN_TIMEOUT_US

#define BXCAN_RX_MB_NUM
#define BXCAN_TX_MB_NUM

/* Primary control register (MCR) bits */
#define BXCAN_MCR_RESET
#define BXCAN_MCR_TTCM
#define BXCAN_MCR_ABOM
#define BXCAN_MCR_AWUM
#define BXCAN_MCR_NART
#define BXCAN_MCR_RFLM
#define BXCAN_MCR_TXFP
#define BXCAN_MCR_SLEEP
#define BXCAN_MCR_INRQ

/* Primary status register (MSR) bits */
#define BXCAN_MSR_ERRI
#define BXCAN_MSR_SLAK
#define BXCAN_MSR_INAK

/* Transmit status register (TSR) bits */
#define BXCAN_TSR_RQCP2
#define BXCAN_TSR_RQCP1
#define BXCAN_TSR_RQCP0

/* Receive FIFO 0 register (RF0R) bits */
#define BXCAN_RF0R_RFOM0
#define BXCAN_RF0R_FMP0_MASK

/* Interrupt enable register (IER) bits */
#define BXCAN_IER_SLKIE
#define BXCAN_IER_WKUIE
#define BXCAN_IER_ERRIE
#define BXCAN_IER_LECIE
#define BXCAN_IER_BOFIE
#define BXCAN_IER_EPVIE
#define BXCAN_IER_EWGIE
#define BXCAN_IER_FOVIE1
#define BXCAN_IER_FFIE1
#define BXCAN_IER_FMPIE1
#define BXCAN_IER_FOVIE0
#define BXCAN_IER_FFIE0
#define BXCAN_IER_FMPIE0
#define BXCAN_IER_TMEIE

/* Error status register (ESR) bits */
#define BXCAN_ESR_REC_MASK
#define BXCAN_ESR_TEC_MASK
#define BXCAN_ESR_LEC_MASK
#define BXCAN_ESR_BOFF
#define BXCAN_ESR_EPVF
#define BXCAN_ESR_EWGF

/* Bit timing register (BTR) bits */
#define BXCAN_BTR_SILM
#define BXCAN_BTR_LBKM
#define BXCAN_BTR_SJW_MASK
#define BXCAN_BTR_TS2_MASK
#define BXCAN_BTR_TS1_MASK
#define BXCAN_BTR_BRP_MASK

/* TX mailbox identifier register (TIxR, x = 0..2) bits */
#define BXCAN_TIxR_STID_MASK
#define BXCAN_TIxR_EXID_MASK
#define BXCAN_TIxR_IDE
#define BXCAN_TIxR_RTR
#define BXCAN_TIxR_TXRQ

/* TX mailbox data length and time stamp register (TDTxR, x = 0..2 bits */
#define BXCAN_TDTxR_DLC_MASK

/* RX FIFO mailbox identifier register (RIxR, x = 0..1 */
#define BXCAN_RIxR_STID_MASK
#define BXCAN_RIxR_EXID_MASK
#define BXCAN_RIxR_IDE
#define BXCAN_RIxR_RTR

/* RX FIFO mailbox data length and timestamp register (RDTxR, x = 0..1) bits */
#define BXCAN_RDTxR_TIME_MASK
#define BXCAN_RDTxR_DLC_MASK

#define BXCAN_FMR_REG
#define BXCAN_FM1R_REG
#define BXCAN_FS1R_REG
#define BXCAN_FFA1R_REG
#define BXCAN_FA1R_REG
#define BXCAN_FiR1_REG(b)
#define BXCAN_FiR2_REG(b)

#define BXCAN_FILTER_ID(cfg)

/* Filter primary register (FMR) bits */
#define BXCAN_FMR_CANSB_MASK
#define BXCAN_FMR_FINIT

enum bxcan_lec_code {};

enum bxcan_cfg {};

/* Structure of the message buffer */
struct bxcan_mb {};

/* Structure of the hardware registers */
struct bxcan_regs {};

struct bxcan_priv {};

static const struct can_bittiming_const bxcan_bittiming_const =;

static inline void bxcan_rmw(struct bxcan_priv *priv, void __iomem *addr,
			     u32 clear, u32 set)
{}

static void bxcan_disable_filters(struct bxcan_priv *priv, enum bxcan_cfg cfg)
{}

static void bxcan_enable_filters(struct bxcan_priv *priv, enum bxcan_cfg cfg)
{}

static inline u8 bxcan_get_tx_head(const struct bxcan_priv *priv)
{}

static inline u8 bxcan_get_tx_tail(const struct bxcan_priv *priv)
{}

static inline u8 bxcan_get_tx_free(const struct bxcan_priv *priv)
{}

static bool bxcan_tx_busy(const struct bxcan_priv *priv)
{}

static int bxcan_chip_softreset(struct bxcan_priv *priv)
{}

static int bxcan_enter_init_mode(struct bxcan_priv *priv)
{}

static int bxcan_leave_init_mode(struct bxcan_priv *priv)
{}

static int bxcan_enter_sleep_mode(struct bxcan_priv *priv)
{}

static int bxcan_leave_sleep_mode(struct bxcan_priv *priv)
{}

static inline
struct bxcan_priv *rx_offload_to_priv(struct can_rx_offload *offload)
{}

static struct sk_buff *bxcan_mailbox_read(struct can_rx_offload *offload,
					  unsigned int mbxno, u32 *timestamp,
					  bool drop)
{}

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

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

static void bxcan_handle_state_change(struct net_device *ndev, u32 esr)
{}

static void bxcan_handle_bus_err(struct net_device *ndev, u32 esr)
{}

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

static int bxcan_chip_start(struct net_device *ndev)
{}

static int bxcan_open(struct net_device *ndev)
{}

static void bxcan_chip_stop(struct net_device *ndev)
{}

static int bxcan_stop(struct net_device *ndev)
{}

static netdev_tx_t bxcan_start_xmit(struct sk_buff *skb,
				    struct net_device *ndev)
{}

static const struct net_device_ops bxcan_netdev_ops =;

static const struct ethtool_ops bxcan_ethtool_ops =;

static int bxcan_do_set_mode(struct net_device *ndev, enum can_mode mode)
{}

static int bxcan_get_berr_counter(const struct net_device *ndev,
				  struct can_berr_counter *bec)
{}

static int bxcan_probe(struct platform_device *pdev)
{}

static void bxcan_remove(struct platform_device *pdev)
{}

static int __maybe_unused bxcan_suspend(struct device *dev)
{}

static int __maybe_unused bxcan_resume(struct device *dev)
{}

static SIMPLE_DEV_PM_OPS(bxcan_pm_ops, bxcan_suspend, bxcan_resume);

static const struct of_device_id bxcan_of_match[] =;
MODULE_DEVICE_TABLE(of, bxcan_of_match);

static struct platform_driver bxcan_driver =;

module_platform_driver();

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