summaryrefslogtreecommitdiff
path: root/common/spi_flash.c
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 /common/spi_flash.c
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 'common/spi_flash.c')
-rw-r--r--common/spi_flash.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/common/spi_flash.c b/common/spi_flash.c
index c4346ef48b..3487c9a581 100644
--- a/common/spi_flash.c
+++ b/common/spi_flash.c
@@ -485,7 +485,8 @@ static int command_spi_flashinfo(int argc, char **argv)
uint8_t unique[8];
int rv;
- spi_enable(CONFIG_SPI_FLASH_PORT, 1);
+ /* TODO(tomhughes): use board function to get devices. */
+ spi_enable(SPI_FLASH_DEVICE, 1);
/* Wait for previous operation to complete */
rv = spi_flash_wait();
@@ -537,7 +538,7 @@ static int command_spi_flasherase(int argc, char **argv)
if (rv)
return rv;
- spi_enable(CONFIG_SPI_FLASH_PORT, 1);
+ spi_enable(SPI_FLASH_DEVICE, 1);
/* Chip has protection */
if (spi_flash_check_protect(offset, bytes))
@@ -562,7 +563,7 @@ static int command_spi_flashwrite(int argc, char **argv)
if (rv)
return rv;
- spi_enable(CONFIG_SPI_FLASH_PORT, 1);
+ spi_enable(SPI_FLASH_DEVICE, 1);
/* Chip has protection */
if (spi_flash_check_protect(offset, bytes))
@@ -607,7 +608,7 @@ static int command_spi_flashread(int argc, char **argv)
if (rv)
return rv;
- spi_enable(CONFIG_SPI_FLASH_PORT, 1);
+ spi_enable(SPI_FLASH_DEVICE, 1);
/* Can't read past size of memory */
if (offset + bytes > CONFIG_FLASH_SIZE_BYTES)
@@ -655,7 +656,7 @@ DECLARE_CONSOLE_COMMAND(spi_flashread, command_spi_flashread,
static int command_spi_flashread_sr(int argc, char **argv)
{
- spi_enable(CONFIG_SPI_FLASH_PORT, 1);
+ spi_enable(SPI_FLASH_DEVICE, 1);
ccprintf("Status Register 1: 0x%02x\n", spi_flash_get_status1());
ccprintf("Status Register 2: 0x%02x\n", spi_flash_get_status2());
@@ -675,7 +676,7 @@ static int command_spi_flashwrite_sr(int argc, char **argv)
if (rv)
return rv;
- spi_enable(CONFIG_SPI_FLASH_PORT, 1);
+ spi_enable(SPI_FLASH_DEVICE, 1);
ccprintf("Writing 0x%02x to status register 1, ", val1);
ccprintf("0x%02x to status register 2...\n", val2);
@@ -694,7 +695,7 @@ static int command_spi_flashprotect(int argc, char **argv)
if (rv)
return rv;
- spi_enable(CONFIG_SPI_FLASH_PORT, 1);
+ spi_enable(SPI_FLASH_DEVICE, 1);
ccprintf("Setting protection for 0x%06x to 0x%06x\n", val1, val1+val2);
return spi_flash_set_protect(val1, val2);