LED configuration support

This commit is contained in:
logicog
2026-02-08 20:23:30 +01:00
parent 7a57416e4c
commit 9424aa3a3b
5 changed files with 146 additions and 1 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ all: create_build_dir $(VERSION_HEADER) $(SUBDIRS) $(BUILDDIR)rtlplayground.bin
create_build_dir:
mkdir -p $(BUILDDIR)
SRCS = rtlplayground.c rtl837x_flash.c rtl837x_phy.c rtl837x_port.c cmd_parser.c html_data.c rtl837x_igmp.c rtl837x_stp.c rtl837x_pins.c dhcp.c machine.c
SRCS = rtlplayground.c rtl837x_flash.c rtl837x_leds.c rtl837x_phy.c rtl837x_port.c cmd_parser.c html_data.c rtl837x_igmp.c rtl837x_stp.c rtl837x_pins.c dhcp.c machine.c
OBJS = ${SRCS:%.c=$(BUILDDIR)%.rel}
OBJS += uip/$(BUILDDIR)/timer.rel uip/$(BUILDDIR)/uip-fw.rel uip/$(BUILDDIR)/uip-neighbor.rel uip/$(BUILDDIR)/uip-split.rel uip/$(BUILDDIR)/uip.rel uip/$(BUILDDIR)/uip_arp.rel uip/$(BUILDDIR)/uiplib.rel httpd/$(BUILDDIR)/httpd.rel httpd/$(BUILDDIR)/page_impl.rel
+130
View File
@@ -0,0 +1,130 @@
/*
* This is a driver implementation for the IGMP features for the RTL827x platform
* This code is in the Public Domain
*/
// #define REGDBG
// #define DEBUG
#define IPMC_USES_L3MC
#include <stdint.h>
#include "rtl837x_common.h"
#include "rtl837x_sfr.h"
#include "rtl837x_regs.h"
#include "rtl837x_leds.h"
#include "machine.h"
extern __code struct machine machine;
#include "uip.h"
#pragma codeseg BANK2
#pragma constseg BANK2
extern __xdata uint8_t sfr_data[4];
void leds_dump(void) __banked
{
print_string("RTL837X_REG_LED_GLB_IO_EN: "); print_reg(RTL837X_REG_LED_GLB_IO_EN); write_char('\n');
print_string("RTL837X_REG_LED1_0_SET0: "); print_reg(RTL837X_REG_LED1_0_SET0); write_char('\n');
print_string("RTL837X_REG_LED3_2_SET0: "); print_reg(RTL837X_REG_LED3_2_SET0); write_char('\n');
print_string("RTL837X_REG_LED1_0_SET1: "); print_reg(RTL837X_REG_LED1_0_SET1); write_char('\n');
print_string("RTL837X_REG_LED3_2_SET1: "); print_reg(RTL837X_REG_LED3_2_SET1); write_char('\n');
print_string("RTL837X_REG_LED1_0_SET2: "); print_reg(RTL837X_REG_LED1_0_SET2); write_char('\n');
print_string("RTL837X_REG_LED3_2_SET2: "); print_reg(RTL837X_REG_LED3_2_SET2); write_char('\n');
print_string("RTL837X_REG_LED1_0_SET3: "); print_reg(RTL837X_REG_LED1_0_SET3); write_char('\n');
print_string("RTL837X_REG_LED3_0_SET1: "); print_reg(RTL837X_REG_LED3_0_SET1); write_char('\n');
print_string("RTL837X_REG_LED3_0_SET3: "); print_reg(RTL837X_REG_LED3_0_SET3); write_char('\n');
print_string("RTL837X_LED_PORT_SET_SEL: "); print_reg(RTL837X_LED_PORT_SET_SEL); write_char('\n');
print_string("LED Configuration:\n");
print_string("LED-ID\t\t0\t\t1\t\t2\t\t3\n");
for (uint8_t set = 0; set < 4; set++) {
print_string("SET "); write_char('0' + set); write_char(':');
for (uint8_t ledid = 0; ledid < 4; ledid++) {
print_string("\t ");
uint8_t b;
if (set < 2) {
reg_read_m(RTL837X_REG_LED3_0_SET1);
b = sfr_data[3-((set << 1) + (ledid >> 1))];
print_byte(ledid & 1 ? b >> 4 : b & 0xf);
} else {
reg_read_m(RTL837X_REG_LED3_0_SET3);
b = sfr_data[3-(((set-2) << 1) + (ledid >> 1))];
print_byte(ledid & 1 ? b >> 4 : b & 0xf);
}
reg_read_m(RTL837X_REG_LED1_0_SET0 - set * 8 - ((ledid >> 1) * 4));
if (! (ledid & 1)) { // LEDID 0, 2
print_byte(sfr_data[2]); print_byte(sfr_data[3]);
} else {
print_byte(sfr_data[0]); print_byte(sfr_data[1]);
}
}
write_char('\n');
}
for (uint8_t i = machine.min_port; i <= machine.max_port; i++) {
reg_read_m(RTL837X_LED_PORT_SET_SEL);
uint8_t set = sfr_data[3 - (i >> 2)];
set = (set >> ((i & 3) << 1));
print_string("Port "); write_char('0' + i); print_string(": SET ");
write_char('0' + set);
print_string(": ");
for (uint8_t ledid = 0; ledid < 4; ledid++) {
write_char('(');
reg_read_m(RTL837X_REG_LED1_0_SET0 - set * 8 - ((ledid >> 1) * 4));
if (ledid & 1) { // LEDID 1, 3
sfr_data[2] = sfr_data[0];
sfr_data[3] = sfr_data[1];
}
if (sfr_data[3] & 0x01)
print_string(" 2G5");
if (sfr_data[3] & 0x02)
print_string(" TWO_1G");
if (sfr_data[3] & 0x04)
print_string(" 1G");
if (sfr_data[3] & 0x08)
print_string(" 500M");
if (sfr_data[3] & 0x10)
print_string(" 100M");
if (sfr_data[3] & 0x20)
print_string(" 10M");
if (sfr_data[3] & 0x40)
print_string(" LINK");
if (sfr_data[3] & 0x80)
print_string(" LINK_FLASH");
if (sfr_data[2] & 0x01)
print_string(" ACT");
if (sfr_data[2] & 0x02)
print_string(" RX");
if (sfr_data[2] & 0x04)
print_string(" TX");
if (sfr_data[2] & 0x00)
print_string(" COL");
if (sfr_data[2] & 0x10)
print_string(" DUPLEX");
if (sfr_data[2] & 0x20)
print_string(" TRAINING");
if (sfr_data[2] & 0x40)
print_string(" MASTER");
uint8_t b;
if (set < 2) {
reg_read_m(RTL837X_REG_LED3_0_SET1);
b = sfr_data[3-((set << 1) + (ledid >> 1))];
} else {
reg_read_m(RTL837X_REG_LED3_0_SET3);
b = sfr_data[3-(((set-2) << 1) + (ledid >> 1))];
}
b = ledid & 1 ? b >> 4 : b & 0xf;
if (b & 0x1)
print_string(" 10G");
if (b & 0x2)
print_string(" TWO_5G");
if (b & 0x4)
print_string(" 5G");
if (b & 0x8)
print_string(" TWO_2G5");
print_string("), ");
}
write_char('\n');
}
}
+7
View File
@@ -0,0 +1,7 @@
#ifndef _RTL837X_LEDS_H_
#define _RTL837X_LEDS_H_
#include <stdint.h>
void leds_dump(void) __banked;
#endif
+6
View File
@@ -23,10 +23,16 @@
// Bytes 0/1 hold the LED mode, e.g. serial, RTL8231?
// Blink rate is defined by setAsicRegBits(0x6520,0xe00000,rate);
#define RTL837X_REG_LED_GLB_IO_EN 0x65DC
#define RTL837X_REG_LED3_0_SET3 0x6524
#define RTL837X_REG_LED3_0_SET1 0x6528
#define RTL837X_REG_LED1_0_SET3 0x6530
#define RTL837X_REG_LED3_2_SET2 0x6534
#define RTL837X_REG_LED1_0_SET2 0x6538
#define RTL837X_REG_LED3_2_SET1 0x653C
#define RTL837X_REG_LED1_0_SET1 0x6540
#define RTL837X_REG_LED3_2_SET0 0x6544
#define RTL837X_REG_LED1_0_SET0 0x6548
#define RTL837X_LED_PORT_SET_SEL 0x654c
// SMI control
#define RTL837X_REG_SMI_PORT0_5_ADDR 0x644C
+2
View File
@@ -13,6 +13,7 @@
#include "rtl837x_port.h"
#include "rtl837x_stp.h"
#include "rtl837x_igmp.h"
#include "rtl837x_leds.h"
#include "dhcp.h"
#include "cmd_parser.h"
#include "uip/uipopt.h"
@@ -2104,6 +2105,7 @@ void bootloader(void)
}
#endif
set_sys_led_state(SYS_LED_SLOW);
leds_dump();
#ifdef DEBUG
// This register seems to work on the RTL8373 only if also the SDS