mailbox-uclass.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2016, NVIDIA CORPORATION.
  4. */
  5. #ifndef _MAILBOX_UCLASS_H
  6. #define _MAILBOX_UCLASS_H
  7. /* See mailbox.h for background documentation. */
  8. #include <mailbox.h>
  9. struct udevice;
  10. /**
  11. * struct mbox_ops - The functions that a mailbox driver must implement.
  12. */
  13. struct mbox_ops {
  14. /**
  15. * of_xlate - Translate a client's device-tree (OF) mailbox specifier.
  16. *
  17. * The mailbox core calls this function as the first step in
  18. * implementing a client's mbox_get_by_*() call.
  19. *
  20. * If this function pointer is set to NULL, the mailbox core will use
  21. * a default implementation, which assumes #mbox-cells = <1>, and that
  22. * the DT cell contains a simple integer channel ID.
  23. *
  24. * At present, the mailbox API solely supports device-tree. If this
  25. * changes, other xxx_xlate() functions may be added to support those
  26. * other mechanisms.
  27. *
  28. * @chan: The channel to hold the translation result.
  29. * @args: The mailbox specifier values from device tree.
  30. * @return 0 if OK, or a negative error code.
  31. */
  32. int (*of_xlate)(struct mbox_chan *chan,
  33. struct ofnode_phandle_args *args);
  34. /**
  35. * request - Request a translated channel.
  36. *
  37. * The mailbox core calls this function as the second step in
  38. * implementing a client's mbox_get_by_*() call, following a successful
  39. * xxx_xlate() call.
  40. *
  41. * @chan: The channel to request; this has been filled in by a
  42. * previoux xxx_xlate() function call.
  43. * @return 0 if OK, or a negative error code.
  44. */
  45. int (*request)(struct mbox_chan *chan);
  46. /**
  47. * free - Free a previously requested channel.
  48. *
  49. * This is the implementation of the client mbox_free() API.
  50. *
  51. * @chan: The channel to free.
  52. * @return 0 if OK, or a negative error code.
  53. */
  54. int (*free)(struct mbox_chan *chan);
  55. /**
  56. * send - Send a message over a mailbox channel
  57. *
  58. * @chan: The channel to send to the message to.
  59. * @data: A pointer to the message to send.
  60. * @return 0 if OK, or a negative error code.
  61. */
  62. int (*send)(struct mbox_chan *chan, const void *data);
  63. /**
  64. * recv - Receive any available message from the channel.
  65. *
  66. * This function does not block. If not message is immediately
  67. * available, the function should return an error.
  68. *
  69. * @chan: The channel to receive to the message from.
  70. * @data: A pointer to the buffer to hold the received message.
  71. * @return 0 if OK, -ENODATA if no message was available, or a negative
  72. * error code.
  73. */
  74. int (*recv)(struct mbox_chan *chan, void *data);
  75. };
  76. #endif