summaryrefslogtreecommitdiff
path: root/chip/host/i2c.c
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2021-11-04 12:11:58 -0600
committerCommit Bot <commit-bot@chromium.org>2021-11-05 04:22:34 +0000
commit252457d4b21f46889eebad61d4c0a65331919cec (patch)
tree01856c4d31d710b20e85a74c8d7b5836e35c3b98 /chip/host/i2c.c
parent08f5a1e6fc2c9467230444ac9b582dcf4d9f0068 (diff)
downloadchrome-ec-stabilize-14633.B-ish.tar.gz
In the interest of making long-term branch maintenance incur as little technical debt on us as possible, we should not maintain any files on the branch we are not actually using. This has the added effect of making it extremely clear when merging CLs from the main branch when changes have the possibility to affect us. The follow-on CL adds a convenience script to actually pull updates from the main branch and generate a CL for the update. BUG=b:204206272 BRANCH=ish TEST=make BOARD=arcada_ish && make BOARD=drallion_ish Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I17e4694c38219b5a0823e0a3e55a28d1348f4b18 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3262038 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Diffstat (limited to 'chip/host/i2c.c')
-rw-r--r--chip/host/i2c.c137
1 files changed, 0 insertions, 137 deletions
diff --git a/chip/host/i2c.c b/chip/host/i2c.c
deleted file mode 100644
index ba4ab376d2..0000000000
--- a/chip/host/i2c.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/* Copyright 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.
- *
- * Mock I2C driver for unit test.
- */
-
-#include "hooks.h"
-#include "i2c.h"
-#include "i2c_private.h"
-#include "link_defs.h"
-#include "test_util.h"
-
-#define MAX_DETACHED_DEV_COUNT 3
-
-struct i2c_dev {
- int port;
- uint16_t addr_flags;
- int valid;
-};
-
-static struct i2c_dev detached_devs[MAX_DETACHED_DEV_COUNT];
-
-static void detach_init(void)
-{
- int i;
- for (i = 0; i < MAX_DETACHED_DEV_COUNT; ++i)
- detached_devs[i].valid = 0;
-}
-DECLARE_HOOK(HOOK_INIT, detach_init, HOOK_PRIO_FIRST);
-
-int test_detach_i2c(const int port, const uint16_t addr_flags)
-{
- int i;
-
- for (i = 0; i < MAX_DETACHED_DEV_COUNT; ++i)
- if (detached_devs[i].valid == 0)
- break;
-
- if (i == MAX_DETACHED_DEV_COUNT)
- return EC_ERROR_OVERFLOW;
-
- detached_devs[i].port = port;
- detached_devs[i].addr_flags = addr_flags;
- detached_devs[i].valid = 1;
-
- return EC_SUCCESS;
-}
-
-int test_attach_i2c(const int port, const uint16_t addr_flags)
-{
- int i;
-
- for (i = 0; i < MAX_DETACHED_DEV_COUNT; ++i)
- if (detached_devs[i].valid &&
- detached_devs[i].port == port &&
- detached_devs[i].addr_flags == addr_flags)
- break;
-
- if (i == MAX_DETACHED_DEV_COUNT)
- return EC_ERROR_INVAL;
-
- detached_devs[i].valid = 0;
- return EC_SUCCESS;
-}
-
-static int test_check_detached(const int port,
- const uint16_t addr_flags)
-{
- int i;
-
- for (i = 0; i < MAX_DETACHED_DEV_COUNT; ++i)
- if (detached_devs[i].valid &&
- detached_devs[i].port == port &&
- detached_devs[i].addr_flags == addr_flags)
- return 1;
- return 0;
-}
-
-int chip_i2c_xfer(const int port, const uint16_t addr_flags,
- const uint8_t *out, int out_size,
- uint8_t *in, int in_size, int flags)
-{
- const struct test_i2c_xfer *p;
- int rv;
-
- if (test_check_detached(port, addr_flags))
- return EC_ERROR_UNKNOWN;
- for (p = __test_i2c_xfer; p < __test_i2c_xfer_end; ++p) {
- rv = p->routine(port, addr_flags,
- out, out_size,
- in, in_size, flags);
- if (rv != EC_ERROR_INVAL)
- return rv;
- }
- return EC_ERROR_UNKNOWN;
-}
-
-int chip_i2c_set_freq(int port, enum i2c_freq freq)
-{
- return EC_ERROR_UNIMPLEMENTED;
-}
-
-enum i2c_freq chip_i2c_get_freq(int port)
-{
- switch (i2c_ports[port].kbps) {
- case 1000:
- return I2C_FREQ_1000KHZ;
- case 400:
- return I2C_FREQ_400KHZ;
- case 100:
- return I2C_FREQ_100KHZ;
- }
-
- /* fallback to 100k */
- return I2C_FREQ_100KHZ;
-}
-
-int i2c_raw_get_scl(int port)
-{
- return 1;
-}
-
-int i2c_raw_get_sda(int port)
-{
- return 1;
-}
-
-int i2c_get_line_levels(int port)
-{
- return 0;
-}
-
-void i2c_init(void)
-{
- /* We don't actually need to initialize anything here for host tests */
-}