diff options
author | Vadim Bendebury <vbendeb@chromium.org> | 2015-02-11 19:13:22 -0800 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2015-04-17 10:09:21 +0200 |
commit | e5fd1c9debb9a3c456c973265f2460df473d5a27 (patch) | |
tree | fcdba0d245d6e2e6ea1d6cc9a3bd099b2aca08df /src/drivers/spi/stmicro.c | |
parent | fc08b76ef5913d6859adc06fbc7bbe598d2bdcd6 (diff) |
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>
Diffstat (limited to 'src/drivers/spi/stmicro.c')
-rw-r--r-- | src/drivers/spi/stmicro.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/src/drivers/spi/stmicro.c b/src/drivers/spi/stmicro.c index 4df02b11a9..c959edab35 100644 --- a/src/drivers/spi/stmicro.c +++ b/src/drivers/spi/stmicro.c @@ -221,10 +221,11 @@ out: return ret; } +static struct stmicro_spi_flash stm; + struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 * idcode) { const struct stmicro_spi_flash_params *params; - struct stmicro_spi_flash *stm; unsigned int i; if (idcode[0] == 0xff) { @@ -257,22 +258,16 @@ struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 * idcode) return NULL; } - stm = malloc(sizeof(struct stmicro_spi_flash)); - if (!stm) { - printk(BIOS_WARNING, "SF: Failed to allocate memory\n"); - return NULL; - } - - stm->params = params; - stm->flash.spi = spi; - stm->flash.name = params->name; + stm.params = params; + stm.flash.spi = spi; + stm.flash.name = params->name; - stm->flash.write = stmicro_write; - stm->flash.erase = spi_flash_cmd_erase; - stm->flash.read = spi_flash_cmd_read_fast; - stm->flash.sector_size = params->page_size * params->pages_per_sector; - stm->flash.size = stm->flash.sector_size * params->nr_sectors; - stm->flash.erase_cmd = params->op_erase; + stm.flash.write = stmicro_write; + stm.flash.erase = spi_flash_cmd_erase; + stm.flash.read = spi_flash_cmd_read_fast; + stm.flash.sector_size = params->page_size * params->pages_per_sector; + stm.flash.size = stm.flash.sector_size * params->nr_sectors; + stm.flash.erase_cmd = params->op_erase; - return &stm->flash; + return &stm.flash; } |