summaryrefslogtreecommitdiff
path: root/src/drivers/spi
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers/spi')
-rw-r--r--src/drivers/spi/Kconfig7
-rw-r--r--src/drivers/spi/Makefile.inc13
-rw-r--r--src/drivers/spi/spi_flash.c11
3 files changed, 29 insertions, 2 deletions
diff --git a/src/drivers/spi/Kconfig b/src/drivers/spi/Kconfig
index ee7584c0c4..e022290457 100644
--- a/src/drivers/spi/Kconfig
+++ b/src/drivers/spi/Kconfig
@@ -24,6 +24,13 @@ config SPI_FLASH
Select this option if your chipset driver needs to store certain
data in the SPI flash.
+config SPI_FLASH_SMM
+ bool "SPI flash driver support in SMM"
+ default n
+ depends on SPI_FLASH && HAVE_SMI_HANDLER
+ help
+ Select this option if you want SPI flash support in SMM.
+
config SPI_FLASH_EON
bool
default y
diff --git a/src/drivers/spi/Makefile.inc b/src/drivers/spi/Makefile.inc
index 1814e80003..7f94abd269 100644
--- a/src/drivers/spi/Makefile.inc
+++ b/src/drivers/spi/Makefile.inc
@@ -10,3 +10,16 @@ ramstage-$(CONFIG_SPI_FLASH_STMICRO) += stmicro.c
ramstage-$(CONFIG_SPI_FLASH_WINBOND) += winbond.c
ramstage-$(CONFIG_SPI_FRAM_RAMTRON) += ramtron.c
+ifeq ($(CONFIG_SPI_FLASH_SMM),y)
+# SPI flash driver interface
+smm-$(CONFIG_SPI_FLASH) += spi_flash.c
+
+# drivers
+smm-$(CONFIG_SPI_FLASH_EON) += eon.c
+smm-$(CONFIG_SPI_FLASH_MACRONIX) += macronix.c
+smm-$(CONFIG_SPI_FLASH_SPANSION) += spansion.c
+smm-$(CONFIG_SPI_FLASH_SST) += sst.c
+smm-$(CONFIG_SPI_FLASH_STMICRO) += stmicro.c
+smm-$(CONFIG_SPI_FLASH_WINBOND) += winbond.c
+smm-$(CONFIG_SPI_FRAM_RAMTRON) += ramtron.c
+endif \ No newline at end of file
diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c
index 6cec611504..78c209d865 100644
--- a/src/drivers/spi/spi_flash.c
+++ b/src/drivers/spi/spi_flash.c
@@ -12,6 +12,9 @@
#include <spi.h>
#include <spi_flash.h>
#include <delay.h>
+#ifdef __SMM__
+#include <cpu/x86/smm.h>
+#endif
#include "spi_flash_internal.h"
static void spi_flash_addr(u32 addr, u8 *cmd)
@@ -115,7 +118,7 @@ int spi_flash_cmd_poll_bit(struct spi_flash *flash, unsigned long timeout,
if ((status & poll_bit) == 0)
break;
- mdelay(1);
+ udelay(500);
} while (timebase--);
if ((status & poll_bit) == 0)
@@ -206,7 +209,7 @@ out:
*/
#define IDCODE_CONT_LEN 0
#define IDCODE_PART_LEN 5
-static const struct {
+static struct {
const u8 shift;
const u8 idcode;
struct spi_flash *(*probe) (struct spi_slave *spi, u8 *idcode);
@@ -275,6 +278,10 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
/* search the table for matches in shift and id */
for (i = 0; i < ARRAY_SIZE(flashes); ++i)
if (flashes[i].shift == shift && flashes[i].idcode == *idp) {
+#ifdef __SMM__
+ /* Need to relocate this function */
+ tseg_relocate((void **)&flashes[i].probe);
+#endif
/* we have a match, call probe */
flash = flashes[i].probe(spi, idp);
if (flash)