diff options
author | Jett Rink <jettrink@chromium.org> | 2020-01-10 11:48:43 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-01-29 19:52:45 +0000 |
commit | f22bc063c93bf1245f872008116359f484cadf70 (patch) | |
tree | 4181b6ee0be5e732b986ac6b427aa4f2ce4e63dc /chip/stm32/usb_spi.c | |
parent | 1e5b4a11489173de522836224951a47e9aef7c35 (diff) | |
download | chrome-ec-f22bc063c93bf1245f872008116359f484cadf70.tar.gz |
spi: keep HW SPI module enabled longer
When the HW SPI module is disabled (i.e. SPE bit is cleared), then the
stm stops actively driving the SPI CLK signal and lets it float. This
can cause spurious communication issues or guaranteed issues if there is a
pullup on the CLK signal.
Ensure that the CLK signal is being driven (low) for the duration of a
USB SPI transaction at minimum.
Driving the CLK signal low for the duration of the SPI transaction also
seems to help with sporadic reliability issues on servo_micro
Also add a flag that enables the SPI module to be enabled for the
entire time the firmware wants to enable the SPI module opposed to
needing both the firmware and the USB host to enabled the SPI module.
BRANCH=servo
BUG=b:145314772,b:144846350
TEST=with scope verify that SPI CLK line is help low as soon at the
`enable_spi 1800` command is enter on C2D2 console and continues to stay
low in between all USB SPI traffic from host.
Change-Id: I9dbd6b3ebca8db6470d9ec70bae02ac8366d6c9e
Signed-off-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1995604
Reviewed-by: Brian Nemec <bnemec@chromium.org>
Reviewed-by: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'chip/stm32/usb_spi.c')
-rw-r--r-- | chip/stm32/usb_spi.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/chip/stm32/usb_spi.c b/chip/stm32/usb_spi.c index b560b55709..597d4c5df7 100644 --- a/chip/stm32/usb_spi.c +++ b/chip/stm32/usb_spi.c @@ -69,14 +69,19 @@ static int rx_valid(struct usb_spi_config const *config) void usb_spi_deferred(struct usb_spi_config const *config) { + int enabled; + + if (config->flags & USB_SPI_CONFIG_FLAGS_IGNORE_HOST_SIDE_ENABLE) + enabled = config->state->enabled_device; + else + enabled = config->state->enabled_device && + config->state->enabled_host; + /* * If our overall enabled state has changed we call the board specific * enable or disable routines and save our new state. */ - int enabled = (config->state->enabled_host && - config->state->enabled_device); - - if (enabled ^ config->state->enabled) { + if (enabled != config->state->enabled) { if (enabled) usb_spi_board_enable(config); else usb_spi_board_disable(config); @@ -180,7 +185,8 @@ int usb_spi_interface(struct usb_spi_config const *config, * Our state has changed, call the deferred function to handle the * state change. */ - hook_call_deferred(config->deferred, 0); + if (!(config->flags & USB_SPI_CONFIG_FLAGS_IGNORE_HOST_SIDE_ENABLE)) + hook_call_deferred(config->deferred, 0); btable_ep[0].tx_count = 0; STM32_TOGGLE_EP(0, EP_TX_RX_MASK, EP_TX_RX_VALID, EP_STATUS_OUT); |