drivers/net/can/rockchip/rockchip_canfd.h

Source file repositories/reference/linux-study-clean/drivers/net/can/rockchip/rockchip_canfd.h

File Facts

System
Linux kernel
Corpus path
drivers/net/can/rockchip/rockchip_canfd.h
Extension
.h
Size
18183 bytes
Lines
554
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct rkcanfd_devtype_data {
	enum rkcanfd_model model;
	u32 quirks;
};

struct rkcanfd_fifo_header {
	u32 frameinfo;
	u32 id;
	u32 ts;
};

struct rkcanfd_stats {
	struct u64_stats_sync syncp;

	/* Erratum 5 */
	u64_stats_t rx_fifo_empty_errors;

	/* Erratum 6 */
	u64_stats_t tx_extended_as_standard_errors;
};

struct rkcanfd_priv {
	struct can_priv can;
	struct can_rx_offload offload;
	struct net_device *ndev;

	void __iomem *regs;
	unsigned int tx_head;
	unsigned int tx_tail;

	u32 reg_mode_default;
	u32 reg_int_mask_default;
	struct rkcanfd_devtype_data devtype_data;

	struct cyclecounter cc;
	struct timecounter tc;
	struct delayed_work timestamp;
	unsigned long work_delay_jiffies;

	struct can_berr_counter bec;

	struct rkcanfd_stats stats;

	struct reset_control *reset;
	struct clk_bulk_data *clks;
	int clks_num;
};

static inline u32
rkcanfd_read(const struct rkcanfd_priv *priv, u32 reg)
{
	return readl(priv->regs + reg);
}

static inline void
rkcanfd_read_rep(const struct rkcanfd_priv *priv, u32 reg,
		 void *buf, unsigned int len)
{
	readsl(priv->regs + reg, buf, len / sizeof(u32));
}

static inline void
rkcanfd_write(const struct rkcanfd_priv *priv, u32 reg, u32 val)
{
	writel(val, priv->regs + reg);
}

static inline u32
rkcanfd_get_timestamp(const struct rkcanfd_priv *priv)
{
	return rkcanfd_read(priv, RKCANFD_REG_TIMESTAMP);
}

static inline unsigned int
rkcanfd_get_tx_head(const struct rkcanfd_priv *priv)
{
	return READ_ONCE(priv->tx_head) & (RKCANFD_TXFIFO_DEPTH - 1);
}

static inline unsigned int
rkcanfd_get_tx_tail(const struct rkcanfd_priv *priv)
{
	return READ_ONCE(priv->tx_tail) & (RKCANFD_TXFIFO_DEPTH - 1);
}

static inline unsigned int
rkcanfd_get_tx_pending(const struct rkcanfd_priv *priv)
{
	return READ_ONCE(priv->tx_head) - READ_ONCE(priv->tx_tail);
}

Annotation

Implementation Notes