mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
Add LED-pad mapping
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
#include "machine.h"
|
#include "machine.h"
|
||||||
#include "rtl837x_pins.h"
|
#include "rtl837x_pins.h"
|
||||||
#include "rtl837x_leds.h"
|
#include "rtl837x_leds.h"
|
||||||
|
#include "rtl837x_regs.h"
|
||||||
|
|
||||||
#ifdef MACHINE_KP_9000_6XHML_X2
|
#ifdef MACHINE_KP_9000_6XHML_X2
|
||||||
__code const struct machine machine = {
|
__code const struct machine machine = {
|
||||||
@@ -35,7 +36,13 @@ __code const struct machine machine = {
|
|||||||
LEDS_1G | LEDS_LINK,
|
LEDS_1G | LEDS_LINK,
|
||||||
0 },
|
0 },
|
||||||
},
|
},
|
||||||
|
.led_mux_custom = 1,
|
||||||
|
.led_mux = {0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x0f, 0x0c, 0x0d, 0x0e, 0x10, 0x11, 0x12, 0x14,
|
||||||
|
0x15, 0x16, 0x18, 0x19, 0x1a, 0x1c, 0x1d, 0x1e, 0x20, 0x21, 0x22, 0x23 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void machine_custom_init(void) { }
|
||||||
|
|
||||||
#elif defined MACHINE_KP_9000_6XH_X
|
#elif defined MACHINE_KP_9000_6XH_X
|
||||||
__code const struct machine machine = {
|
__code const struct machine machine = {
|
||||||
.machine_name = "keepLink KP-9000-6XH-X",
|
.machine_name = "keepLink KP-9000-6XH-X",
|
||||||
@@ -64,6 +71,9 @@ __code const struct machine machine = {
|
|||||||
0 },
|
0 },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void machine_custom_init(void) { }
|
||||||
|
|
||||||
#elif defined MACHINE_KP_9000_9XH_X_EU
|
#elif defined MACHINE_KP_9000_9XH_X_EU
|
||||||
__code const struct machine machine = {
|
__code const struct machine machine = {
|
||||||
.machine_name = "keepLink KP-9000-6XH-X-EU",
|
.machine_name = "keepLink KP-9000-6XH-X-EU",
|
||||||
@@ -89,6 +99,8 @@ __code const struct machine machine = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void machine_custom_init(void) { }
|
||||||
|
|
||||||
#elif defined MACHINE_SWGT024_V2_0
|
#elif defined MACHINE_SWGT024_V2_0
|
||||||
__code const struct machine machine = {
|
__code const struct machine machine = {
|
||||||
.machine_name = "SWGT024 V2.0",
|
.machine_name = "SWGT024 V2.0",
|
||||||
@@ -126,6 +138,8 @@ __code const struct machine machine = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void machine_custom_init(void) { }
|
||||||
|
|
||||||
#elif defined MACHINE_HG0402XG_V1_1
|
#elif defined MACHINE_HG0402XG_V1_1
|
||||||
__code const struct machine machine = {
|
__code const struct machine machine = {
|
||||||
.machine_name = "HG0402XG V1.1",
|
.machine_name = "HG0402XG V1.1",
|
||||||
@@ -164,6 +178,8 @@ __code const struct machine machine = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void machine_custom_init(void) { }
|
||||||
|
|
||||||
#elif defined DEFAULT_8C_1SFP
|
#elif defined DEFAULT_8C_1SFP
|
||||||
__code const struct machine machine = {
|
__code const struct machine machine = {
|
||||||
.machine_name = "8+1 SFP Port Switch",
|
.machine_name = "8+1 SFP Port Switch",
|
||||||
@@ -188,6 +204,9 @@ __code const struct machine machine = {
|
|||||||
LEDS_2G5 | LEDS_LINK | LEDS_ACT },
|
LEDS_2G5 | LEDS_LINK | LEDS_ACT },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void machine_custom_init(void) { }
|
||||||
|
|
||||||
#elif defined MACHINE_TRENDNET_TEG_S562
|
#elif defined MACHINE_TRENDNET_TEG_S562
|
||||||
__code const struct machine machine = {
|
__code const struct machine machine = {
|
||||||
.machine_name = "Trendnet TEG-S562",
|
.machine_name = "Trendnet TEG-S562",
|
||||||
@@ -210,4 +229,7 @@ __code const struct machine machine = {
|
|||||||
.sfp_port[1].i2c = { .sda = GPIO49_I2C_SDA1, .scl = GPIO48_I2C_SCL1 },
|
.sfp_port[1].i2c = { .sda = GPIO49_I2C_SDA1, .scl = GPIO48_I2C_SCL1 },
|
||||||
.reset_pin = GPIO_NA,
|
.reset_pin = GPIO_NA,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void machine_custom_init(void) { }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -59,6 +59,8 @@ typedef struct machine {
|
|||||||
struct high_leds high_leds;
|
struct high_leds high_leds;
|
||||||
uint8_t port_led_set[9];
|
uint8_t port_led_set[9];
|
||||||
uint32_t led_sets[4][4];
|
uint32_t led_sets[4][4];
|
||||||
|
uint8_t led_mux_custom;
|
||||||
|
uint8_t led_mux[28];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct machine_runtime
|
typedef struct machine_runtime
|
||||||
@@ -67,4 +69,6 @@ typedef struct machine_runtime
|
|||||||
uint8_t isN : 1;
|
uint8_t isN : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void machine_custom_init(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+71
-1
@@ -38,7 +38,42 @@ void leds_dump(void) __banked
|
|||||||
print_string("RTL837X_REG_LED3_0_SET1: "); print_reg(RTL837X_REG_LED3_0_SET1); 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_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("RTL837X_LED_PORT_SET_SEL: "); print_reg(RTL837X_LED_PORT_SET_SEL); write_char('\n');
|
||||||
print_string("LED Configuration:\n");
|
print_string("RTL837X_REG_LED_GLB_MUX_1: "); print_reg(RTL837X_REG_LED_GLB_MUX_1); write_char('\n');
|
||||||
|
print_string("RTL837X_REG_LED_GLB_MUX_2: "); print_reg(RTL837X_REG_LED_GLB_MUX_2); write_char('\n');
|
||||||
|
print_string("RTL837X_REG_LED_GLB_MUX_3: "); print_reg(RTL837X_REG_LED_GLB_MUX_3); write_char('\n');
|
||||||
|
print_string("RTL837X_REG_LED_GLB_MUX_4: "); print_reg(RTL837X_REG_LED_GLB_MUX_4); write_char('\n');
|
||||||
|
print_string("RTL837X_REG_LED_GLB_MUX_5: "); print_reg(RTL837X_REG_LED_GLB_MUX_5); write_char('\n');
|
||||||
|
print_string("RTL837X_REG_LED_GLB_MUX_6: "); print_reg(RTL837X_REG_LED_GLB_MUX_6); write_char('\n');
|
||||||
|
print_string("RTL837X_REG_LED_GLB_ACTIVE: "); print_reg(RTL837X_REG_LED_GLB_ACTIVE); write_char('\n');
|
||||||
|
print_string("LED pad Configuration:\n");
|
||||||
|
for (uint8_t i = 0; i < 28; i++) {
|
||||||
|
print_byte(i);
|
||||||
|
write_char(' ');
|
||||||
|
}
|
||||||
|
write_char('\n');
|
||||||
|
for (uint8_t i = 0; i < 28; i++) {
|
||||||
|
switch (i % 5) {
|
||||||
|
case 0: // 0
|
||||||
|
reg_read_m(RTL837X_REG_LED_GLB_MUX_1 + (i / 5) * 4);
|
||||||
|
print_byte(sfr_data[3] & 0x3f);
|
||||||
|
break;
|
||||||
|
case 1: // 6
|
||||||
|
print_byte(((sfr_data[3] >> 6) | (sfr_data[2] << 2)) & 0x3f);
|
||||||
|
break;
|
||||||
|
case 2: // 12
|
||||||
|
print_byte(((sfr_data[1] << 4) | (sfr_data[2] >> 4)) & 0x3f);
|
||||||
|
break;
|
||||||
|
case 3: // 18
|
||||||
|
print_byte((sfr_data[1] >> 2) & 0x3f);
|
||||||
|
break;
|
||||||
|
case 4: // 24
|
||||||
|
print_byte(sfr_data[0] & 0x3f);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
write_char(' ');
|
||||||
|
}
|
||||||
|
write_char('\n');
|
||||||
|
print_string("LED-set Configuration:\n");
|
||||||
print_string("LED-ID\t\t0\t\t1\t\t2\t\t3\n");
|
print_string("LED-ID\t\t0\t\t1\t\t2\t\t3\n");
|
||||||
for (__xdata uint8_t set = 0; set < 4; set++) {
|
for (__xdata uint8_t set = 0; set < 4; set++) {
|
||||||
print_string("SET "); write_char('0' + set); write_char(':');
|
print_string("SET "); write_char('0' + set); write_char(':');
|
||||||
@@ -181,6 +216,38 @@ void leds_setup(void) __banked
|
|||||||
reg_bit_clear(RTL837X_REG_LED_GLB_IO_EN, 29);
|
reg_bit_clear(RTL837X_REG_LED_GLB_IO_EN, 29);
|
||||||
|
|
||||||
|
|
||||||
|
// Configure the LED-mux
|
||||||
|
if (machine.led_mux_custom) {
|
||||||
|
print_string("Configuring custom LED-muxes: ");
|
||||||
|
for (uint8_t i = 0; i < 28; i++) {
|
||||||
|
switch (i % 5) {
|
||||||
|
case 0: // 0
|
||||||
|
sfr_data[3] = machine.led_mux[i];
|
||||||
|
break;
|
||||||
|
case 1: // 6
|
||||||
|
sfr_data[3] |= machine.led_mux[i] << 6;
|
||||||
|
sfr_data[2] = machine.led_mux[i] >> 2;
|
||||||
|
break;
|
||||||
|
case 2: // 12
|
||||||
|
sfr_data[2] |= machine.led_mux[i] << 4;
|
||||||
|
sfr_data[1] = machine.led_mux[i] >> 4;
|
||||||
|
break;
|
||||||
|
case 3: // 18
|
||||||
|
sfr_data[1] |= machine.led_mux[i] << 2;
|
||||||
|
break;
|
||||||
|
case 4: // 24
|
||||||
|
sfr_data[0] = machine.led_mux[i];
|
||||||
|
print_sfr_data(); write_char(' ');
|
||||||
|
reg_write_m(RTL837X_REG_LED_GLB_MUX_1 + (i / 5) * 4);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
write_char(' ');
|
||||||
|
}
|
||||||
|
sfr_data[0] = 0; sfr_data[1] &= 0xf;
|
||||||
|
print_sfr_data(); write_char('\n');
|
||||||
|
reg_write_m(RTL837X_REG_LED_GLB_MUX_6);
|
||||||
|
}
|
||||||
|
|
||||||
// Configure the LED-set of a port
|
// Configure the LED-set of a port
|
||||||
sfr_data[3] = sfr_data[2] = sfr_data[1] = sfr_data[0] = 0;
|
sfr_data[3] = sfr_data[2] = sfr_data[1] = sfr_data[0] = 0;
|
||||||
for (uint8_t i = machine.min_port; i <= machine.max_port; i++)
|
for (uint8_t i = machine.min_port; i <= machine.max_port; i++)
|
||||||
@@ -188,6 +255,9 @@ void leds_setup(void) __banked
|
|||||||
reg_write_m(RTL837X_LED_PORT_SET_SEL);
|
reg_write_m(RTL837X_LED_PORT_SET_SEL);
|
||||||
|
|
||||||
// Configure the LED-sets
|
// Configure the LED-sets
|
||||||
|
sfr_data[3] = sfr_data[2] = sfr_data[1] = sfr_data[0] = 0;
|
||||||
|
reg_write_m(RTL837X_REG_LED3_0_SET1);
|
||||||
|
reg_write_m(RTL837X_REG_LED3_0_SET3);
|
||||||
__code uint8_t * __xdata lptr = &machine.led_sets[0][0];
|
__code uint8_t * __xdata lptr = &machine.led_sets[0][0];
|
||||||
for (__xdata uint8_t set = 0; set < 4; set++) {
|
for (__xdata uint8_t set = 0; set < 4; set++) {
|
||||||
sfr_data[0] = *(lptr + 5);
|
sfr_data[0] = *(lptr + 5);
|
||||||
|
|||||||
@@ -22,6 +22,13 @@
|
|||||||
// BIT 17 set: LED solid on
|
// BIT 17 set: LED solid on
|
||||||
// Bytes 0/1 hold the LED mode, e.g. serial, RTL8231?
|
// Bytes 0/1 hold the LED mode, e.g. serial, RTL8231?
|
||||||
// Blink rate is defined by setAsicRegBits(0x6520,0xe00000,rate);
|
// Blink rate is defined by setAsicRegBits(0x6520,0xe00000,rate);
|
||||||
|
#define RTL837X_REG_LED_GLB_MUX_1 0x65E0
|
||||||
|
#define RTL837X_REG_LED_GLB_MUX_2 0x65E4
|
||||||
|
#define RTL837X_REG_LED_GLB_MUX_3 0x65E8
|
||||||
|
#define RTL837X_REG_LED_GLB_MUX_4 0x65EC
|
||||||
|
#define RTL837X_REG_LED_GLB_MUX_5 0x65F0
|
||||||
|
#define RTL837X_REG_LED_GLB_MUX_6 0x65F4
|
||||||
|
#define RTL837X_REG_LED_GLB_ACTIVE 0x65D8
|
||||||
#define RTL837X_REG_LED_GLB_IO_EN 0x65DC
|
#define RTL837X_REG_LED_GLB_IO_EN 0x65DC
|
||||||
#define RTL837X_REG_LED3_0_SET3 0x6524
|
#define RTL837X_REG_LED3_0_SET3 0x6524
|
||||||
#define RTL837X_REG_LED3_0_SET1 0x6528
|
#define RTL837X_REG_LED3_0_SET1 0x6528
|
||||||
|
|||||||
Reference in New Issue
Block a user