drivers/net/phy/air_en8811h.c

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

File Facts

System
Linux kernel
Corpus path
drivers/net/phy/air_en8811h.c
Extension
.c
Size
39883 bytes
Lines
1571
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 led {
	unsigned long rules;
	unsigned long state;
};

#define clk_hw_to_en8811h_priv(_hw)			\
	container_of(_hw, struct en8811h_priv, hw)

struct en8811h_priv {
	u32			firmware_version;
	bool			mcu_needs_restart;
	struct led		led[EN8811H_LED_COUNT];
	struct clk_hw		hw;
	struct phy_device	*phydev;
	unsigned int		cko_is_enabled;
	struct mdio_device	*pbusdev;
};

enum {
	AIR_PHY_LED_STATE_FORCE_ON,
	AIR_PHY_LED_STATE_FORCE_BLINK,
};

enum {
	AIR_PHY_LED_DUR_BLINK_32MS,
	AIR_PHY_LED_DUR_BLINK_64MS,
	AIR_PHY_LED_DUR_BLINK_128MS,
	AIR_PHY_LED_DUR_BLINK_256MS,
	AIR_PHY_LED_DUR_BLINK_512MS,
	AIR_PHY_LED_DUR_BLINK_1024MS,
};

enum {
	AIR_LED_DISABLE,
	AIR_LED_ENABLE,
};

enum {
	AIR_ACTIVE_LOW,
	AIR_ACTIVE_HIGH,
};

enum {
	AIR_LED_MODE_DISABLE,
	AIR_LED_MODE_USER_DEFINE,
};

#define AIR_PHY_LED_DUR_UNIT	1024
#define AIR_PHY_LED_DUR (AIR_PHY_LED_DUR_UNIT << AIR_PHY_LED_DUR_BLINK_64MS)

static const unsigned long en8811h_led_trig = BIT(TRIGGER_NETDEV_FULL_DUPLEX) |
					      BIT(TRIGGER_NETDEV_LINK)        |
					      BIT(TRIGGER_NETDEV_LINK_10)     |
					      BIT(TRIGGER_NETDEV_LINK_100)    |
					      BIT(TRIGGER_NETDEV_LINK_1000)   |
					      BIT(TRIGGER_NETDEV_LINK_2500)   |
					      BIT(TRIGGER_NETDEV_RX)          |
					      BIT(TRIGGER_NETDEV_TX);

static int __air_pbus_reg_write(struct mdio_device *mdiodev,
				u32 pbus_reg, u32 pbus_data)
{
	int ret;

	ret = __mdiobus_write(mdiodev->bus, mdiodev->addr, AIR_EXT_PAGE_ACCESS,
			      upper_16_bits(pbus_reg));
	if (ret < 0)
		return ret;

	ret = __mdiobus_write(mdiodev->bus, mdiodev->addr, AIR_PBUS_ADDR_HIGH,
			      FIELD_GET(AIR_PBUS_REG_ADDR_HIGH_MASK, pbus_reg));
	if (ret < 0)
		return ret;

	ret = __mdiobus_write(mdiodev->bus, mdiodev->addr,
			      FIELD_GET(AIR_PBUS_REG_ADDR_LOW_MASK, pbus_reg),
			      lower_16_bits(pbus_data));
	if (ret < 0)
		return ret;

	return __mdiobus_write(mdiodev->bus, mdiodev->addr, AIR_PBUS_DATA_HIGH,
			       upper_16_bits(pbus_data));
}

static int __air_write_buf(struct phy_device *phydev, u32 address,
			   const struct firmware *fw)
{
	unsigned int offset;
	int ret;
	u16 val;

Annotation

Implementation Notes