]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
sh: Add OHCI USB support for SH7786
authorKuninori Morimoto <morimoto.kuninori@renesas.com>
Thu, 12 Mar 2009 08:40:15 +0000 (08:40 +0000)
committerPaul Mundt <lethal@linux-sh.org>
Mon, 16 Mar 2009 10:40:34 +0000 (19:40 +0900)
Signed-off-by: Kuninori Morimoto <morimoto.kuninori@renesas.com>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
arch/sh/kernel/cpu/sh4a/setup-sh7786.c
drivers/usb/Kconfig
drivers/usb/host/ohci-hcd.c

index 249b99e1adb5c0d8996abcd24d53749b181b677d..5a47e1cf442eb97a39778c053fa588ce97f0f124 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/serial_sci.h>
 #include <linux/io.h>
 #include <linux/mm.h>
+#include <linux/dma-mapping.h>
 #include <asm/mmzone.h>
 
 static struct plat_sci_port sci_platform_data[] = {
@@ -68,12 +69,94 @@ 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 = DMA_BIT_MASK(32);
+static struct platform_device usb_ohci_device = {
+       .name           = "sh_ohci",
+       .id             = -1,
+       .dev = {
+               .dma_mask               = &usb_ohci_dma_mask,
+               .coherent_dma_mask      = DMA_BIT_MASK(32),
+       },
+       .num_resources  = ARRAY_SIZE(usb_ohci_resources),
+       .resource       = usb_ohci_resources,
+};
+
 static struct platform_device *sh7786_devices[] __initdata = {
        &sci_device,
+       &usb_ohci_device,
 };
 
+
+/*
+ * Please call this function if your platform board
+ * use external clock for USB
+ * */
+#define USBCTL0                0xffe70858
+#define CLOCK_MODE_MASK 0xffffff7f
+#define EXT_CLOCK_MODE  0x00000080
+void __init sh7786_usb_use_exclock(void)
+{
+       u32 val = __raw_readl(USBCTL0) & CLOCK_MODE_MASK;
+       __raw_writel(val | EXT_CLOCK_MODE, USBCTL0);
+}
+
+#define USBINITREG1    0xffe70094
+#define USBINITREG2    0xffe7009c
+#define USBINITVAL1    0x00ff0040
+#define USBINITVAL2    0x00000001
+
+#define USBPCTL1       0xffe70804
+#define USBST          0xffe70808
+#define PHY_ENB                0x00000001
+#define PLL_ENB                0x00000002
+#define PHY_RST                0x00000004
+#define ACT_PLL_STATUS 0xc0000000
+static void __init sh7786_usb_setup(void)
+{
+       int i = 1000000;
+
+       /*
+        * USB initial settings
+        *
+        * The following settings are necessary
+        * for using the USB modules.
+        *
+        * see "USB Inital Settings" for detail
+        */
+       __raw_writel(USBINITVAL1, USBINITREG1);
+       __raw_writel(USBINITVAL2, USBINITREG2);
+
+       /*
+        * Set the PHY and PLL enable bit
+        */
+       __raw_writel(PHY_ENB | PLL_ENB, USBPCTL1);
+       while (i-- &&
+              ((__raw_readl(USBST) & ACT_PLL_STATUS) != ACT_PLL_STATUS))
+               cpu_relax();
+
+       if (i) {
+               /* Set the PHY RST bit */
+               __raw_writel(PHY_ENB | PLL_ENB | PHY_RST, USBPCTL1);
+               printk(KERN_INFO "sh7786 usb setup done\n");
+       }
+}
+
 static int __init sh7786_devices_setup(void)
 {
+       sh7786_usb_setup();
        return platform_add_devices(sh7786_devices,
                                    ARRAY_SIZE(sh7786_devices));
 }
index 83babb0a1df7146a34208754b348d0621f5b3e7e..c6c816b7ecb5d30cacf1dbfe4ca1115df3553788 100644 (file)
@@ -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
 
index 5cf5f1eca4f40d4288d1127647723eb11a6c7781..7658589edb1c289007f124fa07ebf44512f0244b 100644 (file)
@@ -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