summaryrefslogtreecommitdiff
path: root/chip/npcx/sib.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/npcx/sib.c
parent08f5a1e6fc2c9467230444ac9b582dcf4d9f0068 (diff)
downloadchrome-ec-stabilize-14469.41.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/npcx/sib.c')
-rw-r--r--chip/npcx/sib.c191
1 files changed, 0 insertions, 191 deletions
diff --git a/chip/npcx/sib.c b/chip/npcx/sib.c
deleted file mode 100644
index b8e2e17955..0000000000
--- a/chip/npcx/sib.c
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright 2019 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.
- */
-
-/* NPCX-specific SIB module for Chrome EC */
-
-#include "console.h"
-#include "hwtimer_chip.h"
-#include "registers.h"
-#include "task.h"
-#include "timer.h"
-#include "util.h"
-
-/*
- * Timeout to wait for host transaction to be completed.
- *
- * For eSPI - it is 200 us.
- * For LPC - it is 5 us.
- */
-#ifdef CONFIG_HOSTCMD_ESPI
-#define HOST_TRANSACTION_TIMEOUT_US 200
-#else
-#define HOST_TRANSACTION_TIMEOUT_US 5
-#endif
-
-/* Console output macros */
-#ifdef DEBUG_SIB
-#define CPUTS(outstr) cputs(CC_SYSTEM, outstr)
-#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args)
-#else
-#define CPUTS(...)
-#define CPRINTS(...)
-#endif
-
-/*
- * Check host read is not in-progress and no timeout
- */
-static void sib_wait_host_read_done(void)
-{
- timestamp_t deadline, start;
-
- start = get_time();
- deadline.val = start.val + HOST_TRANSACTION_TIMEOUT_US;
- while (IS_BIT_SET(NPCX_SIBCTRL, NPCX_SIBCTRL_CSRD)) {
- if (timestamp_expired(deadline, NULL)) {
- CPRINTS("Unexpected time of host read transaction");
- break;
- }
- /* Handle ITIM32 overflow condition */
- __hw_clock_handle_overflow(start.le.hi);
- }
-}
-
-/*
- * Check host write is not in-progress and no timeout
- */
-static void sib_wait_host_write_done(void)
-{
- timestamp_t deadline, start;
-
- start = get_time();
- deadline.val = start.val + HOST_TRANSACTION_TIMEOUT_US;
- while (IS_BIT_SET(NPCX_SIBCTRL, NPCX_SIBCTRL_CSWR)) {
- if (timestamp_expired(deadline, NULL)) {
- CPRINTS("Unexpected time of host write transaction");
- break;
- }
- /* Handle ITIM32 overflow condition */
- __hw_clock_handle_overflow(start.le.hi);
- }
-}
-
-/* Emulate host to read Keyboard I/O */
-uint8_t sib_read_kbc_reg(uint8_t io_offset)
-{
- uint8_t data_value;
-
- /* Disable interrupts */
- interrupt_disable();
-
- /* Lock host keyboard module */
- SET_BIT(NPCX_LKSIOHA, NPCX_LKSIOHA_LKHIKBD);
- /* Verify Core read/write to host modules is not in progress */
- sib_wait_host_read_done();
- sib_wait_host_write_done();
- /* Enable Core access to keyboard module */
- SET_BIT(NPCX_CRSMAE, NPCX_CRSMAE_HIKBDAE);
-
- /* Specify the io_offset A0 = 0. the index register is accessed */
- NPCX_IHIOA = io_offset;
-
- /* Start a Core read from host module */
- SET_BIT(NPCX_SIBCTRL, NPCX_SIBCTRL_CSRD);
- /* Wait while Core read operation is in progress */
- sib_wait_host_read_done();
- /* Read the data */
- data_value = NPCX_IHD;
-
- /* Disable Core access to keyboard module */
- CLEAR_BIT(NPCX_CRSMAE, NPCX_CRSMAE_HIKBDAE);
- /* unlock host keyboard module */
- CLEAR_BIT(NPCX_LKSIOHA, NPCX_LKSIOHA_LKHIKBD);
-
- /* Enable interrupts */
- interrupt_enable();
-
- return data_value;
-}
-
-/* Super-IO read/write function */
-void sib_write_reg(uint8_t io_offset, uint8_t index_value,
- uint8_t io_data)
-{
- /* Disable interrupts */
- interrupt_disable();
-
- /* Lock host CFG module */
- SET_BIT(NPCX_LKSIOHA, NPCX_LKSIOHA_LKCFG);
- /* Enable Core access to CFG module */
- SET_BIT(NPCX_CRSMAE, NPCX_CRSMAE_CFGAE);
- /* Verify Core read/write to host modules is not in progress */
- sib_wait_host_read_done();
- sib_wait_host_write_done();
-
- /* Specify the io_offset A0 = 0. the index register is accessed */
- NPCX_IHIOA = io_offset;
- /* Write the data. This starts the write access to the host module */
- NPCX_IHD = index_value;
- /* Wait while Core write operation is in progress */
- sib_wait_host_write_done();
-
- /* Specify the io_offset A0 = 1. the data register is accessed */
- NPCX_IHIOA = io_offset+1;
- /* Write the data. This starts the write access to the host module */
- NPCX_IHD = io_data;
- /* Wait while Core write operation is in progress */
- sib_wait_host_write_done();
-
- /* Disable Core access to CFG module */
- CLEAR_BIT(NPCX_CRSMAE, NPCX_CRSMAE_CFGAE);
- /* unlock host CFG module */
- CLEAR_BIT(NPCX_LKSIOHA, NPCX_LKSIOHA_LKCFG);
-
- /* Enable interrupts */
- interrupt_enable();
-}
-
-uint8_t sib_read_reg(uint8_t io_offset, uint8_t index_value)
-{
- uint8_t data_value;
-
- /* Disable interrupts */
- interrupt_disable();
-
- /* Lock host CFG module */
- SET_BIT(NPCX_LKSIOHA, NPCX_LKSIOHA_LKCFG);
- /* Enable Core access to CFG module */
- SET_BIT(NPCX_CRSMAE, NPCX_CRSMAE_CFGAE);
- /* Verify Core read/write to host modules is not in progress */
- sib_wait_host_read_done();
- sib_wait_host_write_done();
-
- /* Specify the io_offset A0 = 0. the index register is accessed */
- NPCX_IHIOA = io_offset;
- /* Write the data. This starts the write access to the host module */
- NPCX_IHD = index_value;
- /* Wait while Core write operation is in progress */
- sib_wait_host_write_done();
-
- /* Specify the io_offset A0 = 1. the data register is accessed */
- NPCX_IHIOA = io_offset+1;
- /* Start a Core read from host module */
- SET_BIT(NPCX_SIBCTRL, NPCX_SIBCTRL_CSRD);
- /* Wait while Core read operation is in progress */
- sib_wait_host_read_done();
- /* Read the data */
- data_value = NPCX_IHD;
-
- /* Disable Core access to CFG module */
- CLEAR_BIT(NPCX_CRSMAE, NPCX_CRSMAE_CFGAE);
- /* unlock host CFG module */
- CLEAR_BIT(NPCX_LKSIOHA, NPCX_LKSIOHA_LKCFG);
-
- /* Enable interrupts */
- interrupt_enable();
-
- return data_value;
-}
-