summaryrefslogtreecommitdiff
path: root/src/include/spi_flash.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/spi_flash.h')
-rw-r--r--src/include/spi_flash.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/include/spi_flash.h b/src/include/spi_flash.h
index 70ca784c90..1a78b5a904 100644
--- a/src/include/spi_flash.h
+++ b/src/include/spi_flash.h
@@ -76,4 +76,15 @@ static inline int spi_flash_erase(struct spi_flash *flash, u32 offset,
return flash->erase(flash, offset, len);
}
+#if !defined(__PRE_RAM__)
+/* convert a pointer to flash area into the offset inside the flash */
+static inline u32 to_flash_offset(struct spi_flash *flash, void *p) {
+#if defined(CONFIG_VIRTUAL_ROM_SIZE)
+ return ((u32)p + CONFIG_VIRTUAL_ROM_SIZE);
+#else
+ return ((u32)p + flash->size);
+#endif /* defined(CONFIG_VIRTUAL_ROM_SIZE) */
+}
+#endif /* !defined(__PRE_RAM__) */
+
#endif /* _SPI_FLASH_H_ */