summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Adolfsson <sadolfsson@google.com>2018-05-06 20:19:37 +0200
committerchrome-bot <chrome-bot@chromium.org>2018-05-11 09:30:35 -0700
commit64cf05b7e8793bc04258bda702b763755d5f15ee (patch)
tree555981bd3ad5c315f832a5191ff91b8c02e8f597
parentad01d0518be65143149b72b3079bef2cdfa166cd (diff)
downloadchrome-ec-64cf05b7e8793bc04258bda702b763755d5f15ee.tar.gz
npcx: CEC: Respect the present initiator free-time
When sending multiple frames, the free-time is a bit higher to make it easier for other senders to get a chance to send. Signed-off-by: Stefan Adolfsson <sadolfsson@chromium.org> BUG=b:76467407 BRANCH=none TEST=none CQ-DEPEND=CL:1030370 Change-Id: I19e510ec0b6e987e0d8477fa5549e0b29ef594ee Reviewed-on: https://chromium-review.googlesource.com/1030371 Commit-Ready: Stefan Adolfsson <sadolfsson@chromium.org> Tested-by: Stefan Adolfsson <sadolfsson@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--chip/npcx/cec.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/chip/npcx/cec.c b/chip/npcx/cec.c
index 6e152714a9..7d02bb5681 100644
--- a/chip/npcx/cec.c
+++ b/chip/npcx/cec.c
@@ -53,10 +53,15 @@
#error "Buffer size must not exceed 255 since offsets are uint8_t"
#endif
-/* Free time timing (us). */
+/*
+ * Free time timing (us). Our free-time is calculated from the end of
+ * the last bit (not from the start). We compensate by having one
+ * free-time period less than in the spec.
+ */
#define NOMINAL_BIT_TIME APB1_TICKS(2400)
-#define FREE_TIME_RS (3 * (NOMINAL_BIT_TIME)) /* Resend */
-#define FREE_TIME_NI (5 * (NOMINAL_BIT_TIME)) /* New initiator */
+#define FREE_TIME_RS (2 * (NOMINAL_BIT_TIME)) /* Resend */
+#define FREE_TIME_NI (4 * (NOMINAL_BIT_TIME)) /* New initiator */
+#define FREE_TIME_PI (6 * (NOMINAL_BIT_TIME)) /* Present initiator */
/* Start bit timing (us) */
#define START_BIT_LOW APB1_TICKS(3700)
@@ -231,6 +236,11 @@ struct cec_tx {
uint8_t resends;
/* Acknowledge received from sink? */
uint8_t ack;
+ /*
+ * When sending multiple concurrent frames,
+ * the free-time is slightly higher
+ */
+ int present_initiator;
};
/* Single state for CEC. We are INITIATOR, FOLLOWER or IDLE */
@@ -497,10 +507,13 @@ void enter_state(enum cec_state new_state)
cap_edge = CAP_EDGE_FALLING;
if (cec_tx.resends)
timeout = FREE_TIME_RS;
+ else if (cec_tx.present_initiator)
+ timeout = FREE_TIME_PI;
else
timeout = FREE_TIME_NI;
break;
case CEC_STATE_INITIATOR_START_LOW:
+ cec_tx.present_initiator = 1;
cec_tx.msgt.bit = 0;
cec_tx.msgt.byte = 0;
gpio = 0;
@@ -561,6 +574,7 @@ void enter_state(enum cec_state new_state)
timeout = NOMINAL_BIT_TIME - NOMINAL_SAMPLE_TIME;
break;
case CEC_STATE_FOLLOWER_START_LOW:
+ cec_tx.present_initiator = 0;
cap_edge = CAP_EDGE_RISING;
timeout = CAP_START_LOW;
break;