summaryrefslogtreecommitdiffstats
path: root/drivers/wear_leveling/wear_leveling_flash_spi_config.h
diff options
context:
space:
mode:
authorNick Brassel <nick@tzarc.org>2022-08-28 14:23:01 +1000
committerNick Brassel <nick@tzarc.org>2022-08-28 14:23:01 +1000
commit0a3f7e48690bb2b7b008300a54554979a55be19a (patch)
tree7499d52f20040ed7d5a56496ecb81ed114f80719 /drivers/wear_leveling/wear_leveling_flash_spi_config.h
parentfc0bf67f372c38f72c303cdec21b1d4afb5e8cb4 (diff)
parent9b5b0722555891ba94f240760ef3a6d4c870fd13 (diff)
Merge remote-tracking branch 'upstream/develop'
Diffstat (limited to 'drivers/wear_leveling/wear_leveling_flash_spi_config.h')
-rw-r--r--drivers/wear_leveling/wear_leveling_flash_spi_config.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/drivers/wear_leveling/wear_leveling_flash_spi_config.h b/drivers/wear_leveling/wear_leveling_flash_spi_config.h
new file mode 100644
index 0000000000..394370daa3
--- /dev/null
+++ b/drivers/wear_leveling/wear_leveling_flash_spi_config.h
@@ -0,0 +1,34 @@
+// Copyright 2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#pragma once
+
+#ifndef __ASSEMBLER__
+# include <stdlib.h>
+# include <stdint.h>
+# include "flash_spi.h"
+#endif
+
+// Use 1 block -- check the config for the SPI flash to determine how big it is
+#ifndef WEAR_LEVELING_EXTERNAL_FLASH_BLOCK_COUNT
+# define WEAR_LEVELING_EXTERNAL_FLASH_BLOCK_COUNT 1
+#endif // WEAR_LEVELING_EXTERNAL_FLASH_BLOCK_COUNT
+
+// Start at the first block of the external flash
+#ifndef WEAR_LEVELING_EXTERNAL_FLASH_BLOCK_OFFSET
+# define WEAR_LEVELING_EXTERNAL_FLASH_BLOCK_OFFSET 0
+#endif // WEAR_LEVELING_EXTERNAL_FLASH_BLOCK_OFFSET
+
+// 8-byte writes by default
+#ifndef BACKING_STORE_WRITE_SIZE
+# define BACKING_STORE_WRITE_SIZE 8
+#endif
+
+// The space allocated by the block
+#ifndef WEAR_LEVELING_BACKING_SIZE
+# define WEAR_LEVELING_BACKING_SIZE ((EXTERNAL_FLASH_BLOCK_SIZE) * (WEAR_LEVELING_EXTERNAL_FLASH_BLOCK_COUNT))
+#endif // WEAR_LEVELING_BACKING_SIZE
+
+// Use half of the backing size for logical EEPROM
+#ifndef WEAR_LEVELING_LOGICAL_SIZE
+# define WEAR_LEVELING_LOGICAL_SIZE ((WEAR_LEVELING_BACKING_SIZE) / 2)
+#endif // WEAR_LEVELING_LOGICAL_SIZE