spi: allow inclusion of Micronix and STM drivers in bootblock
Bootblock does not allow using malloc, use statically allocated chip
structures instead.
BRANCH=storm
BUG=chrome-os-partner:33489
TEST=both drivers compile when configured in, also booted whirlwind
with an STM compatible SPI NOR flash.
Change-Id: I154c33ce5fc278d594205d8b8e62a56edb4e177e
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: eedbb959a595e0898e7a1dd551fc7c517a02f370
Original-Change-Id: I29b37107ac1d58a293f531f59ee76b3d8c4b3e7c
Original-Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/248992
Original-Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: http://review.coreboot.org/9772
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
diff --git a/src/drivers/spi/macronix.c b/src/drivers/spi/macronix.c
index 21eff39..1cee1bf 100644
--- a/src/drivers/spi/macronix.c
+++ b/src/drivers/spi/macronix.c
@@ -212,10 +212,11 @@
return ret;
}
+static struct macronix_spi_flash mcx;
+
struct spi_flash *spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode)
{
const struct macronix_spi_flash_params *params;
- struct macronix_spi_flash *mcx;
unsigned int i;
u16 id = idcode[2] | idcode[1] << 8;
@@ -230,29 +231,23 @@
return NULL;
}
- mcx = malloc(sizeof(*mcx));
- if (!mcx) {
- printk(BIOS_WARNING, "SF: Failed to allocate memory\n");
- return NULL;
- }
+ mcx.params = params;
+ mcx.flash.spi = spi;
+ mcx.flash.name = params->name;
- mcx->params = params;
- mcx->flash.spi = spi;
- mcx->flash.name = params->name;
-
- mcx->flash.write = macronix_write;
- mcx->flash.erase = spi_flash_cmd_erase;
- mcx->flash.status = spi_flash_cmd_status;
+ mcx.flash.write = macronix_write;
+ mcx.flash.erase = spi_flash_cmd_erase;
+ mcx.flash.status = spi_flash_cmd_status;
#if CONFIG_SPI_FLASH_NO_FAST_READ
- mcx->flash.read = spi_flash_cmd_read_slow;
+ mcx.flash.read = spi_flash_cmd_read_slow;
#else
- mcx->flash.read = spi_flash_cmd_read_fast;
+ mcx.flash.read = spi_flash_cmd_read_fast;
#endif
- mcx->flash.sector_size = params->page_size * params->pages_per_sector;
- mcx->flash.size = mcx->flash.sector_size * params->sectors_per_block *
+ mcx.flash.sector_size = params->page_size * params->pages_per_sector;
+ mcx.flash.size = mcx.flash.sector_size * params->sectors_per_block *
params->nr_blocks;
- mcx->flash.erase_cmd = CMD_MX25XX_SE;
- mcx->flash.status_cmd = CMD_MX25XX_RDSR;
+ mcx.flash.erase_cmd = CMD_MX25XX_SE;
+ mcx.flash.status_cmd = CMD_MX25XX_RDSR;
- return &mcx->flash;
+ return &mcx.flash;
}