diff --git a/mongoose.c b/mongoose.c index daf8205e..d29a8da3 100644 --- a/mongoose.c +++ b/mongoose.c @@ -17192,10 +17192,11 @@ void mg_phy_init(struct mg_phy *phy, uint8_t phy_addr, uint8_t config) { if (id1 == MG_PHY_DP83x && id2 != MG_PHY_DP83867) { phy->write_reg(phy_addr, MG_PHY_DP83x_REG_RCSR, MG_BIT(7) | MG_BIT(0)); } else if (id1 == MG_PHY_KSZ8x) { - phy->write_reg( - phy_addr, MG_PHY_REG_BCR, // Disable isolation (override hw) + // Disable isolation (override hw, it doesn't make sense at this point) + phy->write_reg( // #2848, some NXP boards set ISO, even though + phy_addr, MG_PHY_REG_BCR, // docs say they don't phy->read_reg(phy_addr, MG_PHY_REG_BCR) & (uint16_t) ~MG_BIT(10)); - phy->write_reg(phy_addr, MG_PHY_KSZ8x_REG_PC2R, + phy->write_reg(phy_addr, MG_PHY_KSZ8x_REG_PC2R, // now do clock stuff MG_BIT(15) | MG_BIT(8) | MG_BIT(7)); } else if (id1 == MG_PHY_LAN87x) { // nothing to do diff --git a/mongoose.h b/mongoose.h index a4e34926..51ba7b82 100644 --- a/mongoose.h +++ b/mongoose.h @@ -3052,6 +3052,21 @@ struct mg_tcpip_driver_tm4c_data { #define MG_DRIVER_MDC_CR 1 #endif +#define MG_TCPIP_DRIVER_INIT(mgr) \ + do { \ + static struct mg_tcpip_driver_tm4c_data driver_data_; \ + static struct mg_tcpip_if mif_; \ + driver_data_.mdc_cr = MG_DRIVER_MDC_CR; \ + mif_.ip = MG_TCPIP_IP; \ + mif_.mask = MG_TCPIP_MASK; \ + mif_.gw = MG_TCPIP_GW; \ + mif_.driver = &mg_tcpip_driver_tm4c; \ + mif_.driver_data = &driver_data_; \ + MG_SET_MAC_ADDRESS(mif_.mac); \ + mg_tcpip_init(mgr, &mif_); \ + MG_INFO(("Driver: tm4c, MAC: %M", mg_print_mac, mif_.mac)); \ + } while (0) + #endif diff --git a/src/drivers/phy.c b/src/drivers/phy.c index e4f112a8..688c34e6 100644 --- a/src/drivers/phy.c +++ b/src/drivers/phy.c @@ -70,10 +70,11 @@ void mg_phy_init(struct mg_phy *phy, uint8_t phy_addr, uint8_t config) { if (id1 == MG_PHY_DP83x && id2 != MG_PHY_DP83867) { phy->write_reg(phy_addr, MG_PHY_DP83x_REG_RCSR, MG_BIT(7) | MG_BIT(0)); } else if (id1 == MG_PHY_KSZ8x) { - phy->write_reg( - phy_addr, MG_PHY_REG_BCR, // Disable isolation (override hw) + // Disable isolation (override hw, it doesn't make sense at this point) + phy->write_reg( // #2848, some NXP boards set ISO, even though + phy_addr, MG_PHY_REG_BCR, // docs say they don't phy->read_reg(phy_addr, MG_PHY_REG_BCR) & (uint16_t) ~MG_BIT(10)); - phy->write_reg(phy_addr, MG_PHY_KSZ8x_REG_PC2R, + phy->write_reg(phy_addr, MG_PHY_KSZ8x_REG_PC2R, // now do clock stuff MG_BIT(15) | MG_BIT(8) | MG_BIT(7)); } else if (id1 == MG_PHY_LAN87x) { // nothing to do diff --git a/src/drivers/tm4c.h b/src/drivers/tm4c.h index 4b524499..acd11d03 100644 --- a/src/drivers/tm4c.h +++ b/src/drivers/tm4c.h @@ -19,4 +19,19 @@ struct mg_tcpip_driver_tm4c_data { #define MG_DRIVER_MDC_CR 1 #endif +#define MG_TCPIP_DRIVER_INIT(mgr) \ + do { \ + static struct mg_tcpip_driver_tm4c_data driver_data_; \ + static struct mg_tcpip_if mif_; \ + driver_data_.mdc_cr = MG_DRIVER_MDC_CR; \ + mif_.ip = MG_TCPIP_IP; \ + mif_.mask = MG_TCPIP_MASK; \ + mif_.gw = MG_TCPIP_GW; \ + mif_.driver = &mg_tcpip_driver_tm4c; \ + mif_.driver_data = &driver_data_; \ + MG_SET_MAC_ADDRESS(mif_.mac); \ + mg_tcpip_init(mgr, &mif_); \ + MG_INFO(("Driver: tm4c, MAC: %M", mg_print_mac, mif_.mac)); \ + } while (0) + #endif