drivers/net/phy/microchip_t1.c
Source file repositories/reference/linux-study-clean/drivers/net/phy/microchip_t1.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/phy/microchip_t1.c- Extension
.c- Size
- 60700 bytes
- Lines
- 2181
- 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.
- 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/kernel.hlinux/module.hlinux/delay.hlinux/mii.hlinux/phy.hlinux/sort.hlinux/ethtool.hlinux/ethtool_netlink.hlinux/bitfield.hmicrochip_rds_ptp.h
Detected Declarations
struct access_ereg_valstruct lan887x_hw_statstruct lan887x_regwr_mapstruct lan887x_privenum cable_diag_modeenum cable_diag_statefunction lan937x_dsp_workaroundfunction access_eregfunction access_ereg_modify_changedfunction access_smi_poll_timeoutfunction lan87xx_config_rgmii_delayfunction lan87xx_phy_init_cmdfunction lan87xx_phy_initfunction lan87xx_phy_config_intrfunction lan87xx_handle_interruptfunction lan87xx_config_initfunction microchip_cable_test_start_commonfunction lan87xx_cable_test_startfunction lan87xx_cable_test_report_transfunction lan87xx_cable_test_reportfunction lan87xx_cable_test_get_statusfunction lan87xx_read_statusfunction lan87xx_config_anegfunction lan87xx_get_sqifunction lan87xx_get_sqi_maxfunction lan887x_rgmii_initfunction lan887x_sgmii_initfunction lan887x_config_rgmii_enfunction lan887x_config_phy_interfacefunction lan887x_get_featuresfunction lan887x_phy_initfunction lan887x_phy_configfunction lan887x_phy_setupfunction lan887x_100M_setupfunction lan887x_1000M_setupfunction lan887x_link_setupfunction lan887x_phy_resetfunction lan887x_phy_reconfigfunction lan887x_config_anegfunction lan887x_probefunction lan887x_get_statfunction lan887x_get_statsfunction lan887x_get_sset_countfunction lan887x_get_stringsfunction lan887x_config_intrfunction lan887x_handle_interruptfunction lan887x_cd_resetfunction lan887x_cable_test_prep
Annotated Snippet
struct access_ereg_val {
u8 mode;
u8 bank;
u8 offset;
u16 val;
u16 mask;
};
struct lan887x_hw_stat {
const char *string;
u8 mmd;
u16 reg;
u8 bits;
};
static const struct lan887x_hw_stat lan887x_hw_stats[] = {
{ "TX Good Count", MDIO_MMD_VEND1, LAN887X_MIS_PKT_STAT_REG0, 14},
{ "RX Good Count", MDIO_MMD_VEND1, LAN887X_MIS_PKT_STAT_REG1, 14},
{ "RX ERR Count detected by PCS", MDIO_MMD_VEND1, LAN887X_MIS_PKT_STAT_REG3, 16},
{ "TX CRC ERR Count", MDIO_MMD_VEND1, LAN887X_MIS_PKT_STAT_REG4, 8},
{ "RX CRC ERR Count", MDIO_MMD_VEND1, LAN887X_MIS_PKT_STAT_REG5, 8},
{ "RX ERR Count for SGMII MII2GMII", MDIO_MMD_VEND1, LAN887X_MIS_PKT_STAT_REG6, 8},
};
struct lan887x_regwr_map {
u8 mmd;
u16 reg;
u16 val;
};
struct lan887x_priv {
u64 stats[ARRAY_SIZE(lan887x_hw_stats)];
struct mchp_rds_ptp_clock *clock;
bool init_done;
};
static int lan937x_dsp_workaround(struct phy_device *phydev, u16 ereg, u8 bank)
{
u8 prev_bank;
int rc = 0;
u16 val;
mutex_lock(&phydev->lock);
/* Read previous selected bank */
rc = phy_read(phydev, LAN87XX_EXT_REG_CTL);
if (rc < 0)
goto out_unlock;
/* store the prev_bank */
prev_bank = FIELD_GET(LAN87XX_REG_BANK_SEL_MASK, rc);
if (bank != prev_bank && bank == PHYACC_ATTR_BANK_DSP) {
val = ereg & ~LAN87XX_REG_ADDR_MASK;
val &= ~LAN87XX_EXT_REG_CTL_WR_CTL;
val |= LAN87XX_EXT_REG_CTL_RD_CTL;
/* access twice for DSP bank change,dummy access */
rc = phy_write(phydev, LAN87XX_EXT_REG_CTL, val);
}
out_unlock:
mutex_unlock(&phydev->lock);
return rc;
}
static int access_ereg(struct phy_device *phydev, u8 mode, u8 bank,
u8 offset, u16 val)
{
u16 ereg = 0;
int rc = 0;
if (mode > PHYACC_ATTR_MODE_WRITE || bank > PHYACC_ATTR_BANK_MAX)
return -EINVAL;
if (bank == PHYACC_ATTR_BANK_SMI) {
if (mode == PHYACC_ATTR_MODE_WRITE)
rc = phy_write(phydev, offset, val);
else
rc = phy_read(phydev, offset);
return rc;
}
if (mode == PHYACC_ATTR_MODE_WRITE) {
ereg = LAN87XX_EXT_REG_CTL_WR_CTL;
rc = phy_write(phydev, LAN87XX_EXT_REG_WR_DATA, val);
if (rc < 0)
return rc;
} else {
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/delay.h`, `linux/mii.h`, `linux/phy.h`, `linux/sort.h`, `linux/ethtool.h`, `linux/ethtool_netlink.h`.
- Detected declarations: `struct access_ereg_val`, `struct lan887x_hw_stat`, `struct lan887x_regwr_map`, `struct lan887x_priv`, `enum cable_diag_mode`, `enum cable_diag_state`, `function lan937x_dsp_workaround`, `function access_ereg`, `function access_ereg_modify_changed`, `function access_smi_poll_timeout`.
- 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.
- 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.