blob: 14f72d58d1cf2fc53119f73edd56accac8bd00a3 [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
Stephen Warren62f2c902016-05-16 17:41:37 -06006#include <dm.h>
Simon Glass9bc15642020-02-03 07:36:16 -07007#include <malloc.h>
Stephen Warren62f2c902016-05-16 17:41:37 -06008#include <dm/test.h>
9#include <asm/mbox.h>
Simon Glass75c4d412020-07-19 10:15:37 -060010#include <test/test.h>
Stephen Warren62f2c902016-05-16 17:41:37 -060011#include <test/ut.h>
12
13static int dm_test_mailbox(struct unit_test_state *uts)
14{
15 struct udevice *dev;
16 uint32_t msg;
17
18 ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "mbox-test", &dev));
19 ut_assertok(sandbox_mbox_test_get(dev));
20
21 ut_asserteq(-ETIMEDOUT, sandbox_mbox_test_recv(dev, &msg));
22 ut_assertok(sandbox_mbox_test_send(dev, 0xaaff9955UL));
23 ut_assertok(sandbox_mbox_test_recv(dev, &msg));
24 ut_asserteq(msg, 0xaaff9955UL ^ SANDBOX_MBOX_PING_XOR);
25 ut_asserteq(-ETIMEDOUT, sandbox_mbox_test_recv(dev, &msg));
26
27 ut_assertok(sandbox_mbox_test_free(dev));
28
29 return 0;
30}
Simon Glass974dccd2020-07-28 19:41:12 -060031DM_TEST(dm_test_mailbox, UT_TESTF_SCAN_FDT);