Skip to contentSkip to conversation

omap: mailbox: hwmod support and dependent cleanup patches

PATCH Superseded Omar Ramirez Luna 5 participants 18 messages Oct 26, 2010 – Nov 10, 2010

Subsystems (4)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

cover omap: mailbox: hwmod support and dependent cleanup patches

HWMOD support for omap2 and omap3 chips, plus cleanups.

1. omap: mailbox: initial hwmod support for omap3 Changes were made to:
- Rebase to latest code.
- Detect the hwmod by filling prcm union for omap2, without this it was unable to build the hwmod at runtime.
- Replace magic number for defines.
- Use ioremap again instead of relying on the one made by hwmod, as noted in http://patchwork.kernel.org/patch/101661/

Tested on 3430 and 3630

2. omap: mailbox: initial hwmod support for omap2
Was only compiled tested!! Unfortunately I don't have the HW for it.

4. omap: mailbox: fix detection for previously supported chips Original patch was using features framework, but when compiled as a module it was breaking, this patch uses cpu_is_omap34xx macro instead.

This is meant as a short term solution until proper cleanup is done, as suggested in:

http://marc.info/?l=linux-arm-kernel&m=128534253231481&w=2

Felipe Contreras (2):
omap: mailbox: initial hwmod support for omap3
omap: mailbox: add omap_device latency information

Omar Ramirez Luna (4):
omap: mailbox: initial hwmod support for omap2
omap: mailbox: fix detection for previously supported chips
omap: mailbox: remove unreachable return

 arch/arm/mach-omap2/devices.c              |  104 +++++++---------------------
 arch/arm/mach-omap2/mailbox.c              |   40 +++++-----
 arch/arm/mach-omap2/omap_hwmod_2420_data.c |   55 +++++++++++++++
 arch/arm/mach-omap2/omap_hwmod_2430_data.c |   54 ++++++++++++++
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |   54 ++++++++++++++
 arch/arm/plat-omap/include/plat/mailbox.h  |    6 ++
 6 files changed, 213 insertions(+), 100 deletions(-)
#1 lore raw

PATCH 1/5 omap: mailbox: initial hwmod support for omap3

From: Felipe Contreras <[email protected]>

HWMOD support for omap3.

---
 arch/arm/mach-omap2/devices.c              |  100 ++++-----------------------
 arch/arm/mach-omap2/mailbox.c              |    1 +
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |   54 +++++++++++++++
 3 files changed, 70 insertions(+), 85 deletions(-)
arch/arm/mach-omap2/devices.c +15 -85
index eaf3799..d977572 100644
@@ -141,95 +141,25 @@ static inline void omap_init_camera(void)
 #endif
 
 #if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
-
-#define MBOX_REG_SIZE   0x120
-
-#ifdef CONFIG_ARCH_OMAP2
-static struct resource omap2_mbox_resources[] = {
-	{
-		.start		= OMAP24XX_MAILBOX_BASE,
-		.end		= OMAP24XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
-		.flags		= IORESOURCE_MEM,
-	},
-	{
-		.start		= INT_24XX_MAIL_U0_MPU,
-		.flags		= IORESOURCE_IRQ,
-		.name		= "dsp",
-	},
-	{
-		.start		= INT_24XX_MAIL_U3_MPU,
-		.flags		= IORESOURCE_IRQ,
-		.name		= "iva",
-	},
-};
-static int omap2_mbox_resources_sz = ARRAY_SIZE(omap2_mbox_resources);
-#else
-#define omap2_mbox_resources		NULL
-#define omap2_mbox_resources_sz		0
-#endif
-
-#ifdef CONFIG_ARCH_OMAP3
-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,
-		.name		= "dsp",
-	},
-};
-static int omap3_mbox_resources_sz = ARRAY_SIZE(omap3_mbox_resources);
-#else
-#define omap3_mbox_resources		NULL
-#define omap3_mbox_resources_sz		0
-#endif
-
-#ifdef CONFIG_ARCH_OMAP4
-
-#define OMAP4_MBOX_REG_SIZE	0x130
-static struct resource omap4_mbox_resources[] = {
-	{
-		.start          = OMAP44XX_MAILBOX_BASE,
-		.end            = OMAP44XX_MAILBOX_BASE +
-					OMAP4_MBOX_REG_SIZE - 1,
-		.flags          = IORESOURCE_MEM,
-	},
-	{
-		.start          = OMAP44XX_IRQ_MAIL_U0,
-		.flags          = IORESOURCE_IRQ,
-		.name		= "mbox",
-	},
-};
-static int omap4_mbox_resources_sz = ARRAY_SIZE(omap4_mbox_resources);
-#else
-#define omap4_mbox_resources		NULL
-#define omap4_mbox_resources_sz		0
-#endif
-
-static struct platform_device mbox_device = {
-	.name		= "omap-mailbox",
-	.id		= -1,
-};
-
 static inline void omap_init_mbox(void)
 {
-	if (cpu_is_omap24xx()) {
-		mbox_device.resource = omap2_mbox_resources;
-		mbox_device.num_resources = omap2_mbox_resources_sz;
-	} else if (cpu_is_omap34xx()) {
-		mbox_device.resource = omap3_mbox_resources;
-		mbox_device.num_resources = omap3_mbox_resources_sz;
-	} else if (cpu_is_omap44xx()) {
-		mbox_device.resource = omap4_mbox_resources;
-		mbox_device.num_resources = omap4_mbox_resources_sz;
-	} else {
-		pr_err("%s: platform not supported\n", __func__);
+	struct omap_hwmod *oh;
+	struct omap_device *od;
+
+	oh = omap_hwmod_lookup("mailbox");
+	if (!oh) {
+		pr_err("%s: unable to find hwmod\n", __func__);
+		return;
+	}
+
+	od = omap_device_build("omap-mailbox", -1, oh,
+			NULL, 0,
+			NULL, 0,
+			0);
+	if (!od) {
+		pr_err("%s: could not build device\n", __func__);
 		return;
 	}
-	platform_device_register(&mbox_device);
 }
 #else
 static inline void omap_init_mbox(void) { }
arch/arm/mach-omap2/mailbox.c +1 -0
index 40ddeca..1ddb82d 100644
@@ -15,6 +15,7 @@
 #include <linux/platform_device.h>
 #include <linux/io.h>
 #include <plat/mailbox.h>
+#include <plat/omap_hwmod.h>
 #include <mach/irqs.h>
 
 #define MAILBOX_REVISION		0x000
arch/arm/mach-omap2/omap_hwmod_3xxx_data.c +54 -0

72 lines not on this page · raw message

Signature · 1 line
1.7.1
#2 lore raw

RE: [PATCH 1/5] omap: mailbox: initial hwmod support for omap3

Quoted 13 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Ramirez Luna, Omar
Sent: Wednesday, October 27, 2010 3:23 AM
To: Tony Lindgren; Hiroshi DOYU
Cc: Felipe Contreras; Dmitry Kasatkin; Kevin Hilman; Ramirez Luna, Omar; Anna, Suman; Paul Walmsley; Cousson, Benoit; Raja, Govindraj; C.A, Subramaniam; [email protected]
Subject: [PATCH 1/5] omap: mailbox: initial hwmod support for omap3

Quoted 3 lines

From: Felipe Contreras <[email protected]>

HWMOD support for omap3.

Use "hwmod".

Quoted 114 lines
---
 arch/arm/mach-omap2/devices.c              |  100 
++++-----------------------
 arch/arm/mach-omap2/mailbox.c              |    1 +
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |   54 +++++++++++++++
 3 files changed, 70 insertions(+), 85 deletions(-)
arch/arm/mach-omap2/devices.c +3 -84
index eaf3799..d977572 100644
@@ -141,95 +141,25 @@ static inline void omap_init_camera(void)
 #endif
 
 #if defined(CONFIG_OMAP_MBOX_FWK) || 
 defined(CONFIG_OMAP_MBOX_FWK_MODULE)
-
-#define MBOX_REG_SIZE   0x120
-
-#ifdef CONFIG_ARCH_OMAP2
-static struct resource omap2_mbox_resources[] = {
-	{
-		.start		= OMAP24XX_MAILBOX_BASE,
-		.end		= OMAP24XX_MAILBOX_BASE + 
 MBOX_REG_SIZE - 1,
-		.flags		= IORESOURCE_MEM,
-	},
-	{
-		.start		= INT_24XX_MAIL_U0_MPU,
-		.flags		= IORESOURCE_IRQ,
-		.name		= "dsp",
-	},
-	{
-		.start		= INT_24XX_MAIL_U3_MPU,
-		.flags		= IORESOURCE_IRQ,
-		.name		= "iva",
-	},
-};
-static int omap2_mbox_resources_sz = 
 ARRAY_SIZE(omap2_mbox_resources);
-#else
-#define omap2_mbox_resources		NULL
-#define omap2_mbox_resources_sz		0
-#endif
-
-#ifdef CONFIG_ARCH_OMAP3
-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,
-		.name		= "dsp",
-	},
-};
-static int omap3_mbox_resources_sz = 
 ARRAY_SIZE(omap3_mbox_resources);
-#else
-#define omap3_mbox_resources		NULL
-#define omap3_mbox_resources_sz		0
-#endif
-
-#ifdef CONFIG_ARCH_OMAP4
-
-#define OMAP4_MBOX_REG_SIZE	0x130
-static struct resource omap4_mbox_resources[] = {
-	{
-		.start          = OMAP44XX_MAILBOX_BASE,
-		.end            = OMAP44XX_MAILBOX_BASE +
-					OMAP4_MBOX_REG_SIZE - 1,
-		.flags          = IORESOURCE_MEM,
-	},
-	{
-		.start          = OMAP44XX_IRQ_MAIL_U0,
-		.flags          = IORESOURCE_IRQ,
-		.name		= "mbox",
-	},
-};
-static int omap4_mbox_resources_sz = 
 ARRAY_SIZE(omap4_mbox_resources);
-#else
-#define omap4_mbox_resources		NULL
-#define omap4_mbox_resources_sz		0
-#endif
-
-static struct platform_device mbox_device = {
-	.name		= "omap-mailbox",
-	.id		= -1,
-};
-
 static inline void omap_init_mbox(void)
 {
-	if (cpu_is_omap24xx()) {
-		mbox_device.resource = omap2_mbox_resources;
-		mbox_device.num_resources = omap2_mbox_resources_sz;
-	} else if (cpu_is_omap34xx()) {
-		mbox_device.resource = omap3_mbox_resources;
-		mbox_device.num_resources = omap3_mbox_resources_sz;
-	} else if (cpu_is_omap44xx()) {
-		mbox_device.resource = omap4_mbox_resources;
-		mbox_device.num_resources = omap4_mbox_resources_sz;
-	} else {
-		pr_err("%s: platform not supported\n", __func__);
+	struct omap_hwmod *oh;
+	struct omap_device *od;
+

arch/arm/mach-omap2/devices.c static inline void omap_init_camera(void) · line 164

Quoted 10 lines
arch/arm/mach-omap2/devices.c +10 -0
+	oh = omap_hwmod_lookup("mailbox");
+	if (!oh) {
+		pr_err("%s: unable to find hwmod\n", __func__);
+		return;
+	}
+
+	od = omap_device_build("omap-mailbox", -1, oh,
+			NULL, 0,
+			NULL, 0,
+			0);

This patch series breaks OMAP4 support.

OMAP2 support is broken with this patch and the same is fixed in the next patch. Hence patch 2 should be ordered before patch 1.

Quoted 14 lines
arch/arm/mach-omap2/devices.c +2 -1
+	if (!od) {
+		pr_err("%s: could not build device\n", __func__);
 		return;
 	}
-	platform_device_register(&mbox_device);
 }
 #else
 static inline void omap_init_mbox(void) { }
arch/arm/mach-omap2/mailbox.c +0 -0
index 40ddeca..1ddb82d 100644

arch/arm/mach-omap2/mailbox.c line 18

Quoted 4 lines
arch/arm/mach-omap2/mailbox.c +1 -0
@@ -15,6 +15,7 @@
 #include <linux/platform_device.h>
 #include <linux/io.h>
 #include <plat/mailbox.h>
+#include <plat/omap_hwmod.h>

Is this required? I do not see this file using any hwmod info.

-V Charulatha

#3 lore raw

Re: [PATCH 1/5] omap: mailbox: initial hwmod support for omap3

Quoted 3 lines · Charulatha
Quoted 1 line

HWMOD support for omap3.

Use "hwmod".

ok

...

Quoted 1 line

This patch series breaks OMAP4 support.

indeed, I'll try to exercise a sanity use case with omap4 and its hwmod data

Quoted 4 lines

OMAP2 support is broken with this patch and the same is fixed in the next patch. Hence patch 2 should be ordered before patch 1.

Agree

Quoted 9 lines

arch/arm/mach-omap2/mailbox.c line 18

Quoted 7 lines
arch/arm/mach-omap2/mailbox.c +1 -0
@@ -15,6 +15,7 @@
  #include <linux/platform_device.h>
  #include <linux/io.h>
  #include <plat/mailbox.h>
+#include <plat/omap_hwmod.h>

Is this required? I do not see this file using any hwmod info.

might have been kept with the rebase, I'll check again

Regards,

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

#4 lore raw

Re: [PATCH 1/5] omap: mailbox: initial hwmod support for omap3

In reply to Omar Ramirez Luna
Quoted 3 lines · Omar Ramirez Luna

From: Felipe Contreras <[email protected]>

HWMOD support for omap3.

-ENO_DESCRIPTIVE_CHANGELOG

Please describe in more detail what is happening here, starting with a better subject:

omap: mailbox: build device using omap_device/omap_hwmod

and the changelog should describe that what is being changed is that there is no longer a need for static platform_device and resources since all of this data is contained in the omap_hwmod for the mailbox.

Quoted 6 lines
---
 arch/arm/mach-omap2/devices.c              |  100 ++++-----------------------
 arch/arm/mach-omap2/mailbox.c              |    1 +
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |   54 +++++++++++++++

please separate out the addition of hwmod_data into it's own patch that comes before this. As mentioned by Charu, all the hwmod data could be added early in the series, before this conversion is done.

Kevin

#5 lore raw

Re: [PATCH 1/5] omap: mailbox: initial hwmod support for omap3

Quoted 8 lines · Kevin Hilman
Quoted 4 lines

---
 arch/arm/mach-omap2/devices.c              |  100 ++++----------------------- arch/arm/mach-omap2/mailbox.c              |    1 + arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |   54 +++++++++++++++

please separate out the addition of hwmod_data into it's own patch that comes before this.  As mentioned by Charu, all the hwmod data could be added early in the series, before this conversion is done.

Yes, this was changed in v2 [1], thanks for your comments, they will be addressed in the next version.

Regards,

Omar

---
[1] http://www.mail-archive.com/[email protected]/msg38171.html
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw

PATCH 2/5 omap: mailbox: initial hwmod support for omap2

In reply to Omar Ramirez Luna

HWMOD support for omap2430 and 2420.

Compiled tested only.

---
 arch/arm/mach-omap2/omap_hwmod_2420_data.c |   55 ++++++++++++++++++++++++++++
 arch/arm/mach-omap2/omap_hwmod_2430_data.c |   54 +++++++++++++++++++++++++++
 2 files changed, 109 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/omap_hwmod_2420_data.c +55 -0
index a1a3dd6..e417fb4 100644
@@ -81,6 +81,7 @@ static struct omap_hwmod omap2420_uart2_hwmod;
 static struct omap_hwmod omap2420_uart3_hwmod;
 static struct omap_hwmod omap2420_i2c1_hwmod;
 static struct omap_hwmod omap2420_i2c2_hwmod;
+static struct omap_hwmod omap2420_mailbox_hwmod;
 
 /* L4_CORE -> L4_WKUP interface */
 static struct omap_hwmod_ocp_if omap2420_l4_core__l4_wkup = {
@@ -557,6 +558,59 @@ static struct omap_hwmod omap2420_i2c2_hwmod = {
 	.flags		= HWMOD_16BIT_REG,
 };
 
+/* Mailbox */
+
+static struct omap_hwmod_class omap2420_mailbox_hwmod_class = {
+	.name = "mailbox",
+};
+
+static struct omap_hwmod_irq_info omap2420_mailbox_irqs[] = {
+	{ .name = "dsp", .irq = INT_24XX_MAIL_U0_MPU },
+	{ .name = "iva", .irq = INT_24XX_MAIL_U3_MPU },
+};
+
+static struct omap_hwmod_addr_space omap2420_mailbox_addrs[] = {
+	{
+		.pa_start	= OMAP24XX_MAILBOX_BASE,
+		.pa_end		= OMAP24XX_MAILBOX_BASE + SZ_4K - 1,
+		.flags		= ADDR_TYPE_RT
+	},
+};
+
+/* L4_CORE -> Mailbox */
+static struct omap_hwmod_ocp_if omap2420_l4_core__mailbox = {
+	.master		= &omap2420_l4_core_hwmod,
+	.slave		= &omap2420_mailbox_hwmod,
+	.addr		= omap2420_mailbox_addrs,
+	.addr_cnt	= ARRAY_SIZE(omap2420_mailbox_addrs),
+	.user		= OCP_USER_MPU | OCP_USER_SDMA,
+};
+
+/* Mailbox slave ports */
+static struct omap_hwmod_ocp_if *omap2420_mailbox_slaves[] = {
+	&omap2420_l4_core__mailbox,
+};
+
+static struct omap_hwmod omap2420_mailbox_hwmod = {
+	.name		= "mailbox",
+	.class		= &omap2420_mailbox_hwmod_class,
+	.prcm		= {
+		.omap2 = {
+			.prcm_reg_id = 1,
+			.module_bit = OMAP24XX_EN_MAILBOXES_SHIFT,
+			.module_offs = CORE_MOD,
+			.idlest_reg_id = 1,
+			.idlest_idle_bit = OMAP24XX_ST_MAILBOXES_SHIFT,
+		},
+	},
+	.main_clk	= "mailboxes_ick",
+	.mpu_irqs	= omap2420_mailbox_irqs,
+	.mpu_irqs_cnt	= ARRAY_SIZE(omap2420_mailbox_irqs),
+	.slaves		= omap2420_mailbox_slaves,
+	.slaves_cnt	= ARRAY_SIZE(omap2420_mailbox_slaves),
+	.omap_chip	= OMAP_CHIP_INIT(CHIP_IS_OMAP2420),
+};
+
 static __initdata struct omap_hwmod *omap2420_hwmods[] = {
 	&omap2420_l3_main_hwmod,
 	&omap2420_l4_core_hwmod,
@@ -569,6 +623,7 @@ static __initdata struct omap_hwmod *omap2420_hwmods[] = {
 	&omap2420_uart3_hwmod,
 	&omap2420_i2c1_hwmod,
 	&omap2420_i2c2_hwmod,
+	&omap2420_mailbox_hwmod,
 	NULL,
 };
 
arch/arm/mach-omap2/omap_hwmod_2430_data.c +54 -0

72 lines not on this page · raw message

Signature · 1 line
1.7.1
#7 lore raw

RE: [PATCH 2/5] omap: mailbox: initial hwmod support for omap2

Quoted 13 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Omar Ramirez Luna
Sent: Wednesday, October 27, 2010 3:23 AM
To: Tony Lindgren; Hiroshi DOYU
Cc: Felipe Contreras; Dmitry Kasatkin; Kevin Hilman; Ramirez Luna, Omar; Anna, Suman; Paul Walmsley; Cousson, Benoit; Raja, Govindraj; C.A, Subramaniam; [email protected]
Subject: [PATCH 2/5] omap: mailbox: initial hwmod support for omap2

Quoted 1 line

HWMOD support for omap2430 and 2420.

It is preferred to use the following $Subject while adding hwmod data "OMAP2: hwmod data: Add mailbox"

-V Charulatha

<<snip>>

#8 lore raw

PATCH 3/5 omap: mailbox: add omap_device latency information

In reply to Omar Ramirez Luna

From: Felipe Contreras <[email protected]>

So that we can enable the main clock.

---
 arch/arm/mach-omap2/devices.c             |   19 +++++++++++++++++--
 arch/arm/mach-omap2/mailbox.c             |   21 +++++++++------------
 arch/arm/plat-omap/include/plat/mailbox.h |    6 ++++++
 3 files changed, 32 insertions(+), 14 deletions(-)
arch/arm/mach-omap2/devices.c +17 -2
index d977572..337fd7a 100644
@@ -29,6 +29,7 @@
 #include <plat/dma.h>
 #include <plat/omap_hwmod.h>
 #include <plat/omap_device.h>
+#include <plat/mailbox.h>
 
 #include "mux.h"
 #include "control.h"
@@ -141,10 +142,20 @@ static inline void omap_init_camera(void)
 #endif
 
 #if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
+static struct omap_device_pm_latency mbox_latencies[] = {
+	[0] = {
+		.activate_func = omap_device_enable_clocks,
+		.activate_lat = 50000, /* FIXME random value */
+		.deactivate_func = omap_device_enable_clocks,
+		.deactivate_lat = 50000, /* FIXME random value */
+	},
+};
+
 static inline void omap_init_mbox(void)
 {
 	struct omap_hwmod *oh;
 	struct omap_device *od;
+	struct omap_mbox_platform_data pdata;
 
 	oh = omap_hwmod_lookup("mailbox");
 	if (!oh) {
@@ -152,10 +163,14 @@ static inline void omap_init_mbox(void)
 		return;
 	}
 
+	pdata.device_enable = omap_device_enable;
+	pdata.device_disable = omap_device_idle;
+
 	od = omap_device_build("omap-mailbox", -1, oh,
-			NULL, 0,
-			NULL, 0,
+			&pdata, sizeof(pdata),
+			mbox_latencies, ARRAY_SIZE(mbox_latencies),
 			0);
+
 	if (!od) {
 		pr_err("%s: could not build device\n", __func__);
 		return;
arch/arm/mach-omap2/mailbox.c +9 -12
index 1ddb82d..61f2149 100644
@@ -53,6 +53,7 @@
 #define OMAP4_MBOX_NR_REGS		(OMAP4_MBOX_REG_SIZE / sizeof(u32))
 
 static void __iomem *mbox_base;
+static struct platform_device *mbox_pdev;
 
 struct omap_mbox2_fifo {
 	unsigned long msg;
@@ -71,8 +72,6 @@ struct omap_mbox2_priv {
 	unsigned long irqdisable;
 };
 
-static struct clk *mbox_ick_handle;
-
 static void omap2_mbox_enable_irq(struct omap_mbox *mbox,
 				  omap_mbox_type_t irq);
 
@@ -91,14 +90,10 @@ static int omap2_mbox_startup(struct omap_mbox *mbox)
 {
 	u32 l;
 	unsigned long timeout;
+	struct omap_mbox_platform_data *pdata = mbox_pdev->dev.platform_data;
 
-	mbox_ick_handle = clk_get(NULL, "mailboxes_ick");
-	if (IS_ERR(mbox_ick_handle)) {
-		printk(KERN_ERR "Could not get mailboxes_ick: %ld\n",
-			PTR_ERR(mbox_ick_handle));
-		return PTR_ERR(mbox_ick_handle);
-	}
-	clk_enable(mbox_ick_handle);
+	if (pdata->device_enable)
+		pdata->device_enable(mbox_pdev);
 
 	if (cpu_is_omap44xx()) {
 		mbox_write_reg(OMAP4_SOFTRESET, MAILBOX_SYSCONFIG);
@@ -144,9 +139,9 @@ static int omap2_mbox_startup(struct omap_mbox *mbox)
 
 static void omap2_mbox_shutdown(struct omap_mbox *mbox)
 {
-	clk_disable(mbox_ick_handle);
-	clk_put(mbox_ick_handle);
-	mbox_ick_handle = NULL;
+	struct omap_mbox_platform_data *pdata = mbox_pdev->dev.platform_data;
+	if (pdata->device_disable)
+		pdata->device_disable(mbox_pdev);
 }
 
 /* Mailbox FIFO handle functions */
@@ -428,6 +423,8 @@ static int __devinit omap2_mbox_probe(struct platform_device *pdev)
 	if (!mbox_base)
 		return -ENOMEM;
 
+	mbox_pdev = pdev;
+
 	ret = omap_mbox_register(&pdev->dev, list);
 	if (ret) {
 		iounmap(mbox_base);
arch/arm/plat-omap/include/plat/mailbox.h +6 -0
index 9976565..59443b1 100644
@@ -11,6 +11,7 @@
 
 typedef u32 mbox_msg_t;
 struct omap_mbox;
+struct platform_device;
 
 typedef int __bitwise omap_mbox_irq_t;
 #define IRQ_TX ((__force omap_mbox_irq_t) 1)
@@ -59,6 +60,11 @@ struct omap_mbox {
 	void			*priv;
 };
 
+struct omap_mbox_platform_data {
+	int (*device_enable)(struct platform_device *pdev);
+	int (*device_disable)(struct platform_device *pdev);
+};
+
 int omap_mbox_msg_send(struct omap_mbox *, mbox_msg_t msg);
 void omap_mbox_init_seq(struct omap_mbox *);
 
Signature · 1 line
1.7.1
#9 lore raw

Re: [PATCH 3/5] omap: mailbox: add omap_device latency information

Quoted 3 lines · Omar Ramirez Luna

From: Felipe Contreras <[email protected]>

So that we can enable the main clock.

-ENO_DESCRIPTIVE_CHANGELOG

omap_device_enable/disable do more than just manage the clocks

Quoted 22 lines
---
 arch/arm/mach-omap2/devices.c             |   19 +++++++++++++++++--
 arch/arm/mach-omap2/mailbox.c             |   21 +++++++++------------
 arch/arm/plat-omap/include/plat/mailbox.h |    6 ++++++
 3 files changed, 32 insertions(+), 14 deletions(-)
arch/arm/mach-omap2/devices.c +1 -0
index d977572..337fd7a 100644
@@ -29,6 +29,7 @@
 #include <plat/dma.h>
 #include <plat/omap_hwmod.h>
 #include <plat/omap_device.h>
+#include <plat/mailbox.h>
 
 #include "mux.h"
 #include "control.h"
@@ -141,10 +142,20 @@ static inline void omap_init_camera(void)
 #endif

arch/arm/mach-omap2/devices.c static inline void omap_init_camera(void) · line 152

Quoted 10 lines
arch/arm/mach-omap2/devices.c +8 -0
 
 #if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
+static struct omap_device_pm_latency mbox_latencies[] = {
+	[0] = {
+		.activate_func = omap_device_enable_clocks,
+		.activate_lat = 50000, /* FIXME random value */
+		.deactivate_func = omap_device_enable_clocks,
+		.deactivate_lat = 50000, /* FIXME random value */
+	},
+};

hmm, I'm hoping you're not expecting this to merge when using random values.

Quoted 9 lines
arch/arm/mach-omap2/devices.c +1 -0
 static inline void omap_init_mbox(void)
 {
 	struct omap_hwmod *oh;
 	struct omap_device *od;
+	struct omap_mbox_platform_data pdata;
 
 	oh = omap_hwmod_lookup("mailbox");
 	if (!oh) {

arch/arm/mach-omap2/devices.c static inline void omap_init_mbox(void) · line 167

Quoted 5 lines
arch/arm/mach-omap2/devices.c +2 -0
@@ -152,10 +163,14 @@ static inline void omap_init_mbox(void)
 		return;
 	}
 
+	pdata.device_enable = omap_device_enable;
+	pdata.device_disable = omap_device_idle;

If the driver want's to use the hooks, just use the runtime PM API. More on this below.

Quoted 36 lines
arch/arm/mach-omap2/devices.c +3 -2
 	od = omap_device_build("omap-mailbox", -1, oh,
-			NULL, 0,
-			NULL, 0,
+			&pdata, sizeof(pdata),
+			mbox_latencies, ARRAY_SIZE(mbox_latencies),
 			0);
+
 	if (!od) {
 		pr_err("%s: could not build device\n", __func__);
 		return;
arch/arm/mach-omap2/mailbox.c +2 -2
index 1ddb82d..61f2149 100644
@@ -53,6 +53,7 @@
 #define OMAP4_MBOX_NR_REGS		(OMAP4_MBOX_REG_SIZE / sizeof(u32))
 
 static void __iomem *mbox_base;
+static struct platform_device *mbox_pdev;
 
 struct omap_mbox2_fifo {
 	unsigned long msg;
@@ -71,8 +72,6 @@ struct omap_mbox2_priv {
 	unsigned long irqdisable;
 };
 
-static struct clk *mbox_ick_handle;
-
 static void omap2_mbox_enable_irq(struct omap_mbox *mbox,
 				  omap_mbox_type_t irq);
 
@@ -91,14 +90,10 @@ static int omap2_mbox_startup(struct omap_mbox *mbox)
 {
 	u32 l;
 	unsigned long timeout;
+	struct omap_mbox_platform_data *pdata = mbox_pdev->dev.platform_data;

arch/arm/mach-omap2/mailbox.c static int omap2_mbox_startup(struct omap_mbox *mbox) · line 96

Quoted 10 lines
arch/arm/mach-omap2/mailbox.c +2 -7
 
-	mbox_ick_handle = clk_get(NULL, "mailboxes_ick");
-	if (IS_ERR(mbox_ick_handle)) {
-		printk(KERN_ERR "Could not get mailboxes_ick: %ld\n",
-			PTR_ERR(mbox_ick_handle));
-		return PTR_ERR(mbox_ick_handle);
-	}
-	clk_enable(mbox_ick_handle);
+	if (pdata->device_enable)
+		pdata->device_enable(mbox_pdev);

pm_runtime_get_sync(dev)

arch/arm/mach-omap2/mailbox.c static int omap2_mbox_startup(struct omap_mbox *mbox) · line 144

Quoted 12 lines
arch/arm/mach-omap2/mailbox.c +3 -3
 	if (cpu_is_omap44xx()) {
 		mbox_write_reg(OMAP4_SOFTRESET, MAILBOX_SYSCONFIG);
@@ -144,9 +139,9 @@ static int omap2_mbox_startup(struct omap_mbox *mbox)
 
 static void omap2_mbox_shutdown(struct omap_mbox *mbox)
 {
-	clk_disable(mbox_ick_handle);
-	clk_put(mbox_ick_handle);
-	mbox_ick_handle = NULL;
+	struct omap_mbox_platform_data *pdata = mbox_pdev->dev.platform_data;
+	if (pdata->device_disable)
+		pdata->device_disable(mbox_pdev);

pm_runtime_put(dev)

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

Quoted 8 lines
arch/arm/mach-omap2/mailbox.c +1 -0
 }
 
 /* Mailbox FIFO handle functions */
@@ -428,6 +423,8 @@ static int __devinit omap2_mbox_probe(struct platform_device *pdev)
 	if (!mbox_base)
 		return -ENOMEM;
 
+	mbox_pdev = pdev;

please don't use a global for this. What if a future SoC has more than one mailbox?

How about adding a field to struct omap_mbox?

Quoted 16 lines
arch/arm/mach-omap2/mailbox.c +0 -0
 	ret = omap_mbox_register(&pdev->dev, list);
 	if (ret) {
 		iounmap(mbox_base);
arch/arm/plat-omap/include/plat/mailbox.h +1 -0
index 9976565..59443b1 100644
@@ -11,6 +11,7 @@
 
 typedef u32 mbox_msg_t;
 struct omap_mbox;
+struct platform_device;
 
 typedef int __bitwise omap_mbox_irq_t;
 #define IRQ_TX ((__force omap_mbox_irq_t) 1)

arch/arm/plat-omap/include/plat/mailbox.h struct omap_mbox { · line 69

Quoted 10 lines
arch/arm/plat-omap/include/plat/mailbox.h +5 -0
@@ -59,6 +60,11 @@ struct omap_mbox {
 	void			*priv;
 };
 
+struct omap_mbox_platform_data {
+	int (*device_enable)(struct platform_device *pdev);
+	int (*device_disable)(struct platform_device *pdev);
+};
+
 int omap_mbox_msg_send(struct omap_mbox *, mbox_msg_t msg);
 void omap_mbox_init_seq(struct omap_mbox *);

Kevin

#10 lore raw

Re: [PATCH 3/5] omap: mailbox: add omap_device latency information

Quoted 11 lines · Kevin Hilman

arch/arm/mach-omap2/devices.c static inline void omap_init_camera(void) · line 152

Quoted 9 lines

 #if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)

arch/arm/mach-omap2/devices.c +8 -0
+static struct omap_device_pm_latency mbox_latencies[] = {
+     [0] = {
+             .activate_func = omap_device_enable_clocks,
+             .activate_lat = 50000, /* FIXME random value */
+             .deactivate_func = omap_device_enable_clocks,
+             .deactivate_lat = 50000, /* FIXME random value */
+     },
+};

hmm, I'm hoping you're not expecting this to merge when using random values.

No, I was hoping you would comment in the RFC I sent clearly mentioning this was an experiment 6 months ago:
http://thread.gmane.org/gmane.linux.ports.arm.omap/36745

AFAICR this was one of the first patches for hwmod, so there was not much reference. I did see more proper ways to set those latencies after sending that patch (automatic calculation IIRC), but I didn't manage to work on that code again. There are more important things to do, like getting the only user of the mailbox to actually work.

Quoted 8 lines
Quoted 7 lines
arch/arm/mach-omap2/mailbox.c +1 -0
@@ -53,6 +53,7 @@
  #define OMAP4_MBOX_NR_REGS           (OMAP4_MBOX_REG_SIZE / sizeof(u32))
 
  static void __iomem *mbox_base;
+static struct platform_device *mbox_pdev;
Quoted 6 lines

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

Quoted 1 line
arch/arm/mach-omap2/mailbox.c +1 -0
+     mbox_pdev = pdev;

please don't use a global for this.  What if a future SoC has more than one mailbox?

How about adding a field to struct omap_mbox?

If you see above, there can be only one (mbox_base is already global). So support for multiple mailboxes would be the subject of a separate patch.

Cheers.

Signature · 5 lines
Felipe Contreras
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#11 lore raw

Re: [PATCH 3/5] omap: mailbox: add omap_device latency information

In reply to Kevin Hilman
Quoted 11 lines · Kevin Hilman

arch/arm/mach-omap2/devices.c static inline void omap_init_camera(void) · line 152

Quoted 9 lines

 #if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)

arch/arm/mach-omap2/devices.c +8 -0
+static struct omap_device_pm_latency mbox_latencies[] = {
+     [0] = {
+             .activate_func = omap_device_enable_clocks,
+             .activate_lat = 50000, /* FIXME random value */
+             .deactivate_func = omap_device_enable_clocks,
+             .deactivate_lat = 50000, /* FIXME random value */
+     },
+};

hmm, I'm hoping you're not expecting this to merge when using random values.

This was changed on the second iteration of the patch [1], and is still a WIP as some more comments have been made. I'll keep your current comments though.

Regards,

Omar

---
[1] http://www.mail-archive.com/[email protected]/msg38169.html
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#12 lore raw

PATCH 4/5 omap: mailbox: fix detection for previously supported chips

In reply to Omar Ramirez Luna

Fix the mailbox detection for OMAP3630 and 2430, also minor cleanup on conditional ifdef's that could affect it.

Given that 2430 has an iva too include it, as the same steps for omap3 apply.

---
 arch/arm/mach-omap2/mailbox.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)
arch/arm/mach-omap2/mailbox.c +10 -6
index 61f2149..b8fd120 100644
@@ -277,7 +277,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)
+#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP2)
 /* DSP */
 static struct omap_mbox2_priv omap2_mbox_dsp_priv = {
 	.tx_fifo = {
@@ -302,7 +302,7 @@ struct omap_mbox mbox_dsp_info = {
 };
 #endif
 
-#if defined(CONFIG_ARCH_OMAP3430)
+#if defined(CONFIG_ARCH_OMAP3)
 struct omap_mbox *omap3_mboxes[] = { &mbox_dsp_info, NULL };
 #endif
 
@@ -390,15 +390,19 @@ static int __devinit omap2_mbox_probe(struct platform_device *pdev)
 
 	if (false)
 		;
-#if defined(CONFIG_ARCH_OMAP3430)
-	else if (cpu_is_omap3430()) {
+#if defined(CONFIG_ARCH_OMAP3)
+	else if (cpu_is_omap34xx()) {
 		list = omap3_mboxes;
 
 		list[0]->irq = platform_get_irq_byname(pdev, "dsp");
 	}
 #endif
-#if defined(CONFIG_ARCH_OMAP2420)
-	else if (cpu_is_omap2420()) {
+#if defined(CONFIG_ARCH_OMAP2)
+	else if (cpu_is_omap2430()) {
+		list = omap2_mboxes;
+
+		list[0]->irq = platform_get_irq_byname(pdev, "dsp");
+	} else if (cpu_is_omap2420()) {
 		list = omap2_mboxes;
 
 		list[0]->irq = platform_get_irq_byname(pdev, "dsp");
Signature · 1 line
1.7.1
#13 lore raw

RE: [PATCH 4/5] omap: mailbox: fix detection for previously supported chips

Quoted 50 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Ramirez Luna, Omar
Sent: Wednesday, October 27, 2010 3:23 AM
To: Tony Lindgren; Hiroshi DOYU
Cc: Felipe Contreras; Dmitry Kasatkin; Kevin Hilman; Ramirez Luna, Omar; Anna, Suman; Paul Walmsley; Cousson, Benoit; Raja, Govindraj; C.A, Subramaniam; [email protected]
Subject: [PATCH 4/5] omap: mailbox: fix detection for previously supported chips

Fix the mailbox detection for OMAP3630 and 2430, also minor cleanup on conditional ifdef's that could affect it.

Given that 2430 has an iva too include it, as the same steps for omap3 apply.

---
 arch/arm/mach-omap2/mailbox.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)
arch/arm/mach-omap2/mailbox.c +0 -0
index 61f2149..b8fd120 100644
@@ -277,7 +277,7 @@ static struct omap_mbox_ops omap2_mbox_ops = {
 
 /* FIXME: the following structs should be filled 

automatically by the user id */

arch/arm/mach-omap2/mailbox.c +2 -2
-#if defined(CONFIG_ARCH_OMAP3430) || defined(CONFIG_ARCH_OMAP2420)
+#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP2)
 /* DSP */
 static struct omap_mbox2_priv omap2_mbox_dsp_priv = {
 	.tx_fifo = {
@@ -302,7 +302,7 @@ struct omap_mbox mbox_dsp_info = {
 };
 #endif
 
-#if defined(CONFIG_ARCH_OMAP3430)
+#if defined(CONFIG_ARCH_OMAP3)
 struct omap_mbox *omap3_mboxes[] = { &mbox_dsp_info, NULL };
 #endif
 

arch/arm/mach-omap2/mailbox.c static int __devinit · line 395

Quoted 8 lines
arch/arm/mach-omap2/mailbox.c +2 -2
@@ -390,15 +390,19 @@ static int __devinit 
 omap2_mbox_probe(struct platform_device *pdev)
 
 	if (false)
 		;
-#if defined(CONFIG_ARCH_OMAP3430)
-	else if (cpu_is_omap3430()) {
+#if defined(CONFIG_ARCH_OMAP3)
+	else if (cpu_is_omap34xx()) {

Use cpu_is_* check only. No need to have #if CONFIG_ARCH_* checks.

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

Quoted 13 lines
arch/arm/mach-omap2/mailbox.c +6 -2
 		list = omap3_mboxes;
 
 		list[0]->irq = platform_get_irq_byname(pdev, "dsp");
 	}
 #endif
-#if defined(CONFIG_ARCH_OMAP2420)
-	else if (cpu_is_omap2420()) {
+#if defined(CONFIG_ARCH_OMAP2)
+	else if (cpu_is_omap2430()) {
+		list = omap2_mboxes;
+
+		list[0]->irq = platform_get_irq_byname(pdev, "dsp");
+	} else if (cpu_is_omap2420()) {

Ditto

Quoted 12 lines
arch/arm/mach-omap2/mailbox.c +0 -0
 		list = omap2_mboxes;
 

list[0]->irq = platform_get_irq_byname(pdev, "dsp");

Signature · 7 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe 
linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#14 lore raw

Re: [PATCH 4/5] omap: mailbox: fix detection for previously supported chips

Quoted 38 lines · Charulatha
Quoted 38 lines

Fix the mailbox detection for OMAP3630 and 2430, also minor cleanup on conditional ifdef's that could affect it.

Given that 2430 has an iva too include it, as the same steps for omap3 apply.

---
 arch/arm/mach-omap2/mailbox.c |   16 ++++++++++------

 1 files changed, 10 insertions(+), 6 deletions(-)
arch/arm/mach-omap2/mailbox.c +0 -0
index 61f2149..b8fd120 100644
@@ -277,7 +277,7 @@ static struct omap_mbox_ops omap2_mbox_ops = {
 
  /* FIXME: the following structs should be filled

automatically by the user id */

arch/arm/mach-omap2/mailbox.c +1 -1
-#if defined(CONFIG_ARCH_OMAP3430) || defined(CONFIG_ARCH_OMAP2420)
+#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP2)

 /* DSP */
 static struct omap_mbox2_priv omap2_mbox_dsp_priv = { .tx_fifo = {

arch/arm/mach-omap2/mailbox.c +1 -1
@@ -302,7 +302,7 @@ struct omap_mbox mbox_dsp_info = {
  };
  #endif
 
-#if defined(CONFIG_ARCH_OMAP3430)
+#if defined(CONFIG_ARCH_OMAP3)
  struct omap_mbox *omap3_mboxes[] = { &mbox_dsp_info, NULL };
  #endif
 
@@ -390,15 +390,19 @@ static int __devinit
 omap2_mbox_probe(struct platform_device *pdev)
 
Quoted 8 lines

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

Quoted 6 lines
arch/arm/mach-omap2/mailbox.c +2 -2
       if (false)
               ;
-#if defined(CONFIG_ARCH_OMAP3430)
-     else if (cpu_is_omap3430()) {
+#if defined(CONFIG_ARCH_OMAP3)
+     else if (cpu_is_omap34xx()) {

Use cpu_is_* check only. No need to have #if CONFIG_ARCH_* checks.

Some people conditionally compile only for one architecture, like in consumer devices. There's no point in wasting space for that.

Signature · 5 lines
Felipe Contreras
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#15 lore raw

Re: [PATCH 4/5] omap: mailbox: fix detection for previously supported chips

Quoted 6 lines · Felipe Contreras
Quoted 2 lines · Charulatha

Use cpu_is_* check only. No need to have #if CONFIG_ARCH_* checks.

Some people conditionally compile only for one architecture, like in consumer devices. There's no point in wasting space for that.

And cpu_is_* calls become constants in such cases, allowing compiler to optimize away unneeded 'if' blocks, not to mention cpu_is_* allows multi-omap support. cpu_is_* is the way to go.

#16 lore raw

Re: [PATCH 4/5] omap: mailbox: fix detection for previously supported chips

Quoted 4 lines · Grazvydas Ignotas
Quoted 2 lines · Felipe Contreras
Quoted 1 line · Charulatha
Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Use cpu_is_* check only. No need to have #if CONFIG_ARCH_* checks.

Some people conditionally compile only for one architecture, like in consumer devices. There's no point in wasting space for that.

And cpu_is_* calls become constants in such cases, allowing compiler to optimize away unneeded 'if' blocks, not to mention cpu_is_* allows multi-omap support. cpu_is_* is the way to go.

The problem is not the cpu_is_* calls, the problem is what is inside them (e.g. omap3_mboxes). If CONFIG_ARCH_OMAP3 is not defined, then compilation would be broken, unless you always include all the arrays.

Multi-omap support is already there, because it means CONFIG_ARCH_OMAP3, CONFIG_ARCH_OMAP2, etc.

Signature · 1 line
Felipe Contreras
#17 lore raw

PATCH 5/5 omap: mailbox: remove unreachable return

In reply to Omar Ramirez Luna

Remove unreachable return statement.

---
 arch/arm/mach-omap2/mailbox.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
arch/arm/mach-omap2/mailbox.c +0 -2
index b8fd120..2dd0e07 100644
@@ -435,8 +435,6 @@ static int __devinit omap2_mbox_probe(struct platform_device *pdev)
 		return ret;
 	}
 	return 0;
-
-	return ret;
 }
 
 static int __devexit omap2_mbox_remove(struct platform_device *pdev)
Signature · 1 line
1.7.1