]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
omap mailbox: add initial omap3 support
authorHiroshi DOYU <Hiroshi.DOYU@nokia.com>
Tue, 24 Mar 2009 01:07:23 +0000 (18:07 -0700)
committerTony Lindgren <tony@atomide.com>
Tue, 24 Mar 2009 01:07:23 +0000 (18:07 -0700)
Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
arch/arm/mach-omap2/devices.c
arch/arm/mach-omap2/mailbox.c
arch/arm/plat-omap/Kconfig
arch/arm/plat-omap/include/mach/omap34xx.h

index ce03fa750775d25d4d715175218354e90a8d2567..d5f2a8118df3f7db3d9072b830d32b765e7dd36f 100644 (file)
 #include <mach/eac.h>
 #include <mach/mmc.h>
 
-#if defined(CONFIG_OMAP_DSP) || defined(CONFIG_OMAP_DSP_MODULE)
-#define OMAP2_MBOX_BASE                IO_ADDRESS(OMAP24XX_MAILBOX_BASE)
+#if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
 
-static struct resource mbox_resources[] = {
+#define MBOX_REG_SIZE  0x120
+
+static struct resource omap2_mbox_resources[] = {
        {
-               .start          = OMAP2_MBOX_BASE,
-               .end            = OMAP2_MBOX_BASE + 0x11f,
+               .start          = OMAP24XX_MAILBOX_BASE,
+               .end            = OMAP24XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
                .flags          = IORESOURCE_MEM,
        },
        {
@@ -47,20 +48,40 @@ static struct resource mbox_resources[] = {
        },
 };
 
+static struct resource omap3_mbox_resources[] = {
+       {
+               .start          = OMAP34XX_MAILBOX_BASE,
+               .end            = OMAP34XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
+               .flags          = IORESOURCE_MEM,
+       },
+       {
+               .start          = INT_24XX_MAIL_U0_MPU,
+               .flags          = IORESOURCE_IRQ,
+       },
+};
+
 static struct platform_device mbox_device = {
        .name           = "mailbox",
        .id             = -1,
-       .num_resources  = ARRAY_SIZE(mbox_resources),
-       .resource       = mbox_resources,
 };
 
 static inline void omap_init_mbox(void)
 {
+       if (cpu_is_omap2420()) {
+               mbox_device.num_resources = ARRAY_SIZE(omap2_mbox_resources);
+               mbox_device.resource = omap2_mbox_resources;
+       } else if (cpu_is_omap3430()) {
+               mbox_device.num_resources = ARRAY_SIZE(omap3_mbox_resources);
+               mbox_device.resource = omap3_mbox_resources;
+       } else {
+               pr_err("%s: platform not supported\n", __func__);
+               return;
+       }
        platform_device_register(&mbox_device);
 }
 #else
 static inline void omap_init_mbox(void) { }
-#endif
+#endif /* CONFIG_OMAP_MBOX_FWK */
 
 #if defined(CONFIG_OMAP_STI)
 
index 4487a4de52f3adb68813374a1406388357ce9f98..d925ef3d7d4841ba648bb0e74cff7dedda962dc7 100644 (file)
@@ -30,7 +30,7 @@
 #define MAILBOX_IRQ_NEWMSG(u)          (1 << (2 * (u)))
 #define MAILBOX_IRQ_NOTFULL(u)         (1 << (2 * (u) + 1))
 
-static unsigned long mbox_base;
+static void __iomem *mbox_base;
 
 struct omap_mbox2_fifo {
        unsigned long msg;
@@ -52,14 +52,14 @@ static struct clk *mbox_ick_handle;
 static void omap2_mbox_enable_irq(struct omap_mbox *mbox,
                                  omap_mbox_type_t irq);
 
-static inline unsigned int mbox_read_reg(unsigned int reg)
+static inline unsigned int mbox_read_reg(size_t ofs)
 {
-       return __raw_readl(mbox_base + reg);
+       return __raw_readl(mbox_base + ofs);
 }
 
-static inline void mbox_write_reg(unsigned int val, unsigned int reg)
+static inline void mbox_write_reg(u32 val, size_t ofs)
 {
-       __raw_writel(val, mbox_base + reg);
+       __raw_writel(val, mbox_base + ofs);
 }
 
 /* Mailbox H/W preparations */
@@ -208,7 +208,7 @@ struct omap_mbox mbox_dsp_info = {
 };
 EXPORT_SYMBOL(mbox_dsp_info);
 
-/* IVA */
+#if defined(CONFIG_ARCH_OMAP2420) /* IVA */
 static struct omap_mbox2_priv omap2_mbox_iva_priv = {
        .tx_fifo = {
                .msg            = MAILBOX_MESSAGE(2),
@@ -229,17 +229,12 @@ static struct omap_mbox mbox_iva_info = {
        .ops    = &omap2_mbox_ops,
        .priv   = &omap2_mbox_iva_priv,
 };
+#endif
 
 static int __init omap2_mbox_probe(struct platform_device *pdev)
 {
        struct resource *res;
-       int ret = 0;
-
-       if (pdev->num_resources != 3) {
-               dev_err(&pdev->dev, "invalid number of resources: %d\n",
-                       pdev->num_resources);
-               return -ENODEV;
-       }
+       int ret;
 
        /* MBOX base */
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -247,34 +242,53 @@ static int __init omap2_mbox_probe(struct platform_device *pdev)
                dev_err(&pdev->dev, "invalid mem resource\n");
                return -ENODEV;
        }
-       mbox_base = res->start;
+       mbox_base = ioremap(res->start, res->end - res->start);
+       if (!mbox_base)
+               return -ENOMEM;
 
-       /* DSP IRQ */
-       res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-       if (unlikely(!res)) {
+       /* DSP or IVA2 IRQ */
+       mbox_dsp_info.irq = platform_get_irq(pdev, 0);
+       if (mbox_dsp_info.irq < 0) {
                dev_err(&pdev->dev, "invalid irq resource\n");
-               return -ENODEV;
+               ret = -ENODEV;
+               goto err_dsp;
        }
-       mbox_dsp_info.irq = res->start;
 
        ret = omap_mbox_register(&mbox_dsp_info);
-
-       /* IVA IRQ */
-       res = platform_get_resource(pdev, IORESOURCE_IRQ, 1);
-       if (unlikely(!res)) {
-               dev_err(&pdev->dev, "invalid irq resource\n");
-               return -ENODEV;
+       if (ret)
+               goto err_dsp;
+
+#if defined(CONFIG_ARCH_OMAP2420) /* IVA */
+       if (cpu_is_omap2420()) {
+               /* IVA IRQ */
+               res = platform_get_resource(pdev, IORESOURCE_IRQ, 1);
+               if (unlikely(!res)) {
+                       dev_err(&pdev->dev, "invalid irq resource\n");
+                       ret = -ENODEV;
+                       goto err_iva1;
+               }
+               mbox_iva_info.irq = res->start;
+               ret = omap_mbox_register(&mbox_iva_info);
+               if (ret)
+                       goto err_iva1;
        }
-       mbox_iva_info.irq = res->start;
-
-       ret = omap_mbox_register(&mbox_iva_info);
+#endif
+       return 0;
 
+err_iva1:
+       omap_mbox_unregister(&mbox_dsp_info);
+err_dsp:
+       iounmap(mbox_base);
        return ret;
 }
 
 static int omap2_mbox_remove(struct platform_device *pdev)
 {
+#if defined(CONFIG_ARCH_OMAP2420)
+       omap_mbox_unregister(&mbox_iva_info);
+#endif
        omap_mbox_unregister(&mbox_dsp_info);
+       iounmap(mbox_base);
        return 0;
 }
 
index 46d3b0b9ce696eaef46d895a37b7a694059dd554..6b1d50610328ae23dd69d5239533c2dc88219b49 100644 (file)
@@ -104,6 +104,14 @@ config OMAP_MCBSP
          Say Y here if you want support for the OMAP Multichannel
          Buffered Serial Port.
 
+config OMAP_MBOX_FWK
+       tristate "Mailbox framework support"
+       depends on ARCH_OMAP
+       default n
+       help
+         Say Y here if you want to use OMAP Mailbox framework support for
+         DSP, IVA1.0 and IVA2 in OMAP1/2/3.
+
 choice
         prompt "System timer"
        default OMAP_MPU_TIMER
index 8e0479fff05a286090a092ccd80601a2fa5ede8a..89173f16b9b7cd95bd1d3a7c57605f051777179c 100644 (file)
@@ -61,6 +61,7 @@
 #define OMAP2_CM_BASE                  OMAP3430_CM_BASE
 #define OMAP2_PRM_BASE                 OMAP3430_PRM_BASE
 #define OMAP2_VA_IC_BASE               IO_ADDRESS(OMAP34XX_IC_BASE)
+#define OMAP34XX_MAILBOX_BASE          (L4_34XX_BASE + 0x94000)
 
 #endif