mailbox.c 788 B

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