drivers/net/ethernet/xilinx/xilinx_emaclite.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/xilinx/xilinx_emaclite.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/xilinx/xilinx_emaclite.c- Extension
.c- Size
- 37223 bytes
- Lines
- 1269
- 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/module.hlinux/platform_device.hlinux/uaccess.hlinux/netdevice.hlinux/etherdevice.hlinux/skbuff.hlinux/ethtool.hlinux/io.hlinux/slab.hlinux/of.hlinux/of_address.hlinux/of_mdio.hlinux/of_net.hlinux/phy.hlinux/interrupt.hlinux/iopoll.h
Detected Declarations
struct net_localfunction xemaclite_enable_interruptsfunction xemaclite_disable_interruptsfunction xemaclite_aligned_writefunction xemaclite_aligned_readfunction xemaclite_send_datafunction xemaclite_recv_datafunction buffersfunction xemaclite_set_mac_addressfunction xemaclite_tx_timeoutfunction xemaclite_tx_handlerfunction xemaclite_rx_handlerfunction xemaclite_interruptfunction xemaclite_mdio_waitfunction xemaclite_mdio_readfunction xemaclite_mdio_writefunction xemaclite_mdio_setupfunction xemaclite_adjust_linkfunction xemaclite_openfunction xemaclite_closefunction xemaclite_sendfunction get_boolfunction xemaclite_ethtools_get_drvinfofunction xemaclite_of_probefunction xemaclite_of_removefunction xemaclite_poll_controllerfunction xemaclite_ioctl
Annotated Snippet
static const struct net_device_ops xemaclite_netdev_ops;
/**
* xemaclite_of_probe - Probe method for the Emaclite device.
* @ofdev: Pointer to OF device structure
*
* This function probes for the Emaclite device in the device tree.
* It initializes the driver data structure and the hardware, sets the MAC
* address and registers the network device.
* It also registers a mii_bus for the Emaclite device, if MDIO is included
* in the device.
*
* Return: 0, if the driver is bound to the Emaclite device, or
* a negative error if there is failure.
*/
static int xemaclite_of_probe(struct platform_device *ofdev)
{
struct resource *res;
struct net_device *ndev = NULL;
struct net_local *lp = NULL;
struct device *dev = &ofdev->dev;
struct clk *clkin;
int rc = 0;
dev_info(dev, "Device Tree Probing\n");
/* Create an ethernet device instance */
ndev = devm_alloc_etherdev(dev, sizeof(struct net_local));
if (!ndev)
return -ENOMEM;
dev_set_drvdata(dev, ndev);
SET_NETDEV_DEV(ndev, &ofdev->dev);
lp = netdev_priv(ndev);
lp->ndev = ndev;
/* Get IRQ for the device */
rc = platform_get_irq(ofdev, 0);
if (rc < 0)
return rc;
ndev->irq = rc;
lp->base_addr = devm_platform_get_and_ioremap_resource(ofdev, 0, &res);
if (IS_ERR(lp->base_addr))
return PTR_ERR(lp->base_addr);
ndev->mem_start = res->start;
ndev->mem_end = res->end;
spin_lock_init(&lp->reset_lock);
lp->next_tx_buf_to_use = 0x0;
lp->next_rx_buf_to_use = 0x0;
lp->tx_ping_pong = get_bool(ofdev, "xlnx,tx-ping-pong");
lp->rx_ping_pong = get_bool(ofdev, "xlnx,rx-ping-pong");
clkin = devm_clk_get_optional_enabled(&ofdev->dev, NULL);
if (IS_ERR(clkin))
return dev_err_probe(&ofdev->dev, PTR_ERR(clkin),
"Failed to get and enable clock from Device Tree\n");
rc = of_get_ethdev_address(ofdev->dev.of_node, ndev);
if (rc) {
dev_warn(dev, "No MAC address found, using random\n");
eth_hw_addr_random(ndev);
}
/* Clear the Tx CSR's in case this is a restart */
xemaclite_writel(0, lp->base_addr + XEL_TSR_OFFSET);
xemaclite_writel(0, lp->base_addr + XEL_BUFFER_OFFSET + XEL_TSR_OFFSET);
/* Set the MAC address in the EmacLite device */
xemaclite_update_address(lp, ndev->dev_addr);
lp->phy_node = of_parse_phandle(ofdev->dev.of_node, "phy-handle", 0);
xemaclite_mdio_setup(lp, &ofdev->dev);
dev_info(dev, "MAC address is now %pM\n", ndev->dev_addr);
ndev->netdev_ops = &xemaclite_netdev_ops;
ndev->ethtool_ops = &xemaclite_ethtool_ops;
ndev->flags &= ~IFF_MULTICAST;
ndev->watchdog_timeo = TX_TIMEOUT;
/* Finally, register the device */
rc = register_netdev(ndev);
if (rc) {
dev_err(dev,
Annotation
- Immediate include surface: `linux/clk.h`, `linux/module.h`, `linux/platform_device.h`, `linux/uaccess.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/skbuff.h`, `linux/ethtool.h`.
- Detected declarations: `struct net_local`, `function xemaclite_enable_interrupts`, `function xemaclite_disable_interrupts`, `function xemaclite_aligned_write`, `function xemaclite_aligned_read`, `function xemaclite_send_data`, `function xemaclite_recv_data`, `function buffers`, `function xemaclite_set_mac_address`, `function xemaclite_tx_timeout`.
- 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.