summaryrefslogtreecommitdiff
path: root/chip
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2017-03-09 18:46:13 -0800
committerchrome-bot <chrome-bot@chromium.org>2017-03-10 08:34:22 -0800
commit2c0b6b7d3d354e636eacb6deaf2ebc6393f09550 (patch)
tree3d00a2443592363bbc9a18fc05cbaf5b60e328d2 /chip
parent876157085e0ce53de870f23993a6badc5683f16d (diff)
downloadchrome-ec-2c0b6b7d3d354e636eacb6deaf2ebc6393f09550.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>
Diffstat (limited to 'chip')
-rw-r--r--chip/g/sps.c23
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)