drivers/net/ethernet/ti/davinci_emac.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/ti/davinci_emac.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/ti/davinci_emac.c- Extension
.c- Size
- 59963 bytes
- Lines
- 2095
- 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/module.hlinux/kernel.hlinux/sched.hlinux/string.hlinux/timer.hlinux/errno.hlinux/in.hlinux/ioport.hlinux/slab.hlinux/mm.hlinux/interrupt.hlinux/init.hlinux/netdevice.hlinux/etherdevice.hlinux/skbuff.hlinux/ethtool.hlinux/highmem.hlinux/proc_fs.hlinux/ctype.hlinux/spinlock.hlinux/dma-mapping.hlinux/clk.hlinux/platform_device.hlinux/property.hlinux/regmap.hlinux/semaphore.hlinux/phy.hlinux/bitops.hlinux/io.hlinux/uaccess.hlinux/pm_runtime.hlinux/davinci_emac.h
Detected Declarations
struct emac_privfunction informationfunction emac_get_coalescefunction emac_set_coalescefunction emac_update_phystatusfunction hash_getfunction emac_hash_addfunction emac_hash_delfunction emac_add_mcastfunction emac_dev_mcast_setfunction netdev_for_each_mc_addrfunction emac_int_disablefunction emac_int_enablefunction emac_irqfunction emac_rx_handlerfunction emac_tx_handlerfunction successfunction emac_dev_tx_timeoutfunction adapterfunction adapterfunction adapterfunction adapterfunction adapterfunction successfunction emac_pollfunction emac_poll_controllerfunction emac_adjust_linkfunction successfunction emac_dev_openfunction emac_dev_stopfunction davinci_emac_of_get_pdatafunction davinci_emac_try_get_macfunction davinci_emac_probefunction davinci_emac_removefunction davinci_emac_suspendfunction davinci_emac_resumefunction davinci_emac_initfunction davinci_emac_exit
Annotated Snippet
static const struct net_device_ops emac_netdev_ops = {
.ndo_open = emac_dev_open,
.ndo_stop = emac_dev_stop,
.ndo_start_xmit = emac_dev_xmit,
.ndo_set_rx_mode = emac_dev_mcast_set,
.ndo_set_mac_address = emac_dev_setmac_addr,
.ndo_eth_ioctl = emac_devioctl,
.ndo_tx_timeout = emac_dev_tx_timeout,
.ndo_get_stats = emac_dev_getnetstats,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = emac_poll_controller,
#endif
};
static struct emac_platform_data *
davinci_emac_of_get_pdata(struct platform_device *pdev, struct emac_priv *priv)
{
struct device_node *np;
const struct emac_platform_data *auxdata;
struct emac_platform_data *pdata = NULL;
if (!IS_ENABLED(CONFIG_OF) || !pdev->dev.of_node)
return dev_get_platdata(&pdev->dev);
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
return NULL;
np = pdev->dev.of_node;
pdata->version = EMAC_VERSION_2;
if (!is_valid_ether_addr(pdata->mac_addr))
of_get_mac_address(np, pdata->mac_addr);
of_property_read_u32(np, "ti,davinci-ctrl-reg-offset",
&pdata->ctrl_reg_offset);
of_property_read_u32(np, "ti,davinci-ctrl-mod-reg-offset",
&pdata->ctrl_mod_reg_offset);
of_property_read_u32(np, "ti,davinci-ctrl-ram-offset",
&pdata->ctrl_ram_offset);
of_property_read_u32(np, "ti,davinci-ctrl-ram-size",
&pdata->ctrl_ram_size);
of_property_read_u8(np, "ti,davinci-rmii-en", &pdata->rmii_en);
pdata->no_bd_ram = of_property_read_bool(np, "ti,davinci-no-bd-ram");
priv->phy_node = of_parse_phandle(np, "phy-handle", 0);
if (!priv->phy_node) {
if (!of_phy_is_fixed_link(np))
pdata->phy_id = NULL;
else if (of_phy_register_fixed_link(np) >= 0)
priv->phy_node = of_node_get(np);
}
auxdata = pdev->dev.platform_data;
if (auxdata) {
pdata->interrupt_enable = auxdata->interrupt_enable;
pdata->interrupt_disable = auxdata->interrupt_disable;
}
auxdata = device_get_match_data(&pdev->dev);
if (auxdata) {
pdata->version = auxdata->version;
pdata->hw_ram_addr = auxdata->hw_ram_addr;
}
return pdata;
}
static int davinci_emac_try_get_mac(struct platform_device *pdev,
int instance, u8 *mac_addr)
{
if (!pdev->dev.of_node)
return -EINVAL;
return ti_cm_get_macid(&pdev->dev, instance, mac_addr);
}
/**
* davinci_emac_probe - EMAC device probe
* @pdev: The DaVinci EMAC device that we are removing
*
* Called when probing for emac devicesr. We get details of instances and
* resource information from platform init and register a network device
* and allocate resources necessary for driver to perform
*/
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/sched.h`, `linux/string.h`, `linux/timer.h`, `linux/errno.h`, `linux/in.h`, `linux/ioport.h`.
- Detected declarations: `struct emac_priv`, `function information`, `function emac_get_coalesce`, `function emac_set_coalesce`, `function emac_update_phystatus`, `function hash_get`, `function emac_hash_add`, `function emac_hash_del`, `function emac_add_mcast`, `function emac_dev_mcast_set`.
- 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.