summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2016-05-04 18:21:15 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-05-10 19:42:06 -0700
commited910689173561acf3a6998e1d671c84e22f5145 (patch)
tree0299cb83e6824450b4b745ec02513b85fc983141
parent0f6dce9fe4b2c820d0f265f583a9252c0e9ef204 (diff)
downloadchrome-ec-ed910689173561acf3a6998e1d671c84e22f5145.tar.gz
npcx: shi: Fixes for REBOOT_EC host command handling
- For REBOOT_EC and several other host commands, send_response may be called multiple times (once for early success notification, one for actual notification, if the handler exits cleanly). Ignore calls after the first. - During reboot / sysjump, we're not equipped to handle host commands, so disable the SHI interface altogether. BUG=chrome-os-partner:52878 TEST=Manual on kevin. Verify "ectool reboot_ec RO" (RO to RO = NOP) succeeds without error messages on EC console. Verify "ectool reboot_ec RW" causes sysjump without AP going down. BRANCH=None Change-Id: Iae83084e4f8d5218600be2a9da7f71dd7872d569 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/342622 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Mulin Chao <mlchao@nuvoton.com> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--chip/npcx/shi.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/chip/npcx/shi.c b/chip/npcx/shi.c
index ca5c4ac774..6512b2c636 100644
--- a/chip/npcx/shi.c
+++ b/chip/npcx/shi.c
@@ -194,16 +194,6 @@ static int shi_read_inbuf_wait(uint16_t szbytes);
*/
static void shi_send_response_packet(struct host_packet *pkt)
{
- /* Append our past-end byte, which we reserved space for. */
- ((uint8_t *) pkt->response)[pkt->response_size + 0] = EC_SPI_PAST_END;
-
- /* Computing sending bytes of response */
- shi_params.sz_response = pkt->response_size + SHI_PROTO3_OVERHEAD;
-
- /*
- * Before the state is set to SENDING, any CS de-assertion would
- * give up sending.
- */
if (state == SHI_STATE_PROCESSING) {
/*
* Disable interrupts. This routine is not called from interrupt
@@ -211,6 +201,15 @@ static void shi_send_response_packet(struct host_packet *pkt)
* preempted after writing its initial reply byte.
*/
interrupt_disable();
+
+ /* Append our past-end byte, which we reserved space for. */
+ ((uint8_t *) pkt->response)[pkt->response_size + 0] =
+ EC_SPI_PAST_END;
+
+ /* Computing sending bytes of response */
+ shi_params.sz_response =
+ pkt->response_size + SHI_PROTO3_OVERHEAD;
+
/*
* Disable SHI interrupt until we have prepared
* the first package to output
@@ -246,7 +245,7 @@ static void shi_send_response_packet(struct host_packet *pkt)
shi_reset_prepare();
DEBUG_CPRINTF("END\n");
} else
- CPRINTS("Unexpected state %d in response handler\n", state);
+ DEBUG_CPRINTS("Unexpected state %d in response handler", state);
}
void shi_handle_host_package(void)
@@ -747,6 +746,7 @@ static void shi_disable(void)
gpio_config_module(MODULE_SPI, 0);
}
DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, shi_disable, HOOK_PRIO_DEFAULT);
+DECLARE_HOOK(HOOK_SYSJUMP, shi_disable, HOOK_PRIO_DEFAULT);
static void shi_init(void)
{