13 #include <linux/module.h>
24 #define MAILBOX_REVISION 0x000
25 #define MAILBOX_MESSAGE(m) (0x040 + 4 * (m))
26 #define MAILBOX_FIFOSTATUS(m) (0x080 + 4 * (m))
27 #define MAILBOX_MSGSTATUS(m) (0x0c0 + 4 * (m))
28 #define MAILBOX_IRQSTATUS(u) (0x100 + 8 * (u))
29 #define MAILBOX_IRQENABLE(u) (0x104 + 8 * (u))
31 #define OMAP4_MAILBOX_IRQSTATUS(u) (0x104 + 0x10 * (u))
32 #define OMAP4_MAILBOX_IRQENABLE(u) (0x108 + 0x10 * (u))
33 #define OMAP4_MAILBOX_IRQENABLE_CLR(u) (0x10c + 0x10 * (u))
35 #define MAILBOX_IRQ_NEWMSG(m) (1 << (2 * (m)))
36 #define MAILBOX_IRQ_NOTFULL(m) (1 << (2 * (m) + 1))
38 #define MBOX_REG_SIZE 0x120
40 #define OMAP4_MBOX_REG_SIZE 0x130
42 #define MBOX_NR_REGS (MBOX_REG_SIZE / sizeof(u32))
43 #define OMAP4_MBOX_NR_REGS (OMAP4_MBOX_REG_SIZE / sizeof(u32))
67 static inline unsigned int mbox_read_reg(
size_t ofs)
72 static inline void mbox_write_reg(
u32 val,
size_t ofs)
83 pm_runtime_get_sync(mbox->
dev->parent);
86 pr_debug(
"omap mailbox rev %d.%d\n", (l & 0xf0) >> 4, (l & 0x0f));
91 static void omap2_mbox_shutdown(
struct omap_mbox *mbox)
93 pm_runtime_put_sync(mbox->
dev->parent);
94 pm_runtime_disable(mbox->
dev->parent);
109 mbox_write_reg(msg, fifo->
msg);
112 static int omap2_mbox_fifo_empty(
struct omap_mbox *mbox)
116 return (mbox_read_reg(fifo->
msg_stat) == 0);
119 static int omap2_mbox_fifo_full(
struct omap_mbox *mbox)
127 static void omap2_mbox_enable_irq(
struct omap_mbox *mbox,
138 static void omap2_mbox_disable_irq(
struct omap_mbox *mbox,
150 static void omap2_mbox_ack_irq(
struct omap_mbox *mbox,
162 static int omap2_mbox_is_irq(
struct omap_mbox *mbox,
173 static void omap2_mbox_save_ctx(
struct omap_mbox *mbox)
182 for (i = 0; i < nr_regs; i++) {
183 p->
ctx[
i] = mbox_read_reg(i *
sizeof(
u32));
185 dev_dbg(mbox->
dev,
"%s: [%02x] %08x\n", __func__,
190 static void omap2_mbox_restore_ctx(
struct omap_mbox *mbox)
199 for (i = 0; i < nr_regs; i++) {
200 mbox_write_reg(p->
ctx[i], i *
sizeof(
u32));
202 dev_dbg(mbox->
dev,
"%s: [%02x] %08x\n", __func__,
209 .startup = omap2_mbox_startup,
210 .shutdown = omap2_mbox_shutdown,
211 .fifo_read = omap2_mbox_fifo_read,
212 .fifo_write = omap2_mbox_fifo_write,
213 .fifo_empty = omap2_mbox_fifo_empty,
214 .fifo_full = omap2_mbox_fifo_full,
215 .enable_irq = omap2_mbox_enable_irq,
216 .disable_irq = omap2_mbox_disable_irq,
217 .ack_irq = omap2_mbox_ack_irq,
218 .is_irq = omap2_mbox_is_irq,
219 .save_ctx = omap2_mbox_save_ctx,
220 .restore_ctx = omap2_mbox_restore_ctx,
232 #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP2)
252 .ops = &omap2_mbox_ops,
253 .priv = &omap2_mbox_dsp_priv,
257 #if defined(CONFIG_ARCH_OMAP3)
261 #if defined(CONFIG_SOC_OMAP2420)
279 static struct omap_mbox mbox_iva_info = {
281 .ops = &omap2_mbox_ops,
282 .priv = &omap2_mbox_iva_priv,
286 #ifdef CONFIG_ARCH_OMAP2
289 #ifdef CONFIG_SOC_OMAP2420
296 #if defined(CONFIG_ARCH_OMAP4)
316 .ops = &omap2_mbox_ops,
317 .priv = &omap2_mbox_1_priv,
338 .ops = &omap2_mbox_ops,
339 .priv = &omap2_mbox_2_priv,
342 struct omap_mbox *omap4_mboxes[] = { &mbox_1_info, &mbox_2_info,
NULL };
353 #if defined(CONFIG_ARCH_OMAP3)
360 #if defined(CONFIG_ARCH_OMAP2)
372 #if defined(CONFIG_ARCH_OMAP4)
380 pr_err(
"%s: platform not supported\n", __func__);
406 .probe = omap2_mbox_probe,
409 .name =
"omap-mailbox",
413 static int __init omap2_mbox_init(
void)
418 static void __exit omap2_mbox_exit(
void)