Skip to contentSkip to conversation

omap: mailbox: reorganize init

PATCH Superseded Felipe Contreras 5 participants 31 messages May 14, 2010 – May 21, 2010

Subsystems (4)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover omap: mailbox: reorganize init

Hi,

The main purpose of this patch series is to be able to compile mach platform data as built-in. Otherwise, client modules such as bridgedriver will load the platform code, but not the mach code when mailbox is built as a module.

Unfortunately, there's no easy way to do that since plat and mach code are deepely interrelated. So the first patches try to separate the mailbox registering through a defined omap_mbox_platform_data.

Also, it's worth noting that mailboxes are not a one-to-one mapping to resources; that is, some resources belong to multiple mboxes. So it's best to think of mailboxes as fake devices. That is why custom platform_data is required.

Finally, a bunch of cleaning up is done in the very first patches, specially for OMAP1.

The initial RFC included comments from Felipe Balbi, and this proposal includes comments from Tony Lindgren.

v2:
* Rebased on top of Hiroshi's v2.6.34-rc7.mailbox
* A bit more extra cleanups

v1 was tested on OMAP3 (beagleboard), and compiled-tested for OMAP1. v2 was compile-tested for OMAP3 and 1.

Felipe Contreras (17):
omap: mailbox: trivial whitespace cleanups
omap: mailbox: trivial cleanups
omap: mailbox: reorganize structures
omap: mailbox: 2420 should be detected at run-time
omap: mailbox: use correct config for omap1
omap: mailbox: update omap1 probing
omap: mailbox: reorganize registering
omap: mailbox: only compile for configured archs
omap: mailbox: reorganize omap platform_device
omap: mailbox: move more stuff to omap_mbox_init()
omap: mailbox: trivial sync between omap1 and 2
omap: mailbox: split platform driver
omap: mailbox: always built-in platform data
omap: mailbox: reorganize headers
omap: mailbox: don't export unecessary symbols
omap: mailbox: mark some resources as __initdata
omap: mailbox: don't export register/unregister

 arch/arm/mach-omap1/Makefile              |    6 +-
 arch/arm/mach-omap1/devices.c             |   40 -----
 arch/arm/mach-omap1/mailbox.c             |  118 ++++++++------
 arch/arm/mach-omap2/Makefile              |    5 +-
 arch/arm/mach-omap2/devices.c             |   92 -----------
 arch/arm/mach-omap2/mailbox.c             |  254 ++++++++++++++++-------------
 arch/arm/plat-omap/include/plat/mailbox.h |   10 +-
 arch/arm/plat-omap/mailbox.c              |   89 +++++++---
 8 files changed, 290 insertions(+), 324 deletions(-)
#1 lore raw

PATCH v2 1/17 omap: mailbox: trivial whitespace cleanups

---

FWIW I think this should be squashed to the commits that introduced these problems.

 arch/arm/plat-omap/mailbox.c |   32 ++++++++++++++++----------------
 1 files changed, 16 insertions(+), 16 deletions(-)
arch/arm/plat-omap/mailbox.c +16 -16
index c549af3..8cb82c7 100644
@@ -142,14 +142,14 @@ static void mbox_rx_work(struct work_struct *work)
 	struct omap_mbox_queue *mq =
 			container_of(work, struct omap_mbox_queue, work);
 	mbox_msg_t msg;
- 	int len;
-  
- 	while (kfifo_len(&mq->fifo) >= sizeof(msg)) {
- 		len = kfifo_out(&mq->fifo, (unsigned char *)&msg, sizeof(msg));
- 		WARN_ON(len != sizeof(msg));
-
- 		if (mq->callback)
- 			mq->callback((void *)msg);
+	int len;
+
+	while (kfifo_len(&mq->fifo) >= sizeof(msg)) {
+		len = kfifo_out(&mq->fifo, (unsigned char *)&msg, sizeof(msg));
+		WARN_ON(len != sizeof(msg));
+
+		if (mq->callback)
+			mq->callback((void *)msg);
 	}
 }
 
@@ -165,12 +165,12 @@ static void __mbox_tx_interrupt(struct omap_mbox *mbox)
 
 static void __mbox_rx_interrupt(struct omap_mbox *mbox)
 {
- 	struct omap_mbox_queue *mq = mbox->rxq;
+	struct omap_mbox_queue *mq = mbox->rxq;
 	mbox_msg_t msg;
- 	int len;
+	int len;
 
 	while (!mbox_fifo_empty(mbox)) {
- 		if (unlikely(kfifo_avail(&mq->fifo) < sizeof(msg))) {
+		if (unlikely(kfifo_avail(&mq->fifo) < sizeof(msg))) {
 			omap_mbox_disable_irq(mbox, IRQ_RX);
 			rq_full = true;
 			goto nomem;
@@ -178,8 +178,8 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox)
 
 		msg = mbox_fifo_read(mbox);
 
- 		len = kfifo_in(&mq->fifo, (unsigned char *)&msg, sizeof(msg));
- 		WARN_ON(len != sizeof(msg));
+		len = kfifo_in(&mq->fifo, (unsigned char *)&msg, sizeof(msg));
+		WARN_ON(len != sizeof(msg));
 
 		if (mbox->ops->type == OMAP_MBOX_TYPE1)
 			break;
@@ -278,11 +278,11 @@ static int omap_mbox_startup(struct omap_mbox *mbox)
 
 	return 0;
 
- fail_alloc_rxq:
+fail_alloc_rxq:
 	mbox_queue_free(mbox->txq);
- fail_alloc_txq:
+fail_alloc_txq:
 	free_irq(mbox->irq, mbox);
- fail_request_irq:
+fail_request_irq:
 	if (mbox->ops->shutdown)
 		mbox->ops->shutdown(mbox);
 
Signature · 1 line
1.7.1
#2 lore raw

PATCH v2 2/17 omap: mailbox: trivial cleanups

In reply to Felipe Contreras

And fix a few compilation warnings.

---
 arch/arm/mach-omap1/devices.c |    6 ++----
 arch/arm/mach-omap1/mailbox.c |    2 +-
 arch/arm/mach-omap2/mailbox.c |    8 +++++---
 3 files changed, 8 insertions(+), 8 deletions(-)
arch/arm/mach-omap1/devices.c +2 -4
index 379100c..462b59c 100644
@@ -73,12 +73,10 @@ static inline void omap_init_rtc(void) {}
 #  define INT_DSP_MAILBOX1	INT_1610_DSP_MAILBOX1
 #endif
 
-#define OMAP1_MBOX_BASE		OMAP16XX_MAILBOX_BASE
-
 static struct resource mbox_resources[] = {
 	{
-		.start		= OMAP1_MBOX_BASE,
-		.end		= OMAP1_MBOX_BASE + OMAP1_MBOX_SIZE,
+		.start		= OMAP16XX_MAILBOX_BASE,
+		.end		= OMAP16XX_MAILBOX_BASE + OMAP1_MBOX_SIZE,
 		.flags		= IORESOURCE_MEM,
 	},
 	{
arch/arm/mach-omap1/mailbox.c +1 -1
index 4f5b3da..15bf2a2 100644
@@ -83,7 +83,7 @@ static int omap1_mbox_fifo_full(struct omap_mbox *mbox)
 	struct omap_mbox1_fifo *fifo =
 		&((struct omap_mbox1_priv *)mbox->priv)->rx_fifo;
 
-	return (mbox_read_reg(fifo->flag));
+	return mbox_read_reg(fifo->flag);
 }
 
 /* irq */
arch/arm/mach-omap2/mailbox.c +5 -3
index 763272c..c9f3d39 100644
@@ -300,8 +300,6 @@ static struct omap_mbox2_priv omap2_mbox_dsp_priv = {
 	.irqdisable	= MAILBOX_IRQENABLE(0),
 };
 
-
-
 /* OMAP4 specific data structure. Use the cpu_is_omap4xxx()
 to use this*/
 static struct omap_mbox2_priv omap2_mbox_1_priv = {
@@ -357,7 +355,6 @@ struct omap_mbox mbox_2_info = {
 };
 EXPORT_SYMBOL(mbox_2_info);
 
-
 #if defined(CONFIG_ARCH_OMAP2420) /* IVA */
 static struct omap_mbox2_priv omap2_mbox_iva_priv = {
 	.tx_fifo = {
@@ -443,6 +440,11 @@ static int __devinit omap2_mbox_probe(struct platform_device *pdev)
 #endif
 	return 0;
 
+#if defined(CONFIG_ARCH_OMAP2420) /* IVA */
+err_iva1:
+	omap_mbox_unregister(&mbox_dsp_info);
+#endif
+
 err_dsp:
 	iounmap(mbox_base);
 	return ret;
Signature · 1 line
1.7.1
#3 lore raw

PATCH v2 3/17 omap: mailbox: reorganize structures

In reply to Felipe Contreras

OMAP4 ones messed up the organization.

---
 arch/arm/mach-omap2/mailbox.c |   68 +++++++++++++++++++++--------------------
 1 files changed, 35 insertions(+), 33 deletions(-)
arch/arm/mach-omap2/mailbox.c +35 -33
index c9f3d39..7d42034 100644
@@ -283,6 +283,7 @@ static struct omap_mbox_ops omap2_mbox_ops = {
  */
 
 /* FIXME: the following structs should be filled automatically by the user id */
+
 /* DSP */
 static struct omap_mbox2_priv omap2_mbox_dsp_priv = {
 	.tx_fifo = {
@@ -300,8 +301,40 @@ static struct omap_mbox2_priv omap2_mbox_dsp_priv = {
 	.irqdisable	= MAILBOX_IRQENABLE(0),
 };
 
-/* OMAP4 specific data structure. Use the cpu_is_omap4xxx()
-to use this*/
+struct omap_mbox mbox_dsp_info = {
+	.name	= "dsp",
+	.ops	= &omap2_mbox_ops,
+	.priv	= &omap2_mbox_dsp_priv,
+};
+EXPORT_SYMBOL(mbox_dsp_info);
+
+#if defined(CONFIG_ARCH_OMAP2420)
+
+/* IVA */
+static struct omap_mbox2_priv omap2_mbox_iva_priv = {
+	.tx_fifo = {
+		.msg		= MAILBOX_MESSAGE(2),
+		.fifo_stat	= MAILBOX_FIFOSTATUS(2),
+	},
+	.rx_fifo = {
+		.msg		= MAILBOX_MESSAGE(3),
+		.msg_stat	= MAILBOX_MSGSTATUS(3),
+	},
+	.irqenable	= MAILBOX_IRQENABLE(3),
+	.irqstatus	= MAILBOX_IRQSTATUS(3),
+	.notfull_bit	= MAILBOX_IRQ_NOTFULL(2),
+	.newmsg_bit	= MAILBOX_IRQ_NEWMSG(3),
+	.irqdisable	= MAILBOX_IRQENABLE(3),
+};
+
+static struct omap_mbox mbox_iva_info = {
+	.name	= "iva",
+	.ops	= &omap2_mbox_ops,
+	.priv	= &omap2_mbox_iva_priv,
+};
+#endif
+
+/* OMAP4 */
 static struct omap_mbox2_priv omap2_mbox_1_priv = {
 	.tx_fifo = {
 		.msg		= MAILBOX_MESSAGE(0),
@@ -325,13 +358,6 @@ struct omap_mbox mbox_1_info = {
 };
 EXPORT_SYMBOL(mbox_1_info);
 
-struct omap_mbox mbox_dsp_info = {
-	.name	= "dsp",
-	.ops	= &omap2_mbox_ops,
-	.priv	= &omap2_mbox_dsp_priv,
-};
-EXPORT_SYMBOL(mbox_dsp_info);
-
 static struct omap_mbox2_priv omap2_mbox_2_priv = {
 	.tx_fifo = {
 		.msg		= MAILBOX_MESSAGE(3),
@@ -355,30 +381,6 @@ struct omap_mbox mbox_2_info = {
 };
 EXPORT_SYMBOL(mbox_2_info);
 
-#if defined(CONFIG_ARCH_OMAP2420) /* IVA */
-static struct omap_mbox2_priv omap2_mbox_iva_priv = {
-	.tx_fifo = {
-		.msg		= MAILBOX_MESSAGE(2),
-		.fifo_stat	= MAILBOX_FIFOSTATUS(2),
-	},
-	.rx_fifo = {
-		.msg		= MAILBOX_MESSAGE(3),
-		.msg_stat	= MAILBOX_MSGSTATUS(3),
-	},
-	.irqenable	= MAILBOX_IRQENABLE(3),
-	.irqstatus	= MAILBOX_IRQSTATUS(3),
-	.notfull_bit	= MAILBOX_IRQ_NOTFULL(2),
-	.newmsg_bit	= MAILBOX_IRQ_NEWMSG(3),
-	.irqdisable	= MAILBOX_IRQENABLE(3),
-};
-
-static struct omap_mbox mbox_iva_info = {
-	.name	= "iva",
-	.ops	= &omap2_mbox_ops,
-	.priv	= &omap2_mbox_iva_priv,
-};
-#endif
-
 static int __devinit omap2_mbox_probe(struct platform_device *pdev)
 {
 	struct resource *res;
Signature · 1 line
1.7.1
#4 lore raw

PATCH v2 4/17 omap: mailbox: 2420 should be detected at run-time

In reply to Felipe Contreras
---
 arch/arm/mach-omap2/mailbox.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
arch/arm/mach-omap2/mailbox.c +2 -1
index 7d42034..7afc9aa 100644
@@ -455,7 +455,8 @@ err_dsp:
 static int __devexit omap2_mbox_remove(struct platform_device *pdev)
 {
 #if defined(CONFIG_ARCH_OMAP2420)
-	omap_mbox_unregister(&mbox_iva_info);
+	if (cpu_is_omap2420())
+		omap_mbox_unregister(&mbox_iva_info);
 #endif
 
 	if (cpu_is_omap44xx()) {
Signature · 1 line
1.7.1
#5 lore raw

PATCH v2 5/17 omap: mailbox: use correct config for omap1

In reply to Felipe Contreras

CONFIG_OMAP_DSP is not in mainline, CONFIG_OMAP_MBOX_FWK is.

---
 arch/arm/mach-omap1/devices.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/mach-omap1/devices.c +1 -1
index 462b59c..da796f2 100644
@@ -63,7 +63,7 @@ static void omap_init_rtc(void)
 static inline void omap_init_rtc(void) {}
 #endif
 
-#if defined(CONFIG_OMAP_DSP) || defined(CONFIG_OMAP_DSP_MODULE)
+#if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
 
 #if defined(CONFIG_ARCH_OMAP15XX)
 #  define OMAP1_MBOX_SIZE	0x23
Signature · 1 line
1.7.1
#6 lore raw

PATCH v2 6/17 omap: mailbox: update omap1 probing

In reply to Felipe Contreras

Based on omap2 code.

---
 arch/arm/mach-omap1/mailbox.c |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)
arch/arm/mach-omap1/mailbox.c +14 -14
index 15bf2a2..211b9fc 100644
@@ -146,12 +146,7 @@ EXPORT_SYMBOL(mbox_dsp_info);
 static int __devinit omap1_mbox_probe(struct platform_device *pdev)
 {
 	struct resource *res;
-
-	if (pdev->num_resources != 2) {
-		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);
@@ -161,27 +156,32 @@ static int __devinit omap1_mbox_probe(struct platform_device *pdev)
 	}
 
 	mbox_base = ioremap(res->start, resource_size(res));
-	if (!mbox_base) {
-		dev_err(&pdev->dev, "ioremap failed\n");
-		return -ENODEV;
-	}
+	if (!mbox_base)
+		return -ENOMEM;
 
 	/* DSP IRQ */
 	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	if (unlikely(!res)) {
 		dev_err(&pdev->dev, "invalid irq resource\n");
-		iounmap(mbox_base);
-		return -ENODEV;
+		ret = -ENODEV;
+		goto err_out;
 	}
 	mbox_dsp_info.irq = res->start;
 
-	return omap_mbox_register(&pdev->dev, &mbox_dsp_info);
+	ret = omap_mbox_register(&pdev->dev, &mbox_dsp_info);
+	if (ret)
+		goto err_out;
+	return 0;
+
+err_out:
+	iounmap(mbox_base);
+	return ret;
 }
 
 static int __devexit omap1_mbox_remove(struct platform_device *pdev)
 {
 	omap_mbox_unregister(&mbox_dsp_info);
-
+	iounmap(mbox_base);
 	return 0;
 }
 
Signature · 1 line
1.7.1
#7 lore raw

PATCH v2 7/17 omap: mailbox: reorganize registering

In reply to Felipe Contreras

This is a step forward to split the mbox registers.

---
 arch/arm/mach-omap1/mailbox.c |   41 +++++++++--------
 arch/arm/mach-omap2/mailbox.c |  102 +++++++++++++++++------------------------
 2 files changed, 64 insertions(+), 79 deletions(-)
arch/arm/mach-omap1/mailbox.c +22 -19
index 211b9fc..d81b238 100644
@@ -29,6 +29,8 @@
 
 static void __iomem *mbox_base;
 
+static struct omap_mbox **list;
+
 struct omap_mbox1_fifo {
 	unsigned long cmd;
 	unsigned long data;
@@ -143,44 +145,45 @@ struct omap_mbox mbox_dsp_info = {
 };
 EXPORT_SYMBOL(mbox_dsp_info);
 
+struct omap_mbox *omap1_mboxes[] = { &mbox_dsp_info, NULL };
+
 static int __devinit omap1_mbox_probe(struct platform_device *pdev)
 {
 	struct resource *res;
 	int ret;
+	int i;
 
-	/* MBOX base */
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (unlikely(!res)) {
-		dev_err(&pdev->dev, "invalid mem resource\n");
-		return -ENODEV;
-	}
+	res = pdev->resource;
 
-	mbox_base = ioremap(res->start, resource_size(res));
+	mbox_base = ioremap(res[0].start, resource_size(&res[0]));
 	if (!mbox_base)
 		return -ENOMEM;
 
-	/* DSP IRQ */
-	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-	if (unlikely(!res)) {
-		dev_err(&pdev->dev, "invalid irq resource\n");
-		ret = -ENODEV;
-		goto err_out;
-	}
-	mbox_dsp_info.irq = res->start;
+	list = omap1_mboxes;
 
-	ret = omap_mbox_register(&pdev->dev, &mbox_dsp_info);
-	if (ret)
-		goto err_out;
+	list[0]->irq = res[1].start;
+
+	for (i = 0; list[i]; i++) {
+		ret = omap_mbox_register(&pdev->dev, list[i]);
+		if (ret)
+			goto err_out;
+	}
 	return 0;
 
 err_out:
+	while (i--)
+		omap_mbox_unregister(list[i]);
 	iounmap(mbox_base);
 	return ret;
 }
 
 static int __devexit omap1_mbox_remove(struct platform_device *pdev)
 {
-	omap_mbox_unregister(&mbox_dsp_info);
+	int i;
+
+	for (i = 0; list[i]; i++)
+		omap_mbox_unregister(list[i]);
+
 	iounmap(mbox_base);
 	return 0;
 }
arch/arm/mach-omap2/mailbox.c +42 -60

149 lines not on this page · raw message

Signature · 1 line
1.7.1
#8 lore raw

PATCH v2 8/17 omap: mailbox: only compile for configured archs

In reply to Felipe Contreras
---
 arch/arm/mach-omap2/mailbox.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
arch/arm/mach-omap2/mailbox.c +12 -2
index 5dda11c..04b70ba 100644
@@ -286,6 +286,7 @@ static struct omap_mbox_ops omap2_mbox_ops = {
 
 /* FIXME: the following structs should be filled automatically by the user id */
 
+#if defined(CONFIG_ARCH_OMAP3430) || defined(CONFIG_ARCH_OMAP2420)
 /* DSP */
 static struct omap_mbox2_priv omap2_mbox_dsp_priv = {
 	.tx_fifo = {
@@ -309,11 +310,13 @@ struct omap_mbox mbox_dsp_info = {
 	.priv	= &omap2_mbox_dsp_priv,
 };
 EXPORT_SYMBOL(mbox_dsp_info);
+#endif
 
+#if defined(CONFIG_ARCH_OMAP3430)
 struct omap_mbox *omap3_mboxes[] = { &mbox_dsp_info, NULL };
+#endif
 
 #if defined(CONFIG_ARCH_OMAP2420)
-
 /* IVA */
 static struct omap_mbox2_priv omap2_mbox_iva_priv = {
 	.tx_fifo = {
@@ -340,6 +343,7 @@ static struct omap_mbox mbox_iva_info = {
 struct omap_mbox *omap2_mboxes[] = { &mbox_iva_info, &mbox_dsp_info, NULL };
 #endif
 
+#if defined(CONFIG_ARCH_OMAP4)
 /* OMAP4 */
 static struct omap_mbox2_priv omap2_mbox_1_priv = {
 	.tx_fifo = {
@@ -388,6 +392,7 @@ struct omap_mbox mbox_2_info = {
 EXPORT_SYMBOL(mbox_2_info);
 
 struct omap_mbox *omap4_mboxes[] = { &mbox_1_info, &mbox_2_info, NULL };
+#endif
 
 static int __devinit omap2_mbox_probe(struct platform_device *pdev)
 {
@@ -401,11 +406,14 @@ static int __devinit omap2_mbox_probe(struct platform_device *pdev)
 	if (!mbox_base)
 		return -ENOMEM;
 
-	if (cpu_is_omap3430()) {
+	if (false);
+#if defined(CONFIG_ARCH_OMAP3430)
+	else if (cpu_is_omap3430()) {
 		list = omap3_mboxes;
 
 		list[0]->irq = res[1].start;
 	}
+#endif
 #if defined(CONFIG_ARCH_OMAP2420)
 	else if (cpu_is_omap2420()) {
 		list = omap2_mboxes;
@@ -414,12 +422,14 @@ static int __devinit omap2_mbox_probe(struct platform_device *pdev)
 		list[1]->irq = res[2].start;
 	}
 #endif
+#if defined(CONFIG_ARCH_OMAP4)
 	else if (cpu_is_omap44xx()) {
 		list = omap4_mboxes;
 
 		list[0]->irq = res[1].start;
 		list[1]->irq = res[1].start;
 	}
+#endif
 	else {
 		pr_err("%s: platform not supported\n", __func__);
 		return -ENODEV;
Signature · 1 line
1.7.1
#9 lore raw

PATCH v2 8/17 omap: mailbox: only compile for configured archs

arch/arm/mach-omap2/mailbox.c static int __devinit omap2_mbox_probe(struct platform_device *pdev) · line 409

Quoted 3 lines
arch/arm/mach-omap2/mailbox.c +1 -1
-	if (cpu_is_omap3430()) {
+	if (false);

-- Is this statement needed ?

arch/arm/mach-omap2/mailbox.c static int __devinit omap2_mbox_probe(struct platform_device *pdev) · line 414

Quoted 5 lines
arch/arm/mach-omap2/mailbox.c +2 -0
+#if defined(CONFIG_ARCH_OMAP3430)
+	else if (cpu_is_omap3430()) {
 		list = omap3_mboxes;
 
 		list[0]->irq = res[1].start;

Thank you,
Best regards,
Hari

#10 lore raw

PATCH v2 8/17 omap: mailbox: only compile for configured archs

Quoted 5 lines · Hari
Quoted 3 lines

- ? ? if (cpu_is_omap3430()) {
+ ? ? if (false);

-- Is this statement needed ?

Yeah, so:

if (false);
#if 0
else if (foo) {
}
#endif
else {
return -1;
}

Works.

Signature · 1 line
Felipe Contreras
#11 lore raw

PATCH v2 9/17 omap: mailbox: reorganize omap platform_device

In reply to Felipe Contreras

Makes more sense to register in the mach file, plus it will allow more functionality later on.

Also, this probably enables multi-omap for real.

---
 arch/arm/mach-omap1/devices.c |   38 ----------------
 arch/arm/mach-omap1/mailbox.c |   56 ++++++++++++++++++++++++
 arch/arm/mach-omap2/devices.c |   92 ---------------------------------------
 arch/arm/mach-omap2/mailbox.c |   96 +++++++++++++++++++++++++++++++++++++++--
 4 files changed, 148 insertions(+), 134 deletions(-)
arch/arm/mach-omap1/devices.c +0 -38
index da796f2..093dd13 100644
@@ -63,43 +63,6 @@ static void omap_init_rtc(void)
 static inline void omap_init_rtc(void) {}
 #endif
 
-#if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
-
-#if defined(CONFIG_ARCH_OMAP15XX)
-#  define OMAP1_MBOX_SIZE	0x23
-#  define INT_DSP_MAILBOX1	INT_1510_DSP_MAILBOX1
-#elif defined(CONFIG_ARCH_OMAP16XX)
-#  define OMAP1_MBOX_SIZE	0x2f
-#  define INT_DSP_MAILBOX1	INT_1610_DSP_MAILBOX1
-#endif
-
-static struct resource mbox_resources[] = {
-	{
-		.start		= OMAP16XX_MAILBOX_BASE,
-		.end		= OMAP16XX_MAILBOX_BASE + OMAP1_MBOX_SIZE,
-		.flags		= IORESOURCE_MEM,
-	},
-	{
-		.start		= INT_DSP_MAILBOX1,
-		.flags		= IORESOURCE_IRQ,
-	},
-};
-
-static struct platform_device mbox_device = {
-	.name		= "omap1-mailbox",
-	.id		= -1,
-	.num_resources	= ARRAY_SIZE(mbox_resources),
-	.resource	= mbox_resources,
-};
-
-static inline void omap_init_mbox(void)
-{
-	platform_device_register(&mbox_device);
-}
-#else
-static inline void omap_init_mbox(void) { }
-#endif
-
 /*-------------------------------------------------------------------------*/
 
 #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
@@ -293,7 +256,6 @@ static int __init omap1_init_devices(void)
 	 * in alphabetical order so they're easier to sort through.
 	 */
 
-	omap_init_mbox();
 	omap_init_rtc();
 	omap_init_spi100k();
 	omap_init_sti();
arch/arm/mach-omap1/mailbox.c +56 -0

69 lines not on this page · raw message

arch/arm/mach-omap2/devices.c +0 -92

104 lines not on this page · raw message

arch/arm/mach-omap2/mailbox.c +92 -4

115 lines not on this page · raw message

Signature · 1 line
1.7.1
#12 lore raw

PATCH v2 10/17 omap: mailbox: move more stuff to omap_mbox_init()

In reply to Felipe Contreras

Will be needed to split the platform_driver.

---
 arch/arm/mach-omap1/mailbox.c |   23 +++++++++++--------
 arch/arm/mach-omap2/mailbox.c |   49 +++++++++++++++--------------------------
 2 files changed, 31 insertions(+), 41 deletions(-)
arch/arm/mach-omap1/mailbox.c +13 -10
index 25f1f89..8c1b83f 100644
@@ -169,14 +169,6 @@ static int __devinit omap1_mbox_probe(struct platform_device *pdev)
 
 	res = pdev->resource;
 
-	mbox_base = ioremap(res[0].start, resource_size(&res[0]));
-	if (!mbox_base)
-		return -ENOMEM;
-
-	list = omap1_mboxes;
-
-	list[0]->irq = res[1].start;
-
 	for (i = 0; list[i]; i++) {
 		ret = omap_mbox_register(&pdev->dev, list[i]);
 		if (ret)
@@ -187,7 +179,6 @@ static int __devinit omap1_mbox_probe(struct platform_device *pdev)
 err_out:
 	while (i--)
 		omap_mbox_unregister(list[i]);
-	iounmap(mbox_base);
 	return ret;
 }
 
@@ -198,7 +189,6 @@ static int __devexit omap1_mbox_remove(struct platform_device *pdev)
 	for (i = 0; list[i]; i++)
 		omap_mbox_unregister(list[i]);
 
-	iounmap(mbox_base);
 	return 0;
 }
 
@@ -222,14 +212,20 @@ static int __init omap1_mbox_init(void)
 	else if (cpu_is_omap15xx()) {
 		res = omap1_mbox_resources;
 		num = ARRAY_SIZE(omap1_mbox_resources);
+		list = omap1_mboxes;
+
 		res[1].end += 0x23;
+		list[0]->irq = res[1].start;
 	}
 #endif
 #if defined(CONFIG_ARCH_OMAP16XX)
 	else if (cpu_is_omap16xx()) {
 		res = omap1_mbox_resources;
 		num = ARRAY_SIZE(omap1_mbox_resources);
+		list = omap1_mboxes;
+
 		res[1].end += 0x2f;
+		list[0]->irq = res[1].start;
 	}
 #endif
 	else {
@@ -251,6 +247,12 @@ static int __init omap1_mbox_init(void)
 	if (err)
 		goto err_out;
 
+	mbox_base = ioremap(res[0].start, resource_size(&res[0]));
+	if (!mbox_base) {
+		platform_device_put(pdev);
+		return -ENOMEM;
+	}
+
 	return platform_driver_register(&omap1_mbox_driver);
 
 err_out:
@@ -260,6 +262,7 @@ err_out:
 static void __exit omap1_mbox_exit(void)
 {
 	platform_driver_unregister(&omap1_mbox_driver);
+	iounmap(mbox_base);
 }
 
 module_init(omap1_mbox_init);
arch/arm/mach-omap2/mailbox.c +18 -31

97 lines not on this page · raw message

Signature · 1 line
1.7.1
#13 lore raw

PATCH v2 11/17 omap: mailbox: trivial sync between omap1 and 2

In reply to Felipe Contreras
---
 arch/arm/mach-omap1/mailbox.c |    2 +-
 arch/arm/mach-omap2/mailbox.c |    6 ++----
 2 files changed, 3 insertions(+), 5 deletions(-)
arch/arm/mach-omap1/mailbox.c +1 -1
index 8c1b83f..91780a0 100644
@@ -1,5 +1,5 @@
 /*
- * Mailbox reservation modules for DSP
+ * Mailbox reservation modules for OMAP1
  *
  * Copyright (C) 2006-2009 Nokia Corporation
  * Written by: Hiroshi DOYU <[email protected]>
arch/arm/mach-omap2/mailbox.c +2 -4
index 4f3b84e..adbf5d7 100644
@@ -18,8 +18,6 @@
 #include <plat/mailbox.h>
 #include <mach/irqs.h>
 
-#define DRV_NAME "omap2-mailbox"
-
 #define MAILBOX_REVISION		0x000
 #define MAILBOX_SYSCONFIG		0x010
 #define MAILBOX_SYSSTATUS		0x014
@@ -475,7 +473,7 @@ static struct platform_driver omap2_mbox_driver = {
 	.probe = omap2_mbox_probe,
 	.remove = __devexit_p(omap2_mbox_remove),
 	.driver = {
-		.name = DRV_NAME,
+		.name = "omap2-mailbox",
 	},
 };
 
@@ -560,4 +558,4 @@ MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("omap mailbox: omap2/3/4 architecture specific functions");
 MODULE_AUTHOR("Hiroshi DOYU <[email protected]>");
 MODULE_AUTHOR("Paul Mundt");
-MODULE_ALIAS("platform:"DRV_NAME);
+MODULE_ALIAS("platform:omap2-mailbox");
Signature · 1 line
1.7.1
#14 lore raw

PATCH v2 12/17 omap: mailbox: split platform driver

In reply to Felipe Contreras

This will allow the current 'mailbox_mach' to be built-in.

---
 arch/arm/mach-omap1/mailbox.c             |   50 +++++------------------------
 arch/arm/mach-omap2/mailbox.c             |   50 +++++------------------------
 arch/arm/plat-omap/include/plat/mailbox.h |    4 ++
 arch/arm/plat-omap/mailbox.c              |   46 +++++++++++++++++++++++++-
 4 files changed, 64 insertions(+), 86 deletions(-)
arch/arm/mach-omap1/mailbox.c +8 -42
index 91780a0..f29ba8e 100644
@@ -161,51 +161,13 @@ static struct resource omap1_mbox_resources[] = {
 };
 #endif
 
-static int __devinit omap1_mbox_probe(struct platform_device *pdev)
-{
-	struct resource *res;
-	int ret;
-	int i;
-
-	res = pdev->resource;
-
-	for (i = 0; list[i]; i++) {
-		ret = omap_mbox_register(&pdev->dev, list[i]);
-		if (ret)
-			goto err_out;
-	}
-	return 0;
-
-err_out:
-	while (i--)
-		omap_mbox_unregister(list[i]);
-	return ret;
-}
-
-static int __devexit omap1_mbox_remove(struct platform_device *pdev)
-{
-	int i;
-
-	for (i = 0; list[i]; i++)
-		omap_mbox_unregister(list[i]);
-
-	return 0;
-}
-
-static struct platform_driver omap1_mbox_driver = {
-	.probe	= omap1_mbox_probe,
-	.remove	= __devexit_p(omap1_mbox_remove),
-	.driver	= {
-		.name	= "omap1-mailbox",
-	},
-};
-
 static int __init omap1_mbox_init(void)
 {
 	int err;
 	struct platform_device *pdev;
 	struct resource *res;
 	unsigned num;
+	struct omap_mbox_platform_data pdata;
 
 	if (false);
 #if defined(CONFIG_ARCH_OMAP15XX)
@@ -233,7 +195,7 @@ static int __init omap1_mbox_init(void)
 		return -ENODEV;
 	}
 
-	pdev = platform_device_alloc("omap1-mailbox", -1);
+	pdev = platform_device_alloc("omap-mailbox", -1);
 	if (!pdev) {
 		err = -ENOMEM;
 		goto err_out;
@@ -243,6 +205,11 @@ static int __init omap1_mbox_init(void)
 	if (err)
 		goto err_out;
 
+	pdata.list = list;
+	err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
+	if (err)
+		goto err_out;
+
 	err = platform_device_add(pdev);
 	if (err)
 		goto err_out;
@@ -253,7 +220,7 @@ static int __init omap1_mbox_init(void)
 		return -ENOMEM;
 	}
 
-	return platform_driver_register(&omap1_mbox_driver);
+	return 0;
 
 err_out:
 	return err;
@@ -261,7 +228,6 @@ err_out:
 
 static void __exit omap1_mbox_exit(void)
 {
-	platform_driver_unregister(&omap1_mbox_driver);
 	iounmap(mbox_base);
 }
 
arch/arm/mach-omap2/mailbox.c +8 -42

86 lines not on this page · raw message

arch/arm/plat-omap/include/plat/mailbox.h +4 -0
index 0c3c4a5..b68fdc3 100644
@@ -67,6 +67,10 @@ struct omap_mbox {
 	void			(*err_notify)(void);
 };
 
+struct omap_mbox_platform_data {
+	struct omap_mbox **list;
+};
+
 int omap_mbox_msg_send(struct omap_mbox *, mbox_msg_t msg);
 void omap_mbox_init_seq(struct omap_mbox *);
 
arch/arm/plat-omap/mailbox.c +44 -2

69 lines not on this page · raw message

Signature · 1 line
1.7.1
#15 lore raw

PATCH v2 13/17 omap: mailbox: always built-in platform data

In reply to Felipe Contreras
---
 arch/arm/mach-omap1/Makefile |    6 +++---
 arch/arm/mach-omap2/Makefile |    5 +++--
 2 files changed, 6 insertions(+), 5 deletions(-)
arch/arm/mach-omap1/Makefile +3 -3
index b6a537c..c1e1ae5 100644
@@ -14,9 +14,9 @@ obj-$(CONFIG_OMAP_32K_TIMER)	+= timer32k.o
 # Power Management
 obj-$(CONFIG_PM) += pm.o sleep.o
 
-# DSP
-obj-$(CONFIG_OMAP_MBOX_FWK)	+= mailbox_mach.o
-mailbox_mach-objs		:= mailbox.o
+ifneq ($(CONFIG_OMAP_MBOX_FWK),)
+obj-y					+= mailbox.o
+endif
 
 i2c-omap-$(CONFIG_I2C_OMAP)		:= i2c.o
 obj-y					+= $(i2c-omap-m) $(i2c-omap-y)
arch/arm/mach-omap2/Makefile +3 -2
index 4b9fc57..c9757fb 100644
@@ -86,8 +86,9 @@ obj-$(CONFIG_ARCH_OMAP3)		+= omap_hwmod_3xxx_data.o
 # EMU peripherals
 obj-$(CONFIG_OMAP3_EMU)			+= emu.o
 
-obj-$(CONFIG_OMAP_MBOX_FWK)		+= mailbox_mach.o
-mailbox_mach-objs			:= mailbox.o
+ifneq ($(CONFIG_OMAP_MBOX_FWK),)
+obj-y					+= mailbox.o
+endif
 
 iommu-y					+= iommu2.o
 iommu-$(CONFIG_ARCH_OMAP3)		+= omap3-iommu.o
Signature · 1 line
1.7.1
#16 lore raw

PATCH v2 14/17 omap: mailbox: reorganize headers

In reply to Felipe Contreras
---
 arch/arm/mach-omap1/mailbox.c             |    3 ---
 arch/arm/mach-omap2/mailbox.c             |    1 -
 arch/arm/plat-omap/include/plat/mailbox.h |    3 ++-
 arch/arm/plat-omap/mailbox.c              |    5 ++---
 4 files changed, 4 insertions(+), 8 deletions(-)
arch/arm/mach-omap1/mailbox.c +0 -3
index f29ba8e..f6376b9 100644
@@ -9,13 +9,10 @@
  * for more details.
  */
 
-#include <linux/kernel.h>
-#include <linux/resource.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
 #include <linux/io.h>
 #include <plat/mailbox.h>
-#include <mach/irqs.h>
 
 #define MAILBOX_ARM2DSP1		0x00
 #define MAILBOX_ARM2DSP1b		0x04
arch/arm/mach-omap2/mailbox.c +0 -1
index a54898a..c1a732e 100644
@@ -10,7 +10,6 @@
  * for more details.
  */
 
-#include <linux/kernel.h>
 #include <linux/clk.h>
 #include <linux/err.h>
 #include <linux/platform_device.h>
arch/arm/plat-omap/include/plat/mailbox.h +2 -1
index b68fdc3..cbde52a 100644
@@ -3,9 +3,10 @@
 #ifndef MAILBOX_H
 #define MAILBOX_H
 
-#include <linux/wait.h>
+#include <linux/spinlock.h>
 #include <linux/workqueue.h>
 #include <linux/interrupt.h>
+#include <linux/device.h>
 #include <linux/kfifo.h>
 
 typedef u32 mbox_msg_t;
arch/arm/plat-omap/mailbox.c +2 -3
index 6b2f3b3..c7d28fa 100644
@@ -21,10 +21,9 @@
  *
  */
 
-#include <linux/kernel.h>
-#include <linux/module.h>
 #include <linux/interrupt.h>
-#include <linux/device.h>
+#include <linux/spinlock.h>
+#include <linux/mutex.h>
 #include <linux/delay.h>
 #include <linux/slab.h>
 #include <linux/kfifo.h>
Signature · 1 line
1.7.1
#17 lore raw

PATCH v2 15/17 omap: mailbox: don't export unecessary symbols

In reply to Felipe Contreras
---
 arch/arm/mach-omap1/mailbox.c |    1 -
 arch/arm/mach-omap2/mailbox.c |    3 ---
 2 files changed, 0 insertions(+), 4 deletions(-)
arch/arm/mach-omap1/mailbox.c +0 -1
index f6376b9..7e6aea3 100644
@@ -140,7 +140,6 @@ struct omap_mbox mbox_dsp_info = {
 	.ops	= &omap1_mbox_ops,
 	.priv	= &omap1_mbox_dsp_priv,
 };
-EXPORT_SYMBOL(mbox_dsp_info);
 
 struct omap_mbox *omap1_mboxes[] = { &mbox_dsp_info, NULL };
 
arch/arm/mach-omap2/mailbox.c +0 -3
index c1a732e..f230edb 100644
@@ -306,7 +306,6 @@ struct omap_mbox mbox_dsp_info = {
 	.ops	= &omap2_mbox_ops,
 	.priv	= &omap2_mbox_dsp_priv,
 };
-EXPORT_SYMBOL(mbox_dsp_info);
 #endif
 
 #if defined(CONFIG_ARCH_OMAP3430)
@@ -363,7 +362,6 @@ struct omap_mbox mbox_1_info = {
 	.ops	= &omap2_mbox_ops,
 	.priv	= &omap2_mbox_1_priv,
 };
-EXPORT_SYMBOL(mbox_1_info);
 
 static struct omap_mbox2_priv omap2_mbox_2_priv = {
 	.tx_fifo = {
@@ -386,7 +384,6 @@ struct omap_mbox mbox_2_info = {
 	.ops	= &omap2_mbox_ops,
 	.priv	= &omap2_mbox_2_priv,
 };
-EXPORT_SYMBOL(mbox_2_info);
 
 struct omap_mbox *omap4_mboxes[] = { &mbox_1_info, &mbox_2_info, NULL };
 #endif
Signature · 1 line
1.7.1
#18 lore raw

PATCH v2 16/17 omap: mailbox: mark some resources as __initdata

In reply to Felipe Contreras
---
 arch/arm/mach-omap1/mailbox.c |    2 +-
 arch/arm/mach-omap2/mailbox.c |    6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
arch/arm/mach-omap1/mailbox.c +1 -1
index 7e6aea3..aa661a1 100644
@@ -144,7 +144,7 @@ struct omap_mbox mbox_dsp_info = {
 struct omap_mbox *omap1_mboxes[] = { &mbox_dsp_info, NULL };
 
 #if defined(CONFIG_ARCH_OMAP15XX) || defined(CONFIG_ARCH_OMAP16XX)
-static struct resource omap1_mbox_resources[] = {
+static struct resource __initdata omap1_mbox_resources[] = {
 	{
 		.start		= OMAP16XX_MAILBOX_BASE,
 		.end		= OMAP16XX_MAILBOX_BASE, /* to be updated */
arch/arm/mach-omap2/mailbox.c +3 -3
index f230edb..ddaf7f0 100644
@@ -389,7 +389,7 @@ struct omap_mbox *omap4_mboxes[] = { &mbox_1_info, &mbox_2_info, NULL };
 #endif
 
 #ifdef CONFIG_ARCH_OMAP2420
-static struct resource omap2_mbox_resources[] = {
+static struct resource __initdata omap2_mbox_resources[] = {
 	{
 		.start		= OMAP24XX_MAILBOX_BASE,
 		.end		= OMAP24XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
@@ -407,7 +407,7 @@ static struct resource omap2_mbox_resources[] = {
 #endif
 
 #ifdef CONFIG_ARCH_OMAP3430
-static struct resource omap3_mbox_resources[] = {
+static struct resource __initdata omap3_mbox_resources[] = {
 	{
 		.start		= OMAP34XX_MAILBOX_BASE,
 		.end		= OMAP34XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
@@ -421,7 +421,7 @@ static struct resource omap3_mbox_resources[] = {
 #endif
 
 #ifdef CONFIG_ARCH_OMAP4
-static struct resource omap4_mbox_resources[] = {
+static struct resource __initdata omap4_mbox_resources[] = {
 	{
 		.start          = OMAP44XX_MAILBOX_BASE,
 		.end            = OMAP44XX_MAILBOX_BASE + OMAP4_MBOX_REG_SIZE - 1,
Signature · 1 line
1.7.1
#19 lore raw

PATCH v2 17/17 omap: mailbox: don't export register/unregister

In reply to Felipe Contreras

No need for that now.

---
 arch/arm/plat-omap/include/plat/mailbox.h |    3 ---
 arch/arm/plat-omap/mailbox.c              |    6 ++----
 2 files changed, 2 insertions(+), 7 deletions(-)
arch/arm/plat-omap/include/plat/mailbox.h +0 -3
index cbde52a..e01be54 100644
@@ -78,9 +78,6 @@ 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 device *parent, struct omap_mbox *);
-int omap_mbox_unregister(struct omap_mbox *);
-
 static inline void omap_mbox_save_ctx(struct omap_mbox *mbox)
 {
 	if (!mbox->ops->save_ctx) {
arch/arm/plat-omap/mailbox.c +2 -4
index c7d28fa..88d67c4 100644
@@ -347,7 +347,7 @@ void omap_mbox_put(struct omap_mbox *mbox)
 }
 EXPORT_SYMBOL(omap_mbox_put);
 
-int omap_mbox_register(struct device *parent, struct omap_mbox *mbox)
+static int omap_mbox_register(struct device *parent, struct omap_mbox *mbox)
 {
 	int ret = 0;
 	struct omap_mbox **tmp;
@@ -372,9 +372,8 @@ int omap_mbox_register(struct device *parent, struct omap_mbox *mbox)
 err_find:
 	return ret;
 }
-EXPORT_SYMBOL(omap_mbox_register);
 
-int omap_mbox_unregister(struct omap_mbox *mbox)
+static int omap_mbox_unregister(struct omap_mbox *mbox)
 {
 	struct omap_mbox **tmp;
 
@@ -393,7 +392,6 @@ int omap_mbox_unregister(struct omap_mbox *mbox)
 
 	return -EINVAL;
 }
-EXPORT_SYMBOL(omap_mbox_unregister);
 
 static int __devinit omap_mbox_probe(struct platform_device *pdev)
 {
Signature · 1 line
1.7.1
#20 lore raw

v2 cover omap: mailbox: reorganize init

In reply to Felipe Contreras

Hi Felipe,

Quoted 9 lines · Felipe Contreras

Hi,

The main purpose of this patch series is to be able to compile mach platform data as built-in. Otherwise, client modules such as bridgedriver will load the platform code, but not the mach code when mailbox is built as a module.

Unfortunately, there's no easy way to do that since plat and mach code are deepely interrelated. So the first patches try to separate the mailbox registering through a defined omap_mbox_platform_data.

Have you considered converting mailbox to hwmod + omap_device ?

Thanks,
Ohad.

Quoted 52 lines

Also, it's worth noting that mailboxes are not a one-to-one mapping to resources; that is, some resources belong to multiple mboxes. So it's best to think of mailboxes as fake devices. That is why custom platform_data is required.

Finally, a bunch of cleaning up is done in the very first patches, specially for OMAP1.

The initial RFC included comments from Felipe Balbi, and this proposal includes comments from Tony Lindgren.

v2:
?* Rebased on top of Hiroshi's v2.6.34-rc7.mailbox ?* A bit more extra cleanups

v1 was tested on OMAP3 (beagleboard), and compiled-tested for OMAP1. v2 was compile-tested for OMAP3 and 1.

Felipe Contreras (17):
?omap: mailbox: trivial whitespace cleanups ?omap: mailbox: trivial cleanups
?omap: mailbox: reorganize structures ?omap: mailbox: 2420 should be detected at run-time ?omap: mailbox: use correct config for omap1 ?omap: mailbox: update omap1 probing
?omap: mailbox: reorganize registering ?omap: mailbox: only compile for configured archs ?omap: mailbox: reorganize omap platform_device ?omap: mailbox: move more stuff to omap_mbox_init() ?omap: mailbox: trivial sync between omap1 and 2 ?omap: mailbox: split platform driver ?omap: mailbox: always built-in platform data ?omap: mailbox: reorganize headers
?omap: mailbox: don't export unecessary symbols ?omap: mailbox: mark some resources as __initdata ?omap: mailbox: don't export register/unregister

?arch/arm/mach-omap1/Makefile ? ? ? ? ? ? ?| ? ?6 +-
?arch/arm/mach-omap1/devices.c ? ? ? ? ? ? | ? 40 -----
?arch/arm/mach-omap1/mailbox.c ? ? ? ? ? ? | ?118 ++++++++------
?arch/arm/mach-omap2/Makefile ? ? ? ? ? ? ?| ? ?5 +-
?arch/arm/mach-omap2/devices.c ? ? ? ? ? ? | ? 92 -----------
?arch/arm/mach-omap2/mailbox.c ? ? ? ? ? ? | ?254 ++++++++++++++++-------------
?arch/arm/plat-omap/include/plat/mailbox.h | ? 10 +-
?arch/arm/plat-omap/mailbox.c ? ? ? ? ? ? ?| ? 89 +++++++---

?8 files changed, 290 insertions(+), 324 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo at vger.kernel.org
More majordomo info at ?http://vger.kernel.org/majordomo-info.html

#21 lore raw

v2 cover omap: mailbox: reorganize init

Quoted 8 lines · Ohad Ben-Cohen

Hi Felipe,

Quoted 4 lines · Felipe Contreras

The main purpose of this patch series is to be able to compile mach platform data as built-in. Otherwise, client modules such as bridgedriver will load the platform code, but not the mach code when mailbox is built as a module.

Quoted 5 lines
Quoted 3 lines

Unfortunately, there's no easy way to do that since plat and mach code are deepely interrelated. So the first patches try to separate the mailbox registering through a defined omap_mbox_platform_data.

Have you considered converting mailbox to hwmod + omap_device ?

I don't know what's that... so no. Is there any good source of information, or a good example? I think there is further tidying up possible after this patch series independent of that, but I would like to concentrate on getting this in first.

Signature · 1 line
Felipe Contreras
#22 lore raw

v2 cover omap: mailbox: reorganize init

Hi Felipe,

Quoted 9 lines · Felipe Contreras
Quoted 8 lines · Ohad Ben-Cohen

Hi Felipe,

Quoted 4 lines · Felipe Contreras

The main purpose of this patch series is to be able to compile mach platform data as built-in. Otherwise, client modules such as bridgedriver will load the platform code, but not the mach code when mailbox is built as a module.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Unfortunately, there's no easy way to do that since plat and mach code are deepely interrelated. So the first patches try to separate the mailbox registering through a defined omap_mbox_platform_data.

Have you considered converting mailbox to hwmod + omap_device ?

I don't know what's that... so no. Is there any good source of information, or a good example?

A good example (that also demonstrates runtime PM conversion) would be the MMC conversion in Kevin's 'pm-wip/mmc' branch:

http://git.kernel.org/?p=linux/kernel/git/khilman/linux-omap-pm.git;a=log;h=pm-wip/mmc

Quoted 3 lines

I think there is further tidying up
possible after this patch series independent of that, but I would like to concentrate on getting this in first.

Sure thing.

Thanks,
Ohad.

Quoted 4 lines

--
Felipe Contreras

#23 lore raw

v2 cover omap: mailbox: reorganize init

In reply to Felipe Contreras

Hi Felipe,

From: ext Felipe Contreras <[email protected]>
Subject: [PATCH v2 00/17] omap: mailbox: reorganize init
Date: Fri, 14 May 2010 17:01:33 +0200

Quoted 5 lines

Hi,

The main purpose of this patch series is to be able to compile mach platform data as built-in. Otherwise, client modules such as bridgedriver will load the platform code, but not the mach code when mailbox is built as a module.

I think that this is the *udev* responsibility. The udev should take care of loading mailbox_mach.ko since the mailbox platform device was registered by devices.ko at bootup. devices.ko is built in earlier than dspbridge.ko, so the mailbox platform device is registered earlier than the dsp device, "C6410". this registration ordering should take care of the dependency if the udevd works correctly.

Quoted 8 lines

Unfortunately, there's no easy way to do that since plat and mach code are deepely interrelated. So the first patches try to separate the mailbox registering through a defined omap_mbox_platform_data.

Also, it's worth noting that mailboxes are not a one-to-one mapping to resources; that is, some resources belong to multiple mboxes. So it's best to think of mailboxes as fake devices. That is why custom platform_data is required.

Actually there were logical mailbox devices/instances implemented, but it was broken partially when dropping mailbox class support by accident(*1). This is the reason whey omap_mbox struct has unused dev pointer now. At that time, the sysfs interface was not necessary but the device creation itself should not have been removed. I'll get this code back again soon.

The role of each modules were/should be:

- devices.ko: a platform device, based on its resource.
- mailbox_mach.ko: a platform driver to register multiple logical mboxes/devices.
- mailbox.ko: a kind of framework which holds multiple logical mboxes/devices.

The sysfs structure is like below:

~# tree -d -L 2 /sys/devices/platform/omap2-mailbox/ /sys/devices/platform/omap2-mailbox/

  |-- driver -> ../../../bus/platform/drivers/omap2-mailbox
  |-- mbox
  |   |-- dsp      <- they are each instances of logical mailbox.
  |   |-- ducati
  |   |-- iva2
  |   |-- mbox01
  |   |-- mbox02
  |   |-- mbox03
  |   `-- tesla
  |-- power

`-- subsystem -> ../../../bus/platform

The platform device omap2-mailbox accomodatess logical mboxes.

Quoted 3 lines

Finally, a bunch of cleaning up is done in the very first patches, specially for OMAP1.

Most of the cleanups are quite ok.

Would it be possible to rebase them on the top of my coming patch to get back logical device entry?

Sorry for the late reply, it took some time to recall my bad memory...

*1: http://www.mail-archive.com/linux-omap at vger.kernel.org/msg19546.html

Quoted 44 lines

The initial RFC included comments from Felipe Balbi, and this proposal includes comments from Tony Lindgren.

v2:
* Rebased on top of Hiroshi's v2.6.34-rc7.mailbox
* A bit more extra cleanups

v1 was tested on OMAP3 (beagleboard), and compiled-tested for OMAP1. v2 was compile-tested for OMAP3 and 1.

Felipe Contreras (17):
omap: mailbox: trivial whitespace cleanups
omap: mailbox: trivial cleanups
omap: mailbox: reorganize structures
omap: mailbox: 2420 should be detected at run-time
omap: mailbox: use correct config for omap1
omap: mailbox: update omap1 probing
omap: mailbox: reorganize registering
omap: mailbox: only compile for configured archs
omap: mailbox: reorganize omap platform_device
omap: mailbox: move more stuff to omap_mbox_init()
omap: mailbox: trivial sync between omap1 and 2
omap: mailbox: split platform driver
omap: mailbox: always built-in platform data
omap: mailbox: reorganize headers
omap: mailbox: don't export unecessary symbols
omap: mailbox: mark some resources as __initdata
omap: mailbox: don't export register/unregister

 arch/arm/mach-omap1/Makefile              |    6 +-
 arch/arm/mach-omap1/devices.c             |   40 -----
 arch/arm/mach-omap1/mailbox.c             |  118 ++++++++------
 arch/arm/mach-omap2/Makefile              |    5 +-
 arch/arm/mach-omap2/devices.c             |   92 -----------
 arch/arm/mach-omap2/mailbox.c             |  254 ++++++++++++++++-------------
 arch/arm/plat-omap/include/plat/mailbox.h |   10 +-
 arch/arm/plat-omap/mailbox.c              |   89 +++++++---
 8 files changed, 290 insertions(+), 324 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

#24 lore raw

v2 cover omap: mailbox: reorganize init

Quoted 10 lines · Hiroshi DOYU

From: ext Felipe Contreras <[email protected]>
Subject: [PATCH v2 00/17] omap: mailbox: reorganize init
Date: Fri, 14 May 2010 17:01:33 +0200

Quoted 5 lines

Hi,

The main purpose of this patch series is to be able to compile mach platform data as built-in. Otherwise, client modules such as bridgedriver will load the platform code, but not the mach code when mailbox is built as a module.

Quoted 6 lines

I think that this is the *udev* responsibility. The udev should take care of loading mailbox_mach.ko since the mailbox platform device was registered by devices.ko at bootup. devices.ko is built in earlier than dspbridge.ko, so the mailbox platform device is registered earlier than the dsp device, "C6410". this registration ordering should take care of the dependency if the udevd works correctly.

I'm not familiar with this kind of module loading, but certainly not all systems have udev.

I realized the problem because I have a bare-bones system in my beagleboard where I had to manually load mailbox_mach.

Quoted 18 lines
Quoted 8 lines

Unfortunately, there's no easy way to do that since plat and mach code are deepely interrelated. So the first patches try to separate the mailbox registering through a defined omap_mbox_platform_data.

Also, it's worth noting that mailboxes are not a one-to-one mapping to resources; that is, some resources belong to multiple mboxes. So it's best to think of mailboxes as fake devices. That is why custom platform_data is required.

Actually there were logical mailbox devices/instances implemented, but it was broken partially when dropping mailbox class support by accident(*1). This is the reason whey omap_mbox struct has unused dev pointer now. At that time, the sysfs interface was not necessary but the device creation itself should not have been removed. I'll get this code back again soon.

The role of each modules were/should be:

Quoted 7 lines

?- devices.ko: ? ? ? ? a platform device, based on its resource.
?- mailbox_mach.ko: ? ?a platform driver to register multiple logical mboxes/devices. ?- mailbox.ko: ? ? ? ? a kind of framework which holds multiple logical mboxes/devices.

The sysfs structure is like below:

?~# tree -d -L 2 /sys/devices/platform/omap2-mailbox/

I don't see the point of having 'omap2' there, at best it should be 'omap-mailbox', or perhaps even just 'mailbox'.

Quoted 1 line

The platform device omap2-mailbox accomodatess logical mboxes.

Wouldn't it be better the way my patches handle them?
* devices.ko: doesn't care about mbox
* mach_omap1/mailbox.ko: registers "omap-mailbox" platform device
with a list of logical mboxes for OMAP1
* mach_omap2/mailbox.ko: registers "omap-mailbox" platform device
with a list of logical mboxes for OMAP2
* plat-omap/mailbox.ko: creates platform driver based on logical list
of mboxes from platform device and handles the list internally

The end result would be the exactly same, except that there's no hard dependency between the mach, and plat code.

Quoted 7 lines
Quoted 2 lines

Finally, a bunch of cleaning up is done in the very first patches, specially for OMAP1.

Most of the cleanups are quite ok.

Would it be possible to rebase them on the top of my coming patch to get back logical device entry?

Where is that?

Quoted 1 line

Sorry for the late reply, it took some time to recall my bad memory...

No worries.

Cheers.

Signature · 1 line
Felipe Contreras
#25 lore raw

v2 cover omap: mailbox: reorganize init

From: ext Felipe Contreras <[email protected]>
Subject: Re: [PATCH v2 00/17] omap: mailbox: reorganize init
Date: Tue, 18 May 2010 14:03:26 +0200

Quoted 18 lines · Hiroshi DOYU
Quoted 10 lines

From: ext Felipe Contreras <[email protected]>
Subject: [PATCH v2 00/17] omap: mailbox: reorganize init
Date: Fri, 14 May 2010 17:01:33 +0200

Quoted 5 lines

Hi,

The main purpose of this patch series is to be able to compile mach platform data as built-in. Otherwise, client modules such as bridgedriver will load the platform code, but not the mach code when mailbox is built as a module.

Quoted 6 lines

I think that this is the *udev* responsibility. The udev should take care of loading mailbox_mach.ko since the mailbox platform device was registered by devices.ko at bootup. devices.ko is built in earlier than dspbridge.ko, so the mailbox platform device is registered earlier than the dsp device, "C6410". this registration ordering should take care of the dependency if the udevd works correctly.

Quoted 5 lines

I'm not familiar with this kind of module loading, but certainly not all systems have udev.

I realized the problem because I have a bare-bones system in my beagleboard where I had to manually load mailbox_mach.

With udev or something equivalent, it should work fine.

Quoted 23 lines
Quoted 23 lines
Quoted 9 lines

Unfortunately, there's no easy way to do that since plat and mach code are deepely interrelated. So the first patches try to separate the mailbox registering through a defined omap_mbox_platform_data.

Also, it's worth noting that mailboxes are not a one-to-one mapping to resources; that is, some resources belong to multiple mboxes. So it's best to think of mailboxes as fake devices. That is why custom platform_data is required.

Actually there were logical mailbox devices/instances implemented, but it was broken partially when dropping mailbox class support by accident(*1). This is the reason whey omap_mbox struct has unused dev pointer now. At that time, the sysfs interface was not necessary but the device creation itself should not have been removed. I'll get this code back again soon.

The role of each modules were/should be:

?- devices.ko: ? ? ? ? a platform device, based on its resource.
?- mailbox_mach.ko: ? ?a platform driver to register multiple logical mboxes/devices. ?- mailbox.ko: ? ? ? ? a kind of framework which holds multiple logical mboxes/devices.

Quoted 6 lines
Quoted 3 lines

The sysfs structure is like below:

?~# tree -d -L 2 /sys/devices/platform/omap2-mailbox/

I don't see the point of having 'omap2' there, at best it should be 'omap-mailbox', or perhaps even just 'mailbox'.

Sounds nice.

Quoted 11 lines
Quoted 1 line

The platform device omap2-mailbox accomodatess logical mboxes.

Wouldn't it be better the way my patches handle them?
* devices.ko: doesn't care about mbox
* mach_omap1/mailbox.ko: registers "omap-mailbox" platform device
with a list of logical mboxes for OMAP1
* mach_omap2/mailbox.ko: registers "omap-mailbox" platform device
with a list of logical mboxes for OMAP2
* plat-omap/mailbox.ko: creates platform driver based on logical list
of mboxes from platform device and handles the list internally

Quoted 2 lines

The end result would be the exactly same, except that there's no hard dependency between the mach, and plat code.

With the attachemnt, which is just 17 lines of code, you will get the structure of logical mbox devices, which are located under the single platform device, "omap2-mailbox". This is more _descriptive_ since it displays the connection of a platform device and logical devices, IOW, where these logical ones come. I don't see any point of not using this struture.

Quoted 10 lines
Quoted 8 lines
Quoted 3 lines

Finally, a bunch of cleaning up is done in the very first patches, specially for OMAP1.

Most of the cleanups are quite ok.

Would it be possible to rebase them on the top of my coming patch to get back logical device entry?

Where is that?

Attached. Would it be possible to rebase the cleanups on this one?

Quoted 9 lines
Quoted 2 lines

Sorry for the late reply, it took some time to recall my bad memory...

No worries.

Cheers.

Signature · 1 line
Felipe Contreras
#26 lore raw

v2 cover omap: mailbox: reorganize init

Quoted 8 lines · Hiroshi DOYU

From: ext Felipe Contreras <[email protected]>

Quoted 5 lines

I'm not familiar with this kind of module loading, but certainly not all systems have udev.

I realized the problem because I have a bare-bones system in my beagleboard where I had to manually load mailbox_mach.

With udev or something equivalent, it should work fine.

But still, you are relying on udev. I don't think we should, and I don't think there's any need.

Quoted 14 lines
Quoted 11 lines
Quoted 1 line

The platform device omap2-mailbox accomodatess logical mboxes.

Wouldn't it be better the way my patches handle them?
?* devices.ko: ?doesn't care about mbox
?* mach_omap1/mailbox.ko: ?registers "omap-mailbox" platform device with a list of logical mboxes for OMAP1
?* mach_omap2/mailbox.ko: ?registers "omap-mailbox" platform device with a list of logical mboxes for OMAP2
?* plat-omap/mailbox.ko: creates platform driver based on logical list of mboxes from platform device and handles the list internally

Quoted 2 lines

The end result would be the exactly same, except that there's no hard dependency between the mach, and plat code.

Quoted 6 lines

With the attachemnt, which is just 17 lines of code, you will get the structure of logical mbox devices, which are located under the single platform device, "omap2-mailbox". This is more _descriptive_ since it displays the connection of a platform device and logical devices, IOW, where these logical ones come. I don't see any point of not using this struture.

That's neat. Am I understanding correctly that that's not an argument against the split of mailbox_mach and plat mailbox?

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Would it be possible to rebase them on the top of my coming patch to get back logical device entry?

Where is that?

Attached. Would it be possible to rebase the cleanups on this one?

I think it would be easier to apply the patch on top of my patch series... specially since it's so small. Would that be acceptable?

Signature · 1 line
Felipe Contreras
#27 lore raw

v2 cover omap: mailbox: reorganize init

From: ext Felipe Contreras <[email protected]>
Subject: Re: [PATCH v2 00/17] omap: mailbox: reorganize init
Date: Tue, 18 May 2010 18:57:55 +0200

Quoted 5 lines · Hiroshi DOYU
Quoted 4 lines

From: ext Felipe Contreras <[email protected]>

Quoted 3 lines

I'm not familiar with this kind of module loading, but certainly not all systems have udev.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

I realized the problem because I have a bare-bones system in my beagleboard where I had to manually load mailbox_mach.

With udev or something equivalent, it should work fine.

But still, you are relying on udev. I don't think we should, and I don't think there's any need.

Some expert may give some comment here.....

Quoted 21 lines
Quoted 14 lines
Quoted 11 lines
Quoted 1 line

The platform device omap2-mailbox accomodatess logical mboxes.

Wouldn't it be better the way my patches handle them?
?* devices.ko: ?doesn't care about mbox
?* mach_omap1/mailbox.ko: ?registers "omap-mailbox" platform device with a list of logical mboxes for OMAP1
?* mach_omap2/mailbox.ko: ?registers "omap-mailbox" platform device with a list of logical mboxes for OMAP2
?* plat-omap/mailbox.ko: creates platform driver based on logical list of mboxes from platform device and handles the list internally

Quoted 2 lines

The end result would be the exactly same, except that there's no hard dependency between the mach, and plat code.

Quoted 6 lines

With the attachemnt, which is just 17 lines of code, you will get the structure of logical mbox devices, which are located under the single platform device, "omap2-mailbox". This is more _descriptive_ since it displays the connection of a platform device and logical devices, IOW, where these logical ones come. I don't see any point of not using this struture.

Quoted 2 lines

That's neat. Am I understanding correctly that that's not an argument against the split of mailbox_mach and plat mailbox?

I may not get your point. That's just 17 lines of code, nothing else.

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Would it be possible to rebase them on the top of my coming patch to get back logical device entry?

Where is that?

Attached. Would it be possible to rebase the cleanups on this one?

I think it would be easier to apply the patch on top of my patch series... specially since it's so small. Would that be acceptable?

I can pick up some of your cleanups if applied on the previous attachemnt.

#28 lore raw

v2 cover omap: mailbox: reorganize init

Quoted 12 lines · Hiroshi DOYU

From: ext Felipe Contreras <[email protected]>
Subject: Re: [PATCH v2 00/17] omap: mailbox: reorganize init
Date: Tue, 18 May 2010 18:57:55 +0200

Quoted 8 lines · Hiroshi DOYU
Quoted 7 lines

From: ext Felipe Contreras <[email protected]>

Quoted 5 lines

I'm not familiar with this kind of module loading, but certainly not all systems have udev.

I realized the problem because I have a bare-bones system in my beagleboard where I had to manually load mailbox_mach.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

With udev or something equivalent, it should work fine.

But still, you are relying on udev. I don't think we should, and I don't think there's any need.

Some expert may give some comment here.....

Russell, Tony: should mailbox_mach, a module that checks for logical devices be always built-in?

I think that's the easiest... in my patches I moved the architecture-specific code from mach-omapX/devices.c to mach-omapX/mailbox.c, so both the logical devices and real platform devices are in the same code, and can be built-in.

This way, there's no need to rely on services like udev to load mailbox, then mailbox_mach, then bridgedriver. After all, all mailbox_mach is doing is calling functions in mailbox to register the logical devices.

Judging from:
http://article.gmane.org/gmane.linux.ports.arm.kernel/58555

The answer is yes.

Signature · 1 line
Felipe Contreras
maintainer
#29 lore raw

v2 cover omap: mailbox: reorganize init

Quoted 33 lines · Felipe Contreras
Quoted 12 lines · Hiroshi DOYU

From: ext Felipe Contreras <[email protected]>
Subject: Re: [PATCH v2 00/17] omap: mailbox: reorganize init
Date: Tue, 18 May 2010 18:57:55 +0200

Quoted 8 lines · Hiroshi DOYU
Quoted 7 lines

From: ext Felipe Contreras <[email protected]>

Quoted 5 lines

I'm not familiar with this kind of module loading, but certainly not all systems have udev.

I realized the problem because I have a bare-bones system in my beagleboard where I had to manually load mailbox_mach.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

With udev or something equivalent, it should work fine.

But still, you are relying on udev. I don't think we should, and I don't think there's any need.

Some expert may give some comment here.....

Russell, Tony: should mailbox_mach, a module that checks for logical devices be always built-in?

I think that's the easiest... in my patches I moved the architecture-specific code from mach-omapX/devices.c to mach-omapX/mailbox.c, so both the logical devices and real platform devices are in the same code, and can be built-in.

This way, there's no need to rely on services like udev to load mailbox, then mailbox_mach, then bridgedriver. After all, all mailbox_mach is doing is calling functions in mailbox to register the logical devices.

Quoted 4 lines

Judging from:
http://article.gmane.org/gmane.linux.ports.arm.kernel/58555

The answer is yes.

Maybe try using the tested good old criteria: What works the best for "standard Linux behaviour" out of the box? :)

Anything that registers platform devices should be built in. Also anything that's needed to boot the device into a sane operating mode should be built in. For example, the DSP should be powered down (or idled on some earlier omaps) even if no bridge is being used.

Cheers,

Tony

#30 lore raw

v2 cover omap: mailbox: reorganize init

Quoted 19 lines · Tony Lindgren
Quoted 13 lines · Felipe Contreras

Russell, Tony: should mailbox_mach, a module that checks for logical devices be always built-in?

I think that's the easiest... in my patches I moved the architecture-specific code from mach-omapX/devices.c to mach-omapX/mailbox.c, so both the logical devices and real platform devices are in the same code, and can be built-in.

This way, there's no need to rely on services like udev to load mailbox, then mailbox_mach, then bridgedriver. After all, all mailbox_mach is doing is calling functions in mailbox to register the logical devices.

Quoted 4 lines

Judging from:
http://article.gmane.org/gmane.linux.ports.arm.kernel/58555

The answer is yes.

Quoted 7 lines

Maybe try using the tested good old criteria: What works the best for "standard Linux behaviour" out of the box? :)

Anything that registers platform devices should be built in. Also anything that's needed to boot the device into a sane operating mode should be built in. For example, the DSP should be powered down (or idled on some earlier omaps) even if no bridge is being used.

I think both approaches go into a sane operating mode, the difference is that:
a) requires two modules: mailbox_mach, and mailbox, and udev to figure out that mailbox depends on mailbox_mach
b) one module, no need for udev

Anyway, I sent a rebased patch series with a longer introduction in the hopes that the issue is better explained.

FWIW there were no conflicts in the rebasing (except on the last patch which was trivial, and not really important in the series).

Signature · 1 line
Felipe Contreras