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