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.

Dependency Surface

Detected Declarations

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

Implementation Notes