summaryrefslogtreecommitdiff
path: root/src/soc
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2016-08-11 17:09:57 -0500
committerMartin Roth <martinroth@google.com>2016-08-19 03:09:01 +0200
commit1ad9f946b6886f08c2cae8503d7efc3f569c1a93 (patch)
treeb82eeb41195ecdd0e94d4399ca069353f046bee3 /src/soc
parent504b8f2da211735e60b861106bf665a62091c36d (diff)
soc/intel/apollolake: make SPI support early stages
Using malloc() in SPI code is unnecessary as there's only one SPI device that the SoC support code handles: boot device. Therefore, use CAR to for the storage to work around the current limiations of the SPI API which expects one to return pointers to objects that are writable. BUG=chrome-os-partner:56151 Change-Id: If4f5484e27d68b2dd1b17a281cf0b760086850a7 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/16195 Tested-by: build bot (Jenkins) Reviewed-by: Furquan Shaikh <furquan@google.com>
Diffstat (limited to 'src/soc')
-rw-r--r--src/soc/intel/apollolake/spi.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/soc/intel/apollolake/spi.c b/src/soc/intel/apollolake/spi.c
index 7b390bb2b9..139d36cd37 100644
--- a/src/soc/intel/apollolake/spi.c
+++ b/src/soc/intel/apollolake/spi.c
@@ -17,6 +17,7 @@
#define __SIMPLE_DEVICE__
+#include <arch/early_variables.h>
#include <arch/io.h>
#include <device/device.h>
#include <device/pci.h>
@@ -315,6 +316,9 @@ static int nuclear_spi_status(struct spi_flash *flash, uint8_t *reg)
return E_NOT_IMPLEMENTED;
}
+static struct spi_slave boot_spi CAR_GLOBAL;
+static struct spi_flash boot_flash CAR_GLOBAL;
+
/*
* We can't use FDOC and FDOD to read FLCOMP, as previous platforms did.
* For details see:
@@ -328,11 +332,7 @@ static struct spi_flash *nuclear_flash_probe(struct spi_slave *spi)
struct spi_flash *flash;
uint32_t flash_bits;
- flash = malloc(sizeof(*flash));
- if (!flash) {
- printk(BIOS_ERR, "%s(): Could not allocate memory\n", __func__);
- return NULL;
- }
+ flash = car_get_var_ptr(&boot_flash);
/*
* bytes = (bits + 1) / 8;
@@ -371,14 +371,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs)
if ((bus != 0) || (cs != 0))
return NULL;
- struct spi_slave *slave = malloc(sizeof(*slave));
-
- if (!slave) {
- printk(BIOS_ERR, "%s(): Could not allocate memory\n", __func__);
- return NULL;
- }
-
- memset(slave, 0, sizeof(*slave));
+ struct spi_slave *slave = car_get_var_ptr(&boot_spi);
slave->bus = bus;
slave->cs = cs;