summaryrefslogtreecommitdiff
path: root/chip/mec1322
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/mec1322
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/mec1322')
-rw-r--r--chip/mec1322/lfw/ec_lfw.c2
-rw-r--r--chip/mec1322/spi.c4
-rw-r--r--chip/mec1322/system.c2
3 files changed, 5 insertions, 3 deletions
diff --git a/chip/mec1322/lfw/ec_lfw.c b/chip/mec1322/lfw/ec_lfw.c
index ccee9f8967..1fb334e144 100644
--- a/chip/mec1322/lfw/ec_lfw.c
+++ b/chip/mec1322/lfw/ec_lfw.c
@@ -252,7 +252,7 @@ void lfw_main()
dma_init();
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/mec1322/spi.c b/chip/mec1322/spi.c
index ba58bfb0bd..0c4174cecd 100644
--- a/chip/mec1322/spi.c
+++ b/chip/mec1322/spi.c
@@ -148,8 +148,10 @@ int spi_transaction(const struct spi_device_t *spi_device,
return ret;
}
-int spi_enable(int port, int enable)
+int spi_enable(const struct spi_device_t *spi_device, int enable)
{
+ int port = spi_device->port;
+
if (enable) {
gpio_config_module(MODULE_SPI, 1);
diff --git a/chip/mec1322/system.c b/chip/mec1322/system.c
index a3043ba46b..bfa4a3c031 100644
--- a/chip/mec1322/system.c
+++ b/chip/mec1322/system.c
@@ -92,7 +92,7 @@ void system_pre_init(void)
/* Deassert nSIO_RESET */
MEC1322_PCR_PWR_RST_CTL &= ~BIT(0);
- spi_enable(CONFIG_SPI_FLASH_PORT, 1);
+ spi_enable(SPI_FLASH_DEVICE, 1);
}
void chip_save_reset_flags(uint32_t flags)