summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2014-08-18 10:16:21 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-08-18 23:16:22 +0000
commita25d675bc00fdbde0f30b31af4a58a9616aa8eed (patch)
tree724c80b289aa7d0a60ca7de533060a097d191bfb /board
parente1ff1a3caef94bef3c2ea9e8036aa784be26ef1b (diff)
downloadchrome-ec-a25d675bc00fdbde0f30b31af4a58a9616aa8eed.tar.gz
samus_pd: Enable both comparator at the same time
We use window mode to share the non-inverting input of the two comparators. If COMP1 is not enabled, it causes problem on the operation of COMP2. Fix this by enabling both comparator at the same time. BUG=chrome-os-partner:31400 TEST=Reboot PD MCU, and plug into port 1. See SNK_READY state. BRANCH=None Change-Id: Icb7e7acdb8a09e094c24839c1d7b398b2c3fb9c0 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/212921 Reviewed-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'board')
-rw-r--r--board/samus_pd/usb_pd_config.h20
1 files changed, 11 insertions, 9 deletions
diff --git a/board/samus_pd/usb_pd_config.h b/board/samus_pd/usb_pd_config.h
index 60925b3077..c6ec62e2cf 100644
--- a/board/samus_pd/usb_pd_config.h
+++ b/board/samus_pd/usb_pd_config.h
@@ -162,19 +162,21 @@ static inline void pd_tx_disable(int port, int polarity)
/* we know the plug polarity, do the right configuration */
static inline void pd_select_polarity(int port, int polarity)
{
+ uint32_t val = STM32_COMP_CSR;
+
+ /* Use window mode so that COMP1 and COMP2 share non-inverting input */
+ val |= STM32_COMP_CMP1EN | STM32_COMP_CMP2EN | STM32_COMP_WNDWEN;
+
if (port == 0) {
/* use the right comparator inverted input for COMP1 */
- STM32_COMP_CSR = (STM32_COMP_CSR & ~STM32_COMP_CMP1INSEL_MASK)
- | STM32_COMP_CMP1EN
- | (polarity ? STM32_COMP_CMP1INSEL_INM4
- : STM32_COMP_CMP1INSEL_INM6);
+ STM32_COMP_CSR = (val & ~STM32_COMP_CMP1INSEL_MASK) |
+ (polarity ? STM32_COMP_CMP1INSEL_INM4
+ : STM32_COMP_CMP1INSEL_INM6);
} else {
/* use the right comparator inverted input for COMP2 */
- /* use window mode on COMP2 to use COMP1 non-inverting input */
- STM32_COMP_CSR = (STM32_COMP_CSR & ~STM32_COMP_CMP2INSEL_MASK)
- | STM32_COMP_CMP2EN | STM32_COMP_WNDWEN
- | (polarity ? STM32_COMP_CMP2INSEL_INM5
- : STM32_COMP_CMP2INSEL_INM6);
+ STM32_COMP_CSR = (val & ~STM32_COMP_CMP2INSEL_MASK) |
+ (polarity ? STM32_COMP_CMP2INSEL_INM5
+ : STM32_COMP_CMP2INSEL_INM6);
}
}