diff options
author | Vadim Bendebury <vbendeb@chromium.org> | 2017-03-09 18:46:13 -0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2017-03-10 17:17:37 +0000 |
commit | 4e223bc2cba1527ca225f7c909bdb3d1b7876c21 (patch) | |
tree | 87439564fe0e5a3f50194427630cf346f9326f64 | |
parent | a0143b15d33b2c63a98fa02ee076cde753f62539 (diff) | |
download | chrome-ec-4e223bc2cba1527ca225f7c909bdb3d1b7876c21.tar.gz |
g: fix sps interrupt assertion logic
The SPI initialization interrupt needs to be generated only when there
was actual data received while CS was asserted and after transaction
finished (i.e. CS is de-asserted).
BRANCH=cr50
BUG=b:35774896
TEST=verified on a bob with updated AP firmware
Change-Id: Ifc4b11870d511d47e9607a2001d845ee1e153f7f
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/452792
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
(cherry picked from commit 2c0b6b7d3d354e636eacb6deaf2ebc6393f09550)
Reviewed-on: https://chromium-review.googlesource.com/452648
-rw-r--r-- | chip/g/sps.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/chip/g/sps.c b/chip/g/sps.c index dba3129dfc..6a5fed0ee3 100644 --- a/chip/g/sps.c +++ b/chip/g/sps.c @@ -303,6 +303,8 @@ static void sps_advance_rx(int port, int data_size) */ static void sps_rx_interrupt(uint32_t port, int cs_deasserted) { + static uint8_t seen_data; + for (;;) { uint8_t *received_data = NULL; size_t data_size; @@ -311,6 +313,7 @@ static void sps_rx_interrupt(uint32_t port, int cs_deasserted) if (!data_size) break; + seen_data = 1; sps_rx_count += data_size; if (sps_rx_handler) @@ -322,16 +325,20 @@ static void sps_rx_interrupt(uint32_t port, int cs_deasserted) sps_advance_rx(port, data_size); } - if (cs_deasserted) + if (cs_deasserted) { sps_rx_handler(NULL, 0, 1); - /* - * SPI does not provide inherent flow control. Let's use this pin to - * signal the AP that the device has finished processing received - * data. - */ - gpio_set_level(GPIO_INT_AP_L, 0); - gpio_set_level(GPIO_INT_AP_L, 1); + if (seen_data) { + /* + * SPI does not provide inherent flow control. Let's + * use this pin to signal the AP that the device has + * finished processing received data. + */ + gpio_set_level(GPIO_INT_AP_L, 0); + gpio_set_level(GPIO_INT_AP_L, 1); + seen_data = 0; + } + } } static void sps_cs_deassert_interrupt(uint32_t port) |