From 1ad9f946b6886f08c2cae8503d7efc3f569c1a93 Mon Sep 17 00:00:00 2001 From: Aaron Durbin Date: Thu, 11 Aug 2016 17:09:57 -0500 Subject: 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 Reviewed-on: https://review.coreboot.org/16195 Tested-by: build bot (Jenkins) Reviewed-by: Furquan Shaikh --- src/soc/intel/apollolake/spi.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'src/soc') 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 #include #include #include @@ -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; -- cgit v1.2.3