summaryrefslogtreecommitdiff
path: root/cts/i2c
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 /cts/i2c
parent08f5a1e6fc2c9467230444ac9b582dcf4d9f0068 (diff)
downloadchrome-ec-stabilize-14345.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 'cts/i2c')
-rw-r--r--cts/i2c/cts.testlist21
-rw-r--r--cts/i2c/cts_i2c.h20
-rw-r--r--cts/i2c/dut.c94
-rw-r--r--cts/i2c/th.c151
4 files changed, 0 insertions, 286 deletions
diff --git a/cts/i2c/cts.testlist b/cts/i2c/cts.testlist
deleted file mode 100644
index 7b6461e84d..0000000000
--- a/cts/i2c/cts.testlist
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Copyright 2016 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.
- */
-
-/*
- * Test i2c write for 8, 16, and 32 bits. DUT runs as a master and TH
- * runs as a slave.
- */
-CTS_TEST(write8_test,,,,)
-CTS_TEST(write16_test,,,,)
-CTS_TEST(write32_test,,,,)
-
-/*
- * Test i2c read for 8, 16, and 32 bits. DUT runs as a master and TH
- * runs as a slave. You need external pull-ups (10 kohms) on SDL and SDA
- * to make read16_test and read32_test pass.
- */
-CTS_TEST(read8_test,,,,)
-CTS_TEST(read16_test,,,,)
-CTS_TEST(read32_test,,,,) \ No newline at end of file
diff --git a/cts/i2c/cts_i2c.h b/cts/i2c/cts_i2c.h
deleted file mode 100644
index 2914d92a99..0000000000
--- a/cts/i2c/cts_i2c.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright 2016 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.
- */
-
-enum cts_i2c_packets {
- WRITE8_OFF,
- WRITE16_OFF,
- WRITE32_OFF,
- READ8_OFF,
- READ16_OFF,
- READ32_OFF,
-};
-
-#define WRITE8_DATA 0x42
-#define WRITE16_DATA 0x1234
-#define WRITE32_DATA 0xDEADBEEF
-#define READ8_DATA 0x23
-#define READ16_DATA 0xACED
-#define READ32_DATA 0x01ABCDEF
diff --git a/cts/i2c/dut.c b/cts/i2c/dut.c
deleted file mode 100644
index c7a3f9fccf..0000000000
--- a/cts/i2c/dut.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/* Copyright 2016 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.
- */
-
-#include "common.h"
-#include "cts_common.h"
-#include "cts_i2c.h"
-#include "i2c.h"
-#include "registers.h"
-#include "task.h"
-#include "timer.h"
-#include "uart.h"
-#include "watchdog.h"
-
-#define TH_ADDR_FLAGS 0x1e
-
-enum cts_rc write8_test(void)
-{
- if (i2c_write8(i2c_ports[0].port, TH_ADDR_FLAGS,
- WRITE8_OFF, WRITE8_DATA))
- return CTS_RC_FAILURE;
- return CTS_RC_SUCCESS;
-}
-
-enum cts_rc write16_test(void)
-{
- if (i2c_write16(i2c_ports[0].port, TH_ADDR_FLAGS,
- WRITE16_OFF, WRITE16_DATA))
- return CTS_RC_FAILURE;
- return CTS_RC_SUCCESS;
-}
-
-enum cts_rc write32_test(void)
-{
- if (i2c_write32(i2c_ports[0].port, TH_ADDR_FLAGS,
- WRITE32_OFF, WRITE32_DATA))
- return CTS_RC_FAILURE;
- return CTS_RC_SUCCESS;
-}
-
-enum cts_rc read8_test(void)
-{
- int data;
-
- if (i2c_read8(i2c_ports[0].port, TH_ADDR_FLAGS,
- READ8_OFF, &data))
- return CTS_RC_FAILURE;
- if (data != READ8_DATA) {
- CPRINTL("Expecting 0x%x but read 0x%x", READ8_DATA, data);
- return CTS_RC_FAILURE;
- }
-
- return CTS_RC_SUCCESS;
-}
-
-enum cts_rc read16_test(void)
-{
- int data;
-
- if (i2c_read16(i2c_ports[0].port, TH_ADDR_FLAGS,
- READ16_OFF, &data))
- return CTS_RC_FAILURE;
- if (data != READ16_DATA) {
- CPRINTL("Expecting 0x%x but read 0x%x", READ16_DATA, data);
- return CTS_RC_FAILURE;
- }
-
- return CTS_RC_SUCCESS;
-}
-
-enum cts_rc read32_test(void)
-{
- int data;
-
- if (i2c_read32(i2c_ports[0].port, TH_ADDR_FLAGS,
- READ32_OFF, &data))
- return CTS_RC_FAILURE;
- if (data != READ32_DATA) {
- CPRINTL("Read 0x%x expecting 0x%x", data, READ32_DATA);
- return CTS_RC_FAILURE;
- }
-
- return CTS_RC_SUCCESS;
-}
-
-
-#include "cts_testlist.h"
-
-void cts_task(void)
-{
- cts_main_loop(tests, "I2C");
- task_wait_event(-1);
-}
diff --git a/cts/i2c/th.c b/cts/i2c/th.c
deleted file mode 100644
index 78035cb1b2..0000000000
--- a/cts/i2c/th.c
+++ /dev/null
@@ -1,151 +0,0 @@
-/* Copyright 2016 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.
- */
-
-#include <string.h>
-#include "common.h"
-#include "cts_common.h"
-#include "cts_i2c.h"
-#include "i2c.h"
-#include "registers.h"
-#include "task.h"
-#include "timer.h"
-#include "uart.h"
-#include "watchdog.h"
-
-static uint8_t inbox[I2C_MAX_HOST_PACKET_SIZE + 2];
-static char data_received;
-
-void i2c_data_received(int port, uint8_t *buf, int len)
-{
- memcpy(inbox, buf, len);
- data_received = 1;
-}
-
-/* CTS I2C protocol implementation */
-int i2c_set_response(int port, uint8_t *buf, int len)
-{
- switch (buf[0]) {
- case READ8_OFF:
- buf[0] = READ8_DATA;
- return 1;
- case READ16_OFF:
- buf[0] = READ16_DATA & 0xFF;
- buf[1] = (READ16_DATA >> 8) & 0xFF;
- return 2;
- case READ32_OFF:
- buf[0] = READ32_DATA & 0xFF;
- buf[1] = (READ32_DATA >> 8) & 0xFF;
- buf[2] = (READ32_DATA >> 16) & 0xFF;
- buf[3] = (READ32_DATA >> 24) & 0xFF;
- return 4;
- default:
- return 0;
- }
-}
-
-static int wait_for_in_flag(uint32_t timeout_ms)
-{
- uint64_t start_time, end_time;
-
- start_time = get_time().val;
- end_time = start_time + timeout_ms * 1000;
-
- while (get_time().val < end_time) {
- if (data_received)
- return 0;
- msleep(5);
- watchdog_reload();
- }
- return 1;
-}
-
-void clean_state(void)
-{
- memset(inbox, 0, sizeof(inbox));
- data_received = 0;
-}
-
-enum cts_rc write8_test(void)
-{
- int in;
-
- if (wait_for_in_flag(100))
- return CTS_RC_TIMEOUT;
- if (inbox[0] != WRITE8_OFF)
- return CTS_RC_FAILURE;
- in = inbox[1];
- if (in != WRITE8_DATA)
- return CTS_RC_FAILURE;
-
- return CTS_RC_SUCCESS;
-}
-
-enum cts_rc write16_test(void)
-{
- int in;
-
- if (wait_for_in_flag(100))
- return CTS_RC_TIMEOUT;
- if (inbox[0] != WRITE16_OFF)
- return CTS_RC_FAILURE;
- in = inbox[2] << 8 | inbox[1] << 0;
- if (in != WRITE16_DATA)
- return CTS_RC_FAILURE;
-
- return CTS_RC_SUCCESS;
-}
-
-enum cts_rc write32_test(void)
-{
- int in;
-
- if (wait_for_in_flag(100))
- return CTS_RC_TIMEOUT;
- if (inbox[0] != WRITE32_OFF)
- return CTS_RC_FAILURE;
- in = inbox[4] << 24 | inbox[3] << 16 | inbox[2] << 8 | inbox[1];
- if (in != WRITE32_DATA)
- return CTS_RC_FAILURE;
-
- return CTS_RC_SUCCESS;
-}
-
-enum cts_rc read8_test(void)
-{
- if (wait_for_in_flag(100))
- return CTS_RC_TIMEOUT;
- if (inbox[0] != READ8_OFF)
- return CTS_RC_FAILURE;
-
- return CTS_RC_SUCCESS;
-}
-
-enum cts_rc read16_test(void)
-{
- if (wait_for_in_flag(100))
- return CTS_RC_TIMEOUT;
- if (inbox[0] != READ16_OFF)
- return CTS_RC_FAILURE;
-
- return CTS_RC_SUCCESS;
-}
-
-enum cts_rc read32_test(void)
-{
- if (wait_for_in_flag(100))
- return CTS_RC_TIMEOUT;
- if (inbox[0] != READ32_OFF)
- return CTS_RC_FAILURE;
-
- return CTS_RC_SUCCESS;
-}
-
-#include "cts_testlist.h"
-
-void cts_task(void)
-{
- cts_main_loop(tests, "I2C");
- task_wait_event(-1);
-}