drivers/net/phy/amd.c
Source file repositories/reference/linux-study-clean/drivers/net/phy/amd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/phy/amd.c- Extension
.c- Size
- 2653 bytes
- Lines
- 121
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/errno.hlinux/init.hlinux/module.hlinux/mii.hlinux/phy.h
Detected Declarations
function am79c_ack_interruptfunction am79c_config_initfunction am79c_config_intrfunction am79c_handle_interrupt
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* Driver for AMD am79c PHYs
*
* Author: Heiko Schocher <hs@denx.de>
*
* Copyright (c) 2011 DENX Software Engineering GmbH
*/
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/mii.h>
#include <linux/phy.h>
#define PHY_ID_AC101L 0x00225520
#define PHY_ID_AM79C874 0x0022561b
#define MII_AM79C_IR 17 /* Interrupt Status/Control Register */
#define MII_AM79C_IR_EN_LINK 0x0400 /* IR enable Linkstate */
#define MII_AM79C_IR_EN_ANEG 0x0100 /* IR enable Aneg Complete */
#define MII_AM79C_IR_IMASK_INIT (MII_AM79C_IR_EN_LINK | MII_AM79C_IR_EN_ANEG)
#define MII_AM79C_IR_LINK_DOWN BIT(2)
#define MII_AM79C_IR_ANEG_DONE BIT(0)
#define MII_AM79C_IR_IMASK_STAT (MII_AM79C_IR_LINK_DOWN | MII_AM79C_IR_ANEG_DONE)
MODULE_DESCRIPTION("AMD PHY driver");
MODULE_AUTHOR("Heiko Schocher <hs@denx.de>");
MODULE_LICENSE("GPL");
static int am79c_ack_interrupt(struct phy_device *phydev)
{
int err;
err = phy_read(phydev, MII_BMSR);
if (err < 0)
return err;
err = phy_read(phydev, MII_AM79C_IR);
if (err < 0)
return err;
return 0;
}
static int am79c_config_init(struct phy_device *phydev)
{
return 0;
}
static int am79c_config_intr(struct phy_device *phydev)
{
int err;
if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
err = am79c_ack_interrupt(phydev);
if (err)
return err;
err = phy_write(phydev, MII_AM79C_IR, MII_AM79C_IR_IMASK_INIT);
} else {
err = phy_write(phydev, MII_AM79C_IR, 0);
if (err)
return err;
err = am79c_ack_interrupt(phydev);
}
return err;
}
static irqreturn_t am79c_handle_interrupt(struct phy_device *phydev)
{
int irq_status;
irq_status = phy_read(phydev, MII_AM79C_IR);
if (irq_status < 0) {
phy_error(phydev);
return IRQ_NONE;
}
if (!(irq_status & MII_AM79C_IR_IMASK_STAT))
return IRQ_NONE;
phy_trigger_machine(phydev);
return IRQ_HANDLED;
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/errno.h`, `linux/init.h`, `linux/module.h`, `linux/mii.h`, `linux/phy.h`.
- Detected declarations: `function am79c_ack_interrupt`, `function am79c_config_init`, `function am79c_config_intr`, `function am79c_handle_interrupt`.
- 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.