icE1usb fw: Use green per-port LED to indicate alignment status

Whenever Rx is aligned, the green LED is permanently on.
Whenever Rx is not aligned, the green LED is blinking.

What's missing is to check for E1 clock ticks and turn the LED off
completely if there are no clock ticks.

Change-Id: I42d53544858dbbbae5206d9a62b08672966c9ebf
This commit is contained in:
Harald Welte 2020-12-15 18:35:42 +01:00 committed by laforge
parent 2df1f805a6
commit 5276567b24
4 changed files with 51 additions and 4 deletions

View File

@ -128,9 +128,17 @@ Found Runtime: [1d50:6145] ver=0003, devnum=44, cfg=1, intf=1, path="1-2", alt=0
=== Use of the E1 Interface LEDs
Each E1 interface has two LEDs integrated into the RJ45 connector.
Each E1 interface has two LEDs integrated into the RJ45 connector. They
are (starting to get) used by the firmware to indicate status
information to the user.
[options="header"]
|===
|Color | Pattern | Meaning
|Green | Blinking (slow) | E1 Receiver attempting to align
|Green | On | E1 Receiver fully aligned
|===
FIXME: describe how they are used.
=== Use of the Multi-Color RGB LED

View File

@ -412,10 +412,14 @@ e1_poll(void)
return;
/* HACK: LED link status */
if (e1_regs->rx.csr & E1_RX_SR_ALIGNED)
if (e1_regs->rx.csr & E1_RX_SR_ALIGNED) {
e1_platform_led_set(0, E1P_LED_GREEN, E1P_LED_ST_ON);
led_color(0, 48, 0);
else
} else {
e1_platform_led_set(0, E1P_LED_GREEN, E1P_LED_ST_BLINK);
/* TODO: completely off if rx tick counter not incrementing */
led_color(48, 0, 0);
}
/* Recover any done TX BD */
while ( (bd = e1_regs->tx.bd) & E1_BD_VALID ) {

View File

@ -13,3 +13,19 @@ void e1_debug_print(bool data);
volatile uint8_t *e1_data_ptr(int mf, int frame, int ts);
unsigned int e1_data_ofs(int mf, int frame, int ts);
enum e1_platform_led {
E1P_LED_GREEN = 0,
E1P_LED_YELLOW = 1,
};
enum e1_platform_led_state {
E1P_LED_ST_OFF = 0,
E1P_LED_ST_ON = 1,
E1P_LED_ST_BLINK = 2,
E1P_LED_ST_BLINK_FAST = 3
};
/* external function provided by the platform; used by E1 driver to control LEDs */
extern void e1_platform_led_set(uint8_t port, enum e1_platform_led led,
enum e1_platform_led_state state);

View File

@ -10,6 +10,7 @@
#include "config.h"
#include "misc.h"
#include "e1.h"
struct misc {
@ -51,6 +52,24 @@ e1_led_set(bool enable, uint8_t cfg)
misc_regs->e1_led = (enable ? 0x100 : 0x000) | cfg;
}
void
e1_platform_led_set(uint8_t port, enum e1_platform_led led,
enum e1_platform_led_state state)
{
uint32_t tmp;
unsigned int shift;
if (port >= 2)
return;
shift = 4*port + 2*led;
tmp = misc_regs->e1_led;
tmp &= ~(3 << shift);
tmp |= 0x100 | ((state & 3) << shift);
misc_regs->e1_led = tmp;
}
uint16_t
e1_tick_read(void)
{