aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/mailbox.c
diff options
context:
space:
mode:
authorHiroshi DOYU <Hiroshi.DOYU@nokia.com>2009-03-23 21:07:23 -0400
committerTony Lindgren <tony@atomide.com>2009-03-23 21:07:23 -0400
commit6c20a68372f158def0a29657ce11b3609ed24f9a (patch)
tree22be97db69357d2b5770a5e878220c8d529e9b16 /arch/arm/mach-omap2/mailbox.c
parent733ecc5c06bb2892f04ab1881721d665644cd261 (diff)
omap mailbox: add initial omap3 support
Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
Diffstat (limited to 'arch/arm/mach-omap2/mailbox.c')
-rw-r--r--arch/arm/mach-omap2/mailbox.c70
1 files changed, 42 insertions, 28 deletions
diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
index 4487a4de52f3..d925ef3d7d48 100644
--- a/arch/arm/mach-omap2/mailbox.c
+++ b/arch/arm/mach-omap2/mailbox.c
@@ -30,7 +30,7 @@
30#define MAILBOX_IRQ_NEWMSG(u) (1 << (2 * (u))) 30#define MAILBOX_IRQ_NEWMSG(u) (1 << (2 * (u)))
31#define MAILBOX_IRQ_NOTFULL(u) (1 << (2 * (u) + 1)) 31#define MAILBOX_IRQ_NOTFULL(u) (1 << (2 * (u) + 1))
32 32
33static unsigned long mbox_base; 33static void __iomem *mbox_base;
34 34
35struct omap_mbox2_fifo { 35struct omap_mbox2_fifo {
36 unsigned long msg; 36 unsigned long msg;
@@ -52,14 +52,14 @@ static struct clk *mbox_ick_handle;
52static void omap2_mbox_enable_irq(struct omap_mbox *mbox, 52static void omap2_mbox_enable_irq(struct omap_mbox *mbox,
53 omap_mbox_type_t irq); 53 omap_mbox_type_t irq);
54 54
55static inline unsigned int mbox_read_reg(unsigned int reg) 55static inline unsigned int mbox_read_reg(size_t ofs)
56{ 56{
57 return __raw_readl(mbox_base + reg); 57 return __raw_readl(mbox_base + ofs);
58} 58}
59 59
60static inline void mbox_write_reg(unsigned int val, unsigned int reg) 60static inline void mbox_write_reg(u32 val, size_t ofs)
61{ 61{
62 __raw_writel(val, mbox_base + reg); 62 __raw_writel(val, mbox_base + ofs);
63} 63}
64 64
65/* Mailbox H/W preparations */ 65/* Mailbox H/W preparations */
@@ -208,7 +208,7 @@ struct omap_mbox mbox_dsp_info = {
208}; 208};
209EXPORT_SYMBOL(mbox_dsp_info); 209EXPORT_SYMBOL(mbox_dsp_info);
210 210
211/* IVA */ 211#if defined(CONFIG_ARCH_OMAP2420) /* IVA */
212static struct omap_mbox2_priv omap2_mbox_iva_priv = { 212static struct omap_mbox2_priv omap2_mbox_iva_priv = {
213 .tx_fifo = { 213 .tx_fifo = {
214 .msg = MAILBOX_MESSAGE(2), 214 .msg = MAILBOX_MESSAGE(2),
@@ -229,17 +229,12 @@ static struct omap_mbox mbox_iva_info = {
229 .ops = &omap2_mbox_ops, 229 .ops = &omap2_mbox_ops,
230 .priv = &omap2_mbox_iva_priv, 230 .priv = &omap2_mbox_iva_priv,
231}; 231};
232#endif
232 233
233static int __init omap2_mbox_probe(struct platform_device *pdev) 234static int __init omap2_mbox_probe(struct platform_device *pdev)
234{ 235{
235 struct resource *res; 236 struct resource *res;
236 int ret = 0; 237 int ret;
237
238 if (pdev->num_resources != 3) {
239 dev_err(&pdev->dev, "invalid number of resources: %d\n",
240 pdev->num_resources);
241 return -ENODEV;
242 }
243 238
244 /* MBOX base */ 239 /* MBOX base */
245 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 240 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -247,34 +242,53 @@ static int __init omap2_mbox_probe(struct platform_device *pdev)
247 dev_err(&pdev->dev, "invalid mem resource\n"); 242 dev_err(&pdev->dev, "invalid mem resource\n");
248 return -ENODEV; 243 return -ENODEV;
249 } 244 }
250 mbox_base = res->start; 245 mbox_base = ioremap(res->start, res->end - res->start);
246 if (!mbox_base)
247 return -ENOMEM;
251 248
252 /* DSP IRQ */ 249 /* DSP or IVA2 IRQ */
253 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 250 mbox_dsp_info.irq = platform_get_irq(pdev, 0);
254 if (unlikely(!res)) { 251 if (mbox_dsp_info.irq < 0) {
255 dev_err(&pdev->dev, "invalid irq resource\n"); 252 dev_err(&pdev->dev, "invalid irq resource\n");
256 return -ENODEV; 253 ret = -ENODEV;
254 goto err_dsp;
257 } 255 }
258 mbox_dsp_info.irq = res->start;
259 256
260 ret = omap_mbox_register(&mbox_dsp_info); 257 ret = omap_mbox_register(&mbox_dsp_info);
261 258 if (ret)
262 /* IVA IRQ */ 259 goto err_dsp;
263 res = platform_get_resource(pdev, IORESOURCE_IRQ, 1); 260
264 if (unlikely(!res)) { 261#if defined(CONFIG_ARCH_OMAP2420) /* IVA */
265 dev_err(&pdev->dev, "invalid irq resource\n"); 262 if (cpu_is_omap2420()) {
266 return -ENODEV; 263 /* IVA IRQ */
264 res = platform_get_resource(pdev, IORESOURCE_IRQ, 1);
265 if (unlikely(!res)) {
266 dev_err(&pdev->dev, "invalid irq resource\n");
267 ret = -ENODEV;
268 goto err_iva1;
269 }
270 mbox_iva_info.irq = res->start;
271 ret = omap_mbox_register(&mbox_iva_info);
272 if (ret)
273 goto err_iva1;
267 } 274 }
268 mbox_iva_info.irq = res->start; 275#endif
269 276 return 0;
270 ret = omap_mbox_register(&mbox_iva_info);
271 277
278err_iva1:
279 omap_mbox_unregister(&mbox_dsp_info);
280err_dsp:
281 iounmap(mbox_base);
272 return ret; 282 return ret;
273} 283}
274 284
275static int omap2_mbox_remove(struct platform_device *pdev) 285static int omap2_mbox_remove(struct platform_device *pdev)
276{ 286{
287#if defined(CONFIG_ARCH_OMAP2420)
288 omap_mbox_unregister(&mbox_iva_info);
289#endif
277 omap_mbox_unregister(&mbox_dsp_info); 290 omap_mbox_unregister(&mbox_dsp_info);
291 iounmap(mbox_base);
278 return 0; 292 return 0;
279} 293}
280 294