[U-Boot] [PATCH 23/29] cpu/mpc512x/i2c.c: use I/O accessors instead of pointer accesses

Wolfgang Denk wd at denx.de
Sat May 9 21:51:02 CEST 2009


Signed-off-by: Wolfgang Denk <wd at denx.de>
Cc: John Rigby <jcrigby at gmail.com>
---
 cpu/mpc512x/i2c.c |   25 +++++++++++--------------
 1 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/cpu/mpc512x/i2c.c b/cpu/mpc512x/i2c.c
index e9bb3e7..c8184cc 100644
--- a/cpu/mpc512x/i2c.c
+++ b/cpu/mpc512x/i2c.c
@@ -24,6 +24,7 @@
  */
 
 #include <common.h>
+#include <asm/io.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -53,24 +54,18 @@ static int  mpc_get_fdr(int);
 
 static int mpc_reg_in (volatile u32 *reg)
 {
-	int ret = *reg >> 24;
-	__asm__ __volatile__ ("eieio");
+	int ret = in_be32(reg) >> 24;
+
 	return ret;
 }
 
 static void mpc_reg_out (volatile u32 *reg, int val, int mask)
 {
-	int tmp;
-
 	if (!mask) {
-		*reg = val << 24;
+		out_be32(reg, val << 24);
 	} else {
-		tmp = mpc_reg_in (reg);
-		*reg = ((tmp & ~mask) | (val & mask)) << 24;
+		clrsetbits_be32(reg, mask << 24, (val & mask) << 24);
 	}
-	__asm__ __volatile__ ("eieio");
-
-	return;
 }
 
 static int wait_for_bb (void)
@@ -212,8 +207,10 @@ void i2c_init (int speed, int saddr)
 {
 	volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
 	int i;
-	for(i = 0; i < I2C_BUS_CNT; i++){
+
+	for (i = 0; i < I2C_BUS_CNT; i++){
 		volatile i2c512x_dev_t *regs = &im->i2c.dev[i];
+
 		mpc_reg_out (&regs->mcr, 0, 0);
 
 		/* Set clock */
@@ -226,10 +223,10 @@ void i2c_init (int speed, int saddr)
 	}
 
 	/* Disable interrupts */
-	im->i2c.icr = 0;
+	out_be32(&im->i2c.icr, 0);
+
 	/* Turn off filters */
-	im->i2c.mifr = 0;
-	return;
+	out_be32(&im->i2c.mifr, 0);
 }
 
 static int mpc_get_fdr (int speed)
-- 
1.6.0.6



More information about the U-Boot mailing list