drivers/net/dsa/mv88e6xxx/pcs-639x.c
Source file repositories/reference/linux-study-clean/drivers/net/dsa/mv88e6xxx/pcs-639x.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/dsa/mv88e6xxx/pcs-639x.c- Extension
.c- Size
- 24287 bytes
- Lines
- 971
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/interrupt.hlinux/irqdomain.hlinux/mii.hlinux/string_choices.hchip.hglobal2.hphy.hport.hserdes.h
Detected Declarations
struct mv88e639x_pcsfunction mv88e639x_readfunction mv88e639x_writefunction mv88e639x_modifyfunction mv88e639x_modify_changedfunction mv88e639x_pcs_allocfunction mv88e639x_pcs_handle_irqfunction mv88e639x_pcs_setup_irqfunction mv88e639x_pcs_teardownfunction mv88e639x_sgmii_handle_irqfunction mv88e639x_sgmii_pcs_control_irqfunction mv88e639x_sgmii_pcs_control_pwrfunction mv88e639x_sgmii_pcs_enablefunction mv88e639x_sgmii_pcs_disablefunction mv88e639x_sgmii_pcs_pre_configfunction mv88e6390_erratum_3_14function mv88e639x_sgmii_pcs_post_configfunction mv88e639x_sgmii_pcs_get_statefunction mv88e639x_sgmii_pcs_configfunction mv88e639x_sgmii_pcs_an_restartfunction mv88e639x_sgmii_pcs_link_upfunction mv88e639x_xg_pcs_enablefunction mv88e639x_xg_pcs_disablefunction mv88e639x_xg_pcs_get_statefunction mv88e639x_xg_pcs_configfunction mv88e639x_pcs_selectfunction mv88e6390_xg_handle_irqfunction mv88e6390_xg_control_irqfunction mv88e6390_xg_pcs_enablefunction mv88e6390_xg_pcs_disablefunction mv88e6390_pcs_enable_checkerfunction mv88e6390_pcs_initfunction mv88e6393x_power_lanefunction mv88e6393x_erratum_4_6function mv88e6393x_erratum_4_8function mv88e6393x_erratum_5_2function mechanismfunction mv88e6393x_sgmii_apply_2500basex_anfunction mv88e6393x_sgmii_pcs_disablefunction mv88e6393x_sgmii_pcs_pre_configfunction mv88e6393x_sgmii_pcs_post_configfunction mv88e6393x_xg_handle_irqfunction mv88e6393x_xg_control_irqfunction mv88e6393x_xg_pcs_enablefunction mv88e6393x_xg_pcs_disablefunction mv88e6393x_xg_pcs_pre_configfunction mv88e6393x_xg_pcs_post_configfunction mv88e6393x_xg_pcs_get_state
Annotated Snippet
struct mv88e639x_pcs {
struct mdio_device mdio;
struct phylink_pcs sgmii_pcs;
struct phylink_pcs xg_pcs;
bool erratum_3_14;
bool supports_5g;
phy_interface_t interface;
unsigned int irq;
char name[64];
irqreturn_t (*handle_irq)(struct mv88e639x_pcs *mpcs);
};
static int mv88e639x_read(struct mv88e639x_pcs *mpcs, u16 regnum, u16 *val)
{
int err;
err = mdiodev_c45_read(&mpcs->mdio, MDIO_MMD_PHYXS, regnum);
if (err < 0)
return err;
*val = err;
return 0;
}
static int mv88e639x_write(struct mv88e639x_pcs *mpcs, u16 regnum, u16 val)
{
return mdiodev_c45_write(&mpcs->mdio, MDIO_MMD_PHYXS, regnum, val);
}
static int mv88e639x_modify(struct mv88e639x_pcs *mpcs, u16 regnum, u16 mask,
u16 val)
{
return mdiodev_c45_modify(&mpcs->mdio, MDIO_MMD_PHYXS, regnum, mask,
val);
}
static int mv88e639x_modify_changed(struct mv88e639x_pcs *mpcs, u16 regnum,
u16 mask, u16 set)
{
return mdiodev_c45_modify_changed(&mpcs->mdio, MDIO_MMD_PHYXS, regnum,
mask, set);
}
static struct mv88e639x_pcs *
mv88e639x_pcs_alloc(struct device *dev, struct mii_bus *bus, unsigned int addr,
int port)
{
struct mv88e639x_pcs *mpcs;
mpcs = kzalloc_obj(*mpcs);
if (!mpcs)
return NULL;
mpcs->mdio.dev.parent = dev;
mpcs->mdio.bus = bus;
mpcs->mdio.addr = addr;
snprintf(mpcs->name, sizeof(mpcs->name),
"mv88e6xxx-%s-serdes-%d", dev_name(dev), port);
return mpcs;
}
static irqreturn_t mv88e639x_pcs_handle_irq(int irq, void *dev_id)
{
struct mv88e639x_pcs *mpcs = dev_id;
irqreturn_t (*handler)(struct mv88e639x_pcs *);
handler = READ_ONCE(mpcs->handle_irq);
if (!handler)
return IRQ_NONE;
return handler(mpcs);
}
static int mv88e639x_pcs_setup_irq(struct mv88e639x_pcs *mpcs,
struct mv88e6xxx_chip *chip, int port)
{
unsigned int irq;
irq = mv88e6xxx_serdes_irq_mapping(chip, port);
if (!irq) {
/* Use polling mode */
mpcs->sgmii_pcs.poll = true;
mpcs->xg_pcs.poll = true;
return 0;
}
mpcs->irq = irq;
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/irqdomain.h`, `linux/mii.h`, `linux/string_choices.h`, `chip.h`, `global2.h`, `phy.h`, `port.h`.
- Detected declarations: `struct mv88e639x_pcs`, `function mv88e639x_read`, `function mv88e639x_write`, `function mv88e639x_modify`, `function mv88e639x_modify_changed`, `function mv88e639x_pcs_alloc`, `function mv88e639x_pcs_handle_irq`, `function mv88e639x_pcs_setup_irq`, `function mv88e639x_pcs_teardown`, `function mv88e639x_sgmii_handle_irq`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- 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.