diff options
author | Jett Rink <jettrink@chromium.org> | 2018-06-08 08:25:42 -0600 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-06-08 12:54:51 -0700 |
commit | 3846871131d40790efcc9467eb3cfa01b859969e (patch) | |
tree | 8779361a94177147412baabde70420bb28845996 /common/i2c_master.c | |
parent | 25345adac03162414ddc9b5da8412286028d9f5b (diff) | |
download | chrome-ec-3846871131d40790efcc9467eb3cfa01b859969e.tar.gz |
i2c: preserve 1.8V flag during raw i2c gpio access
When we try to unwedge an i2c port, we change the pin type into a
manually GPIO ODR. When we do that we should also carry over the 1.8V
flag if it exists on the original GPIO definition.
BRANCH=none
BUG=b:109884927
TEST=verified with manually-created EC console command that low voltage
register is not set when going into raw mode before this change and
correctly sets the low voltage register after this change (when going into
raw mode).
Change-Id: I87515d53cc68ace3f69ea1058b83a378ef9a281c
Signed-off-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1093011
Reviewed-by: Justin TerAvest <teravest@chromium.org>
Diffstat (limited to 'common/i2c_master.c')
-rw-r--r-- | common/i2c_master.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/common/i2c_master.c b/common/i2c_master.c index 220ba8b9f1..7915451b32 100644 --- a/common/i2c_master.c +++ b/common/i2c_master.c @@ -380,6 +380,12 @@ int i2c_raw_mode(int port, int enable) return EC_ERROR_INVAL; if (enable) { + int raw_gpio_mode_flags = GPIO_ODR_HIGH; + + /* If the CLK line is 1.8V, then ensure we set 1.8V mode */ + if ((gpio_list + scl)->flags & GPIO_SEL_1P8V) + raw_gpio_mode_flags |= GPIO_SEL_1P8V; + /* * To enable raw mode, take out of alternate function mode and * set the flags to open drain output. @@ -387,8 +393,8 @@ int i2c_raw_mode(int port, int enable) ret_sda = gpio_config_pin(MODULE_I2C, sda, 0); ret_scl = gpio_config_pin(MODULE_I2C, scl, 0); - gpio_set_flags(scl, GPIO_ODR_HIGH); - gpio_set_flags(sda, GPIO_ODR_HIGH); + gpio_set_flags(scl, raw_gpio_mode_flags); + gpio_set_flags(sda, raw_gpio_mode_flags); } else { /* * Configure the I2C pins to exit raw mode and return |