blob: 80836dc0dffa89993a7825b9b44fa405f0f2be5c [file] [log] [blame]
Sean Anderson8734d6f2023-10-14 16:48:05 -04001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2023 Sean Anderson <seanga2@gmail.com>
4 */
5
Sean Anderson8734d6f2023-10-14 16:48:05 -04006#include <dm.h>
7#include <spi_flash.h>
8#include <spl.h>
9#include <test/spl.h>
10#include <test/ut.h>
11
12static int spl_test_spi_write_image(struct unit_test_state *uts, void *img,
13 size_t img_size)
14{
15 struct spi_flash *flash;
16
17 flash = spi_flash_probe(spl_spi_boot_bus(), spl_spi_boot_cs(),
18 CONFIG_SF_DEFAULT_SPEED,
19 CONFIG_SF_DEFAULT_MODE);
20 ut_assertnonnull(flash);
21 ut_assertok(spi_flash_write(flash, spl_spi_get_uboot_offs(flash),
22 img_size, img));
23
24 return 0;
25}
26
27static int spl_test_spi(struct unit_test_state *uts, const char *test_name,
28 enum spl_test_image type)
29{
30 return do_spl_test_load(uts, test_name, type,
31 SPL_LOAD_IMAGE_GET(1, BOOT_DEVICE_SPI,
32 spl_spi_load_image),
33 spl_test_spi_write_image);
34}
35SPL_IMG_TEST(spl_test_spi, LEGACY, DM_FLAGS);
Sean Anderson38e4f622023-11-08 11:48:56 -050036SPL_IMG_TEST(spl_test_spi, LEGACY_LZMA, DM_FLAGS);
Sean Anderson8734d6f2023-10-14 16:48:05 -040037SPL_IMG_TEST(spl_test_spi, IMX8, DM_FLAGS);
38SPL_IMG_TEST(spl_test_spi, FIT_INTERNAL, DM_FLAGS);
39#if !IS_ENABLED(CONFIG_SPL_LOAD_FIT_FULL)
40SPL_IMG_TEST(spl_test_spi, FIT_EXTERNAL, DM_FLAGS);
41#endif