From fb08d194cab17607faa4d7e0f198749a8162824e Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Sun, 24 Nov 2019 20:08:24 +0800 Subject: [PATCH] foboot: spi: fix spiId and remove dead code Remove code that doesn't get called. Also, remove the `spi_id` global. It conflicted with one from the linker, which was causing contention. Signed-off-by: Sean Cross --- booster/include/spi.h | 7 ++----- booster/src/spi.c | 31 ++----------------------------- 2 files changed, 4 insertions(+), 34 deletions(-) diff --git a/booster/include/spi.h b/booster/include/spi.h index cac9331..48aa1ae 100644 --- a/booster/include/spi.h +++ b/booster/include/spi.h @@ -6,10 +6,6 @@ #define SPI_ERASE_SECTOR_SIZE 4096 #define SPI_PROGRAM_PAGE_SIZE 256 -void spiBegin(void); -void spiEnd(void); -void spiPause(void); -void spiCommand(uint8_t cmd); uint8_t spiCommandRx(void); uint8_t spiReadStatus(void); void spiBeginErase4(uint32_t erase_addr); @@ -18,5 +14,6 @@ void spiBeginErase64(uint32_t erase_addr); int spiIsBusy(void); void spiBeginWrite(uint32_t addr, const void *v_data, unsigned int count); uint32_t spiId(void); +void spiReset(void); -#endif /* _FOBOOST_SPI_H */ \ No newline at end of file +#endif /* _FOBOOST_SPI_H */ diff --git a/booster/src/spi.c b/booster/src/spi.c index d5f3184..acfc914 100644 --- a/booster/src/spi.c +++ b/booster/src/spi.c @@ -72,12 +72,9 @@ int spiIsBusy(void) { return spi_read_status() & (1 << 0); } -__attribute__((used)) -uint32_t spi_id; - __attribute__((used)) uint32_t spiId(void) { - spi_id = 0; + uint32_t spi_id = 0; spiBegin(); spi_single_tx(0x90); // Read manufacturer ID @@ -160,7 +157,7 @@ void spiBeginWrite(uint32_t addr, const void *v_data, unsigned int count) { spiEnd(); } -uint8_t spiReset(void) { +void spiReset(void) { // Writing 0xff eight times is equivalent to exiting QPI mode, // or if CFM mode is enabled it will terminate CFM and return // to idle. @@ -174,25 +171,6 @@ uint8_t spiReset(void) { spiBegin(); spi_single_tx(0xab); // Read electronic signature spiEnd(); - - return 0; -} - -int spiInit(void) { - - // Ensure CS is deasserted and the clock is high - lxspi_bitbang_write((0 << PIN_CLK) | (1 << PIN_CS)); - - // Disable memory-mapped mode and enable bit-bang mode - lxspi_bitbang_en_write(1); - - // Reset the SPI flash, which will return it to SPI mode even - // if it's in QPI mode, and ensure the chip is accepting commands. - spiReset(); - - spiId(); - - return 0; } void spiHold(void) { @@ -206,8 +184,3 @@ void spiUnhold(void) { spi_single_tx(0xab); spiEnd(); } - -void spiFree(void) { - // Re-enable memory-mapped mode - lxspi_bitbang_en_write(0); -}