diff options
author | Aseda Aboagye <aaboagye@google.com> | 2015-08-06 16:48:28 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-08-08 04:26:33 +0000 |
commit | c124e8cbc7a2215b418655f644df1fa204e253b4 (patch) | |
tree | 094893758b393bb5d86d122afe24b99f1596a0f3 | |
parent | 3a659c1fedb3536a6f04b80b65ff18df6ddb653f (diff) | |
download | chrome-ec-c124e8cbc7a2215b418655f644df1fa204e253b4.tar.gz |
stm32: Deprecate SPI protocol version 2.
Now that v3 support is in the cros_ec kernel driver and depthcharge,
deprecate support for the old v2 protocol. At some point in the future,
support for the v2 protocol will dropped entirely.
Boards that require support for the V2 protocol should enable the
following config option.
#define CONFIG_SPI_PROTOCOL_V2
BUG=chrome-os-partner:20533
BRANCH=None
TEST=make -j buildall tests
TEST=Flash jerry, AP & EC boot successful.
TEST=`ectool protoinfo` shows only version 3 supported on jerry.
TEST=Flashrom still works on jerry.
Change-Id: I72d3aee00879314b936cc0b1002c9883550b1f1a
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/291411
Trybot-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r-- | board/big/board.h | 1 | ||||
-rw-r--r-- | board/pit/board.h | 1 | ||||
-rw-r--r-- | chip/stm32/spi.c | 20 | ||||
-rw-r--r-- | include/config.h | 3 |
4 files changed, 22 insertions, 3 deletions
diff --git a/board/big/board.h b/board/big/board.h index e83d89ee5d..9f0f398e8b 100644 --- a/board/big/board.h +++ b/board/big/board.h @@ -22,6 +22,7 @@ #define CONFIG_I2C #define CONFIG_KEYBOARD_PROTOCOL_MKBP #define CONFIG_SPI +#define CONFIG_SPI_PROTOCOL_V2 #define CONFIG_PWM #define CONFIG_POWER_BUTTON #define CONFIG_VBOOT_HASH diff --git a/board/pit/board.h b/board/pit/board.h index b0846b5d03..10d99147e0 100644 --- a/board/pit/board.h +++ b/board/pit/board.h @@ -24,6 +24,7 @@ #define CONFIG_PMU_TPS65090 #define CONFIG_PMU_TPS65090_CHARGING_LED #define CONFIG_SPI +#define CONFIG_SPI_PROTOCOL_V2 #define CONFIG_VBOOT_HASH #ifndef __ASSEMBLER__ diff --git a/chip/stm32/spi.c b/chip/stm32/spi.c index abb86940a4..a4a8e9febc 100644 --- a/chip/stm32/spi.c +++ b/chip/stm32/spi.c @@ -48,6 +48,7 @@ static const struct dma_option dma_rx_option = { */ #define SPI_CMD_RX_TIMEOUT_US 8192 +#ifdef CONFIG_SPI_PROTOCOL_V2 /* * Offset of output parameters needs to account for pad and framing bytes and * one last past-end byte at the end so any additional bytes clocked out by @@ -56,7 +57,7 @@ static const struct dma_option dma_rx_option = { #define SPI_PROTO2_OFFSET (EC_PROTO2_RESPONSE_HEADER_BYTES + 2) #define SPI_PROTO2_OVERHEAD (SPI_PROTO2_OFFSET + \ EC_PROTO2_RESPONSE_TRAILER_BYTES + 1) - +#endif /* defined(CONFIG_SPI_PROTOCOL_V2) */ /* * Max data size for a version 3 request/response packet. This is big enough * to handle a request/response header, flash write offset/size, and 512 bytes @@ -103,7 +104,9 @@ static uint8_t out_msg[SPI_MAX_RESPONSE_SIZE + sizeof(out_preamble) + EC_SPI_PAST_END_LENGTH] __aligned(4); static uint8_t in_msg[SPI_MAX_REQUEST_SIZE] __aligned(4); static uint8_t enabled; +#ifdef CONFIG_SPI_PROTOCOL_V2 static struct host_cmd_handler_args args; +#endif static struct host_packet spi_packet; /* @@ -175,6 +178,7 @@ static int wait_for_bytes(stm32_dma_chan_t *rxdma, int needed, } } +#ifdef CONFIG_SPI_PROTOCOL_V2 /** * Send a reply on a given port. * @@ -247,6 +251,7 @@ static void reply(stm32_dma_chan_t *txdma, /* Kick off the DMA to send the data */ dma_go(txdma); } +#endif /* defined(CONFIG_SPI_PROTOCOL_V2) */ /** * Sends a byte over SPI without DMA @@ -339,7 +344,7 @@ static void check_setup_transaction_later(void) } } - +#ifdef CONFIG_SPI_PROTOCOL_V2 /** * Called for V2 protocol to indicate that a command has completed * @@ -375,6 +380,7 @@ static void spi_send_response(struct host_cmd_handler_args *args) state = SPI_STATE_SENDING; check_setup_transaction_later(); } +#endif /* defined(CONFIG_SPI_PROTOCOL_V2) */ /** * Called to send a response back to the host. @@ -528,6 +534,7 @@ void spi_event(enum gpio_signal signal) return; } else if (in_msg[0] >= EC_CMD_VERSION0) { +#ifdef CONFIG_SPI_PROTOCOL_V2 /* * Protocol version 2 * @@ -572,6 +579,10 @@ void spi_event(enum gpio_signal signal) host_command_received(&args); return; +#else /* !defined(CONFIG_SPI_PROTOCOL_V2) */ + /* Protocol version 2 is deprecated. */ + CPRINTS("ERROR: Protocol V2 is not supported!"); +#endif /* defined(CONFIG_SPI_PROTOCOL_V2) */ } spi_event_error: @@ -664,7 +675,10 @@ static int spi_get_protocol_info(struct host_cmd_handler_args *args) struct ec_response_get_protocol_info *r = args->response; memset(r, 0, sizeof(*r)); - r->protocol_versions = (1 << 2) | (1 << 3); +#ifdef CONFIG_SPI_PROTOCOL_V2 + r->protocol_versions |= (1 << 2); +#endif + r->protocol_versions |= (1 << 3); r->max_request_packet_size = SPI_MAX_REQUEST_SIZE; r->max_response_packet_size = SPI_MAX_RESPONSE_SIZE; r->flags = EC_PROTOCOL_INFO_IN_PROGRESS_SUPPORTED; diff --git a/include/config.h b/include/config.h index d7efc38e05..603062f6da 100644 --- a/include/config.h +++ b/include/config.h @@ -1349,6 +1349,9 @@ /* Support SPI interfaces */ #undef CONFIG_SPI +/* Support deprecated SPI protocol version 2. */ +#undef CONFIG_SPI_PROTOCOL_V2 + /* * Support SPI Slave interfaces. The first board supporting this is cr50 and * in its parlance SPI_SLAVE is called SPS. This convention might be |