mailbox-uclass.h 2.4 KB

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