mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
Merge pull request #362 from bloqaudio/fix/v210-bank0
leds: move the SWTG018AS-V2.1.0 custom LED init to BANK2
This commit is contained in:
@@ -53,6 +53,7 @@ create_build_dir:
|
|||||||
# Keep machine.c in first position to fail immediately on invalid $MACHINE value
|
# Keep machine.c in first position to fail immediately on invalid $MACHINE value
|
||||||
SRCS = \
|
SRCS = \
|
||||||
machine.c \
|
machine.c \
|
||||||
|
machine_init.c \
|
||||||
cmd_editor.c \
|
cmd_editor.c \
|
||||||
cmd_parser.c \
|
cmd_parser.c \
|
||||||
dhcp.c \
|
dhcp.c \
|
||||||
@@ -142,6 +143,7 @@ machine_check:
|
|||||||
do \
|
do \
|
||||||
echo "Checking $${MACHINE}"; \
|
echo "Checking $${MACHINE}"; \
|
||||||
$(CC) $(CC_FLAGS) -DMACHINE_$${MACHINE} -MMD -o $(BUILDDIR)/tmp/machine_check -c machine.c; \
|
$(CC) $(CC_FLAGS) -DMACHINE_$${MACHINE} -MMD -o $(BUILDDIR)/tmp/machine_check -c machine.c; \
|
||||||
|
$(CC) $(CC_FLAGS) -DMACHINE_$${MACHINE} -MMD -o $(BUILDDIR)/tmp/machine_check -c machine_init.c; \
|
||||||
done
|
done
|
||||||
@rm -rf $(BUILDDIR)/tmp
|
@rm -rf $(BUILDDIR)/tmp
|
||||||
|
|
||||||
|
|||||||
@@ -42,8 +42,6 @@ __code const struct machine machine = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
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",
|
||||||
@@ -72,8 +70,6 @@ __code const struct machine machine = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
void machine_custom_init(void) { }
|
|
||||||
|
|
||||||
#elif defined MACHINE_KP_9000_6XH_X2
|
#elif defined MACHINE_KP_9000_6XH_X2
|
||||||
__code const struct machine machine = {
|
__code const struct machine machine = {
|
||||||
.machine_name = "keepLink KP-9000-6XH-X2",
|
.machine_name = "keepLink KP-9000-6XH-X2",
|
||||||
@@ -122,10 +118,6 @@ __code const struct machine machine = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
void machine_custom_init(void) {
|
|
||||||
reg_bit_set(RTL837X_REG_LED_GLB_IO_EN, 6);
|
|
||||||
}
|
|
||||||
|
|
||||||
#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-9XH-X-EU",
|
.machine_name = "keepLink KP-9000-9XH-X-EU",
|
||||||
@@ -151,8 +143,6 @@ __code const struct machine machine = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
void machine_custom_init(void) { }
|
|
||||||
|
|
||||||
#elif defined MACHINE_KP_9000_9XHML_X_V2_2
|
#elif defined MACHINE_KP_9000_9XHML_X_V2_2
|
||||||
__code const struct machine machine = {
|
__code const struct machine machine = {
|
||||||
.machine_name = "keepLink KP-9000-9XHML-X V2.2",
|
.machine_name = "keepLink KP-9000-9XHML-X V2.2",
|
||||||
@@ -204,8 +194,6 @@ __code const struct machine machine = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
void machine_custom_init(void) { }
|
|
||||||
|
|
||||||
#elif defined MACHINE_KP_9000_9XHML_X_V3_1
|
#elif defined MACHINE_KP_9000_9XHML_X_V3_1
|
||||||
__code const struct machine machine = {
|
__code const struct machine machine = {
|
||||||
.machine_name = "keepLink KP-9000-9XHML-X V3.1",
|
.machine_name = "keepLink KP-9000-9XHML-X V3.1",
|
||||||
@@ -241,8 +229,6 @@ __code const struct machine machine = {
|
|||||||
0x1a, 0x19, 0x1d, 0x1e, 0x1c, 0x1d, 0x20, 0x21},
|
0x1a, 0x19, 0x1d, 0x1e, 0x1c, 0x1d, 0x20, 0x21},
|
||||||
};
|
};
|
||||||
|
|
||||||
void machine_custom_init(void) { }
|
|
||||||
|
|
||||||
#elif defined MACHINE_SWGT024_V2_0_MANAGED
|
#elif defined MACHINE_SWGT024_V2_0_MANAGED
|
||||||
__code const struct machine machine = {
|
__code const struct machine machine = {
|
||||||
.machine_name = "SWGT024 V2.0 Managed",
|
.machine_name = "SWGT024 V2.0 Managed",
|
||||||
@@ -284,8 +270,6 @@ __code const struct machine machine = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
void machine_custom_init(void) { }
|
|
||||||
|
|
||||||
#elif defined MACHINE_SWGT024_V2_0_UNMANAGED
|
#elif defined MACHINE_SWGT024_V2_0_UNMANAGED
|
||||||
__code const struct machine machine = {
|
__code const struct machine machine = {
|
||||||
.machine_name = "SWGT024 V2.0 Unmanaged",
|
.machine_name = "SWGT024 V2.0 Unmanaged",
|
||||||
@@ -327,8 +311,6 @@ __code const struct machine machine = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
void machine_custom_init(void) { }
|
|
||||||
|
|
||||||
#elif defined MACHINE_SWTG018AS_A_V_2_0
|
#elif defined MACHINE_SWTG018AS_A_V_2_0
|
||||||
__code const struct machine machine = {
|
__code const struct machine machine = {
|
||||||
.machine_name = "SWTG018AS-A V2.0",
|
.machine_name = "SWTG018AS-A V2.0",
|
||||||
@@ -368,8 +350,6 @@ __code const struct machine machine = {
|
|||||||
0x1d, 0x20, 0x21 },
|
0x1d, 0x20, 0x21 },
|
||||||
};
|
};
|
||||||
|
|
||||||
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",
|
||||||
@@ -408,8 +388,6 @@ __code const struct machine machine = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
void machine_custom_init(void) { }
|
|
||||||
|
|
||||||
#elif defined MACHINE_SWTGW218AS
|
#elif defined MACHINE_SWTGW218AS
|
||||||
|
|
||||||
__code const struct machine machine = {
|
__code const struct machine machine = {
|
||||||
@@ -443,8 +421,6 @@ __code const struct machine machine = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
void machine_custom_init(void) { }
|
|
||||||
|
|
||||||
#elif defined MACHINE_PCB_SWTG018AS_V2_1_0 // Sold as Sodola SL902 / Horaco "SWTGW218AS"; the SWTGW218AS label also covers other PCBs with different SFP and LED wiring (see MACHINE_SWTGW218AS)
|
#elif defined MACHINE_PCB_SWTG018AS_V2_1_0 // Sold as Sodola SL902 / Horaco "SWTGW218AS"; the SWTGW218AS label also covers other PCBs with different SFP and LED wiring (see MACHINE_SWTGW218AS)
|
||||||
|
|
||||||
__code const struct machine machine = {
|
__code const struct machine machine = {
|
||||||
@@ -487,44 +463,6 @@ __code const struct machine machine = {
|
|||||||
0x1d, 0x20, 0x21 },
|
0x1d, 0x20, 0x21 },
|
||||||
};
|
};
|
||||||
|
|
||||||
// The LED-set encoding cannot express this board's bi-color SFP LED (green <= 2.5G,
|
|
||||||
// blue at 10G), so program the LED register block with the values the stock firmware
|
|
||||||
// uses. Runs after leds_setup() and overrides the values computed there.
|
|
||||||
// The final entry routes the blue-LED pin to the LED controller via PIN_MUX_0;
|
|
||||||
// as a GPIO (the default) no LED register can light it. PIN_MUX_1/2 stay
|
|
||||||
// untouched so SFP detect (GPIO38) and i2c remain GPIOs.
|
|
||||||
static __code const struct { uint16_t reg; uint32_t val; } custom_init_regs[] = {
|
|
||||||
{ 0x6520, 0x0023e430UL }, // LED_MODE
|
|
||||||
{ 0x6524, 0xff001400UL }, // LED3_0_SET3
|
|
||||||
{ 0x6528, 0x00100000UL }, // LED3_0_SET1
|
|
||||||
{ 0x652c, 0x007f013fUL }, // LED3_2_SET3
|
|
||||||
{ 0x6530, 0x02000400UL }, // LED1_0_SET3
|
|
||||||
{ 0x6534, 0x01400141UL }, // LED3_2_SET2
|
|
||||||
{ 0x6538, 0x01440170UL }, // LED1_0_SET2
|
|
||||||
{ 0x653c, 0x18000041UL }, // LED3_2_SET1
|
|
||||||
{ 0x6540, 0x01400155UL }, // LED1_0_SET1
|
|
||||||
{ 0x6544, 0x01411000UL }, // LED3_2_SET0
|
|
||||||
{ 0x6548, 0x01740141UL }, // LED1_0_SET0
|
|
||||||
{ 0x654c, 0x00010000UL }, // LED_PORT_SET_SEL
|
|
||||||
{ 0x65d8, 0x3ffb6dffUL }, // LED_GLB_ACTIVE
|
|
||||||
{ 0x65dc, 0x7f24977fUL }, // LED_GLB_IO_EN
|
|
||||||
{ 0x65e0, 0x08144040UL }, // LED_GLB_MUX_1
|
|
||||||
{ 0x65e4, 0x10349309UL }, // LED_GLB_MUX_2
|
|
||||||
{ 0x65e8, 0x12454391UL }, // LED_GLB_MUX_3
|
|
||||||
{ 0x65ec, 0x19616555UL }, // LED_GLB_MUX_4
|
|
||||||
{ 0x65f0, 0x1c79d65aUL }, // LED_GLB_MUX_5
|
|
||||||
{ 0x65f4, 0x0002181dUL }, // LED_GLB_MUX_6
|
|
||||||
{ 0x7f8c, 0x20db6880UL }, // PIN_MUX_0
|
|
||||||
};
|
|
||||||
|
|
||||||
void machine_custom_init(void) {
|
|
||||||
uint8_t i;
|
|
||||||
// REG_SET is a multi-statement macro without a do-while wrapper: braces required
|
|
||||||
for (i = 0; i < sizeof(custom_init_regs) / sizeof(custom_init_regs[0]); i++) {
|
|
||||||
REG_SET(custom_init_regs[i].reg, custom_init_regs[i].val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined MACHINE_LIANGUO_ZX_SWTGW215AS // Has PCB branded PCB-SWTG115AS-V2.0 but is labeled and reports as a ZX-SWTGW215AS, seems to be identical to the "real" ZX-SWTGW215AS except for the LEDs
|
#elif defined MACHINE_LIANGUO_ZX_SWTGW215AS // Has PCB branded PCB-SWTG115AS-V2.0 but is labeled and reports as a ZX-SWTGW215AS, seems to be identical to the "real" ZX-SWTGW215AS except for the LEDs
|
||||||
__code const struct machine machine = {
|
__code const struct machine machine = {
|
||||||
.machine_name = "Lianguo ZX-SWTGW215AS",
|
.machine_name = "Lianguo ZX-SWTGW215AS",
|
||||||
@@ -557,8 +495,6 @@ __code const struct machine machine = {
|
|||||||
.led_mux_custom = 0,
|
.led_mux_custom = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
void machine_custom_init(void) { }
|
|
||||||
|
|
||||||
#elif defined MACHINE_DEFAULT_8C_1SFP
|
#elif defined MACHINE_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",
|
||||||
@@ -584,8 +520,6 @@ __code const struct machine machine = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
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",
|
||||||
@@ -625,8 +559,6 @@ __code const struct machine machine = {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void machine_custom_init(void) { }
|
|
||||||
|
|
||||||
#elif defined(MACHINE_PCB_K0402WS_V3) || defined(MACHINE_HI_K0402WS) // Sold as a variety of devices, see doc/
|
#elif defined(MACHINE_PCB_K0402WS_V3) || defined(MACHINE_HI_K0402WS) // Sold as a variety of devices, see doc/
|
||||||
__code const struct machine machine = {
|
__code const struct machine machine = {
|
||||||
.machine_name = "PCB-K0402WS-V3.0",
|
.machine_name = "PCB-K0402WS-V3.0",
|
||||||
@@ -673,10 +605,6 @@ __code const struct machine machine = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
void machine_custom_init(void) {
|
|
||||||
reg_bit_set(RTL837X_REG_LED_GLB_IO_EN, 6);
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined MACHINE_K0501W_V2_0
|
#elif defined MACHINE_K0501W_V2_0
|
||||||
__code const struct machine machine = {
|
__code const struct machine machine = {
|
||||||
.machine_name = "K0501W V2.0",
|
.machine_name = "K0501W V2.0",
|
||||||
@@ -711,8 +639,6 @@ __code const struct machine machine = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
void machine_custom_init(void) { }
|
|
||||||
|
|
||||||
#elif defined MACHINE_ZX310S_4T2XH
|
#elif defined MACHINE_ZX310S_4T2XH
|
||||||
__code const struct machine machine = {
|
__code const struct machine machine = {
|
||||||
.machine_name = "ZX310S-4T2XH",
|
.machine_name = "ZX310S-4T2XH",
|
||||||
@@ -756,8 +682,6 @@ __code const struct machine machine = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
void machine_custom_init(void) { }
|
|
||||||
|
|
||||||
#elif defined MACHINE_STEAMEMO_IG204_V1
|
#elif defined MACHINE_STEAMEMO_IG204_V1
|
||||||
__code const struct machine machine = {
|
__code const struct machine machine = {
|
||||||
.machine_name = "Steamemo IG204 V1",
|
.machine_name = "Steamemo IG204 V1",
|
||||||
@@ -808,8 +732,6 @@ __code const struct machine machine = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
void machine_custom_init(void) { }
|
|
||||||
|
|
||||||
#elif defined MACHINE_HI_K0801WS
|
#elif defined MACHINE_HI_K0801WS
|
||||||
__code const struct machine machine = {
|
__code const struct machine machine = {
|
||||||
.machine_name = "Hi-Source HI-k0801WS",
|
.machine_name = "Hi-Source HI-k0801WS",
|
||||||
@@ -859,8 +781,6 @@ __code const struct machine machine = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
void machine_custom_init(void) { }
|
|
||||||
|
|
||||||
#elif defined MACHINE_FNS1200P
|
#elif defined MACHINE_FNS1200P
|
||||||
__code const struct machine machine = {
|
__code const struct machine machine = {
|
||||||
.machine_name = "FNS-1200P",
|
.machine_name = "FNS-1200P",
|
||||||
@@ -916,11 +836,6 @@ __code const struct machine machine = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
void machine_custom_init(void)
|
|
||||||
{
|
|
||||||
reg_bit_set(RTL837X_REG_LED_GLB_IO_EN, 6);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#elif defined MACHINE_PCB_SWTG024AS_A_2_0_1
|
#elif defined MACHINE_PCB_SWTG024AS_A_2_0_1
|
||||||
__code const struct machine machine = {
|
__code const struct machine machine = {
|
||||||
@@ -970,14 +885,6 @@ __code const struct machine machine = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
void machine_custom_init(void)
|
|
||||||
{
|
|
||||||
reg_bit_set(RTL837X_REG_LED_GLB_IO_EN, 6);
|
|
||||||
reg_bit_set(RTL837X_REG_LED_MODE, 17);
|
|
||||||
reg_bit_clear(RTL837X_REG_LED_MODE, 9);
|
|
||||||
reg_bit_clear(RTL837X_REG_LED_MODE, 7);
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined MACHINE_SWTG024AS_A_2_0_1_5C_1SFP
|
#elif defined MACHINE_SWTG024AS_A_2_0_1_5C_1SFP
|
||||||
__code const struct machine machine = {
|
__code const struct machine machine = {
|
||||||
.machine_name = "SWTG024AS-A-V2.0.1-5C-1SFP",
|
.machine_name = "SWTG024AS-A-V2.0.1-5C-1SFP",
|
||||||
@@ -1021,25 +928,6 @@ __code const struct machine machine = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
void machine_custom_init(void)
|
|
||||||
{
|
|
||||||
uint16_t pval;
|
|
||||||
|
|
||||||
reg_bit_set(RTL837X_REG_LED_GLB_IO_EN, 6);
|
|
||||||
reg_bit_set(RTL837X_REG_LED_MODE, 17);
|
|
||||||
reg_bit_clear(RTL837X_REG_LED_MODE, 9);
|
|
||||||
reg_bit_clear(RTL837X_REG_LED_MODE, 7);
|
|
||||||
|
|
||||||
// OEM firmware sets these companion SDS0 polarity bits for the RTL8221B.
|
|
||||||
sds_read(0, 0, 0);
|
|
||||||
pval = SFR_DATA_U16;
|
|
||||||
sds_write_v(0, 0, 0, pval | 0x100);
|
|
||||||
|
|
||||||
sds_read(0, 6, 2);
|
|
||||||
pval = SFR_DATA_U16;
|
|
||||||
sds_write_v(0, 6, 2, pval | 0x4000);
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined MACHINE_SWTG024AS_V2_0
|
#elif defined MACHINE_SWTG024AS_V2_0
|
||||||
__code const struct machine machine = {
|
__code const struct machine machine = {
|
||||||
.machine_name = "SWTG024AS-V2.0",
|
.machine_name = "SWTG024AS-V2.0",
|
||||||
@@ -1083,25 +971,6 @@ __code const struct machine machine = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
void machine_custom_init(void)
|
|
||||||
{
|
|
||||||
uint16_t pval;
|
|
||||||
|
|
||||||
reg_bit_set(RTL837X_REG_LED_GLB_IO_EN, 6);
|
|
||||||
reg_bit_set(RTL837X_REG_LED_MODE, 17);
|
|
||||||
reg_bit_clear(RTL837X_REG_LED_MODE, 9);
|
|
||||||
reg_bit_clear(RTL837X_REG_LED_MODE, 7);
|
|
||||||
|
|
||||||
// OEM firmware sets these companion SDS0 polarity bits for the RTL8221B.
|
|
||||||
sds_read(0, 0, 0);
|
|
||||||
pval = SFR_DATA_U16;
|
|
||||||
sds_write_v(0, 0, 0, pval | 0x100);
|
|
||||||
|
|
||||||
sds_read(0, 6, 2);
|
|
||||||
pval = SFR_DATA_U16;
|
|
||||||
sds_write_v(0, 6, 2, pval | 0x4000);
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined MACHINE_ZX310S_4T2XT
|
#elif defined MACHINE_ZX310S_4T2XT
|
||||||
__code const struct machine machine = {
|
__code const struct machine machine = {
|
||||||
.machine_name = "ZX310S_4T2XT",
|
.machine_name = "ZX310S_4T2XT",
|
||||||
@@ -1139,12 +1008,6 @@ __code const struct machine machine = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
void machine_custom_init(void) {
|
|
||||||
// For this device, the reset value of RTL837X_PIN_MUX_0 is 0x30000000,
|
|
||||||
// which would disables all LEDS, enable them manually:
|
|
||||||
REG_SET(RTL837X_PIN_MUX_0, 0x30db68bf);
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined MACHINE_FG_4GT_2SX_V2_0
|
#elif defined MACHINE_FG_4GT_2SX_V2_0
|
||||||
__code const struct machine machine = {
|
__code const struct machine machine = {
|
||||||
.machine_name = "FG-4GT-2SX_V2.0",
|
.machine_name = "FG-4GT-2SX_V2.0",
|
||||||
@@ -1211,10 +1074,6 @@ __code const struct machine machine = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
void machine_custom_init(void) {
|
|
||||||
REG_SET(RTL837X_REG_LED_GLB_IO_EN, 0x7624155b);
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error "Please select a machine type in machine.h"
|
#error "Please select a machine type in machine.h"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -95,6 +95,6 @@ typedef struct machine_runtime
|
|||||||
uint8_t isN : 1;
|
uint8_t isN : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
void machine_custom_init(void);
|
void machine_custom_init(void) __banked;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+120
@@ -0,0 +1,120 @@
|
|||||||
|
/*
|
||||||
|
* Per-machine one-shot boot hooks, hosted in BANK2 so board-specific
|
||||||
|
* tables and code do not consume the common bank.
|
||||||
|
*/
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "machine.h"
|
||||||
|
#include "rtl837x_pins.h"
|
||||||
|
#include "rtl837x_leds.h"
|
||||||
|
#include "rtl837x_sfr.h"
|
||||||
|
#include "rtl837x_regs.h"
|
||||||
|
#include "rtl837x_common.h"
|
||||||
|
|
||||||
|
#pragma codeseg BANK2
|
||||||
|
#pragma constseg BANK2
|
||||||
|
|
||||||
|
#if defined MACHINE_KP_9000_6XH_X2
|
||||||
|
void machine_custom_init(void) __banked
|
||||||
|
{
|
||||||
|
reg_bit_set(RTL837X_REG_LED_GLB_IO_EN, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined MACHINE_PCB_SWTG018AS_V2_1_0
|
||||||
|
// Stock-firmware values for what the LED-set encoding cannot express: the
|
||||||
|
// bi-color SFP LED (blue pin at 10G) and the PIN_MUX_0 routing of that pin
|
||||||
|
// to the LED controller. Runs after leds_setup(), which covers the rest.
|
||||||
|
static __code const struct { uint16_t reg; uint32_t val; } custom_init_regs[] = {
|
||||||
|
{ RTL837X_REG_LED3_0_SET1, 0x00100000UL },
|
||||||
|
{ RTL837X_REG_LED1_0_SET1, 0x01400155UL },
|
||||||
|
{ RTL837X_REG_LED1_0_SET0, 0x01740141UL },
|
||||||
|
{ RTL837X_REG_LED_GLB_IO_EN, 0x7f24977fUL },
|
||||||
|
{ RTL837X_PIN_MUX_0, 0x20db6880UL },
|
||||||
|
};
|
||||||
|
|
||||||
|
void machine_custom_init(void) __banked
|
||||||
|
{
|
||||||
|
uint8_t i;
|
||||||
|
// REG_SET is a multi-statement macro without a do-while wrapper: braces required
|
||||||
|
for (i = 0; i < sizeof(custom_init_regs) / sizeof(custom_init_regs[0]); i++) {
|
||||||
|
REG_SET(custom_init_regs[i].reg, custom_init_regs[i].val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(MACHINE_PCB_K0402WS_V3) || defined(MACHINE_HI_K0402WS)
|
||||||
|
void machine_custom_init(void) __banked
|
||||||
|
{
|
||||||
|
reg_bit_set(RTL837X_REG_LED_GLB_IO_EN, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined MACHINE_FNS1200P
|
||||||
|
void machine_custom_init(void) __banked
|
||||||
|
{
|
||||||
|
reg_bit_set(RTL837X_REG_LED_GLB_IO_EN, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined MACHINE_PCB_SWTG024AS_A_2_0_1
|
||||||
|
void machine_custom_init(void) __banked
|
||||||
|
{
|
||||||
|
reg_bit_set(RTL837X_REG_LED_GLB_IO_EN, 6);
|
||||||
|
reg_bit_set(RTL837X_REG_LED_MODE, 17);
|
||||||
|
reg_bit_clear(RTL837X_REG_LED_MODE, 9);
|
||||||
|
reg_bit_clear(RTL837X_REG_LED_MODE, 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined MACHINE_SWTG024AS_A_2_0_1_5C_1SFP
|
||||||
|
void machine_custom_init(void) __banked
|
||||||
|
{
|
||||||
|
uint16_t pval;
|
||||||
|
|
||||||
|
reg_bit_set(RTL837X_REG_LED_GLB_IO_EN, 6);
|
||||||
|
reg_bit_set(RTL837X_REG_LED_MODE, 17);
|
||||||
|
reg_bit_clear(RTL837X_REG_LED_MODE, 9);
|
||||||
|
reg_bit_clear(RTL837X_REG_LED_MODE, 7);
|
||||||
|
|
||||||
|
// OEM firmware sets these companion SDS0 polarity bits for the RTL8221B.
|
||||||
|
sds_read(0, 0, 0);
|
||||||
|
pval = SFR_DATA_U16;
|
||||||
|
sds_write_v(0, 0, 0, pval | 0x100);
|
||||||
|
|
||||||
|
sds_read(0, 6, 2);
|
||||||
|
pval = SFR_DATA_U16;
|
||||||
|
sds_write_v(0, 6, 2, pval | 0x4000);
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined MACHINE_SWTG024AS_V2_0
|
||||||
|
void machine_custom_init(void) __banked
|
||||||
|
{
|
||||||
|
uint16_t pval;
|
||||||
|
|
||||||
|
reg_bit_set(RTL837X_REG_LED_GLB_IO_EN, 6);
|
||||||
|
reg_bit_set(RTL837X_REG_LED_MODE, 17);
|
||||||
|
reg_bit_clear(RTL837X_REG_LED_MODE, 9);
|
||||||
|
reg_bit_clear(RTL837X_REG_LED_MODE, 7);
|
||||||
|
|
||||||
|
// OEM firmware sets these companion SDS0 polarity bits for the RTL8221B.
|
||||||
|
sds_read(0, 0, 0);
|
||||||
|
pval = SFR_DATA_U16;
|
||||||
|
sds_write_v(0, 0, 0, pval | 0x100);
|
||||||
|
|
||||||
|
sds_read(0, 6, 2);
|
||||||
|
pval = SFR_DATA_U16;
|
||||||
|
sds_write_v(0, 6, 2, pval | 0x4000);
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined MACHINE_ZX310S_4T2XT
|
||||||
|
void machine_custom_init(void) __banked
|
||||||
|
{
|
||||||
|
// For this device, the reset value of RTL837X_PIN_MUX_0 is 0x30000000,
|
||||||
|
// which would disables all LEDS, enable them manually:
|
||||||
|
REG_SET(RTL837X_PIN_MUX_0, 0x30db68bf);
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined MACHINE_FG_4GT_2SX_V2_0
|
||||||
|
void machine_custom_init(void) __banked
|
||||||
|
{
|
||||||
|
REG_SET(RTL837X_REG_LED_GLB_IO_EN, 0x7624155b);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
void machine_custom_init(void) __banked { }
|
||||||
|
#endif
|
||||||
@@ -14,6 +14,11 @@
|
|||||||
#include "uip.h"
|
#include "uip.h"
|
||||||
#include "machine.h"
|
#include "machine.h"
|
||||||
|
|
||||||
|
// All entry points are __banked and nothing here runs from an interrupt,
|
||||||
|
// so the module does not need to stay in the resident bank
|
||||||
|
#pragma codeseg BANK2
|
||||||
|
#pragma constseg BANK2
|
||||||
|
|
||||||
extern __code struct machine machine;
|
extern __code struct machine machine;
|
||||||
extern __xdata uint8_t sfr_data[4];
|
extern __xdata uint8_t sfr_data[4];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user