summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorDavid Hendricks <dhendrix@chromium.org>2014-12-12 14:07:08 -0800
committerPatrick Georgi <pgeorgi@google.com>2015-03-20 16:02:34 +0100
commitfccc7dea2459f313476c32437493285779e2f814 (patch)
treebc7de36bf9085123cea723270d633ea23c477946 /src/drivers
parent032d4d258030c0b25325d2906c2a97b59f82bf40 (diff)
downloadcoreboot-fccc7dea2459f313476c32437493285779e2f814.tar.xz
spi: do not use malloc in Gigadevice driver
This allows us to use the driver before ramstage. BRANCH=none BUG=none TEST=built and booted on Pinky Change-Id: I0700388b0e4e0562e3c0a52863c8357097bfd8d6 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Commit-Id: cd57587dab74de509d5c50cfc1ad337d765af6c8 Original-Signed-off-by: David Hendricks <dhendrix@chromium.org> Original-Change-Id: I0ce901331e401274254b8889484ffb41359119fa Original-Reviewed-on: https://chromium-review.googlesource.com/235864 Original-Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-on: http://review.coreboot.org/8774 Tested-by: build bot (Jenkins) Reviewed-by: David Hendricks <dhendrix@chromium.org> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/spi/gigadevice.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/src/drivers/spi/gigadevice.c b/src/drivers/spi/gigadevice.c
index 68b487efca..0f0d7b7432 100644
--- a/src/drivers/spi/gigadevice.c
+++ b/src/drivers/spi/gigadevice.c
@@ -189,11 +189,12 @@ static int gigadevice_erase(struct spi_flash *flash, u32 offset, size_t len)
return spi_flash_cmd_erase(flash, CMD_GD25_SE, offset, len);
}
+static struct gigadevice_spi_flash stm;
+
struct spi_flash *spi_flash_probe_gigadevice(struct spi_slave *spi, u8 *idcode)
{
const struct gigadevice_spi_flash_params *params;
unsigned page_size;
- struct gigadevice_spi_flash *stm;
unsigned int i;
for (i = 0; i < ARRAY_SIZE(gigadevice_spi_flash_table); i++) {
@@ -209,32 +210,25 @@ struct spi_flash *spi_flash_probe_gigadevice(struct spi_slave *spi, u8 *idcode)
return NULL;
}
- stm = malloc(sizeof(struct gigadevice_spi_flash));
- if (!stm) {
- printk(BIOS_WARNING,
- "SF gigadevice.c: 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;
/* Assuming power-of-two page size initially. */
page_size = 1 << params->l2_page_size;
- stm->flash.write = gigadevice_write;
- stm->flash.erase = gigadevice_erase;
+ stm.flash.write = gigadevice_write;
+ stm.flash.erase = gigadevice_erase;
#if CONFIG_SPI_FLASH_NO_FAST_READ
- stm->flash.read = spi_flash_cmd_read_slow;
+ stm.flash.read = spi_flash_cmd_read_slow;
#else
- stm->flash.read = spi_flash_cmd_read_fast;
+ stm.flash.read = spi_flash_cmd_read_fast;
#endif
- stm->flash.sector_size = (1 << stm->params->l2_page_size) *
- stm->params->pages_per_sector;
- stm->flash.size = page_size * params->pages_per_sector
+ stm.flash.sector_size = (1 << stm.params->l2_page_size) *
+ stm.params->pages_per_sector;
+ stm.flash.size = page_size * params->pages_per_sector
* params->sectors_per_block
* params->nr_blocks;
- return &stm->flash;
+ return &stm.flash;
}