1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2023 Sean Anderson <seanga2@gmail.com>
4  */
5 
6 #include <dm.h>
7 #include <spl.h>
8 #include <asm/io.h>
9 #include <test/spl.h>
10 #include <test/ut.h>
11 
12 static void *spl_test_nor_base;
13 
spl_nor_get_uboot_base(void)14 unsigned long spl_nor_get_uboot_base(void)
15 {
16 	return virt_to_phys(spl_test_nor_base);
17 }
18 
spl_test_nor_write_image(struct unit_test_state * uts,void * img,size_t img_size)19 static int spl_test_nor_write_image(struct unit_test_state *uts, void *img,
20 				    size_t img_size)
21 {
22 	spl_test_nor_base = img;
23 	return 0;
24 }
25 
spl_test_nor(struct unit_test_state * uts,const char * test_name,enum spl_test_image type)26 static int spl_test_nor(struct unit_test_state *uts, const char *test_name,
27 			enum spl_test_image type)
28 {
29 	return do_spl_test_load(uts, test_name, type,
30 				SPL_LOAD_IMAGE_GET(0, BOOT_DEVICE_NOR,
31 						   spl_nor_load_image),
32 				spl_test_nor_write_image);
33 }
34 SPL_IMG_TEST(spl_test_nor, LEGACY, 0);
35 SPL_IMG_TEST(spl_test_nor, LEGACY_LZMA, 0);
36 SPL_IMG_TEST(spl_test_nor, IMX8, 0);
37 SPL_IMG_TEST(spl_test_nor, FIT_INTERNAL, 0);
38 #if !IS_ENABLED(CONFIG_SPL_LOAD_FIT_FULL)
39 SPL_IMG_TEST(spl_test_nor, FIT_EXTERNAL, 0);
40 #endif
41