blob: e0618aad97b95165c6d6238af905833aa3a4b4ee [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0 */
Stephen Warrend0107832016-05-13 15:50:29 -06002/*
3 * Copyright (c) 2016, NVIDIA CORPORATION.
Stephen Warrend0107832016-05-13 15:50:29 -06004 */
5
6#ifndef _MAILBOX_UCLASS_H
7#define _MAILBOX_UCLASS_H
8
Stephen Warren3cdf6762016-06-17 09:43:56 -06009/* See mailbox.h for background documentation. */
Stephen Warrend0107832016-05-13 15:50:29 -060010
Stephen Warren3cdf6762016-06-17 09:43:56 -060011#include <mailbox.h>
Stephen Warrend0107832016-05-13 15:50:29 -060012
13struct udevice;
14
15/**
16 * struct mbox_ops - The functions that a mailbox driver must implement.
17 */
18struct mbox_ops {
19 /**
20 * of_xlate - Translate a client's device-tree (OF) mailbox specifier.
21 *
22 * The mailbox core calls this function as the first step in
23 * implementing a client's mbox_get_by_*() call.
24 *
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.
28 *
29 * At present, the mailbox API solely supports device-tree. If this
30 * changes, other xxx_xlate() functions may be added to support those
31 * other mechanisms.
32 *
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.
36 */
37 int (*of_xlate)(struct mbox_chan *chan,
Simon Glass91dbd532017-05-18 20:09:46 -060038 struct ofnode_phandle_args *args);
Stephen Warrend0107832016-05-13 15:50:29 -060039 /**
40 * request - Request a translated channel.
41 *
42 * The mailbox core calls this function as the second step in
43 * implementing a client's mbox_get_by_*() call, following a successful
44 * xxx_xlate() call.
45 *
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.
49 */
50 int (*request)(struct mbox_chan *chan);
51 /**
52 * free - Free a previously requested channel.
53 *
54 * This is the implementation of the client mbox_free() API.
55 *
56 * @chan: The channel to free.
57 * @return 0 if OK, or a negative error code.
58 */
59 int (*free)(struct mbox_chan *chan);
60 /**
61 * send - Send a message over a mailbox channel
62 *
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.
66 */
67 int (*send)(struct mbox_chan *chan, const void *data);
68 /**
69 * recv - Receive any available message from the channel.
70 *
71 * This function does not block. If not message is immediately
72 * available, the function should return an error.
73 *
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
77 * error code.
78 */
79 int (*recv)(struct mbox_chan *chan, void *data);
80};
81
82#endif