1*8961b524SStephen Warren /* 2*8961b524SStephen Warren * Copyright (c) 2016, NVIDIA CORPORATION. 3*8961b524SStephen Warren * 4*8961b524SStephen Warren * SPDX-License-Identifier: GPL-2.0 5*8961b524SStephen Warren */ 6*8961b524SStephen Warren 7*8961b524SStephen Warren #include <common.h> 8*8961b524SStephen Warren #include <dm.h> 9*8961b524SStephen Warren #include <dm/test.h> 10*8961b524SStephen Warren #include <asm/mbox.h> 11*8961b524SStephen Warren #include <test/ut.h> 12*8961b524SStephen Warren 13*8961b524SStephen Warren static int dm_test_mailbox(struct unit_test_state *uts) 14*8961b524SStephen Warren { 15*8961b524SStephen Warren struct udevice *dev; 16*8961b524SStephen Warren uint32_t msg; 17*8961b524SStephen Warren 18*8961b524SStephen Warren ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "mbox-test", &dev)); 19*8961b524SStephen Warren ut_assertok(sandbox_mbox_test_get(dev)); 20*8961b524SStephen Warren 21*8961b524SStephen Warren ut_asserteq(-ETIMEDOUT, sandbox_mbox_test_recv(dev, &msg)); 22*8961b524SStephen Warren ut_assertok(sandbox_mbox_test_send(dev, 0xaaff9955UL)); 23*8961b524SStephen Warren ut_assertok(sandbox_mbox_test_recv(dev, &msg)); 24*8961b524SStephen Warren ut_asserteq(msg, 0xaaff9955UL ^ SANDBOX_MBOX_PING_XOR); 25*8961b524SStephen Warren ut_asserteq(-ETIMEDOUT, sandbox_mbox_test_recv(dev, &msg)); 26*8961b524SStephen Warren 27*8961b524SStephen Warren ut_assertok(sandbox_mbox_test_free(dev)); 28*8961b524SStephen Warren 29*8961b524SStephen Warren return 0; 30*8961b524SStephen Warren } 31*8961b524SStephen Warren DM_TEST(dm_test_mailbox, DM_TESTF_SCAN_FDT); 32