summaryrefslogtreecommitdiff
path: root/src/drivers/spi/spi_flash.c
diff options
context:
space:
mode:
authorDuncan Laurie <dlaurie@chromium.org>2012-06-23 16:53:57 -0700
committerRonald G. Minnich <rminnich@gmail.com>2012-07-24 23:44:40 +0200
commit181bbdd51cb4ec318e8b44c1ca652310bf6abb22 (patch)
tree91489a7a78cea0a7ce3e464f51cbaf4dbb867d20 /src/drivers/spi/spi_flash.c
parentf5e9ac48c65bba2876d1dd7f103cd15c5e33c7df (diff)
downloadcoreboot-181bbdd51cb4ec318e8b44c1ca652310bf6abb22.tar.xz
SMM: Add option for SPI driver to be available in SMM
- add Kconfig option for CONFIG_SPI_FLASH_SMM - compile subsystem and chip drivers for smm if enabled - change mdelay(1) to udelay(500) since mdelay is not defined in SMM and a 1ms delay is worth avoiding - make flash chip structure non-const so the probe function pointers can be relocated for use in TSEG - Make SMM PCI access possible in southbridge SPI code Change-Id: Icfcbbe8e4e56658769d46af0b5bf6c79a6432641 Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: http://review.coreboot.org/1313 Tested-by: build bot (Jenkins) Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Diffstat (limited to 'src/drivers/spi/spi_flash.c')
-rw-r--r--src/drivers/spi/spi_flash.c11
1 files changed, 9 insertions, 2 deletions
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)