Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F178162093
D62213.1796157128.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
7 KB
Referenced Files
None
Subscribers
None
D62213.1796157128.diff
View Options
Index: sys/dev/rge/if_rge.c
===================================================================
--- sys/dev/rge/if_rge.c
+++ sys/dev/rge/if_rge.c
@@ -455,6 +455,10 @@
sc->rge_type = MAC_R27;
device_printf(dev, "chip rev: RTL8127 (0x%08x)\n", hwrev);
break;
+ case 0x70800000:
+ sc->rge_type = MAC_R25CP;
+ device_printf(dev, "chip rev: RTL8125CP (0x%08x)\n", hwrev);
+ break;
default:
RGE_PRINT_ERROR(sc, "unknown version 0x%08x\n", hwrev);
goto fail;
@@ -695,8 +699,19 @@
mbufq_init(&rx_mq, RGE_RX_LIST_CNT);
- if ((if_getdrvflags(sc->sc_ifp) & IFF_DRV_RUNNING) == 0)
+ if ((if_getdrvflags(sc->sc_ifp) & IFF_DRV_RUNNING) == 0) {
+ /*
+ * RTL8125CP uses the v2 interrupt status block (0xd04/0xd14,
+ * W1C); acknowledge both it and the legacy ISR so an early
+ * interrupt cannot keep re-firing before init.
+ */
+ if (RGE_TYPE_R25CP(sc)) {
+ RGE_WRITE_4(sc, 0xd04, RGE_READ_4(sc, 0xd04));
+ RGE_WRITE_4(sc, 0xd14, RGE_READ_4(sc, 0xd14));
+ RGE_WRITE_4(sc, RGE_ISR, RGE_READ_4(sc, RGE_ISR));
+ }
return;
+ }
RGE_LOCK(sc);
@@ -1186,7 +1201,8 @@
else
rxconf = RGE_RXCFG_CONFIG_8126;
RGE_WRITE_4(sc, RGE_RXCFG, rxconf);
- RGE_WRITE_4(sc, RGE_TXCFG, RGE_TXCFG_CONFIG);
+ RGE_WRITE_4(sc, RGE_TXCFG, RGE_TYPE_R25CP(sc) ?
+ RGE_TXCFG_CONFIG_8125CP : RGE_TXCFG_CONFIG);
val = rge_read_csi(sc, 0x70c) & ~0x3f000000;
rge_write_csi(sc, 0x70c, val | 0x27000000);
@@ -1210,7 +1226,11 @@
RGE_MAC_SETBIT(sc, 0xeb58, 0x0001);
- if (RGE_TYPE_R26(sc) || sc->rge_type == MAC_R27) {
+ if (RGE_TYPE_R25CP(sc)) {
+ RGE_CLRBIT_1(sc, 0xd8, 0x02);
+ RGE_MAC_CLRBIT(sc, 0xe00c, 0x1000);
+ RGE_MAC_CLRBIT(sc, 0xc0c2, 0x0040);
+ } else if (RGE_TYPE_R26(sc) || sc->rge_type == MAC_R27) {
RGE_CLRBIT_1(sc, 0xd8, 0x02);
if (sc->rge_type == MAC_R27) {
RGE_CLRBIT_1(sc, 0x20e4, 0x04);
@@ -1278,7 +1298,7 @@
RGE_MAC_CLRBIT(sc, 0xe080, 0x0002);
}
- if (RGE_TYPE_R26(sc) || sc->rge_type == MAC_R27)
+ if (RGE_TYPE_R26(sc) || sc->rge_type == MAC_R27 || RGE_TYPE_R25CP(sc))
RGE_MAC_CLRBIT(sc, 0xea1c, 0x0304);
else
RGE_MAC_CLRBIT(sc, 0xea1c, 0x0004);
@@ -1322,17 +1342,19 @@
RGE_MAC_SETBIT(sc, 0xc0ac, 0x1f80);
- rge_write_mac_ocp(sc, 0xe098, 0xc302);
+ rge_write_mac_ocp(sc, 0xe098, RGE_TYPE_R25CP(sc) ? 0x09c2 : 0xc302);
RGE_MAC_CLRBIT(sc, 0xe032, 0x0003);
val = rge_read_csi(sc, 0x98) & ~0x0000ff00;
rge_write_csi(sc, 0x98, val);
- if (RGE_TYPE_R25D(sc)) {
+ if (RGE_TYPE_R25D(sc) && !RGE_TYPE_R25CP(sc)) {
val = rge_read_mac_ocp(sc, 0xe092) & ~0x00ff;
rge_write_mac_ocp(sc, 0xe092, val | 0x0008);
} else
RGE_MAC_CLRBIT(sc, 0xe092, 0x00ff);
+ if (RGE_TYPE_R25CP(sc))
+ RGE_MAC_SETBIT(sc, 0xdc42, 0x0008);
/* Enable/disable HW VLAN tagging based on enabled capability */
if ((if_getcapabilities(sc->sc_ifp) & IFCAP_VLAN_HWTAGGING) != 0)
Index: sys/dev/rge/if_rge_hw.c
===================================================================
--- sys/dev/rge/if_rge_hw.c
+++ sys/dev/rge/if_rge_hw.c
@@ -74,6 +74,7 @@
static void rge_ephy_config_mac_r25b(struct rge_softc *sc);
static void rge_ephy_config_mac_r27(struct rge_softc *sc);
static void rge_phy_config_mac_r27(struct rge_softc *sc);
+static void rge_phy_config_mac_r25cp(struct rge_softc *sc);
static void rge_phy_config_mac_r26_1(struct rge_softc *sc);
static void rge_phy_config_mac_r26_2(struct rge_softc *sc);
static void rge_phy_config_mac_r25(struct rge_softc *sc);
@@ -553,6 +554,9 @@
case MAC_R27:
rge_phy_config_mac_r27(sc);
break;
+ case MAC_R25CP:
+ rge_phy_config_mac_r25cp(sc);
+ break;
default:
break; /* Can't happen. */
}
@@ -583,6 +587,39 @@
return (0);
}
+/*
+ * PHY configuration for the RTL8125CP. The chip loads its PHY ram-code
+ * (0x0024) from its own flash, so no host ram-code patch table is uploaded.
+ */
+static void
+rge_phy_config_mac_r25cp(struct rge_softc *sc)
+{
+ uint16_t val;
+
+ if (sc->rge_rcodever != RGE_MAC_R25CP_RCODE_VER)
+ device_printf(sc->sc_dev, "RTL8125CP PHY ram code 0x%04x, "
+ "expected 0x%04x; not patched\n", sc->rge_rcodever,
+ RGE_MAC_R25CP_RCODE_VER);
+
+ rge_write_phy_ocp(sc, 0xa4d2, 0);
+ rge_read_phy_ocp(sc, 0xa4d4);
+ RGE_PHY_SETBIT(sc, 0xa442, 0x0800);
+ val = rge_read_phy_ocp(sc, 0xad0e) & ~0x007f;
+ rge_write_phy_ocp(sc, 0xad0e, val | 0x000b);
+ RGE_PHY_SETBIT(sc, 0xad78, 0x0010);
+ rge_write_phy_ocp(sc, 0xb87c, 0x807f);
+ val = rge_read_phy_ocp(sc, 0xb87e) & ~0xff00;
+ rge_write_phy_ocp(sc, 0xb87e, val | 0x5300);
+ RGE_PHY_SETBIT(sc, 0xa430, 0x0003);
+ RGE_PHY_CLRBIT(sc, 0xa430, 0x1000);
+ RGE_PHY_SETBIT(sc, 0xa442, 0x0080);
+ RGE_PHY_SETBIT(sc, 0xa654, 0x0800);
+ RGE_PHY_SETBIT(sc, 0xa430, 0x0004);
+ RGE_PHY_SETBIT(sc, 0xe400, 0x8000);
+ RGE_PHY_SETBIT(sc, 0xe410, 0x0100);
+ RGE_PHY_SETBIT(sc, 0xa640, 0x8000);
+}
+
static void
rge_phy_config_mac_r27(struct rge_softc *sc)
{
@@ -1798,18 +1835,27 @@
/* Disable UPS. */
RGE_MAC_CLRBIT(sc, 0xd40a, 0x0010);
- /* Disable MAC MCU. */
- rge_disable_aspm_clkreq(sc);
- rge_write_mac_ocp(sc, 0xfc48, 0);
- for (reg = 0xfc28; reg < 0xfc48; reg += 2)
- rge_write_mac_ocp(sc, reg, 0);
- DELAY(3000);
- rge_write_mac_ocp(sc, 0xfc26, 0);
-
- if (RGE_TYPE_R26(sc) || sc->rge_type == MAC_R27)
- rge_mac_config_ext_mcu(sc, sc->rge_type);
- else
- rge_mac_config_mcu(sc, sc->rge_type);
+ if (RGE_TYPE_R25CP(sc)) {
+ /*
+ * RTL8125CP runs its MAC MCU from its own flash and has no
+ * host patch table.
+ */
+ RGE_MAC_CLRBIT(sc, 0xe080, 0x0002);
+ RGE_MAC_SETBIT(sc, 0xd434, 0x0002);
+ } else {
+ /* Disable MAC MCU. */
+ rge_disable_aspm_clkreq(sc);
+ rge_write_mac_ocp(sc, 0xfc48, 0);
+ for (reg = 0xfc28; reg < 0xfc48; reg += 2)
+ rge_write_mac_ocp(sc, reg, 0);
+ DELAY(3000);
+ rge_write_mac_ocp(sc, 0xfc26, 0);
+
+ if (RGE_TYPE_R26(sc) || sc->rge_type == MAC_R27)
+ rge_mac_config_ext_mcu(sc, sc->rge_type);
+ else
+ rge_mac_config_mcu(sc, sc->rge_type);
+ }
/* Disable PHY power saving. */
if (sc->rge_type == MAC_R25)
@@ -1898,7 +1944,8 @@
if (unlock)
RGE_SETBIT_1(sc, RGE_EECMD, RGE_EECMD_WRITECFG);
- if (RGE_TYPE_R26(sc) || sc->rge_type == MAC_R27)
+ if (RGE_TYPE_R26(sc) || sc->rge_type == MAC_R27 ||
+ RGE_TYPE_R25CP(sc))
RGE_CLRBIT_1(sc, RGE_INT_CFG0, 0x08);
else
RGE_CLRBIT_1(sc, RGE_CFG2, RGE_CFG2_CLKREQ_EN);
@@ -1984,7 +2031,7 @@
}
rge_write_mac_ocp(sc, 0xc0aa, 0x07d0);
- rge_write_mac_ocp(sc, 0xc0a6, 0x01b5);
+ rge_write_mac_ocp(sc, 0xc0a6, RGE_TYPE_R25CP(sc) ? 0x0521 : 0x01b5);
rge_write_mac_ocp(sc, 0xc01e, 0x5555);
for (i = 0; i < 10; i++) {
Index: sys/dev/rge/if_rgereg.h
===================================================================
--- sys/dev/rge/if_rgereg.h
+++ sys/dev/rge/if_rgereg.h
@@ -374,7 +374,11 @@
#define RGE_MAC_R25B_RCODE_VER 0x0b99
#define RGE_TYPE_R25D(sc) \
- ((sc)->rge_type == MAC_R25D_1 || (sc)->rge_type == MAC_R25D_2)
+ ((sc)->rge_type == MAC_R25D_1 || (sc)->rge_type == MAC_R25D_2 || \
+ (sc)->rge_type == MAC_R25CP)
+
+#define RGE_TYPE_R25CP(sc) ((sc)->rge_type == MAC_R25CP)
+#define RGE_MAC_R25CP_RCODE_VER 0x0024
#define RGE_TYPE_R26(sc) \
((sc)->rge_type == MAC_R26_1 || (sc)->rge_type == MAC_R26_2)
@@ -387,6 +391,7 @@
ETHER_VLAN_ENCAP_LEN)
#define RGE_TXCFG_CONFIG 0x03000700
+#define RGE_TXCFG_CONFIG_8125CP 0x03000780
#define RGE_RXCFG_CONFIG 0x41000700
#define RGE_RXCFG_CONFIG_8125B 0x41000c00
#define RGE_RXCFG_CONFIG_8125D 0x41200c00
Index: sys/dev/rge/if_rgevar.h
===================================================================
--- sys/dev/rge/if_rgevar.h
+++ sys/dev/rge/if_rgevar.h
@@ -34,7 +34,8 @@
MAC_R25D_2,
MAC_R26_1,
MAC_R26_2,
- MAC_R27
+ MAC_R27,
+ MAC_R25CP
};
struct rge_drv_stats {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 1, 8:32 PM (6 m, 21 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42119969
Default Alt Text
D62213.1796157128.diff (7 KB)
Attached To
Mode
D62213: rge: add RTL8125CP (hwrev 0x70800000) support
Attached
Detach File
Event Timeline