summaryrefslogtreecommitdiff
path: root/cpu/mpc86xx/i2c.c
diff options
context:
space:
mode:
authorJon Loeliger <jdl@freescale.com>2006-08-22 12:26:51 -0500
committerJon Loeliger <jdl@freescale.com>2006-08-22 12:26:51 -0500
commitf1f33de3321f6e6cf882ad7be0f5569234199aef (patch)
treeb6a2e4b453378405e1bb8ce5fb70d44e0f5b6b51 /cpu/mpc86xx/i2c.c
parent4b7576fb804f9aae275a9ad5d947d2eb727d8cb7 (diff)
parent80e955c7dd98f4b4fd23c2113caf75ed2b77b5b3 (diff)
downloadu-boot-imx-f1f33de3321f6e6cf882ad7be0f5569234199aef.zip
u-boot-imx-f1f33de3321f6e6cf882ad7be0f5569234199aef.tar.gz
u-boot-imx-f1f33de3321f6e6cf882ad7be0f5569234199aef.tar.bz2
Merge branch 'mpc86xx'
Diffstat (limited to 'cpu/mpc86xx/i2c.c')
-rw-r--r--cpu/mpc86xx/i2c.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/cpu/mpc86xx/i2c.c b/cpu/mpc86xx/i2c.c
index b3ac848..d99ecb9 100644
--- a/cpu/mpc86xx/i2c.c
+++ b/cpu/mpc86xx/i2c.c
@@ -61,7 +61,7 @@ i2c_init(int speed, int slaveadd)
writeb(0x3f, I2CFDR);
/* set default filter */
- writeb(0x10,I2CDFSRR);
+ writeb(0x10, I2CDFSRR);
/* write slave address */
writeb(slaveadd, I2CADR);
@@ -76,7 +76,7 @@ i2c_init(int speed, int slaveadd)
static __inline__ int
i2c_wait4bus(void)
{
- ulong timeval = get_timer (0);
+ ulong timeval = get_timer(0);
while (readb(I2CCSR) & MPC86xx_I2CSR_MBB) {
if (get_timer(timeval) > TIMEOUT) {
@@ -91,7 +91,7 @@ static __inline__ int
i2c_wait(int write)
{
u32 csr;
- ulong timeval = get_timer (0);
+ ulong timeval = get_timer(0);
do {
csr = readb(I2CCSR);
@@ -105,7 +105,7 @@ i2c_wait(int write)
return -1;
}
- if (!(csr & MPC86xx_I2CSR_MCF)) {
+ if (!(csr & MPC86xx_I2CSR_MCF)) {
debug("i2c_wait: unfinished\n");
return -1;
}
@@ -123,7 +123,7 @@ i2c_wait(int write)
}
static __inline__ int
-i2c_write_addr (u8 dev, u8 dir, int rsta)
+i2c_write_addr(u8 dev, u8 dir, int rsta)
{
writeb(MPC86xx_I2CCR_MEN | MPC86xx_I2CCR_MSTA | MPC86xx_I2CCR_MTX
| (rsta ? MPC86xx_I2CCR_RSTA : 0),
@@ -138,7 +138,7 @@ i2c_write_addr (u8 dev, u8 dir, int rsta)
}
static __inline__ int
-__i2c_write (u8 *data, int length)
+__i2c_write(u8 *data, int length)
{
int i;
@@ -156,7 +156,7 @@ __i2c_write (u8 *data, int length)
}
static __inline__ int
-__i2c_read (u8 *data, int length)
+__i2c_read(u8 *data, int length)
{
int i;
@@ -174,8 +174,7 @@ __i2c_read (u8 *data, int length)
/* Generate ack on last next to last byte */
if (i == length - 2)
writeb(MPC86xx_I2CCR_MEN | MPC86xx_I2CCR_MSTA
- | MPC86xx_I2CCR_TXAK,
- I2CCCR);
+ | MPC86xx_I2CCR_TXAK, I2CCCR);
/* Generate stop on last byte */
if (i == length - 1)
@@ -188,10 +187,10 @@ __i2c_read (u8 *data, int length)
}
int
-i2c_read (u8 dev, uint addr, int alen, u8 *data, int length)
+i2c_read(u8 dev, uint addr, int alen, u8 *data, int length)
{
int i = 0;
- u8 *a = (u8*)&addr;
+ u8 *a = (u8 *) &addr;
if (i2c_wait4bus() < 0)
goto exit;
@@ -214,10 +213,10 @@ exit:
}
int
-i2c_write (u8 dev, uint addr, int alen, u8 *data, int length)
+i2c_write(u8 dev, uint addr, int alen, u8 *data, int length)
{
int i = 0;
- u8 *a = (u8*)&addr;
+ u8 *a = (u8 *) &addr;
if (i2c_wait4bus() < 0)
goto exit;
@@ -236,7 +235,8 @@ exit:
return !(i == length);
}
-int i2c_probe (uchar chip)
+int
+i2c_probe(uchar chip)
{
int tmp;
@@ -250,7 +250,8 @@ int i2c_probe (uchar chip)
return i2c_read(chip, 0, 1, (char *)&tmp, 1);
}
-uchar i2c_reg_read (uchar i2c_addr, uchar reg)
+uchar
+i2c_reg_read(uchar i2c_addr, uchar reg)
{
char buf[1];
@@ -259,7 +260,8 @@ uchar i2c_reg_read (uchar i2c_addr, uchar reg)
return buf[0];
}
-void i2c_reg_write (uchar i2c_addr, uchar reg, uchar val)
+void
+i2c_reg_write(uchar i2c_addr, uchar reg, uchar val)
{
i2c_write(i2c_addr, reg, 1, &val, 1);
}