sf.c (f9d49f92f8cdf04a47704519a63368259595c3a0) sf.c (a58986ca8b53d8c7a441397082f84edc7f47d19f)
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2013 Google, Inc
4 */
5
6#include <common.h>
7#include <dm.h>
8#include <fdtdec.h>
9#include <mapmem.h>
10#include <os.h>
11#include <spi.h>
12#include <spi_flash.h>
13#include <asm/state.h>
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2013 Google, Inc
4 */
5
6#include <common.h>
7#include <dm.h>
8#include <fdtdec.h>
9#include <mapmem.h>
10#include <os.h>
11#include <spi.h>
12#include <spi_flash.h>
13#include <asm/state.h>
14#include <asm/test.h>
14#include <dm/test.h>
15#include <dm/util.h>
16#include <test/ut.h>
17
18/* Simple test of sandbox SPI flash */
19static int dm_test_spi_flash(struct unit_test_state *uts)
20{
21 struct udevice *dev, *emul;

--- 18 unchanged lines hidden (view full) ---

40
41 /* Write some new data */
42 for (i = 0; i < size; i++)
43 src[i] = i;
44 ut_assertok(spi_flash_write_dm(dev, 0, size, src));
45 ut_assertok(spi_flash_read_dm(dev, 0, size, dst));
46 ut_assertok(memcmp(src, dst, size));
47
15#include <dm/test.h>
16#include <dm/util.h>
17#include <test/ut.h>
18
19/* Simple test of sandbox SPI flash */
20static int dm_test_spi_flash(struct unit_test_state *uts)
21{
22 struct udevice *dev, *emul;

--- 18 unchanged lines hidden (view full) ---

41
42 /* Write some new data */
43 for (i = 0; i < size; i++)
44 src[i] = i;
45 ut_assertok(spi_flash_write_dm(dev, 0, size, src));
46 ut_assertok(spi_flash_read_dm(dev, 0, size, dst));
47 ut_assertok(memcmp(src, dst, size));
48
49 /* Try the write-protect stuff */
50 ut_assertok(uclass_first_device_err(UCLASS_SPI_EMUL, &emul));
51 ut_asserteq(0, spl_flash_get_sw_write_prot(dev));
52 sandbox_sf_set_block_protect(emul, 1);
53 ut_asserteq(1, spl_flash_get_sw_write_prot(dev));
54 sandbox_sf_set_block_protect(emul, 0);
55 ut_asserteq(0, spl_flash_get_sw_write_prot(dev));
56
48 /*
49 * Since we are about to destroy all devices, we must tell sandbox
50 * to forget the emulation device
51 */
52 sandbox_sf_unbind_emul(state_get_current(), 0, 0);
53
54 return 0;
55}

--- 29 unchanged lines hidden ---
57 /*
58 * Since we are about to destroy all devices, we must tell sandbox
59 * to forget the emulation device
60 */
61 sandbox_sf_unbind_emul(state_get_current(), 0, 0);
62
63 return 0;
64}

--- 29 unchanged lines hidden ---