6 #include <linux/wait.h>
7 #include <linux/workqueue.h>
8 #include <linux/interrupt.h>
9 #include <linux/kfifo.h>
11 typedef u32 mbox_msg_t;
14 typedef int __bitwise omap_mbox_irq_t;
15 #define IRQ_TX ((__force omap_mbox_irq_t) 1)
16 #define IRQ_RX ((__force omap_mbox_irq_t) 2)
18 typedef int __bitwise omap_mbox_type_t;
19 #define OMAP_MBOX_TYPE1 ((__force omap_mbox_type_t) 1)
20 #define OMAP_MBOX_TYPE2 ((__force omap_mbox_type_t) 2)
22 struct omap_mbox_ops {
23 omap_mbox_type_t type;
24 int (*startup)(struct omap_mbox *mbox);
25 void (*shutdown)(struct omap_mbox *mbox);
27 mbox_msg_t (*fifo_read)(struct omap_mbox *mbox);
28 void (*fifo_write)(struct omap_mbox *mbox, mbox_msg_t msg);
29 int (*fifo_empty)(struct omap_mbox *mbox);
30 int (*fifo_full)(struct omap_mbox *mbox);
32 void (*enable_irq)(struct omap_mbox *mbox,
34 void (*disable_irq)(struct omap_mbox *mbox,
36 void (*ack_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
37 int (*is_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
39 void (*save_ctx)(struct omap_mbox *mbox);
40 void (*restore_ctx)(struct omap_mbox *mbox);
43 struct omap_mbox_queue {
46 struct work_struct work;
47 struct tasklet_struct tasklet;
48 int (*callback)(void *);
49 struct omap_mbox *mbox;
55 struct omap_mbox_queue *txq, *rxq;
56 struct omap_mbox_ops *ops;
61 int omap_mbox_msg_send(struct omap_mbox *, mbox_msg_t msg);
62 void omap_mbox_init_seq(struct omap_mbox *);
64 struct omap_mbox *omap_mbox_get(const char *);
65 void omap_mbox_put(struct omap_mbox *);
67 int omap_mbox_register(struct device *parent, struct omap_mbox **);
68 int omap_mbox_unregister(void);
70 static inline void omap_mbox_save_ctx(struct omap_mbox *mbox)
72 if (!mbox->ops->save_ctx) {
73 dev_err(mbox->dev, "%s:\tno save\n", __func__);
77 mbox->ops->save_ctx(mbox);
80 static inline void omap_mbox_restore_ctx(struct omap_mbox *mbox)
82 if (!mbox->ops->restore_ctx) {
83 dev_err(mbox->dev, "%s:\tno restore\n", __func__);
87 mbox->ops->restore_ctx(mbox);
90 static inline void omap_mbox_enable_irq(struct omap_mbox *mbox,
93 mbox->ops->enable_irq(mbox, irq);
96 static inline void omap_mbox_disable_irq(struct omap_mbox *mbox,
99 mbox->ops->disable_irq(mbox, irq);
102 #endif /* MAILBOX_H */