[lwip 4/6] tms570: Add EMACUse100Mbps()

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Apr 4 14:55:14 UTC 2023


---
 uLan/ports/driver/tms570_emac/ti_drv_emac.h  | 19 +++++++++++++++++++
 uLan/ports/driver/tms570_emac/tms570_netif.c |  6 ++++++
 2 files changed, 25 insertions(+)

diff --git a/uLan/ports/driver/tms570_emac/ti_drv_emac.h b/uLan/ports/driver/tms570_emac/ti_drv_emac.h
index 54f22c8..a829edd 100644
--- a/uLan/ports/driver/tms570_emac/ti_drv_emac.h
+++ b/uLan/ports/driver/tms570_emac/ti_drv_emac.h
@@ -163,6 +163,25 @@ EMACDuplexSet(volatile tms570_emacm_t *emacBase, int duplexMode)
   }
 }
 
+/**
+ * \brief   This API sets the RMII interface speeed for MAC.
+ *
+ * \param   emacBase     Base address of the EMAC Module registers.
+ * \param   use100Mbps   indicates if the RMII interface speed shall be 100 Mbps.
+ *
+ * \return  None
+ *
+ **/
+static inline void
+EMACUse100Mbps(volatile tms570_emacm_t *emacBase, bool use100Mbps)
+{
+  if (use100Mbps) {
+    emacBase->MACCONTROL |= TMS570_EMACM_MACCONTROL_RMIISPEED;
+  } else {
+    emacBase->MACCONTROL &= ~TMS570_EMACM_MACCONTROL_RMIISPEED;
+  }
+}
+
 /**
  * \brief   API to enable the transmit in the TX Control Register
  *          After the transmit is enabled, any write to TXHDP of
diff --git a/uLan/ports/driver/tms570_emac/tms570_netif.c b/uLan/ports/driver/tms570_emac/tms570_netif.c
index 46e025a..b484a42 100644
--- a/uLan/ports/driver/tms570_emac/tms570_netif.c
+++ b/uLan/ports/driver/tms570_emac/tms570_netif.c
@@ -468,6 +468,12 @@ tms570_eth_init_hw_post_init(struct tms570_netif_state *nf_state)
     return UNKN_DUPLEX_MODE;
   }
 
+  if (regContent & (PHY_100BASETX_m | PHY_100BASETXDUPL_m)) {
+    EMACUse100Mbps(nf_state->emac_base, true);
+  } else {
+    EMACUse100Mbps(nf_state->emac_base, false);
+  }
+
   /* enable hostpend interrupts in emac module */
   nf_state->emac_base->MACINTMASKSET |= TMS570_EMACM_MACINTMASKSET_HOSTMASK;
 
-- 
2.35.3



More information about the devel mailing list