[coreboot-gerrit] Patch set updated for coreboot: soc/intel/apollolake: make SPI support early stages

Aaron Durbin (adurbin@chromium.org) gerrit at coreboot.org
Fri Aug 12 23:28:33 CEST 2016


Aaron Durbin (adurbin at chromium.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/16195

-gerrit

commit 01631874227f0a89e7a9a169852127cc603ea410
Author: Aaron Durbin <adurbin at chromium.org>
Date:   Thu Aug 11 17:09:57 2016 -0500

    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 at chromium.org>
---
 src/soc/intel/apollolake/spi.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/src/soc/intel/apollolake/spi.c b/src/soc/intel/apollolake/spi.c
index 7b390bb..139d36c 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;



More information about the coreboot-gerrit mailing list