drivers/net/dsa/mv88e6xxx/leds.c

Source file repositories/reference/linux-study-clean/drivers/net/dsa/mv88e6xxx/leds.c

File Facts

System
Linux kernel
Corpus path
drivers/net/dsa/mv88e6xxx/leds.c
Extension
.c
Size
22292 bytes
Lines
849
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 mv88e6xxx_led_hwconfig {
	int led;
	u8 portmask;
	unsigned long rules;
	bool fiber;
	bool blink_activity;
	u16 selector;
};

/* The following is a lookup table to check what rules we can support on a
 * certain LED given restrictions such as that some rules only work with fiber
 * (SFP) connections and some blink on activity by default.
 */
#define MV88E6XXX_PORTS_0_3 (BIT(0) | BIT(1) | BIT(2) | BIT(3))
#define MV88E6XXX_PORTS_4_5 (BIT(4) | BIT(5))
#define MV88E6XXX_PORT_4 BIT(4)
#define MV88E6XXX_PORT_5 BIT(5)

/* Entries are listed in selector order.
 *
 * These configurations vary across different switch families, list
 * different tables per-family here.
 */
static const struct mv88e6xxx_led_hwconfig mv88e6352_led_hwconfigs[] = {
	{
		.led = 0,
		.portmask = MV88E6XXX_PORT_4,
		.rules = BIT(TRIGGER_NETDEV_LINK),
		.blink_activity = true,
		.selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SEL0,
	},
	{
		.led = 1,
		.portmask = MV88E6XXX_PORT_5,
		.rules = BIT(TRIGGER_NETDEV_LINK_1000),
		.blink_activity = true,
		.selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL0,
	},
	{
		.led = 0,
		.portmask = MV88E6XXX_PORTS_0_3,
		.rules = BIT(TRIGGER_NETDEV_LINK_100) | BIT(TRIGGER_NETDEV_LINK_1000),
		.blink_activity = true,
		.selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SEL1,
	},
	{
		.led = 1,
		.portmask = MV88E6XXX_PORTS_0_3,
		.rules = BIT(TRIGGER_NETDEV_LINK_10) | BIT(TRIGGER_NETDEV_LINK_100),
		.blink_activity = true,
		.selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL1,
	},
	{
		.led = 0,
		.portmask = MV88E6XXX_PORTS_4_5,
		.rules = BIT(TRIGGER_NETDEV_LINK_100),
		.blink_activity = true,
		.fiber = true,
		.selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SEL1,
	},
	{
		.led = 1,
		.portmask = MV88E6XXX_PORTS_4_5,
		.rules = BIT(TRIGGER_NETDEV_LINK_1000),
		.blink_activity = true,
		.fiber = true,
		.selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL1,
	},
	{
		.led = 0,
		.portmask = MV88E6XXX_PORTS_0_3,
		.rules = BIT(TRIGGER_NETDEV_LINK_1000),
		.blink_activity = true,
		.selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SEL2,
	},
	{
		.led = 1,
		.portmask = MV88E6XXX_PORTS_0_3,
		.rules = BIT(TRIGGER_NETDEV_LINK_10) | BIT(TRIGGER_NETDEV_LINK_100),
		.blink_activity = true,
		.selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL2,
	},
	{
		.led = 0,
		.portmask = MV88E6XXX_PORTS_4_5,
		.rules = BIT(TRIGGER_NETDEV_LINK_1000),
		.blink_activity = true,
		.fiber = true,
		.selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SEL2,
	},

Annotation

Implementation Notes