drivers/net/phy/realtek/realtek_main.c
Source file repositories/reference/linux-study-clean/drivers/net/phy/realtek/realtek_main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/phy/realtek/realtek_main.c- Extension
.c- Size
- 78685 bytes
- Lines
- 3015
- 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/bitops.hlinux/ethtool_netlink.hlinux/of.hlinux/phy.hlinux/pm_wakeirq.hlinux/netdevice.hlinux/module.hlinux/delay.hlinux/clk.hlinux/string_choices.hnet/phy/realtek_phy.h../phylib.hrealtek.h
Detected Declarations
struct rtl821x_privfunction rtl821x_read_pagefunction rtl821x_write_pagefunction rtl821x_read_ext_pagefunction rtl821x_modify_ext_pagefunction rtl821x_probefunction rtl8211f_probefunction phy_interrupt_is_validfunction rtl8201_ack_interruptfunction rtl821x_ack_interruptfunction rtl8211f_ack_interruptfunction rtl8201_config_intrfunction rtl8211b_config_intrfunction rtl8211e_config_intrfunction rtl8211f_config_intrfunction rtl8201_handle_interruptfunction rtl821x_handle_interruptfunction rtl8211f_handle_interruptfunction rtl8211f_get_wolfunction rtl8211f_set_wolfunction rtl8211_config_anegfunction rtl8211c_config_initfunction rtl8211f_config_rgmii_delayfunction rtl8211f_config_clk_outfunction rtl8211f_config_aldpsfunction rtl8211f_disable_autonomous_eeefunction rtl8211f_config_clkout_sscfunction rtl8211f_config_rxc_sscfunction rtl8211f_config_sysclk_sscfunction rtl8211f_config_initfunction rtl821x_suspendfunction rtl8211f_suspendfunction rtl821x_resumefunction rtl8211f_resumefunction rtl8211x_led_hw_is_supportedfunction rtl8211f_led_hw_control_getfunction rtl8211f_led_hw_control_setfunction rtl8211e_led_hw_control_getfunction rtl8211e_led_hw_control_setfunction rtl8211e_config_initfunction rtl8211b_suspendfunction rtl8211b_resumefunction rtl8366rb_config_initfunction rtlgen_decode_physrfunction rtlgen_read_statusfunction rtlgen_read_vend2function rtlgen_write_vend2function rtlgen_read_mmd
Annotated Snippet
struct rtl821x_priv {
bool enable_aldps;
bool disable_clk_out;
bool enable_clkout_ssc;
bool enable_rxc_ssc;
bool enable_sysclk_ssc;
struct clk *clk;
/* rtl8211f */
u16 iner;
};
static int rtl821x_read_page(struct phy_device *phydev)
{
return __phy_read(phydev, RTL821x_PAGE_SELECT);
}
static int rtl821x_write_page(struct phy_device *phydev, int page)
{
return __phy_write(phydev, RTL821x_PAGE_SELECT, page);
}
static int rtl821x_read_ext_page(struct phy_device *phydev, u16 ext_page,
u32 regnum)
{
int oldpage, ret = 0;
oldpage = phy_select_page(phydev, RTL821x_SET_EXT_PAGE);
if (oldpage >= 0) {
ret = __phy_write(phydev, RTL821x_EXT_PAGE_SELECT, ext_page);
if (ret == 0)
ret = __phy_read(phydev, regnum);
}
return phy_restore_page(phydev, oldpage, ret);
}
static int rtl821x_modify_ext_page(struct phy_device *phydev, u16 ext_page,
u32 regnum, u16 mask, u16 set)
{
int oldpage, ret = 0;
oldpage = phy_select_page(phydev, RTL821x_SET_EXT_PAGE);
if (oldpage >= 0) {
ret = __phy_write(phydev, RTL821x_EXT_PAGE_SELECT, ext_page);
if (ret == 0)
ret = __phy_modify(phydev, regnum, mask, set);
}
return phy_restore_page(phydev, oldpage, ret);
}
static int rtl821x_probe(struct phy_device *phydev)
{
struct device *dev = &phydev->mdio.dev;
struct rtl821x_priv *priv;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
priv->clk = devm_clk_get_optional_enabled(dev, NULL);
if (IS_ERR(priv->clk))
return dev_err_probe(dev, PTR_ERR(priv->clk),
"failed to get phy clock\n");
priv->enable_aldps = of_property_read_bool(dev->of_node,
"realtek,aldps-enable");
priv->disable_clk_out = of_property_read_bool(dev->of_node,
"realtek,clkout-disable");
priv->enable_clkout_ssc = of_property_read_bool(dev->of_node,
"realtek,clkout-ssc-enable");
priv->enable_rxc_ssc = of_property_read_bool(dev->of_node,
"realtek,rxc-ssc-enable");
priv->enable_sysclk_ssc = of_property_read_bool(dev->of_node,
"realtek,sysclk-ssc-enable");
phydev->priv = priv;
return 0;
}
static int rtl8211f_probe(struct phy_device *phydev)
{
struct device *dev = &phydev->mdio.dev;
int ret;
ret = rtl821x_probe(phydev);
if (ret < 0)
return ret;
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/ethtool_netlink.h`, `linux/of.h`, `linux/phy.h`, `linux/pm_wakeirq.h`, `linux/netdevice.h`, `linux/module.h`, `linux/delay.h`.
- Detected declarations: `struct rtl821x_priv`, `function rtl821x_read_page`, `function rtl821x_write_page`, `function rtl821x_read_ext_page`, `function rtl821x_modify_ext_page`, `function rtl821x_probe`, `function rtl8211f_probe`, `function phy_interrupt_is_valid`, `function rtl8201_ack_interrupt`, `function rtl821x_ack_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.