diff options
author | Felipe Contreras <felipe.contreras@gmail.com> | 2010-06-11 11:51:45 -0400 |
---|---|---|
committer | Hiroshi DOYU <Hiroshi.DOYU@nokia.com> | 2010-08-04 08:50:19 -0400 |
commit | 898ee75623d5a151157e3f0dca12b0148051e2d6 (patch) | |
tree | 4c71a2b21491b4a97a18d7a6dfd1f85f1bf8281a /arch/arm/mach-omap2 | |
parent | 1f2c4dfd30edfe9125a00d76596ebb3adabd8a5a (diff) |
omap: mailbox: reorganize registering
It's more extensible this way.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
Diffstat (limited to 'arch/arm/mach-omap2')
-rw-r--r-- | arch/arm/mach-omap2/mailbox.c | 107 |
1 files changed, 44 insertions, 63 deletions
diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c index 3ff1ad592bca..e5abc8e42f52 100644 --- a/arch/arm/mach-omap2/mailbox.c +++ b/arch/arm/mach-omap2/mailbox.c | |||
@@ -56,6 +56,8 @@ | |||
56 | 56 | ||
57 | static void __iomem *mbox_base; | 57 | static void __iomem *mbox_base; |
58 | 58 | ||
59 | static struct omap_mbox **list; | ||
60 | |||
59 | struct omap_mbox2_fifo { | 61 | struct omap_mbox2_fifo { |
60 | unsigned long msg; | 62 | unsigned long msg; |
61 | unsigned long fifo_stat; | 63 | unsigned long fifo_stat; |
@@ -307,6 +309,8 @@ struct omap_mbox mbox_dsp_info = { | |||
307 | .priv = &omap2_mbox_dsp_priv, | 309 | .priv = &omap2_mbox_dsp_priv, |
308 | }; | 310 | }; |
309 | 311 | ||
312 | struct omap_mbox *omap3_mboxes[] = { &mbox_dsp_info, NULL }; | ||
313 | |||
310 | #if defined(CONFIG_ARCH_OMAP2420) | 314 | #if defined(CONFIG_ARCH_OMAP2420) |
311 | 315 | ||
312 | /* IVA */ | 316 | /* IVA */ |
@@ -331,6 +335,8 @@ static struct omap_mbox mbox_iva_info = { | |||
331 | .ops = &omap2_mbox_ops, | 335 | .ops = &omap2_mbox_ops, |
332 | .priv = &omap2_mbox_iva_priv, | 336 | .priv = &omap2_mbox_iva_priv, |
333 | }; | 337 | }; |
338 | |||
339 | struct omap_mbox *omap2_mboxes[] = { &mbox_iva_info, &mbox_dsp_info, NULL }; | ||
334 | #endif | 340 | #endif |
335 | 341 | ||
336 | /* OMAP4 */ | 342 | /* OMAP4 */ |
@@ -378,89 +384,64 @@ struct omap_mbox mbox_2_info = { | |||
378 | .priv = &omap2_mbox_2_priv, | 384 | .priv = &omap2_mbox_2_priv, |
379 | }; | 385 | }; |
380 | 386 | ||
387 | struct omap_mbox *omap4_mboxes[] = { &mbox_1_info, &mbox_2_info, NULL }; | ||
388 | |||
381 | static int __devinit omap2_mbox_probe(struct platform_device *pdev) | 389 | static int __devinit omap2_mbox_probe(struct platform_device *pdev) |
382 | { | 390 | { |
383 | struct resource *res; | 391 | struct resource *mem; |
384 | int ret; | 392 | int ret; |
393 | int i; | ||
385 | 394 | ||
386 | /* MBOX base */ | 395 | if (cpu_is_omap3430()) { |
387 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 396 | list = omap3_mboxes; |
388 | if (unlikely(!res)) { | 397 | |
389 | dev_err(&pdev->dev, "invalid mem resource\n"); | 398 | list[0]->irq = platform_get_irq_byname(pdev, "dsp"); |
390 | return -ENODEV; | ||
391 | } | 399 | } |
392 | mbox_base = ioremap(res->start, resource_size(res)); | 400 | #if defined(CONFIG_ARCH_OMAP2420) |
393 | if (!mbox_base) | 401 | else if (cpu_is_omap2420()) { |
394 | return -ENOMEM; | 402 | list = omap2_mboxes; |
395 | 403 | ||
396 | /* DSP or IVA2 IRQ */ | 404 | list[0]->irq = platform_get_irq_byname(pdev, "dsp"); |
397 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | 405 | list[1]->irq = platform_get_irq_byname(pdev, "iva"); |
406 | } | ||
407 | #endif | ||
408 | else if (cpu_is_omap44xx()) { | ||
409 | list = omap4_mboxes; | ||
398 | 410 | ||
399 | if (unlikely(!res)) { | 411 | list[0]->irq = list[1]->irq = |
400 | dev_err(&pdev->dev, "invalid irq resource\n"); | 412 | platform_get_irq_byname(pdev, "mbox"); |
401 | ret = -ENODEV; | ||
402 | goto err_dsp; | ||
403 | } | 413 | } |
404 | if (cpu_is_omap44xx()) { | 414 | else { |
405 | mbox_1_info.irq = res->start; | 415 | pr_err("%s: platform not supported\n", __func__); |
406 | ret = omap_mbox_register(&pdev->dev, &mbox_1_info); | 416 | return -ENODEV; |
407 | } else { | ||
408 | mbox_dsp_info.irq = res->start; | ||
409 | ret = omap_mbox_register(&pdev->dev, &mbox_dsp_info); | ||
410 | } | 417 | } |
411 | if (ret) | ||
412 | goto err_dsp; | ||
413 | 418 | ||
414 | if (cpu_is_omap44xx()) { | 419 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
415 | mbox_2_info.irq = res->start; | 420 | mbox_base = ioremap(mem->start, resource_size(mem)); |
416 | ret = omap_mbox_register(&pdev->dev, &mbox_2_info); | 421 | if (!mbox_base) |
417 | if (ret) { | 422 | return -ENOMEM; |
418 | omap_mbox_unregister(&mbox_1_info); | 423 | |
419 | goto err_dsp; | 424 | for (i = 0; list[i]; i++) { |
420 | } | 425 | ret = omap_mbox_register(&pdev->dev, list[i]); |
421 | } | 426 | if (ret) |
422 | #if defined(CONFIG_ARCH_OMAP2420) /* IVA */ | 427 | goto err_out; |
423 | if (cpu_is_omap2420()) { | ||
424 | /* IVA IRQ */ | ||
425 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 1); | ||
426 | if (unlikely(!res)) { | ||
427 | dev_err(&pdev->dev, "invalid irq resource\n"); | ||
428 | ret = -ENODEV; | ||
429 | omap_mbox_unregister(&mbox_dsp_info); | ||
430 | goto err_dsp; | ||
431 | } | ||
432 | mbox_iva_info.irq = res->start; | ||
433 | ret = omap_mbox_register(&pdev->dev, &mbox_iva_info); | ||
434 | if (ret) { | ||
435 | omap_mbox_unregister(&mbox_dsp_info); | ||
436 | goto err_dsp; | ||
437 | } | ||
438 | } | 428 | } |
439 | #endif | ||
440 | return 0; | 429 | return 0; |
441 | 430 | ||
442 | #if defined(CONFIG_ARCH_OMAP2420) /* IVA */ | 431 | err_out: |
443 | err_iva1: | 432 | while (i--) |
444 | omap_mbox_unregister(&mbox_dsp_info); | 433 | omap_mbox_unregister(list[i]); |
445 | #endif | ||
446 | |||
447 | err_dsp: | ||
448 | iounmap(mbox_base); | 434 | iounmap(mbox_base); |
449 | return ret; | 435 | return ret; |
450 | } | 436 | } |
451 | 437 | ||
452 | static int __devexit omap2_mbox_remove(struct platform_device *pdev) | 438 | static int __devexit omap2_mbox_remove(struct platform_device *pdev) |
453 | { | 439 | { |
454 | #if defined(CONFIG_ARCH_OMAP2420) | 440 | int i; |
455 | if (cpu_is_omap2420()) | 441 | |
456 | omap_mbox_unregister(&mbox_iva_info); | 442 | for (i = 0; list[i]; i++) |
457 | #endif | 443 | omap_mbox_unregister(list[i]); |
458 | 444 | ||
459 | if (cpu_is_omap44xx()) { | ||
460 | omap_mbox_unregister(&mbox_2_info); | ||
461 | omap_mbox_unregister(&mbox_1_info); | ||
462 | } else | ||
463 | omap_mbox_unregister(&mbox_dsp_info); | ||
464 | iounmap(mbox_base); | 445 | iounmap(mbox_base); |
465 | return 0; | 446 | return 0; |
466 | } | 447 | } |