summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-07-14 09:31:26 -0400
committerIan Moffett <ian@osmora.org>2025-07-14 09:31:26 -0400
commitaf7ca08dbdfcd1ce8f4a320db09d29919ca3c682 (patch)
tree546403b0abd2de39e9a53abe1b9536535961dc31 /sys
parent73b1b60e924908479f8b2bd424da0a4f78e07a3c (diff)
kernel: phy: Give more control over LED state
Allow finer control over which LEDs to toggle and how they should be toggled. Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/phy/et131x.c10
-rw-r--r--sys/include/dev/phy/et131xregs.h19
2 files changed, 24 insertions, 5 deletions
diff --git a/sys/dev/phy/et131x.c b/sys/dev/phy/et131x.c
index c6c588c..52fac6c 100644
--- a/sys/dev/phy/et131x.c
+++ b/sys/dev/phy/et131x.c
@@ -162,7 +162,7 @@ et131x_init_pci(void)
}
/*
- * Blink the LED of the card
+ * Blink both LEDs of the card
*
* @io: Register space
* @count: Number of times to blink
@@ -171,10 +171,14 @@ et131x_init_pci(void)
static void
et131x_blink(struct et131x_iospace *io, uint32_t count, uint16_t delay)
{
+ uint16_t on_val;
+
+ on_val = (LED_ON << LED_LINK_SHIFT);
+ on_val |= (LED_ON << LED_TXRX_SHIFT);
for (uint32_t i = 0; i < count; ++i) {
- et131x_mii_write(io, 0, PHY_LED2, LED_ON);
+ et131x_mii_write(io, 0, PHY_LED2, on_val);
tmr.msleep(delay);
- et131x_mii_write(io, 0, PHY_LED2, LED_OFF);
+ et131x_mii_write(io, 0, PHY_LED2, LED_ALL_OFF);
tmr.msleep(delay);
}
}
diff --git a/sys/include/dev/phy/et131xregs.h b/sys/include/dev/phy/et131xregs.h
index 54b81c0..0e05c94 100644
--- a/sys/include/dev/phy/et131xregs.h
+++ b/sys/include/dev/phy/et131xregs.h
@@ -228,9 +228,24 @@ struct mac_regs {
/* LED register defines */
#define PHY_LED2 0x1C
-/* LED control register 2 values */
+/*
+ * LED control register 2 values
+ */
+#define LED_BLINK 0xD
#define LED_ON 0xE
-#define LED_OFF 0xFFFF
+#define LED_OFF 0xF
+#define LED_ALL_OFF 0xFFFF
+
+/*
+ * LED register bit-shift constants
+ *
+ * Bits [3:0]: 100BASE-T LED
+ * Bits [7:4]: 100BASE-TX LED
+ * Bits [11:8]: TX/RX LED
+ * Bits [15:12]: Link LED
+ */
+#define LED_TXRX_SHIFT 8
+#define LED_LINK_SHIFT 12
struct et131x_iospace {