summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorJes B. Klinke <jbk@chromium.org>2023-03-19 20:19:33 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-03-28 22:01:27 +0000
commit3d67ca20c4432a7258d4710c0be07d344998c992 (patch)
tree1d716eb70ba3e9a58e2944bc2170db5b53a59c2b /board
parent625d268fbd803a8af8d65f38aa60ec5d910feb69 (diff)
downloadchrome-ec-3d67ca20c4432a7258d4710c0be07d344998c992.tar.gz
chip/stm32: Eliminate support for multiple USB->SPI instances
For some reason, all methods in usb_spi.c pass along pointers to config and state, as if prepared to have multiple USB interfaces each implementing their own instance of the SPI->USB bridge protocol. Doing so would make little sense, as a single instance is already able to manipulate multiple SPI busses. This CL eliminates the pointer parameters, for a tiny performance improvement, and code simplification. BUG=b:273601311 TEST=none Change-Id: Ifbfdb18b4a2ba656732e4eb143de9f678416067a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4352128 Reviewed-by: Brian Nemec <bnemec@google.com> Tested-by: Jes Klinke <jbk@chromium.org> Commit-Queue: Jes Klinke <jbk@chromium.org>
Diffstat (limited to 'board')
-rw-r--r--board/c2d2/board.c12
-rw-r--r--board/discovery-stm32f072/board.c8
-rw-r--r--board/hammer/board.c8
-rw-r--r--board/hyperdebug/board.c4
-rw-r--r--board/hyperdebug/spi.c4
-rw-r--r--board/servo_micro/board.c12
6 files changed, 24 insertions, 24 deletions
diff --git a/board/c2d2/board.c b/board/c2d2/board.c
index 02fce6143e..5e63b7dcec 100644
--- a/board/c2d2/board.c
+++ b/board/c2d2/board.c
@@ -297,7 +297,7 @@ const struct spi_device_t spi_devices[] = {
};
const unsigned int spi_devices_used = ARRAY_SIZE(spi_devices);
-void usb_spi_board_enable(struct usb_spi_config const *config)
+void usb_spi_board_enable(void)
{
/* Configure SPI GPIOs */
gpio_config_module(MODULE_SPI_FLASH, 1);
@@ -315,7 +315,7 @@ void usb_spi_board_enable(struct usb_spi_config const *config)
spi_enable(&spi_devices[0], 1);
}
-void usb_spi_board_disable(struct usb_spi_config const *config)
+void usb_spi_board_disable(void)
{
spi_enable(&spi_devices[0], 0);
@@ -329,7 +329,7 @@ void usb_spi_board_disable(struct usb_spi_config const *config)
STM32_GPIO_OSPEEDR(GPIO_B) &= ~0xff000000;
}
-USB_SPI_CONFIG(usb_spi, USB_IFACE_SPI, USB_EP_SPI,
+USB_SPI_CONFIG(USB_IFACE_SPI, USB_EP_SPI,
USB_SPI_CONFIG_FLAGS_IGNORE_HOST_SIDE_ENABLE);
/******************************************************************************
@@ -531,7 +531,7 @@ static int command_enable_spi(int argc, const char **argv)
gpio_set_level(GPIO_EN_CLK_CSN_EC_UART, 0);
/* Disable SPI. Sets SPI pins to inputs. */
- usb_spi_enable(&usb_spi, 0);
+ usb_spi_enable(0);
/* Set default state for chip select */
gpio_set_flags(GPIO_SPI_CSN, GPIO_INPUT);
@@ -584,7 +584,7 @@ static int command_enable_spi(int argc, const char **argv)
gpio_set_flags(GPIO_SPI_CSN, GPIO_OUT_HIGH);
/* Enable SPI. Sets SPI pins to SPI alternate mode. */
- usb_spi_enable(&usb_spi, 1);
+ usb_spi_enable(1);
/* Set requested Vref voltage */
gpio_set_level(GPIO_SEL_SPIVREF_H1VREF_3V3,
@@ -1072,6 +1072,6 @@ static void board_jump(void)
usart_shutdown(&usart4);
/* Ensure SPI2 is disabled as well */
- usb_spi_enable(&usb_spi, 0);
+ usb_spi_enable(0);
}
DECLARE_HOOK(HOOK_SYSJUMP, board_jump, HOOK_PRIO_DEFAULT);
diff --git a/board/discovery-stm32f072/board.c b/board/discovery-stm32f072/board.c
index fb61ea1232..b6f0aa9883 100644
--- a/board/discovery-stm32f072/board.c
+++ b/board/discovery-stm32f072/board.c
@@ -132,7 +132,7 @@ const struct spi_device_t spi_devices[] = {
};
const unsigned int spi_devices_used = ARRAY_SIZE(spi_devices);
-void usb_spi_board_enable(struct usb_spi_config const *config)
+void usb_spi_board_enable(void)
{
/* Remap SPI2 to DMA channels 6 and 7 */
STM32_SYSCFG_CFGR1 |= BIT(24);
@@ -153,7 +153,7 @@ void usb_spi_board_enable(struct usb_spi_config const *config)
spi_enable(&spi_devices[0], 1);
}
-void usb_spi_board_disable(struct usb_spi_config const *config)
+void usb_spi_board_disable(void)
{
spi_enable(&spi_devices[0], 0);
@@ -164,7 +164,7 @@ void usb_spi_board_disable(struct usb_spi_config const *config)
gpio_config_module(MODULE_SPI_FLASH, 0);
}
-USB_SPI_CONFIG(usb_spi, USB_IFACE_SPI, USB_EP_SPI, 0);
+USB_SPI_CONFIG(USB_IFACE_SPI, USB_EP_SPI, 0);
/******************************************************************************
* Initialize board.
@@ -179,6 +179,6 @@ static void board_init(void)
usart_init(&loopback_usart);
usart_init(&forward_usart);
- usb_spi_enable(&usb_spi, 1);
+ usb_spi_enable(1);
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
diff --git a/board/hammer/board.c b/board/hammer/board.c
index 85be6a0449..cfd953990d 100644
--- a/board/hammer/board.c
+++ b/board/hammer/board.c
@@ -84,12 +84,12 @@ const struct spi_device_t spi_devices[] = {
};
const unsigned int spi_devices_used = ARRAY_SIZE(spi_devices);
-USB_SPI_CONFIG(usb_spi, USB_IFACE_I2C_SPI, USB_EP_I2C_SPI, 0);
+USB_SPI_CONFIG(USB_IFACE_I2C_SPI, USB_EP_I2C_SPI, 0);
/* SPI interface is always enabled, no need to do anything. */
-void usb_spi_board_enable(struct usb_spi_config const *config)
+void usb_spi_board_enable(void)
{
}
-void usb_spi_board_disable(struct usb_spi_config const *config)
+void usb_spi_board_disable(void)
{
}
#endif /* !HAS_SPI_TOUCHPAD */
@@ -206,7 +206,7 @@ static void board_init(void)
spi_enable(&spi_devices[SPI_ST_TP_DEVICE_ID], 0);
/* Disable SPI passthrough when the system is locked */
- usb_spi_enable(&usb_spi, system_is_locked());
+ usb_spi_enable(system_is_locked());
/* Set all four SPI pins to high speed */
/* pins B3/5, A15 */
diff --git a/board/hyperdebug/board.c b/board/hyperdebug/board.c
index 1872ddcb93..99b575c190 100644
--- a/board/hyperdebug/board.c
+++ b/board/hyperdebug/board.c
@@ -122,7 +122,7 @@ USB_STREAM_CONFIG(usart5_usb, USB_IFACE_USART5_STREAM,
* usb_spi_board_disable to be defined to enable and disable the SPI bridge.
*/
-USB_SPI_CONFIG(usb_spi, USB_IFACE_SPI, USB_EP_SPI, 0);
+USB_SPI_CONFIG(USB_IFACE_SPI, USB_EP_SPI, 0);
/******************************************************************************
* Define the strings used in our USB descriptors.
@@ -210,7 +210,7 @@ static void board_init(void)
usart_init(&usart5);
/* Structured endpoints */
- usb_spi_enable(&usb_spi, 1);
+ usb_spi_enable(1);
/* Configure SPI GPIOs */
gpio_config_module(MODULE_SPI, 1);
diff --git a/board/hyperdebug/spi.c b/board/hyperdebug/spi.c
index 36fede34ac..4b549120a5 100644
--- a/board/hyperdebug/spi.c
+++ b/board/hyperdebug/spi.c
@@ -354,12 +354,12 @@ static int octospi_indirect_read(const uint8_t *control_data, int control_len,
/*
* Board-specific SPI driver entry point, called by usb_spi.c.
*/
-void usb_spi_board_enable(struct usb_spi_config const *config)
+void usb_spi_board_enable(void)
{
/* All initialization already done in board_init(). */
}
-void usb_spi_board_disable(struct usb_spi_config const *config)
+void usb_spi_board_disable(void)
{
}
diff --git a/board/servo_micro/board.c b/board/servo_micro/board.c
index 9fbc4be635..fc6741e6ee 100644
--- a/board/servo_micro/board.c
+++ b/board/servo_micro/board.c
@@ -302,7 +302,7 @@ const struct spi_device_t spi_devices[] = {
};
const unsigned int spi_devices_used = ARRAY_SIZE(spi_devices);
-void usb_spi_board_enable(struct usb_spi_config const *config)
+void usb_spi_board_enable(void)
{
/* Configure SPI GPIOs */
gpio_config_module(MODULE_SPI_FLASH, 1);
@@ -320,7 +320,7 @@ void usb_spi_board_enable(struct usb_spi_config const *config)
spi_enable(&spi_devices[0], 1);
}
-void usb_spi_board_disable(struct usb_spi_config const *config)
+void usb_spi_board_disable(void)
{
spi_enable(&spi_devices[0], 0);
@@ -331,7 +331,7 @@ void usb_spi_board_disable(struct usb_spi_config const *config)
gpio_config_module(MODULE_SPI_FLASH, 0);
}
-USB_SPI_CONFIG(usb_spi, USB_IFACE_SPI, USB_EP_SPI, 0);
+USB_SPI_CONFIG(USB_IFACE_SPI, USB_EP_SPI, 0);
/******************************************************************************
* Support I2C bridging over USB.
@@ -380,8 +380,8 @@ static void board_init(void)
/* Enable GPIO expander. */
gpio_set_level(GPIO_TCA6416_RESET_L, 1);
- /* Structured enpoints */
- usb_spi_enable(&usb_spi, 1);
+ /* Structured endpoints */
+ usb_spi_enable(1);
/* Enable UARTs by default. */
gpio_set_level(GPIO_UART1_EN_L, 0);
@@ -418,6 +418,6 @@ static void board_jump(void)
usart_shutdown(&usart4);
/* Shutdown other hardware modules and let RW reinitialize them */
- usb_spi_enable(&usb_spi, 0);
+ usb_spi_enable(0);
}
DECLARE_HOOK(HOOK_SYSJUMP, board_jump, HOOK_PRIO_DEFAULT);