summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2014-07-08 16:25:44 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-07-09 20:29:55 +0000
commit0a9545cb9e48822d37073b2059848e66141803ff (patch)
tree38f0b35603f7b651bab6833d8cab3dcfcb4c4cd3
parent3a05c30d22d72e51bae7c62f25d61f9ddc59ad65 (diff)
downloadchrome-ec-0a9545cb9e48822d37073b2059848e66141803ff.tar.gz
mec1322: Simplify reading raw I2C pin states
Now that gpio_get_level() always returns actual pin states, we can simplify i2c_raw_get_scl/sda(). BUG=chrome-os-partner:26483 TEST=make buildall BRANCH=None Change-Id: Ifefb6fa5da8f566b44c419a0ea5adec41f8925e3 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/207057 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--chip/mec1322/i2c.c46
1 files changed, 2 insertions, 44 deletions
diff --git a/chip/mec1322/i2c.c b/chip/mec1322/i2c.c
index 2ed2cbaedb..adc3cef04d 100644
--- a/chip/mec1322/i2c.c
+++ b/chip/mec1322/i2c.c
@@ -306,65 +306,23 @@ err_i2c_xfer:
int i2c_raw_get_scl(int port)
{
enum gpio_signal g;
- int ret;
/* If no SCL pin defined for this port, then return 1 to appear idle. */
if (get_scl_from_i2c_port(port, &g) != EC_SUCCESS)
return 1;
- /*
- * TODO(crosbug.com/p/26483): The following code assumes the worst case,
- * that since the pin is an output, gpio_get_level() will return the
- * state that we are trying to drive the output to, instead of the
- * actual state of the pin. Need to determine if this is the case, and
- * if not, we can optimize.
- */
-
- /* If we are driving the pin low, it must be low. */
- if (gpio_get_level(g) == 0)
- return 0;
-
- /*
- * Otherwise, we need to toggle it to an input to read the true pin
- * state.
- */
- gpio_set_flags(g, GPIO_INPUT);
- ret = gpio_get_level(g);
- gpio_set_flags(g, GPIO_ODR_HIGH);
-
- return ret;
+ return gpio_get_level(g);
}
int i2c_raw_get_sda(int port)
{
enum gpio_signal g;
- int ret;
/* If no SDA pin defined for this port, then return 1 to appear idle. */
if (get_sda_from_i2c_port(port, &g) != EC_SUCCESS)
return 1;
- /*
- * TODO(crosbug.com/p/26483): The following code assumes the worst case,
- * that since the pin is an output, gpio_get_level() will return the
- * state that we are trying to drive the output to, instead of the
- * actual state of the pin. Need to determine if this is the case, and
- * if not, we can optimize.
- */
-
- /* If we are driving the pin low, it must be low. */
- if (gpio_get_level(g) == 0)
- return 0;
-
- /*
- * Otherwise, we need to toggle it to an input to read the true pin
- * state.
- */
- gpio_set_flags(g, GPIO_INPUT);
- ret = gpio_get_level(g);
- gpio_set_flags(g, GPIO_ODR_HIGH);
-
- return ret;
+ return gpio_get_level(g);
}
int i2c_get_line_levels(int port)