drivers/net/ethernet/nxp/lpc_eth.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/nxp/lpc_eth.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/nxp/lpc_eth.c- Extension
.c- Size
- 40962 bytes
- Lines
- 1523
- 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/clk.hlinux/crc32.hlinux/etherdevice.hlinux/module.hlinux/of.hlinux/of_mdio.hlinux/of_net.hlinux/phy.hlinux/platform_device.hlinux/spinlock.hlinux/soc/nxp/lpc32xx-misc.h
Detected Declarations
struct txrx_desc_tstruct rx_status_tstruct netdata_localfunction Copyrightfunction use_iram_for_netfunction __lpc_set_macfunction __lpc_get_macfunction __lpc_params_setupfunction __lpc_eth_resetfunction __lpc_mii_mngt_resetfunction __va_to_pafunction lpc_eth_enable_intfunction lpc_eth_disable_intfunction __lpc_txrx_desc_setupfunction __lpc_eth_initfunction __lpc_eth_shutdownfunction lpc_mdio_readfunction lpc_mdio_writefunction lpc_mdio_resetfunction lpc_handle_link_changefunction lpc_mii_probefunction lpc_mii_initfunction __lpc_handle_xmitfunction __lpc_handle_recvfunction readlfunction lpc_eth_pollfunction __lpc_eth_interruptfunction lpc_eth_closefunction lpc_eth_hard_start_xmitfunction lpc_set_mac_addressfunction lpc_eth_set_multicast_listfunction lpc_eth_openfunction lpc_eth_ethtool_getdrvinfofunction lpc_eth_ethtool_getmsglevelfunction lpc_eth_ethtool_setmsglevelfunction lpc_eth_drv_probefunction lpc_eth_drv_removefunction lpc_eth_drv_suspendfunction lpc_eth_drv_resume
Annotated Snippet
static const struct net_device_ops lpc_netdev_ops = {
.ndo_open = lpc_eth_open,
.ndo_stop = lpc_eth_close,
.ndo_start_xmit = lpc_eth_hard_start_xmit,
.ndo_set_rx_mode = lpc_eth_set_multicast_list,
.ndo_eth_ioctl = phy_do_ioctl_running,
.ndo_set_mac_address = lpc_set_mac_address,
.ndo_validate_addr = eth_validate_addr,
};
static int lpc_eth_drv_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node;
struct netdata_local *pldat;
struct net_device *ndev;
dma_addr_t dma_handle;
struct resource *res;
u8 addr[ETH_ALEN];
int irq, ret;
/* Setup network interface for RMII or MII mode */
lpc32xx_set_phy_interface_mode(lpc_phy_interface_mode(dev));
/* Get platform resources */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
irq = platform_get_irq(pdev, 0);
if (!res || irq < 0) {
dev_err(dev, "error getting resources.\n");
ret = -ENXIO;
goto err_exit;
}
/* Allocate net driver data structure */
ndev = alloc_etherdev(sizeof(struct netdata_local));
if (!ndev) {
dev_err(dev, "could not allocate device.\n");
ret = -ENOMEM;
goto err_exit;
}
SET_NETDEV_DEV(ndev, dev);
pldat = netdev_priv(ndev);
pldat->pdev = pdev;
pldat->ndev = ndev;
spin_lock_init(&pldat->lock);
/* Save resources */
ndev->irq = irq;
/* Get clock for the device */
pldat->clk = clk_get(dev, NULL);
if (IS_ERR(pldat->clk)) {
dev_err(dev, "error getting clock.\n");
ret = PTR_ERR(pldat->clk);
goto err_out_free_dev;
}
/* Enable network clock */
ret = clk_prepare_enable(pldat->clk);
if (ret)
goto err_out_clk_put;
/* Map IO space */
pldat->net_base = ioremap(res->start, resource_size(res));
if (!pldat->net_base) {
dev_err(dev, "failed to map registers\n");
ret = -ENOMEM;
goto err_out_disable_clocks;
}
ret = request_irq(ndev->irq, __lpc_eth_interrupt, 0,
ndev->name, ndev);
if (ret) {
dev_err(dev, "error requesting interrupt.\n");
goto err_out_iounmap;
}
/* Setup driver functions */
ndev->netdev_ops = &lpc_netdev_ops;
ndev->ethtool_ops = &lpc_eth_ethtool_ops;
ndev->watchdog_timeo = msecs_to_jiffies(2500);
/* Get size of DMA buffers/descriptors region */
pldat->dma_buff_size = (ENET_TX_DESC + ENET_RX_DESC) * (ENET_MAXF_SIZE +
sizeof(struct txrx_desc_t) + sizeof(struct rx_status_t));
if (use_iram_for_net(dev)) {
if (pldat->dma_buff_size >
Annotation
- Immediate include surface: `linux/clk.h`, `linux/crc32.h`, `linux/etherdevice.h`, `linux/module.h`, `linux/of.h`, `linux/of_mdio.h`, `linux/of_net.h`, `linux/phy.h`.
- Detected declarations: `struct txrx_desc_t`, `struct rx_status_t`, `struct netdata_local`, `function Copyright`, `function use_iram_for_net`, `function __lpc_set_mac`, `function __lpc_get_mac`, `function __lpc_params_setup`, `function __lpc_eth_reset`, `function __lpc_mii_mngt_reset`.
- 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.