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 | |
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')
-rw-r--r-- | arch/arm/mach-omap1/mailbox.c | 42 | ||||
-rw-r--r-- | arch/arm/mach-omap2/mailbox.c | 107 |
2 files changed, 66 insertions, 83 deletions
diff --git a/arch/arm/mach-omap1/mailbox.c b/arch/arm/mach-omap1/mailbox.c index 590ac6688866..0318754e8504 100644 --- a/arch/arm/mach-omap1/mailbox.c +++ b/arch/arm/mach-omap1/mailbox.c | |||
@@ -29,6 +29,8 @@ | |||
29 | 29 | ||
30 | static void __iomem *mbox_base; | 30 | static void __iomem *mbox_base; |
31 | 31 | ||
32 | static struct omap_mbox **list; | ||
33 | |||
32 | struct omap_mbox1_fifo { | 34 | struct omap_mbox1_fifo { |
33 | unsigned long cmd; | 35 | unsigned long cmd; |
34 | unsigned long data; | 36 | unsigned long data; |
@@ -142,44 +144,44 @@ struct omap_mbox mbox_dsp_info = { | |||
142 | .priv = &omap1_mbox_dsp_priv, | 144 | .priv = &omap1_mbox_dsp_priv, |
143 | }; | 145 | }; |
144 | 146 | ||
147 | struct omap_mbox *omap1_mboxes[] = { &mbox_dsp_info, NULL }; | ||
148 | |||
145 | static int __devinit omap1_mbox_probe(struct platform_device *pdev) | 149 | static int __devinit omap1_mbox_probe(struct platform_device *pdev) |
146 | { | 150 | { |
147 | struct resource *res; | 151 | struct resource *mem; |
148 | int ret; | 152 | int ret; |
153 | int i; | ||
149 | 154 | ||
150 | /* MBOX base */ | 155 | list = omap1_mboxes; |
151 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 156 | |
152 | if (unlikely(!res)) { | 157 | list[0]->irq = platform_get_irq_byname(pdev, "dsp"); |
153 | dev_err(&pdev->dev, "invalid mem resource\n"); | ||
154 | return -ENODEV; | ||
155 | } | ||
156 | 158 | ||
157 | mbox_base = ioremap(res->start, resource_size(res)); | 159 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
160 | mbox_base = ioremap(mem->start, resource_size(mem)); | ||
158 | if (!mbox_base) | 161 | if (!mbox_base) |
159 | return -ENOMEM; | 162 | return -ENOMEM; |
160 | 163 | ||
161 | /* DSP IRQ */ | 164 | for (i = 0; list[i]; i++) { |
162 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | 165 | ret = omap_mbox_register(&pdev->dev, list[i]); |
163 | if (unlikely(!res)) { | 166 | if (ret) |
164 | dev_err(&pdev->dev, "invalid irq resource\n"); | 167 | goto err_out; |
165 | ret = -ENODEV; | ||
166 | goto err_out; | ||
167 | } | 168 | } |
168 | mbox_dsp_info.irq = res->start; | ||
169 | |||
170 | ret = omap_mbox_register(&pdev->dev, &mbox_dsp_info); | ||
171 | if (ret) | ||
172 | goto err_out; | ||
173 | return 0; | 169 | return 0; |
174 | 170 | ||
175 | err_out: | 171 | err_out: |
172 | while (i--) | ||
173 | omap_mbox_unregister(list[i]); | ||
176 | iounmap(mbox_base); | 174 | iounmap(mbox_base); |
177 | return ret; | 175 | return ret; |
178 | } | 176 | } |
179 | 177 | ||
180 | static int __devexit omap1_mbox_remove(struct platform_device *pdev) | 178 | static int __devexit omap1_mbox_remove(struct platform_device *pdev) |
181 | { | 179 | { |
182 | omap_mbox_unregister(&mbox_dsp_info); | 180 | int i; |
181 | |||
182 | for (i = 0; list[i]; i++) | ||
183 | omap_mbox_unregister(list[i]); | ||
184 | |||
183 | iounmap(mbox_base); | 185 | iounmap(mbox_base); |
184 | return 0; | 186 | return 0; |
185 | } | 187 | } |
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 | } |