drivers/net/phy/air_an8801.c

Source file repositories/reference/linux-study-clean/drivers/net/phy/air_an8801.c

File Facts

System
Linux kernel
Corpus path
drivers/net/phy/air_an8801.c
Extension
.c
Size
29837 bytes
Lines
1157
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

struct an8801r_priv {
	bool wake_magic_enabled;
	bool wake_lnkchg_enabled;
};

static const unsigned long an8801r_led_trig = BIT(TRIGGER_NETDEV_LINK) |
					      BIT(TRIGGER_NETDEV_LINK_10) |
					      BIT(TRIGGER_NETDEV_LINK_100) |
					      BIT(TRIGGER_NETDEV_LINK_1000) |
					      BIT(TRIGGER_NETDEV_RX) |
					      BIT(TRIGGER_NETDEV_RX_ERR) |
					      BIT(TRIGGER_NETDEV_TX);

static int an8801_buckpbus_reg_rmw(struct phy_device *phydev,
				   u32 addr, u32 mask, u32 set)
{
	return air_phy_buckpbus_reg_modify(phydev,
					   addr | AN8801_PBUS_ACCESS,
					   mask, set);
}

static int an8801_buckpbus_reg_set_bits(struct phy_device *phydev,
					u32 addr, u32 mask)
{
	return air_phy_buckpbus_reg_modify(phydev,
					   addr | AN8801_PBUS_ACCESS,
					   mask, mask);
}

static int an8801_buckpbus_reg_clear_bits(struct phy_device *phydev,
					  u32 addr, u32 mask)
{
	return air_phy_buckpbus_reg_modify(phydev,
					   addr | AN8801_PBUS_ACCESS,
					   mask, 0);
}

static int an8801_buckpbus_reg_write(struct phy_device *phydev, u32 addr,
				     u32 data)
{
	return air_phy_buckpbus_reg_write(phydev,
					  addr | AN8801_PBUS_ACCESS,
					  data);
}

static int an8801_buckpbus_reg_read(struct phy_device *phydev, u32 addr,
				    u32 *data)
{
	return air_phy_buckpbus_reg_read(phydev,
					 addr | AN8801_PBUS_ACCESS,
					 data);
}

static u32 an8801r_led_blink_ms_to_hw(unsigned long req_ms)
{
	u32 req_ns, regval;

	if (req_ms > AN8801_MAX_PERIOD_MS)
		req_ms = AN8801_MAX_PERIOD_MS;

	req_ns = req_ms * NSEC_PER_MSEC;

	/* Round to the nearest period unit... */
	regval = req_ns + (AN8801_PERIOD_UNIT / 2);

	/* ...and now divide by the full period */
	regval >>= AN8801_PERIOD_SHIFT;

	return regval;
}

static int an8801r_led_blink_set(struct phy_device *phydev, u8 index,
				 unsigned long *delay_on,
				 unsigned long *delay_off)
{
	u32 hw_delay_on, hw_delay_off;
	u16 blink_dur;
	bool blink;
	int ret;

	if (index >= AN8801R_NUM_LEDS)
		return -EINVAL;

	if (delay_on && delay_off) {
		blink = true;

		if (*delay_on == 0 || *delay_off == 0) {
			*delay_on = 64;
			*delay_off = 64;
		}

Annotation

Implementation Notes