From cdb61a6f5d2268b059ac56da3b69ad0313f3fb90 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Mon, 7 Apr 2014 18:45:14 -0700 Subject: i2c: Replace the i2c API. The new API is in use in depthcharge and is based around the "i2c_transfer" function instead of i2c_read and i2c_write. The new function takes an array of i2c_seg structures which represent each portion of the transfer after a start bit and before the stop bit. If there's more than one segment, they're seperated by repeated starts. Some wrapper functions have also been added which make certain common operations easy. These include reading or writing a byte from a register or reading or writing a blob of raw data. The i2c device drivers generally use these wrappers but can call the i2c_transfer function directly if the need something different. The tegra i2c driver was very similar to the one in depthcharge and was simple to convert. The Exynos 5250 and 5420 drivers were ported from depthcharge and replace the ones in coreboot. The Exynos 5420 driver was ported from the high speed portion of the one in coreboot and was straightforward to port back. The low speed portion and the Exynos 5250 drivers had been transplanted from U-Boot and were replaced with the depthcharge implementation. BUG=None TEST=Built and booted on nyan with and without EFS. Built and booted on, pit and daisy. BRANCH=None Original-Change-Id: I1e98c3fa2560be25444ab3d0394bb214b9d56e93 Original-Signed-off-by: Gabe Black Original-Reviewed-on: https://chromium-review.googlesource.com/193561 Original-Reviewed-by: David Hendricks Original-Reviewed-by: Jimmy Zhang Original-Tested-by: Jimmy Zhang Original-Reviewed-by: Hung-Te Lin Original-Commit-Queue: Gabe Black Original-Tested-by: Gabe Black (cherry picked from commit 00c423fb2c06c69d580ee3ec0a3892ebf164a5fe) This cherry-pick required additional changes to the following: src/cpu/allwinner/a10/twi.c src/drivers/xpowers/axp209/axp209.c Signed-off-by: Marc Jones Change-Id: I691959c66308eeeec219b1bec463b8b365a246d7 Reviewed-on: http://review.coreboot.org/7751 Tested-by: build bot (Jenkins) Reviewed-by: Alexandru Gagniuc Reviewed-by: Patrick Georgi --- src/mainboard/google/daisy/mainboard.c | 1 + src/mainboard/google/nyan/pmic.c | 2 +- src/mainboard/google/nyan_big/pmic.c | 2 +- src/mainboard/google/nyan_blaze/pmic.c | 2 +- src/mainboard/google/peach_pit/mainboard.c | 1 + src/mainboard/google/peach_pit/romstage.c | 9 +++------ 6 files changed, 8 insertions(+), 9 deletions(-) (limited to 'src/mainboard/google') diff --git a/src/mainboard/google/daisy/mainboard.c b/src/mainboard/google/daisy/mainboard.c index 8a252b1a19..cf25967851 100644 --- a/src/mainboard/google/daisy/mainboard.c +++ b/src/mainboard/google/daisy/mainboard.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include "exynos5250.h" diff --git a/src/mainboard/google/nyan/pmic.c b/src/mainboard/google/nyan/pmic.c index cea872602a..7ec9290fd9 100644 --- a/src/mainboard/google/nyan/pmic.c +++ b/src/mainboard/google/nyan/pmic.c @@ -59,7 +59,7 @@ static struct as3722_init_reg init_list[] = { static void pmic_write_reg(unsigned bus, uint8_t reg, uint8_t val, int do_delay) { - i2c_write(bus, AS3722_I2C_ADDR, reg, 1, &val, 1); + i2c_writeb(bus, AS3722_I2C_ADDR, reg, val); if (do_delay) udelay(500); } diff --git a/src/mainboard/google/nyan_big/pmic.c b/src/mainboard/google/nyan_big/pmic.c index a6f6912a62..9f3f81a985 100644 --- a/src/mainboard/google/nyan_big/pmic.c +++ b/src/mainboard/google/nyan_big/pmic.c @@ -59,7 +59,7 @@ static struct as3722_init_reg init_list[] = { static void pmic_write_reg(unsigned bus, uint8_t reg, uint8_t val, int do_delay) { - i2c_write(bus, AS3722_I2C_ADDR, reg, 1, &val, 1); + i2c_writeb(bus, AS3722_I2C_ADDR, reg, val); if (do_delay) udelay(500); } diff --git a/src/mainboard/google/nyan_blaze/pmic.c b/src/mainboard/google/nyan_blaze/pmic.c index a6f6912a62..9f3f81a985 100644 --- a/src/mainboard/google/nyan_blaze/pmic.c +++ b/src/mainboard/google/nyan_blaze/pmic.c @@ -59,7 +59,7 @@ static struct as3722_init_reg init_list[] = { static void pmic_write_reg(unsigned bus, uint8_t reg, uint8_t val, int do_delay) { - i2c_write(bus, AS3722_I2C_ADDR, reg, 1, &val, 1); + i2c_writeb(bus, AS3722_I2C_ADDR, reg, val); if (do_delay) udelay(500); } diff --git a/src/mainboard/google/peach_pit/mainboard.c b/src/mainboard/google/peach_pit/mainboard.c index 706447ae92..01d19bc4aa 100644 --- a/src/mainboard/google/peach_pit/mainboard.c +++ b/src/mainboard/google/peach_pit/mainboard.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include diff --git a/src/mainboard/google/peach_pit/romstage.c b/src/mainboard/google/peach_pit/romstage.c index 16dc997e75..248809d1a2 100644 --- a/src/mainboard/google/peach_pit/romstage.c +++ b/src/mainboard/google/peach_pit/romstage.c @@ -97,13 +97,10 @@ static int setup_power(int is_resume) uint8_t reg = pmic_writes[i].reg; if (pmic_writes[i].or_orig) - error |= i2c_read(4, MAX77802_I2C_ADDR, - reg, sizeof(reg), - &data, sizeof(data)); + error |= i2c_readb(4, MAX77802_I2C_ADDR, reg, &data); + data |= pmic_writes[i].val; - error |= i2c_write(4, MAX77802_I2C_ADDR, - reg, sizeof(reg), - &data, sizeof(data)); + error |= i2c_writeb(4, MAX77802_I2C_ADDR, reg, data); } return error; -- cgit v1.2.3