diff options
author | Scott Collyer <scollyer@google.com> | 2021-03-10 21:47:53 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-03-16 16:51:46 +0000 |
commit | 16aaf46a09b0b0f8b140ea639fe280c222d7b84c (patch) | |
tree | a78f3173ba83cb3edf3428aa743715fd60f9c031 /chip/stm32 | |
parent | 1fa94b164460c1e79775f052eafdf03bc450e68f (diff) | |
download | chrome-ec-16aaf46a09b0b0f8b140ea639fe280c222d7b84c.tar.gz |
ucpd: Add support to turn off type-2 BIST mode
This CL adds changes to the ucpd driver to support turning off BIST
mode once it's been started. For ucpd, the peripheral has to be
disabled and reset for this purpose.
BUG=b:182436876
BRANCH=None
TEST=Verfied that honeybuns can pass TDA.2.1.1.1: BMC-PHY-TX-EYE
compliance test, which previously was failing because BIST type-2 mode
was not being stopped.
Signed-off-by: Scott Collyer <scollyer@google.com>
Change-Id: Ib6aa898ef5727dd5887e5d1c0b2eee94fdb366b3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2751328
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Diana Z <dzigterman@chromium.org>
Commit-Queue: Scott Collyer <scollyer@chromium.org>
Diffstat (limited to 'chip/stm32')
-rw-r--r-- | chip/stm32/ucpd-stm32gx.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/chip/stm32/ucpd-stm32gx.c b/chip/stm32/ucpd-stm32gx.c index e9693dfa1e..47045229fc 100644 --- a/chip/stm32/ucpd-stm32gx.c +++ b/chip/stm32/ucpd-stm32gx.c @@ -388,11 +388,23 @@ static void ucpd_rx_enque_error(void) } DECLARE_DEFERRED(ucpd_rx_enque_error); +static void stm32gx_ucpd_state_init(int port) +{ + /* Init variables used to manage tx process */ + ucpd_tx_request = 0; + tx_retry_count = 0; + ucpd_tx_state = STATE_IDLE; + ucpd_timeout_us = -1; +} + int stm32gx_ucpd_init(int port) { uint32_t cfgr1_reg; uint32_t moder_reg; + /* Disable UCPD interrupts */ + task_disable_irq(STM32_IRQ_UCPD1); + /* * After exiting reset, stm32gx will have dead battery mode enabled by * default which connects Rd to CC1/CC2. This should be disabled when EC @@ -439,6 +451,8 @@ int stm32gx_ucpd_init(int port) /* SOP'/SOP'' must be enabled via TCPCI call */ ucpd_rx_sop_prime_enabled = false; + stm32gx_ucpd_state_init(port); + /* Enable UCPD interrupts */ task_enable_irq(STM32_IRQ_UCPD1); @@ -904,10 +918,7 @@ void ucpd_task(void *p) const int port = (int) ((intptr_t) p); /* Init variables used to manage tx process */ - ucpd_tx_request = 0; - tx_retry_count = 0; - ucpd_tx_state = STATE_IDLE; - ucpd_timeout_us = -1; + stm32gx_ucpd_state_init(port); while (1) { /* @@ -1344,11 +1355,16 @@ static int command_ucpd(int argc, char **argv) if (!strcasecmp(argv[1], "rst")) { /* Force reset of ucpd peripheral */ stm32gx_ucpd_init(port); + pd_execute_hard_reset(port); + task_set_event(PD_PORT_TO_TASK_ID(port), TASK_EVENT_WAKE); } else if (!strcasecmp(argv[1], "info")) { ucpd_info(port); } else if (!strcasecmp(argv[1], "bist")) { - stm32gx_ucpd_transmit(port, TCPC_TX_BIST_MODE_2, 0, - &tx_data); + /* Need to initiate via DPM to have a timer */ + /* TODO(b/182861002): uncomment when Gingerbread has + * full PD support landed. + * pd_dpm_request(port, DPM_REQUEST_BIST_TX); + */ } else if (!strcasecmp(argv[1], "hard")) { stm32gx_ucpd_transmit(port, TCPC_TX_HARD_RESET, 0, &tx_data); |