From 64cf05b7e8793bc04258bda702b763755d5f15ee Mon Sep 17 00:00:00 2001 From: Stefan Adolfsson Date: Sun, 6 May 2018 20:19:37 +0200 Subject: 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 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 Tested-by: Stefan Adolfsson Reviewed-by: Randall Spangler --- chip/npcx/cec.c | 20 +++++++++++++++++--- 1 file 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; -- cgit v1.2.1