Skip to content

Commit 86a80ea

Browse files
bwallanJeff Kirsher
authored andcommitted
e1000e: fix LED blink logic for designs with LEDs driven by cathode
When the LEDs are driven by cathode, the bit logic is reversed. Use the LED Invert bit to invert the logic. Cleanup use of a magic number and change the for loop increment to reduce the number of shifts. Signed-off-by: Bruce Allan <[email protected]> Tested-by: Jeff Pieper <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 772d05c commit 86a80ea

File tree

1 file changed

+20
-7
lines changed
  • drivers/net/ethernet/intel/e1000e

1 file changed

+20
-7
lines changed

drivers/net/ethernet/intel/e1000e/mac.c

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,15 +1600,28 @@ s32 e1000e_blink_led_generic(struct e1000_hw *hw)
16001600
ledctl_blink = E1000_LEDCTL_LED0_BLINK |
16011601
(E1000_LEDCTL_MODE_LED_ON << E1000_LEDCTL_LED0_MODE_SHIFT);
16021602
} else {
1603-
/* set the blink bit for each LED that's "on" (0x0E)
1604-
* in ledctl_mode2
1603+
/* Set the blink bit for each LED that's "on" (0x0E)
1604+
* (or "off" if inverted) in ledctl_mode2. The blink
1605+
* logic in hardware only works when mode is set to "on"
1606+
* so it must be changed accordingly when the mode is
1607+
* "off" and inverted.
16051608
*/
16061609
ledctl_blink = hw->mac.ledctl_mode2;
1607-
for (i = 0; i < 4; i++)
1608-
if (((hw->mac.ledctl_mode2 >> (i * 8)) & 0xFF) ==
1609-
E1000_LEDCTL_MODE_LED_ON)
1610-
ledctl_blink |= (E1000_LEDCTL_LED0_BLINK <<
1611-
(i * 8));
1610+
for (i = 0; i < 32; i += 8) {
1611+
u32 mode = (hw->mac.ledctl_mode2 >> i) &
1612+
E1000_LEDCTL_LED0_MODE_MASK;
1613+
u32 led_default = hw->mac.ledctl_default >> i;
1614+
1615+
if ((!(led_default & E1000_LEDCTL_LED0_IVRT) &&
1616+
(mode == E1000_LEDCTL_MODE_LED_ON)) ||
1617+
((led_default & E1000_LEDCTL_LED0_IVRT) &&
1618+
(mode == E1000_LEDCTL_MODE_LED_OFF))) {
1619+
ledctl_blink &=
1620+
~(E1000_LEDCTL_LED0_MODE_MASK << i);
1621+
ledctl_blink |= (E1000_LEDCTL_LED0_BLINK |
1622+
E1000_LEDCTL_MODE_LED_ON) << i;
1623+
}
1624+
}
16121625
}
16131626

16141627
ew32(LEDCTL, ledctl_blink);

0 commit comments

Comments
 (0)