summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/spi/macronix.c35
-rw-r--r--src/drivers/spi/stmicro.c29
2 files changed, 27 insertions, 37 deletions
diff --git a/src/drivers/spi/macronix.c b/src/drivers/spi/macronix.c
index 21eff39ccc..1cee1bfd84 100644
--- a/src/drivers/spi/macronix.c
+++ b/src/drivers/spi/macronix.c
@@ -212,10 +212,11 @@ static int macronix_write(struct spi_flash *flash,
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 @@ struct spi_flash *spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode)
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;
}
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;
}