diff options
author | Anton Staaf <robotboy@chromium.org> | 2015-08-31 11:13:39 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2015-09-08 10:38:20 -0700 |
commit | 4876ab900b469d7fc92e1cb079d86262f34b9e01 (patch) | |
tree | 3b8a9889c4ef9bec55670a301b8f98e8ce939287 | |
parent | 84ed699ac98f7aab6556b806092bc6f8b501453f (diff) | |
download | chrome-ec-4876ab900b469d7fc92e1cb079d86262f34b9e01.tar.gz |
I2C: Remove unused arbitration support
The i2c_claim and i2c_release routines are no longer in use, removing
this code removes one odd usecase of the panic printing routines.
Signed-off-by: Anton Staaf <robotboy@chromium.org>
BRANCH=None
BUG=None
TEST=make buildall -j
Change-Id: I76c1d90738e1e39b4b3226c31085513a20bbd769
Reviewed-on: https://chromium-review.googlesource.com/296732
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r-- | chip/nrf51/i2c.c | 1 | ||||
-rw-r--r-- | chip/stm32/i2c-stm32l.c | 1 | ||||
-rw-r--r-- | common/build.mk | 1 | ||||
-rw-r--r-- | common/i2c_arbitration.c | 104 | ||||
-rw-r--r-- | include/config.h | 1 | ||||
-rw-r--r-- | include/i2c_arbitration.h | 44 |
6 files changed, 0 insertions, 152 deletions
diff --git a/chip/nrf51/i2c.c b/chip/nrf51/i2c.c index 668f4c6863..11d90ba05a 100644 --- a/chip/nrf51/i2c.c +++ b/chip/nrf51/i2c.c @@ -9,7 +9,6 @@ #include "gpio.h" #include "hooks.h" #include "i2c.h" -#include "i2c_arbitration.h" #include "registers.h" #include "task.h" #include "timer.h" diff --git a/chip/stm32/i2c-stm32l.c b/chip/stm32/i2c-stm32l.c index 90fe7aa0d7..cdca08a25a 100644 --- a/chip/stm32/i2c-stm32l.c +++ b/chip/stm32/i2c-stm32l.c @@ -12,7 +12,6 @@ #include "hooks.h" #include "host_command.h" #include "i2c.h" -#include "i2c_arbitration.h" #include "registers.h" #include "task.h" #include "timer.h" diff --git a/common/build.mk b/common/build.mk index f1aa62556b..2006cb8c69 100644 --- a/common/build.mk +++ b/common/build.mk @@ -51,7 +51,6 @@ common-$(CONFIG_GESTURE_DETECTION)+=gesture.o common-$(CONFIG_HOSTCMD_EVENTS)+=host_event_commands.o common-$(CONFIG_HOSTCMD_PD)+=host_command_master.o common-$(CONFIG_I2C)+=i2c.o -common-$(CONFIG_I2C_ARBITRATION)+=i2c_arbitration.o common-$(CONFIG_INDUCTIVE_CHARGING)+=inductive_charging.o common-$(CONFIG_KEYBOARD_PROTOCOL_8042)+=keyboard_8042.o \ keyboard_8042_sharedlib.o diff --git a/common/i2c_arbitration.c b/common/i2c_arbitration.c deleted file mode 100644 index 128ef16287..0000000000 --- a/common/i2c_arbitration.c +++ /dev/null @@ -1,104 +0,0 @@ -/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -/* I2C arbitration using a pair of GPIO lines */ - -#include "chipset.h" -#include "common.h" -#include "gpio.h" -#include "hooks.h" -#include "i2c.h" -#include "timer.h" -#include "util.h" - -/* Time between requesting bus and deciding that we have it */ -#define BUS_SLEW_DELAY_US 10 - -/* Time between retrying to see if the AP has released the bus */ -#define BUS_WAIT_RETRY_US 3000 - -/* Time to wait until the bus becomes free */ -#define BUS_WAIT_FREE_US (100 * 1000) - -/* - * This reflects the desired value of GPIO_EC_CLAIM to ensure that the - * GPIO is driven correctly when re-enabled before AP power on. - */ -static char i2c_claimed_by_ec; - -int i2c_claim(int port) -{ - timestamp_t start; - - if (port != I2C_PORT_MASTER) - return EC_SUCCESS; - - /* If AP is off, we have the bus */ - if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) { - i2c_claimed_by_ec = 1; - return EC_SUCCESS; - } - - /* Start a round of trying to claim the bus */ - start = get_time(); - do { - timestamp_t start_retry; - int waiting = 0; - - /* Indicate that we want to claim the bus */ - gpio_set_level(GPIO_EC_CLAIM, 0); - usleep(BUS_SLEW_DELAY_US); - - /* Wait for the AP to release it */ - start_retry = get_time(); - while (time_since32(start_retry) < BUS_WAIT_RETRY_US) { - if (gpio_get_level(GPIO_AP_CLAIM)) { - /* We got it, so return */ - i2c_claimed_by_ec = 1; - return EC_SUCCESS; - } - - if (!waiting) - waiting = 1; - } - - /* It didn't release, so give up, wait, and try again */ - gpio_set_level(GPIO_EC_CLAIM, 1); - - usleep(BUS_WAIT_RETRY_US); - } while (time_since32(start) < BUS_WAIT_FREE_US); - - gpio_set_level(GPIO_EC_CLAIM, 1); - usleep(BUS_SLEW_DELAY_US); - i2c_claimed_by_ec = 0; - - panic_puts("Unable to access I2C bus (arbitration timeout)\n"); - return EC_ERROR_BUSY; -} - -void i2c_release(int port) -{ - if (port == I2C_PORT_MASTER) { - /* Release our claim */ - gpio_set_level(GPIO_EC_CLAIM, 1); - usleep(BUS_SLEW_DELAY_US); - i2c_claimed_by_ec = 0; - } -} - -static void i2c_pre_init_hook(void) -{ - gpio_set_flags(GPIO_AP_CLAIM, GPIO_PULL_UP); - gpio_set_level(GPIO_EC_CLAIM, i2c_claimed_by_ec ? 0 : 1); - gpio_set_flags(GPIO_EC_CLAIM, GPIO_OUTPUT); - usleep(BUS_SLEW_DELAY_US); -} -DECLARE_HOOK(HOOK_CHIPSET_PRE_INIT, i2c_pre_init_hook, HOOK_PRIO_DEFAULT); - -static void i2c_shutdown_hook(void) -{ - gpio_set_flags(GPIO_AP_CLAIM, GPIO_INPUT); - gpio_set_flags(GPIO_EC_CLAIM, GPIO_INPUT); -} -DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, i2c_shutdown_hook, HOOK_PRIO_DEFAULT); diff --git a/include/config.h b/include/config.h index be35fa09c9..946e9dcf5b 100644 --- a/include/config.h +++ b/include/config.h @@ -951,7 +951,6 @@ /* I2C configuration */ #undef CONFIG_I2C -#undef CONFIG_I2C_ARBITRATION #undef CONFIG_I2C_DEBUG #undef CONFIG_I2C_DEBUG_PASSTHRU #undef CONFIG_I2C_PASSTHROUGH diff --git a/include/i2c_arbitration.h b/include/i2c_arbitration.h deleted file mode 100644 index cf4d39d247..0000000000 --- a/include/i2c_arbitration.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* I2C arbitration for Chrome EC */ - -#ifndef __CROS_EC_I2C_ARBITRATION_H -#define __CROS_EC_I2C_ARBITRATION_H - -#include "common.h" - -#ifdef CONFIG_I2C_ARBITRATION - -/** - * Claim an I2C port for use in master mode. - * - * If this function succeeds, you must later call i2c_release() to release the - * claim. - * - * This function must not be called to claim an already-claimed port. - * - * @param port Port to claim (0 for first, 1 for second, etc.) - * @return 0 if claimed successfully, -1 if it is in use - */ -int i2c_claim(int port); - -/** - * Release an I2C port (after previously being claimed) - * - * This function must not be called to release an already-released port. - * - * @param port Port to claim (0 for first, 1 for second, etc.) - */ -void i2c_release(int port); - -#else - -static inline int i2c_claim(int port) { return EC_SUCCESS; } -static inline void i2c_release(int port) {} - -#endif - -#endif /* __CROS_EC_I2C_ARBITRATION_H */ |