All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felipe Contreras <felipe.contreras@gmail.com>
To: linux-omap <linux-omap@vger.kernel.org>
Cc: linux-arm <linux-arm-kernel@lists.infradead.org>,
	Hiroshi Doyu <hiroshi.doyu@nokia.com>,
	Tony Lindgren <tony@atomide.com>,
	Russell King <linux@arm.linux.org.uk>,
	Felipe Contreras <felipe.contreras@gmail.com>
Subject: [PATCH 08/15] omap: mailbox: reorganize omap platform_device
Date: Thu, 13 May 2010 20:47:29 +0300	[thread overview]
Message-ID: <1273772856-10881-9-git-send-email-felipe.contreras@gmail.com> (raw)
In-Reply-To: <1273772856-10881-1-git-send-email-felipe.contreras@gmail.com>

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.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 arch/arm/mach-omap1/devices.c |   38 ----------------
 arch/arm/mach-omap1/mailbox.c |   57 ++++++++++++++++++++++++
 arch/arm/mach-omap2/devices.c |   74 -------------------------------
 arch/arm/mach-omap2/mailbox.c |   97 +++++++++++++++++++++++++++++++++++++++--
 4 files changed, 150 insertions(+), 116 deletions(-)

diff --git a/arch/arm/mach-omap1/devices.c b/arch/arm/mach-omap1/devices.c
index da796f2..093dd13 100644
--- a/arch/arm/mach-omap1/devices.c
+++ b/arch/arm/mach-omap1/devices.c
@@ -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();
diff --git a/arch/arm/mach-omap1/mailbox.c b/arch/arm/mach-omap1/mailbox.c
index 8b18313..e28b226 100644
--- a/arch/arm/mach-omap1/mailbox.c
+++ b/arch/arm/mach-omap1/mailbox.c
@@ -147,6 +147,20 @@ EXPORT_SYMBOL(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[] = {
+	{
+		.start		= OMAP16XX_MAILBOX_BASE,
+		.end		= OMAP16XX_MAILBOX_BASE, /* to be updated */
+		.flags		= IORESOURCE_MEM,
+	},
+	{
+		.start		= 10,
+		.flags		= IORESOURCE_IRQ,
+	},
+};
+#endif
+
 static int __devinit omap1_mbox_probe(struct platform_device *pdev)
 {
 	struct resource *res;
@@ -198,7 +212,50 @@ static struct platform_driver omap1_mbox_driver = {
 
 static int __init omap1_mbox_init(void)
 {
+	int err;
+	struct platform_device *pdev;
+	struct resource *res;
+	unsigned num;
+
+	if (false) {
+	}
+#if defined(CONFIG_ARCH_OMAP15XX)
+	else if (cpu_is_omap15xx()) {
+		res = omap1_mbox_resources;
+		num = ARRAY_SIZE(omap1_mbox_resources);
+		res[1].end += 0x23;
+	}
+#endif
+#if defined(CONFIG_ARCH_OMAP16XX)
+	else if (cpu_is_omap16xx()) {
+		res = omap1_mbox_resources;
+		num = ARRAY_SIZE(omap1_mbox_resources);
+		res[1].end += 0x2f;
+	}
+#endif
+	else {
+		pr_err("%s: platform not supported\n", __func__);
+		return -ENODEV;
+	}
+
+	pdev = platform_device_alloc("omap1-mailbox", -1);
+	if (!pdev) {
+		err = -ENOMEM;
+		goto err_out;
+	}
+
+	err = platform_device_add_resources(pdev, res, num);
+	if (err)
+		goto err_out;
+
+	err = platform_device_add(pdev);
+	if (err)
+		goto err_out;
+
 	return platform_driver_register(&omap1_mbox_driver);
+
+err_out:
+	return err;
 }
 
 static void __exit omap1_mbox_exit(void)
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 18ad931..bc7ac38 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -136,79 +136,6 @@ 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 omap_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,
-	},
-	{
-		.start		= INT_24XX_MAIL_U3_MPU,
-		.flags		= IORESOURCE_IRQ,
-	},
-};
-#endif
-
-#ifdef CONFIG_ARCH_OMAP3
-static struct resource omap_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,
-	},
-};
-#endif
-
-#ifdef CONFIG_ARCH_OMAP4
-
-#define OMAP4_MBOX_REG_SIZE	0x130
-static struct resource omap_mbox_resources[] = {
-	{
-		.start          = OMAP44XX_MAILBOX_BASE,
-		.end            = OMAP44XX_MAILBOX_BASE +
-					OMAP4_MBOX_REG_SIZE - 1,
-		.flags          = IORESOURCE_MEM,
-	},
-	{
-		.start          = INT_44XX_MAIL_U0_MPU,
-		.flags          = IORESOURCE_IRQ,
-	},
-};
-#endif
-
-static struct platform_device mbox_device = {
-	.name		= "omap2-mailbox",
-	.id		= -1,
-};
-
-static inline void omap_init_mbox(void)
-{
-	if (cpu_is_omap2420() || cpu_is_omap3430() || cpu_is_omap44xx()) {
-		mbox_device.num_resources = ARRAY_SIZE(omap_mbox_resources);
-		mbox_device.resource = omap_mbox_resources;
-	} else {
-		pr_err("%s: platform not supported\n", __func__);
-		return;
-	}
-	platform_device_register(&mbox_device);
-}
-#else
-static inline void omap_init_mbox(void) { }
-#endif /* CONFIG_OMAP_MBOX_FWK */
-
 #if defined(CONFIG_OMAP_STI)
 
 #if defined(CONFIG_ARCH_OMAP2)
@@ -772,7 +699,6 @@ static int __init omap2_init_devices(void)
 	 */
 	omap_hsmmc_reset();
 	omap_init_camera();
-	omap_init_mbox();
 	omap_init_mcspi();
 	omap_hdq_init();
 	omap_init_sti();
diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
index 103c670..31a0659 100644
--- a/arch/arm/mach-omap2/mailbox.c
+++ b/arch/arm/mach-omap2/mailbox.c
@@ -373,6 +373,52 @@ EXPORT_SYMBOL(mbox_2_info);
 struct omap_mbox *omap4_mboxes[] = { &mbox_1_info, &mbox_2_info, NULL };
 #endif
 
+#ifdef CONFIG_ARCH_OMAP2420
+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,
+	},
+	{
+		.start		= INT_24XX_MAIL_U3_MPU,
+		.flags		= IORESOURCE_IRQ,
+	},
+};
+#endif
+
+#ifdef CONFIG_ARCH_OMAP3430
+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,
+	},
+};
+#endif
+
+#ifdef CONFIG_ARCH_OMAP4
+static struct resource omap4_mbox_resources[] = {
+	{
+		.start          = OMAP44XX_MAILBOX_BASE,
+		.end            = OMAP44XX_MAILBOX_BASE + OMAP4_MBOX_REG_SIZE - 1,
+		.flags          = IORESOURCE_MEM,
+	},
+	{
+		.start          = INT_44XX_MAIL_U0_MPU,
+		.flags          = IORESOURCE_IRQ,
+	},
+};
+#endif
+
 static int __devinit omap2_mbox_probe(struct platform_device *pdev)
 {
 	struct resource *res;
@@ -410,10 +456,6 @@ static int __devinit omap2_mbox_probe(struct platform_device *pdev)
 		list[1]->irq = res[1].start;
 	}
 #endif
-	else {
-		pr_err("%s: platform not supported\n", __func__);
-		return -ENODEV;
-	}
 
 	for (i = 0; list[i]; i++) {
 		ret = omap_mbox_register(&pdev->dev, list[i]);
@@ -450,7 +492,54 @@ static struct platform_driver omap2_mbox_driver = {
 
 static int __init omap2_mbox_init(void)
 {
+	int err;
+	struct platform_device *pdev;
+	struct resource *res;
+	unsigned num;
+
+	if (false) {
+	}
+#if defined(CONFIG_ARCH_OMAP3430)
+	else if (cpu_is_omap3430()) {
+		res = omap3_mbox_resources;
+		num = ARRAY_SIZE(omap3_mbox_resources);
+	}
+#endif
+#if defined(CONFIG_ARCH_OMAP2420)
+	else if (cpu_is_omap2420()) {
+		res = omap2_mbox_resources;
+		num = ARRAY_SIZE(omap2_mbox_resources);
+	}
+#endif
+#if defined(CONFIG_ARCH_OMAP4)
+	else if (cpu_is_omap44xx()) {
+		res = omap4_mbox_resources;
+		num = ARRAY_SIZE(omap4_mbox_resources);
+	}
+#endif
+	else {
+		pr_err("%s: platform not supported\n", __func__);
+		return -ENODEV;
+	}
+
+	pdev = platform_device_alloc("omap2-mailbox", -1);
+	if (!pdev) {
+		err = -ENOMEM;
+		goto err_out;
+	}
+
+	err = platform_device_add_resources(pdev, res, num);
+	if (err)
+		goto err_out;
+
+	err = platform_device_add(pdev);
+	if (err)
+		goto err_out;
+
 	return platform_driver_register(&omap2_mbox_driver);
+
+err_out:
+	return err;
 }
 
 static void __exit omap2_mbox_exit(void)
-- 
1.7.1


WARNING: multiple messages have this Message-ID (diff)
From: felipe.contreras@gmail.com (Felipe Contreras)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 08/15] omap: mailbox: reorganize omap platform_device
Date: Thu, 13 May 2010 20:47:29 +0300	[thread overview]
Message-ID: <1273772856-10881-9-git-send-email-felipe.contreras@gmail.com> (raw)
In-Reply-To: <1273772856-10881-1-git-send-email-felipe.contreras@gmail.com>

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.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 arch/arm/mach-omap1/devices.c |   38 ----------------
 arch/arm/mach-omap1/mailbox.c |   57 ++++++++++++++++++++++++
 arch/arm/mach-omap2/devices.c |   74 -------------------------------
 arch/arm/mach-omap2/mailbox.c |   97 +++++++++++++++++++++++++++++++++++++++--
 4 files changed, 150 insertions(+), 116 deletions(-)

diff --git a/arch/arm/mach-omap1/devices.c b/arch/arm/mach-omap1/devices.c
index da796f2..093dd13 100644
--- a/arch/arm/mach-omap1/devices.c
+++ b/arch/arm/mach-omap1/devices.c
@@ -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();
diff --git a/arch/arm/mach-omap1/mailbox.c b/arch/arm/mach-omap1/mailbox.c
index 8b18313..e28b226 100644
--- a/arch/arm/mach-omap1/mailbox.c
+++ b/arch/arm/mach-omap1/mailbox.c
@@ -147,6 +147,20 @@ EXPORT_SYMBOL(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[] = {
+	{
+		.start		= OMAP16XX_MAILBOX_BASE,
+		.end		= OMAP16XX_MAILBOX_BASE, /* to be updated */
+		.flags		= IORESOURCE_MEM,
+	},
+	{
+		.start		= 10,
+		.flags		= IORESOURCE_IRQ,
+	},
+};
+#endif
+
 static int __devinit omap1_mbox_probe(struct platform_device *pdev)
 {
 	struct resource *res;
@@ -198,7 +212,50 @@ static struct platform_driver omap1_mbox_driver = {
 
 static int __init omap1_mbox_init(void)
 {
+	int err;
+	struct platform_device *pdev;
+	struct resource *res;
+	unsigned num;
+
+	if (false) {
+	}
+#if defined(CONFIG_ARCH_OMAP15XX)
+	else if (cpu_is_omap15xx()) {
+		res = omap1_mbox_resources;
+		num = ARRAY_SIZE(omap1_mbox_resources);
+		res[1].end += 0x23;
+	}
+#endif
+#if defined(CONFIG_ARCH_OMAP16XX)
+	else if (cpu_is_omap16xx()) {
+		res = omap1_mbox_resources;
+		num = ARRAY_SIZE(omap1_mbox_resources);
+		res[1].end += 0x2f;
+	}
+#endif
+	else {
+		pr_err("%s: platform not supported\n", __func__);
+		return -ENODEV;
+	}
+
+	pdev = platform_device_alloc("omap1-mailbox", -1);
+	if (!pdev) {
+		err = -ENOMEM;
+		goto err_out;
+	}
+
+	err = platform_device_add_resources(pdev, res, num);
+	if (err)
+		goto err_out;
+
+	err = platform_device_add(pdev);
+	if (err)
+		goto err_out;
+
 	return platform_driver_register(&omap1_mbox_driver);
+
+err_out:
+	return err;
 }
 
 static void __exit omap1_mbox_exit(void)
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 18ad931..bc7ac38 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -136,79 +136,6 @@ 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 omap_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,
-	},
-	{
-		.start		= INT_24XX_MAIL_U3_MPU,
-		.flags		= IORESOURCE_IRQ,
-	},
-};
-#endif
-
-#ifdef CONFIG_ARCH_OMAP3
-static struct resource omap_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,
-	},
-};
-#endif
-
-#ifdef CONFIG_ARCH_OMAP4
-
-#define OMAP4_MBOX_REG_SIZE	0x130
-static struct resource omap_mbox_resources[] = {
-	{
-		.start          = OMAP44XX_MAILBOX_BASE,
-		.end            = OMAP44XX_MAILBOX_BASE +
-					OMAP4_MBOX_REG_SIZE - 1,
-		.flags          = IORESOURCE_MEM,
-	},
-	{
-		.start          = INT_44XX_MAIL_U0_MPU,
-		.flags          = IORESOURCE_IRQ,
-	},
-};
-#endif
-
-static struct platform_device mbox_device = {
-	.name		= "omap2-mailbox",
-	.id		= -1,
-};
-
-static inline void omap_init_mbox(void)
-{
-	if (cpu_is_omap2420() || cpu_is_omap3430() || cpu_is_omap44xx()) {
-		mbox_device.num_resources = ARRAY_SIZE(omap_mbox_resources);
-		mbox_device.resource = omap_mbox_resources;
-	} else {
-		pr_err("%s: platform not supported\n", __func__);
-		return;
-	}
-	platform_device_register(&mbox_device);
-}
-#else
-static inline void omap_init_mbox(void) { }
-#endif /* CONFIG_OMAP_MBOX_FWK */
-
 #if defined(CONFIG_OMAP_STI)
 
 #if defined(CONFIG_ARCH_OMAP2)
@@ -772,7 +699,6 @@ static int __init omap2_init_devices(void)
 	 */
 	omap_hsmmc_reset();
 	omap_init_camera();
-	omap_init_mbox();
 	omap_init_mcspi();
 	omap_hdq_init();
 	omap_init_sti();
diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
index 103c670..31a0659 100644
--- a/arch/arm/mach-omap2/mailbox.c
+++ b/arch/arm/mach-omap2/mailbox.c
@@ -373,6 +373,52 @@ EXPORT_SYMBOL(mbox_2_info);
 struct omap_mbox *omap4_mboxes[] = { &mbox_1_info, &mbox_2_info, NULL };
 #endif
 
+#ifdef CONFIG_ARCH_OMAP2420
+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,
+	},
+	{
+		.start		= INT_24XX_MAIL_U3_MPU,
+		.flags		= IORESOURCE_IRQ,
+	},
+};
+#endif
+
+#ifdef CONFIG_ARCH_OMAP3430
+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,
+	},
+};
+#endif
+
+#ifdef CONFIG_ARCH_OMAP4
+static struct resource omap4_mbox_resources[] = {
+	{
+		.start          = OMAP44XX_MAILBOX_BASE,
+		.end            = OMAP44XX_MAILBOX_BASE + OMAP4_MBOX_REG_SIZE - 1,
+		.flags          = IORESOURCE_MEM,
+	},
+	{
+		.start          = INT_44XX_MAIL_U0_MPU,
+		.flags          = IORESOURCE_IRQ,
+	},
+};
+#endif
+
 static int __devinit omap2_mbox_probe(struct platform_device *pdev)
 {
 	struct resource *res;
@@ -410,10 +456,6 @@ static int __devinit omap2_mbox_probe(struct platform_device *pdev)
 		list[1]->irq = res[1].start;
 	}
 #endif
-	else {
-		pr_err("%s: platform not supported\n", __func__);
-		return -ENODEV;
-	}
 
 	for (i = 0; list[i]; i++) {
 		ret = omap_mbox_register(&pdev->dev, list[i]);
@@ -450,7 +492,54 @@ static struct platform_driver omap2_mbox_driver = {
 
 static int __init omap2_mbox_init(void)
 {
+	int err;
+	struct platform_device *pdev;
+	struct resource *res;
+	unsigned num;
+
+	if (false) {
+	}
+#if defined(CONFIG_ARCH_OMAP3430)
+	else if (cpu_is_omap3430()) {
+		res = omap3_mbox_resources;
+		num = ARRAY_SIZE(omap3_mbox_resources);
+	}
+#endif
+#if defined(CONFIG_ARCH_OMAP2420)
+	else if (cpu_is_omap2420()) {
+		res = omap2_mbox_resources;
+		num = ARRAY_SIZE(omap2_mbox_resources);
+	}
+#endif
+#if defined(CONFIG_ARCH_OMAP4)
+	else if (cpu_is_omap44xx()) {
+		res = omap4_mbox_resources;
+		num = ARRAY_SIZE(omap4_mbox_resources);
+	}
+#endif
+	else {
+		pr_err("%s: platform not supported\n", __func__);
+		return -ENODEV;
+	}
+
+	pdev = platform_device_alloc("omap2-mailbox", -1);
+	if (!pdev) {
+		err = -ENOMEM;
+		goto err_out;
+	}
+
+	err = platform_device_add_resources(pdev, res, num);
+	if (err)
+		goto err_out;
+
+	err = platform_device_add(pdev);
+	if (err)
+		goto err_out;
+
 	return platform_driver_register(&omap2_mbox_driver);
+
+err_out:
+	return err;
 }
 
 static void __exit omap2_mbox_exit(void)
-- 
1.7.1

  parent reply	other threads:[~2010-05-13 17:48 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-13 17:47 [PATCH 00/15] omap: mailbox: reorganize init Felipe Contreras
2010-05-13 17:47 ` Felipe Contreras
2010-05-13 17:47 ` [PATCH 01/15] omap: mailbox: trivial cleanups Felipe Contreras
2010-05-13 17:47   ` Felipe Contreras
2010-05-13 17:47 ` [PATCH 02/15] omap: mailbox: reorganize structures Felipe Contreras
2010-05-13 17:47   ` Felipe Contreras
2010-05-13 17:47 ` [PATCH 03/15] omap: mailbox: 2420 should be detected at run-time Felipe Contreras
2010-05-13 17:47   ` Felipe Contreras
2010-05-14 10:17   ` Sergei Shtylyov
2010-05-14 10:17     ` Sergei Shtylyov
2010-05-14 10:47     ` Felipe Contreras
2010-05-14 10:47       ` Felipe Contreras
2010-05-13 17:47 ` [PATCH 04/15] omap: mailbox: use correct config for omap1 Felipe Contreras
2010-05-13 17:47   ` Felipe Contreras
2010-05-13 17:47 ` [PATCH 05/15] omap: mailbox: update omap1 probing Felipe Contreras
2010-05-13 17:47   ` Felipe Contreras
2010-05-13 17:47 ` [PATCH 06/15] omap: mailbox: reorganize registering Felipe Contreras
2010-05-13 17:47   ` Felipe Contreras
2010-05-13 17:47 ` [PATCH 07/15] omap: mailbox: only compile for configured archs Felipe Contreras
2010-05-13 17:47   ` Felipe Contreras
2010-05-13 17:47 ` Felipe Contreras [this message]
2010-05-13 17:47   ` [PATCH 08/15] omap: mailbox: reorganize omap platform_device Felipe Contreras
2010-05-13 17:47 ` [PATCH 09/15] omap: mailbox: move more stuff to omap_mbox_init() Felipe Contreras
2010-05-13 17:47   ` Felipe Contreras
2010-05-13 17:47 ` [PATCH 10/15] omap: mailbox: trivial sync between omap1 and 2 Felipe Contreras
2010-05-13 17:47   ` Felipe Contreras
2010-05-13 17:47 ` [PATCH 11/15] omap: mailbox: split platform driver Felipe Contreras
2010-05-13 17:47   ` Felipe Contreras
2010-05-13 17:47 ` [PATCH 12/15] omap: mailbox: always built-in platform data Felipe Contreras
2010-05-13 17:47   ` Felipe Contreras
2010-05-13 17:47 ` [PATCH 13/15] omap: mailbox: reorganize headers Felipe Contreras
2010-05-13 17:47   ` Felipe Contreras
2010-05-13 17:47 ` [PATCH 14/15] omap: mailbox: don't export unecessary symbols Felipe Contreras
2010-05-13 17:47   ` Felipe Contreras
2010-05-13 17:47 ` [PATCH 15/15] omap: mailbox: mark some resources as __initdata Felipe Contreras
2010-05-13 17:47   ` Felipe Contreras
2010-05-14  9:12 ` [PATCH 00/15] omap: mailbox: reorganize init Hiroshi DOYU
2010-05-14  9:12   ` Hiroshi DOYU
2010-05-14 15:06   ` Felipe Contreras
2010-05-14 15:06     ` Felipe Contreras

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1273772856-10881-9-git-send-email-felipe.contreras@gmail.com \
    --to=felipe.contreras@gmail.com \
    --cc=hiroshi.doyu@nokia.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.