]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/plat-omap/mailbox.h
ARM:OMAP: Integrated blk request queues for mbox fwk
[linux-2.6-omap-h63xx.git] / arch / arm / plat-omap / mailbox.h
1 /*
2  * Mailbox internal functions
3  *
4  * Copyright (C) 2006 Nokia Corporation
5  * Written by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
6  *
7  * This file is subject to the terms and conditions of the GNU General Public
8  * License.  See the file "COPYING" in the main directory of this archive
9  * for more details.
10  */
11
12 #ifndef __ARCH_ARM_PLAT_MAILBOX_H
13 #define __ARCH_ARM_PLAT_MAILBOX_H
14
15 #define MBOX_NAME_LEN 255
16
17 /*
18  * Mailbox sequence bit API
19  */
20 #if defined(CONFIG_ARCH_OMAP1)
21 #  define MBOX_USE_SEQ_BIT
22 #elif defined(CONFIG_ARCH_OMAP2)
23 #  define MBOX_USE_SEQ_BIT
24 #endif
25
26 #ifdef MBOX_USE_SEQ_BIT
27 /* seq_rcv should be initialized with any value other than
28  * 0 and 1 << 31, to allow either value for the first
29  * message.  */
30 static inline void mbox_seq_init(struct omap_mbox *mbox)
31 {
32         /* any value other than 0 and 1 << 31 */
33         mbox->seq_rcv = 0xffffffff;
34 }
35
36 static inline void mbox_seq_toggle(struct omap_mbox *mbox, mbox_msg_t * msg)
37 {
38         /* add seq_snd to msg */
39         *msg = (*msg & 0x7fffffff) | mbox->seq_snd;
40         /* flip seq_snd */
41         mbox->seq_snd ^= 1 << 31;
42 }
43
44 static inline int mbox_seq_test(struct omap_mbox *mbox, mbox_msg_t msg)
45 {
46         mbox_msg_t seq = msg & (1 << 31);
47         if (seq == mbox->seq_rcv)
48                 return -1;
49         mbox->seq_rcv = seq;
50         return 0;
51 }
52 #else
53 static inline void mbox_seq_init(struct omap_mbox *mbox)
54 {
55 }
56 static inline void mbox_seq_toggle(struct omap_mbox *mbox, mbox_msg_t * msg)
57 {
58 }
59 static inline int mbox_seq_test(struct omap_mbox *mbox, mbox_msg_t msg)
60 {
61         return 0;
62 }
63 #endif
64
65 /* Mailbox FIFO handle functions */
66 static inline mbox_msg_t mbox_fifo_read(struct omap_mbox *mbox)
67 {
68         return mbox->ops->fifo_read(mbox);
69 }
70 static inline void mbox_fifo_write(struct omap_mbox *mbox, mbox_msg_t msg)
71 {
72         mbox->ops->fifo_write(mbox, msg);
73 }
74 static inline int mbox_fifo_empty(struct omap_mbox *mbox)
75 {
76         return mbox->ops->fifo_empty(mbox);
77 }
78 static inline int mbox_fifo_full(struct omap_mbox *mbox)
79 {
80         return mbox->ops->fifo_full(mbox);
81 }
82
83 /* Mailbox IRQ handle functions */
84 static inline void enable_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
85 {
86         mbox->ops->enable_irq(mbox, irq);
87 }
88 static inline void disable_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
89 {
90         mbox->ops->disable_irq(mbox, irq);
91 }
92 static inline void ack_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
93 {
94         if (mbox->ops->ack_irq)
95                 mbox->ops->ack_irq(mbox, irq);
96 }
97 static inline int is_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
98 {
99         return mbox->ops->is_irq(mbox, irq);
100 }
101
102 #endif                          /* __ARCH_ARM_PLAT_MAILBOX_H */