1 /*
2  * Copyright (c) 2022 Nordic Semiconductor ASA
3  * Copyright (c) 2023 Husqvarna AB
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 #if FFCONF_DEF != 80286
8 #error "Configuration version mismatch"
9 #endif
10 
11 /*
12  * Overrides of FF_ options from ffconf.h
13  */
14 #if defined(CONFIG_FS_FATFS_READ_ONLY)
15 #undef FF_FS_READONLY
16 #define FF_FS_READONLY	CONFIG_FS_FATFS_READ_ONLY
17 #endif /* defined(CONFIG_FS_FATFS_READ_ONLY) */
18 
19 #if defined(CONFIG_FS_FATFS_MKFS)
20 #undef FF_USE_MKFS
21 #define FF_USE_MKFS	CONFIG_FS_FATFS_MKFS
22 #else
23 /* Note that by default the ffconf.h disables MKFS */
24 #undef FF_USE_MKFS
25 #define FF_USE_MKFS 1
26 #endif /* defined(CONFIG_FS_FATFS_MKFS) */
27 
28 #if defined(CONFIG_FS_FATFS_CODEPAGE)
29 #undef FF_CODE_PAGE
30 #define FF_CODE_PAGE	CONFIG_FS_FATFS_CODEPAGE
31 #else
32 /* Note that default value, in ffconf.h, for FF_CODE_PAGE is 932 */
33 #undef FF_CODE_PAGE
34 #define FF_CODE_PAGE 437
35 #endif /* defined(CONFIG_FS_FATFS_CODEPAGE) */
36 
37 #if defined(CONFIG_FS_FATFS_FF_USE_LFN)
38 #if CONFIG_FS_FATFS_FF_USE_LFN <= 3
39 #undef FF_USE_LFN
40 #define FF_USE_LFN CONFIG_FS_FATFS_FF_USE_LFN
41 #else
42 #error Invalid LFN buffer location
43 #endif
44 #endif /* defined(CONFIG_FS_FATFS_LFN) */
45 
46 #if defined(CONFIG_FS_FATFS_MAX_LFN)
47 #undef FF_MAX_LFN
48 #define	FF_MAX_LFN	CONFIG_FS_FATFS_MAX_LFN
49 #endif /* defined(CONFIG_FS_FATFS_MAX_LFN) */
50 
51 #if defined(CONFIG_FS_FATFS_MIN_SS)
52 #undef FF_MIN_SS
53 #define FF_MIN_SS	CONFIG_FS_FATFS_MIN_SS
54 #endif /* defined(CONFIG_FS_FATFS_MIN_SS) */
55 
56 #if defined(CONFIG_FS_FATFS_MAX_SS)
57 #undef FF_MAX_SS
58 #define FF_MAX_SS		CONFIG_FS_FATFS_MAX_SS
59 #endif /* defined(CONFIG_FS_FATFS_MAX_SS) */
60 
61 #if defined(CONFIG_FS_FATFS_EXFAT)
62 #undef FF_FS_EXFAT
63 #define FF_FS_EXFAT		CONFIG_FS_FATFS_EXFAT
64 #endif /* defined(CONFIG_FS_FATFS_EXFAT) */
65 
66 #if defined(CONFIG_FS_FATFS_REENTRANT)
67 #undef FF_FS_REENTRANT
68 #undef FF_FS_TIMEOUT
69 #include <zephyr/kernel.h>
70 #define FF_FS_REENTRANT		CONFIG_FS_FATFS_REENTRANT
71 #define FF_FS_TIMEOUT		K_FOREVER
72 #endif /* defined(CONFIG_FS_FATFS_REENTRANT) */
73 
74 #if defined(CONFIG_FS_FATFS_LBA64)
75 #undef FF_LBA64
76 #define FF_LBA64		CONFIG_FS_FATFS_LBA64
77 #endif /* defined(CONFIG_FS_FATFS_LBA64) */
78 
79 #if defined(CONFIG_FS_FATFS_MULTI_PARTITION)
80 #undef FF_MULTI_PARTITION
81 #define FF_MULTI_PARTITION	CONFIG_FS_FATFS_MULTI_PARTITION
82 #endif /* defined(CONFIG_FS_FATFS_MULTI_PARTITION) */
83 
84 /*
85  * These options are override from default values, but have no Kconfig
86  * options.
87  */
88 #undef FF_FS_TINY
89 #define FF_FS_TINY 1
90 
91 #undef FF_FS_NORTC
92 #if defined(CONFIG_FS_FATFS_HAS_RTC)
93 #define FF_FS_NORTC 0
94 #else
95 #define FF_FS_NORTC 1
96 #endif /* defined(CONFIG_FS_FATFS_HAS_RTC) */
97 
98 /* Zephyr uses FF_VOLUME_STRS */
99 #undef FF_STR_VOLUME_ID
100 #define FF_STR_VOLUME_ID 1
101 
102 /* By default FF_STR_VOLUME_ID in ffconf.h is 0, which means that
103  * FF_VOLUME_STRS is not used. Zephyr uses FF_VOLUME_STRS, which
104  * by default holds 8 possible strings representing mount points,
105  * and FF_VOLUMES needs to reflect that, which means that dolt
106  * value of 1 is overridden here with 8.
107  */
108 #undef FF_VOLUMES
109 #define FF_VOLUMES 8
110 
111 #if defined(CONFIG_FS_FATFS_EXTRA_NATIVE_API)
112 #undef FF_USE_LABEL
113 #undef FF_USE_EXPAND
114 #undef FF_USE_FIND
115 #define FF_USE_LABEL 1
116 #define FF_USE_EXPAND 1
117 #define FF_USE_FIND 1
118 #endif /* defined(CONFIG_FS_FATFS_EXTRA_NATIVE_API) */
119 
120 /*
121  * Options provided below have been added to ELM FAT source code to
122  * support Zephyr specific features, and are not part of ffconf.h.
123  */
124 /*
125  * The FS_FATFS_WINDOW_ALIGNMENT is used to align win buffer of FATFS structure
126  * to allow more optimal use with MCUs that require specific bufer alignment
127  * for DMA to work.
128  */
129 #if defined(CONFIG_FS_FATFS_WINDOW_ALIGNMENT)
130 #define FS_FATFS_WINDOW_ALIGNMENT	CONFIG_FS_FATFS_WINDOW_ALIGNMENT
131 #else
132 #define FS_FATFS_WINDOW_ALIGNMENT	1
133 #endif /* defined(CONFIG_FS_FATFS_WINDOW_ALIGNMENT) */
134