diff mbox

Add OHCI USB support for SH7786

Message ID uy6vozecn.wl%morimoto.kuninori@renesas.com (mailing list archive)
State Superseded
Headers show

Commit Message

Kuninori Morimoto March 2, 2009, 5:16 a.m. UTC
Signed-off-by: Kuninori Morimoto <morimoto.kuninori@renesas.com>
---
 arch/sh/kernel/cpu/sh4a/setup-sh7786.c |   60 ++++++++++++++++++++++++++++++++
 drivers/usb/Kconfig                    |    1 +
 drivers/usb/host/ohci-hcd.c            |    3 +-
 3 files changed, 63 insertions(+), 1 deletions(-)

Comments

Paul Mundt March 3, 2009, 6:50 a.m. UTC | #1
On Mon, Mar 02, 2009 at 02:16:06PM +0900, Kuninori Morimoto wrote:
> +static u64 usb_ohci_dma_mask = 0xffffffffUL;

Please use DMA_BIT_MASK(32) here for the initializer instead. The
definition is in linux/dma-mapping.h.

> +static struct platform_device usb_ohci_device = {
> +	.name		= "sh_ohci",
> +	.id		= -1,
> +	.dev = {
> +		.dma_mask		= &usb_ohci_dma_mask,
> +		.coherent_dma_mask	= 0xffffffff,
> +	},

Likewise for the coherent_dma_mask.

> +int __init sh7786_usb_setup(int exclock)
> +{
Where is this function used?

> +	int i;
> +	u32 val;
> +
> +	ctrl_outl(0x00ff0040, 0xffe70094);
> +	ctrl_outl(0x00000001, 0xffe7009c);
> +
This needs documenting. Also, please use __raw_writel() and friends
instead of the ctrl_xxx() variants for new code.

> +	val = ctrl_inl(USBCTL0) & 0xffffff7f;
> +	if (exclock)
> +		val |= 0x00000080;
> +	ctrl_outl(val, USBCTL0);
> +
The above mask and bit definition should have macros associated with
them, so we know precisely what is changing.

> +	/* Set the PHY ENB bit */
> +	i = 1000000;
> +	ctrl_outl(0x00000001, USBPCTL1);
> +	while (i-- && !(ctrl_inl(USBST) & (1 << 30)))
> +		;
> +
This is not sufficient, all new versions of gcc will optimize this away.
At the very least, you will need a cpu_relax(); to prevent the loop
optimization.

> +	/* Set the PLL ENB bit */
> +	i = 1000000;
> +	ctrl_outl(0x00000003, USBPCTL1);
> +	while (i-- && ((ctrl_inl(USBST) & (0x3 << 30)) != (0x3 << 30)))
> +		;
> +
Likewise.
--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7786.c b/arch/sh/kernel/cpu/sh4a/setup-sh7786.c
index ca5d987..ad5b4d4 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7786.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7786.c
@@ -68,10 +68,70 @@  static struct platform_device sci_device = {
 	},
 };
 
+static struct resource usb_ohci_resources[] = {
+	[0] = {
+		.start	= 0xffe70400,
+		.end	= 0xffe704ff,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.start	= 77,
+		.end	= 77,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static u64 usb_ohci_dma_mask = 0xffffffffUL;
+static struct platform_device usb_ohci_device = {
+	.name		= "sh_ohci",
+	.id		= -1,
+	.dev = {
+		.dma_mask		= &usb_ohci_dma_mask,
+		.coherent_dma_mask	= 0xffffffff,
+	},
+	.num_resources	= ARRAY_SIZE(usb_ohci_resources),
+	.resource	= usb_ohci_resources,
+};
+
 static struct platform_device *sh7786_devices[] __initdata = {
 	&sci_device,
+	&usb_ohci_device,
 };
 
+#define USBPCTL1	0xffe70804
+#define USBST		0xffe70808
+#define USBCTL0		0xffe70858
+int __init sh7786_usb_setup(int exclock)
+{
+	int i;
+	u32 val;
+
+	ctrl_outl(0x00ff0040, 0xffe70094);
+	ctrl_outl(0x00000001, 0xffe7009c);
+
+	val = ctrl_inl(USBCTL0) & 0xffffff7f;
+	if (exclock)
+		val |= 0x00000080;
+	ctrl_outl(val, USBCTL0);
+
+	/* Set the PHY ENB bit */
+	i = 1000000;
+	ctrl_outl(0x00000001, USBPCTL1);
+	while (i-- && !(ctrl_inl(USBST) & (1 << 30)))
+		;
+
+	/* Set the PLL ENB bit */
+	i = 1000000;
+	ctrl_outl(0x00000003, USBPCTL1);
+	while (i-- && ((ctrl_inl(USBST) & (0x3 << 30)) != (0x3 << 30)))
+		;
+
+	/* Set the PHY RST bit */
+	ctrl_outl(0x00000007, USBPCTL1);
+
+	printk(KERN_INFO "sh7786 usb setup done\n");
+}
+
 static int __init sh7786_devices_setup(void)
 {
 	return platform_add_devices(sh7786_devices,
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index 83babb0..c6c816b 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -47,6 +47,7 @@  config USB_ARCH_HAS_OHCI
 	default y if CPU_SUBTYPE_SH7720
 	default y if CPU_SUBTYPE_SH7721
 	default y if CPU_SUBTYPE_SH7763
+	default y if CPU_SUBTYPE_SH7786
 	# more:
 	default PCI
 
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 5cf5f1e..7658589 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -1049,7 +1049,8 @@  MODULE_LICENSE ("GPL");
 
 #if defined(CONFIG_CPU_SUBTYPE_SH7720) || \
     defined(CONFIG_CPU_SUBTYPE_SH7721) || \
-    defined(CONFIG_CPU_SUBTYPE_SH7763)
+    defined(CONFIG_CPU_SUBTYPE_SH7763) || \
+    defined(CONFIG_CPU_SUBTYPE_SH7786)
 #include "ohci-sh.c"
 #define PLATFORM_DRIVER		ohci_hcd_sh_driver
 #endif