summaryrefslogtreecommitdiff
path: root/chip/stm32/usb_spi.h
diff options
context:
space:
mode:
authorAnton Staaf <robotboy@chromium.org>2014-12-02 10:42:22 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-12-08 21:51:59 +0000
commit9e1f4ed7015ac8543169fe41b74f1939a8b86f3b (patch)
tree96e0dbba21fffbb74f8c1b2420c58541501f5b0f /chip/stm32/usb_spi.h
parent731a2e74872159ecfa910c3174e9d3ae50ff2dae (diff)
downloadchrome-ec-9e1f4ed7015ac8543169fe41b74f1939a8b86f3b.tar.gz
USB-SPI: Switch from task to deferred function
The task based approach made sense when it looked like there would be a case closed debugging task to handle multiple bridges (SPI/I2C/USART...). I'm not convinced anymore that that task will be needed, so this simplification seems good. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Change-Id: Ic431c287c28d10252246fe9f507d9c5fcc64a077 Reviewed-on: https://chromium-review.googlesource.com/232733 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.h35
1 files changed, 15 insertions, 20 deletions
diff --git a/chip/stm32/usb_spi.h b/chip/stm32/usb_spi.h
index 4917c16f0b..5da35c91f6 100644
--- a/chip/stm32/usb_spi.h
+++ b/chip/stm32/usb_spi.h
@@ -8,6 +8,7 @@
/* STM32 USB SPI driver for Chrome EC */
#include "compile_time_macros.h"
+#include "hooks.h"
#include "usb.h"
/*
@@ -95,18 +96,16 @@ struct usb_spi_config {
int endpoint;
/*
+ * Deferred function to call to handle SPI request.
+ */
+ void (*deferred)(void);
+
+ /*
* Pointers to USB packet RAM and bounce buffer.
*/
uint16_t *buffer;
usb_uint *rx_ram;
usb_uint *tx_ram;
-
- /*
- * Callback to notify managing task that a new SPI request has been
- * received. This should wake up a task that will eventually call
- * the usb_spi_service_request function.
- */
- void (*ready)(struct usb_spi_config const *config);
};
/*
@@ -120,16 +119,14 @@ struct usb_spi_config {
*
* ENDPOINT is the index of the USB bulk endpoint used for receiving and
* transmitting bytes.
- *
- * READY callback function for command reception notification.
*/
#define USB_SPI_CONFIG(NAME, \
INTERFACE, \
- ENDPOINT, \
- READY) \
+ ENDPOINT) \
static uint16_t CONCAT2(NAME, _buffer_)[USB_MAX_PACKET_SIZE / 2]; \
static usb_uint CONCAT2(NAME, _ep_rx_buffer_)[USB_MAX_PACKET_SIZE / 2] __usb_ram; \
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, \
@@ -138,10 +135,10 @@ struct usb_spi_config {
.state = &CONCAT2(NAME, _state_), \
.interface = INTERFACE, \
.endpoint = ENDPOINT, \
+ .deferred = CONCAT2(NAME, _deferred_), \
.buffer = CONCAT2(NAME, _buffer_), \
.rx_ram = CONCAT2(NAME, _ep_rx_buffer_), \
.tx_ram = CONCAT2(NAME, _ep_tx_buffer_), \
- .ready = READY, \
}; \
const struct usb_interface_descriptor \
USB_IFACE_DESC(INTERFACE) = { \
@@ -184,17 +181,15 @@ struct usb_spi_config {
usb_uint *tx_buf) \
{ return usb_spi_interface(&NAME, rx_buf, tx_buf); } \
USB_DECLARE_IFACE(INTERFACE, \
- CONCAT2(NAME, _interface_));
+ CONCAT2(NAME, _interface_)); \
+ static void CONCAT2(NAME, _deferred_)(void) \
+ { usb_spi_deferred(&NAME); } \
+ DECLARE_DEFERRED(CONCAT2(NAME, _deferred_));
/*
- * Check for a new request and process it synchronously, the SPI transaction
- * will complete before this function returns.
- *
- * Returns:
- * 1: request serviced
- * 0: no request waiting
+ * Handle SPI request in a deferred callback.
*/
-int usb_spi_service_request(struct usb_spi_config const *config);
+void usb_spi_deferred(struct usb_spi_config const *config);
/*
* Set the enable state for the USB-SPI bridge.