diff options
author | Shawn Nematbakhsh <shawnn@chromium.org> | 2017-08-24 08:57:42 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-08-28 15:24:14 -0700 |
commit | 4e46386877adbc0f2f85e78670051d68143b5b1f (patch) | |
tree | d72709f3ee17631b1ba2a33f33e190b121a813ad | |
parent | 88abd3ee7284862fd7b76d251aabc4d79a735831 (diff) | |
download | chrome-ec-4e46386877adbc0f2f85e78670051d68143b5b1f.tar.gz |
tcpm: fusb302: Round VNC and Rd thresholds to nearest step
fusb302 determines attach / no-attach (and Rd / Ra) by comparing CC
voltage against an MDAC output (42 mV steps). The previous 'floor'
calculation was particularly bad for 3.0A Rp (2600 / 42 = 61, 61 * 42 =
2562 mV - 21 = 2551 mV actual threshold, ignoring other error sources).
Reduce the chance of error by rounding our thresholds, which also
matches the suggested thresholds in the datasheet.
BUG=chromium:758608
BRANCH=gru
TEST=Attach problematic dingdong, verify we don't enter an attach /
detach loop.
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I9211782da0fdad8339246e272952ba1930b69851
Reviewed-on: https://chromium-review.googlesource.com/633276
Reviewed-by: Joe Bauman <joe.bauman@fairchildsemi.com>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
(cherry picked from commit 311b3e4e15fd37ea2ab151edb8b8a468e93355fd)
Reviewed-on: https://chromium-review.googlesource.com/638694
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r-- | driver/tcpm/fusb302.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/driver/tcpm/fusb302.h b/driver/tcpm/fusb302.h index 1773645e91..6236e47439 100644 --- a/driver/tcpm/fusb302.h +++ b/driver/tcpm/fusb302.h @@ -50,7 +50,12 @@ #define TCPC_REG_MEASURE 0x04 #define TCPC_REG_MEASURE_VBUS (1<<6) -#define TCPC_REG_MEASURE_MDAC_MV(mv) (((mv)/42) & 0x3f) +/* + * MDAC reference voltage step size is 42 mV. Round our thresholds to reduce + * maximum error, which also matches suggested thresholds in datasheet + * (Table 3. Host Interrupt Summary). + */ +#define TCPC_REG_MEASURE_MDAC_MV(mv) (DIV_ROUND_NEAREST((mv), 42) & 0x3f) #define TCPC_REG_CONTROL0 0x06 #define TCPC_REG_CONTROL0_TX_FLUSH (1<<6) |