diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2015-07-25 02:14:13 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-07-30 19:57:55 +0000 |
commit | 5b71b33aba6cb0108a864cc7000918b8f06b139a (patch) | |
tree | aa49a59a306d91b189e9fcdddc3bbb0e2deba628 /board/discovery-stm32f072 | |
parent | 9008c7a4fd131a96ccb0078a46ec545cff2f43b1 (diff) | |
download | chrome-ec-5b71b33aba6cb0108a864cc7000918b8f06b139a.tar.gz |
common: change interface to SPI flash
Allow more than one SPI master.
Add CONFIG variables to address the system SPI flash.
To have SPI master ports, spi_ports array must be defined.
BRANCH=smaug
TEST=compile
BUG=chrome-os-partner:42304
Change-Id: Id43869f648965c1582b7be1c7fb3a38f175fda95
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/288512
Commit-Queue: David James <davidjames@chromium.org>
Diffstat (limited to 'board/discovery-stm32f072')
-rw-r--r-- | board/discovery-stm32f072/board.c | 11 | ||||
-rw-r--r-- | board/discovery-stm32f072/board.h | 5 |
2 files changed, 12 insertions, 4 deletions
diff --git a/board/discovery-stm32f072/board.c b/board/discovery-stm32f072/board.c index 0ce00c9368..7aa9a70555 100644 --- a/board/discovery-stm32f072/board.c +++ b/board/discovery-stm32f072/board.c @@ -144,6 +144,13 @@ BUILD_ASSERT(ARRAY_SIZE(usb_strings) == USB_STR_COUNT); * Support SPI bridging over USB, this requires usb_spi_board_enable and * usb_spi_board_disable to be defined to enable and disable the SPI bridge. */ + +/* SPI devices */ +const struct spi_device_t spi_devices[] = { + { CONFIG_SPI_FLASH_PORT, 0, GPIO_SPI_CS}, +}; +const unsigned int spi_devices_used = ARRAY_SIZE(spi_devices); + void usb_spi_board_enable(struct usb_spi_config const *config) { /* Remap SPI2 to DMA channels 6 and 7 */ @@ -162,12 +169,12 @@ void usb_spi_board_enable(struct usb_spi_config const *config) STM32_RCC_APB1RSTR |= STM32_RCC_PB1_SPI2; STM32_RCC_APB1RSTR &= ~STM32_RCC_PB1_SPI2; - spi_enable(1); + spi_enable(CONFIG_SPI_FLASH_PORT, 1); } void usb_spi_board_disable(struct usb_spi_config const *config) { - spi_enable(0); + spi_enable(CONFIG_SPI_FLASH_PORT, 0); /* Disable clocks to SPI2 module */ STM32_RCC_APB1ENR &= ~STM32_RCC_PB1_SPI2; diff --git a/board/discovery-stm32f072/board.h b/board/discovery-stm32f072/board.h index ef839bfc49..2e57167604 100644 --- a/board/discovery-stm32f072/board.h +++ b/board/discovery-stm32f072/board.h @@ -49,8 +49,9 @@ #define CONFIG_USB_GPIO /* Enable control of SPI over USB */ -#define CONFIG_SPI_MASTER_PORT 2 -#define CONFIG_SPI_CS_GPIO GPIO_SPI_CS +#define CONFIG_SPI_MASTER +#define CONFIG_SPI_FLASH_PORT 0 /* First SPI master port */ + #define CONFIG_USB_SPI |