drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c- Extension
.c- Size
- 17141 bytes
- Lines
- 679
- 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/gpio/machine.hlinux/gpio/driver.hlinux/gpio/property.hlinux/clk-provider.hlinux/clkdev.hlinux/i2c.hlinux/pci.hlinux/platform_device.hlinux/regmap.hlinux/pcs/pcs-xpcs.hlinux/phylink.h../libwx/wx_type.h../libwx/wx_lib.h../libwx/wx_ptp.h../libwx/wx_sriov.h../libwx/wx_mbx.h../libwx/wx_hw.htxgbe_type.htxgbe_aml.htxgbe_phy.htxgbe_hw.h
Detected Declarations
function txgbe_swnodes_registerfunction txgbe_pcs_readfunction txgbe_pcs_writefunction txgbe_mdio_pcs_initfunction txgbe_mac_configfunction txgbe_mac_link_upfunction txgbe_mac_preparefunction txgbe_mac_finishfunction txgbe_phylink_initfunction txgbe_link_irq_handlerfunction txgbe_gpio_getfunction txgbe_gpio_get_directionfunction txgbe_gpio_direction_infunction txgbe_gpio_direction_outfunction txgbe_gpio_initfunction txgbe_clock_registerfunction txgbe_i2c_readfunction txgbe_i2c_writefunction txgbe_i2c_registerfunction txgbe_sfp_registerfunction txgbe_ext_phy_initfunction txgbe_init_phyfunction txgbe_remove_phy
Annotated Snippet
if (ret) {
phylink_destroy(phylink);
return ret;
}
}
wx->phylink = phylink;
return 0;
}
irqreturn_t txgbe_link_irq_handler(int irq, void *data)
{
struct txgbe *txgbe = data;
struct wx *wx = txgbe->wx;
u32 status;
bool up;
status = rd32(wx, TXGBE_CFG_PORT_ST);
up = !!(status & TXGBE_CFG_PORT_ST_LINK_UP);
if (txgbe->pcs)
phylink_pcs_change(txgbe->pcs, up);
else
phylink_mac_change(wx->phylink, up);
return IRQ_HANDLED;
}
static int txgbe_gpio_get(struct gpio_chip *chip, unsigned int offset)
{
struct wx *wx = gpiochip_get_data(chip);
int val;
val = rd32m(wx, WX_GPIO_EXT, BIT(offset));
return !!(val & BIT(offset));
}
static int txgbe_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
{
struct wx *wx = gpiochip_get_data(chip);
u32 val;
val = rd32(wx, WX_GPIO_DDR);
if (BIT(offset) & val)
return GPIO_LINE_DIRECTION_OUT;
return GPIO_LINE_DIRECTION_IN;
}
static int txgbe_gpio_direction_in(struct gpio_chip *chip, unsigned int offset)
{
struct wx *wx = gpiochip_get_data(chip);
unsigned long flags;
raw_spin_lock_irqsave(&wx->gpio_lock, flags);
wr32m(wx, WX_GPIO_DDR, BIT(offset), 0);
raw_spin_unlock_irqrestore(&wx->gpio_lock, flags);
return 0;
}
static int txgbe_gpio_direction_out(struct gpio_chip *chip, unsigned int offset,
int val)
{
struct wx *wx = gpiochip_get_data(chip);
unsigned long flags;
u32 set;
set = val ? BIT(offset) : 0;
raw_spin_lock_irqsave(&wx->gpio_lock, flags);
wr32m(wx, WX_GPIO_DR, BIT(offset), set);
wr32m(wx, WX_GPIO_DDR, BIT(offset), BIT(offset));
raw_spin_unlock_irqrestore(&wx->gpio_lock, flags);
return 0;
}
static int txgbe_gpio_init(struct txgbe *txgbe)
{
struct gpio_chip *gc;
struct device *dev;
struct wx *wx;
int ret;
wx = txgbe->wx;
dev = &wx->pdev->dev;
Annotation
- Immediate include surface: `linux/gpio/machine.h`, `linux/gpio/driver.h`, `linux/gpio/property.h`, `linux/clk-provider.h`, `linux/clkdev.h`, `linux/i2c.h`, `linux/pci.h`, `linux/platform_device.h`.
- Detected declarations: `function txgbe_swnodes_register`, `function txgbe_pcs_read`, `function txgbe_pcs_write`, `function txgbe_mdio_pcs_init`, `function txgbe_mac_config`, `function txgbe_mac_link_up`, `function txgbe_mac_prepare`, `function txgbe_mac_finish`, `function txgbe_phylink_init`, `function txgbe_link_irq_handler`.
- 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.