sandbox-mbox-test.c 1.1 KB

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