drivers/net/ethernet/freescale/xgmac_mdio.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/freescale/xgmac_mdio.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/freescale/xgmac_mdio.c- Extension
.c- Size
- 12497 bytes
- Lines
- 472
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/acpi.hlinux/acpi_mdio.hlinux/clk.hlinux/interrupt.hlinux/kernel.hlinux/mdio.hlinux/module.hlinux/of.hlinux/of_mdio.hlinux/phy.hlinux/platform_device.hlinux/slab.h
Detected Declarations
struct tgec_mdio_controllerstruct mdio_fsl_privfunction xgmac_read32function xgmac_write32function xgmac_wait_until_freefunction xgmac_wait_until_donefunction xgmac_mdio_write_c22function xgmac_mdio_write_c45function xgmac_mdio_read_c22function xgmac_mdio_read_c45function xgmac_mdio_set_mdc_freqfunction xgmac_mdio_set_suppress_preamblefunction xgmac_mdio_probe
Annotated Snippet
struct tgec_mdio_controller {
__be32 reserved[12];
__be32 mdio_stat; /* MDIO configuration and status */
__be32 mdio_ctl; /* MDIO control */
__be32 mdio_data; /* MDIO data */
__be32 mdio_addr; /* MDIO address */
} __packed;
#define MDIO_STAT_ENC BIT(6)
#define MDIO_STAT_CLKDIV(x) (((x) & 0x1ff) << 7)
#define MDIO_STAT_BSY BIT(0)
#define MDIO_STAT_RD_ER BIT(1)
#define MDIO_STAT_PRE_DIS BIT(5)
#define MDIO_CTL_DEV_ADDR(x) (x & 0x1f)
#define MDIO_CTL_PORT_ADDR(x) ((x & 0x1f) << 5)
#define MDIO_CTL_PRE_DIS BIT(10)
#define MDIO_CTL_SCAN_EN BIT(11)
#define MDIO_CTL_POST_INC BIT(14)
#define MDIO_CTL_READ BIT(15)
#define MDIO_DATA(x) (x & 0xffff)
struct mdio_fsl_priv {
struct tgec_mdio_controller __iomem *mdio_base;
struct clk *enet_clk;
u32 mdc_freq;
bool is_little_endian;
bool has_a009885;
bool has_a011043;
};
static u32 xgmac_read32(void __iomem *regs,
bool is_little_endian)
{
if (is_little_endian)
return ioread32(regs);
else
return ioread32be(regs);
}
static void xgmac_write32(u32 value,
void __iomem *regs,
bool is_little_endian)
{
if (is_little_endian)
iowrite32(value, regs);
else
iowrite32be(value, regs);
}
/*
* Wait until the MDIO bus is free
*/
static int xgmac_wait_until_free(struct device *dev,
struct tgec_mdio_controller __iomem *regs,
bool is_little_endian)
{
unsigned int timeout;
/* Wait till the bus is free */
timeout = TIMEOUT;
while ((xgmac_read32(®s->mdio_stat, is_little_endian) &
MDIO_STAT_BSY) && timeout) {
cpu_relax();
timeout--;
}
if (!timeout) {
dev_err(dev, "timeout waiting for bus to be free\n");
return -ETIMEDOUT;
}
return 0;
}
/*
* Wait till the MDIO read or write operation is complete
*/
static int xgmac_wait_until_done(struct device *dev,
struct tgec_mdio_controller __iomem *regs,
bool is_little_endian)
{
unsigned int timeout;
/* Wait till the MDIO write is complete */
timeout = TIMEOUT;
while ((xgmac_read32(®s->mdio_stat, is_little_endian) &
MDIO_STAT_BSY) && timeout) {
cpu_relax();
timeout--;
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/acpi_mdio.h`, `linux/clk.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/mdio.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `struct tgec_mdio_controller`, `struct mdio_fsl_priv`, `function xgmac_read32`, `function xgmac_write32`, `function xgmac_wait_until_free`, `function xgmac_wait_until_done`, `function xgmac_mdio_write_c22`, `function xgmac_mdio_write_c45`, `function xgmac_mdio_read_c22`, `function xgmac_mdio_read_c45`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
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.