drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
Source file repositories/reference/linux-study-clean/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c- Extension
.c- Size
- 64365 bytes
- Lines
- 2455
- 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.
- 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/unaligned.hlinux/bitfield.hlinux/clk.hlinux/device.hlinux/mod_devicetable.hlinux/module.hlinux/pm_runtime.hlinux/property.hmcp251xfd.h
Detected Declarations
function mcp251xfd_get_model_strfunction mcp251xfd_get_osc_strfunction mcp251xfd_vdd_enablefunction mcp251xfd_vdd_disablefunction mcp251xfd_transceiver_enablefunction mcp251xfd_transceiver_disablefunction mcp251xfd_clks_and_vdd_enablefunction mcp251xfd_clks_and_vdd_disablefunction mcp251xfd_reg_invalidfunction mcp251xfd_chip_get_modefunction __mcp251xfd_chip_set_modefunction mcp251xfd_chip_set_modefunction mcp251xfd_chip_set_mode_nowaitfunction mcp251xfd_chip_wait_for_osc_readyfunction mcp251xfd_chip_wakefunction mcp251xfd_chip_sleepfunction mcp251xfd_chip_softreset_dofunction mcp251xfd_chip_softreset_checkfunction mcp251xfd_chip_softresetfunction mcp251xfd_chip_clock_initfunction mcp251xfd_chip_timestamp_initfunction mcp251xfd_set_bittimingfunction mcp251xfd_chip_rx_int_enablefunction mcp251xfd_chip_rx_int_disablefunction mcp251xfd_chip_ecc_initfunction mcp251xfd_get_normal_modefunction __mcp251xfd_chip_set_normal_modefunction mcp251xfd_chip_set_normal_modefunction mcp251xfd_chip_set_normal_mode_nowaitfunction mcp251xfd_chip_interrupts_enablefunction mcp251xfd_chip_interrupts_disablefunction mcp251xfd_chip_stopfunction mcp251xfd_chip_xstbyen_enablefunction mcp251xfd_chip_startfunction mcp251xfd_set_modefunction __mcp251xfd_get_berr_counterfunction mcp251xfd_get_berr_counterfunction mcp251xfd_alloc_can_err_skbfunction mcp251xfd_handle_rxoviffunction mcp251xfd_for_each_rx_ringfunction mcp251xfd_handle_txatiffunction mcp251xfd_handle_ivmiffunction mcp251xfd_handle_cerriffunction mcp251xfd_handle_modiffunction mcp251xfd_handle_serriffunction ECCIFfunction activatedfunction mcp251xfd_handle_eccif_recover
Annotated Snippet
static const struct net_device_ops mcp251xfd_netdev_ops = {
.ndo_open = mcp251xfd_open,
.ndo_stop = mcp251xfd_stop,
.ndo_start_xmit = mcp251xfd_start_xmit,
.ndo_hwtstamp_get = can_hwtstamp_get,
.ndo_hwtstamp_set = can_hwtstamp_set,
};
static void
mcp251xfd_register_quirks(struct mcp251xfd_priv *priv)
{
const struct spi_device *spi = priv->spi;
const struct spi_controller *ctlr = spi->controller;
if (ctlr->flags & SPI_CONTROLLER_HALF_DUPLEX)
priv->devtype_data.quirks |= MCP251XFD_QUIRK_HALF_DUPLEX;
}
static int mcp251xfd_register_chip_detect(struct mcp251xfd_priv *priv)
{
const struct net_device *ndev = priv->ndev;
const struct mcp251xfd_devtype_data *devtype_data;
u32 osc;
int err;
/* The OSC_LPMEN is only supported on MCP2518FD and MCP251863,
* so use it to autodetect the model.
*/
err = regmap_update_bits(priv->map_reg, MCP251XFD_REG_OSC,
MCP251XFD_REG_OSC_LPMEN,
MCP251XFD_REG_OSC_LPMEN);
if (err)
return err;
err = regmap_read(priv->map_reg, MCP251XFD_REG_OSC, &osc);
if (err)
return err;
if (osc & MCP251XFD_REG_OSC_LPMEN) {
/* We cannot distinguish between MCP2518FD and
* MCP251863. If firmware specifies MCP251863, keep
* it, otherwise set to MCP2518FD.
*/
if (mcp251xfd_is_251863(priv))
devtype_data = &mcp251xfd_devtype_data_mcp251863;
else
devtype_data = &mcp251xfd_devtype_data_mcp2518fd;
} else {
devtype_data = &mcp251xfd_devtype_data_mcp2517fd;
}
if (!mcp251xfd_is_251XFD(priv) &&
priv->devtype_data.model != devtype_data->model) {
netdev_info(ndev,
"Detected %s, but firmware specifies a %s. Fixing up.\n",
__mcp251xfd_get_model_str(devtype_data->model),
mcp251xfd_get_model_str(priv));
}
priv->devtype_data = *devtype_data;
/* We need to preserve the Half Duplex Quirk. */
mcp251xfd_register_quirks(priv);
/* Re-init regmap with quirks of detected model. */
return mcp251xfd_regmap_init(priv);
}
static int mcp251xfd_register_check_rx_int(struct mcp251xfd_priv *priv)
{
int err, rx_pending;
if (!priv->rx_int)
return 0;
err = mcp251xfd_chip_rx_int_enable(priv);
if (err)
return err;
/* Check if RX_INT is properly working. The RX_INT should not
* be active after a softreset.
*/
rx_pending = gpiod_get_value_cansleep(priv->rx_int);
err = mcp251xfd_chip_rx_int_disable(priv);
if (err)
return err;
if (!rx_pending)
return 0;
Annotation
- Immediate include surface: `linux/unaligned.h`, `linux/bitfield.h`, `linux/clk.h`, `linux/device.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/pm_runtime.h`, `linux/property.h`.
- Detected declarations: `function mcp251xfd_get_model_str`, `function mcp251xfd_get_osc_str`, `function mcp251xfd_vdd_enable`, `function mcp251xfd_vdd_disable`, `function mcp251xfd_transceiver_enable`, `function mcp251xfd_transceiver_disable`, `function mcp251xfd_clks_and_vdd_enable`, `function mcp251xfd_clks_and_vdd_disable`, `function mcp251xfd_reg_invalid`, `function mcp251xfd_chip_get_mode`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
- 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.