• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/arch/arm/plat-omap/include/plat/
1/* mailbox.h */
2
3#ifndef MAILBOX_H
4#define MAILBOX_H
5
6#include <linux/spinlock.h>
7#include <linux/workqueue.h>
8#include <linux/interrupt.h>
9#include <linux/device.h>
10#include <linux/kfifo.h>
11
12typedef u32 mbox_msg_t;
13struct omap_mbox;
14
15typedef int __bitwise omap_mbox_irq_t;
16#define IRQ_TX ((__force omap_mbox_irq_t) 1)
17#define IRQ_RX ((__force omap_mbox_irq_t) 2)
18
19typedef int __bitwise omap_mbox_type_t;
20#define OMAP_MBOX_TYPE1 ((__force omap_mbox_type_t) 1)
21#define OMAP_MBOX_TYPE2 ((__force omap_mbox_type_t) 2)
22
23struct omap_mbox_ops {
24	omap_mbox_type_t	type;
25	int		(*startup)(struct omap_mbox *mbox);
26	void		(*shutdown)(struct omap_mbox *mbox);
27	/* fifo */
28	mbox_msg_t	(*fifo_read)(struct omap_mbox *mbox);
29	void		(*fifo_write)(struct omap_mbox *mbox, mbox_msg_t msg);
30	int		(*fifo_empty)(struct omap_mbox *mbox);
31	int		(*fifo_full)(struct omap_mbox *mbox);
32	/* irq */
33	void		(*enable_irq)(struct omap_mbox *mbox,
34						omap_mbox_irq_t irq);
35	void		(*disable_irq)(struct omap_mbox *mbox,
36						omap_mbox_irq_t irq);
37	void		(*ack_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
38	int		(*is_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
39	/* ctx */
40	void		(*save_ctx)(struct omap_mbox *mbox);
41	void		(*restore_ctx)(struct omap_mbox *mbox);
42};
43
44struct omap_mbox_queue {
45	spinlock_t		lock;
46	struct kfifo		fifo;
47	struct work_struct	work;
48	struct tasklet_struct	tasklet;
49	int	(*callback)(void *);
50	struct omap_mbox	*mbox;
51};
52
53struct omap_mbox {
54	char			*name;
55	unsigned int		irq;
56	struct omap_mbox_queue	*txq, *rxq;
57	struct omap_mbox_ops	*ops;
58	struct device		*dev;
59	void			*priv;
60};
61
62int omap_mbox_msg_send(struct omap_mbox *, mbox_msg_t msg);
63void omap_mbox_init_seq(struct omap_mbox *);
64
65struct omap_mbox *omap_mbox_get(const char *);
66void omap_mbox_put(struct omap_mbox *);
67
68int omap_mbox_register(struct device *parent, struct omap_mbox **);
69int omap_mbox_unregister(void);
70
71static inline void omap_mbox_save_ctx(struct omap_mbox *mbox)
72{
73	if (!mbox->ops->save_ctx) {
74		dev_err(mbox->dev, "%s:\tno save\n", __func__);
75		return;
76	}
77
78	mbox->ops->save_ctx(mbox);
79}
80
81static inline void omap_mbox_restore_ctx(struct omap_mbox *mbox)
82{
83	if (!mbox->ops->restore_ctx) {
84		dev_err(mbox->dev, "%s:\tno restore\n", __func__);
85		return;
86	}
87
88	mbox->ops->restore_ctx(mbox);
89}
90
91static inline void omap_mbox_enable_irq(struct omap_mbox *mbox,
92					omap_mbox_irq_t irq)
93{
94	mbox->ops->enable_irq(mbox, irq);
95}
96
97static inline void omap_mbox_disable_irq(struct omap_mbox *mbox,
98					 omap_mbox_irq_t irq)
99{
100	mbox->ops->disable_irq(mbox, irq);
101}
102
103#endif /* MAILBOX_H */
104