summaryrefslogtreecommitdiff
path: root/drivers/i2c
diff options
context:
space:
mode:
authorStefan Roese <sr@denx.de>2012-01-20 11:52:33 +0100
committerAlbert ARIBAUD <albert.u.boot@aribaud.net>2012-07-07 14:07:43 +0200
commit496ba48f5ec60187d9ff7e4298e3d37677d74530 (patch)
treed981029cc4a18ad136646b0cfa67f2fc5ac9246e /drivers/i2c
parent038f3c54ba9a7ab4552943f47efe8f05736b1732 (diff)
downloadu-boot-imx-496ba48f5ec60187d9ff7e4298e3d37677d74530.zip
u-boot-imx-496ba48f5ec60187d9ff7e4298e3d37677d74530.tar.gz
u-boot-imx-496ba48f5ec60187d9ff7e4298e3d37677d74530.tar.bz2
i2c: designware_i2c.c: Add support for the "i2c probe" command
i2c_probe() is changed to reinit the i2c bus upon read failure. This is naturally the case upon i2c bus probing. Also, some printf messages upon read failure are removed. As they would interfere with the "i2c probe" command. Additionally, i2c_set_bus_speed() now returns 0, so that the "i2c speed" command can be used. Signed-off-by: Stefan Roese <sr@denx.de> Cc: Amit Virdi <amit.virdi@st.com> Cc: Vipin Kumar <vipin.kumar@st.com>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/designware_i2c.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/i2c/designware_i2c.c b/drivers/i2c/designware_i2c.c
index 6d118ac..bf64a2a 100644
--- a/drivers/i2c/designware_i2c.c
+++ b/drivers/i2c/designware_i2c.c
@@ -90,7 +90,7 @@ static void set_speed(int i2c_spd)
*
* Set the i2c speed.
*/
-void i2c_set_bus_speed(int speed)
+int i2c_set_bus_speed(int speed)
{
if (speed >= I2C_MAX_SPEED)
set_speed(IC_SPEED_MODE_MAX);
@@ -98,6 +98,8 @@ void i2c_set_bus_speed(int speed)
set_speed(IC_SPEED_MODE_FAST);
else
set_speed(IC_SPEED_MODE_STANDARD);
+
+ return 0;
}
/*
@@ -215,10 +217,8 @@ static int check_params(uint addr, int alen, uchar *buffer, int len)
static int i2c_xfer_init(uchar chip, uint addr)
{
- if (i2c_wait_for_bb()) {
- printf("Timed out waiting for bus\n");
+ if (i2c_wait_for_bb())
return 1;
- }
i2c_setaddress(chip);
writel(addr, &i2c_regs_p->ic_cmd_data);
@@ -282,7 +282,6 @@ int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
start_time_rx = get_timer(0);
} else if (get_timer(start_time_rx) > I2C_BYTE_TO) {
- printf("Timed out. i2c read Failed\n");
return 1;
}
}
@@ -334,9 +333,14 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
int i2c_probe(uchar chip)
{
u32 tmp;
+ int ret;
/*
* Try to read the first location of the chip.
*/
- return i2c_read(chip, 0, 1, (uchar *)&tmp, 1);
+ ret = i2c_read(chip, 0, 1, (uchar *)&tmp, 1);
+ if (ret)
+ i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+
+ return ret;
}