diff options
author | Suman Anna <s-anna@ti.com> | 2013-03-12 18:55:29 -0400 |
---|---|---|
committer | Suman Anna <s-anna@ti.com> | 2013-06-11 12:41:51 -0400 |
commit | c869c75c16b3d1ffcf64fb2fd63ba0c4a369071c (patch) | |
tree | 02be072bd60241b604e2295addf78e817c47e3ca /arch/arm/mach-omap1 | |
parent | fe32c1f6024e357f586b1d666237cab80a1215ce (diff) |
mailbox/omap: move the OMAP mailbox framework to drivers
The mailbox hardware (in OMAP) uses a queued mailbox interrupt
mechanism that provides a communication channel between processors
through a set of registers and their associated interrupt signals
by sending and receiving messages.
The OMAP mailbox framework/driver code is moved to be under
drivers/mailbox, in preparation for adapting to a common mailbox
driver framework. This allows the build for OMAP mailbox to be
enabled (it was disabled during the multi-platform support).
As part of the migration from plat and mach code:
- Kconfig symbols have been renamed to build OMAP1 or OMAP2+ drivers.
- mailbox.h under plat-omap/plat/include has been split into a public
and private header files. The public header has only the API related
functions and types.
- The module name mailbox.ko from plat-omap is changed to
omap-mailbox.ko
- The module name mailbox_mach.ko from mach-omapX is changed as
mailbox_omap1.ko for OMAP1
mailbox_omap2.ko for OMAP2+
Cc: Tony Lindgren <tony@atomide.com>
[gregkh@linuxfoundation.org: ack for staging part]
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Omar Ramirez Luna <omar.ramirez@copitl.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
Diffstat (limited to 'arch/arm/mach-omap1')
-rw-r--r-- | arch/arm/mach-omap1/Makefile | 4 | ||||
-rw-r--r-- | arch/arm/mach-omap1/mailbox.c | 202 |
2 files changed, 0 insertions, 206 deletions
diff --git a/arch/arm/mach-omap1/Makefile b/arch/arm/mach-omap1/Makefile index 222d58c0ae76..3889b6cd211e 100644 --- a/arch/arm/mach-omap1/Makefile +++ b/arch/arm/mach-omap1/Makefile | |||
@@ -19,10 +19,6 @@ obj-$(CONFIG_ARCH_OMAP16XX) += ocpi.o | |||
19 | # Power Management | 19 | # Power Management |
20 | obj-$(CONFIG_PM) += pm.o sleep.o | 20 | obj-$(CONFIG_PM) += pm.o sleep.o |
21 | 21 | ||
22 | # DSP | ||
23 | obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox_mach.o | ||
24 | mailbox_mach-objs := mailbox.o | ||
25 | |||
26 | i2c-omap-$(CONFIG_I2C_OMAP) := i2c.o | 22 | i2c-omap-$(CONFIG_I2C_OMAP) := i2c.o |
27 | obj-y += $(i2c-omap-m) $(i2c-omap-y) | 23 | obj-y += $(i2c-omap-m) $(i2c-omap-y) |
28 | 24 | ||
diff --git a/arch/arm/mach-omap1/mailbox.c b/arch/arm/mach-omap1/mailbox.c deleted file mode 100644 index 7246a5258292..000000000000 --- a/arch/arm/mach-omap1/mailbox.c +++ /dev/null | |||
@@ -1,202 +0,0 @@ | |||
1 | /* | ||
2 | * Mailbox reservation modules for OMAP1 | ||
3 | * | ||
4 | * Copyright (C) 2006-2009 Nokia Corporation | ||
5 | * Written by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com> | ||
6 | * | ||
7 | * This file is subject to the terms and conditions of the GNU General Public | ||
8 | * License. See the file "COPYING" in the main directory of this archive | ||
9 | * for more details. | ||
10 | */ | ||
11 | |||
12 | #include <linux/module.h> | ||
13 | #include <linux/interrupt.h> | ||
14 | #include <linux/platform_device.h> | ||
15 | #include <linux/io.h> | ||
16 | #include <plat/mailbox.h> | ||
17 | |||
18 | #define MAILBOX_ARM2DSP1 0x00 | ||
19 | #define MAILBOX_ARM2DSP1b 0x04 | ||
20 | #define MAILBOX_DSP2ARM1 0x08 | ||
21 | #define MAILBOX_DSP2ARM1b 0x0c | ||
22 | #define MAILBOX_DSP2ARM2 0x10 | ||
23 | #define MAILBOX_DSP2ARM2b 0x14 | ||
24 | #define MAILBOX_ARM2DSP1_Flag 0x18 | ||
25 | #define MAILBOX_DSP2ARM1_Flag 0x1c | ||
26 | #define MAILBOX_DSP2ARM2_Flag 0x20 | ||
27 | |||
28 | static void __iomem *mbox_base; | ||
29 | |||
30 | struct omap_mbox1_fifo { | ||
31 | unsigned long cmd; | ||
32 | unsigned long data; | ||
33 | unsigned long flag; | ||
34 | }; | ||
35 | |||
36 | struct omap_mbox1_priv { | ||
37 | struct omap_mbox1_fifo tx_fifo; | ||
38 | struct omap_mbox1_fifo rx_fifo; | ||
39 | }; | ||
40 | |||
41 | static inline int mbox_read_reg(size_t ofs) | ||
42 | { | ||
43 | return __raw_readw(mbox_base + ofs); | ||
44 | } | ||
45 | |||
46 | static inline void mbox_write_reg(u32 val, size_t ofs) | ||
47 | { | ||
48 | __raw_writew(val, mbox_base + ofs); | ||
49 | } | ||
50 | |||
51 | /* msg */ | ||
52 | static mbox_msg_t omap1_mbox_fifo_read(struct omap_mbox *mbox) | ||
53 | { | ||
54 | struct omap_mbox1_fifo *fifo = | ||
55 | &((struct omap_mbox1_priv *)mbox->priv)->rx_fifo; | ||
56 | mbox_msg_t msg; | ||
57 | |||
58 | msg = mbox_read_reg(fifo->data); | ||
59 | msg |= ((mbox_msg_t) mbox_read_reg(fifo->cmd)) << 16; | ||
60 | |||
61 | return msg; | ||
62 | } | ||
63 | |||
64 | static void | ||
65 | omap1_mbox_fifo_write(struct omap_mbox *mbox, mbox_msg_t msg) | ||
66 | { | ||
67 | struct omap_mbox1_fifo *fifo = | ||
68 | &((struct omap_mbox1_priv *)mbox->priv)->tx_fifo; | ||
69 | |||
70 | mbox_write_reg(msg & 0xffff, fifo->data); | ||
71 | mbox_write_reg(msg >> 16, fifo->cmd); | ||
72 | } | ||
73 | |||
74 | static int omap1_mbox_fifo_empty(struct omap_mbox *mbox) | ||
75 | { | ||
76 | return 0; | ||
77 | } | ||
78 | |||
79 | static int omap1_mbox_fifo_full(struct omap_mbox *mbox) | ||
80 | { | ||
81 | struct omap_mbox1_fifo *fifo = | ||
82 | &((struct omap_mbox1_priv *)mbox->priv)->rx_fifo; | ||
83 | |||
84 | return mbox_read_reg(fifo->flag); | ||
85 | } | ||
86 | |||
87 | /* irq */ | ||
88 | static void | ||
89 | omap1_mbox_enable_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq) | ||
90 | { | ||
91 | if (irq == IRQ_RX) | ||
92 | enable_irq(mbox->irq); | ||
93 | } | ||
94 | |||
95 | static void | ||
96 | omap1_mbox_disable_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq) | ||
97 | { | ||
98 | if (irq == IRQ_RX) | ||
99 | disable_irq(mbox->irq); | ||
100 | } | ||
101 | |||
102 | static int | ||
103 | omap1_mbox_is_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq) | ||
104 | { | ||
105 | if (irq == IRQ_TX) | ||
106 | return 0; | ||
107 | return 1; | ||
108 | } | ||
109 | |||
110 | static struct omap_mbox_ops omap1_mbox_ops = { | ||
111 | .type = OMAP_MBOX_TYPE1, | ||
112 | .fifo_read = omap1_mbox_fifo_read, | ||
113 | .fifo_write = omap1_mbox_fifo_write, | ||
114 | .fifo_empty = omap1_mbox_fifo_empty, | ||
115 | .fifo_full = omap1_mbox_fifo_full, | ||
116 | .enable_irq = omap1_mbox_enable_irq, | ||
117 | .disable_irq = omap1_mbox_disable_irq, | ||
118 | .is_irq = omap1_mbox_is_irq, | ||
119 | }; | ||
120 | |||
121 | /* FIXME: the following struct should be created automatically by the user id */ | ||
122 | |||
123 | /* DSP */ | ||
124 | static struct omap_mbox1_priv omap1_mbox_dsp_priv = { | ||
125 | .tx_fifo = { | ||
126 | .cmd = MAILBOX_ARM2DSP1b, | ||
127 | .data = MAILBOX_ARM2DSP1, | ||
128 | .flag = MAILBOX_ARM2DSP1_Flag, | ||
129 | }, | ||
130 | .rx_fifo = { | ||
131 | .cmd = MAILBOX_DSP2ARM1b, | ||
132 | .data = MAILBOX_DSP2ARM1, | ||
133 | .flag = MAILBOX_DSP2ARM1_Flag, | ||
134 | }, | ||
135 | }; | ||
136 | |||
137 | static struct omap_mbox mbox_dsp_info = { | ||
138 | .name = "dsp", | ||
139 | .ops = &omap1_mbox_ops, | ||
140 | .priv = &omap1_mbox_dsp_priv, | ||
141 | }; | ||
142 | |||
143 | static struct omap_mbox *omap1_mboxes[] = { &mbox_dsp_info, NULL }; | ||
144 | |||
145 | static int omap1_mbox_probe(struct platform_device *pdev) | ||
146 | { | ||
147 | struct resource *mem; | ||
148 | int ret; | ||
149 | struct omap_mbox **list; | ||
150 | |||
151 | list = omap1_mboxes; | ||
152 | list[0]->irq = platform_get_irq_byname(pdev, "dsp"); | ||
153 | |||
154 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
155 | if (!mem) | ||
156 | return -ENOENT; | ||
157 | |||
158 | mbox_base = ioremap(mem->start, resource_size(mem)); | ||
159 | if (!mbox_base) | ||
160 | return -ENOMEM; | ||
161 | |||
162 | ret = omap_mbox_register(&pdev->dev, list); | ||
163 | if (ret) { | ||
164 | iounmap(mbox_base); | ||
165 | return ret; | ||
166 | } | ||
167 | |||
168 | return 0; | ||
169 | } | ||
170 | |||
171 | static int omap1_mbox_remove(struct platform_device *pdev) | ||
172 | { | ||
173 | omap_mbox_unregister(); | ||
174 | iounmap(mbox_base); | ||
175 | return 0; | ||
176 | } | ||
177 | |||
178 | static struct platform_driver omap1_mbox_driver = { | ||
179 | .probe = omap1_mbox_probe, | ||
180 | .remove = omap1_mbox_remove, | ||
181 | .driver = { | ||
182 | .name = "omap-mailbox", | ||
183 | }, | ||
184 | }; | ||
185 | |||
186 | static int __init omap1_mbox_init(void) | ||
187 | { | ||
188 | return platform_driver_register(&omap1_mbox_driver); | ||
189 | } | ||
190 | |||
191 | static void __exit omap1_mbox_exit(void) | ||
192 | { | ||
193 | platform_driver_unregister(&omap1_mbox_driver); | ||
194 | } | ||
195 | |||
196 | module_init(omap1_mbox_init); | ||
197 | module_exit(omap1_mbox_exit); | ||
198 | |||
199 | MODULE_LICENSE("GPL v2"); | ||
200 | MODULE_DESCRIPTION("omap mailbox: omap1 architecture specific functions"); | ||
201 | MODULE_AUTHOR("Hiroshi DOYU <Hiroshi.DOYU@nokia.com>"); | ||
202 | MODULE_ALIAS("platform:omap1-mailbox"); | ||