Index: c/src/lib/libbsp/powerpc/gen5200/ChangeLog
===================================================================
--- c/src/lib/libbsp/powerpc/gen5200/ChangeLog	(revision 6a1c84351743d358c22987ed1f7e59c1558f383d)
+++ c/src/lib/libbsp/powerpc/gen5200/ChangeLog	(revision 4a260f074de547dd91bb0dbc25ab52ca4c94eb53)
@@ -1,2 +1,12 @@
+2008-09-08	Sebastian Huber <sebastian.huber@embedded-brains.de>
+
+	* include/mscan-base.h: Added bit timing macros.
+
+2008-09-08      Thomas Doerfler <Thomas.Doerfler@embedded-brains.de>
+
+	* i2c/i2c.c, i2c/i2cdrv.c, i2c/mpc5200mbus.c, i2c/mpc5200mbus.h,
+	include/i2c.h:
+	converted done_arg to a void pointer 
+	
 2008-09-06	Ralf CorsÃ©pius <ralf.corsepius@rtems.org>
 
Index: c/src/lib/libbsp/powerpc/gen5200/i2c/i2c.c
===================================================================
--- c/src/lib/libbsp/powerpc/gen5200/i2c/i2c.c	(revision 6a1c84351743d358c22987ed1f7e59c1558f383d)
+++ c/src/lib/libbsp/powerpc/gen5200/i2c/i2c.c	(revision 4a260f074de547dd91bb0dbc25ab52ca4c94eb53)
@@ -24,7 +24,7 @@
  */
 static void
-i2c_transfer_sema_done_func(uint32_t         arg)
-{
-    rtems_id sema = (rtems_id)arg;
+i2c_transfer_sema_done_func(void * arg)
+{
+    rtems_id sema = *(rtems_id *)arg;
     rtems_semaphore_release(sema);
 }
@@ -39,5 +39,5 @@
  */
 static void
-i2c_transfer_poll_done_func(uint32_t         arg)
+i2c_transfer_poll_done_func(void *arg)
 {
     bool *poll_done_flag = (bool *)arg;
@@ -73,5 +73,6 @@
     if (sc != RTEMS_SUCCESSFUL)
         return I2C_RESOURCE_NOT_AVAILABLE;
-    sc = i2c_transfer(bus, nmsg, msg, i2c_transfer_sema_done_func, sema);
+    sc = i2c_transfer(bus, nmsg, msg, 
+		      i2c_transfer_sema_done_func, &sema);
     if (sc != RTEMS_SUCCESSFUL)
     {
@@ -99,9 +100,14 @@
 i2c_transfer_wait_poll(i2c_bus_number bus, i2c_message *msg, int nmsg)
 {
-    volatile bool poll_done_flag;
+  /*
+   * this looks nasty, but is correct:
+   * we wait in this function, until the poll_done_flag is
+   * set deep inside the i2c_poll() function
+   */
+    volatile rtems_boolean poll_done_flag;
     rtems_status_code sc;
     poll_done_flag = false;
-    sc = i2c_transfer(bus, nmsg, msg, i2c_transfer_poll_done_func,
-                      (uint32_t)&poll_done_flag);
+    sc = i2c_transfer(bus, nmsg, msg, 
+		      i2c_transfer_poll_done_func,(void *)&poll_done_flag);
     if (sc != RTEMS_SUCCESSFUL)
         return sc;
Index: c/src/lib/libbsp/powerpc/gen5200/i2c/i2cdrv.c
===================================================================
--- c/src/lib/libbsp/powerpc/gen5200/i2c/i2cdrv.c	(revision 6a1c84351743d358c22987ed1f7e59c1558f383d)
+++ c/src/lib/libbsp/powerpc/gen5200/i2c/i2cdrv.c	(revision 4a260f074de547dd91bb0dbc25ab52ca4c94eb53)
@@ -71,5 +71,5 @@
     int               nmsg;     /* number of messages in transfer */
     i2c_transfer_done done;     /* transfer done callback function */
-    uint32_t          done_arg; /* arbitrary argument to done callback */
+    void *    done_arg_ptr;     /* arbitrary arg pointer to done callback */
 } i2c_qel;
 
@@ -106,9 +106,9 @@
  */
 static void
-i2cdrv_done(uint32_t         arg)
+i2cdrv_done(void * arg_ptr)
 {
     rtems_interrupt_level level;
     i2c_qel *qel = tqueue + tqueue_tail;
-    qel->done(qel->done_arg);
+    qel->done(qel->done_arg_ptr);
     rtems_interrupt_disable(level);
     tqueue_tail = (tqueue_tail + 1) % tqueue_size;
@@ -141,6 +141,6 @@
             mpc5200mbus_select_clock_divider(&mbus[qel->bus], i2cdrv_bus_clock_div_current);
         }
-        sc = mpc5200mbus_i2c_transfer(&mbus[qel->bus], qel->nmsg, qel->msg, i2cdrv_done,
-                                  (uint32_t)qel);
+        sc = mpc5200mbus_i2c_transfer(&mbus[qel->bus], qel->nmsg, qel->msg, 
+				      i2cdrv_done,qel);
         if (sc != RTEMS_SUCCESSFUL)
         {
@@ -150,5 +150,5 @@
                 qel->msg[i].status = I2C_RESOURCE_NOT_AVAILABLE;
             }
-            i2cdrv_done((uint32_t)qel);
+            i2cdrv_done(qel);
         }
     }
@@ -169,5 +169,5 @@
  *     msg - pointer to messages array
  *     done - function which is called when transfer is finished
- *     done_arg - arbitrary argument passed to done funciton
+ *     done_arg_ptr - arbitrary argument pointer passed to done funciton
  *
  * RETURNS:
@@ -177,5 +177,5 @@
 rtems_status_code
 i2c_transfer(i2c_bus_number bus, int nmsg, i2c_message *msg,
-             i2c_transfer_done done, uint32_t         done_arg)
+             i2c_transfer_done done, void *     done_arg_ptr)
 {
     i2c_qel qel;
@@ -196,5 +196,5 @@
     qel.nmsg = nmsg;
     qel.done = done;
-    qel.done_arg = done_arg;
+    qel.done_arg_ptr = done_arg_ptr;
     rtems_interrupt_disable(level);
     if ((tqueue_head + 1) % tqueue_size == tqueue_tail)
Index: c/src/lib/libbsp/powerpc/gen5200/i2c/mpc5200mbus.c
===================================================================
--- c/src/lib/libbsp/powerpc/gen5200/i2c/mpc5200mbus.c	(revision 6a1c84351743d358c22987ed1f7e59c1558f383d)
+++ c/src/lib/libbsp/powerpc/gen5200/i2c/mpc5200mbus.c	(revision 4a260f074de547dd91bb0dbc25ab52ca4c94eb53)
@@ -215,5 +215,5 @@
                         bus->msg = bus->cmsg = NULL;
                         bus->nmsg = bus->byte = 0;
-                        bus->done(bus->done_arg);
+                        bus->done(bus->done_arg_ptr);
                         break;
                     }
@@ -628,5 +628,5 @@
  *     msg - pointer to messages array
  *     done - function which is called when transfer is finished
- *     done_arg - arbitrary argument passed to done funciton
+ *     done_arg_ptr - arbitrary argument pointer passed to done funciton
  *
  * RETURNS:
@@ -636,5 +636,5 @@
 rtems_status_code
 mpc5200mbus_i2c_transfer(mpc5200mbus *bus, int nmsg, i2c_message *msg,
-                     i2c_transfer_done done, uint32_t   done_arg)
+                     i2c_transfer_done done, void *done_arg_ptr)
 {
     if (bus->state == STATE_UNINITIALIZED)
@@ -642,5 +642,5 @@
     
     bus->done = done;
-    bus->done_arg = done_arg;
+    bus->done_arg_ptr = done_arg_ptr;
     bus->cmsg = bus->msg = msg;
     bus->nmsg = nmsg;
Index: c/src/lib/libbsp/powerpc/gen5200/i2c/mpc5200mbus.h
===================================================================
--- c/src/lib/libbsp/powerpc/gen5200/i2c/mpc5200mbus.h	(revision 6a1c84351743d358c22987ed1f7e59c1558f383d)
+++ c/src/lib/libbsp/powerpc/gen5200/i2c/mpc5200mbus.h	(revision 4a260f074de547dd91bb0dbc25ab52ca4c94eb53)
@@ -57,5 +57,5 @@
     rtems_id               sema; /* MBUS semaphore */
     i2c_transfer_done      done; /* Transfer done function */
-    uint32_t         done_arg; /* Done function argument */
+    void *         done_arg_ptr; /* Done function argument pointer */
   int              bus_idx;  /* bus index: 0 or 1 */
 } mpc5200mbus;
@@ -99,5 +99,5 @@
  *     msg - pointer to messages array
  *     done - function which is called when transfer is finished
- *     done_arg - arbitrary argument passed to done funciton
+ *     done_arg_ptr - arbitrary argument ptr passed to done funciton
  *
  * RETURNS:
@@ -107,5 +107,5 @@
 rtems_status_code
 mpc5200mbus_i2c_transfer(mpc5200mbus *bus, int nmsg, i2c_message *msg,
-                     i2c_transfer_done done, uint32_t   done_arg);
+                     i2c_transfer_done done, void * done_arg_ptr);
 
 /* mpc5200mbus_i2c_done --
Index: c/src/lib/libbsp/powerpc/gen5200/include/i2c.h
===================================================================
--- c/src/lib/libbsp/powerpc/gen5200/include/i2c.h	(revision 6a1c84351743d358c22987ed1f7e59c1558f383d)
+++ c/src/lib/libbsp/powerpc/gen5200/include/i2c.h	(revision 4a260f074de547dd91bb0dbc25ab52ca4c94eb53)
@@ -68,5 +68,5 @@
                                    is failed */
 /* Type for function which is called when transfer over I2C bus is finished */
-typedef void (*i2c_transfer_done) (uint32_t         arg);
+typedef void (*i2c_transfer_done) (void * arg);
 
 /* i2c_initialize --
@@ -117,5 +117,5 @@
  *     msg - pointer to messages array
  *     done - function which is called when transfer is finished
- *     done_arg - arbitrary argument passed to done funciton
+ *     done_arg_ptr - arbitrary argument ptr passed to done funciton
  *
  * RETURNS:
@@ -125,5 +125,5 @@
 rtems_status_code
 i2c_transfer(i2c_bus_number bus, int nmsg, i2c_message *msg,
-             i2c_transfer_done done, uint32_t         done_arg);
+             i2c_transfer_done done, void *done_arg);
 
 /* i2c_transfer_wait --
Index: c/src/lib/libbsp/powerpc/gen5200/include/mscan-base.h
===================================================================
--- c/src/lib/libbsp/powerpc/gen5200/include/mscan-base.h	(revision 6a1c84351743d358c22987ed1f7e59c1558f383d)
+++ c/src/lib/libbsp/powerpc/gen5200/include/mscan-base.h	(revision 4a260f074de547dd91bb0dbc25ab52ca4c94eb53)
@@ -91,6 +91,12 @@
  */
 
-#define BTR0_SJW(btr0)           ((btr0) << 6)
-#define BTR0_BRP(btr0)           ((btr0) << 0)
+#define BTR0_SJW_MASK            0xc0
+#define BTR0_BRP_MASK            0x3f
+
+#define BTR0_SJW( btr0)          ((btr0) << 6)
+#define BTR0_BRP( btr0)          ((btr0) << 0)
+
+#define BTR0_GET_SJW( btr0)      (((btr0) & BTR0_SJW_MASK) >> 6)
+#define BTR0_GET_BRP( btr0)      (((btr0) & BTR0_BRP_MASK) >> 0)
 
 /** @} */
@@ -102,7 +108,14 @@
  */
 
+#define BTR1_SAMP_MASK           0x80
+#define BTR1_TSEG1_MASK          0x0f
+#define BTR1_TSEG2_MASK          0x70
+
 #define BTR1_SAMP                (1 << 7)
-#define BTR1_TSEG2(btr1)    ((btr1) << 4)
-#define BTR1_TSEG1(btr1)    ((btr1) << 0)
+#define BTR1_TSEG1( btr1)        ((btr1) << 0)
+#define BTR1_TSEG2( btr1)        ((btr1) << 4)
+
+#define BTR1_GET_TSEG1( btr0)    (((btr0) & BTR1_TSEG1_MASK) >> 0)
+#define BTR1_GET_TSEG2( btr0)    (((btr0) & BTR1_TSEG2_MASK) >> 4)
 
 /** @} */
