mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
Add 10G/5G speed configuration/display
This commit is contained in:
+12
-4
@@ -77,14 +77,17 @@ void static sds_init(void)
|
|||||||
pval = SFR_DATA_U16;
|
pval = SFR_DATA_U16;
|
||||||
sds_write_v(0, 0, 0, pval | 0x200);
|
sds_write_v(0, 0, 0, pval | 0x200);
|
||||||
}
|
}
|
||||||
}
|
} else if (machine.n_10g == 1) {
|
||||||
if (machine.n_10g) {
|
|
||||||
reg_read_m(RTL837X_CFG_PHY_MDI_REVERSE);
|
reg_read_m(RTL837X_CFG_PHY_MDI_REVERSE);
|
||||||
sfr_mask_data(0, 0x0f,0x0c);
|
sfr_mask_data(0, 0x0f,0x0c);
|
||||||
reg_write_m(RTL837X_CFG_PHY_MDI_REVERSE);
|
reg_write_m(RTL837X_CFG_PHY_MDI_REVERSE);
|
||||||
REG_SET(RTL837X_CFG_PHY_TX_POLARITY_SWAP, 0x0000596a);
|
REG_SET(RTL837X_CFG_PHY_TX_POLARITY_SWAP, 0x0000596a);
|
||||||
|
} else if (machine.n_10g == 2) {
|
||||||
|
REG_SET(RTL837X_CFG_PHY_MDI_REVERSE, 0xc);
|
||||||
|
REG_SET(RTL837X_CFG_PHY_TX_POLARITY_SWAP, 0x0000596a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
print_string("\nsds_init done\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -190,15 +193,20 @@ void rtl8372_init(void)
|
|||||||
print_string("\nrtl8372_init called\n");
|
print_string("\nrtl8372_init called\n");
|
||||||
|
|
||||||
sds_init();
|
sds_init();
|
||||||
|
if (machine.n_10g != 2)
|
||||||
phy_config(8); // PHY configuration: External 8221B?
|
phy_config(8); // PHY configuration: External 8221B?
|
||||||
if (machine.n_10g)
|
if (machine.n_10g)
|
||||||
phy_config_8261(3);
|
phy_config_8261(3, 0);
|
||||||
|
if (machine.n_10g == 2)
|
||||||
|
phy_config_8261(8, 1);
|
||||||
else
|
else
|
||||||
phy_config(3); // PHY configuration: all internal PHYs?
|
phy_config(3); // PHY configuration: all internal PHYs?
|
||||||
// Set the MAC SerDes Modes Bits 0-4: SDS 0 = 0x2 (0x2), Bits 5-9: SDS 1: 1f (off)
|
// Set the MAC SerDes Modes Bits 0-4: SDS 0 = 0x2 (0x2), Bits 5-9: SDS 1: 1f (off)
|
||||||
// r7b20:00000bff R7b20-00000bff r7b20:00000bff R7b20-00000bff r7b20:00000bff R7b20-000003ff r7b20:000003ff R7b20-000003e2 r7b20:000003e2 R7b20-000003e2
|
// r7b20:00000bff R7b20-00000bff r7b20:00000bff R7b20-00000bff r7b20:00000bff R7b20-000003ff r7b20:000003ff R7b20-000003e2 r7b20:000003e2 R7b20-000003e2
|
||||||
if (machine.n_10g) {
|
if (machine.n_10g == 1) {
|
||||||
REG_SET(RTL837X_REG_SDS_MODES, 0x3ed); // Disable SFP for now, set RTL8261BE SDS 0 to 0xd
|
REG_SET(RTL837X_REG_SDS_MODES, 0x3ed); // Disable SFP for now, set RTL8261BE SDS 0 to 0xd
|
||||||
|
} else if(machine.n_10g == 2) {
|
||||||
|
REG_SET(RTL837X_REG_SDS_MODES, 0x1ad); // Both 10g ports use SDS_QXGMII
|
||||||
} else {
|
} else {
|
||||||
reg_read_m(RTL837X_REG_SDS_MODES);
|
reg_read_m(RTL837X_REG_SDS_MODES);
|
||||||
sfr_mask_data(1, 0, 0x03);
|
sfr_mask_data(1, 0, 0x03);
|
||||||
|
|||||||
+20
-1
@@ -263,6 +263,10 @@ void phy_set_speed(void) __banked
|
|||||||
uint16_t v;
|
uint16_t v;
|
||||||
|
|
||||||
print_string("Setting port "); write_char(machine.log_to_phys_port[phy_settings.port] + '0');
|
print_string("Setting port "); write_char(machine.log_to_phys_port[phy_settings.port] + '0');
|
||||||
|
if (machine.n_10g && phy_settings.port == 3)
|
||||||
|
phy_settings.is10g_port = 1;
|
||||||
|
if (machine.n_10g == 2 && phy_settings.port == 8)
|
||||||
|
phy_settings.is10g_port = 1;
|
||||||
if (phy_settings.speed == PHY_OFF) {
|
if (phy_settings.speed == PHY_OFF) {
|
||||||
print_string(" to disabled");
|
print_string(" to disabled");
|
||||||
} else {
|
} else {
|
||||||
@@ -270,6 +274,8 @@ void phy_set_speed(void) __banked
|
|||||||
switch(phy_settings.speed) {
|
switch(phy_settings.speed) {
|
||||||
case PHY_SPEED_AUTO:
|
case PHY_SPEED_AUTO:
|
||||||
print_string("auto");
|
print_string("auto");
|
||||||
|
if (phy_settings.is10g_port)
|
||||||
|
print_string (" (10g)");
|
||||||
break;
|
break;
|
||||||
case PHY_SPEED_10M:
|
case PHY_SPEED_10M:
|
||||||
print_string("10M");
|
print_string("10M");
|
||||||
@@ -316,7 +322,10 @@ void phy_set_speed(void) __banked
|
|||||||
// bit 14: SLAVE, bit 13: Multi-Port device, bit 8: 2.5GBit available, 1: LD
|
// bit 14: SLAVE, bit 13: Multi-Port device, bit 8: 2.5GBit available, 1: LD
|
||||||
phy_write(phy_settings.port, PHY_MMD_AN, PHY_ANEG_MGBASE_CTRL, 0x6081);
|
phy_write(phy_settings.port, PHY_MMD_AN, PHY_ANEG_MGBASE_CTRL, 0x6081);
|
||||||
// GBCR (1000Base-T Control Register, MMD 31.0xA412)
|
// GBCR (1000Base-T Control Register, MMD 31.0xA412)
|
||||||
phy_modify(phy_settings.port, PHY_MMD31, PHY_MMD31_GBCR, 0x0000, 0x0200); // Loop timing enabled
|
if (phy_settings.is10g_port)
|
||||||
|
phy_modify(phy_settings.port, PHY_MMD31, PHY_MMD31_GBCR, 0x0000, 0x0e00);
|
||||||
|
else
|
||||||
|
phy_modify(phy_settings.port, PHY_MMD31, PHY_MMD31_GBCR, 0x0000, 0x0200);
|
||||||
phy_write(phy_settings.port, PHY_MMD_AN, PHY_ANEG_CTRL, 0x3200); // Restart AN
|
phy_write(phy_settings.port, PHY_MMD_AN, PHY_ANEG_CTRL, 0x3200); // Restart AN
|
||||||
} else {
|
} else {
|
||||||
// AN Control Register (MMD 7.0x0000)
|
// AN Control Register (MMD 7.0x0000)
|
||||||
@@ -355,6 +364,12 @@ void phy_set_speed(void) __banked
|
|||||||
phy_write(phy_settings.port, PHY_MMD_AN, PHY_ANEG_MGBASE_CTRL, 0x6081);
|
phy_write(phy_settings.port, PHY_MMD_AN, PHY_ANEG_MGBASE_CTRL, 0x6081);
|
||||||
// GBCR (1000Base-T Control Register, MMD 31.0xA412)
|
// GBCR (1000Base-T Control Register, MMD 31.0xA412)
|
||||||
phy_modify(phy_settings.port, PHY_MMD31, PHY_MMD31_GBCR, 0x0200, 0x0000);
|
phy_modify(phy_settings.port, PHY_MMD31, PHY_MMD31_GBCR, 0x0200, 0x0000);
|
||||||
|
} else if (phy_settings.speed == PHY_SPEED_5G) {
|
||||||
|
phy_write(phy_settings.port, PHY_MMD_AN, PHY_ANEG_MGBASE_CTRL, 0x6081);
|
||||||
|
phy_modify(phy_settings.port, PHY_MMD31, PHY_MMD31_GBCR, 0x0400, 0x0000);
|
||||||
|
} else if (phy_settings.speed == PHY_SPEED_10G) {
|
||||||
|
phy_write(phy_settings.port, PHY_MMD_AN, PHY_ANEG_MGBASE_CTRL, 0x6081);
|
||||||
|
phy_modify(phy_settings.port, PHY_MMD31, PHY_MMD31_GBCR, 0x0800, 0x0000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
phy_write(phy_settings.port, PHY_MMD_AN, PHY_ANEG_CTRL, 0x3000); // Enable AN
|
phy_write(phy_settings.port, PHY_MMD_AN, PHY_ANEG_CTRL, 0x3000); // Enable AN
|
||||||
@@ -512,6 +527,10 @@ void phy_show(uint8_t port) __banked
|
|||||||
v = SFR_DATA_U16;
|
v = SFR_DATA_U16;
|
||||||
if (v & 0x0080)
|
if (v & 0x0080)
|
||||||
print_string(" 2500BaseN-Full");
|
print_string(" 2500BaseN-Full");
|
||||||
|
if (v & 0x0100)
|
||||||
|
print_string(" 5000BaseN-Full");
|
||||||
|
if (v & 0x1000)
|
||||||
|
print_string(" 10GBaseN-Full");
|
||||||
}
|
}
|
||||||
phy_read(port, PHY_MMD_AN, PHY_ANEG_LP_ABILITY);
|
phy_read(port, PHY_MMD_AN, PHY_ANEG_LP_ABILITY);
|
||||||
v = SFR_DATA_U16;
|
v = SFR_DATA_U16;
|
||||||
|
|||||||
Reference in New Issue
Block a user