blob: 955f3d7641e828e904ae84f35dcb2bbb16594837 [file] [log] [blame]
Jassi Brar95115d42014-06-12 22:31:19 +05301/*
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
15struct 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 */
30struct 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
Mark Brown4bd33802014-06-13 21:40:45 +010040struct mbox_chan *mbox_request_channel(struct mbox_client *cl);
Jassi Brar95115d42014-06-12 22:31:19 +053041int mbox_send_message(struct mbox_chan *chan, void *mssg);
42void mbox_client_txdone(struct mbox_chan *chan, int r);
Mark Brown087e5632014-06-13 21:36:34 +010043bool mbox_client_peek_data(struct mbox_chan *chan);
Jassi Brar95115d42014-06-12 22:31:19 +053044void mbox_free_channel(struct mbox_chan *chan);
45
46#endif /* __MAILBOX_CLIENT_H */