Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (C) 2013-2014 Linaro Ltd.
0004  * Author: Jassi Brar <jassisinghbrar@gmail.com>
0005  */
0006 
0007 #ifndef __MAILBOX_CLIENT_H
0008 #define __MAILBOX_CLIENT_H
0009 
0010 #include <linux/of.h>
0011 #include <linux/device.h>
0012 
0013 struct mbox_chan;
0014 
0015 /**
0016  * struct mbox_client - User of a mailbox
0017  * @dev:        The client device
0018  * @tx_block:       If the mbox_send_message should block until data is
0019  *          transmitted.
0020  * @tx_tout:        Max block period in ms before TX is assumed failure
0021  * @knows_txdone:   If the client could run the TX state machine. Usually
0022  *          if the client receives some ACK packet for transmission.
0023  *          Unused if the controller already has TX_Done/RTR IRQ.
0024  * @rx_callback:    Atomic callback to provide client the data received
0025  * @tx_prepare:     Atomic callback to ask client to prepare the payload
0026  *          before initiating the transmission if required.
0027  * @tx_done:        Atomic callback to tell client of data transmission
0028  */
0029 struct mbox_client {
0030     struct device *dev;
0031     bool tx_block;
0032     unsigned long tx_tout;
0033     bool knows_txdone;
0034 
0035     void (*rx_callback)(struct mbox_client *cl, void *mssg);
0036     void (*tx_prepare)(struct mbox_client *cl, void *mssg);
0037     void (*tx_done)(struct mbox_client *cl, void *mssg, int r);
0038 };
0039 
0040 struct mbox_chan *mbox_request_channel_byname(struct mbox_client *cl,
0041                           const char *name);
0042 struct mbox_chan *mbox_request_channel(struct mbox_client *cl, int index);
0043 int mbox_send_message(struct mbox_chan *chan, void *mssg);
0044 int mbox_flush(struct mbox_chan *chan, unsigned long timeout);
0045 void mbox_client_txdone(struct mbox_chan *chan, int r); /* atomic */
0046 bool mbox_client_peek_data(struct mbox_chan *chan); /* atomic */
0047 void mbox_free_channel(struct mbox_chan *chan); /* may sleep */
0048 
0049 #endif /* __MAILBOX_CLIENT_H */