summaryrefslogtreecommitdiff
path: root/drivers/wear_leveling/wear_leveling_flash_spi_config.h
blob: 394370daa3d39571e24423fb7aefff445bc8a82a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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