summaryrefslogtreecommitdiff
path: root/chip/mchp
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2021-01-26 11:36:48 -0800
committerCommit Bot <commit-bot@chromium.org>2021-01-28 01:08:04 +0000
commitb5a0fdab0680fd93b0b7b08a139a5fdcbb679ee6 (patch)
treee950d8969881d4f8b8978b349b94b9c7085eb3e5 /chip/mchp
parentc60037148c629e4947b67287b88c3abf701e2040 (diff)
downloadchrome-ec-b5a0fdab0680fd93b0b7b08a139a5fdcbb679ee6.tar.gz
spi: Pass in spi_device as argument to spi_enable instead of port
Rather than passing in the port and iterating over the global spi_devices variable, pass in the specific spi_device that is being enabled/disabled. The spi_device_t struct has the port. This change makes the functions in spi.h more consistent since they now all take a spi_device_t*. This change is the first step in making the SPI configuration more dynamic. BRANCH=none BUG=b:177908650 TEST=git grep 'spi_enable(CONFIG' => no results TEST=make buildall TEST=Flash dragonclaw v0.2 and view console to verify FP sensor ID Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I64124e0ebcf898e88496acb77703b5f59ae931c2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2654081 Commit-Queue: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
Diffstat (limited to 'chip/mchp')
-rw-r--r--chip/mchp/lfw/ec_lfw.c2
-rw-r--r--chip/mchp/spi.c23
-rw-r--r--chip/mchp/system.c2
3 files changed, 11 insertions, 16 deletions
diff --git a/chip/mchp/lfw/ec_lfw.c b/chip/mchp/lfw/ec_lfw.c
index c2fe9d6515..0d69c6a16b 100644
--- a/chip/mchp/lfw/ec_lfw.c
+++ b/chip/mchp/lfw/ec_lfw.c
@@ -381,7 +381,7 @@ void lfw_main(void)
uart_init();
system_init();
- spi_enable(CONFIG_SPI_FLASH_PORT, 1);
+ spi_enable(SPI_FLASH_DEVICE, 1);
uart_puts("littlefw ");
uart_puts(current_image_data.version);
diff --git a/chip/mchp/spi.c b/chip/mchp/spi.c
index 2d5a7e9a3f..5931b05f1d 100644
--- a/chip/mchp/spi.c
+++ b/chip/mchp/spi.c
@@ -267,31 +267,26 @@ int spi_transaction(const struct spi_device_t *spi_device,
/**
* Enable SPI port and associated controller
*
- * @param port Zero based index into spi_device an array of
- * struct spi_device_t
+ * @param spi_device SPI device
* @param enable
* @return EC_SUCCESS or EC_ERROR_INVAL if port is unrecognized
* @note called from common/spi_flash.c
*
- * spi_devices[].port is defined as
+ * spi_device->port is defined as
* bits[3:0] = controller instance
* bits[7:4] = controller family 0 = QMSPI, 1 = GPSPI
*/
-int spi_enable(int port, int enable)
+int spi_enable(const struct spi_device_t *spi_device, int enable)
{
int rc;
- uint8_t hw_port;
-
+ uint8_t hw_port = spi_device->port;
rc = EC_ERROR_INVAL;
- if (port < spi_devices_used) {
- hw_port = spi_devices[port].port;
- if ((hw_port & 0xF0) == QMSPI_CLASS)
- rc = qmspi_enable(hw_port, enable);
+
+ if ((hw_port & 0xF0) == QMSPI_CLASS)
+ rc = qmspi_enable(hw_port, enable);
#if defined(CONFIG_MCHP_GPSPI) && !defined(LFW)
- if ((hw_port & 0xF0) == GPSPI_CLASS)
- rc = gpspi_enable(hw_port, enable);
+ if ((hw_port & 0xF0) == GPSPI_CLASS)
+ rc = gpspi_enable(hw_port, enable);
#endif
- }
-
return rc;
}
diff --git a/chip/mchp/system.c b/chip/mchp/system.c
index 1d152f0b79..212c8b636f 100644
--- a/chip/mchp/system.c
+++ b/chip/mchp/system.c
@@ -199,7 +199,7 @@ void system_pre_init(void)
MCHP_INT_BLK_DIS = 0xfffffffful;
MCHP_INT_BLK_EN = (0x1Ful << 8) + (0x07ul << 24);
- spi_enable(CONFIG_SPI_FLASH_PORT, 1);
+ spi_enable(SPI_FLASH_DEVICE, 1);
}
uint32_t chip_read_reset_flags(void)