2 * Mailbox internal functions
4 * Copyright (C) 2006 Nokia Corporation
5 * Written by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
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
12 #ifndef __ARCH_ARM_PLAT_MAILBOX_H
13 #define __ARCH_ARM_PLAT_MAILBOX_H
15 #define MBOX_NAME_LEN 255
18 * Mailbox sequence bit API
20 #if defined(CONFIG_ARCH_OMAP1)
21 # define MBOX_USE_SEQ_BIT
22 #elif defined(CONFIG_ARCH_OMAP2)
23 # define MBOX_USE_SEQ_BIT
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
30 static inline void mbox_seq_init(struct omap_mbox *mbox)
32 /* any value other than 0 and 1 << 31 */
33 mbox->seq_rcv = 0xffffffff;
36 static inline void mbox_seq_toggle(struct omap_mbox *mbox, mbox_msg_t * msg)
38 /* add seq_snd to msg */
39 *msg = (*msg & 0x7fffffff) | mbox->seq_snd;
41 mbox->seq_snd ^= 1 << 31;
44 static inline int mbox_seq_test(struct omap_mbox *mbox, mbox_msg_t msg)
46 mbox_msg_t seq = msg & (1 << 31);
47 if (seq == mbox->seq_rcv)
53 static inline void mbox_seq_init(struct omap_mbox *mbox)
56 static inline void mbox_seq_toggle(struct omap_mbox *mbox, mbox_msg_t * msg)
59 static inline int mbox_seq_test(struct omap_mbox *mbox, mbox_msg_t msg)
65 /* Mailbox FIFO handle functions */
66 static inline mbox_msg_t mbox_fifo_read(struct omap_mbox *mbox)
68 return mbox->ops->fifo_read(mbox);
70 static inline void mbox_fifo_write(struct omap_mbox *mbox, mbox_msg_t msg)
72 mbox->ops->fifo_write(mbox, msg);
74 static inline int mbox_fifo_empty(struct omap_mbox *mbox)
76 return mbox->ops->fifo_empty(mbox);
78 static inline int mbox_fifo_full(struct omap_mbox *mbox)
80 return mbox->ops->fifo_full(mbox);
83 /* Mailbox IRQ handle functions */
84 static inline void enable_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
86 mbox->ops->enable_irq(mbox, irq);
88 static inline void disable_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
90 mbox->ops->disable_irq(mbox, irq);
92 static inline void ack_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
94 if (mbox->ops->ack_irq)
95 mbox->ops->ack_irq(mbox, irq);
97 static inline int is_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
99 return mbox->ops->is_irq(mbox, irq);
102 #endif /* __ARCH_ARM_PLAT_MAILBOX_H */