Merge remote-tracking branch 'lsk/v3.10/topic/configs' into linux-linaro-lsk
[firefly-linux-kernel-4.4.55.git] / include / linux / mailbox_client.h
1 /*
2  * Copyright (C) 2014 Linaro Ltd.
3  * Author: Jassi Brar <jassisinghbrar@gmail.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation.
8  */
9
10 #ifndef __MAILBOX_CLIENT_H
11 #define __MAILBOX_CLIENT_H
12
13 #include <linux/of.h>
14
15 struct mbox_chan;
16
17 /**
18  * struct mbox_client - User of a mailbox
19  * @dev:                The client device
20  * @chan_name:          The "controller:channel" this client wants
21  * @rx_callback:        Atomic callback to provide client the data received
22  * @tx_done:            Atomic callback to tell client of data transmission
23  * @tx_block:           If the mbox_send_message should block until data is
24  *                      transmitted.
25  * @tx_tout:            Max block period in ms before TX is assumed failure
26  * @knows_txdone:       if the client could run the TX state machine. Usually
27  *                      if the client receives some ACK packet for transmission.
28  *                      Unused if the controller already has TX_Done/RTR IRQ.
29  */
30 struct mbox_client {
31         struct device *dev;
32         const char *chan_name;
33         void (*rx_callback)(struct mbox_client *cl, void *mssg);
34         void (*tx_done)(struct mbox_client *cl, void *mssg, int r);
35         bool tx_block;
36         unsigned long tx_tout;
37         bool knows_txdone;
38 };
39
40 struct mbox_chan *mbox_request_channel(struct mbox_client *cl);
41 int mbox_send_message(struct mbox_chan *chan, void *mssg);
42 void mbox_client_txdone(struct mbox_chan *chan, int r);
43 bool mbox_client_peek_data(struct mbox_chan *chan);
44 void mbox_free_channel(struct mbox_chan *chan);
45
46 #endif /* __MAILBOX_CLIENT_H */