summaryrefslogtreecommitdiff
path: root/chip/npcx/lpc.c
diff options
context:
space:
mode:
authorMulin Chao <mlchao@nuvoton.com>2017-08-18 13:17:49 +0800
committerchrome-bot <chrome-bot@chromium.org>2017-08-21 23:48:13 -0700
commit20c3de1c36bf44822834ff0daa308499aa466b5c (patch)
tree1118f27a34f67b1e5db1d6ff38d485ed15c71e95 /chip/npcx/lpc.c
parent577a7418553ab2f6198c422f33fd64907506e11a (diff)
downloadchrome-ec-20c3de1c36bf44822834ff0daa308499aa466b5c.tar.gz
npcx: bypasses for SHM reading fail via eSPI and CSAE impact efficiency
In eSPI systems, when the host performs a data read from the Shared Memory space, the returned data may be corrupted. This is a result of the Core-to-Host access enable bit being toggled (by toggling CSAE bit in SIBCTRL register) during an eSPI transaction. The bypass for this symptom is to set CSAE bit to 1 during initialization and remove the toggling of CSAE bit from other EC firmware code. But keeping the CSAE bit at 1 forever also impacts the eSPI performance a lots. When the core clock is stalled by sleep, deep sleep or wfi instruction, the eSPI Peripheral Channel transaction is stalled if this bit is set. The bypass for this symptom is to wake up the core by eSPI peripheral channel transaction and let eSPI module handle the remaining packet. BRANCH=eve BUG=b:64730183 TEST=No build errors for make buildall. Flash poppy ec image, make sure it can boot to OS. Run "ectool version" over 100000 times, no error occurs. Use following script "count=0; while :; do echo "--- iteration --- $count"; time flashrom -p ec -r ec.bin; sleep 5; count=$((${count}+1)); done" to test eSPI performances over 1000 times. No errors occur and all tests' efficiency are the same as removing CSAE bypass. Change-Id: I1b9051c5a3d368a5917882d9d1c3bb00481a53ad Signed-off-by: CHLin <CHLIN56@nuvoton.com> Signed-off-by: Mulin Chao <mlchao@nuvoton.com> Reviewed-on: https://chromium-review.googlesource.com/620301 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Diffstat (limited to 'chip/npcx/lpc.c')
-rw-r--r--chip/npcx/lpc.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/chip/npcx/lpc.c b/chip/npcx/lpc.c
index 7770609c1b..556276dbc8 100644
--- a/chip/npcx/lpc.c
+++ b/chip/npcx/lpc.c
@@ -368,8 +368,6 @@ uint8_t lpc_sib_read_kbc_reg(uint8_t io_offset)
/* Lock host keyboard module */
SET_BIT(NPCX_LKSIOHA, NPCX_LKSIOHA_LKHIKBD);
- /* Enable Core-to-Host Modules Access */
- SET_BIT(NPCX_SIBCTRL, NPCX_SIBCTRL_CSAE);
/* Verify Core read/write to host modules is not in progress */
lpc_sib_wait_host_read_done();
lpc_sib_wait_host_write_done();
@@ -388,8 +386,6 @@ uint8_t lpc_sib_read_kbc_reg(uint8_t io_offset)
/* Disable Core access to keyboard module */
CLEAR_BIT(NPCX_CRSMAE, NPCX_CRSMAE_HIKBDAE);
- /* Disable Core-to-Host Modules Access */
- CLEAR_BIT(NPCX_SIBCTRL, NPCX_SIBCTRL_CSAE);
/* unlock host keyboard module */
CLEAR_BIT(NPCX_LKSIOHA, NPCX_LKSIOHA_LKHIKBD);
@@ -724,8 +720,6 @@ void lpc_sib_write_reg(uint8_t io_offset, uint8_t index_value,
/* Lock host CFG module */
SET_BIT(NPCX_LKSIOHA, NPCX_LKSIOHA_LKCFG);
- /* Enable Core-to-Host Modules Access */
- SET_BIT(NPCX_SIBCTRL, NPCX_SIBCTRL_CSAE);
/* Enable Core access to CFG module */
SET_BIT(NPCX_CRSMAE, NPCX_CRSMAE_CFGAE);
/* Verify Core read/write to host modules is not in progress */
@@ -748,8 +742,6 @@ void lpc_sib_write_reg(uint8_t io_offset, uint8_t index_value,
/* Disable Core access to CFG module */
CLEAR_BIT(NPCX_CRSMAE, NPCX_CRSMAE_CFGAE);
- /* Disable Core-to-Host Modules Access */
- CLEAR_BIT(NPCX_SIBCTRL, NPCX_SIBCTRL_CSAE);
/* unlock host CFG module */
CLEAR_BIT(NPCX_LKSIOHA, NPCX_LKSIOHA_LKCFG);
@@ -766,8 +758,6 @@ uint8_t lpc_sib_read_reg(uint8_t io_offset, uint8_t index_value)
/* Lock host CFG module */
SET_BIT(NPCX_LKSIOHA, NPCX_LKSIOHA_LKCFG);
- /* Enable Core-to-Host Modules Access */
- SET_BIT(NPCX_SIBCTRL, NPCX_SIBCTRL_CSAE);
/* Enable Core access to CFG module */
SET_BIT(NPCX_CRSMAE, NPCX_CRSMAE_CFGAE);
/* Verify Core read/write to host modules is not in progress */
@@ -792,8 +782,6 @@ uint8_t lpc_sib_read_reg(uint8_t io_offset, uint8_t index_value)
/* Disable Core access to CFG module */
CLEAR_BIT(NPCX_CRSMAE, NPCX_CRSMAE_CFGAE);
- /* Disable Core-to-Host Modules Access */
- CLEAR_BIT(NPCX_SIBCTRL, NPCX_SIBCTRL_CSAE);
/* unlock host CFG module */
CLEAR_BIT(NPCX_LKSIOHA, NPCX_LKSIOHA_LKCFG);
@@ -806,6 +794,9 @@ uint8_t lpc_sib_read_reg(uint8_t io_offset, uint8_t index_value)
/* For LPC host register initial via SIB module */
void host_register_init(void)
{
+ /* Enable Core-to-Host Modules Access */
+ SET_BIT(NPCX_SIBCTRL, NPCX_SIBCTRL_CSAE);
+
/* enable ACPI*/
lpc_sib_write_reg(SIO_OFFSET, 0x07, 0x11);
lpc_sib_write_reg(SIO_OFFSET, 0x30, 0x01);