Sean Anderson | 8734d6f | 2023-10-14 16:48:05 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright (C) 2023 Sean Anderson <seanga2@gmail.com> |
| 4 | */ |
| 5 | |
Sean Anderson | 8734d6f | 2023-10-14 16:48:05 -0400 | [diff] [blame] | 6 | #include <dm.h> |
| 7 | #include <spi_flash.h> |
| 8 | #include <spl.h> |
| 9 | #include <test/spl.h> |
| 10 | #include <test/ut.h> |
| 11 | |
| 12 | static 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 | |
| 27 | static 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 | } |
| 35 | SPL_IMG_TEST(spl_test_spi, LEGACY, DM_FLAGS); |
Sean Anderson | 38e4f62 | 2023-11-08 11:48:56 -0500 | [diff] [blame] | 36 | SPL_IMG_TEST(spl_test_spi, LEGACY_LZMA, DM_FLAGS); |
Sean Anderson | 8734d6f | 2023-10-14 16:48:05 -0400 | [diff] [blame] | 37 | SPL_IMG_TEST(spl_test_spi, IMX8, DM_FLAGS); |
| 38 | SPL_IMG_TEST(spl_test_spi, FIT_INTERNAL, DM_FLAGS); |
| 39 | #if !IS_ENABLED(CONFIG_SPL_LOAD_FIT_FULL) |
| 40 | SPL_IMG_TEST(spl_test_spi, FIT_EXTERNAL, DM_FLAGS); |
| 41 | #endif |