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 /*
75  * These options are override from default values, but have no Kconfig
76  * options.
77  */
78 #undef FF_FS_TINY
79 #define FF_FS_TINY 1
80 
81 #undef FF_FS_NORTC
82 #define FF_FS_NORTC 1
83 
84 /* Zephyr uses FF_VOLUME_STRS */
85 #undef FF_STR_VOLUME_ID
86 #define FF_STR_VOLUME_ID 1
87 
88 /* By default FF_STR_VOLUME_ID in ffconf.h is 0, which means that
89  * FF_VOLUME_STRS is not used. Zephyr uses FF_VOLUME_STRS, which
90  * by default holds 8 possible strings representing mount points,
91  * and FF_VOLUMES needs to reflect that, which means that dolt
92  * value of 1 is overridden here with 8.
93  */
94 #undef FF_VOLUMES
95 #define FF_VOLUMES 8
96 
97 /*
98  * Options provided below have been added to ELM FAT source code to
99  * support Zephyr specific features, and are not part of ffconf.h.
100  */
101 /*
102  * The FS_FATFS_WINDOW_ALIGNMENT is used to align win buffer of FATFS structure
103  * to allow more optimal use with MCUs that require specific bufer alignment
104  * for DMA to work.
105  */
106 #if defined(CONFIG_FS_FATFS_WINDOW_ALIGNMENT)
107 #define FS_FATFS_WINDOW_ALIGNMENT	CONFIG_FS_FATFS_WINDOW_ALIGNMENT
108 #else
109 #define FS_FATFS_WINDOW_ALIGNMENT	1
110 #endif /* defined(CONFIG_FS_FATFS_WINDOW_ALIGNMENT) */
111