drivers/net/can/rcar/rcar_canfd.c
Source file repositories/reference/linux-study-clean/drivers/net/can/rcar/rcar_canfd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/can/rcar/rcar_canfd.c- Extension
.c- Size
- 68998 bytes
- Lines
- 2390
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/bitmap.hlinux/bitops.hlinux/can/dev.hlinux/clk.hlinux/errno.hlinux/ethtool.hlinux/interrupt.hlinux/iopoll.hlinux/kernel.hlinux/module.hlinux/moduleparam.hlinux/netdevice.hlinux/of.hlinux/phy/phy.hlinux/platform_device.hlinux/reset.hlinux/types.h
Detected Declarations
struct rcar_canfd_f_cstruct rcar_canfd_globalstruct rcar_canfd_regsstruct rcar_canfd_shift_datastruct rcar_canfd_hw_infostruct rcar_canfd_channelstruct rcar_canfd_globalfunction rcar_canfd_updatefunction rcar_canfd_readfunction rcar_canfd_writefunction rcar_canfd_set_bitfunction rcar_canfd_clear_bitfunction rcar_canfd_update_bitfunction rcar_canfd_set_bit_regfunction rcar_canfd_clear_bit_regfunction rcar_canfd_update_bit_regfunction rcar_canfd_get_datafunction rcar_canfd_put_datafunction rcar_canfd_tx_failure_cleanupfunction rcar_canfd_set_rncfunction rcar_canfd_reset_controllerfunction rcar_canfd_configure_controllerfunction rcar_canfd_configure_afl_rulesfunction rcar_canfd_configure_rxfunction rcar_canfd_configure_txfunction rcar_canfd_enable_global_interruptsfunction rcar_canfd_disable_global_interruptsfunction rcar_canfd_enable_channel_interruptsfunction rcar_canfd_disable_channel_interruptsfunction rcar_canfd_global_errorfunction rcar_canfd_errorfunction rcar_canfd_tx_donefunction rcar_canfd_handle_global_errfunction rcar_canfd_global_err_interruptfunction rcar_canfd_handle_global_receivefunction rcar_canfd_global_receive_fifo_interruptfunction rcar_canfd_global_interruptfunction rcar_canfd_state_changefunction rcar_canfd_handle_channel_txfunction rcar_canfd_channel_tx_interruptfunction rcar_canfd_handle_channel_errfunction rcar_canfd_channel_err_interruptfunction rcar_canfd_channel_interruptfunction rcar_canfd_compute_nominal_bit_rate_cfgfunction rcar_canfd_compute_data_bit_rate_cfgfunction rcar_canfd_set_bittimingfunction rcar_canfd_startfunction rcar_canfd_open
Annotated Snippet
static const struct net_device_ops rcar_canfd_netdev_ops = {
.ndo_open = rcar_canfd_open,
.ndo_stop = rcar_canfd_close,
.ndo_start_xmit = rcar_canfd_start_xmit,
};
static const struct ethtool_ops rcar_canfd_ethtool_ops = {
.get_ts_info = ethtool_op_get_ts_info,
};
static int rcar_canfd_channel_probe(struct rcar_canfd_global *gpriv, u32 ch,
u32 fcan_freq, struct phy *transceiver)
{
const struct rcar_canfd_hw_info *info = gpriv->info;
struct platform_device *pdev = gpriv->pdev;
struct device *dev = &pdev->dev;
struct rcar_canfd_channel *priv;
struct net_device *ndev;
int err = -ENODEV;
ndev = alloc_candev(sizeof(*priv), RCANFD_FIFO_DEPTH);
if (!ndev)
return -ENOMEM;
priv = netdev_priv(ndev);
ndev->netdev_ops = &rcar_canfd_netdev_ops;
ndev->ethtool_ops = &rcar_canfd_ethtool_ops;
ndev->flags |= IFF_ECHO;
priv->ndev = ndev;
priv->base = gpriv->base;
priv->transceiver = transceiver;
priv->channel = ch;
priv->gpriv = gpriv;
if (transceiver)
priv->can.bitrate_max = transceiver->attrs.max_link_rate;
priv->can.clock.freq = fcan_freq;
dev_info(dev, "can_clk rate is %u\n", priv->can.clock.freq);
if (info->multi_channel_irqs) {
char *irq_name;
char name[10];
int err_irq;
int tx_irq;
scnprintf(name, sizeof(name), "ch%u_err", ch);
err_irq = platform_get_irq_byname(pdev, name);
if (err_irq < 0) {
err = err_irq;
goto fail;
}
scnprintf(name, sizeof(name), "ch%u_trx", ch);
tx_irq = platform_get_irq_byname(pdev, name);
if (tx_irq < 0) {
err = tx_irq;
goto fail;
}
irq_name = devm_kasprintf(dev, GFP_KERNEL, "canfd.ch%d_err",
ch);
if (!irq_name) {
err = -ENOMEM;
goto fail;
}
err = devm_request_irq(dev, err_irq,
rcar_canfd_channel_err_interrupt, 0,
irq_name, priv);
if (err) {
dev_err(dev, "devm_request_irq CH Err %d failed: %pe\n",
err_irq, ERR_PTR(err));
goto fail;
}
irq_name = devm_kasprintf(dev, GFP_KERNEL, "canfd.ch%d_trx",
ch);
if (!irq_name) {
err = -ENOMEM;
goto fail;
}
err = devm_request_irq(dev, tx_irq,
rcar_canfd_channel_tx_interrupt, 0,
irq_name, priv);
if (err) {
dev_err(dev, "devm_request_irq Tx %d failed: %pe\n",
tx_irq, ERR_PTR(err));
goto fail;
}
}
if (gpriv->fdmode) {
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bitmap.h`, `linux/bitops.h`, `linux/can/dev.h`, `linux/clk.h`, `linux/errno.h`, `linux/ethtool.h`, `linux/interrupt.h`.
- Detected declarations: `struct rcar_canfd_f_c`, `struct rcar_canfd_global`, `struct rcar_canfd_regs`, `struct rcar_canfd_shift_data`, `struct rcar_canfd_hw_info`, `struct rcar_canfd_channel`, `struct rcar_canfd_global`, `function rcar_canfd_update`, `function rcar_canfd_read`, `function rcar_canfd_write`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.