From 48f695f3e6d112ef635eecb12e46122ccb654c5e Mon Sep 17 00:00:00 2001 From: "Sergio R. Caprile" Date: Wed, 2 Oct 2024 10:22:09 -0300 Subject: [PATCH] DP83848 has no clock setup --- mongoose.c | 12 +++++++++--- src/drivers/phy.c | 10 ++++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/mongoose.c b/mongoose.c index c869edb9..9440a68b 100644 --- a/mongoose.c +++ b/mongoose.c @@ -7560,7 +7560,7 @@ static void read_conn(struct mg_connection *c) { if (c->rtls.len == 0 || m < 0) { // Close only when we have fully drained both rtls and TLS buffers c->is_closing = 1; // or there's nothing we can do about it. - m = -1; + m = MG_IO_ERR; } else { // see #2885 // TLS buffer is capped to max record size, even though, there can // be more than one record, give TLS a chance to process them. @@ -17180,8 +17180,10 @@ struct mg_tcpip_driver mg_tcpip_driver_imxrt = {mg_tcpip_driver_imxrt_init, enum { // ID1 ID2 MG_PHY_KSZ8x = 0x22, // 0022 1561 - KSZ8081RNB - MG_PHY_DP83x = 0x2000, // 2000 a140 - TI DP83825I + MG_PHY_DP83x = 0x2000, MG_PHY_DP83867 = 0xa231, // 2000 a231 - TI DP83867I + MG_PHY_DP83825 = 0xa140, // 2000 a140 - TI DP83825I + MG_PHY_DP83848 = 0x5ca2, // 2000 5ca2 - TI DP83848I MG_PHY_LAN87x = 0x7, // 0007 c0fx - LAN8720 MG_PHY_RTL8201 = 0x1C // 001c c816 - RTL8201 }; @@ -17208,6 +17210,10 @@ static const char *mg_phy_id_to_str(uint16_t id1, uint16_t id2) { switch (id2) { case MG_PHY_DP83867: return "DP83867"; + case MG_PHY_DP83848: + return "DP83848"; + case MG_PHY_DP83825: + return "DP83825"; default: return "DP83x"; } @@ -17245,7 +17251,7 @@ void mg_phy_init(struct mg_phy *phy, uint8_t phy_addr, uint8_t config) { // nothing to do } else { // MAC clocks PHY, PHY has no xtal // Enable 50 MHz external ref clock at XI (preserve defaults) - if (id1 == MG_PHY_DP83x && id2 != MG_PHY_DP83867) { + if (id1 == MG_PHY_DP83x && id2 != MG_PHY_DP83867 && id2 != MG_PHY_DP83848) { phy->write_reg(phy_addr, MG_PHY_DP83x_REG_RCSR, MG_BIT(7) | MG_BIT(0)); } else if (id1 == MG_PHY_KSZ8x) { // Disable isolation (override hw, it doesn't make sense at this point) diff --git a/src/drivers/phy.c b/src/drivers/phy.c index 688c34e6..2af18ed1 100644 --- a/src/drivers/phy.c +++ b/src/drivers/phy.c @@ -2,8 +2,10 @@ enum { // ID1 ID2 MG_PHY_KSZ8x = 0x22, // 0022 1561 - KSZ8081RNB - MG_PHY_DP83x = 0x2000, // 2000 a140 - TI DP83825I + MG_PHY_DP83x = 0x2000, MG_PHY_DP83867 = 0xa231, // 2000 a231 - TI DP83867I + MG_PHY_DP83825 = 0xa140, // 2000 a140 - TI DP83825I + MG_PHY_DP83848 = 0x5ca2, // 2000 5ca2 - TI DP83848I MG_PHY_LAN87x = 0x7, // 0007 c0fx - LAN8720 MG_PHY_RTL8201 = 0x1C // 001c c816 - RTL8201 }; @@ -30,6 +32,10 @@ static const char *mg_phy_id_to_str(uint16_t id1, uint16_t id2) { switch (id2) { case MG_PHY_DP83867: return "DP83867"; + case MG_PHY_DP83848: + return "DP83848"; + case MG_PHY_DP83825: + return "DP83825"; default: return "DP83x"; } @@ -67,7 +73,7 @@ void mg_phy_init(struct mg_phy *phy, uint8_t phy_addr, uint8_t config) { // nothing to do } else { // MAC clocks PHY, PHY has no xtal // Enable 50 MHz external ref clock at XI (preserve defaults) - if (id1 == MG_PHY_DP83x && id2 != MG_PHY_DP83867) { + if (id1 == MG_PHY_DP83x && id2 != MG_PHY_DP83867 && id2 != MG_PHY_DP83848) { phy->write_reg(phy_addr, MG_PHY_DP83x_REG_RCSR, MG_BIT(7) | MG_BIT(0)); } else if (id1 == MG_PHY_KSZ8x) { // Disable isolation (override hw, it doesn't make sense at this point)