drivers/net/ethernet/freescale/fsl_pq_mdio.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/freescale/fsl_pq_mdio.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/freescale/fsl_pq_mdio.c- Extension
.c- Size
- 13975 bytes
- Lines
- 538
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/platform_device.hlinux/string.hlinux/errno.hlinux/slab.hlinux/delay.hlinux/module.hlinux/mii.hlinux/of.hlinux/of_address.hlinux/of_mdio.hlinux/property.hasm/io.hsoc/fsl/qe/ucc.hgianfar.h
Detected Declarations
struct fsl_pq_miistruct fsl_pq_mdiostruct fsl_pq_mdio_privstruct fsl_pq_mdio_datafunction fsl_pq_mdio_writefunction fsl_pq_mdio_readfunction fsl_pq_mdio_resetfunction registersfunction registersfunction registersfunction ucc_configurefunction for_each_compatible_nodefunction set_tbipafunction fsl_pq_mdio_probefunction fsl_pq_mdio_remove
Annotated Snippet
struct fsl_pq_mii {
u32 miimcfg; /* MII management configuration reg */
u32 miimcom; /* MII management command reg */
u32 miimadd; /* MII management address reg */
u32 miimcon; /* MII management control reg */
u32 miimstat; /* MII management status reg */
u32 miimind; /* MII management indication reg */
};
struct fsl_pq_mdio {
u8 res1[16];
u32 ieventm; /* MDIO Interrupt event register (for etsec2)*/
u32 imaskm; /* MDIO Interrupt mask register (for etsec2)*/
u8 res2[4];
u32 emapm; /* MDIO Event mapping register (for etsec2)*/
u8 res3[1280];
struct fsl_pq_mii mii;
u8 res4[28];
u32 utbipar; /* TBI phy address reg (only on UCC) */
u8 res5[2728];
} __packed;
/* Number of microseconds to wait for an MII register to respond */
#define MII_TIMEOUT 1000
struct fsl_pq_mdio_priv {
void __iomem *map;
struct fsl_pq_mii __iomem *regs;
};
/*
* Per-device-type data. Each type of device tree node that we support gets
* one of these.
*
* @mii_offset: the offset of the MII registers within the memory map of the
* node. Some nodes define only the MII registers, and some define the whole
* MAC (which includes the MII registers).
*
* @get_tbipa: determines the address of the TBIPA register
*
* @ucc_configure: a special function for extra QE configuration
*/
struct fsl_pq_mdio_data {
unsigned int mii_offset; /* offset of the MII registers */
uint32_t __iomem * (*get_tbipa)(void __iomem *p);
void (*ucc_configure)(phys_addr_t start, phys_addr_t end);
};
/*
* Write value to the PHY at mii_id at register regnum, on the bus attached
* to the local interface, which may be different from the generic mdio bus
* (tied to a single interface), waiting until the write is done before
* returning. This is helpful in programming interfaces like the TBI which
* control interfaces like onchip SERDES and are always tied to the local
* mdio pins, which may not be the same as system mdio bus, used for
* controlling the external PHYs, for example.
*/
static int fsl_pq_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
u16 value)
{
struct fsl_pq_mdio_priv *priv = bus->priv;
struct fsl_pq_mii __iomem *regs = priv->regs;
unsigned int timeout;
/* Set the PHY address and the register address we want to write */
iowrite32be((mii_id << 8) | regnum, ®s->miimadd);
/* Write out the value we want */
iowrite32be(value, ®s->miimcon);
/* Wait for the transaction to finish */
timeout = MII_TIMEOUT;
while ((ioread32be(®s->miimind) & MIIMIND_BUSY) && timeout) {
cpu_relax();
timeout--;
}
return timeout ? 0 : -ETIMEDOUT;
}
/*
* Read the bus for PHY at addr mii_id, register regnum, and return the value.
* Clears miimcom first.
*
* All PHY operation done on the bus attached to the local interface, which
* may be different from the generic mdio bus. This is helpful in programming
* interfaces like the TBI which, in turn, control interfaces like on-chip
* SERDES and are always tied to the local mdio pins, which may not be the
* same as system mdio bus, used for controlling the external PHYs, for eg.
*/
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/platform_device.h`, `linux/string.h`, `linux/errno.h`, `linux/slab.h`, `linux/delay.h`, `linux/module.h`, `linux/mii.h`.
- Detected declarations: `struct fsl_pq_mii`, `struct fsl_pq_mdio`, `struct fsl_pq_mdio_priv`, `struct fsl_pq_mdio_data`, `function fsl_pq_mdio_write`, `function fsl_pq_mdio_read`, `function fsl_pq_mdio_reset`, `function registers`, `function registers`, `function registers`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.