From patchwork Fri Jun 24 18:51:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Constantine Shulyupin X-Patchwork-Id: 917272 Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p5OIqjq7014501 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 24 Jun 2011 18:53:11 GMT Received: from dlep35.itg.ti.com ([157.170.170.118]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id p5OIpgoX023417 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 24 Jun 2011 13:51:42 -0500 Received: from linux.omap.com (smtp-le.itg.ti.com [157.170.170.27]) by dlep35.itg.ti.com (8.13.7/8.13.8) with ESMTP id p5OIpfwC004021; Fri, 24 Jun 2011 13:51:41 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 4575180627; Fri, 24 Jun 2011 13:51:41 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp51.itg.ti.com (dflp51.itg.ti.com [128.247.22.94]) by linux.omap.com (Postfix) with ESMTP id 4512880626 for ; Fri, 24 Jun 2011 13:51:40 -0500 (CDT) Received: from medina.ext.ti.com (medina.ext.ti.com [192.91.81.31]) by dflp51.itg.ti.com (8.13.7/8.13.8) with ESMTP id p5OIpe2g004127 for ; Fri, 24 Jun 2011 13:51:40 -0500 (CDT) Received: from psmtp.com (na3sys009amx179.postini.com [74.125.149.160]) by medina.ext.ti.com (8.13.7/8.13.7) with SMTP id p5OIpd5X021649 for ; Fri, 24 Jun 2011 13:51:39 -0500 Received: from oproxy3-pub.bluehost.com ([69.89.21.8]) by na3sys009amx179.postini.com ([74.125.148.10]) with SMTP; Fri, 24 Jun 2011 18:51:39 GMT Received: (qmail 31075 invoked by uid 0); 24 Jun 2011 18:51:33 -0000 Received: from unknown (HELO box668.bluehost.com) (66.147.244.168) by oproxy3.bluehost.com with SMTP; 24 Jun 2011 18:51:32 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=makelinux.com; h=MIME-Version:Date:Message-ID:Subject:From:To:Cc:Content-Type:X-Identified-User; b=KeLFqd6LBI8RtwriVYbrHV88/e8Ra+6sv2WWuInw9sZFPmr63lqQunlN4atASkPkf7o+7gFhbV4j0MxK5nejWIVgH+3N/AVsObSqVZRKh8QXCrYv/NrGaHIRgYx5glUh; Received: from mail-qy0-f173.google.com ([209.85.216.173]) by box668.bluehost.com with esmtpsa (TLSv1:RC4-SHA:128) (Exim 4.69) (envelope-from ) id 1QaBTY-0008Np-B1 for davinci-linux-open-source@linux.davincidsp.com; Fri, 24 Jun 2011 12:51:32 -0600 Received: by qyk10 with SMTP id 10so535029qyk.4 for ; Fri, 24 Jun 2011 11:51:31 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.26.84 with SMTP id d20mr2049108qcc.203.1308941491520; Fri, 24 Jun 2011 11:51:31 -0700 (PDT) Received: by 10.229.235.193 with HTTP; Fri, 24 Jun 2011 11:51:31 -0700 (PDT) Date: Fri, 24 Jun 2011 21:51:31 +0300 Message-ID: Subject: [PATCH] Enable USB on TI DM365 From: Constantine Shulyupin To: linux-kernel@vger.kernel.org, linux-embedded@vger.kernel.org, davinci-linux-open-source@linux.davincidsp.com X-Identified-User: {1470:box668.bluehost.com:makelinu:makelinux.com} {sentby:smtp auth 209.85.216.173 authed with const@makelinux.com} X-pstn-levels: (S:52.29819/99.90000 CV:99.9000 FC:95.5390 LC:95.5390 R:95.9108 P:95.9108 M:97.0282 C:98.6951 ) X-pstn-settings: 2 (0.5000:0.5000) s cv gt3 gt2 gt1 r p m c X-pstn-addresses: from [35/1] X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: davinci-linux-open-source-bounces@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com X-Greylist: Sender succeeded STARTTLS authentication, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Fri, 24 Jun 2011 18:53:12 +0000 (UTC) Enable USB on TI DM365 Signed-off-by: Constantine Shulyupin --- arch/arm/mach-davinci/Makefile | 3 +- arch/arm/mach-davinci/include/mach/usb.h | 2 +- arch/arm/mach-davinci/usb.c | 32 ++++++++++++++++++++++++++--- drivers/usb/musb/davinci.c | 13 ++++++++++++ drivers/usb/musb/davinci.h | 1 + 5 files changed, 45 insertions(+), 6 deletions(-) diff --git a/arch/arm/mach-davinci/Makefile b/arch/arm/mach-davinci/Makefile index 0b87a1c..52961a8 100644 --- a/arch/arm/mach-davinci/Makefile +++ b/arch/arm/mach-davinci/Makefile @@ -5,7 +5,7 @@ # Common objects obj-y := time.o clock.o serial.o io.o psc.o \ - gpio.o dma.o usb.o common.o sram.o aemif.o + gpio.o dma.o common.o sram.o aemif.o obj-$(CONFIG_DAVINCI_MUX) += mux.o @@ -40,3 +40,4 @@ obj-$(CONFIG_MACH_OMAPL138_HAWKBOARD) += board-omapl138-hawk.o obj-$(CONFIG_CPU_FREQ) += cpufreq.o obj-$(CONFIG_CPU_IDLE) += cpuidle.o obj-$(CONFIG_SUSPEND) += pm.o sleep.o +obj-$(CONFIG_USB_MUSB_DAVINCI) += usb.o diff --git a/arch/arm/mach-davinci/include/mach/usb.h b/arch/arm/mach-davinci/include/mach/usb.h index e0bc4ab..863c27f 100644 --- a/arch/arm/mach-davinci/include/mach/usb.h +++ b/arch/arm/mach-davinci/include/mach/usb.h @@ -54,6 +54,6 @@ struct da8xx_ohci_root_hub { u8 potpgt; }; -void davinci_setup_usb(unsigned mA, unsigned potpgt_ms); +int davinci_setup_usb(unsigned mA, unsigned potpgt_ms); #endif /* ifndef __ASM_ARCH_USB_H */ diff --git a/arch/arm/mach-davinci/usb.c b/arch/arm/mach-davinci/usb.c index 23d2b6d..8b12206 100644 --- a/arch/arm/mach-davinci/usb.c +++ b/arch/arm/mach-davinci/usb.c @@ -4,19 +4,22 @@ #include #include #include - #include #include #include #include #include +#include +#include #define DAVINCI_USB_OTG_BASE 0x01c64000 #define DA8XX_USB0_BASE 0x01e00000 #define DA8XX_USB1_BASE 0x01e25000 +static int retval; + #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE) static struct musb_hdrc_eps_bits musb_eps[] = { { "ep1_tx", 8, }, @@ -87,7 +90,7 @@ static struct platform_device usb_dev = { .num_resources = ARRAY_SIZE(usb_resources), }; -void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms) +int __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms) { usb_data.power = mA > 510 ? 255 : mA / 2; usb_data.potpgt = (potpgt_ms + 1) / 2; @@ -99,7 +102,8 @@ void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms) } else /* other devices don't have dedicated CPPI IRQ */ usb_dev.num_resources = 2; - platform_device_register(&usb_dev); + retval = platform_device_register(&usb_dev); + return retval; } #ifdef CONFIG_ARCH_DAVINCI_DA8XX @@ -132,7 +136,7 @@ int __init da8xx_register_usb20(unsigned mA, unsigned potpgt) #else -void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms) +int __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms) { } @@ -178,3 +182,23 @@ int __init da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata) return platform_device_register(&da8xx_usb11_device); } #endif /* CONFIG_DAVINCI_DA8XX */ + +#ifdef CONFIG_MACH_DAVINCI_DM365_EVM +int __init dm365evm_usb_configure(void) +{ + davinci_cfg_reg(DM365_GPIO33); + gpio_request(33, "usb"); + gpio_direction_output(33, 1); + retval = davinci_setup_usb(500, 8); + return retval; +} +subsys_initcall(dm365evm_usb_configure); + +static void __exit dm365evm_usb_exit(void) +{ + platform_device_unregister(&usb_dev); +} +module_exit(dm365evm_usb_exit); + +#endif +MODULE_LICENSE("GPL"); diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c index 2a2adf6..0147f5c 100644 --- a/drivers/usb/musb/davinci.c +++ b/drivers/usb/musb/davinci.c @@ -72,6 +72,16 @@ static inline void phy_on(void) /* power everything up; start the on-chip PHY and its PLL */ phy_ctrl &= ~(USBPHY_OSCPDWN | USBPHY_OTGPDWN | USBPHY_PHYPDWN); phy_ctrl |= USBPHY_SESNDEN | USBPHY_VBDTCTEN | USBPHY_PHYPLLON; + + if (cpu_is_davinci_dm365()) { + /* + * DM365 PHYCLKFREQ field [15:12] is set to 2 + * to get clock from 24MHz crystal + */ + phy_ctrl |= USBPHY_CLKFREQ_24MHZ; + /*phy_ctrl &= ~USBPHY_PHYPDWN;*/ + } + __raw_writel(phy_ctrl, USB_PHY_CTRL); /* wait for PLL to lock before proceeding */ @@ -193,6 +203,9 @@ static void davinci_musb_source_power(struct musb *musb, int is_on, int immediat else schedule_work(&evm_vbus_work); } + + if (cpu_is_davinci_dm365()) + gpio_set_value(33, is_on); if (immediate) vbus_state = is_on; #endif diff --git a/drivers/usb/musb/davinci.h b/drivers/usb/musb/davinci.h index 046c844..1bf50e6 100644 --- a/drivers/usb/musb/davinci.h +++ b/drivers/usb/musb/davinci.h @@ -17,6 +17,7 @@ /* Integrated highspeed/otg PHY */ #define USBPHY_CTL_PADDR (DAVINCI_SYSTEM_MODULE_BASE + 0x34) #define USBPHY_DATAPOL BIT(11) /* (dm355) switch D+/D- */ +#define USBPHY_CLKFREQ_24MHZ BIT(13) #define USBPHY_PHYCLKGD BIT(8) #define USBPHY_SESNDEN BIT(7) /* v(sess_end) comparator */ #define USBPHY_VBDTCTEN BIT(6) /* v(bus) comparator */