Sean Anderson | 60d76e3 | 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 | |
| 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 | |
| 13 | static 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 | |
| 28 | static 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 | } |
| 36 | SPL_IMG_TEST(spl_test_spi, LEGACY, DM_FLAGS); |
Sean Anderson | a04d5f6 | 2023-11-08 11:48:56 -0500 | [diff] [blame] | 37 | SPL_IMG_TEST(spl_test_spi, LEGACY_LZMA, DM_FLAGS); |
Sean Anderson | 60d76e3 | 2023-10-14 16:48:05 -0400 | [diff] [blame] | 38 | SPL_IMG_TEST(spl_test_spi, IMX8, DM_FLAGS); |
| 39 | SPL_IMG_TEST(spl_test_spi, FIT_INTERNAL, DM_FLAGS); |
| 40 | #if !IS_ENABLED(CONFIG_SPL_LOAD_FIT_FULL) |
| 41 | SPL_IMG_TEST(spl_test_spi, FIT_EXTERNAL, DM_FLAGS); |
| 42 | #endif |