diff options
author | Simon Glass <sjg@chromium.org> | 2012-07-27 11:13:45 +0100 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-09-17 10:10:14 -0700 |
commit | 78474d4eeb29537e7fd0ca071cf0a78a464e5f90 (patch) | |
tree | 014ddf606179598537106a3bebfb5f8245f8b378 /include/spi.h | |
parent | b4d73d3c72d5773e39812ba069dfff12d6da71c1 (diff) | |
download | chrome-ec-78474d4eeb29537e7fd0ca071cf0a78a464e5f90.tar.gz |
spi: Rewrite driver for new protocol, better performance
The old spi driver has atrophied in various ways. It doesn't support
the new protocol and does not build either.
Rewrite the driver to:
- Use dma for reception (rather than just reception)
- This makes message reception more robust and allows us to process
the new multi-byte commands
- Add timeouts for rx and tx so that we don't wait forever
- Increase buffer sizes to deal with new larger messages
- Always send a preamble byte regardless of SPI clock speed
(previously above 10MHz we sometimes miss this)
- Use the NSS line to delineate transactions. When it drops, a
transaction is starting. When it rises the transaction is immediately
terminates regardless of state. This keeps the AP and EC in sync even
in the event of timeouts, bus errors and other oddities.
- Implement the new protocol which has a checksum, version byte, etc
- Set up tx dma in advance and kick it when ready, thus ensuring that
a message body is always attached immediately after the preamble
- Use the new host_cmd_handle_args structure, which makes things much
easier for us, since we don't need globals, and can use the
send_response handler to know when a slow command is complete.
- Handle the new type of 'slow' commands properly
BUG=chrome-os-partner:10533
TEST=manual
build and boot to kernel on snow
Change-Id: I11767d1a6f045a86f6c9a0b4b1e943b660e4da33
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/32076
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'include/spi.h')
-rw-r--r-- | include/spi.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/include/spi.h b/include/spi.h index 4af03bc365..a03e04f134 100644 --- a/include/spi.h +++ b/include/spi.h @@ -19,4 +19,20 @@ int spi_enable(int enable); int spi_transaction(const uint8_t *txdata, int txlen, uint8_t *rxdata, int rxlen); +#ifdef CONFIG_SPI +/** + * Called when the NSS level changes, signalling the start or end of a SPI + * transaction. + * + * @param signal GPIO signal that changed + */ +void spi_event(enum gpio_signal signal); + +#else +static inline void spi_event(enum gpio_signal signal) +{ +} + +#endif + #endif /* __CROS_EC_SPI_H */ |