[rtems commit] bsp/mpc55xx: Fix SMSC9218I_BIG_ENDIAN_SUPPORT

Sebastian Huber sebh at rtems.org
Tue Aug 21 09:02:48 UTC 2012


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

Author:    Christian Mauderer <christian.mauderer at embedded-brains.de>
Date:      Thu Aug 16 12:19:14 2012 +0200

bsp/mpc55xx: Fix SMSC9218I_BIG_ENDIAN_SUPPORT

---

 .../libbsp/powerpc/mpc55xxevb/include/smsc9218i.h  |   12 ++++++++----
 .../libbsp/powerpc/mpc55xxevb/network/smsc9218i.c  |   10 +++++++---
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/c/src/lib/libbsp/powerpc/mpc55xxevb/include/smsc9218i.h b/c/src/lib/libbsp/powerpc/mpc55xxevb/include/smsc9218i.h
index 018633c..8284a2f 100644
--- a/c/src/lib/libbsp/powerpc/mpc55xxevb/include/smsc9218i.h
+++ b/c/src/lib/libbsp/powerpc/mpc55xxevb/include/smsc9218i.h
@@ -70,21 +70,25 @@ typedef struct {
  */
 #ifdef SMSC9218I_BIG_ENDIAN_SUPPORT
   volatile smsc9218i_registers *const smsc9218i =
+    (volatile smsc9218i_registers *) 0x3fff8000;
+  volatile smsc9218i_registers *const smsc9218i_dma =
     (volatile smsc9218i_registers *) 0x3fff8200;
 #else
   volatile smsc9218i_registers *const smsc9218i =
     (volatile smsc9218i_registers *) 0x3fff8000;
+  volatile smsc9218i_registers *const smsc9218i_dma =
+    (volatile smsc9218i_registers *) 0x3fff8000;
 #endif
 
 /** @} */
 
 #ifdef SMSC9218I_BIG_ENDIAN_SUPPORT
+  #define SMSC9218I_BIT_POS(pos) (pos)
+#else
   #define SMSC9218I_BIT_POS(pos) \
     ((pos) > 15 ? \
       ((pos) > 23 ? (pos) - 24 : (pos) - 8) \
         : ((pos) > 7 ? (pos) + 8 : (pos) + 24))
-#else
-  #define SMSC9218I_BIT_POS(pos) (pos)
 #endif
 
 #define SMSC9218I_FLAG(pos) \
@@ -105,13 +109,13 @@ typedef struct {
     | SMSC9218I_GET_FIELD_8(reg, pos))
 
 #ifdef SMSC9218I_BIG_ENDIAN_SUPPORT
+  #define SMSC9218I_SWAP(val) (val)
+#else
   #define SMSC9218I_SWAP(val) \
     ((((val) >> 24) & 0xff) \
       | ((((val) >> 16) & 0xff) << 8) \
       | ((((val) >> 8) & 0xff) << 16) \
       | (((val) & 0xff) << 24))
-#else
-  #define SMSC9218I_SWAP(val) (val)
 #endif
 
 /**
diff --git a/c/src/lib/libbsp/powerpc/mpc55xxevb/network/smsc9218i.c b/c/src/lib/libbsp/powerpc/mpc55xxevb/network/smsc9218i.c
index cf5072a..50d6c85 100644
--- a/c/src/lib/libbsp/powerpc/mpc55xxevb/network/smsc9218i.c
+++ b/c/src/lib/libbsp/powerpc/mpc55xxevb/network/smsc9218i.c
@@ -776,6 +776,7 @@ static void smsc9218i_new_mbuf(
 static void smsc9218i_init_receive_jobs(
   smsc9218i_driver_entry *e,
   volatile smsc9218i_registers *regs,
+  volatile smsc9218i_registers *regs_dma,
   smsc9218i_receive_job_control *jc
 )
 {
@@ -795,7 +796,7 @@ static void smsc9218i_init_receive_jobs(
     struct tcd_t *tcd = &jc->tcd_table [i];
     struct tcd_t *next_tcd = &jc->tcd_table [(i + 1) % SMSC9218I_RX_JOBS];
 
-    tcd->SADDR = (uint32_t) &regs->rx_fifo_data;
+    tcd->SADDR = (uint32_t) &regs_dma->rx_fifo_data;
     tcd->SDF.B.SSIZE = 0x2;
     tcd->SDF.B.DSIZE = 0x2;
     tcd->CDF.B.CITER = 1;
@@ -846,9 +847,10 @@ static void smsc9218i_receive_task(void *arg)
   smsc9218i_receive_job_control *jc = &smsc_rx_jc;
   smsc9218i_driver_entry *e = (smsc9218i_driver_entry *) arg;
   volatile smsc9218i_registers *const regs = smsc9218i;
+  volatile smsc9218i_registers *const regs_dma = smsc9218i_dma;
   uint32_t mac_cr = 0;
 
-  smsc9218i_init_receive_jobs(e, regs, jc);
+  smsc9218i_init_receive_jobs(e, regs, regs_dma, jc);
 
   /* Configure receiver */
   regs->rx_cfg = SMSC9218I_RX_CFG_END_ALIGN_4
@@ -1335,6 +1337,7 @@ static void smsc9218i_transmit_task(void *arg)
   smsc9218i_driver_entry *e = (smsc9218i_driver_entry *) arg;
   struct ifnet *ifp = &e->arpcom.ac_if;
   volatile smsc9218i_registers *const regs = smsc9218i;
+  volatile smsc9218i_registers *const regs_dma = smsc9218i_dma;
   uint32_t mac_cr = 0;
   smsc9218i_transmit_job_control *jc = &smsc_tx_jc;
   unsigned i = 0;
@@ -1362,11 +1365,12 @@ static void smsc9218i_transmit_task(void *arg)
     tcd.SDF.B.DSIZE = 2;
     tcd.CDF.B.CITER = 1;
     tcd.BMF.R = SMSC9218I_TCD_BMF_LINK;
-    tcd.DADDR = (uint32_t) &regs->tx_fifo_data;
 
+    tcd.DADDR = (uint32_t) &regs_dma->tx_fifo_data;
     tcd.DLAST_SGA = (int32_t) next_command_tcd;
     *data_tcd = tcd;
 
+    tcd.DADDR = (uint32_t) &regs->tx_fifo_data;
     tcd.SADDR = (uint32_t) &jc->command_table [i].a;
     tcd.NBYTES = 8;
     tcd.DLAST_SGA = (int32_t) data_tcd;




More information about the vc mailing list