drivers/net/can/ti_hecc.c
Source file repositories/reference/linux-study-clean/drivers/net/can/ti_hecc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/can/ti_hecc.c- Extension
.c- Size
- 31091 bytes
- Lines
- 1038
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/kernel.hlinux/types.hlinux/interrupt.hlinux/errno.hlinux/ethtool.hlinux/netdevice.hlinux/skbuff.hlinux/platform_device.hlinux/clk.hlinux/io.hlinux/of.hlinux/regulator/consumer.hlinux/can/dev.hlinux/can/error.hlinux/can/rx-offload.h
Detected Declarations
struct ti_hecc_privfunction get_tx_head_mbfunction get_tx_tail_mbfunction get_tx_head_priofunction hecc_write_lamfunction hecc_read_stampfunction hecc_write_mbxfunction hecc_read_mbxfunction hecc_writefunction hecc_readfunction hecc_set_bitfunction hecc_clear_bitfunction hecc_get_bitfunction ti_hecc_set_btcfunction ti_hecc_transceiver_switchfunction ti_hecc_resetfunction ti_hecc_startfunction ti_hecc_stopfunction ti_hecc_do_set_modefunction ti_hecc_get_berr_counterfunction levelfunction ti_hecc_errorfunction ti_hecc_change_statefunction ti_hecc_interruptfunction ti_hecc_openfunction ti_hecc_closefunction ti_hecc_probefunction ti_hecc_removefunction ti_hecc_suspendfunction ti_hecc_resume
Annotated Snippet
static const struct net_device_ops ti_hecc_netdev_ops = {
.ndo_open = ti_hecc_open,
.ndo_stop = ti_hecc_close,
.ndo_start_xmit = ti_hecc_xmit,
};
static const struct ethtool_ops ti_hecc_ethtool_ops = {
.get_ts_info = ethtool_op_get_ts_info,
};
static const struct of_device_id ti_hecc_dt_ids[] = {
{
.compatible = "ti,am3517-hecc",
},
{ }
};
MODULE_DEVICE_TABLE(of, ti_hecc_dt_ids);
static int ti_hecc_probe(struct platform_device *pdev)
{
struct net_device *ndev = (struct net_device *)0;
struct ti_hecc_priv *priv;
struct device_node *np = pdev->dev.of_node;
struct regulator *reg_xceiver;
int err = -ENODEV;
if (!IS_ENABLED(CONFIG_OF) || !np)
return -EINVAL;
reg_xceiver = devm_regulator_get(&pdev->dev, "xceiver");
if (PTR_ERR(reg_xceiver) == -EPROBE_DEFER)
return -EPROBE_DEFER;
else if (IS_ERR(reg_xceiver))
reg_xceiver = NULL;
ndev = alloc_candev(sizeof(struct ti_hecc_priv), HECC_MAX_TX_MBOX);
if (!ndev) {
dev_err(&pdev->dev, "alloc_candev failed\n");
return -ENOMEM;
}
priv = netdev_priv(ndev);
/* handle hecc memory */
priv->base = devm_platform_ioremap_resource_byname(pdev, "hecc");
if (IS_ERR(priv->base)) {
dev_err(&pdev->dev, "hecc ioremap failed\n");
err = PTR_ERR(priv->base);
goto probe_exit_candev;
}
/* handle hecc-ram memory */
priv->hecc_ram = devm_platform_ioremap_resource_byname(pdev,
"hecc-ram");
if (IS_ERR(priv->hecc_ram)) {
dev_err(&pdev->dev, "hecc-ram ioremap failed\n");
err = PTR_ERR(priv->hecc_ram);
goto probe_exit_candev;
}
/* handle mbx memory */
priv->mbx = devm_platform_ioremap_resource_byname(pdev, "mbx");
if (IS_ERR(priv->mbx)) {
dev_err(&pdev->dev, "mbx ioremap failed\n");
err = PTR_ERR(priv->mbx);
goto probe_exit_candev;
}
ndev->irq = platform_get_irq(pdev, 0);
if (ndev->irq < 0) {
err = ndev->irq;
goto probe_exit_candev;
}
priv->ndev = ndev;
priv->reg_xceiver = reg_xceiver;
priv->use_hecc1int = of_property_read_bool(np, "ti,use-hecc1int");
priv->can.bittiming_const = &ti_hecc_bittiming_const;
priv->can.do_set_mode = ti_hecc_do_set_mode;
priv->can.do_get_berr_counter = ti_hecc_get_berr_counter;
priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES;
spin_lock_init(&priv->mbx_lock);
ndev->flags |= IFF_ECHO;
platform_set_drvdata(pdev, ndev);
SET_NETDEV_DEV(ndev, &pdev->dev);
ndev->netdev_ops = &ti_hecc_netdev_ops;
ndev->ethtool_ops = &ti_hecc_ethtool_ops;
priv->clk = clk_get(&pdev->dev, "hecc_ck");
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/types.h`, `linux/interrupt.h`, `linux/errno.h`, `linux/ethtool.h`, `linux/netdevice.h`, `linux/skbuff.h`.
- Detected declarations: `struct ti_hecc_priv`, `function get_tx_head_mb`, `function get_tx_tail_mb`, `function get_tx_head_prio`, `function hecc_write_lam`, `function hecc_read_stamp`, `function hecc_write_mbx`, `function hecc_read_mbx`, `function hecc_write`, `function hecc_read`.
- 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.