From patchwork Fri Sep 28 17:09:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Beno=C3=AEt_Th=C3=A9baudeau?= X-Patchwork-Id: 187839 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 77BE02C00BA for ; Sat, 29 Sep 2012 03:04:18 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B57B2280C6; Fri, 28 Sep 2012 19:04:16 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hCS3xqGOvzd0; Fri, 28 Sep 2012 19:04:16 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5D43028099; Fri, 28 Sep 2012 19:04:14 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4D43228099 for ; Fri, 28 Sep 2012 19:04:11 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 12Nxd2D8STx5 for ; Fri, 28 Sep 2012 19:04:10 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from zose-mta15.web4all.fr (zose-mta15.web4all.fr [176.31.217.11]) by theia.denx.de (Postfix) with ESMTP id 12E4A28090 for ; Fri, 28 Sep 2012 19:04:08 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zose-mta15.web4all.fr (Postfix) with ESMTP id 4FD9932105; Fri, 28 Sep 2012 19:07:10 +0200 (CEST) X-Virus-Scanned: amavisd-new at zose1.web4all.fr Received: from zose-mta15.web4all.fr ([127.0.0.1]) by localhost (zose-mta15.web4all.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UjcRmPGgp27M; Fri, 28 Sep 2012 19:07:09 +0200 (CEST) Received: from zose-store12.web4all.fr (zose-store-12.w4a.fr [178.33.204.48]) by zose-mta15.web4all.fr (Postfix) with ESMTP id 479A7320F9; Fri, 28 Sep 2012 19:07:09 +0200 (CEST) Date: Fri, 28 Sep 2012 19:09:03 +0200 (CEST) From: =?utf-8?Q?Beno=C3=AEt_Th=C3=A9baudeau?= To: U-Boot-Users ML Message-ID: <1907961929.5443516.1348852143703.JavaMail.root@advansee.com> In-Reply-To: <1466470464.5372380.1348777318566.JavaMail.root@advansee.com> MIME-Version: 1.0 X-Originating-IP: [88.188.188.98] X-Mailer: Zimbra 7.2.0_GA_2669 (ZimbraWebClient - FF3.0 (Win)/7.2.0_GA_2669) Cc: Marek Vasut , Wolfgang Grandegger , Jana Rapava Subject: [U-Boot] [PATCH v3 05/14] mx51: Fix USB PHY clocks X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de The i.MX51 has a single USB PHY clock, while the i.MX53 has two. These 3 clocks have different clock gate control bit-fields. The existing code was correct only for i.MX53, so this patch fixes the i.MX51 use case. Signed-off-by: Benoît Thébaudeau Cc: Stefano Babic Cc: Marek Vasut Cc: Jana Rapava Cc: Wolfgang Grandegger Cc: Igor Grinberg Acked-by: Igor Grinberg --- This patch supersedes http://patchwork.ozlabs.org/patch/187458/ . Changes for v2: - Split patch into 3 parts (the 3, 4 and 5 from this v2 series). - Merge the various set_usb_phy*_clk() functions (they were identical). Changes for v3: - Use same functions on i.MX51 (with one empty) as on i.MX53 in order to avoid #ifdef's. .../arch/arm/cpu/armv7/mx5/clock.c | 25 ++++++++++++++------ .../arch/arm/include/asm/arch-mx5/clock.h | 3 ++- .../drivers/usb/host/ehci-mx5.c | 3 ++- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git u-boot-imx-e1eb75b.orig/arch/arm/cpu/armv7/mx5/clock.c u-boot-imx-e1eb75b/arch/arm/cpu/armv7/mx5/clock.c index df7e5cd..fd5456e 100644 --- u-boot-imx-e1eb75b.orig/arch/arm/cpu/armv7/mx5/clock.c +++ u-boot-imx-e1eb75b/arch/arm/cpu/armv7/mx5/clock.c @@ -126,23 +126,33 @@ int enable_i2c_clk(unsigned char enable, unsigned i2c_num) } #endif -void set_usb_phy1_clk(void) +void set_usb_phy_clk(void) { clrbits_le32(&mxc_ccm->cscmr1, MXC_CCM_CSCMR1_USB_PHY_CLK_SEL); } +#if defined(CONFIG_MX51) void enable_usb_phy1_clk(unsigned char enable) { unsigned int cg = enable ? MXC_CCM_CCGR_CG_ON : MXC_CCM_CCGR_CG_OFF; - clrsetbits_le32(&mxc_ccm->CCGR4, - MXC_CCM_CCGR4_USB_PHY1(MXC_CCM_CCGR_CG_MASK), - MXC_CCM_CCGR4_USB_PHY1(cg)); + clrsetbits_le32(&mxc_ccm->CCGR2, + MXC_CCM_CCGR2_USB_PHY(MXC_CCM_CCGR_CG_MASK), + MXC_CCM_CCGR2_USB_PHY(cg)); } -void set_usb_phy2_clk(void) +void enable_usb_phy2_clk(unsigned char enable) { - clrbits_le32(&mxc_ccm->cscmr1, MXC_CCM_CSCMR1_USB_PHY_CLK_SEL); + /* i.MX51 has a single USB PHY clock, so do nothing here. */ +} +#elif defined(CONFIG_MX53) +void enable_usb_phy1_clk(unsigned char enable) +{ + unsigned int cg = enable ? MXC_CCM_CCGR_CG_ON : MXC_CCM_CCGR_CG_OFF; + + clrsetbits_le32(&mxc_ccm->CCGR4, + MXC_CCM_CCGR4_USB_PHY1(MXC_CCM_CCGR_CG_MASK), + MXC_CCM_CCGR4_USB_PHY1(cg)); } void enable_usb_phy2_clk(unsigned char enable) @@ -153,6 +163,7 @@ void enable_usb_phy2_clk(unsigned char enable) MXC_CCM_CCGR4_USB_PHY2(MXC_CCM_CCGR_CG_MASK), MXC_CCM_CCGR4_USB_PHY2(cg)); } +#endif /* * Calculate the frequency of PLLn. @@ -803,7 +814,7 @@ void mxc_set_sata_internal_clock(void) u32 *tmp_base = (u32 *)(IIM_BASE_ADDR + 0x180c); - set_usb_phy1_clk(); + set_usb_phy_clk(); clrsetbits_le32(tmp_base, 0x6, 0x4); } diff --git u-boot-imx-e1eb75b.orig/arch/arm/include/asm/arch-mx5/clock.h u-boot-imx-e1eb75b/arch/arm/include/asm/arch-mx5/clock.h index 55e3b51..668e913 100644 --- u-boot-imx-e1eb75b.orig/arch/arm/include/asm/arch-mx5/clock.h +++ u-boot-imx-e1eb75b/arch/arm/include/asm/arch-mx5/clock.h @@ -56,7 +56,8 @@ u32 imx_get_uartclk(void); u32 imx_get_fecclk(void); unsigned int mxc_get_clock(enum mxc_clock clk); int mxc_set_clock(u32 ref, u32 freq, u32 clk_type); -void set_usb_phy2_clk(void); +void set_usb_phy_clk(void); +void enable_usb_phy1_clk(unsigned char enable); void enable_usb_phy2_clk(unsigned char enable); void set_usboh3_clk(void); void enable_usboh3_clk(unsigned char enable); diff --git u-boot-imx-e1eb75b.orig/drivers/usb/host/ehci-mx5.c u-boot-imx-e1eb75b/drivers/usb/host/ehci-mx5.c index 58cdcbe..fbfd310 100644 --- u-boot-imx-e1eb75b.orig/drivers/usb/host/ehci-mx5.c +++ u-boot-imx-e1eb75b/drivers/usb/host/ehci-mx5.c @@ -221,7 +221,8 @@ int ehci_hcd_init(void) set_usboh3_clk(); enable_usboh3_clk(1); - set_usb_phy2_clk(); + set_usb_phy_clk(); + enable_usb_phy1_clk(1); enable_usb_phy2_clk(1); mdelay(1);