summaryrefslogtreecommitdiff
path: root/chip/stm32/usb_spi.h
diff options
context:
space:
mode:
authorAnton Staaf <robotboy@chromium.org>2015-03-17 11:49:29 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-03-23 19:23:35 +0000
commita0158dd136b63b2daffd666d51d84a67481cb609 (patch)
treeb3ceb010fbba052fb63825d862a0ef2eae2767a6 /chip/stm32/usb_spi.h
parent4002d66297f381c18e1118fa8e2cc156bc5baffd (diff)
downloadchrome-ec-a0158dd136b63b2daffd666d51d84a67481cb609.tar.gz
CCD: Add ability to enable and disable SPI bridgestabilize-6909.B
This required changing the USB-SPI implementation slightly so that all work is done within the deferred callback. In particular, this allows the board specific enable and disable functions to do things that can only be done from a task context, like sleeping. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Change-Id: I3f6a01ed9d6f31a3259ba0a0f6b4e123d6d2e718 Reviewed-on: https://chromium-review.googlesource.com/260964 Trybot-Ready: Anton Staaf <robotboy@chromium.org> Tested-by: Anton Staaf <robotboy@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org>
Diffstat (limited to 'chip/stm32/usb_spi.h')
-rw-r--r--chip/stm32/usb_spi.h28
1 files changed, 21 insertions, 7 deletions
diff --git a/chip/stm32/usb_spi.h b/chip/stm32/usb_spi.h
index 316c827420..76719c6d2c 100644
--- a/chip/stm32/usb_spi.h
+++ b/chip/stm32/usb_spi.h
@@ -69,12 +69,25 @@ BUILD_ASSERT(USB_MAX_PACKET_SIZE == (2 + USB_SPI_MAX_READ_COUNT));
struct usb_spi_state {
/*
- * The SPI bridge must be both not disabled and enabled to allow access
- * to the SPI device. The disabled bit is dictated by the caller of
- * usb_spi_enable. The enabled bit is set by the USB host, most likely
- * flashrom, by sending a USB_SPI_REQ_ENABLE message to the device.
+ * The SPI bridge must be enabled both locally and by the host to allow
+ * access to the SPI device. The enabled_host flag is set and cleared
+ * by sending USB_SPI_REQ_ENABLE and USB_SPI_REQ_DISABLE to the device
+ * control endpoint. The enabled_device flag is set by calling
+ * usb_spi_enable.
+ */
+ int enabled_host;
+ int enabled_device;
+
+ /*
+ * The current enabled state. This is only updated in the deferred
+ * callback. Whenever either of the host or device specific enable
+ * flags is changed the deferred callback is queued, and it will check
+ * their combined state against this flag. If the combined state is
+ * different, then one of usb_spi_board_enable or usb_spi_board_disable
+ * is called and this flag is updated. This ensures that the board
+ * specific state update routines are only called from the deferred
+ * callback.
*/
- int disabled;
int enabled;
};
@@ -128,8 +141,9 @@ struct usb_spi_config {
static usb_uint CONCAT2(NAME, _ep_tx_buffer_)[USB_MAX_PACKET_SIZE / 2] __usb_ram; \
static void CONCAT2(NAME, _deferred_)(void); \
struct usb_spi_state CONCAT2(NAME, _state_) = { \
- .disabled = 1, \
- .enabled = 0, \
+ .enabled_host = 0, \
+ .enabled_device = 0, \
+ .enabled = 0, \
}; \
struct usb_spi_config const NAME = { \
.state = &CONCAT2(NAME, _state_), \