diff options
author | Stefan Adolfsson <sadolfsson@google.com> | 2018-05-06 20:19:37 +0200 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2018-06-19 20:02:11 +0000 |
commit | f040716c3fd06bb647449f8dac2fa0e36842ac21 (patch) | |
tree | 3d475a7e75f63931936df3d03aea5beb829f2ca8 | |
parent | 63aaa1ab2b166ed48e5a52d54ba6d3714660db8e (diff) | |
download | chrome-ec-f040716c3fd06bb647449f8dac2fa0e36842ac21.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
Reviewed-on: https://chromium-review.googlesource.com/1030371
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Change-Id: I19e510ec0b6e987e0d8477fa5549e0b29ef594ee
Reviewed-on: https://chromium-review.googlesource.com/1055830
Tested-by: Stefan Adolfsson <sadolfsson@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Commit-Queue: Stefan Adolfsson <sadolfsson@chromium.org>
-rw-r--r-- | chip/npcx/cec.c | 20 |
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; |