aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-omap/mailbox.c
diff options
context:
space:
mode:
authorHiroshi DOYU <Hiroshi.DOYU@nokia.com>2009-03-23 21:07:26 -0400
committerTony Lindgren <tony@atomide.com>2009-03-23 21:07:26 -0400
commit9ae0ee0076d51d9017e89004643825a67d852910 (patch)
tree7a51c4f51beb00999ffd68e2f8682a0d73f98509 /arch/arm/plat-omap/mailbox.c
parentc75ee7520b4ad48a6948f51ca43b2e46ebd3696a (diff)
omap mailbox: move mailbox.h into mailbox.c
no need to keep mailbox.h separately. Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
Diffstat (limited to 'arch/arm/plat-omap/mailbox.c')
-rw-r--r--arch/arm/plat-omap/mailbox.c86
1 files changed, 85 insertions, 1 deletions
diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index 75ede474d844..fcac60dedc8a 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -31,11 +31,95 @@
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/io.h> 32#include <linux/io.h>
33#include <mach/mailbox.h> 33#include <mach/mailbox.h>
34#include "mailbox.h"
35 34
36static struct omap_mbox *mboxes; 35static struct omap_mbox *mboxes;
37static DEFINE_RWLOCK(mboxes_lock); 36static DEFINE_RWLOCK(mboxes_lock);
38 37
38/*
39 * Mailbox sequence bit API
40 */
41#if defined(CONFIG_ARCH_OMAP1)
42# define MBOX_USE_SEQ_BIT
43#elif defined(CONFIG_ARCH_OMAP2)
44# define MBOX_USE_SEQ_BIT
45#endif
46
47#ifdef MBOX_USE_SEQ_BIT
48/* seq_rcv should be initialized with any value other than
49 * 0 and 1 << 31, to allow either value for the first
50 * message. */
51static inline void mbox_seq_init(struct omap_mbox *mbox)
52{
53 /* any value other than 0 and 1 << 31 */
54 mbox->seq_rcv = 0xffffffff;
55}
56
57static inline void mbox_seq_toggle(struct omap_mbox *mbox, mbox_msg_t * msg)
58{
59 /* add seq_snd to msg */
60 *msg = (*msg & 0x7fffffff) | mbox->seq_snd;
61 /* flip seq_snd */
62 mbox->seq_snd ^= 1 << 31;
63}
64
65static inline int mbox_seq_test(struct omap_mbox *mbox, mbox_msg_t msg)
66{
67 mbox_msg_t seq = msg & (1 << 31);
68 if (seq == mbox->seq_rcv)
69 return -1;
70 mbox->seq_rcv = seq;
71 return 0;
72}
73#else
74static inline void mbox_seq_init(struct omap_mbox *mbox)
75{
76}
77static inline void mbox_seq_toggle(struct omap_mbox *mbox, mbox_msg_t * msg)
78{
79}
80static inline int mbox_seq_test(struct omap_mbox *mbox, mbox_msg_t msg)
81{
82 return 0;
83}
84#endif
85
86/* Mailbox FIFO handle functions */
87static inline mbox_msg_t mbox_fifo_read(struct omap_mbox *mbox)
88{
89 return mbox->ops->fifo_read(mbox);
90}
91static inline void mbox_fifo_write(struct omap_mbox *mbox, mbox_msg_t msg)
92{
93 mbox->ops->fifo_write(mbox, msg);
94}
95static inline int mbox_fifo_empty(struct omap_mbox *mbox)
96{
97 return mbox->ops->fifo_empty(mbox);
98}
99static inline int mbox_fifo_full(struct omap_mbox *mbox)
100{
101 return mbox->ops->fifo_full(mbox);
102}
103
104/* Mailbox IRQ handle functions */
105static inline void enable_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
106{
107 mbox->ops->enable_irq(mbox, irq);
108}
109static inline void disable_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
110{
111 mbox->ops->disable_irq(mbox, irq);
112}
113static inline void ack_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
114{
115 if (mbox->ops->ack_irq)
116 mbox->ops->ack_irq(mbox, irq);
117}
118static inline int is_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
119{
120 return mbox->ops->is_irq(mbox, irq);
121}
122
39/* Mailbox Sequence Bit function */ 123/* Mailbox Sequence Bit function */
40void omap_mbox_init_seq(struct omap_mbox *mbox) 124void omap_mbox_init_seq(struct omap_mbox *mbox)
41{ 125{