All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Lindgren <tony@atomide.com>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: linux-arm-kernel@lists.arm.linux.org.uk,
	Ajay Kumar Gupta <ajay.gupta@ti.com>,
	Felipe Balbi <felipe.balbi@nokia.com>,
	linux-omap@vger.kernel.org
Subject: Re: [PATCH 12/12] ARM: OMAP3: MUSB initialization for omap hw, v2
Date: Mon, 16 Mar 2009 15:37:38 -0700	[thread overview]
Message-ID: <20090316223737.GN19229@atomide.com> (raw)
In-Reply-To: <20090315161446.GG10786@n2100.arm.linux.org.uk>

[-- Attachment #1: Type: text/plain, Size: 1241 bytes --]

* Russell King - ARM Linux <linux@arm.linux.org.uk> [090315 09:14]:
> On Tue, Mar 10, 2009 at 02:16:28PM -0700, Tony Lindgren wrote:
> > Patch modified by Tony to build the module based on
> > CONFIG_USB_MUSB_SOC.
> 
> I don't see this.
> 
> > +# Platform specific device init code
> > +obj-$(CONFIG_USB_MUSB_SOC)		+= usb-musb.o
> 
> So, if this can be a module, the file itself doesn't export any symbols
> and doesn't have any module_init or module_exit functions.  So, if this
> gets built as a module, it isn't useful.

Good point. I've updated the Makefile, it's not intended to be compiled
as a module as it's initialized from the low-level board init code only
for the systems that have the musb wired up.

> > +void __init usb_musb_init(void)
> > +{
> > +	if (cpu_is_omap243x()) {
> > +		musb_resources[0].start = OMAP243X_HS_BASE;
> > +		musb_plat.clock = "usbhs_ick";
> 
> kill kill kill.
> 
> > +	} else {
> > +		musb_resources[0].start = OMAP34XX_HSUSB_OTG_BASE;
> > +		musb_plat.clock = "hsotgusb_ick";
> 
> kill kill kill.

Heh!
 
> clkdev removes the need for this sort of crap.

Here's the future proof version. Will post another patch against your
omap-clks3 branch to set the names for musb clocks in clock[23]4xx.c.

Tony

[-- Attachment #2: musb-init-v2.patch --]
[-- Type: text/x-diff, Size: 8939 bytes --]

>From 18936e335f62f252fa584ee9a22f99ebc34cd4c5 Mon Sep 17 00:00:00 2001
From: Felipe Balbi <felipe.balbi@nokia.com>
Date: Mon, 16 Mar 2009 11:01:50 -0700
Subject: [PATCH] ARM: OMAP3: MUSB initialization for omap hw, v2

Create a generic board-file for initializing usb
on omap2430 and omap3 boards.

Patch modified by Tony to build the module based on
CONFIG_USB_MUSB_SOC. Also merged in a patch adding
the nop xceiv from Ajay Kumar Gupta <ajay.gupta@ti.com>.

Signed-off-by: Ajay Kumar Gupta <ajay.gupta@ti.com>
Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index bbd12bc..29f6ca9 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -39,3 +39,7 @@ obj-$(CONFIG_MACH_OVERO)		+= board-overo.o \
 obj-$(CONFIG_MACH_OMAP3_PANDORA)	+= board-omap3pandora.o \
 					   mmc-twl4030.o
 
+# Platform specific device init code
+ifeq ($(CONFIG_USB_MUSB_SOC),y)
+obj-y					+= usb-musb.o
+endif
diff --git a/arch/arm/mach-omap2/board-2430sdp.c b/arch/arm/mach-omap2/board-2430sdp.c
index 83fa372..9619e25 100644
--- a/arch/arm/mach-omap2/board-2430sdp.c
+++ b/arch/arm/mach-omap2/board-2430sdp.c
@@ -35,6 +35,7 @@
 #include <mach/board.h>
 #include <mach/common.h>
 #include <mach/gpmc.h>
+#include <mach/usb.h>
 
 #include "mmc-twl4030.h"
 
@@ -251,6 +252,7 @@ static void __init omap_2430sdp_init(void)
 	omap_board_config_size = ARRAY_SIZE(sdp2430_config);
 	omap_serial_init();
 	twl4030_mmc_init(mmc);
+	usb_musb_init();
 }
 
 static void __init omap_2430sdp_map_io(void)
diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
index 6031e17..1b54c20 100644
--- a/arch/arm/mach-omap2/board-ldp.c
+++ b/arch/arm/mach-omap2/board-ldp.c
@@ -38,6 +38,7 @@
 #include <asm/io.h>
 #include <asm/delay.h>
 #include <mach/control.h>
+#include <mach/usb.h>
 
 #include "mmc-twl4030.h"
 
@@ -162,6 +163,7 @@ static void __init omap_ldp_init(void)
 	omap_board_config_size = ARRAY_SIZE(ldp_config);
 	omap_serial_init();
 	twl4030_mmc_init(mmc);
+	usb_musb_init();
 }
 
 static void __init omap_ldp_map_io(void)
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index e3c8628..2f3d821 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -41,6 +41,7 @@
 #include <mach/gpmc.h>
 #include <mach/nand.h>
 #include <mach/mux.h>
+#include <mach/usb.h>
 
 #include "mmc-twl4030.h"
 
@@ -313,6 +314,7 @@ static void __init omap3_beagle_init(void)
 	/* REVISIT leave DVI powered down until it's needed ... */
 	gpio_direction_output(170, true);
 
+	usb_musb_init();
 	omap3beagle_flash_init();
 }
 
diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
index 6e17180..16e2128 100644
--- a/arch/arm/mach-omap2/board-omap3pandora.c
+++ b/arch/arm/mach-omap2/board-omap3pandora.c
@@ -34,6 +34,7 @@
 #include <mach/gpio.h>
 #include <mach/hardware.h>
 #include <mach/mcspi.h>
+#include <mach/usb.h>
 
 #include "mmc-twl4030.h"
 
@@ -200,6 +201,7 @@ static void __init omap3pandora_init(void)
 	spi_register_board_info(omap3pandora_spi_board_info,
 			ARRAY_SIZE(omap3pandora_spi_board_info));
 	omap3pandora_ads7846_init();
+	usb_musb_init();
 }
 
 static void __init omap3pandora_map_io(void)
diff --git a/arch/arm/mach-omap2/board-overo.c b/arch/arm/mach-omap2/board-overo.c
index 61f8e23..d785aa8 100644
--- a/arch/arm/mach-omap2/board-overo.c
+++ b/arch/arm/mach-omap2/board-overo.c
@@ -44,6 +44,7 @@
 #include <mach/gpmc.h>
 #include <mach/hardware.h>
 #include <mach/nand.h>
+#include <mach/usb.h>
 
 #include "mmc-twl4030.h"
 
@@ -223,6 +224,7 @@ static void __init overo_init(void)
 	omap_serial_init();
 	twl4030_mmc_init(mmc);
 	overo_flash_init();
+	usb_musb_init();
 
 	if ((gpio_request(OVERO_GPIO_W2W_NRESET,
 			  "OVERO_GPIO_W2W_NRESET") == 0) &&
diff --git a/arch/arm/mach-omap2/usb-musb.c b/arch/arm/mach-omap2/usb-musb.c
new file mode 100644
index 0000000..fc74e91
--- /dev/null
+++ b/arch/arm/mach-omap2/usb-musb.c
@@ -0,0 +1,187 @@
+/*
+ * linux/arch/arm/mach-omap2/usb-musb.c
+ *
+ * This file will contain the board specific details for the
+ * MENTOR USB OTG controller on OMAP3430
+ *
+ * Copyright (C) 2007-2008 Texas Instruments
+ * Copyright (C) 2008 Nokia Corporation
+ * Author: Vikram Pandita
+ *
+ * Generalization by:
+ * Felipe Balbi <felipe.balbi@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/delay.h>
+#include <linux/platform_device.h>
+#include <linux/clk.h>
+#include <linux/dma-mapping.h>
+#include <linux/io.h>
+
+#include <linux/usb/musb.h>
+
+#include <mach/hardware.h>
+#include <mach/irqs.h>
+#include <mach/pm.h>
+#include <mach/mux.h>
+#include <mach/usb.h>
+
+static struct resource musb_resources[] = {
+	[0] = { /* start and end set dynamically */
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {	/* general IRQ */
+		.start	= INT_243X_HS_USB_MC,
+		.flags	= IORESOURCE_IRQ,
+	},
+	[2] = {	/* DMA IRQ */
+		.start	= INT_243X_HS_USB_DMA,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static int clk_on;
+
+static int musb_set_clock(struct clk *clk, int state)
+{
+	if (state) {
+		if (clk_on > 0)
+			return -ENODEV;
+
+		clk_enable(clk);
+		clk_on = 1;
+	} else {
+		if (clk_on == 0)
+			return -ENODEV;
+
+		clk_disable(clk);
+		clk_on = 0;
+	}
+
+	return 0;
+}
+
+static struct musb_hdrc_eps_bits musb_eps[] = {
+	{	"ep1_tx", 10,	},
+	{	"ep1_rx", 10,	},
+	{	"ep2_tx", 9,	},
+	{	"ep2_rx", 9,	},
+	{	"ep3_tx", 3,	},
+	{	"ep3_rx", 3,	},
+	{	"ep4_tx", 3,	},
+	{	"ep4_rx", 3,	},
+	{	"ep5_tx", 3,	},
+	{	"ep5_rx", 3,	},
+	{	"ep6_tx", 3,	},
+	{	"ep6_rx", 3,	},
+	{	"ep7_tx", 3,	},
+	{	"ep7_rx", 3,	},
+	{	"ep8_tx", 2,	},
+	{	"ep8_rx", 2,	},
+	{	"ep9_tx", 2,	},
+	{	"ep9_rx", 2,	},
+	{	"ep10_tx", 2,	},
+	{	"ep10_rx", 2,	},
+	{	"ep11_tx", 2,	},
+	{	"ep11_rx", 2,	},
+	{	"ep12_tx", 2,	},
+	{	"ep12_rx", 2,	},
+	{	"ep13_tx", 2,	},
+	{	"ep13_rx", 2,	},
+	{	"ep14_tx", 2,	},
+	{	"ep14_rx", 2,	},
+	{	"ep15_tx", 2,	},
+	{	"ep15_rx", 2,	},
+};
+
+static struct musb_hdrc_config musb_config = {
+	.multipoint	= 1,
+	.dyn_fifo	= 1,
+	.soft_con	= 1,
+	.dma		= 1,
+	.num_eps	= 16,
+	.dma_channels	= 7,
+	.dma_req_chan	= (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3),
+	.ram_bits	= 12,
+	.eps_bits	= musb_eps,
+};
+
+static struct musb_hdrc_platform_data musb_plat = {
+#ifdef CONFIG_USB_MUSB_OTG
+	.mode		= MUSB_OTG,
+#elif defined(CONFIG_USB_MUSB_HDRC_HCD)
+	.mode		= MUSB_HOST,
+#elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
+	.mode		= MUSB_PERIPHERAL,
+#endif
+	/* .clock is set dynamically */
+	.set_clock	= musb_set_clock,
+	.config		= &musb_config,
+
+	/* REVISIT charge pump on TWL4030 can supply up to
+	 * 100 mA ... but this value is board-specific, like
+	 * "mode", and should be passed to usb_musb_init().
+	 */
+	.power		= 50,			/* up to 100 mA */
+};
+
+static u64 musb_dmamask = DMA_32BIT_MASK;
+
+static struct platform_device musb_device = {
+	.name		= "musb_hdrc",
+	.id		= -1,
+	.dev = {
+		.dma_mask		= &musb_dmamask,
+		.coherent_dma_mask	= DMA_32BIT_MASK,
+		.platform_data		= &musb_plat,
+	},
+	.num_resources	= ARRAY_SIZE(musb_resources),
+	.resource	= musb_resources,
+};
+
+#ifdef CONFIG_NOP_USB_XCEIV
+static u64 nop_xceiv_dmamask = DMA_32BIT_MASK;
+
+static struct platform_device nop_xceiv_device = {
+	.name		= "nop_usb_xceiv",
+	.id		= -1,
+	.dev = {
+		.dma_mask		= &nop_xceiv_dmamask,
+		.coherent_dma_mask	= DMA_32BIT_MASK,
+		.platform_data		= NULL,
+	},
+};
+#endif
+
+void __init usb_musb_init(void)
+{
+	if (cpu_is_omap243x())
+		musb_resources[0].start = OMAP243X_HS_BASE;
+	else
+		musb_resources[0].start = OMAP34XX_HSUSB_OTG_BASE;
+	musb_resources[0].end = musb_resources[0].start + SZ_8K - 1;
+
+	/*
+	 * REVISIT: This line can be removed once all the platforms using
+	 * musb_core.c have been converted to use use clkdev.
+	 */
+	musb_plat.clock = "ick";
+
+#ifdef CONFIG_NOP_USB_XCEIV
+	if (platform_device_register(&nop_xceiv_device) < 0) {
+		printk(KERN_ERR "Unable to register NOP-XCEIV device\n");
+		return;
+	}
+#endif
+
+	if (platform_device_register(&musb_device) < 0) {
+		printk(KERN_ERR "Unable to register HS-USB (MUSB) device\n");
+		return;
+	}
+}
diff --git a/arch/arm/plat-omap/include/mach/usb.h b/arch/arm/plat-omap/include/mach/usb.h
index e033e51..69f0cee 100644
--- a/arch/arm/plat-omap/include/mach/usb.h
+++ b/arch/arm/plat-omap/include/mach/usb.h
@@ -27,6 +27,14 @@
 #define UDC_BASE			OMAP2_UDC_BASE
 #define OMAP_OHCI_BASE			OMAP2_OHCI_BASE
 
+#ifdef CONFIG_USB_MUSB_SOC
+extern void usb_musb_init(void);
+#else
+static inline void usb_musb_init(void)
+{
+}
+#endif
+
 #endif
 
 void omap_usb_init(struct omap_usb_config *pdata);

  parent reply	other threads:[~2009-03-16 22:37 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-10 21:00 [PATCH 00/12] Omap3 updates for the merge window after 2.6.29 Tony Lindgren
2009-03-10 21:02 ` [PATCH 01/12] ARM: OMAP3: Remove unused CONFIG_I2C2_OMAP_BEAGLE Tony Lindgren
2009-03-10 21:03 ` [PATCH 02/12] ARM: OMAP3: Store reboot mode in scratchpad on OMAP34xx Tony Lindgren
2009-03-15 15:51   ` Russell King - ARM Linux
2009-03-16 16:07     ` Juha Yrjola
2009-03-16 17:10       ` Russell King - ARM Linux
2009-03-16 17:40         ` Juha Yrjola
2009-03-16 22:21           ` Russell King - ARM Linux
2009-03-18 18:28             ` Tony Lindgren
2009-03-18 19:26               ` Russell King - ARM Linux
2009-03-18 20:10                 ` Tony Lindgren
2009-03-18 20:15                   ` Tony Lindgren
2009-03-19  0:08                   ` Russell King - ARM Linux
2009-03-19 15:56                     ` Tony Lindgren
2009-03-24  1:11   ` Tony Lindgren
2009-03-10 21:04 ` [PATCH 03/12] ARM: OMAP3: Add more GPIO mux options Tony Lindgren
2009-03-10 21:06 ` [PATCH 04/12] ARM: OMAP3: mmc-twl4030 fix name buffer length Tony Lindgren
2009-03-15 16:00   ` Russell King - ARM Linux
2009-03-16 10:04     ` Adrian Hunter
2009-03-16 10:14       ` Russell King - ARM Linux
2009-03-16 17:42         ` Tony Lindgren
2009-03-16 22:22           ` Russell King - ARM Linux
2009-03-10 21:07 ` [PATCH 05/12] ARM: OMAP3: mmc-twl4030 voltage cleanup Tony Lindgren
2009-03-10 21:08 ` [PATCH 06/12] ARM: OMAP3: mmc-twl4030 init passes device nodes back Tony Lindgren
2009-03-15 16:02   ` Russell King - ARM Linux
2009-03-16 17:44     ` Tony Lindgren
2009-03-16 22:22       ` Russell King - ARM Linux
2009-03-10 21:10 ` [PATCH 07/12] ARM: OMAP3: mmc-twl4030 add MMC3 support Tony Lindgren
2009-03-15 16:04   ` Russell King - ARM Linux
2009-03-15 17:27     ` Grazvydas Ignotas
2009-03-15 17:40       ` Russell King - ARM Linux
2009-03-16 17:56         ` [PATCH 07/12] ARM: OMAP3: mmc-twl4030 add MMC3 support, v2 Tony Lindgren
2009-03-10 21:11 ` [PATCH 08/12] ARM: OMAP3: mmc-twl4030 fix for vmmc = 0 Tony Lindgren
2009-03-10 21:12 ` [PATCH 09/12] ARM: OMAP3: mmc-twl4030 add cover switch Tony Lindgren
2009-03-10 21:13 ` [PATCH 10/12] ARM: OMAP3: mmc-twl4030 allow arbitrary slot names Tony Lindgren
2009-03-15 16:08   ` Russell King - ARM Linux
2009-03-16 10:04     ` Adrian Hunter
2009-03-16 10:05     ` Adrian Hunter
2009-03-16 10:16       ` Russell King - ARM Linux
2009-03-16 18:01         ` Tony Lindgren
2009-03-10 21:15 ` [PATCH 11/12] ARM: OMAP3: Add base address definitions and resources for OMAP 3 IS Tony Lindgren
2009-03-24  1:37   ` [PATCH 11/12] ARM: OMAP3: Add base address definitions and resources for OMAP 3 IS, v2 Tony Lindgren
2009-03-10 21:16 ` [PATCH 12/12] ARM: OMAP3: MUSB initialization for omap hw Tony Lindgren
2009-03-15 16:14   ` Russell King - ARM Linux
2009-03-15 18:46     ` David Brownell
2009-03-16 22:42       ` [PATCH] ARM: OMAP: Add name for musb clocks Tony Lindgren
2009-05-12 17:40         ` [APPLIED] " Tony Lindgren
2009-03-16 22:37     ` Tony Lindgren [this message]
2009-03-24  2:51 ` [PATCH 00/12] Omap3 updates for the merge window after 2.6.29 Tony Lindgren

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=20090316223737.GN19229@atomide.com \
    --to=tony@atomide.com \
    --cc=ajay.gupta@ti.com \
    --cc=felipe.balbi@nokia.com \
    --cc=linux-arm-kernel@lists.arm.linux.org.uk \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    /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.