blob: 4562d2ac4f83e7fa8c88a9bb8c20addd694e1343 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0
Stephen Warren62f2c902016-05-16 17:41:37 -06002/*
3 * Copyright (c) 2016, NVIDIA CORPORATION.
Stephen Warren62f2c902016-05-16 17:41:37 -06004 */
5
6#include <common.h>
7#include <dm.h>
8#include <dm/test.h>
9#include <asm/mbox.h>
10#include <test/ut.h>
11
12static int dm_test_mailbox(struct unit_test_state *uts)
13{
14 struct udevice *dev;
15 uint32_t msg;
16
17 ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "mbox-test", &dev));
18 ut_assertok(sandbox_mbox_test_get(dev));
19
20 ut_asserteq(-ETIMEDOUT, sandbox_mbox_test_recv(dev, &msg));
21 ut_assertok(sandbox_mbox_test_send(dev, 0xaaff9955UL));
22 ut_assertok(sandbox_mbox_test_recv(dev, &msg));
23 ut_asserteq(msg, 0xaaff9955UL ^ SANDBOX_MBOX_PING_XOR);
24 ut_asserteq(-ETIMEDOUT, sandbox_mbox_test_recv(dev, &msg));
25
26 ut_assertok(sandbox_mbox_test_free(dev));
27
28 return 0;
29}
30DM_TEST(dm_test_mailbox, DM_TESTF_SCAN_FDT);