summaryrefslogtreecommitdiff
path: root/src/soc/intel
diff options
context:
space:
mode:
authorKyösti Mälkki <kyosti.malkki@gmail.com>2015-01-06 07:08:46 +0100
committerEdward O'Callaghan <eocallaghan@alterapraxis.com>2015-01-06 11:19:28 +0100
commit9b29aad5263f2aeba21cf4d521e7798f9dedb2b9 (patch)
treee513c718c9cb6960c4be58d2e5c299a0bab968f7 /src/soc/intel
parent6355cbff51966144d5b709a73e24622df3e96122 (diff)
downloadcoreboot-9b29aad5263f2aeba21cf4d521e7798f9dedb2b9.tar.xz
Revert "Re-factor 'to_flash_offset()' into 'spi_flash.h'"
This reverts commit 9270553fff23462fcb298f154296319bf3639d15. Change-Id: I195f721ce7a18aac6c1aa6f4e0f9284455d531b0 Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: http://review.coreboot.org/8138 Tested-by: build bot (Jenkins) Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Diffstat (limited to 'src/soc/intel')
-rw-r--r--src/soc/intel/common/nvm.c10
-rw-r--r--src/soc/intel/fsp_baytrail/nvm.c13
2 files changed, 19 insertions, 4 deletions
diff --git a/src/soc/intel/common/nvm.c b/src/soc/intel/common/nvm.c
index 54b3baf821..791422fe30 100644
--- a/src/soc/intel/common/nvm.c
+++ b/src/soc/intel/common/nvm.c
@@ -46,6 +46,12 @@ static int nvm_init(void)
return 0;
}
+/* Convert memory mapped pointer to flash offset. */
+static inline uint32_t to_flash_offset(void *p)
+{
+ return CONFIG_ROM_SIZE + (uintptr_t)p;
+}
+
int nvm_is_erased(const void *start, size_t size)
{
const uint8_t *cur = start;
@@ -64,7 +70,7 @@ int nvm_erase(void *start, size_t size)
{
if (nvm_init() < 0)
return -1;
- return flash->erase(flash, to_flash_offset(flash, start), size);
+ return flash->erase(flash, to_flash_offset(start), size);
}
/* Write data to NVM. Returns 0 on success < 0 on error. */
@@ -72,5 +78,5 @@ int nvm_write(void *start, const void *data, size_t size)
{
if (nvm_init() < 0)
return -1;
- return flash->write(flash, to_flash_offset(flash, start), size, data);
+ return flash->write(flash, to_flash_offset(start), size, data);
}
diff --git a/src/soc/intel/fsp_baytrail/nvm.c b/src/soc/intel/fsp_baytrail/nvm.c
index d1e5223996..02244636f8 100644
--- a/src/soc/intel/fsp_baytrail/nvm.c
+++ b/src/soc/intel/fsp_baytrail/nvm.c
@@ -47,6 +47,15 @@ static int nvm_init(void)
return 0;
}
+/* Convert memory mapped pointer to flash offset. */
+static inline uint32_t to_flash_offset(void *p)
+{
+#ifndef CONFIG_ROM_SIZE
+#error CONFIG_ROM_SIZE must be set.
+#endif
+ return CONFIG_ROM_SIZE + (uintptr_t)p;
+}
+
int nvm_is_erased(const void *start, size_t size)
{
const uint8_t *cur = start;
@@ -65,7 +74,7 @@ int nvm_erase(void *start, size_t size)
{
if (nvm_init() < 0)
return -1;
- flash->erase(flash, to_flash_offset(flash, start), size);
+ flash->erase(flash, to_flash_offset(start), size);
return 0;
}
@@ -74,6 +83,6 @@ int nvm_write(void *start, const void *data, size_t size)
{
if (nvm_init() < 0)
return -1;
- flash->write(flash, to_flash_offset(flash, start), size, data);
+ flash->write(flash, to_flash_offset(start), size, data);
return 0;
}