[rtems commit] bsp/tqm8xx: Fix network interface driver

Sebastian Huber sebh at rtems.org
Thu Mar 22 13:51:35 UTC 2018


Module:    rtems
Branch:    master
Commit:    df8a31d6bab9b6e368287f1dcdbb9aae9abe6142
Changeset: http://git.rtems.org/rtems/commit/?id=df8a31d6bab9b6e368287f1dcdbb9aae9abe6142

Author:    Thomas Doerfler <thomas.doerfler at embedded-brains.de>
Date:      Thu Mar 22 14:50:02 2018 +0100

bsp/tqm8xx: Fix network interface driver

---

 bsps/powerpc/include/mpc8xx.h                         | 16 ++++++++++++++++
 c/src/lib/libbsp/powerpc/tqm8xx/network/network_fec.c | 16 +++++++++-------
 2 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/bsps/powerpc/include/mpc8xx.h b/bsps/powerpc/include/mpc8xx.h
index 3222e7f..f0134ed 100644
--- a/bsps/powerpc/include/mpc8xx.h
+++ b/bsps/powerpc/include/mpc8xx.h
@@ -290,6 +290,22 @@ typedef struct m8xxFECRegisters_ {
 #define M8xx_FEC_MII_DATA_WDATA(n) ((n) & 0xffff           )
 #define M8xx_FEC_MII_DATA_RDATA(reg) ((reg) & 0xffff       )
   /*
+   * bits for FEC ECNTRL register
+   */
+#define M8xx_FEC_ECNTRL_FEC_PINMUX ( 1           << (31-29))
+#define M8xx_FEC_ECNTRL_ETHER_EN   ( 1           << (31-30))
+#define M8xx_FEC_ECNTRL_RESET      ( 1           << (31-31))
+
+  /*
+   * bits for FEC R_CNTRL register
+   */
+#define M8xx_FEC_R_CNTRL_BC_REJ     ( 1           << (31-27))
+#define M8xx_FEC_R_CNTRL_PROM       ( 1           << (31-28))
+#define M8xx_FEC_R_CNTRL_MII_MODE   ( 1           << (31-29))
+#define M8xx_FEC_R_CNTRL_DRT        ( 1           << (31-30))
+#define M8xx_FEC_R_CNTRL_LOOP       ( 1           << (31-31))
+
+  /*
    * bits for FEC X_CNTRL register
    */
 #define M8xx_FEC_X_CNTRL_FDEN       ( 1           << (31-29))
diff --git a/c/src/lib/libbsp/powerpc/tqm8xx/network/network_fec.c b/c/src/lib/libbsp/powerpc/tqm8xx/network/network_fec.c
index 71da617..a2a3016 100644
--- a/c/src/lib/libbsp/powerpc/tqm8xx/network/network_fec.c
+++ b/c/src/lib/libbsp/powerpc/tqm8xx/network/network_fec.c
@@ -374,7 +374,7 @@ m8xx_fec_initialize_hardware (struct m8xx_fec_enet_struct *sc)
   /*
    * Issue reset to FEC
    */
-  m8xx.fec.ecntrl=0x1;
+  m8xx.fec.ecntrl = M8xx_FEC_ECNTRL_RESET;
 
   /*
    * Put ethernet transciever in reset
@@ -385,7 +385,7 @@ m8xx_fec_initialize_hardware (struct m8xx_fec_enet_struct *sc)
    * Configure I/O ports
    */
   m8xx.pdpar = 0x1fff;
-  m8xx.pddir = 0x1c58;
+  m8xx.pddir = 0x1fff;
 
   /*
    * Take ethernet transciever out of reset
@@ -451,7 +451,7 @@ m8xx_fec_initialize_hardware (struct m8xx_fec_enet_struct *sc)
    *   Half duplex
    *   No loopback
    */
-  m8xx.fec.r_cntrl = 0x00000006;
+  m8xx.fec.r_cntrl = M8xx_FEC_R_CNTRL_MII_MODE | M8xx_FEC_R_CNTRL_DRT;
 
   /*
    * Set up Transmit Control Register:
@@ -474,7 +474,7 @@ m8xx_fec_initialize_hardware (struct m8xx_fec_enet_struct *sc)
    *   FEC arbitration ID = 0 => U-bus arbitration = 6
    *   RISC arbitration ID = 1 => U-bus arbitration = 5
    */
-  m8xx.sdcr = 1;
+  m8xx.sdcr = M8xx_SDCR_RAID_5;
 
   /*
    * Set up receive buffer descriptors
@@ -894,9 +894,9 @@ static void fec_init (void *arg)
    * Set flags appropriately
    */
   if (ifp->if_flags & IFF_PROMISC)
-    m8xx.fec.r_cntrl |= 0x8;
+    m8xx.fec.r_cntrl |= M8xx_FEC_R_CNTRL_PROM;
   else
-    m8xx.fec.r_cntrl &= ~0x8;
+    m8xx.fec.r_cntrl &= ~M8xx_FEC_R_CNTRL_PROM;
 
   /*
    * init timer so the "watchdog function gets called periodically
@@ -911,7 +911,7 @@ static void fec_init (void *arg)
   /*
    * Enable receiver and transmitter
    */
-  m8xx.fec.ecntrl = 0x2;
+  m8xx.fec.ecntrl = M8xx_FEC_ECNTRL_ETHER_EN | M8xx_FEC_ECNTRL_FEC_PINMUX;
 }
 
 /*
@@ -1104,9 +1104,11 @@ int fec_mode_adapt
    */
   if (0 == (IFM_FDX & IFM_OPTIONS(media))) {
     m8xx.fec.x_cntrl &= ~M8xx_FEC_X_CNTRL_FDEN;
+    m8xx.fec.r_cntrl |=  M8xx_FEC_R_CNTRL_DRT;
   }
   else {
     m8xx.fec.x_cntrl |=  M8xx_FEC_X_CNTRL_FDEN;
+    m8xx.fec.r_cntrl &= ~M8xx_FEC_R_CNTRL_DRT;
   }
   /*
    * store current media state for future compares



More information about the vc mailing list