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