From patchwork Fri Apr 10 00:54:07 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 17858 X-Patchwork-Delegate: lethal@linux-sh.org 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 n3D0C4W7026662 for ; Mon, 13 Apr 2009 00:12:04 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751065AbZDMAMD (ORCPT ); Sun, 12 Apr 2009 20:12:03 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751895AbZDMAMB (ORCPT ); Sun, 12 Apr 2009 20:12:01 -0400 Received: from mail.renesas.com ([202.234.163.13]:40151 "EHLO mail06.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751065AbZDMAMB (ORCPT ); Sun, 12 Apr 2009 20:12:01 -0400 X-AuditID: ac14038a-0000000a00001ca1-b3-49e2833c0801 Received: from guardian02.idc.renesas.com ([172.20.8.201]) by mail06.idc.renesas.com (sendmail) with ESMTP id n3D0Bdh4018531; Mon, 13 Apr 2009 09:11:40 +0900 (JST) Received: (from root@localhost) by guardian02.idc.renesas.com with id n3D0BcHK009297; Mon, 13 Apr 2009 09:11:38 +0900 (JST) Received: from mta04.idc.renesas.com (localhost [127.0.0.1]) by mta04.idc.renesas.com with ESMTP id n3D0Bcgj002557; Mon, 13 Apr 2009 09:11:38 +0900 (JST) Received: from PG10870.renesas.com ([172.30.8.159]) by ims05.idc.renesas.com (Sendmail) with ESMTPA id <0KI0003PCJ7DGK@ims05.idc.renesas.com>; Mon, 13 Apr 2009 09:11:39 +0900 (JST) Date: Fri, 10 Apr 2009 09:54:07 +0900 From: Kuninori Morimoto Subject: [PATCH v2] sh7786: modify usb setup timeout judgment bug. To: Paul Mundt Cc: SH-Linux , juha_motorsportcom@luukku.com, Michael Trimarchi , Nobuhiro Iwamatsu 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 Timeout counter "i" can reach -1 if USB setup isn't done. And "i" can be 0 if USB setup is done when last possible moment. Then it is judged to fail though setup is done. This patch modify this problem. Special thanks to Mr. Juha Leppanen and Iwamatsu-san for nice advice. Reported-by: "Juha Leppanen" Signed-off-by: Kuninori Morimoto --- >> Paul Can you test this patch on Urquell board please ? >> Michael I will try to create patch which skip setup if bootloader is already done. please wait. v1 -> v2 o Set the PHY RST bit in "while loop". Thank you Iwamatsu-san o Add Iwamatsu-san's name in patch explanation area arch/sh/kernel/cpu/sh4a/setup-sh7786.c | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7786.c b/arch/sh/kernel/cpu/sh4a/setup-sh7786.c index 5a47e1c..90e8cff 100644 --- a/arch/sh/kernel/cpu/sh4a/setup-sh7786.c +++ b/arch/sh/kernel/cpu/sh4a/setup-sh7786.c @@ -143,14 +143,14 @@ static void __init sh7786_usb_setup(void) * 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)) + while (i--) { + if (ACT_PLL_STATUS == (__raw_readl(USBST) & ACT_PLL_STATUS)) { + /* Set the PHY RST bit */ + __raw_writel(PHY_ENB | PLL_ENB | PHY_RST, USBPCTL1); + printk(KERN_INFO "sh7786 usb setup done\n"); + break; + } 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"); } }