6 #include <linux/wait.h>
7 #include <linux/workqueue.h>
8 #include <linux/blkdev.h>
10 typedef u32 mbox_msg_t;
13 typedef int __bitwise omap_mbox_irq_t;
14 #define IRQ_TX ((__force omap_mbox_irq_t) 1)
15 #define IRQ_RX ((__force omap_mbox_irq_t) 2)
17 typedef int __bitwise omap_mbox_type_t;
18 #define OMAP_MBOX_TYPE1 ((__force omap_mbox_type_t) 1)
19 #define OMAP_MBOX_TYPE2 ((__force omap_mbox_type_t) 2)
21 struct omap_mbox_ops {
22 omap_mbox_type_t type;
23 int (*startup)(struct omap_mbox *mbox);
24 void (*shutdown)(struct omap_mbox *mbox);
26 mbox_msg_t (*fifo_read)(struct omap_mbox *mbox);
27 void (*fifo_write)(struct omap_mbox *mbox, mbox_msg_t msg);
28 int (*fifo_empty)(struct omap_mbox *mbox);
29 int (*fifo_full)(struct omap_mbox *mbox);
31 void (*enable_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
32 void (*disable_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
33 void (*ack_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
34 int (*is_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
36 void (*save_ctx)(struct omap_mbox *mbox);
37 void (*restore_ctx)(struct omap_mbox *mbox);
40 struct omap_mbox_queue {
42 struct request_queue *queue;
43 struct work_struct work;
44 int (*callback)(void *);
45 struct omap_mbox *mbox;
52 struct omap_mbox_queue *txq, *rxq;
54 struct omap_mbox_ops *ops;
56 mbox_msg_t seq_snd, seq_rcv;
60 struct omap_mbox *next;
63 void (*err_notify)(void);
66 int omap_mbox_msg_send(struct omap_mbox *, mbox_msg_t msg, void *);
67 void omap_mbox_init_seq(struct omap_mbox *);
69 struct omap_mbox *omap_mbox_get(const char *);
70 void omap_mbox_put(struct omap_mbox *);
72 int omap_mbox_register(struct device *parent, struct omap_mbox *);
73 int omap_mbox_unregister(struct omap_mbox *);
75 static inline void omap_mbox_save_ctx(struct omap_mbox *mbox)
77 if (!mbox->ops->save_ctx) {
78 dev_err(mbox->dev, "%s:\tno save\n", __func__);
82 mbox->ops->save_ctx(mbox);
85 static inline void omap_mbox_restore_ctx(struct omap_mbox *mbox)
87 if (!mbox->ops->restore_ctx) {
88 dev_err(mbox->dev, "%s:\tno restore\n", __func__);
92 mbox->ops->restore_ctx(mbox);
95 #endif /* MAILBOX_H */