You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/09/12 17:50:29 UTC

(nuttx) 02/03: arch/arm64/src/imx9: Add config option to select TX clk direction

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 3f8205062379e3ffc51bddce64f20e284ef6627c
Author: Jukka Laitinen <ju...@ssrc.tii.ae>
AuthorDate: Thu Aug 29 15:31:14 2024 +0300

    arch/arm64/src/imx9: Add config option to select TX clk direction
    
    TX clock or ref clock can be driven either from outside (PHY / oscilator) or by the ENET block.
    
    Typical connection with RMII PHY is that the PHY drives the refclk.
    
    Signed-off-by: Jukka Laitinen <ju...@ssrc.tii.ae>
---
 arch/arm64/src/imx9/Kconfig     | 10 ++++++++++
 arch/arm64/src/imx9/imx9_enet.c | 11 ++++++++++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/src/imx9/Kconfig b/arch/arm64/src/imx9/Kconfig
index 40d0caaa62..36f02606d3 100644
--- a/arch/arm64/src/imx9/Kconfig
+++ b/arch/arm64/src/imx9/Kconfig
@@ -959,6 +959,16 @@ config IMX9_ENET1_RGMII
 
 endchoice
 
+config IMX9_ENET1_TX_CLOCK_IS_INPUT
+	bool "ENET1 TX clock is input"
+	default y if IMX9_ENET1_RMII
+	default n if IMX9_ENET1_RGMII
+	---help---
+		The ethernet TX clock can be either driven by the PHY, in
+		which case it is input to the MAC. Or it can be driven by
+		the MAC, in which case it is output. Typical configuration is
+		input for RMII and output for RGMII.
+
 config IMX9_ENET1_PHY_AUTONEG
 	bool "ENET1 PHY autonegotiation enable"
 	default y
diff --git a/arch/arm64/src/imx9/imx9_enet.c b/arch/arm64/src/imx9/imx9_enet.c
index b6a501362b..16924bff72 100644
--- a/arch/arm64/src/imx9/imx9_enet.c
+++ b/arch/arm64/src/imx9/imx9_enet.c
@@ -64,6 +64,7 @@
 #include "imx9_iomuxc.h"
 #include "hardware/imx9_ccm.h"
 #include "hardware/imx9_pinmux.h"
+#include "hardware/imx9_blk_ctrl.h"
 
 #ifdef CONFIG_IMX9_ENET
 
@@ -423,7 +424,7 @@ static inline uint32_t imx9_enet_getreg32(struct imx9_driver_s *priv,
 }
 
 /****************************************************************************
- * Name: imx9_enet_putreg32
+ * Name: imx9_enet_modifyreg32
  *
  * Description:
  *   Atomically modify the specified bits in a memory mapped register
@@ -3092,6 +3093,14 @@ int imx9_netinitialize(int intf)
 
   imx9_ccm_configure_root_clock(CCM_CR_ENETREFPHY, SYS_PLL1PFD0DIV2, 20);
 
+  /* Enet TX / ref clock direction */
+
+#ifdef CONFIG_IMX9_ENET1_TX_CLOCK_IS_INPUT
+  modifyreg32(IMX9_WAKUPMIX_ENET_CLK_SEL, WAKEUPMIX_ENET1_TX_CLK_SEL, 0);
+#else
+  modifyreg32(IMX9_WAKUPMIX_ENET_CLK_SEL, 0, WAKEUPMIX_ENET1_TX_CLK_SEL);
+#endif
+
   /* Enable the ENET clock */
 
   imx9_ccm_gate_on(priv->clk_gate, true);