diff options
Diffstat (limited to 'arch/arm/mach-ux500/include/mach/mbox-db5500.h')
-rw-r--r-- | arch/arm/mach-ux500/include/mach/mbox-db5500.h | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/arch/arm/mach-ux500/include/mach/mbox-db5500.h b/arch/arm/mach-ux500/include/mach/mbox-db5500.h new file mode 100644 index 000000000000..7f9da4d2fbda --- /dev/null +++ b/arch/arm/mach-ux500/include/mach/mbox-db5500.h | |||
@@ -0,0 +1,88 @@ | |||
1 | /* | ||
2 | * Copyright (C) ST-Ericsson SA 2010 | ||
3 | * Author: Stefan Nilsson <stefan.xk.nilsson@stericsson.com> for ST-Ericsson. | ||
4 | * Author: Martin Persson <martin.persson@stericsson.com> for ST-Ericsson. | ||
5 | * License terms: GNU General Public License (GPL), version 2. | ||
6 | */ | ||
7 | |||
8 | #ifndef __INC_STE_MBOX_H | ||
9 | #define __INC_STE_MBOX_H | ||
10 | |||
11 | #define MBOX_BUF_SIZE 16 | ||
12 | #define MBOX_NAME_SIZE 8 | ||
13 | |||
14 | /** | ||
15 | * mbox_recv_cb_t - Definition of the mailbox callback. | ||
16 | * @mbox_msg: The mailbox message. | ||
17 | * @priv: The clients private data as specified in the call to mbox_setup. | ||
18 | * | ||
19 | * This function will be called upon reception of new mailbox messages. | ||
20 | */ | ||
21 | typedef void mbox_recv_cb_t (u32 mbox_msg, void *priv); | ||
22 | |||
23 | /** | ||
24 | * struct mbox - Mailbox instance struct | ||
25 | * @list: Linked list head. | ||
26 | * @pdev: Pointer to device struct. | ||
27 | * @cb: Callback function. Will be called | ||
28 | * when new data is received. | ||
29 | * @client_data: Clients private data. Will be sent back | ||
30 | * in the callback function. | ||
31 | * @virtbase_peer: Virtual address for outgoing mailbox. | ||
32 | * @virtbase_local: Virtual address for incoming mailbox. | ||
33 | * @buffer: Then internal queue for outgoing messages. | ||
34 | * @name: Name of this mailbox. | ||
35 | * @buffer_available: Completion variable to achieve "blocking send". | ||
36 | * This variable will be signaled when there is | ||
37 | * internal buffer space available. | ||
38 | * @client_blocked: To keep track if any client is currently | ||
39 | * blocked. | ||
40 | * @lock: Spinlock to protect this mailbox instance. | ||
41 | * @write_index: Index in internal buffer to write to. | ||
42 | * @read_index: Index in internal buffer to read from. | ||
43 | * @allocated: Indicates whether this particular mailbox | ||
44 | * id has been allocated by someone. | ||
45 | */ | ||
46 | struct mbox { | ||
47 | struct list_head list; | ||
48 | struct platform_device *pdev; | ||
49 | mbox_recv_cb_t *cb; | ||
50 | void *client_data; | ||
51 | void __iomem *virtbase_peer; | ||
52 | void __iomem *virtbase_local; | ||
53 | u32 buffer[MBOX_BUF_SIZE]; | ||
54 | char name[MBOX_NAME_SIZE]; | ||
55 | struct completion buffer_available; | ||
56 | u8 client_blocked; | ||
57 | spinlock_t lock; | ||
58 | u8 write_index; | ||
59 | u8 read_index; | ||
60 | bool allocated; | ||
61 | }; | ||
62 | |||
63 | /** | ||
64 | * mbox_setup - Set up a mailbox and return its instance. | ||
65 | * @mbox_id: The ID number of the mailbox. 0 or 1 for modem CPU, | ||
66 | * 2 for modem DSP. | ||
67 | * @mbox_cb: Pointer to the callback function to be called when a new message | ||
68 | * is received. | ||
69 | * @priv: Client user data which will be returned in the callback. | ||
70 | * | ||
71 | * Returns a mailbox instance to be specified in subsequent calls to mbox_send. | ||
72 | */ | ||
73 | struct mbox *mbox_setup(u8 mbox_id, mbox_recv_cb_t *mbox_cb, void *priv); | ||
74 | |||
75 | /** | ||
76 | * mbox_send - Send a mailbox message. | ||
77 | * @mbox: Mailbox instance (returned by mbox_setup) | ||
78 | * @mbox_msg: The mailbox message to send. | ||
79 | * @block: Specifies whether this call will block until send is possible, | ||
80 | * or return an error if the mailbox buffer is full. | ||
81 | * | ||
82 | * Returns 0 on success or a negative error code on error. -ENOMEM indicates | ||
83 | * that the internal buffer is full and you have to try again later (or | ||
84 | * specify "block" in order to block until send is possible). | ||
85 | */ | ||
86 | int mbox_send(struct mbox *mbox, u32 mbox_msg, bool block); | ||
87 | |||
88 | #endif /*INC_STE_MBOX_H*/ | ||