sandbox-mbox-test.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 <mailbox.h>
  8. #include <malloc.h>
  9. #include <asm/io.h>
  10. struct sandbox_mbox_test {
  11. struct mbox_chan chan;
  12. };
  13. int sandbox_mbox_test_get(struct udevice *dev)
  14. {
  15. struct sandbox_mbox_test *sbmt = dev_get_priv(dev);
  16. return mbox_get_by_name(dev, "test", &sbmt->chan);
  17. }
  18. int sandbox_mbox_test_send(struct udevice *dev, uint32_t msg)
  19. {
  20. struct sandbox_mbox_test *sbmt = dev_get_priv(dev);
  21. return mbox_send(&sbmt->chan, &msg);
  22. }
  23. int sandbox_mbox_test_recv(struct udevice *dev, uint32_t *msg)
  24. {
  25. struct sandbox_mbox_test *sbmt = dev_get_priv(dev);
  26. return mbox_recv(&sbmt->chan, msg, 100);
  27. }
  28. int sandbox_mbox_test_free(struct udevice *dev)
  29. {
  30. struct sandbox_mbox_test *sbmt = dev_get_priv(dev);
  31. return mbox_free(&sbmt->chan);
  32. }
  33. static const struct udevice_id sandbox_mbox_test_ids[] = {
  34. { .compatible = "sandbox,mbox-test" },
  35. { }
  36. };
  37. U_BOOT_DRIVER(sandbox_mbox_test) = {
  38. .name = "sandbox_mbox_test",
  39. .id = UCLASS_MISC,
  40. .of_match = sandbox_mbox_test_ids,
  41. .priv_auto_alloc_size = sizeof(struct sandbox_mbox_test),
  42. };