diff options
| author | Tom Rini <[email protected]> | 2023-11-16 12:46:09 -0500 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2023-11-16 13:49:13 -0500 |
| commit | 5e6a112e1187ebc570b8befd1dd6eef3a64dec39 (patch) | |
| tree | 0f87bf8f8b38403cc7b331ecc1660a2ef6b3af45 /include | |
| parent | a9a73799731807cca117d234c4338b710db3cfdd (diff) | |
| parent | 8502b5bf20505408773d98fbc6e9307cb962e8b0 (diff) | |
Merge patch series "nand: Add sandbox tests"
To quote the author:
This series tests raw nand flash in sandbox and fixes various bugs discovered in
the process. I've tried to do things in a contemporary manner, avoiding the
(numerous) variations present on only a few boards. The test is pretty minimal.
Future work could test the rest of the nand API as well as the MTD API.
Bloat (for v1) at [1] (for boards with SPL_NAND_SUPPORT enabled). Almost
everything grows by a few bytes due to nand_page_size. A few boards grow more,
mostly those using nand_spl_loaders.c. CI at [2].
[1] https://gist.github.com/Forty-Bot/9694f3401893c9e706ccc374922de6c2
[2] https://source.denx.de/u-boot/custodians/u-boot-clk/-/pipelines/18443
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/mtd/mtd.h | 12 | ||||
| -rw-r--r-- | include/mtd/cfi_flash.h | 2 | ||||
| -rw-r--r-- | include/nand.h | 3 | ||||
| -rw-r--r-- | include/os.h | 13 | ||||
| -rw-r--r-- | include/system-constants.h | 4 |
5 files changed, 33 insertions, 1 deletions
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index 09f52698877..7a66c7af749 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h @@ -552,8 +552,20 @@ unsigned mtd_mmap_capabilities(struct mtd_info *mtd); #ifdef __UBOOT__ /* drivers/mtd/mtdcore.h */ +#if CONFIG_IS_ENABLED(MTD) int add_mtd_device(struct mtd_info *mtd); int del_mtd_device(struct mtd_info *mtd); +#else +static inline int add_mtd_device(struct mtd_info *mtd) +{ + return -ENOSYS; +} + +static inline int del_mtd_device(struct mtd_info *mtd) +{ + return -ENOSYS; +} +#endif #ifdef CONFIG_MTD_PARTITIONS int add_mtd_partitions(struct mtd_info *, const struct mtd_partition *, int); diff --git a/include/mtd/cfi_flash.h b/include/mtd/cfi_flash.h index 52cd1c4dbc4..f4aecaac75f 100644 --- a/include/mtd/cfi_flash.h +++ b/include/mtd/cfi_flash.h @@ -163,7 +163,7 @@ struct cfi_pri_hdr { #if defined(CONFIG_SYS_MAX_FLASH_BANKS_DETECT) /* map to cfi_flash_num_flash_banks only when supported */ #if IS_ENABLED(CONFIG_FLASH_CFI_DRIVER) && \ - (!IS_ENABLED(CONFIG_SPL_BUILD) || IS_ENABLED(CONFIG_SPL_MTD_SUPPORT)) + (!IS_ENABLED(CONFIG_SPL_BUILD) || IS_ENABLED(CONFIG_SPL_MTD)) #define CFI_FLASH_BANKS (cfi_flash_num_flash_banks) /* board code can update this variable before CFI detection */ extern int cfi_flash_num_flash_banks; diff --git a/include/nand.h b/include/nand.h index 70c1286ccb4..220ffa202ef 100644 --- a/include/nand.h +++ b/include/nand.h @@ -11,7 +11,9 @@ #include <config.h> extern void nand_init(void); +void nand_reinit(void); unsigned long nand_size(void); +unsigned int nand_page_size(void); #include <linux/compat.h> #include <linux/mtd/mtd.h> @@ -21,6 +23,7 @@ int nand_mtd_to_devnum(struct mtd_info *mtd); #if CONFIG_IS_ENABLED(SYS_NAND_SELF_INIT) void board_nand_init(void); int nand_register(int devnum, struct mtd_info *mtd); +void nand_unregister(struct mtd_info *mtd); #else struct nand_chip; diff --git a/include/os.h b/include/os.h index fc8a1b15cbf..877404a6c13 100644 --- a/include/os.h +++ b/include/os.h @@ -109,6 +109,19 @@ int os_unlink(const char *pathname); int os_persistent_file(char *buf, int maxsize, const char *fname); /** + * os_mktemp() - Create a temporary file + * @fname: The template to use for the file name. This must end with 6 Xs. It + * will be modified to the opened filename on success. + * @size: The size of the file + * + * Create a temporary file using @fname as a template, unlink it, and truncate + * it to @size. + * + * Return: A file descriptor, or negative errno on error + */ +int os_mktemp(char *fname, off_t size); + +/** * os_exit() - access to the OS exit() system call * * This exits with the supplied return code, which should be 0 to indicate diff --git a/include/system-constants.h b/include/system-constants.h index 59371568d1e..d688629f119 100644 --- a/include/system-constants.h +++ b/include/system-constants.h @@ -41,4 +41,8 @@ #define SPL_PAYLOAD_ARGS_ADDR 0 #endif +/* Number of pages per block */ +#define SYS_NAND_BLOCK_PAGES \ + (CONFIG_SYS_NAND_BLOCK_SIZE / CONFIG_SYS_NAND_PAGE_SIZE) + #endif |
