drivers/net/phy/marvell.c
Source file repositories/reference/linux-study-clean/drivers/net/phy/marvell.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/phy/marvell.c- Extension
.c- Size
- 107953 bytes
- Lines
- 4206
- 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/kernel.hlinux/string.hlinux/ctype.hlinux/errno.hlinux/unistd.hlinux/hwmon.hlinux/interrupt.hlinux/init.hlinux/delay.hlinux/netdevice.hlinux/etherdevice.hlinux/skbuff.hlinux/spinlock.hlinux/mm.hlinux/module.hlinux/mii.hlinux/ethtool.hlinux/ethtool_netlink.hlinux/phy.hlinux/phy_port.hlinux/marvell_phy.hlinux/bitfield.hlinux/of.hlinux/io.hasm/irq.hlinux/uaccess.h
Detected Declarations
struct marvell_hw_statstruct marvell_hw_stat_simplestruct marvell_privstruct marvell_hwmon_opsstruct marvell_led_rulesfunction marvell_read_pagefunction marvell_write_pagefunction marvell_set_pagefunction marvell_ack_interruptfunction marvell_config_intrfunction marvell_handle_interruptfunction marvell_set_polarityfunction marvell_config_anegfunction m88e1101_config_anegfunction marvell_of_reg_initfunction marvell_of_reg_initfunction m88e1121_config_aneg_rgmii_delaysfunction m88e1121_config_anegfunction m88e1318_config_anegfunction linkmode_adv_to_fiber_adv_tfunction marvell_config_aneg_fiberfunction m88e1111_inband_capsfunction m88e1111_config_inbandfunction m88e1111_config_anegfunction m88e1510_config_anegfunction marvell_config_ledfunction marvell_config_initfunction m88e3016_config_initfunction m88e1111_config_init_hwcfg_modefunction m88e1111_config_init_rgmii_delaysfunction m88e1111_config_init_rgmiifunction m88e1111_config_init_sgmiifunction m88e1111_config_init_rtbifunction m88e1111_config_init_1000basexfunction m88e1111_config_initfunction m88e1111_get_downshiftfunction m88e1111_set_downshiftfunction m88e1111_get_tunablefunction m88e1111_set_tunablefunction m88e1011_get_downshiftfunction m88e1011_set_downshiftfunction m88e1011_get_tunablefunction m88e1011_set_tunablefunction m88e1112_config_initfunction m88e1111gbe_config_initfunction marvell_1011gbe_config_initfunction m88e1116r_config_initfunction m88e1318_config_init
Annotated Snippet
struct marvell_hw_stat {
const char *string;
u8 page;
u8 reg;
u8 bits;
};
static const struct marvell_hw_stat marvell_hw_stats[] = {
{ "phy_receive_errors_copper", 0, 21, 16},
{ "phy_idle_errors", 0, 10, 8 },
{ "phy_receive_errors_fiber", 1, 21, 16},
};
static_assert(ARRAY_SIZE(marvell_hw_stats) <= NB_STAT_MAX);
/* "simple" stat list + corresponding marvell_get_*_simple functions are used
* on PHYs without a page register
*/
struct marvell_hw_stat_simple {
const char *string;
u8 reg;
u8 bits;
};
static const struct marvell_hw_stat_simple marvell_hw_stats_simple[] = {
{ "phy_receive_errors", 21, 16},
};
static_assert(ARRAY_SIZE(marvell_hw_stats_simple) <= NB_STAT_MAX);
enum {
M88E3082_VCT_OFF,
M88E3082_VCT_PHASE1,
M88E3082_VCT_PHASE2,
};
struct marvell_priv {
u64 stats[NB_STAT_MAX];
char *hwmon_name;
struct device *hwmon_dev;
bool cable_test_tdr;
u32 first;
u32 last;
u32 step;
s8 pair;
u8 vct_phase;
};
static int marvell_read_page(struct phy_device *phydev)
{
return __phy_read(phydev, MII_MARVELL_PHY_PAGE);
}
static int marvell_write_page(struct phy_device *phydev, int page)
{
return __phy_write(phydev, MII_MARVELL_PHY_PAGE, page);
}
static int marvell_set_page(struct phy_device *phydev, int page)
{
return phy_write(phydev, MII_MARVELL_PHY_PAGE, page);
}
static int marvell_ack_interrupt(struct phy_device *phydev)
{
int err;
/* Clear the interrupts by reading the reg */
err = phy_read(phydev, MII_M1011_IEVENT);
if (err < 0)
return err;
return 0;
}
static int marvell_config_intr(struct phy_device *phydev)
{
int err;
if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
err = marvell_ack_interrupt(phydev);
if (err)
return err;
err = phy_write(phydev, MII_M1011_IMASK,
MII_M1011_IMASK_INIT);
} else {
err = phy_write(phydev, MII_M1011_IMASK,
MII_M1011_IMASK_CLEAR);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/string.h`, `linux/ctype.h`, `linux/errno.h`, `linux/unistd.h`, `linux/hwmon.h`, `linux/interrupt.h`, `linux/init.h`.
- Detected declarations: `struct marvell_hw_stat`, `struct marvell_hw_stat_simple`, `struct marvell_priv`, `struct marvell_hwmon_ops`, `struct marvell_led_rules`, `function marvell_read_page`, `function marvell_write_page`, `function marvell_set_page`, `function marvell_ack_interrupt`, `function marvell_config_intr`.
- 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.