From f4ef77e8449338931a990cb35580dad584cc6053 Mon Sep 17 00:00:00 2001 From: Jimmy Zhang Date: Thu, 5 Jun 2014 15:20:56 -0700 Subject: [PATCH] tegra: i2c: re-init i2c controller after reset This serves as supplemental patch to CL:197732. After clearing bus, we should also redo controller init (because controller has been reset before bus clear). On the upper layer, upon receiving error return status, it should just retry instead of simply call cpu_reset(). BUG=chrome-os-partner:28323 BRANCH=nyan TEST=Built and tested on nyan and nyan_big. Original-Change-Id: Ib526bc730cb73ffef8696fc2a6a2769d6e71eb9e Original-Signed-off-by: Jimmy Zhang Original-Reviewed-on: https://chromium-review.googlesource.com/202784 Original-Reviewed-by: Julius Werner (cherry picked from commit 06f8917c70ddca88c847d0f15ebe7f286a3f6338) Signed-off-by: Marc Jones Change-Id: I1d8bc43d730b53fe7f2dad8713831311e96e3984 Reviewed-on: http://review.coreboot.org/8145 Reviewed-by: Stefan Reinauer Tested-by: build bot (Jenkins) --- src/soc/nvidia/tegra/i2c.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/soc/nvidia/tegra/i2c.c b/src/soc/nvidia/tegra/i2c.c index 26c2559d84..542d4f0fab 100644 --- a/src/soc/nvidia/tegra/i2c.c +++ b/src/soc/nvidia/tegra/i2c.c @@ -112,12 +112,14 @@ static int tegra_i2c_send_recv(int bus, int read, "%s: The address was not acknowledged.\n", __func__); info->reset_func(info->reset_bit); + i2c_init(bus); return -1; } else if (transfer_status & I2C_PKT_STATUS_NOACK_DATA) { printk(BIOS_ERR, "%s: The data was not acknowledged.\n", __func__); info->reset_func(info->reset_bit); + i2c_init(bus); return -1; } else if (transfer_status & I2C_PKT_STATUS_ARB_LOST) { printk(BIOS_ERR, @@ -128,6 +130,9 @@ static int tegra_i2c_send_recv(int bus, int read, /* Use Tegra bus clear registers to unlock SDA */ do_bus_clear(bus); + /* re-init i2c controller */ + i2c_init(bus); + /* Return w/error, let caller decide what to do */ return -1; }