mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
Use generic led configuration
This commit is contained in:
@@ -57,7 +57,6 @@ __code const struct machine machine = {
|
|||||||
.sfp_port[0].pin_los = GPIO37,
|
.sfp_port[0].pin_los = GPIO37,
|
||||||
.sfp_port[0].pin_tx_disable = GPIO_NA,
|
.sfp_port[0].pin_tx_disable = GPIO_NA,
|
||||||
.sfp_port[0].sds = 1,
|
.sfp_port[0].sds = 1,
|
||||||
.sfp_port[0].i2c_bus = { .sda = 4, .scl = 3 },
|
|
||||||
.sfp_port[0].i2c = { .sda = GPIO39_I2C_SDA4, .scl = GPIO40_I2C_SCL3_MDC1 },
|
.sfp_port[0].i2c = { .sda = GPIO39_I2C_SDA4, .scl = GPIO40_I2C_SCL3_MDC1 },
|
||||||
.reset_pin = GPIO_NA,
|
.reset_pin = GPIO_NA,
|
||||||
/* Conditions for LED on:
|
/* Conditions for LED on:
|
||||||
|
|||||||
@@ -215,7 +215,6 @@ void leds_setup(void) __banked
|
|||||||
else
|
else
|
||||||
reg_bit_clear(RTL837X_REG_LED_GLB_IO_EN, 29);
|
reg_bit_clear(RTL837X_REG_LED_GLB_IO_EN, 29);
|
||||||
|
|
||||||
|
|
||||||
// Configure the LED-mux
|
// Configure the LED-mux
|
||||||
if (machine.led_mux_custom) {
|
if (machine.led_mux_custom) {
|
||||||
print_string("Configuring custom LED-muxes: ");
|
print_string("Configuring custom LED-muxes: ");
|
||||||
|
|||||||
+9
-134
@@ -1456,46 +1456,6 @@ void sds_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void led_config_9xh(void)
|
|
||||||
{
|
|
||||||
// r65d8:3ffbedff R65d8-3ffbedff
|
|
||||||
reg_bit_set(0x65d8, 0x1d);
|
|
||||||
|
|
||||||
// r6520:0021fdb0 R6520-0021e7b0 r6520:0021e7b0 R6520-0021e6b0
|
|
||||||
reg_read_m(RTL837X_REG_LED_MODE);
|
|
||||||
sfr_mask_data(1, 0x1f, 0x6);
|
|
||||||
sfr_mask_data(0, 0xe0, 0xa0);
|
|
||||||
reg_write_m(RTL837X_REG_LED_MODE);
|
|
||||||
|
|
||||||
// Set LED blink rate to slow during booting
|
|
||||||
set_sys_led_state(SYS_LED_SLOW);
|
|
||||||
|
|
||||||
// Disable RLDP (Realtek Loop Detection Protocol) LEDs on loop detection
|
|
||||||
reg_read_m(RTL837X_REG_LED_RLDP_1);
|
|
||||||
sfr_mask_data(0, 0, 0x3);
|
|
||||||
reg_write_m(RTL837X_REG_LED_RLDP_1);
|
|
||||||
// Configure LED group for RLDP per port
|
|
||||||
REG_SET(RTL837X_REG_LED_RLDP_2, 0xffffffff); // Ports 0-7
|
|
||||||
REG_SET(RTL837X_REG_LED_RLDP_3, 0x0000000f); // Port 8
|
|
||||||
|
|
||||||
reg_bit_set(RTL837X_REG_LED_GLB_IO_EN, 29);
|
|
||||||
reg_bit_clear(RTL837X_REG_LED_GLB_IO_EN, 27);
|
|
||||||
|
|
||||||
// GPIO 27 is LED
|
|
||||||
reg_bit_set(RTL837X_PIN_MUX_0, 27);
|
|
||||||
|
|
||||||
// Configure LED_SET_0, ledid 0/1
|
|
||||||
REG_SET(RTL837X_REG_LED1_0_SET0, 0x0041017f);
|
|
||||||
|
|
||||||
// Configure LED_SET_0 ledid 2
|
|
||||||
REG_SET(RTL837X_REG_LED3_2_SET0, 0x01410044);
|
|
||||||
|
|
||||||
// r6528:00000000 R6528-0000000f
|
|
||||||
reg_read_m(RTL837X_REG_LED3_0_SET1);
|
|
||||||
sfr_mask_data(0, 0x0f, 0x0f);
|
|
||||||
reg_write_m(RTL837X_REG_LED3_0_SET1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_sys_led_state(uint8_t state)
|
void set_sys_led_state(uint8_t state)
|
||||||
{
|
{
|
||||||
reg_read_m(RTL837X_REG_LED_MODE);
|
reg_read_m(RTL837X_REG_LED_MODE);
|
||||||
@@ -1503,94 +1463,6 @@ void set_sys_led_state(uint8_t state)
|
|||||||
reg_write_m(RTL837X_REG_LED_MODE);
|
reg_write_m(RTL837X_REG_LED_MODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef MACHINE_HG0402XG_V1_1
|
|
||||||
void led_config(void)
|
|
||||||
{
|
|
||||||
reg_read_m(RTL837X_REG_LED_MODE);
|
|
||||||
sfr_mask_data(2, 0xe0, 0x23); // Mask blink rate field (0xe0), set blink rate and LED to solid (set bit 1 = bit 17 overal
|
|
||||||
// Configure led-mode (serial?)
|
|
||||||
sfr_data[2] = 0xe6;
|
|
||||||
sfr_data[3] = 0xb0;
|
|
||||||
reg_write_m(RTL837X_REG_LED_MODE);
|
|
||||||
// Disable RLDP (Realtek Loop Detection Protocol) LEDs on loop detection
|
|
||||||
reg_read_m(RTL837X_REG_LED_RLDP_1);
|
|
||||||
sfr_mask_data(0, 0x03, 0);
|
|
||||||
reg_write_m(RTL837X_REG_LED_RLDP_1);
|
|
||||||
REG_SET(RTL837X_REG_LED_RLDP_2, 0xffff0000); // Ports 0-7 0x65fc
|
|
||||||
REG_SET(RTL837X_REG_LED_RLDP_3, 0x0000000f); // Port 8
|
|
||||||
|
|
||||||
reg_bit_set(RTL837X_REG_LED_GLB_IO_EN, 29);
|
|
||||||
reg_bit_clear(RTL837X_REG_LED_GLB_IO_EN, 27);
|
|
||||||
reg_bit_set(RTL837X_PIN_MUX_0, 29);
|
|
||||||
reg_bit_set(RTL837X_PIN_MUX_0, 27);
|
|
||||||
|
|
||||||
REG_SET(RTL837X_REG_LED1_0_SET0, 0x141); // 0x6548
|
|
||||||
reg_read_m(RTL837X_REG_LED3_2_SET0);
|
|
||||||
sfr_data[2] = 0x01;
|
|
||||||
sfr_data[3] = 0x74;
|
|
||||||
reg_write_m(RTL837X_REG_LED3_2_SET0);
|
|
||||||
reg_read_m(RTL837X_REG_LED1_0_SET1); // 6540
|
|
||||||
sfr_data[2] = 0x01;
|
|
||||||
sfr_data[3] = 0x7f;
|
|
||||||
reg_write_m(RTL837X_REG_LED1_0_SET1);
|
|
||||||
|
|
||||||
reg_read_m(RTL837X_REG_LED3_0_SET1);
|
|
||||||
sfr_data[1] |= 0x0f;
|
|
||||||
reg_write_m(RTL837X_REG_LED3_0_SET1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
void led_config(void)
|
|
||||||
{
|
|
||||||
// LED initialization
|
|
||||||
// r6520:0021fdb0 R6520-0021e7b0 r6520:0021e7b0 R6520-0021e6b0
|
|
||||||
reg_read_m(RTL837X_REG_LED_MODE);
|
|
||||||
sfr_mask_data(2, 0xe0, 0x23); // Mask blink rate field (0xe0), set blink rate and LED to solid (set bit 1 = bit 17 overall)
|
|
||||||
// Configure led-mode (serial?)
|
|
||||||
sfr_data[2] = 0xe6;
|
|
||||||
sfr_data[3] = 0xb0;
|
|
||||||
reg_write_m(RTL837X_REG_LED_MODE);
|
|
||||||
|
|
||||||
// Disable RLDP (Realtek Loop Detection Protocol) LEDs on loop detection
|
|
||||||
reg_read_m(RTL837X_REG_LED_RLDP_1);
|
|
||||||
sfr_mask_data(0, 0x03, 0);
|
|
||||||
reg_write_m(RTL837X_REG_LED_RLDP_1);
|
|
||||||
// Configure LED group for RLDP per port
|
|
||||||
REG_SET(RTL837X_REG_LED_RLDP_2, 0xffffffff); // Ports 0-7
|
|
||||||
REG_SET(RTL837X_REG_LED_RLDP_3, 0x0000000f); // Port 8
|
|
||||||
|
|
||||||
reg_bit_set(RTL837X_REG_LED_GLB_IO_EN, 29);
|
|
||||||
reg_bit_clear(RTL837X_REG_LED_GLB_IO_EN, 27);
|
|
||||||
|
|
||||||
// Configure GPIO for LEDs 27-29
|
|
||||||
if (machine.n_sfp == 2) {
|
|
||||||
reg_bit_set(RTL837X_PIN_MUX_0, 27);
|
|
||||||
reg_bit_clear(RTL837X_PIN_MUX_0, 28);
|
|
||||||
reg_bit_set(RTL837X_PIN_MUX_0, 29);
|
|
||||||
} else {
|
|
||||||
reg_bit_set(RTL837X_PIN_MUX_0, 27);
|
|
||||||
reg_bit_set(RTL837X_PIN_MUX_0, 28);
|
|
||||||
reg_bit_set(RTL837X_PIN_MUX_0, 29);
|
|
||||||
}
|
|
||||||
// LED setup
|
|
||||||
// r6520:0021fdb0 R6520-0021e7b0 r6520:0021e7b0 R6520-0021e6b0 r65f8:00000018 R65f8-00000018 R65fc-fffff000 r6600:00000000 R6600-0000000f r65dc:5fffff00 R65dc-7fffff00 r65dc:7fffff00 R65dc-77ffff00
|
|
||||||
// r7f8c:30000000 R7f8c-30000000 r7f8c:30000000 R7f8c-38000000 R6548-00410175 r6544:01411000 R6544-01410044 r6528:00000000 R6528-00000011
|
|
||||||
|
|
||||||
// Configure LED_SET_0, ledid 0/1
|
|
||||||
REG_SET(RTL837X_REG_LED1_0_SET0, 0x00410175);
|
|
||||||
|
|
||||||
// Configure led-sets 2 and 3
|
|
||||||
REG_SET(RTL837X_REG_LED3_2_SET0, 0x01410044);
|
|
||||||
|
|
||||||
// Further configure LED_SET_0
|
|
||||||
// r6528:00000000 R6528-00000011
|
|
||||||
reg_read_m(RTL837X_REG_LED3_0_SET1);
|
|
||||||
sfr_data[3] = 0x11;
|
|
||||||
reg_write_m(RTL837X_REG_LED3_0_SET1);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void rtl8373_revision(void)
|
void rtl8373_revision(void)
|
||||||
{
|
{
|
||||||
reg_read_m(RTL837X_REG_CHIP_INFO);
|
reg_read_m(RTL837X_REG_CHIP_INFO);
|
||||||
@@ -1609,7 +1481,9 @@ void rtl8373_init(void)
|
|||||||
{
|
{
|
||||||
print_string("\nrtl8373_init called\n");
|
print_string("\nrtl8373_init called\n");
|
||||||
|
|
||||||
led_config_9xh();
|
// r65d8:3ffbedff R65d8-3ffbedff
|
||||||
|
reg_bit_set(0x65d8, 0x1d);
|
||||||
|
|
||||||
sds_init();
|
sds_init();
|
||||||
// Disable all SERDES for configuration
|
// Disable all SERDES for configuration
|
||||||
REG_SET(RTL837X_REG_SDS_MODES, 0x000037ff);
|
REG_SET(RTL837X_REG_SDS_MODES, 0x000037ff);
|
||||||
@@ -1704,8 +1578,6 @@ void rtl8372_init(void)
|
|||||||
{
|
{
|
||||||
print_string("\nrtl8372_init called\n");
|
print_string("\nrtl8372_init called\n");
|
||||||
|
|
||||||
led_config();
|
|
||||||
|
|
||||||
sds_init();
|
sds_init();
|
||||||
phy_config(8); // PHY configuration: External 8221B?
|
phy_config(8); // PHY configuration: External 8221B?
|
||||||
phy_config(3); // PHY configuration: all internal PHYs?
|
phy_config(3); // PHY configuration: all internal PHYs?
|
||||||
@@ -2024,6 +1896,12 @@ void bootloader(void)
|
|||||||
init_smi();
|
init_smi();
|
||||||
|
|
||||||
rtl8373_revision();
|
rtl8373_revision();
|
||||||
|
|
||||||
|
leds_setup();
|
||||||
|
machine_custom_init();
|
||||||
|
|
||||||
|
leds_dump();
|
||||||
|
|
||||||
if (machine_detected.isRTL8373)
|
if (machine_detected.isRTL8373)
|
||||||
rtl8373_init();
|
rtl8373_init();
|
||||||
else
|
else
|
||||||
@@ -2034,7 +1912,6 @@ void bootloader(void)
|
|||||||
flash_region.addr = FIRMWARE_UPLOAD_START;
|
flash_region.addr = FIRMWARE_UPLOAD_START;
|
||||||
flash_region.len = 0x100;
|
flash_region.len = 0x100;
|
||||||
flash_read_bulk(flash_buf);
|
flash_read_bulk(flash_buf);
|
||||||
#ifndef MACHINE_HG0402XG_V1_1
|
|
||||||
if (flash_buf[0] == 0x00 && flash_buf[1] == 0x40) {
|
if (flash_buf[0] == 0x00 && flash_buf[1] == 0x40) {
|
||||||
__xdata uint32_t dest = 0x0;
|
__xdata uint32_t dest = 0x0;
|
||||||
__xdata uint32_t source = FIRMWARE_UPLOAD_START;
|
__xdata uint32_t source = FIRMWARE_UPLOAD_START;
|
||||||
@@ -2105,9 +1982,7 @@ void bootloader(void)
|
|||||||
dest += 0x1000;
|
dest += 0x1000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
set_sys_led_state(SYS_LED_SLOW);
|
set_sys_led_state(SYS_LED_SLOW);
|
||||||
leds_dump();
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
// This register seems to work on the RTL8373 only if also the SDS
|
// This register seems to work on the RTL8373 only if also the SDS
|
||||||
|
|||||||
Reference in New Issue
Block a user