summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorChe-Liang Chiou <clchiou@chromium.org>2011-12-20 16:29:00 +0800
committerGerrit <chrome-bot@google.com>2011-12-20 07:43:29 -0800
commit690c2073f08f142c00c89b71195f530314360207 (patch)
tree982d4fef0f3a5675b17cba2c71fa463e1c47458f /drivers
parentc4d58d54eb6c147e7558fc6014d51856a03a26dd (diff)
tegra: i2c: Support zero register address length
BUG=none TEST=emerge-tegra_kaen chromeos-u-boot Signed-off-by: Che-Liang Chiou <clchiou@chromium.org> Change-Id: Ibb8f42116812dba74e726129ea92a941e15c272b Reviewed-on: https://gerrit.chromium.org/gerrit/13226 Commit-Ready: Che-Liang Chiou <clchiou@chromium.org> Tested-by: Che-Liang Chiou <clchiou@chromium.org> Reviewed-by: Rong Chang <rongchang@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/i2c/tegra_i2c.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/drivers/i2c/tegra_i2c.c b/drivers/i2c/tegra_i2c.c
index 54d38f30abc..58e42d695b0 100644
--- a/drivers/i2c/tegra_i2c.c
+++ b/drivers/i2c/tegra_i2c.c
@@ -572,10 +572,19 @@ int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
uint offset;
int i;
- debug("i2c_read: chip=0x%x, addr=0x%x, len=0x%x\n",
- chip, addr, len);
+ debug("%s: chip=0x%x, addr=0x%x, len=0x%x\n", __func__,
+ chip, addr, len);
+
+ if (!alen) {
+ if (i2c_read_data(chip, buffer, len)) {
+ debug("%s: error reading\n", __func__);
+ return 1;
+ }
+ return 0;
+ }
+
if (!i2c_addr_ok(addr, alen)) {
- debug("i2c_read: Bad address %x.%d.\n", addr, alen);
+ debug("%s: Bad address %x.%d.\n", __func__, addr, alen);
return 1;
}
for (offset = 0; offset < len; offset++) {
@@ -586,13 +595,13 @@ int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
(addr + offset) >> (8 * i);
}
if (i2c_write_data(chip, data, alen)) {
- debug("i2c_read: error sending (0x%x)\n",
- addr);
+ debug("%s: error sending (0x%x)\n", __func__,
+ addr);
return 1;
}
}
if (i2c_read_data(chip, buffer + offset, 1)) {
- debug("i2c_read: error reading (0x%x)\n", addr);
+ debug("%s: error reading (0x%x)\n", __func__, addr);
return 1;
}
}
@@ -606,10 +615,19 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
uint offset;
int i;
- debug("i2c_write: chip=0x%x, addr=0x%x, len=0x%x\n",
- chip, addr, len);
+ debug("%s: chip=0x%x, addr=0x%x, len=0x%x\n", __func__,
+ chip, addr, len);
+
+ if (!alen) {
+ if (i2c_write_data(chip, buffer, len)) {
+ debug("%s: error sending\n", __func__);
+ return 1;
+ }
+ return 0;
+ }
+
if (!i2c_addr_ok(addr, alen)) {
- debug("i2c_write: Bad address %x.%d.\n", addr, alen);
+ debug("%s: Bad address %x.%d.\n", __func__, addr, alen);
return 1;
}
for (offset = 0; offset < len; offset++) {
@@ -618,7 +636,7 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
data[alen - i - 1] = (addr + offset) >> (8 * i);
data[alen] = buffer[offset];
if (i2c_write_data(chip, data, alen + 1)) {
- debug("i2c_write: error sending (0x%x)\n", addr);
+ debug("%s: error sending (0x%x)\n", __func__, addr);
return 1;
}
}