diff options
author | Vincent Palatin <vpalatin@chromium.org> | 2014-10-29 17:03:35 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-10-30 09:57:10 +0000 |
commit | d4f3279db9d31159624449828362e45062bd7703 (patch) | |
tree | 6025f9552c378d5d3a8295040e6a7cfa3f022a55 | |
parent | bd9a53f3229018ec3fce077118c7e33e0561453c (diff) | |
download | chrome-ec-d4f3279db9d31159624449828362e45062bd7703.tar.gz |
twinkie: fix CC2 reception in PD injector mode
Properly set the comparator output when using CC2.
Also add some basic LED color to display the current power contract when
we are a sink :
- green : 5V
- red : 20V
- blue : other voltage
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BRANCH=none
BUG=none
TEST=plug to Zinger in each plug direction and see green then red LED.
type "pd 0 dev 12" and see the blue LED.
Change-Id: I4eb4339568eda5871c7f3df75bedebd97238e941
Reviewed-on: https://chromium-review.googlesource.com/226385
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r-- | board/twinkie/usb_pd_config.h | 4 | ||||
-rw-r--r-- | board/twinkie/usb_pd_policy.c | 7 |
2 files changed, 9 insertions, 2 deletions
diff --git a/board/twinkie/usb_pd_config.h b/board/twinkie/usb_pd_config.h index 649b7a802e..e32b29fd67 100644 --- a/board/twinkie/usb_pd_config.h +++ b/board/twinkie/usb_pd_config.h @@ -48,9 +48,9 @@ static inline void spi_enable_clock(int port) STM32_RCC_APB2ENR |= STM32_RCC_PB2_SPI1; } -/* RX is using COMP1 triggering TIM1 CH1 */ +/* RX is using COMP1 or COMp2 triggering TIM1 CH1 */ #define CMP1OUTSEL STM32_COMP_CMP1OUTSEL_TIM1_IC1 -#define CMP2OUTSEL 0 +#define CMP2OUTSEL STM32_COMP_CMP2OUTSEL_TIM1_IC1 #define DMAC_TIM_RX(p) STM32_DMAC_CH2 #define TIM_RX_CCR_IDX(p) TIM_RX_CCR_C0 diff --git a/board/twinkie/usb_pd_policy.c b/board/twinkie/usb_pd_policy.c index acfa5ab4e5..d71770e4ec 100644 --- a/board/twinkie/usb_pd_policy.c +++ b/board/twinkie/usb_pd_policy.c @@ -6,6 +6,7 @@ #include "common.h" #include "config.h" #include "console.h" +#include "gpio.h" #include "hooks.h" #include "registers.h" #include "task.h" @@ -81,6 +82,12 @@ int pd_choose_voltage(int cnt, uint32_t *src_caps, uint32_t *rdo, void pd_set_input_current_limit(int port, uint32_t max_ma, uint32_t supply_voltage) { + int red = supply_voltage == 20000; + int green = supply_voltage == 5000; + int blue = supply_voltage && !(red || green); + gpio_set_level(GPIO_LED_R_L, !red); + gpio_set_level(GPIO_LED_G_L, !green); + gpio_set_level(GPIO_LED_B_L, !blue); } void pd_set_max_voltage(unsigned mv) |