public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/10] omap mailbox driver update with omap3 support
@ 2008-11-25  9:39 Hiroshi DOYU
  2008-11-25  9:39 ` [PATCH 01/10] omap mailbox: cleanup omap2 register definition with macro Hiroshi DOYU
  0 siblings, 1 reply; 23+ messages in thread
From: Hiroshi DOYU @ 2008-11-25  9:39 UTC (permalink / raw)
  To: linux-omap

Hi,

The followin patches are mainly for updating the mailbox driver with
omap3 support.

If there's no problem, please merge them into l-o.

The following changes since commit 3b7de4be879f1f4f55ae59882a5cbd80f6dcf0f0:
  Paul Walmsley (1):
        OMAP3 clock: disable DPLL autoidle while waiting for DPLL to lock

are available in the git repository at:

  http://git.gitorious.org/lk/mainline.git mailbox

Hiroshi DOYU (10):
      omap mailbox: cleanup omap2 register definition with macro
      omap mailbox: add initial omap3 support
      omap mailbox: print hardware revision at startup
      omap mailbox: fix empty struct device for omap_mbox
      omap mailbox: fix empty struct device for omap1
      omap mailbox: fix empty struct device for omap2
      omap mailbox: add save_/restore_ctx() for PM
      omap mailbox: move mailbox.h into mailbox.c
      omap mailbox: convert sequence bit checking to module paramter
      omap mailbox: remove unnecessary header file inclusion

 arch/arm/mach-omap1/devices.c              |    2 +-
 arch/arm/mach-omap1/mailbox.c              |   31 +++--
 arch/arm/mach-omap2/devices.c              |   26 +++-
 arch/arm/mach-omap2/mailbox.c              |  178 +++++++++++++++++-----------
 arch/arm/plat-omap/Kconfig                 |    2 +-
 arch/arm/plat-omap/include/mach/irqs.h     |    1 +
 arch/arm/plat-omap/include/mach/mailbox.h  |   10 ++-
 arch/arm/plat-omap/include/mach/omap34xx.h |    2 +-
 arch/arm/plat-omap/mailbox.c               |  170 ++++++++++++++++++++------
 arch/arm/plat-omap/mailbox.h               |  100 ----------------
 10 files changed, 288 insertions(+), 234 deletions(-)
 delete mode 100644 arch/arm/plat-omap/mailbox.h



^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 01/10] omap mailbox: cleanup omap2 register definition with macro
  2008-11-25  9:39 [PATCH 0/10] omap mailbox driver update with omap3 support Hiroshi DOYU
@ 2008-11-25  9:39 ` Hiroshi DOYU
  2008-11-25  9:39   ` [PATCH 02/10] omap mailbox: add initial omap3 support Hiroshi DOYU
  0 siblings, 1 reply; 23+ messages in thread
From: Hiroshi DOYU @ 2008-11-25  9:39 UTC (permalink / raw)
  To: linux-omap; +Cc: Hiroshi DOYU

Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
---
 arch/arm/mach-omap2/mailbox.c |   77 +++++++++++++++-------------------------
 1 files changed, 29 insertions(+), 48 deletions(-)

diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
index 22546d0..5ff2ed8 100644
--- a/arch/arm/mach-omap2/mailbox.c
+++ b/arch/arm/mach-omap2/mailbox.c
@@ -1,9 +1,9 @@
 /*
- * Mailbox reservation modules for OMAP2
+ * Mailbox reservation modules for OMAP2/3
  *
- * Copyright (C) 2006 Nokia Corporation
+ * Copyright (C) 2006-2008 Nokia Corporation
  * Written by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
- *        and  Paul Mundt <paul.mundt@nokia.com>
+ *        and  Paul Mundt
  *
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
@@ -18,40 +18,19 @@
 #include <mach/mailbox.h>
 #include <mach/irqs.h>
 
-#define MAILBOX_REVISION		0x00
-#define MAILBOX_SYSCONFIG		0x10
-#define MAILBOX_SYSSTATUS		0x14
-#define MAILBOX_MESSAGE_0		0x40
-#define MAILBOX_MESSAGE_1		0x44
-#define MAILBOX_MESSAGE_2		0x48
-#define MAILBOX_MESSAGE_3		0x4c
-#define MAILBOX_MESSAGE_4		0x50
-#define MAILBOX_MESSAGE_5		0x54
-#define MAILBOX_FIFOSTATUS_0		0x80
-#define MAILBOX_FIFOSTATUS_1		0x84
-#define MAILBOX_FIFOSTATUS_2		0x88
-#define MAILBOX_FIFOSTATUS_3		0x8c
-#define MAILBOX_FIFOSTATUS_4		0x90
-#define MAILBOX_FIFOSTATUS_5		0x94
-#define MAILBOX_MSGSTATUS_0		0xc0
-#define MAILBOX_MSGSTATUS_1		0xc4
-#define MAILBOX_MSGSTATUS_2		0xc8
-#define MAILBOX_MSGSTATUS_3		0xcc
-#define MAILBOX_MSGSTATUS_4		0xd0
-#define MAILBOX_MSGSTATUS_5		0xd4
-#define MAILBOX_IRQSTATUS_0		0x100
-#define MAILBOX_IRQENABLE_0		0x104
-#define MAILBOX_IRQSTATUS_1		0x108
-#define MAILBOX_IRQENABLE_1		0x10c
-#define MAILBOX_IRQSTATUS_2		0x110
-#define MAILBOX_IRQENABLE_2		0x114
-#define MAILBOX_IRQSTATUS_3		0x118
-#define MAILBOX_IRQENABLE_3		0x11c
+#define MAILBOX_REVISION		0x000
+#define MAILBOX_SYSCONFIG		0x010
+#define MAILBOX_SYSSTATUS		0x014
+#define MAILBOX_MESSAGE(m)		(0x040 + 4 * (m))
+#define MAILBOX_FIFOSTATUS(m)		(0x080 + 4 * (m))
+#define MAILBOX_MSGSTATUS(m)		(0x0c0 + 4 * (m))
+#define MAILBOX_IRQSTATUS(u)		(0x100 + 8 * (u))
+#define MAILBOX_IRQENABLE(u)		(0x108 + 8 * (u))
 
-static unsigned long mbox_base;
+#define MAILBOX_IRQ_NEWMSG(u)		(1 << (2 * (u)))
+#define MAILBOX_IRQ_NOTFULL(u)		(1 << (2 * (u) + 1))
 
-#define MAILBOX_IRQ_NOTFULL(n)		(1 << (2 * (n) + 1))
-#define MAILBOX_IRQ_NEWMSG(n)		(1 << (2 * (n)))
+static unsigned long mbox_base;
 
 struct omap_mbox2_fifo {
 	unsigned long msg;
@@ -209,15 +188,15 @@ static struct omap_mbox_ops omap2_mbox_ops = {
 /* DSP */
 static struct omap_mbox2_priv omap2_mbox_dsp_priv = {
 	.tx_fifo = {
-		.msg		= MAILBOX_MESSAGE_0,
-		.fifo_stat	= MAILBOX_FIFOSTATUS_0,
+		.msg		= MAILBOX_MESSAGE(0),
+		.fifo_stat	= MAILBOX_FIFOSTATUS(0),
 	},
 	.rx_fifo = {
-		.msg		= MAILBOX_MESSAGE_1,
-		.msg_stat	= MAILBOX_MSGSTATUS_1,
+		.msg		= MAILBOX_MESSAGE(1),
+		.msg_stat	= MAILBOX_MSGSTATUS(1),
 	},
-	.irqenable	= MAILBOX_IRQENABLE_0,
-	.irqstatus	= MAILBOX_IRQSTATUS_0,
+	.irqenable	= MAILBOX_IRQENABLE(0),
+	.irqstatus	= MAILBOX_IRQSTATUS(0),
 	.notfull_bit	= MAILBOX_IRQ_NOTFULL(0),
 	.newmsg_bit	= MAILBOX_IRQ_NEWMSG(1),
 };
@@ -232,15 +211,15 @@ EXPORT_SYMBOL(mbox_dsp_info);
 /* IVA */
 static struct omap_mbox2_priv omap2_mbox_iva_priv = {
 	.tx_fifo = {
-		.msg		= MAILBOX_MESSAGE_2,
-		.fifo_stat	= MAILBOX_FIFOSTATUS_2,
+		.msg		= MAILBOX_MESSAGE(2),
+		.fifo_stat	= MAILBOX_FIFOSTATUS(2),
 	},
 	.rx_fifo = {
-		.msg		= MAILBOX_MESSAGE_3,
-		.msg_stat	= MAILBOX_MSGSTATUS_3,
+		.msg		= MAILBOX_MESSAGE(3),
+		.msg_stat	= MAILBOX_MSGSTATUS(3),
 	},
-	.irqenable	= MAILBOX_IRQENABLE_3,
-	.irqstatus	= MAILBOX_IRQSTATUS_3,
+	.irqenable	= MAILBOX_IRQENABLE(3),
+	.irqstatus	= MAILBOX_IRQSTATUS(3),
 	.notfull_bit	= MAILBOX_IRQ_NOTFULL(2),
 	.newmsg_bit	= MAILBOX_IRQ_NEWMSG(3),
 };
@@ -320,4 +299,6 @@ static void __exit omap2_mbox_exit(void)
 module_init(omap2_mbox_init);
 module_exit(omap2_mbox_exit);
 
-MODULE_LICENSE("GPL");
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("omap mailbox: omap2/3 architecture specific functions");
+MODULE_AUTHOR("Hiroshi DOYU <Hiroshi.DOYU@nokia.com>, Paul Mundt");
-- 
1.6.0.3.613.g9f8f13


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 02/10] omap mailbox: add initial omap3 support
  2008-11-25  9:39 ` [PATCH 01/10] omap mailbox: cleanup omap2 register definition with macro Hiroshi DOYU
@ 2008-11-25  9:39   ` Hiroshi DOYU
  2008-11-25  9:39     ` [PATCH 03/10] omap mailbox: print hardware revision at startup Hiroshi DOYU
                       ` (2 more replies)
  0 siblings, 3 replies; 23+ messages in thread
From: Hiroshi DOYU @ 2008-11-25  9:39 UTC (permalink / raw)
  To: linux-omap; +Cc: Hiroshi DOYU

Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
---
 arch/arm/mach-omap2/devices.c              |   24 +++++++++++---
 arch/arm/mach-omap2/mailbox.c              |   46 ++++++++++++++++++----------
 arch/arm/plat-omap/Kconfig                 |    2 +-
 arch/arm/plat-omap/include/mach/irqs.h     |    1 +
 arch/arm/plat-omap/include/mach/omap34xx.h |    2 +-
 5 files changed, 52 insertions(+), 23 deletions(-)

diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 241e418..d385f0f 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -84,13 +84,15 @@ static inline void omap_init_camera(void)
 }
 #endif
 
-#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)
+
+#define MBOX_REG_SIZE	0x120
 
 static struct resource mbox_resources[] = {
+#if defined(CONFIG_ARCH_OMAP2420)
 	{
-		.start		= OMAP2_MBOX_BASE,
-		.end		= OMAP2_MBOX_BASE + 0x11f,
+		.start		= OMAP24XX_MAILBOX_BASE,
+		.end		= OMAP24XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
 		.flags		= IORESOURCE_MEM,
 	},
 	{
@@ -101,6 +103,18 @@ static struct resource mbox_resources[] = {
 		.start		= INT_24XX_MAIL_U3_MPU,
 		.flags		= IORESOURCE_IRQ,
 	},
+/* FIXME: if multiple architecture support is necessary */
+#elif  defined(CONFIG_ARCH_OMAP3)
+	{
+		.start		= OMAP34XX_MAILBOX_BASE,
+		.end		= OMAP34XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
+		.flags		= IORESOURCE_MEM,
+	},
+	{
+		.start		= INT_34XX_MAIL_U0_MPU,
+		.flags		= IORESOURCE_IRQ,
+	},
+#endif
 };
 
 static struct platform_device mbox_device = {
@@ -116,7 +130,7 @@ static inline void omap_init_mbox(void)
 }
 #else
 static inline void omap_init_mbox(void) { }
-#endif
+#endif /* CONFIG_OMAP_MBOX_FWK */
 
 #if defined(CONFIG_OMAP_STI)
 
diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
index 5ff2ed8..261cd79 100644
--- a/arch/arm/mach-omap2/mailbox.c
+++ b/arch/arm/mach-omap2/mailbox.c
@@ -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((void __iomem *)(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, (void __iomem *)(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,52 +229,66 @@ 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;
-	}
-
 	/* MBOX base */
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (unlikely(!res)) {
 		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 */
+	/* DSP or IVA2 IRQ */
 	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	if (unlikely(!res)) {
 		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);
+	if (!ret)
+		goto err_dsp;
 
+#if defined(CONFIG_ARCH_OMAP2420)
 	/* IVA IRQ */
 	res = platform_get_resource(pdev, IORESOURCE_IRQ, 1);
 	if (unlikely(!res)) {
 		dev_err(&pdev->dev, "invalid irq resource\n");
-		return -ENODEV;
+		ret = -ENODEV;
+		goto err_iva1;
 	}
 	mbox_iva_info.irq = res->start;
 
 	ret = omap_mbox_register(&mbox_iva_info);
+	if (!ret)
+		goto err_iva1;
+#endif
+	return ret;
 
+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;
 }
 
diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index 960c13f..2465aea 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -180,7 +180,7 @@ config OMAP_MBOX_FWK
 	default n
 	help
 	  Say Y here if you want to use OMAP Mailbox framework support for
-	  DSP and IVA1.0 in OMAP1/2.
+	  DSP, IVA1.0 and IVA2 in OMAP1/2/3.
 
 choice
         prompt "System timer"
diff --git a/arch/arm/plat-omap/include/mach/irqs.h b/arch/arm/plat-omap/include/mach/irqs.h
index d12c39f..74f58c6 100644
--- a/arch/arm/plat-omap/include/mach/irqs.h
+++ b/arch/arm/plat-omap/include/mach/irqs.h
@@ -315,6 +315,7 @@
 #define INT_34XX_MCBSP3_IRQ	22
 #define INT_34XX_MCBSP4_IRQ	23
 #define INT_34XX_CAM_IRQ	24
+#define INT_34XX_MAIL_U0_MPU	26
 #define INT_34XX_MCBSP5_IRQ	27
 #define INT_34XX_GPIO_BANK1	29
 #define INT_34XX_GPIO_BANK2	30
diff --git a/arch/arm/plat-omap/include/mach/omap34xx.h b/arch/arm/plat-omap/include/mach/omap34xx.h
index 0a137c1..afd0f6c 100644
--- a/arch/arm/plat-omap/include/mach/omap34xx.h
+++ b/arch/arm/plat-omap/include/mach/omap34xx.h
@@ -63,8 +63,8 @@
 #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)
 #define OMAP34XX_CAMERA_BASE		(L4_34XX_BASE + 0xBC000)
-
 #endif
 
 #define OMAP34XX_DSP_BASE	0x58000000
-- 
1.6.0.3.613.g9f8f13


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 03/10] omap mailbox: print hardware revision at startup
  2008-11-25  9:39   ` [PATCH 02/10] omap mailbox: add initial omap3 support Hiroshi DOYU
@ 2008-11-25  9:39     ` Hiroshi DOYU
  2008-11-25  9:39       ` [PATCH 04/10] omap mailbox: fix empty struct device for omap_mbox Hiroshi DOYU
  2008-11-25 21:54     ` [PATCH 02/10] omap mailbox: add initial omap3 support Tony Lindgren
  2009-01-21 20:02     ` Kanigeri, Hari
  2 siblings, 1 reply; 23+ messages in thread
From: Hiroshi DOYU @ 2008-11-25  9:39 UTC (permalink / raw)
  To: linux-omap; +Cc: Hiroshi DOYU

Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
---
 arch/arm/mach-omap2/mailbox.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
index 261cd79..7c4d6ef 100644
--- a/arch/arm/mach-omap2/mailbox.c
+++ b/arch/arm/mach-omap2/mailbox.c
@@ -74,6 +74,9 @@ static int omap2_mbox_startup(struct omap_mbox *mbox)
 	}
 	clk_enable(mbox_ick_handle);
 
+	l = mbox_read_reg(MAILBOX_REVISION);
+	pr_info("omap mailbox rev %x\n", l);
+
 	/* set smart-idle & autoidle */
 	l = mbox_read_reg(MAILBOX_SYSCONFIG);
 	l |= 0x00000011;
-- 
1.6.0.3.613.g9f8f13


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 04/10] omap mailbox: fix empty struct device for omap_mbox
  2008-11-25  9:39     ` [PATCH 03/10] omap mailbox: print hardware revision at startup Hiroshi DOYU
@ 2008-11-25  9:39       ` Hiroshi DOYU
  2008-11-25  9:39         ` [PATCH 05/10] omap mailbox: fix empty struct device for omap1 Hiroshi DOYU
  0 siblings, 1 reply; 23+ messages in thread
From: Hiroshi DOYU @ 2008-11-25  9:39 UTC (permalink / raw)
  To: linux-omap; +Cc: Hiroshi DOYU

Since "mbox->dev" doesn't exist and isn't created either at
registration, this patch will create "struct device", which belongs to
"omap-mailbox" class and set this pointer for the member of
"struct omap_mbox".

Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
---
 arch/arm/plat-omap/include/mach/mailbox.h |    4 +-
 arch/arm/plat-omap/mailbox.c              |   63 ++++++++++++++---------------
 2 files changed, 33 insertions(+), 34 deletions(-)

diff --git a/arch/arm/plat-omap/include/mach/mailbox.h b/arch/arm/plat-omap/include/mach/mailbox.h
index 9d3994b..b81df6a 100644
--- a/arch/arm/plat-omap/include/mach/mailbox.h
+++ b/arch/arm/plat-omap/include/mach/mailbox.h
@@ -53,7 +53,7 @@ struct omap_mbox {
 
 	mbox_msg_t		seq_snd, seq_rcv;
 
-	struct device		dev;
+	struct device		*dev;
 
 	struct omap_mbox	*next;
 	void			*priv;
@@ -69,7 +69,7 @@ void omap_mbox_init_seq(struct omap_mbox *);
 struct omap_mbox *omap_mbox_get(const char *);
 void omap_mbox_put(struct omap_mbox *);
 
-int omap_mbox_register(struct omap_mbox *);
+int omap_mbox_register(struct device *parent, struct omap_mbox *);
 int omap_mbox_unregister(struct omap_mbox *);
 
 #endif /* MAILBOX_H */
diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index b52ce05..5e8cd65 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -1,10 +1,9 @@
 /*
  * OMAP mailbox driver
  *
- * Copyright (C) 2006 Nokia Corporation. All rights reserved.
+ * Copyright (C) 2006-2008 Nokia Corporation. All rights reserved.
  *
- * Contact: Toshihiro Kobayashi <toshihiro.kobayashi@nokia.com>
- *		Restructured by Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
+ * Contact: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -136,7 +135,7 @@ static void mbox_rx_work(struct work_struct *work)
 	unsigned long flags;
 
 	if (mbox->rxq->callback == NULL) {
-		sysfs_notify(&mbox->dev.kobj, NULL, "mbox");
+		sysfs_notify(&mbox->dev->kobj, NULL, "mbox");
 		return;
 	}
 
@@ -204,7 +203,7 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox)
 	/* no more messages in the fifo. clear IRQ source. */
 	ack_mbox_irq(mbox, IRQ_RX);
 	enable_mbox_irq(mbox, IRQ_RX);
-	nomem:
+nomem:
 	schedule_work(&mbox->rxq->work);
 }
 
@@ -286,7 +285,7 @@ static ssize_t mbox_show(struct class *class, char *buf)
 static CLASS_ATTR(mbox, S_IRUGO, mbox_show, NULL);
 
 static struct class omap_mbox_class = {
-	.name = "omap_mbox",
+	.name = "omap-mailbox",
 };
 
 static struct omap_mbox_queue *mbox_queue_alloc(struct omap_mbox *mbox,
@@ -333,21 +332,6 @@ static int omap_mbox_init(struct omap_mbox *mbox)
 			return ret;
 	}
 
-	mbox->dev.class = &omap_mbox_class;
-	dev_set_name(&mbox->dev, "%s", mbox->name);
-	dev_set_drvdata(&mbox->dev, mbox);
-
-	ret = device_register(&mbox->dev);
-	if (unlikely(ret))
-		goto fail_device_reg;
-
-	ret = device_create_file(&mbox->dev, &dev_attr_mbox);
-	if (unlikely(ret)) {
-		printk(KERN_ERR
-			"device_create_file failed: %d\n", ret);
-		goto fail_create_mbox;
-	}
-
 	ret = request_irq(mbox->irq, mbox_interrupt, IRQF_DISABLED,
 				mbox->name, mbox);
 	if (unlikely(ret)) {
@@ -377,10 +361,6 @@ static int omap_mbox_init(struct omap_mbox *mbox)
  fail_alloc_txq:
 	free_irq(mbox->irq, mbox);
  fail_request_irq:
-	device_remove_file(&mbox->dev, &dev_attr_mbox);
- fail_create_mbox:
-	device_unregister(&mbox->dev);
- fail_device_reg:
 	if (unlikely(mbox->ops->shutdown))
 		mbox->ops->shutdown(mbox);
 
@@ -393,8 +373,6 @@ static void omap_mbox_fini(struct omap_mbox *mbox)
 	mbox_queue_free(mbox->rxq);
 
 	free_irq(mbox->irq, mbox);
-	device_remove_file(&mbox->dev, &dev_attr_mbox);
-	class_unregister(&omap_mbox_class);
 
 	if (unlikely(mbox->ops->shutdown))
 		mbox->ops->shutdown(mbox);
@@ -440,7 +418,7 @@ void omap_mbox_put(struct omap_mbox *mbox)
 }
 EXPORT_SYMBOL(omap_mbox_put);
 
-int omap_mbox_register(struct omap_mbox *mbox)
+int omap_mbox_register(struct device *parent, struct omap_mbox *mbox)
 {
 	int ret = 0;
 	struct omap_mbox **tmp;
@@ -450,14 +428,31 @@ int omap_mbox_register(struct omap_mbox *mbox)
 	if (mbox->next)
 		return -EBUSY;
 
+	mbox->dev = device_create(&omap_mbox_class,
+				  parent, 0, mbox, "%s", mbox->name);
+	if (IS_ERR(mbox->dev))
+		return PTR_ERR(mbox->dev);
+
+	ret = device_create_file(mbox->dev, &dev_attr_mbox);
+	if (ret)
+		goto err_sysfs;
+
 	write_lock(&mboxes_lock);
 	tmp = find_mboxes(mbox->name);
-	if (*tmp)
+	if (*tmp) {
 		ret = -EBUSY;
-	else
-		*tmp = mbox;
+		write_unlock(&mboxes_lock);
+		goto err_find;
+	}
+	*tmp = mbox;
 	write_unlock(&mboxes_lock);
 
+	return 0;
+
+err_find:
+	device_remove_file(mbox->dev, &dev_attr_mbox);
+err_sysfs:
+	device_unregister(mbox->dev);
 	return ret;
 }
 EXPORT_SYMBOL(omap_mbox_register);
@@ -473,6 +468,8 @@ int omap_mbox_unregister(struct omap_mbox *mbox)
 			*tmp = mbox->next;
 			mbox->next = NULL;
 			write_unlock(&mboxes_lock);
+			device_remove_file(mbox->dev, &dev_attr_mbox);
+			device_unregister(mbox->dev);
 			return 0;
 		}
 		tmp = &(*tmp)->next;
@@ -501,4 +498,6 @@ static void __exit omap_mbox_class_exit(void)
 subsys_initcall(omap_mbox_class_init);
 module_exit(omap_mbox_class_exit);
 
-MODULE_LICENSE("GPL");
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("omap mailbox: interrupt driven messaging");
+MODULE_AUTHOR("Toshihiro Kobayashi and Hiroshi DOYU");
-- 
1.6.0.3.613.g9f8f13


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 05/10] omap mailbox: fix empty struct device for omap1
  2008-11-25  9:39       ` [PATCH 04/10] omap mailbox: fix empty struct device for omap_mbox Hiroshi DOYU
@ 2008-11-25  9:39         ` Hiroshi DOYU
  2008-11-25  9:39           ` [PATCH 06/10] omap mailbox: fix empty struct device for omap2 Hiroshi DOYU
  2008-11-25  9:44           ` [PATCH 05/10] omap mailbox: fix empty struct device for omap1 Felipe Balbi
  0 siblings, 2 replies; 23+ messages in thread
From: Hiroshi DOYU @ 2008-11-25  9:39 UTC (permalink / raw)
  To: linux-omap; +Cc: Hiroshi DOYU

Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
---
 arch/arm/mach-omap1/devices.c |    2 +-
 arch/arm/mach-omap1/mailbox.c |   31 +++++++++++++++++--------------
 2 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/arch/arm/mach-omap1/devices.c b/arch/arm/mach-omap1/devices.c
index 77382d8..b4b6106 100644
--- a/arch/arm/mach-omap1/devices.c
+++ b/arch/arm/mach-omap1/devices.c
@@ -86,7 +86,7 @@ static struct resource mbox_resources[] = {
 };
 
 static struct platform_device mbox_device = {
-	.name		= "mailbox",
+	.name		= "omap1-mailbox",
 	.id		= -1,
 	.num_resources	= ARRAY_SIZE(mbox_resources),
 	.resource	= mbox_resources,
diff --git a/arch/arm/mach-omap1/mailbox.c b/arch/arm/mach-omap1/mailbox.c
index 59abbf3..d4b2e94 100644
--- a/arch/arm/mach-omap1/mailbox.c
+++ b/arch/arm/mach-omap1/mailbox.c
@@ -1,7 +1,7 @@
 /*
  * Mailbox reservation modules for DSP
  *
- * Copyright (C) 2006 Nokia Corporation
+ * Copyright (C) 2006-2008 Nokia Corporation
  * Written by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
  *
  * This file is subject to the terms and conditions of the GNU General Public
@@ -17,6 +17,8 @@
 #include <mach/mailbox.h>
 #include <mach/irqs.h>
 
+#define DRV_NAME "omap1-mailbox"
+
 #define MAILBOX_ARM2DSP1		0x00
 #define MAILBOX_ARM2DSP1b		0x04
 #define MAILBOX_DSP2ARM1		0x08
@@ -27,7 +29,7 @@
 #define MAILBOX_DSP2ARM1_Flag		0x1c
 #define MAILBOX_DSP2ARM2_Flag		0x20
 
-unsigned long mbox_base;
+static void __iomem *mbox_base;
 
 struct omap_mbox1_fifo {
 	unsigned long cmd;
@@ -40,14 +42,14 @@ struct omap_mbox1_priv {
 	struct omap_mbox1_fifo rx_fifo;
 };
 
-static inline int mbox_read_reg(unsigned int reg)
+static inline int mbox_read_reg(size_t ofs)
 {
-	return __raw_readw(mbox_base + reg);
+	return __raw_readw(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_writew(val, mbox_base + reg);
+	__raw_writew(val, mbox_base + ofs);
 }
 
 /* msg */
@@ -143,7 +145,7 @@ struct omap_mbox mbox_dsp_info = {
 };
 EXPORT_SYMBOL(mbox_dsp_info);
 
-static int __init omap1_mbox_probe(struct platform_device *pdev)
+static int __devinit omap1_mbox_probe(struct platform_device *pdev)
 {
 	struct resource *res;
 	int ret = 0;
@@ -170,12 +172,10 @@ static int __init omap1_mbox_probe(struct platform_device *pdev)
 	}
 	mbox_dsp_info.irq = res->start;
 
-	ret = omap_mbox_register(&mbox_dsp_info);
-
-	return ret;
+	return omap_mbox_register(&pdev->dev, &mbox_dsp_info);
 }
 
-static int omap1_mbox_remove(struct platform_device *pdev)
+static int __devexit omap1_mbox_remove(struct platform_device *pdev)
 {
 	omap_mbox_unregister(&mbox_dsp_info);
 
@@ -184,9 +184,9 @@ static int omap1_mbox_remove(struct platform_device *pdev)
 
 static struct platform_driver omap1_mbox_driver = {
 	.probe	= omap1_mbox_probe,
-	.remove	= omap1_mbox_remove,
+	.remove	= __devexit_p(omap1_mbox_remove),
 	.driver	= {
-		.name	= "mailbox",
+		.name	= DRV_NAME,
 	},
 };
 
@@ -203,4 +203,7 @@ static void __exit omap1_mbox_exit(void)
 module_init(omap1_mbox_init);
 module_exit(omap1_mbox_exit);
 
-MODULE_LICENSE("GPL");
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("omap mailbox: omap1 architecture specific functions");
+MODULE_AUTHOR("Hiroshi DOYU" <Hiroshi.DOYU@nokia.com>);
+MODULE_ALIAS("platform:"DRV_NAME");
-- 
1.6.0.3.613.g9f8f13


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 06/10] omap mailbox: fix empty struct device for omap2
  2008-11-25  9:39         ` [PATCH 05/10] omap mailbox: fix empty struct device for omap1 Hiroshi DOYU
@ 2008-11-25  9:39           ` Hiroshi DOYU
  2008-11-25  9:39             ` [PATCH 07/10] omap mailbox: add save_/restore_ctx() for PM Hiroshi DOYU
  2008-11-25  9:44           ` [PATCH 05/10] omap mailbox: fix empty struct device for omap1 Felipe Balbi
  1 sibling, 1 reply; 23+ messages in thread
From: Hiroshi DOYU @ 2008-11-25  9:39 UTC (permalink / raw)
  To: linux-omap; +Cc: Hiroshi DOYU

Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
---
 arch/arm/mach-omap2/devices.c |    2 +-
 arch/arm/mach-omap2/mailbox.c |   15 +++++++++------
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index d385f0f..95d8673 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -118,7 +118,7 @@ static struct resource mbox_resources[] = {
 };
 
 static struct platform_device mbox_device = {
-	.name		= "mailbox",
+	.name		= "omap2-mailbox",
 	.id		= -1,
 	.num_resources	= ARRAY_SIZE(mbox_resources),
 	.resource	= mbox_resources,
diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
index 7c4d6ef..12715d8 100644
--- a/arch/arm/mach-omap2/mailbox.c
+++ b/arch/arm/mach-omap2/mailbox.c
@@ -18,6 +18,8 @@
 #include <mach/mailbox.h>
 #include <mach/irqs.h>
 
+#define DRV_NAME "omap2-mailbox"
+
 #define MAILBOX_REVISION		0x000
 #define MAILBOX_SYSCONFIG		0x010
 #define MAILBOX_SYSSTATUS		0x014
@@ -234,7 +236,7 @@ static struct omap_mbox mbox_iva_info = {
 };
 #endif
 
-static int __init omap2_mbox_probe(struct platform_device *pdev)
+static int __devinit omap2_mbox_probe(struct platform_device *pdev)
 {
 	struct resource *res;
 	int ret = 0;
@@ -258,7 +260,7 @@ static int __init omap2_mbox_probe(struct platform_device *pdev)
 	}
 	mbox_dsp_info.irq = res->start;
 
-	ret = omap_mbox_register(&mbox_dsp_info);
+	ret = omap_mbox_register(&pdev->dev, &mbox_dsp_info);
 	if (!ret)
 		goto err_dsp;
 
@@ -272,7 +274,7 @@ static int __init omap2_mbox_probe(struct platform_device *pdev)
 	}
 	mbox_iva_info.irq = res->start;
 
-	ret = omap_mbox_register(&mbox_iva_info);
+	ret = omap_mbox_register(&pdev->dev, &mbox_iva_info);
 	if (!ret)
 		goto err_iva1;
 #endif
@@ -285,7 +287,7 @@ err_dsp:
 	return ret;
 }
 
-static int omap2_mbox_remove(struct platform_device *pdev)
+static int __devexit omap2_mbox_remove(struct platform_device *pdev)
 {
 #if defined(CONFIG_ARCH_OMAP2420)
 	omap_mbox_unregister(&mbox_iva_info);
@@ -297,9 +299,9 @@ static int omap2_mbox_remove(struct platform_device *pdev)
 
 static struct platform_driver omap2_mbox_driver = {
 	.probe = omap2_mbox_probe,
-	.remove = omap2_mbox_remove,
+	.remove = __devexit_p(omap2_mbox_remove),
 	.driver = {
-		.name = "mailbox",
+		.name = DRV_NAME,
 	},
 };
 
@@ -319,3 +321,4 @@ module_exit(omap2_mbox_exit);
 MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("omap mailbox: omap2/3 architecture specific functions");
 MODULE_AUTHOR("Hiroshi DOYU <Hiroshi.DOYU@nokia.com>, Paul Mundt");
+MODULE_ALIAS("platform:"DRV_NAME);
-- 
1.6.0.3.613.g9f8f13


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 07/10] omap mailbox: add save_/restore_ctx() for PM
  2008-11-25  9:39           ` [PATCH 06/10] omap mailbox: fix empty struct device for omap2 Hiroshi DOYU
@ 2008-11-25  9:39             ` Hiroshi DOYU
  2008-11-25  9:39               ` [PATCH 08/10] omap mailbox: move mailbox.h into mailbox.c Hiroshi DOYU
  0 siblings, 1 reply; 23+ messages in thread
From: Hiroshi DOYU @ 2008-11-25  9:39 UTC (permalink / raw)
  To: linux-omap; +Cc: Hiroshi DOYU

To preserve the registers during off-mode

Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
---
 arch/arm/mach-omap2/mailbox.c             |   35 +++++++++++++++++++++++++++++
 arch/arm/plat-omap/include/mach/mailbox.h |    6 +++++
 arch/arm/plat-omap/mailbox.c              |   18 +++++++++++++++
 3 files changed, 59 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
index 12715d8..c29015f 100644
--- a/arch/arm/mach-omap2/mailbox.c
+++ b/arch/arm/mach-omap2/mailbox.c
@@ -32,6 +32,8 @@
 #define MAILBOX_IRQ_NEWMSG(u)		(1 << (2 * (u)))
 #define MAILBOX_IRQ_NOTFULL(u)		(1 << (2 * (u) + 1))
 
+#define MBOX_REG_SIZE			0x120
+
 static void __iomem *mbox_base;
 
 struct omap_mbox2_fifo {
@@ -47,6 +49,7 @@ struct omap_mbox2_priv {
 	unsigned long irqstatus;
 	u32 newmsg_bit;
 	u32 notfull_bit;
+	char ctx[MBOX_REG_SIZE];
 };
 
 static struct clk *mbox_ick_handle;
@@ -167,6 +170,36 @@ static int omap2_mbox_is_irq(struct omap_mbox *mbox,
 	return (enable & status & bit);
 }
 
+static void omap2_mbox_save_ctx(struct omap_mbox *mbox)
+{
+	int i;
+	struct omap_mbox2_priv *p = mbox->priv;
+
+	for (i = 0; i < MBOX_REG_SIZE; i += sizeof(u32)) {
+		u32 val;
+
+		val = mbox_read_reg(i);
+		*(u32 *)(p->ctx + i) = val;
+
+		dev_dbg(mbox->dev, "%s\t[%02d] %08x\n", __func__, i, val);
+	}
+}
+
+static void omap2_mbox_restore_ctx(struct omap_mbox *mbox)
+{
+	int i;
+	struct omap_mbox2_priv *p = mbox->priv;
+
+	for (i = 0; i < MBOX_REG_SIZE; i += sizeof(u32)) {
+		u32 val;
+
+		val = *(u32 *)(p->ctx + i);
+		mbox_write_reg(val, i);
+
+		dev_dbg(mbox->dev, "%s\t[%02d] %08x\n", __func__, i, val);
+	}
+}
+
 static struct omap_mbox_ops omap2_mbox_ops = {
 	.type		= OMAP_MBOX_TYPE2,
 	.startup	= omap2_mbox_startup,
@@ -179,6 +212,8 @@ static struct omap_mbox_ops omap2_mbox_ops = {
 	.disable_irq	= omap2_mbox_disable_irq,
 	.ack_irq	= omap2_mbox_ack_irq,
 	.is_irq		= omap2_mbox_is_irq,
+	.save_ctx	= omap2_mbox_save_ctx,
+	.restore_ctx	= omap2_mbox_restore_ctx,
 };
 
 /*
diff --git a/arch/arm/plat-omap/include/mach/mailbox.h b/arch/arm/plat-omap/include/mach/mailbox.h
index b81df6a..bca34d7 100644
--- a/arch/arm/plat-omap/include/mach/mailbox.h
+++ b/arch/arm/plat-omap/include/mach/mailbox.h
@@ -33,6 +33,9 @@ struct omap_mbox_ops {
 	void		(*disable_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
 	void		(*ack_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
 	int		(*is_irq)(struct omap_mbox *mbox, omap_mbox_irq_t irq);
+	/* ctx */
+	void		(*save_ctx)(struct omap_mbox *mbox);
+	void		(*restore_ctx)(struct omap_mbox *mbox);
 };
 
 struct omap_mbox_queue {
@@ -72,4 +75,7 @@ void omap_mbox_put(struct omap_mbox *);
 int omap_mbox_register(struct device *parent, struct omap_mbox *);
 int omap_mbox_unregister(struct omap_mbox *);
 
+void omap_mbox_save_ctx(struct omap_mbox *);
+void omap_mbox_restore_ctx(struct omap_mbox *);
+
 #endif /* MAILBOX_H */
diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index 5e8cd65..7b55f2f 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -36,6 +36,24 @@
 static struct omap_mbox *mboxes;
 static DEFINE_RWLOCK(mboxes_lock);
 
+void omap_mbox_save_ctx(struct omap_mbox *mbox)
+{
+	if (!mbox->ops->save_ctx)
+		dev_err(mbox->dev, "%s:\tno save\n", __func__);
+
+	mbox->ops->save_ctx(mbox);
+}
+EXPORT_SYMBOL_GPL(omap_mbox_save_ctx);
+
+void omap_mbox_restore_ctx(struct omap_mbox *mbox)
+{
+	if (!mbox->ops->restore_ctx)
+		dev_err(mbox->dev, "%s:\tno restore\n", __func__);
+
+	mbox->ops->restore_ctx(mbox);
+}
+EXPORT_SYMBOL_GPL(omap_mbox_restore_ctx);
+
 /* Mailbox Sequence Bit function */
 void omap_mbox_init_seq(struct omap_mbox *mbox)
 {
-- 
1.6.0.3.613.g9f8f13


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 08/10] omap mailbox: move mailbox.h into mailbox.c
  2008-11-25  9:39             ` [PATCH 07/10] omap mailbox: add save_/restore_ctx() for PM Hiroshi DOYU
@ 2008-11-25  9:39               ` Hiroshi DOYU
  2008-11-25  9:39                 ` [PATCH 09/10] omap mailbox: convert sequence bit checking to module paramter Hiroshi DOYU
  0 siblings, 1 reply; 23+ messages in thread
From: Hiroshi DOYU @ 2008-11-25  9:39 UTC (permalink / raw)
  To: linux-omap; +Cc: Hiroshi DOYU

no need to keep mailbox.h separately.

Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
---
 arch/arm/plat-omap/mailbox.c |   86 +++++++++++++++++++++++++++++++++++-
 arch/arm/plat-omap/mailbox.h |  100 ------------------------------------------
 2 files changed, 85 insertions(+), 101 deletions(-)
 delete mode 100644 arch/arm/plat-omap/mailbox.h

diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index 7b55f2f..43c0ce3 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -31,11 +31,95 @@
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <mach/mailbox.h>
-#include "mailbox.h"
 
 static struct omap_mbox *mboxes;
 static DEFINE_RWLOCK(mboxes_lock);
 
+/*
+ * Mailbox sequence bit API
+ */
+#if defined(CONFIG_ARCH_OMAP1)
+#  define MBOX_USE_SEQ_BIT
+#elif defined(CONFIG_ARCH_OMAP2)
+#  define MBOX_USE_SEQ_BIT
+#endif
+
+#ifdef MBOX_USE_SEQ_BIT
+/* seq_rcv should be initialized with any value other than
+ * 0 and 1 << 31, to allow either value for the first
+ * message.  */
+static inline void mbox_seq_init(struct omap_mbox *mbox)
+{
+	/* any value other than 0 and 1 << 31 */
+	mbox->seq_rcv = 0xffffffff;
+}
+
+static inline void mbox_seq_toggle(struct omap_mbox *mbox, mbox_msg_t * msg)
+{
+	/* add seq_snd to msg */
+	*msg = (*msg & 0x7fffffff) | mbox->seq_snd;
+	/* flip seq_snd */
+	mbox->seq_snd ^= 1 << 31;
+}
+
+static inline int mbox_seq_test(struct omap_mbox *mbox, mbox_msg_t msg)
+{
+	mbox_msg_t seq = msg & (1 << 31);
+	if (seq == mbox->seq_rcv)
+		return -1;
+	mbox->seq_rcv = seq;
+	return 0;
+}
+#else
+static inline void mbox_seq_init(struct omap_mbox *mbox)
+{
+}
+static inline void mbox_seq_toggle(struct omap_mbox *mbox, mbox_msg_t * msg)
+{
+}
+static inline int mbox_seq_test(struct omap_mbox *mbox, mbox_msg_t msg)
+{
+	return 0;
+}
+#endif
+
+/* Mailbox FIFO handle functions */
+static inline mbox_msg_t mbox_fifo_read(struct omap_mbox *mbox)
+{
+	return mbox->ops->fifo_read(mbox);
+}
+static inline void mbox_fifo_write(struct omap_mbox *mbox, mbox_msg_t msg)
+{
+	mbox->ops->fifo_write(mbox, msg);
+}
+static inline int mbox_fifo_empty(struct omap_mbox *mbox)
+{
+	return mbox->ops->fifo_empty(mbox);
+}
+static inline int mbox_fifo_full(struct omap_mbox *mbox)
+{
+	return mbox->ops->fifo_full(mbox);
+}
+
+/* Mailbox IRQ handle functions */
+static inline void enable_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
+{
+	mbox->ops->enable_irq(mbox, irq);
+}
+static inline void disable_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
+{
+	mbox->ops->disable_irq(mbox, irq);
+}
+static inline void ack_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
+{
+	if (mbox->ops->ack_irq)
+		mbox->ops->ack_irq(mbox, irq);
+}
+static inline int is_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
+{
+	return mbox->ops->is_irq(mbox, irq);
+}
+
 void omap_mbox_save_ctx(struct omap_mbox *mbox)
 {
 	if (!mbox->ops->save_ctx)
diff --git a/arch/arm/plat-omap/mailbox.h b/arch/arm/plat-omap/mailbox.h
deleted file mode 100644
index 67c6740..0000000
--- a/arch/arm/plat-omap/mailbox.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Mailbox internal functions
- *
- * Copyright (C) 2006 Nokia Corporation
- * Written by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#ifndef __ARCH_ARM_PLAT_MAILBOX_H
-#define __ARCH_ARM_PLAT_MAILBOX_H
-
-/*
- * Mailbox sequence bit API
- */
-#if defined(CONFIG_ARCH_OMAP1)
-#  define MBOX_USE_SEQ_BIT
-#elif defined(CONFIG_ARCH_OMAP2)
-#  define MBOX_USE_SEQ_BIT
-#endif
-
-#ifdef MBOX_USE_SEQ_BIT
-/* seq_rcv should be initialized with any value other than
- * 0 and 1 << 31, to allow either value for the first
- * message.  */
-static inline void mbox_seq_init(struct omap_mbox *mbox)
-{
-	/* any value other than 0 and 1 << 31 */
-	mbox->seq_rcv = 0xffffffff;
-}
-
-static inline void mbox_seq_toggle(struct omap_mbox *mbox, mbox_msg_t * msg)
-{
-	/* add seq_snd to msg */
-	*msg = (*msg & 0x7fffffff) | mbox->seq_snd;
-	/* flip seq_snd */
-	mbox->seq_snd ^= 1 << 31;
-}
-
-static inline int mbox_seq_test(struct omap_mbox *mbox, mbox_msg_t msg)
-{
-	mbox_msg_t seq = msg & (1 << 31);
-	if (seq == mbox->seq_rcv)
-		return -1;
-	mbox->seq_rcv = seq;
-	return 0;
-}
-#else
-static inline void mbox_seq_init(struct omap_mbox *mbox)
-{
-}
-static inline void mbox_seq_toggle(struct omap_mbox *mbox, mbox_msg_t * msg)
-{
-}
-static inline int mbox_seq_test(struct omap_mbox *mbox, mbox_msg_t msg)
-{
-	return 0;
-}
-#endif
-
-/* Mailbox FIFO handle functions */
-static inline mbox_msg_t mbox_fifo_read(struct omap_mbox *mbox)
-{
-	return mbox->ops->fifo_read(mbox);
-}
-static inline void mbox_fifo_write(struct omap_mbox *mbox, mbox_msg_t msg)
-{
-	mbox->ops->fifo_write(mbox, msg);
-}
-static inline int mbox_fifo_empty(struct omap_mbox *mbox)
-{
-	return mbox->ops->fifo_empty(mbox);
-}
-static inline int mbox_fifo_full(struct omap_mbox *mbox)
-{
-	return mbox->ops->fifo_full(mbox);
-}
-
-/* Mailbox IRQ handle functions */
-static inline void enable_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
-{
-	mbox->ops->enable_irq(mbox, irq);
-}
-static inline void disable_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
-{
-	mbox->ops->disable_irq(mbox, irq);
-}
-static inline void ack_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
-{
-	if (mbox->ops->ack_irq)
-		mbox->ops->ack_irq(mbox, irq);
-}
-static inline int is_mbox_irq(struct omap_mbox *mbox, omap_mbox_irq_t irq)
-{
-	return mbox->ops->is_irq(mbox, irq);
-}
-
-#endif				/* __ARCH_ARM_PLAT_MAILBOX_H */
-- 
1.6.0.3.613.g9f8f13


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 09/10] omap mailbox: convert sequence bit checking to module paramter
  2008-11-25  9:39               ` [PATCH 08/10] omap mailbox: move mailbox.h into mailbox.c Hiroshi DOYU
@ 2008-11-25  9:39                 ` Hiroshi DOYU
  2008-11-25  9:39                   ` [PATCH 10/10] omap mailbox: remove unnecessary header file inclusion Hiroshi DOYU
  0 siblings, 1 reply; 23+ messages in thread
From: Hiroshi DOYU @ 2008-11-25  9:39 UTC (permalink / raw)
  To: linux-omap; +Cc: Hiroshi DOYU

Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
---
 arch/arm/plat-omap/mailbox.c |   35 ++++++++++++++++-------------------
 1 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index 43c0ce3..5b00fc5 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -32,30 +32,34 @@
 #include <linux/io.h>
 #include <mach/mailbox.h>
 
+static int enable_seq_bit;
+module_param(enable_seq_bit, bool, 0);
+MODULE_PARM_DESC(enable_seq_bit, "Enable sequence bit checking.");
+
 static struct omap_mbox *mboxes;
 static DEFINE_RWLOCK(mboxes_lock);
 
 /*
  * Mailbox sequence bit API
  */
-#if defined(CONFIG_ARCH_OMAP1)
-#  define MBOX_USE_SEQ_BIT
-#elif defined(CONFIG_ARCH_OMAP2)
-#  define MBOX_USE_SEQ_BIT
-#endif
 
-#ifdef MBOX_USE_SEQ_BIT
 /* seq_rcv should be initialized with any value other than
  * 0 and 1 << 31, to allow either value for the first
  * message.  */
 static inline void mbox_seq_init(struct omap_mbox *mbox)
 {
+	if (!enable_seq_bit)
+		return;
+
 	/* any value other than 0 and 1 << 31 */
 	mbox->seq_rcv = 0xffffffff;
 }
 
 static inline void mbox_seq_toggle(struct omap_mbox *mbox, mbox_msg_t * msg)
 {
+	if (!enable_seq_bit)
+		return;
+
 	/* add seq_snd to msg */
 	*msg = (*msg & 0x7fffffff) | mbox->seq_snd;
 	/* flip seq_snd */
@@ -64,24 +68,17 @@ static inline void mbox_seq_toggle(struct omap_mbox *mbox, mbox_msg_t * msg)
 
 static inline int mbox_seq_test(struct omap_mbox *mbox, mbox_msg_t msg)
 {
-	mbox_msg_t seq = msg & (1 << 31);
+	mbox_msg_t seq;
+
+	if (!enable_seq_bit)
+		return 0;
+
+	seq = msg & (1 << 31);
 	if (seq == mbox->seq_rcv)
 		return -1;
 	mbox->seq_rcv = seq;
 	return 0;
 }
-#else
-static inline void mbox_seq_init(struct omap_mbox *mbox)
-{
-}
-static inline void mbox_seq_toggle(struct omap_mbox *mbox, mbox_msg_t * msg)
-{
-}
-static inline int mbox_seq_test(struct omap_mbox *mbox, mbox_msg_t msg)
-{
-	return 0;
-}
-#endif
 
 /* Mailbox FIFO handle functions */
 static inline mbox_msg_t mbox_fifo_read(struct omap_mbox *mbox)
-- 
1.6.0.3.613.g9f8f13


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 10/10] omap mailbox: remove unnecessary header file inclusion
  2008-11-25  9:39                 ` [PATCH 09/10] omap mailbox: convert sequence bit checking to module paramter Hiroshi DOYU
@ 2008-11-25  9:39                   ` Hiroshi DOYU
  0 siblings, 0 replies; 23+ messages in thread
From: Hiroshi DOYU @ 2008-11-25  9:39 UTC (permalink / raw)
  To: linux-omap; +Cc: Hiroshi DOYU

Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
---
 arch/arm/plat-omap/mailbox.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index 5b00fc5..b03c8d9 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -21,15 +21,11 @@
  *
  */
 
-#include <linux/init.h>
 #include <linux/module.h>
-#include <linux/sched.h>
 #include <linux/interrupt.h>
 #include <linux/device.h>
-#include <linux/blkdev.h>
-#include <linux/err.h>
 #include <linux/delay.h>
-#include <linux/io.h>
+
 #include <mach/mailbox.h>
 
 static int enable_seq_bit;
-- 
1.6.0.3.613.g9f8f13


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH 05/10] omap mailbox: fix empty struct device for omap1
  2008-11-25  9:39         ` [PATCH 05/10] omap mailbox: fix empty struct device for omap1 Hiroshi DOYU
  2008-11-25  9:39           ` [PATCH 06/10] omap mailbox: fix empty struct device for omap2 Hiroshi DOYU
@ 2008-11-25  9:44           ` Felipe Balbi
  2008-11-25 11:13             ` Hiroshi DOYU
  1 sibling, 1 reply; 23+ messages in thread
From: Felipe Balbi @ 2008-11-25  9:44 UTC (permalink / raw)
  To: ext Hiroshi DOYU; +Cc: linux-omap

On Tue, Nov 25, 2008 at 11:39:53AM +0200, Hiroshi DOYU wrote:
> +MODULE_ALIAS("platform:"DRV_NAME");

small typo here ?

MODULE_ALIAS("platform:" DRV_NAME);

-- 
balbi

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 05/10] omap mailbox: fix empty struct device for omap1
  2008-11-25  9:44           ` [PATCH 05/10] omap mailbox: fix empty struct device for omap1 Felipe Balbi
@ 2008-11-25 11:13             ` Hiroshi DOYU
  0 siblings, 0 replies; 23+ messages in thread
From: Hiroshi DOYU @ 2008-11-25 11:13 UTC (permalink / raw)
  To: felipe.balbi; +Cc: linux-omap

From: Felipe Balbi <felipe.balbi@nokia.com>
Subject: Re: [PATCH 05/10] omap mailbox: fix empty struct device for omap1
Date: Tue, 25 Nov 2008 11:44:27 +0200

> On Tue, Nov 25, 2008 at 11:39:53AM +0200, Hiroshi DOYU wrote:
> > +MODULE_ALIAS("platform:"DRV_NAME");
> 
> small typo here ?

Right. fixed it in the repository. Thanks.

       Hiroshi DOYU

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 02/10] omap mailbox: add initial omap3 support
  2008-11-25  9:39   ` [PATCH 02/10] omap mailbox: add initial omap3 support Hiroshi DOYU
  2008-11-25  9:39     ` [PATCH 03/10] omap mailbox: print hardware revision at startup Hiroshi DOYU
@ 2008-11-25 21:54     ` Tony Lindgren
  2008-11-26  0:10       ` Hiroshi DOYU
  2009-01-21 20:02     ` Kanigeri, Hari
  2 siblings, 1 reply; 23+ messages in thread
From: Tony Lindgren @ 2008-11-25 21:54 UTC (permalink / raw)
  To: Hiroshi DOYU; +Cc: linux-omap

* Hiroshi DOYU <Hiroshi.DOYU@nokia.com> [081125 01:40]:
> Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
> ---
>  arch/arm/mach-omap2/devices.c              |   24 +++++++++++---
>  arch/arm/mach-omap2/mailbox.c              |   46 ++++++++++++++++++----------
>  arch/arm/plat-omap/Kconfig                 |    2 +-
>  arch/arm/plat-omap/include/mach/irqs.h     |    1 +
>  arch/arm/plat-omap/include/mach/omap34xx.h |    2 +-
>  5 files changed, 52 insertions(+), 23 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
> index 241e418..d385f0f 100644
> --- a/arch/arm/mach-omap2/devices.c
> +++ b/arch/arm/mach-omap2/devices.c
> @@ -84,13 +84,15 @@ static inline void omap_init_camera(void)
>  }
>  #endif
>  
> -#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)
> +
> +#define MBOX_REG_SIZE	0x120
>  
>  static struct resource mbox_resources[] = {
> +#if defined(CONFIG_ARCH_OMAP2420)
>  	{
> -		.start		= OMAP2_MBOX_BASE,
> -		.end		= OMAP2_MBOX_BASE + 0x11f,
> +		.start		= OMAP24XX_MAILBOX_BASE,
> +		.end		= OMAP24XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
>  		.flags		= IORESOURCE_MEM,
>  	},
>  	{> @@ -101,6 +103,18 @@ static struct resource mbox_resources[] = {
>  		.start		= INT_24XX_MAIL_U3_MPU,
>  		.flags		= IORESOURCE_IRQ,
>  	},
> +/* FIXME: if multiple architecture support is necessary */
> +#elif  defined(CONFIG_ARCH_OMAP3)
> +	{
> +		.start		= OMAP34XX_MAILBOX_BASE,
> +		.end		= OMAP34XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
> +		.flags		= IORESOURCE_MEM,
> +	},
> +	{
> +		.start		= INT_34XX_MAIL_U0_MPU,
> +		.flags		= IORESOURCE_IRQ,
> +	},
> +#endif
>  };
>  
>  static struct platform_device mbox_device = {

How about setting up omap2_mbox_resources[] and omap3_mbox_resources[]
above instead? Then just select the right one to use during init.

We should not need to use ifdefs in any of the code for detecting the
omap cpu type, please use cpu_is_omap24xx() and cpu_is_omap34xx()
instead.

Regards,

Tony




> @@ -116,7 +130,7 @@ static inline void omap_init_mbox(void)
>  }
>  #else
>  static inline void omap_init_mbox(void) { }
> -#endif
> +#endif /* CONFIG_OMAP_MBOX_FWK */
>  
>  #if defined(CONFIG_OMAP_STI)
>  
> diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
> index 5ff2ed8..261cd79 100644
> --- a/arch/arm/mach-omap2/mailbox.c
> +++ b/arch/arm/mach-omap2/mailbox.c
> @@ -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((void __iomem *)(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, (void __iomem *)(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,52 +229,66 @@ 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;
> -	}
> -
>  	/* MBOX base */
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	if (unlikely(!res)) {
>  		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 */
> +	/* DSP or IVA2 IRQ */
>  	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
>  	if (unlikely(!res)) {
>  		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);
> +	if (!ret)
> +		goto err_dsp;
>  
> +#if defined(CONFIG_ARCH_OMAP2420)
>  	/* IVA IRQ */
>  	res = platform_get_resource(pdev, IORESOURCE_IRQ, 1);
>  	if (unlikely(!res)) {
>  		dev_err(&pdev->dev, "invalid irq resource\n");
> -		return -ENODEV;
> +		ret = -ENODEV;
> +		goto err_iva1;
>  	}
>  	mbox_iva_info.irq = res->start;
>  
>  	ret = omap_mbox_register(&mbox_iva_info);
> +	if (!ret)
> +		goto err_iva1;
> +#endif
> +	return ret;
>  
> +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;
>  }
>  
> diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
> index 960c13f..2465aea 100644
> --- a/arch/arm/plat-omap/Kconfig
> +++ b/arch/arm/plat-omap/Kconfig
> @@ -180,7 +180,7 @@ config OMAP_MBOX_FWK
>  	default n
>  	help
>  	  Say Y here if you want to use OMAP Mailbox framework support for
> -	  DSP and IVA1.0 in OMAP1/2.
> +	  DSP, IVA1.0 and IVA2 in OMAP1/2/3.
>  
>  choice
>          prompt "System timer"
> diff --git a/arch/arm/plat-omap/include/mach/irqs.h b/arch/arm/plat-omap/include/mach/irqs.h
> index d12c39f..74f58c6 100644
> --- a/arch/arm/plat-omap/include/mach/irqs.h
> +++ b/arch/arm/plat-omap/include/mach/irqs.h
> @@ -315,6 +315,7 @@
>  #define INT_34XX_MCBSP3_IRQ	22
>  #define INT_34XX_MCBSP4_IRQ	23
>  #define INT_34XX_CAM_IRQ	24
> +#define INT_34XX_MAIL_U0_MPU	26
>  #define INT_34XX_MCBSP5_IRQ	27
>  #define INT_34XX_GPIO_BANK1	29
>  #define INT_34XX_GPIO_BANK2	30
> diff --git a/arch/arm/plat-omap/include/mach/omap34xx.h b/arch/arm/plat-omap/include/mach/omap34xx.h
> index 0a137c1..afd0f6c 100644
> --- a/arch/arm/plat-omap/include/mach/omap34xx.h
> +++ b/arch/arm/plat-omap/include/mach/omap34xx.h
> @@ -63,8 +63,8 @@
>  #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)
>  #define OMAP34XX_CAMERA_BASE		(L4_34XX_BASE + 0xBC000)
> -
>  #endif
>  
>  #define OMAP34XX_DSP_BASE	0x58000000
> -- 
> 1.6.0.3.613.g9f8f13
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 02/10] omap mailbox: add initial omap3 support
  2008-11-25 21:54     ` [PATCH 02/10] omap mailbox: add initial omap3 support Tony Lindgren
@ 2008-11-26  0:10       ` Hiroshi DOYU
  2008-11-26 18:36         ` Tony Lindgren
  0 siblings, 1 reply; 23+ messages in thread
From: Hiroshi DOYU @ 2008-11-26  0:10 UTC (permalink / raw)
  To: tony; +Cc: linux-omap

Hi Tony,

From: "ext Tony Lindgren" <tony@atomide.com>
Subject: Re: [PATCH 02/10] omap mailbox: add initial omap3 support
Date: Tue, 25 Nov 2008 13:54:14 -0800

> * Hiroshi DOYU <Hiroshi.DOYU@nokia.com> [081125 01:40]:
> > Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
> > ---
> >  arch/arm/mach-omap2/devices.c              |   24 +++++++++++---
> >  arch/arm/mach-omap2/mailbox.c              |   46 ++++++++++++++++++----------
> >  arch/arm/plat-omap/Kconfig                 |    2 +-
> >  arch/arm/plat-omap/include/mach/irqs.h     |    1 +
> >  arch/arm/plat-omap/include/mach/omap34xx.h |    2 +-
> >  5 files changed, 52 insertions(+), 23 deletions(-)
> > 
> > diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
> > index 241e418..d385f0f 100644
> > --- a/arch/arm/mach-omap2/devices.c
> > +++ b/arch/arm/mach-omap2/devices.c
> > @@ -84,13 +84,15 @@ static inline void omap_init_camera(void)
> >  }
> >  #endif
> >  
> > -#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)
> > +
> > +#define MBOX_REG_SIZE	0x120
> >  
> >  static struct resource mbox_resources[] = {
> > +#if defined(CONFIG_ARCH_OMAP2420)
> >  	{
> > -		.start		= OMAP2_MBOX_BASE,
> > -		.end		= OMAP2_MBOX_BASE + 0x11f,
> > +		.start		= OMAP24XX_MAILBOX_BASE,
> > +		.end		= OMAP24XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
> >  		.flags		= IORESOURCE_MEM,
> >  	},
> >  	{> @@ -101,6 +103,18 @@ static struct resource mbox_resources[] = {
> >  		.start		= INT_24XX_MAIL_U3_MPU,
> >  		.flags		= IORESOURCE_IRQ,
> >  	},
> > +/* FIXME: if multiple architecture support is necessary */
> > +#elif  defined(CONFIG_ARCH_OMAP3)
> > +	{
> > +		.start		= OMAP34XX_MAILBOX_BASE,
> > +		.end		= OMAP34XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
> > +		.flags		= IORESOURCE_MEM,
> > +	},
> > +	{
> > +		.start		= INT_34XX_MAIL_U0_MPU,
> > +		.flags		= IORESOURCE_IRQ,
> > +	},
> > +#endif
> >  };
> >  
> >  static struct platform_device mbox_device = {
> 
> How about setting up omap2_mbox_resources[] and omap3_mbox_resources[]
> above instead? Then just select the right one to use during init.
> 
> We should not need to use ifdefs in any of the code for detecting the
> omap cpu type, please use cpu_is_omap24xx() and cpu_is_omap34xx()
> instead.

Agreed and updated as below.

Also, the latest patchset is available in the git repository at:

  http://git.gitorious.org/lk/mainline.git mailbox

>From 7b62c1b04ae50adf2827fb3ca1ec8a3e72349d14 Mon Sep 17 00:00:00 2001
From: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
Date: Sat, 22 Nov 2008 02:28:36 +0200
Subject: [PATCH 02/10] omap mailbox: add initial omap3 support

Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
---
 arch/arm/mach-omap2/devices.c              |   36 +++++++++++++++++-----
 arch/arm/mach-omap2/mailbox.c              |   46 ++++++++++++++++++----------
 arch/arm/plat-omap/Kconfig                 |    2 +-
 arch/arm/plat-omap/include/mach/irqs.h     |    1 +
 arch/arm/plat-omap/include/mach/omap34xx.h |    2 +-
 5 files changed, 61 insertions(+), 26 deletions(-)

diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 241e418..ea37f37 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -84,13 +84,14 @@ static inline void omap_init_camera(void)
 }
 #endif
 
-#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,
 	},
 	{
@@ -103,20 +104,39 @@ 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_34XX_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 {
+		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)
 
diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
index 5ff2ed8..261cd79 100644
--- a/arch/arm/mach-omap2/mailbox.c
+++ b/arch/arm/mach-omap2/mailbox.c
@@ -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((void __iomem *)(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, (void __iomem *)(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,52 +229,66 @@ 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;
-	}
-
 	/* MBOX base */
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (unlikely(!res)) {
 		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 */
+	/* DSP or IVA2 IRQ */
 	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	if (unlikely(!res)) {
 		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);
+	if (!ret)
+		goto err_dsp;
 
+#if defined(CONFIG_ARCH_OMAP2420)
 	/* IVA IRQ */
 	res = platform_get_resource(pdev, IORESOURCE_IRQ, 1);
 	if (unlikely(!res)) {
 		dev_err(&pdev->dev, "invalid irq resource\n");
-		return -ENODEV;
+		ret = -ENODEV;
+		goto err_iva1;
 	}
 	mbox_iva_info.irq = res->start;
 
 	ret = omap_mbox_register(&mbox_iva_info);
+	if (!ret)
+		goto err_iva1;
+#endif
+	return ret;
 
+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;
 }
 
diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index 960c13f..2465aea 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -180,7 +180,7 @@ config OMAP_MBOX_FWK
 	default n
 	help
 	  Say Y here if you want to use OMAP Mailbox framework support for
-	  DSP and IVA1.0 in OMAP1/2.
+	  DSP, IVA1.0 and IVA2 in OMAP1/2/3.
 
 choice
         prompt "System timer"
diff --git a/arch/arm/plat-omap/include/mach/irqs.h b/arch/arm/plat-omap/include/mach/irqs.h
index d12c39f..74f58c6 100644
--- a/arch/arm/plat-omap/include/mach/irqs.h
+++ b/arch/arm/plat-omap/include/mach/irqs.h
@@ -315,6 +315,7 @@
 #define INT_34XX_MCBSP3_IRQ	22
 #define INT_34XX_MCBSP4_IRQ	23
 #define INT_34XX_CAM_IRQ	24
+#define INT_34XX_MAIL_U0_MPU	26
 #define INT_34XX_MCBSP5_IRQ	27
 #define INT_34XX_GPIO_BANK1	29
 #define INT_34XX_GPIO_BANK2	30
diff --git a/arch/arm/plat-omap/include/mach/omap34xx.h b/arch/arm/plat-omap/include/mach/omap34xx.h
index 0a137c1..afd0f6c 100644
--- a/arch/arm/plat-omap/include/mach/omap34xx.h
+++ b/arch/arm/plat-omap/include/mach/omap34xx.h
@@ -63,8 +63,8 @@
 #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)
 #define OMAP34XX_CAMERA_BASE		(L4_34XX_BASE + 0xBC000)
-
 #endif
 
 #define OMAP34XX_DSP_BASE	0x58000000
-- 
1.6.0.3.613.g9f8f13


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH 02/10] omap mailbox: add initial omap3 support
  2008-11-26  0:10       ` Hiroshi DOYU
@ 2008-11-26 18:36         ` Tony Lindgren
  2008-11-27 14:39           ` Hiroshi DOYU
  0 siblings, 1 reply; 23+ messages in thread
From: Tony Lindgren @ 2008-11-26 18:36 UTC (permalink / raw)
  To: Hiroshi DOYU; +Cc: linux-omap

* Hiroshi DOYU <Hiroshi.DOYU@nokia.com> [081125 16:10]:
> Hi Tony,
> 
> From: "ext Tony Lindgren" <tony@atomide.com>
> Subject: Re: [PATCH 02/10] omap mailbox: add initial omap3 support
> Date: Tue, 25 Nov 2008 13:54:14 -0800
> 
> > * Hiroshi DOYU <Hiroshi.DOYU@nokia.com> [081125 01:40]:
> > > Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
> > > ---
> > >  arch/arm/mach-omap2/devices.c              |   24 +++++++++++---
> > >  arch/arm/mach-omap2/mailbox.c              |   46 ++++++++++++++++++----------
> > >  arch/arm/plat-omap/Kconfig                 |    2 +-
> > >  arch/arm/plat-omap/include/mach/irqs.h     |    1 +
> > >  arch/arm/plat-omap/include/mach/omap34xx.h |    2 +-
> > >  5 files changed, 52 insertions(+), 23 deletions(-)
> > > 
> > > diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
> > > index 241e418..d385f0f 100644
> > > --- a/arch/arm/mach-omap2/devices.c
> > > +++ b/arch/arm/mach-omap2/devices.c
> > > @@ -84,13 +84,15 @@ static inline void omap_init_camera(void)
> > >  }
> > >  #endif
> > >  
> > > -#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)
> > > +
> > > +#define MBOX_REG_SIZE	0x120
> > >  
> > >  static struct resource mbox_resources[] = {
> > > +#if defined(CONFIG_ARCH_OMAP2420)
> > >  	{
> > > -		.start		= OMAP2_MBOX_BASE,
> > > -		.end		= OMAP2_MBOX_BASE + 0x11f,
> > > +		.start		= OMAP24XX_MAILBOX_BASE,
> > > +		.end		= OMAP24XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
> > >  		.flags		= IORESOURCE_MEM,
> > >  	},
> > >  	{> @@ -101,6 +103,18 @@ static struct resource mbox_resources[] = {
> > >  		.start		= INT_24XX_MAIL_U3_MPU,
> > >  		.flags		= IORESOURCE_IRQ,
> > >  	},
> > > +/* FIXME: if multiple architecture support is necessary */
> > > +#elif  defined(CONFIG_ARCH_OMAP3)
> > > +	{
> > > +		.start		= OMAP34XX_MAILBOX_BASE,
> > > +		.end		= OMAP34XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
> > > +		.flags		= IORESOURCE_MEM,
> > > +	},
> > > +	{
> > > +		.start		= INT_34XX_MAIL_U0_MPU,
> > > +		.flags		= IORESOURCE_IRQ,
> > > +	},
> > > +#endif
> > >  };
> > >  
> > >  static struct platform_device mbox_device = {
> > 
> > How about setting up omap2_mbox_resources[] and omap3_mbox_resources[]
> > above instead? Then just select the right one to use during init.
> > 
> > We should not need to use ifdefs in any of the code for detecting the
> > omap cpu type, please use cpu_is_omap24xx() and cpu_is_omap34xx()
> > instead.
> 
> Agreed and updated as below.

Thanks, since this is a large series, can you please send your series for
RMK to integrate to LAKML? Make sure it also applies against mainline
first :) Please feel free to add my Ack to your patches.

> Also, the latest patchset is available in the git repository at:
> 
>   http://git.gitorious.org/lk/mainline.git mailbox

Thanks, I've added mirroring for this branch to my kernel.org tree.
Let's wait for ack from RMK before integrating it to l-o.

BTW, we should move dspgateway also into a separate branch like
tidspbridge as it's not in the mainline tree. Do you want to keep the
original for that on your git server too?

Regards,

Tony


> From 7b62c1b04ae50adf2827fb3ca1ec8a3e72349d14 Mon Sep 17 00:00:00 2001
> From: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
> Date: Sat, 22 Nov 2008 02:28:36 +0200
> Subject: [PATCH 02/10] omap mailbox: add initial omap3 support
> 
> Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
> ---
>  arch/arm/mach-omap2/devices.c              |   36 +++++++++++++++++-----
>  arch/arm/mach-omap2/mailbox.c              |   46 ++++++++++++++++++----------
>  arch/arm/plat-omap/Kconfig                 |    2 +-
>  arch/arm/plat-omap/include/mach/irqs.h     |    1 +
>  arch/arm/plat-omap/include/mach/omap34xx.h |    2 +-
>  5 files changed, 61 insertions(+), 26 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
> index 241e418..ea37f37 100644
> --- a/arch/arm/mach-omap2/devices.c
> +++ b/arch/arm/mach-omap2/devices.c
> @@ -84,13 +84,14 @@ static inline void omap_init_camera(void)
>  }
>  #endif
>  
> -#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,
>  	},
>  	{
> @@ -103,20 +104,39 @@ 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_34XX_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 {
> +		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)
>  
> diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
> index 5ff2ed8..261cd79 100644
> --- a/arch/arm/mach-omap2/mailbox.c
> +++ b/arch/arm/mach-omap2/mailbox.c
> @@ -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((void __iomem *)(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, (void __iomem *)(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,52 +229,66 @@ 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;
> -	}
> -
>  	/* MBOX base */
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	if (unlikely(!res)) {
>  		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 */
> +	/* DSP or IVA2 IRQ */
>  	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
>  	if (unlikely(!res)) {
>  		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);
> +	if (!ret)
> +		goto err_dsp;
>  
> +#if defined(CONFIG_ARCH_OMAP2420)
>  	/* IVA IRQ */
>  	res = platform_get_resource(pdev, IORESOURCE_IRQ, 1);
>  	if (unlikely(!res)) {
>  		dev_err(&pdev->dev, "invalid irq resource\n");
> -		return -ENODEV;
> +		ret = -ENODEV;
> +		goto err_iva1;
>  	}
>  	mbox_iva_info.irq = res->start;
>  
>  	ret = omap_mbox_register(&mbox_iva_info);
> +	if (!ret)
> +		goto err_iva1;
> +#endif
> +	return ret;
>  
> +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;
>  }
>  
> diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
> index 960c13f..2465aea 100644
> --- a/arch/arm/plat-omap/Kconfig
> +++ b/arch/arm/plat-omap/Kconfig
> @@ -180,7 +180,7 @@ config OMAP_MBOX_FWK
>  	default n
>  	help
>  	  Say Y here if you want to use OMAP Mailbox framework support for
> -	  DSP and IVA1.0 in OMAP1/2.
> +	  DSP, IVA1.0 and IVA2 in OMAP1/2/3.
>  
>  choice
>          prompt "System timer"
> diff --git a/arch/arm/plat-omap/include/mach/irqs.h b/arch/arm/plat-omap/include/mach/irqs.h
> index d12c39f..74f58c6 100644
> --- a/arch/arm/plat-omap/include/mach/irqs.h
> +++ b/arch/arm/plat-omap/include/mach/irqs.h
> @@ -315,6 +315,7 @@
>  #define INT_34XX_MCBSP3_IRQ	22
>  #define INT_34XX_MCBSP4_IRQ	23
>  #define INT_34XX_CAM_IRQ	24
> +#define INT_34XX_MAIL_U0_MPU	26
>  #define INT_34XX_MCBSP5_IRQ	27
>  #define INT_34XX_GPIO_BANK1	29
>  #define INT_34XX_GPIO_BANK2	30
> diff --git a/arch/arm/plat-omap/include/mach/omap34xx.h b/arch/arm/plat-omap/include/mach/omap34xx.h
> index 0a137c1..afd0f6c 100644
> --- a/arch/arm/plat-omap/include/mach/omap34xx.h
> +++ b/arch/arm/plat-omap/include/mach/omap34xx.h
> @@ -63,8 +63,8 @@
>  #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)
>  #define OMAP34XX_CAMERA_BASE		(L4_34XX_BASE + 0xBC000)
> -
>  #endif
>  
>  #define OMAP34XX_DSP_BASE	0x58000000
> -- 
> 1.6.0.3.613.g9f8f13
> 

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 02/10] omap mailbox: add initial omap3 support
  2008-11-26 18:36         ` Tony Lindgren
@ 2008-11-27 14:39           ` Hiroshi DOYU
  0 siblings, 0 replies; 23+ messages in thread
From: Hiroshi DOYU @ 2008-11-27 14:39 UTC (permalink / raw)
  To: tony; +Cc: linux-omap

Hi Tony,

From: "ext Tony Lindgren" <tony@atomide.com>
Subject: Re: [PATCH 02/10] omap mailbox: add initial omap3 support
Date: Wed, 26 Nov 2008 10:36:14 -0800

<snip>

> Thanks, since this is a large series, can you please send your series for
> RMK to integrate to LAKML? Make sure it also applies against mainline
> first :) Please feel free to add my Ack to your patches.

OK. I'll try, anyway.

> > Also, the latest patchset is available in the git repository at:
> > 
> >   http://git.gitorious.org/lk/mainline.git mailbox
> 
> Thanks, I've added mirroring for this branch to my kernel.org tree.
> Let's wait for ack from RMK before integrating it to l-o.
> 
> BTW, we should move dspgateway also into a separate branch like
> tidspbridge as it's not in the mainline tree. Do you want to keep the
> original for that on your git server too?

I agreed that "dspgateway" is to be moved into one of branches and
this would be enough for the moment since I don't think that I have
time to work on "dspgateway" newly.

    Hiroshi DOYU

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 02/10] omap mailbox: add initial omap3 support
  2009-01-16  8:27 [PATCH 00/10] arm: omap mailbox: add omap3 support with some fixes Hiroshi DOYU
@ 2009-01-16  8:27 ` Hiroshi DOYU
  2009-01-16 15:43   ` Felipe Balbi
  0 siblings, 1 reply; 23+ messages in thread
From: Hiroshi DOYU @ 2009-01-16  8:27 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-arm-kernel, linux-omap

Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
---

 arch/arm/mach-omap2/devices.c              |   36 ++++++++++++----
 arch/arm/mach-omap2/mailbox.c              |   65 +++++++++++++++++-----------
 arch/arm/plat-omap/Kconfig                 |    8 +++
 arch/arm/plat-omap/include/mach/omap34xx.h |    1 
 4 files changed, 77 insertions(+), 33 deletions(-)

diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 9d7216f..05baccd 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -28,13 +28,14 @@
 #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,39 @@ 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 {
+		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)
 
diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
index 0609e2d..3176bb7 100644
--- a/arch/arm/mach-omap2/mailbox.c
+++ b/arch/arm/mach-omap2/mailbox.c
@@ -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,54 @@ 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 */
+	/* DSP or IVA2 IRQ */
 	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	if (unlikely(!res)) {
 		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;
 }
 
diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index 46d3b0b..6b1d506 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -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
diff --git a/arch/arm/plat-omap/include/mach/omap34xx.h b/arch/arm/plat-omap/include/mach/omap34xx.h
index 8e0479f..89173f1 100644
--- a/arch/arm/plat-omap/include/mach/omap34xx.h
+++ b/arch/arm/plat-omap/include/mach/omap34xx.h
@@ -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
 


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH 02/10] omap mailbox: add initial omap3 support
  2009-01-16  8:27 ` [PATCH 02/10] omap mailbox: add initial omap3 support Hiroshi DOYU
@ 2009-01-16 15:43   ` Felipe Balbi
  0 siblings, 0 replies; 23+ messages in thread
From: Felipe Balbi @ 2009-01-16 15:43 UTC (permalink / raw)
  To: Hiroshi DOYU; +Cc: linux-kernel, linux-arm-kernel, linux-omap

Hi Hiroshi,

On Fri, Jan 16, 2009 at 10:27:11AM +0200, Hiroshi DOYU wrote:
>  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 {

how about a pr_info() or pr_err() here ?? Something like:
pr_err("%s: platform not supported yet\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)
>  
> diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
> index 0609e2d..3176bb7 100644
> --- a/arch/arm/mach-omap2/mailbox.c
> +++ b/arch/arm/mach-omap2/mailbox.c
> @@ -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 */

would be nice to have something like if (cpu_has_iva()) { ... } and move
this check to a later location e.g. on probe(), but this wouldn't prevent
this patch from going in now. Just a suggestion for later improvements.

>  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

[snip]

> -	/* 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);

platform_get_irq(pdev, 0) would look more standard, I think.

-- 
balbi

^ permalink raw reply	[flat|nested] 23+ messages in thread

* RE: [PATCH 02/10] omap mailbox: add initial omap3 support
  2008-11-25  9:39   ` [PATCH 02/10] omap mailbox: add initial omap3 support Hiroshi DOYU
  2008-11-25  9:39     ` [PATCH 03/10] omap mailbox: print hardware revision at startup Hiroshi DOYU
  2008-11-25 21:54     ` [PATCH 02/10] omap mailbox: add initial omap3 support Tony Lindgren
@ 2009-01-21 20:02     ` Kanigeri, Hari
  2009-01-21 22:45       ` Hiroshi DOYU
  2 siblings, 1 reply; 23+ messages in thread
From: Kanigeri, Hari @ 2009-01-21 20:02 UTC (permalink / raw)
  To: Hiroshi DOYU, linux-omap@vger.kernel.org

Hi Doyu-san,

Can we add the function to return number of messages in the mailbox ?

Thank you,
Best regards,
Hari

> -----Original Message-----
> From: linux-omap-owner@vger.kernel.org [mailto:linux-omap-
> owner@vger.kernel.org] On Behalf Of Hiroshi DOYU
> Sent: Tuesday, November 25, 2008 3:40 AM
> To: linux-omap@vger.kernel.org
> Cc: Hiroshi DOYU
> Subject: [PATCH 02/10] omap mailbox: add initial omap3 support
> 
> Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
> ---
>  arch/arm/mach-omap2/devices.c              |   24 +++++++++++---
>  arch/arm/mach-omap2/mailbox.c              |   46 ++++++++++++++++++-----
> -----
>  arch/arm/plat-omap/Kconfig                 |    2 +-
>  arch/arm/plat-omap/include/mach/irqs.h     |    1 +
>  arch/arm/plat-omap/include/mach/omap34xx.h |    2 +-
>  5 files changed, 52 insertions(+), 23 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
> index 241e418..d385f0f 100644
> --- a/arch/arm/mach-omap2/devices.c
> +++ b/arch/arm/mach-omap2/devices.c
> @@ -84,13 +84,15 @@ static inline void omap_init_camera(void)
>  }
>  #endif
> 
> -#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)
> +
> +#define MBOX_REG_SIZE	0x120
> 
>  static struct resource mbox_resources[] = {
> +#if defined(CONFIG_ARCH_OMAP2420)
>  	{
> -		.start		= OMAP2_MBOX_BASE,
> -		.end		= OMAP2_MBOX_BASE + 0x11f,
> +		.start		= OMAP24XX_MAILBOX_BASE,
> +		.end		= OMAP24XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
>  		.flags		= IORESOURCE_MEM,
>  	},
>  	{
> @@ -101,6 +103,18 @@ static struct resource mbox_resources[] = {
>  		.start		= INT_24XX_MAIL_U3_MPU,
>  		.flags		= IORESOURCE_IRQ,
>  	},
> +/* FIXME: if multiple architecture support is necessary */
> +#elif  defined(CONFIG_ARCH_OMAP3)
> +	{
> +		.start		= OMAP34XX_MAILBOX_BASE,
> +		.end		= OMAP34XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
> +		.flags		= IORESOURCE_MEM,
> +	},
> +	{
> +		.start		= INT_34XX_MAIL_U0_MPU,
> +		.flags		= IORESOURCE_IRQ,
> +	},
> +#endif
>  };
> 
>  static struct platform_device mbox_device = {
> @@ -116,7 +130,7 @@ static inline void omap_init_mbox(void)
>  }
>  #else
>  static inline void omap_init_mbox(void) { }
> -#endif
> +#endif /* CONFIG_OMAP_MBOX_FWK */
> 
>  #if defined(CONFIG_OMAP_STI)
> 
> diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
> index 5ff2ed8..261cd79 100644
> --- a/arch/arm/mach-omap2/mailbox.c
> +++ b/arch/arm/mach-omap2/mailbox.c
> @@ -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((void __iomem *)(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, (void __iomem *)(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,52 +229,66 @@ 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;
> -	}
> -
>  	/* MBOX base */
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	if (unlikely(!res)) {
>  		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 */
> +	/* DSP or IVA2 IRQ */
>  	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
>  	if (unlikely(!res)) {
>  		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);
> +	if (!ret)
> +		goto err_dsp;
> 
> +#if defined(CONFIG_ARCH_OMAP2420)
>  	/* IVA IRQ */
>  	res = platform_get_resource(pdev, IORESOURCE_IRQ, 1);
>  	if (unlikely(!res)) {
>  		dev_err(&pdev->dev, "invalid irq resource\n");
> -		return -ENODEV;
> +		ret = -ENODEV;
> +		goto err_iva1;
>  	}
>  	mbox_iva_info.irq = res->start;
> 
>  	ret = omap_mbox_register(&mbox_iva_info);
> +	if (!ret)
> +		goto err_iva1;
> +#endif
> +	return ret;
> 
> +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;
>  }
> 
> diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
> index 960c13f..2465aea 100644
> --- a/arch/arm/plat-omap/Kconfig
> +++ b/arch/arm/plat-omap/Kconfig
> @@ -180,7 +180,7 @@ config OMAP_MBOX_FWK
>  	default n
>  	help
>  	  Say Y here if you want to use OMAP Mailbox framework support for
> -	  DSP and IVA1.0 in OMAP1/2.
> +	  DSP, IVA1.0 and IVA2 in OMAP1/2/3.
> 
>  choice
>          prompt "System timer"
> diff --git a/arch/arm/plat-omap/include/mach/irqs.h b/arch/arm/plat-
> omap/include/mach/irqs.h
> index d12c39f..74f58c6 100644
> --- a/arch/arm/plat-omap/include/mach/irqs.h
> +++ b/arch/arm/plat-omap/include/mach/irqs.h
> @@ -315,6 +315,7 @@
>  #define INT_34XX_MCBSP3_IRQ	22
>  #define INT_34XX_MCBSP4_IRQ	23
>  #define INT_34XX_CAM_IRQ	24
> +#define INT_34XX_MAIL_U0_MPU	26
>  #define INT_34XX_MCBSP5_IRQ	27
>  #define INT_34XX_GPIO_BANK1	29
>  #define INT_34XX_GPIO_BANK2	30
> diff --git a/arch/arm/plat-omap/include/mach/omap34xx.h b/arch/arm/plat-
> omap/include/mach/omap34xx.h
> index 0a137c1..afd0f6c 100644
> --- a/arch/arm/plat-omap/include/mach/omap34xx.h
> +++ b/arch/arm/plat-omap/include/mach/omap34xx.h
> @@ -63,8 +63,8 @@
>  #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)
>  #define OMAP34XX_CAMERA_BASE		(L4_34XX_BASE + 0xBC000)
> -
>  #endif
> 
>  #define OMAP34XX_DSP_BASE	0x58000000
> --
> 1.6.0.3.613.g9f8f13
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 02/10] omap mailbox: add initial omap3 support
  2009-01-21 20:02     ` Kanigeri, Hari
@ 2009-01-21 22:45       ` Hiroshi DOYU
  2009-01-22  5:12         ` Ramesh Gupta Guntha
  0 siblings, 1 reply; 23+ messages in thread
From: Hiroshi DOYU @ 2009-01-21 22:45 UTC (permalink / raw)
  To: h-kanigeri2; +Cc: linux-omap

Hi Hari,

From: "ext Kanigeri, Hari" <h-kanigeri2@ti.com>
Subject: RE: [PATCH 02/10] omap mailbox: add initial omap3 support
Date: Wed, 21 Jan 2009 14:02:05 -0600

> Hi Doyu-san,
> 
> Can we add the function to return number of messages in the mailbox ?

Yes. I assume that you meant the number of h/w fifo.
It would be helpful if you explain the case where this API is used.

> 
> Thank you,
> Best regards,
> Hari
> 
> > -----Original Message-----
> > From: linux-omap-owner@vger.kernel.org [mailto:linux-omap-
> > owner@vger.kernel.org] On Behalf Of Hiroshi DOYU
> > Sent: Tuesday, November 25, 2008 3:40 AM
> > To: linux-omap@vger.kernel.org
> > Cc: Hiroshi DOYU
> > Subject: [PATCH 02/10] omap mailbox: add initial omap3 support
> > 
> > Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
> > ---
> >  arch/arm/mach-omap2/devices.c              |   24 +++++++++++---
> >  arch/arm/mach-omap2/mailbox.c              |   46 ++++++++++++++++++-----
> > -----
> >  arch/arm/plat-omap/Kconfig                 |    2 +-
> >  arch/arm/plat-omap/include/mach/irqs.h     |    1 +
> >  arch/arm/plat-omap/include/mach/omap34xx.h |    2 +-
> >  5 files changed, 52 insertions(+), 23 deletions(-)
> > 
> > diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
> > index 241e418..d385f0f 100644
> > --- a/arch/arm/mach-omap2/devices.c
> > +++ b/arch/arm/mach-omap2/devices.c
> > @@ -84,13 +84,15 @@ static inline void omap_init_camera(void)
> >  }
> >  #endif
> > 
> > -#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)
> > +
> > +#define MBOX_REG_SIZE	0x120
> > 
> >  static struct resource mbox_resources[] = {
> > +#if defined(CONFIG_ARCH_OMAP2420)
> >  	{
> > -		.start		= OMAP2_MBOX_BASE,
> > -		.end		= OMAP2_MBOX_BASE + 0x11f,
> > +		.start		= OMAP24XX_MAILBOX_BASE,
> > +		.end		= OMAP24XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
> >  		.flags		= IORESOURCE_MEM,
> >  	},
> >  	{
> > @@ -101,6 +103,18 @@ static struct resource mbox_resources[] = {
> >  		.start		= INT_24XX_MAIL_U3_MPU,
> >  		.flags		= IORESOURCE_IRQ,
> >  	},
> > +/* FIXME: if multiple architecture support is necessary */
> > +#elif  defined(CONFIG_ARCH_OMAP3)
> > +	{
> > +		.start		= OMAP34XX_MAILBOX_BASE,
> > +		.end		= OMAP34XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
> > +		.flags		= IORESOURCE_MEM,
> > +	},
> > +	{
> > +		.start		= INT_34XX_MAIL_U0_MPU,
> > +		.flags		= IORESOURCE_IRQ,
> > +	},
> > +#endif
> >  };
> > 
> >  static struct platform_device mbox_device = {
> > @@ -116,7 +130,7 @@ static inline void omap_init_mbox(void)
> >  }
> >  #else
> >  static inline void omap_init_mbox(void) { }
> > -#endif
> > +#endif /* CONFIG_OMAP_MBOX_FWK */
> > 
> >  #if defined(CONFIG_OMAP_STI)
> > 
> > diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
> > index 5ff2ed8..261cd79 100644
> > --- a/arch/arm/mach-omap2/mailbox.c
> > +++ b/arch/arm/mach-omap2/mailbox.c
> > @@ -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((void __iomem *)(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, (void __iomem *)(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,52 +229,66 @@ 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;
> > -	}
> > -
> >  	/* MBOX base */
> >  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> >  	if (unlikely(!res)) {
> >  		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 */
> > +	/* DSP or IVA2 IRQ */
> >  	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
> >  	if (unlikely(!res)) {
> >  		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);
> > +	if (!ret)
> > +		goto err_dsp;
> > 
> > +#if defined(CONFIG_ARCH_OMAP2420)
> >  	/* IVA IRQ */
> >  	res = platform_get_resource(pdev, IORESOURCE_IRQ, 1);
> >  	if (unlikely(!res)) {
> >  		dev_err(&pdev->dev, "invalid irq resource\n");
> > -		return -ENODEV;
> > +		ret = -ENODEV;
> > +		goto err_iva1;
> >  	}
> >  	mbox_iva_info.irq = res->start;
> > 
> >  	ret = omap_mbox_register(&mbox_iva_info);
> > +	if (!ret)
> > +		goto err_iva1;
> > +#endif
> > +	return ret;
> > 
> > +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;
> >  }
> > 
> > diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
> > index 960c13f..2465aea 100644
> > --- a/arch/arm/plat-omap/Kconfig
> > +++ b/arch/arm/plat-omap/Kconfig
> > @@ -180,7 +180,7 @@ config OMAP_MBOX_FWK
> >  	default n
> >  	help
> >  	  Say Y here if you want to use OMAP Mailbox framework support for
> > -	  DSP and IVA1.0 in OMAP1/2.
> > +	  DSP, IVA1.0 and IVA2 in OMAP1/2/3.
> > 
> >  choice
> >          prompt "System timer"
> > diff --git a/arch/arm/plat-omap/include/mach/irqs.h b/arch/arm/plat-
> > omap/include/mach/irqs.h
> > index d12c39f..74f58c6 100644
> > --- a/arch/arm/plat-omap/include/mach/irqs.h
> > +++ b/arch/arm/plat-omap/include/mach/irqs.h
> > @@ -315,6 +315,7 @@
> >  #define INT_34XX_MCBSP3_IRQ	22
> >  #define INT_34XX_MCBSP4_IRQ	23
> >  #define INT_34XX_CAM_IRQ	24
> > +#define INT_34XX_MAIL_U0_MPU	26
> >  #define INT_34XX_MCBSP5_IRQ	27
> >  #define INT_34XX_GPIO_BANK1	29
> >  #define INT_34XX_GPIO_BANK2	30
> > diff --git a/arch/arm/plat-omap/include/mach/omap34xx.h b/arch/arm/plat-
> > omap/include/mach/omap34xx.h
> > index 0a137c1..afd0f6c 100644
> > --- a/arch/arm/plat-omap/include/mach/omap34xx.h
> > +++ b/arch/arm/plat-omap/include/mach/omap34xx.h
> > @@ -63,8 +63,8 @@
> >  #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)
> >  #define OMAP34XX_CAMERA_BASE		(L4_34XX_BASE + 0xBC000)
> > -
> >  #endif
> > 
> >  #define OMAP34XX_DSP_BASE	0x58000000
> > --
> > 1.6.0.3.613.g9f8f13
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 02/10] omap mailbox: add initial omap3 support
  2009-01-21 22:45       ` Hiroshi DOYU
@ 2009-01-22  5:12         ` Ramesh Gupta Guntha
  2009-01-22  6:10           ` Hiroshi DOYU
  0 siblings, 1 reply; 23+ messages in thread
From: Ramesh Gupta Guntha @ 2009-01-22  5:12 UTC (permalink / raw)
  To: Hiroshi DOYU; +Cc: h-kanigeri2, linux-omap

Hi Hiroshi,


On 1/22/09, Hiroshi DOYU <Hiroshi.DOYU@nokia.com> wrote:
> Hi Hari,
>
> From: "ext Kanigeri, Hari" <h-kanigeri2@ti.com>
> Subject: RE: [PATCH 02/10] omap mailbox: add initial omap3 support
> Date: Wed, 21 Jan 2009 14:02:05 -0600
>
> > Hi Doyu-san,
> >
> > Can we add the function to return number of messages in the mailbox ?
>
> Yes. I assume that you meant the number of h/w fifo.
> It would be helpful if you explain the case where this API is used.

This is to make sure that mail box fifo is not full before trying to
write a new message, if it is full for any reason, one can wait for a
while until fifo is empty.

thanks
Ramesh Gupta G




> > > -----Original Message-----
> > > From: linux-omap-owner@vger.kernel.org [mailto:linux-omap-
> > > owner@vger.kernel.org] On Behalf Of Hiroshi DOYU
> > > Sent: Tuesday, November 25, 2008 3:40 AM
> > > To: linux-omap@vger.kernel.org
> > > Cc: Hiroshi DOYU
> > > Subject: [PATCH 02/10] omap mailbox: add initial omap3 support
> > >
> > > Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
> > > ---
> > >  arch/arm/mach-omap2/devices.c              |   24 +++++++++++---
> > >  arch/arm/mach-omap2/mailbox.c              |   46 ++++++++++++++++++-----
> > > -----
> > >  arch/arm/plat-omap/Kconfig                 |    2 +-
> > >  arch/arm/plat-omap/include/mach/irqs.h     |    1 +
> > >  arch/arm/plat-omap/include/mach/omap34xx.h |    2 +-
> > >  5 files changed, 52 insertions(+), 23 deletions(-)
> > >
> > > diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
> > > index 241e418..d385f0f 100644
> > > --- a/arch/arm/mach-omap2/devices.c
> > > +++ b/arch/arm/mach-omap2/devices.c
> > > @@ -84,13 +84,15 @@ static inline void omap_init_camera(void)
> > >  }
> > >  #endif
> > >
> > > -#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)
> > > +
> > > +#define MBOX_REG_SIZE      0x120
> > >
> > >  static struct resource mbox_resources[] = {
> > > +#if defined(CONFIG_ARCH_OMAP2420)
> > >     {
> > > -           .start          = OMAP2_MBOX_BASE,
> > > -           .end            = OMAP2_MBOX_BASE + 0x11f,
> > > +           .start          = OMAP24XX_MAILBOX_BASE,
> > > +           .end            = OMAP24XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
> > >             .flags          = IORESOURCE_MEM,
> > >     },
> > >     {
> > > @@ -101,6 +103,18 @@ static struct resource mbox_resources[] = {
> > >             .start          = INT_24XX_MAIL_U3_MPU,
> > >             .flags          = IORESOURCE_IRQ,
> > >     },
> > > +/* FIXME: if multiple architecture support is necessary */
> > > +#elif  defined(CONFIG_ARCH_OMAP3)
> > > +   {
> > > +           .start          = OMAP34XX_MAILBOX_BASE,
> > > +           .end            = OMAP34XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
> > > +           .flags          = IORESOURCE_MEM,
> > > +   },
> > > +   {
> > > +           .start          = INT_34XX_MAIL_U0_MPU,
> > > +           .flags          = IORESOURCE_IRQ,
> > > +   },
> > > +#endif
> > >  };
> > >
> > >  static struct platform_device mbox_device = {
> > > @@ -116,7 +130,7 @@ static inline void omap_init_mbox(void)
> > >  }
> > >  #else
> > >  static inline void omap_init_mbox(void) { }
> > > -#endif
> > > +#endif /* CONFIG_OMAP_MBOX_FWK */
> > >
> > >  #if defined(CONFIG_OMAP_STI)
> > >
> > > diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
> > > index 5ff2ed8..261cd79 100644
> > > --- a/arch/arm/mach-omap2/mailbox.c
> > > +++ b/arch/arm/mach-omap2/mailbox.c
> > > @@ -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((void __iomem *)(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, (void __iomem *)(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,52 +229,66 @@ 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;
> > > -   }
> > > -
> > >     /* MBOX base */
> > >     res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > >     if (unlikely(!res)) {
> > >             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 */
> > > +   /* DSP or IVA2 IRQ */
> > >     res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
> > >     if (unlikely(!res)) {
> > >             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);
> > > +   if (!ret)
> > > +           goto err_dsp;
> > >
> > > +#if defined(CONFIG_ARCH_OMAP2420)
> > >     /* IVA IRQ */
> > >     res = platform_get_resource(pdev, IORESOURCE_IRQ, 1);
> > >     if (unlikely(!res)) {
> > >             dev_err(&pdev->dev, "invalid irq resource\n");
> > > -           return -ENODEV;
> > > +           ret = -ENODEV;
> > > +           goto err_iva1;
> > >     }
> > >     mbox_iva_info.irq = res->start;
> > >
> > >     ret = omap_mbox_register(&mbox_iva_info);
> > > +   if (!ret)
> > > +           goto err_iva1;
> > > +#endif
> > > +   return ret;
> > >
> > > +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;
> > >  }
> > >
> > > diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
> > > index 960c13f..2465aea 100644
> > > --- a/arch/arm/plat-omap/Kconfig
> > > +++ b/arch/arm/plat-omap/Kconfig
> > > @@ -180,7 +180,7 @@ config OMAP_MBOX_FWK
> > >     default n
> > >     help
> > >       Say Y here if you want to use OMAP Mailbox framework support for
> > > -     DSP and IVA1.0 in OMAP1/2.
> > > +     DSP, IVA1.0 and IVA2 in OMAP1/2/3.
> > >
> > >  choice
> > >          prompt "System timer"
> > > diff --git a/arch/arm/plat-omap/include/mach/irqs.h b/arch/arm/plat-
> > > omap/include/mach/irqs.h
> > > index d12c39f..74f58c6 100644
> > > --- a/arch/arm/plat-omap/include/mach/irqs.h
> > > +++ b/arch/arm/plat-omap/include/mach/irqs.h
> > > @@ -315,6 +315,7 @@
> > >  #define INT_34XX_MCBSP3_IRQ        22
> > >  #define INT_34XX_MCBSP4_IRQ        23
> > >  #define INT_34XX_CAM_IRQ   24
> > > +#define INT_34XX_MAIL_U0_MPU       26
> > >  #define INT_34XX_MCBSP5_IRQ        27
> > >  #define INT_34XX_GPIO_BANK1        29
> > >  #define INT_34XX_GPIO_BANK2        30
> > > diff --git a/arch/arm/plat-omap/include/mach/omap34xx.h b/arch/arm/plat-
> > > omap/include/mach/omap34xx.h
> > > index 0a137c1..afd0f6c 100644
> > > --- a/arch/arm/plat-omap/include/mach/omap34xx.h
> > > +++ b/arch/arm/plat-omap/include/mach/omap34xx.h
> > > @@ -63,8 +63,8 @@
> > >  #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)
> > >  #define OMAP34XX_CAMERA_BASE               (L4_34XX_BASE + 0xBC000)
> > > -
> > >  #endif
> > >
> > >  #define OMAP34XX_DSP_BASE  0x58000000
> > > --
> > > 1.6.0.3.613.g9f8f13
> > >
> > > --
> > > To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> > > the body of a message to majordomo@vger.kernel.org
> > > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>


-- 
Thanks
Ramesh Gupta G

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 02/10] omap mailbox: add initial omap3 support
  2009-01-22  5:12         ` Ramesh Gupta Guntha
@ 2009-01-22  6:10           ` Hiroshi DOYU
  0 siblings, 0 replies; 23+ messages in thread
From: Hiroshi DOYU @ 2009-01-22  6:10 UTC (permalink / raw)
  To: grgupta77; +Cc: h-kanigeri2, linux-omap

Hi Ramesh,

From: "ext Ramesh Gupta Guntha" <grgupta77@gmail.com>
Subject: Re: [PATCH 02/10] omap mailbox: add initial omap3 support
Date: Thu, 22 Jan 2009 10:42:52 +0530

> Hi Hiroshi,
> 
> 
> On 1/22/09, Hiroshi DOYU <Hiroshi.DOYU@nokia.com> wrote:
> > Hi Hari,
> >
> > From: "ext Kanigeri, Hari" <h-kanigeri2@ti.com>
> > Subject: RE: [PATCH 02/10] omap mailbox: add initial omap3 support
> > Date: Wed, 21 Jan 2009 14:02:05 -0600
> >
> > > Hi Doyu-san,
> > >
> > > Can we add the function to return number of messages in the mailbox ?
> >
> > Yes. I assume that you meant the number of h/w fifo.
> > It would be helpful if you explain the case where this API is used.
> 
> This is to make sure that mail box fifo is not full before trying to
> write a new message, if it is full for any reason, one can wait for a
> while until fifo is empty.

In the current mailbox implementation, the (request)queue is provided
in order to avoid the situation where client/user has to wait until
fifo is available. And then, a kernel thread tries to put each request
into h/w fifo. If h/w fifo is full, it tries later again.

So I think that there's no need for client side to care about the
availability of h/w fifo, but there's a case that s/w queue isn't
avaiable because of the lack of memory, then client has to sleep or
try again. This is quite unlikely, though.

     Hiroshi DOYU

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2009-01-22  6:10 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-25  9:39 [PATCH 0/10] omap mailbox driver update with omap3 support Hiroshi DOYU
2008-11-25  9:39 ` [PATCH 01/10] omap mailbox: cleanup omap2 register definition with macro Hiroshi DOYU
2008-11-25  9:39   ` [PATCH 02/10] omap mailbox: add initial omap3 support Hiroshi DOYU
2008-11-25  9:39     ` [PATCH 03/10] omap mailbox: print hardware revision at startup Hiroshi DOYU
2008-11-25  9:39       ` [PATCH 04/10] omap mailbox: fix empty struct device for omap_mbox Hiroshi DOYU
2008-11-25  9:39         ` [PATCH 05/10] omap mailbox: fix empty struct device for omap1 Hiroshi DOYU
2008-11-25  9:39           ` [PATCH 06/10] omap mailbox: fix empty struct device for omap2 Hiroshi DOYU
2008-11-25  9:39             ` [PATCH 07/10] omap mailbox: add save_/restore_ctx() for PM Hiroshi DOYU
2008-11-25  9:39               ` [PATCH 08/10] omap mailbox: move mailbox.h into mailbox.c Hiroshi DOYU
2008-11-25  9:39                 ` [PATCH 09/10] omap mailbox: convert sequence bit checking to module paramter Hiroshi DOYU
2008-11-25  9:39                   ` [PATCH 10/10] omap mailbox: remove unnecessary header file inclusion Hiroshi DOYU
2008-11-25  9:44           ` [PATCH 05/10] omap mailbox: fix empty struct device for omap1 Felipe Balbi
2008-11-25 11:13             ` Hiroshi DOYU
2008-11-25 21:54     ` [PATCH 02/10] omap mailbox: add initial omap3 support Tony Lindgren
2008-11-26  0:10       ` Hiroshi DOYU
2008-11-26 18:36         ` Tony Lindgren
2008-11-27 14:39           ` Hiroshi DOYU
2009-01-21 20:02     ` Kanigeri, Hari
2009-01-21 22:45       ` Hiroshi DOYU
2009-01-22  5:12         ` Ramesh Gupta Guntha
2009-01-22  6:10           ` Hiroshi DOYU
  -- strict thread matches above, loose matches on Subject: below --
2009-01-16  8:27 [PATCH 00/10] arm: omap mailbox: add omap3 support with some fixes Hiroshi DOYU
2009-01-16  8:27 ` [PATCH 02/10] omap mailbox: add initial omap3 support Hiroshi DOYU
2009-01-16 15:43   ` Felipe Balbi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox