summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorPeter Tyser <ptyser@xes-inc.com>2009-04-24 15:34:07 -0500
committerWolfgang Denk <wd@denx.de>2009-06-12 20:39:45 +0200
commita056b1ce9e19b4d4ab3dd01c3f897dcd832cd37f (patch)
tree2aa3fdbc71f996ed1066455e74149ee6fa8214c1 /board
parent54afc6ee10c8cd09598d814d49e601359b005e49 (diff)
downloadu-boot-imx-a056b1ce9e19b4d4ab3dd01c3f897dcd832cd37f.zip
u-boot-imx-a056b1ce9e19b4d4ab3dd01c3f897dcd832cd37f.tar.gz
u-boot-imx-a056b1ce9e19b4d4ab3dd01c3f897dcd832cd37f.tar.bz2
Marvell: i2c cleanup
The following changes were made, primarily to bring the Marvell i2c driver in line with U-Boot's current I2C API: - Made i2c_init() globally accessible - Made i2c_read() and i2c_write() return an integer - Updated i2c_init() calls to pass in CONFIG_SYS_I2C_SLAVE in the offhand chance someone adds slave support in the future Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
Diffstat (limited to 'board')
-rw-r--r--board/Marvell/common/i2c.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/board/Marvell/common/i2c.c b/board/Marvell/common/i2c.c
index d426044..8d87b2d 100644
--- a/board/Marvell/common/i2c.c
+++ b/board/Marvell/common/i2c.c
@@ -26,6 +26,7 @@
#include <common.h>
#include <mpc8xx.h>
#include <malloc.h>
+#include <i2c.h>
#include "../include/mv_gen_reg.h"
#include "../include/core.h"
@@ -42,7 +43,7 @@
/* Assuming that there is only one master on the bus (us) */
-static void i2c_init (int speed, int slaveaddr)
+void i2c_init (int speed, int slaveaddr)
{
unsigned int n, m, freq, margin, power;
unsigned int actualN = 0, actualM = 0;
@@ -367,7 +368,7 @@ i2c_set_dev_offset (uchar dev_addr, unsigned int offset, int ten_bit,
return 0; /* sucessful completion */
}
-uchar
+int
i2c_read (uchar dev_addr, unsigned int offset, int alen, uchar * data,
int len)
{
@@ -376,7 +377,8 @@ i2c_read (uchar dev_addr, unsigned int offset, int alen, uchar * data,
DP (puts ("i2c_read\n"));
- i2c_init (i2cFreq, 0); /* set the i2c frequency */
+ /* set the i2c frequency */
+ i2c_init (i2cFreq, CONFIG_SYS_I2C_SLAVE);
status = i2c_start ();
@@ -396,7 +398,8 @@ i2c_read (uchar dev_addr, unsigned int offset, int alen, uchar * data,
return status;
}
- i2c_init (i2cFreq, 0); /* set the i2c frequency again */
+ /* set the i2c frequency again */
+ i2c_init (i2cFreq, CONFIG_SYS_I2C_SLAVE);
status = i2c_start ();
if (status) {
@@ -442,7 +445,7 @@ void i2c_stop (void)
/* */
/* returns 0 = succesful */
/* anything but zero is failure */
-uchar
+int
i2c_write (uchar dev_addr, unsigned int offset, int alen, uchar * data,
int len)
{
@@ -451,7 +454,8 @@ i2c_write (uchar dev_addr, unsigned int offset, int alen, uchar * data,
DP (puts ("i2c_write\n"));
- i2c_init (i2cFreq, 0); /* set the i2c frequency */
+ /* set the i2c frequency */
+ i2c_init (i2cFreq, CONFIG_SYS_I2C_SLAVE);
status = i2c_start (); /* send a start bit */
@@ -504,7 +508,8 @@ int i2c_probe (uchar chip)
DP (puts ("i2c_probe\n"));
- i2c_init (i2cFreq, 0); /* set the i2c frequency */
+ /* set the i2c frequency */
+ i2c_init (i2cFreq, CONFIG_SYS_I2C_SLAVE);
status = i2c_start (); /* send a start bit */