From patchwork Mon Mar 2 05:16:06 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 9488 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n225OjwS000777 for ; Mon, 2 Mar 2009 05:24:45 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750730AbZCBFYp (ORCPT ); Mon, 2 Mar 2009 00:24:45 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750786AbZCBFYp (ORCPT ); Mon, 2 Mar 2009 00:24:45 -0500 Received: from mail.renesas.com ([202.234.163.13]:54141 "EHLO mail02.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750730AbZCBFYo (ORCPT ); Mon, 2 Mar 2009 00:24:44 -0500 X-AuditID: ac140385-00000009000002de-d0-49ab6d98343b Received: from guardian02.idc.renesas.com ([172.20.8.201]) by mail02.idc.renesas.com (sendmail) with ESMTP id n225OeBe016980; Mon, 2 Mar 2009 14:24:40 +0900 (JST) Received: (from root@localhost) by guardian02.idc.renesas.com with id n225OfAr007509; Mon, 2 Mar 2009 14:24:41 +0900 (JST) Received: from mta01.idc.renesas.com (localhost [127.0.0.1]) by mta01.idc.renesas.com with ESMTP id n225OeQv024294; Mon, 2 Mar 2009 14:24:41 +0900 (JST) Received: from PG10870.renesas.com ([172.30.8.159]) by ims05.idc.renesas.com (Sendmail) with ESMTPA id <0KFV009BV5P4BG@ims05.idc.renesas.com>; Mon, 02 Mar 2009 14:24:41 +0900 (JST) Date: Mon, 02 Mar 2009 14:16:06 +0900 From: Kuninori Morimoto Subject: [PATCH] Add OHCI USB support for SH7786 To: Paul Mundt Cc: SH-Linux Message-id: MIME-version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-type: text/plain; charset=US-ASCII User-Agent: SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL/10.7 Emacs/22.1 (i386-mingw-nt5.1.2600) MULE/5.0 (SAKAKI) Meadow/3.00-dev (KIKU) X-Brightmail-Tracker: AAAAAA== Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org Signed-off-by: Kuninori Morimoto --- 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(-) 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