drivers/net/ethernet/adi/adin1110.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/adi/adin1110.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/adi/adin1110.c- Extension
.c- Size
- 43410 bytes
- Lines
- 1741
- 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/bitfield.hlinux/bits.hlinux/cache.hlinux/crc8.hlinux/etherdevice.hlinux/ethtool.hlinux/gpio/consumer.hlinux/if_bridge.hlinux/interrupt.hlinux/iopoll.hlinux/kernel.hlinux/mii.hlinux/module.hlinux/netdevice.hlinux/regulator/consumer.hlinux/phy.hlinux/property.hlinux/spi/spi.hnet/switchdev.hlinux/unaligned.h
Detected Declarations
struct adin1110_cfgstruct adin1110_port_privstruct adin1110_privstruct adin1110_switchdev_event_workenum adin1110_chips_idfunction adin1110_crc_datafunction adin1110_read_regfunction adin1110_write_regfunction adin1110_set_bitsfunction adin1110_round_lenfunction adin1110_read_fifofunction adin1110_write_fifofunction adin1110_read_mdio_accfunction adin1110_mdio_readfunction adin1110_mdio_writefunction adin1110_register_mdiobusfunction adin1110_port_rx_readyfunction adin1110_read_framesfunction adin1110_wake_queuesfunction adin1110_irqfunction adin1110_write_mac_addressfunction adin1110_clear_mac_addressfunction adin1110_port_rulesfunction adin1110_multicast_filterfunction adin1110_broadcasts_filterfunction adin1110_set_mac_addressfunction adin1110_ndo_set_mac_addressfunction adin1110_ioctlfunction adin1110_set_promisc_modefunction adin1110_setup_rx_modefunction adin1110_can_offload_forwardingfunction adin1110_rx_mode_workfunction adin1110_set_rx_modefunction adin1110_net_openfunction adin1110_net_stopfunction adin1110_tx_workfunction adin1110_start_xmitfunction adin1110_ndo_get_stats64function adin1110_port_get_port_parent_idfunction adin1110_ndo_get_phys_port_namefunction adin1110_get_drvinfofunction adin1110_adjust_linkfunction adin1110_check_spifunction adin1110_hw_forwardingfunction adin1110_port_bridge_joinfunction adin1110_port_bridge_leavefunction adin1110_port_dev_checkfunction adin1110_netdevice_event
Annotated Snippet
static const struct net_device_ops adin1110_netdev_ops = {
.ndo_open = adin1110_net_open,
.ndo_stop = adin1110_net_stop,
.ndo_eth_ioctl = adin1110_ioctl,
.ndo_start_xmit = adin1110_start_xmit,
.ndo_set_mac_address = adin1110_ndo_set_mac_address,
.ndo_set_rx_mode = adin1110_set_rx_mode,
.ndo_validate_addr = eth_validate_addr,
.ndo_get_stats64 = adin1110_ndo_get_stats64,
.ndo_get_port_parent_id = adin1110_port_get_port_parent_id,
.ndo_get_phys_port_name = adin1110_ndo_get_phys_port_name,
};
static void adin1110_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *di)
{
strscpy(di->driver, "ADIN1110", sizeof(di->driver));
strscpy(di->bus_info, dev_name(dev->dev.parent), sizeof(di->bus_info));
}
static const struct ethtool_ops adin1110_ethtool_ops = {
.get_drvinfo = adin1110_get_drvinfo,
.get_link = ethtool_op_get_link,
.get_link_ksettings = phy_ethtool_get_link_ksettings,
.set_link_ksettings = phy_ethtool_set_link_ksettings,
};
static void adin1110_adjust_link(struct net_device *dev)
{
struct phy_device *phydev = dev->phydev;
if (!phydev->link)
phy_print_status(phydev);
}
/* PHY ID is stored in the MAC registers too,
* check spi connection by reading it.
*/
static int adin1110_check_spi(struct adin1110_priv *priv)
{
struct gpio_desc *reset_gpio;
int ret;
u32 val;
reset_gpio = devm_gpiod_get_optional(&priv->spidev->dev, "reset",
GPIOD_OUT_LOW);
if (IS_ERR(reset_gpio))
return dev_err_probe(&priv->spidev->dev, PTR_ERR(reset_gpio),
"failed to get reset gpio\n");
if (reset_gpio) {
/* MISO pin is used for internal configuration, can't have
* anyone else disturbing the SDO line.
*/
spi_bus_lock(priv->spidev->controller);
gpiod_set_value(reset_gpio, 1);
fsleep(10000);
gpiod_set_value(reset_gpio, 0);
/* Need to wait 90 ms before interacting with
* the MAC after a HW reset.
*/
fsleep(90000);
spi_bus_unlock(priv->spidev->controller);
}
ret = adin1110_read_reg(priv, ADIN1110_PHY_ID, &val);
if (ret < 0)
return ret;
if (val != priv->cfg->phy_id_val) {
dev_err(&priv->spidev->dev, "PHY ID expected: %x, read: %x\n",
priv->cfg->phy_id_val, val);
return -EIO;
}
return 0;
}
static int adin1110_hw_forwarding(struct adin1110_priv *priv, bool enable)
{
int ret;
int i;
priv->forwarding = enable;
if (!priv->forwarding) {
for (i = ADIN_MAC_FDB_ADDR_SLOT; i < ADIN_MAC_MAX_ADDR_SLOTS; i++) {
ret = adin1110_clear_mac_address(priv, i);
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bits.h`, `linux/cache.h`, `linux/crc8.h`, `linux/etherdevice.h`, `linux/ethtool.h`, `linux/gpio/consumer.h`, `linux/if_bridge.h`.
- Detected declarations: `struct adin1110_cfg`, `struct adin1110_port_priv`, `struct adin1110_priv`, `struct adin1110_switchdev_event_work`, `enum adin1110_chips_id`, `function adin1110_crc_data`, `function adin1110_read_reg`, `function adin1110_write_reg`, `function adin1110_set_bits`, `function adin1110_round_len`.
- 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.