From patchwork Thu Apr 9 04:38:00 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 17315 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 n395MSpZ031218 for ; Thu, 9 Apr 2009 05:22:29 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758934AbZDIFW2 (ORCPT ); Thu, 9 Apr 2009 01:22:28 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1759288AbZDIFW2 (ORCPT ); Thu, 9 Apr 2009 01:22:28 -0400 Received: from mail.renesas.com ([202.234.163.13]:53243 "EHLO mail01.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1758934AbZDIFW1 (ORCPT ); Thu, 9 Apr 2009 01:22:27 -0400 X-AuditID: ac140384-00000005000004f6-06-49dd860a1caf Received: from guardian01.idc.renesas.com ([172.20.8.200]) by mail01.idc.renesas.com (sendmail) with ESMTP id n395MIKf008459; Thu, 9 Apr 2009 14:22:18 +0900 (JST) Received: (from root@localhost) by guardian01.idc.renesas.com with id n395MIHW010427; Thu, 9 Apr 2009 14:22:18 +0900 (JST) Received: from mta03.idc.renesas.com (localhost [127.0.0.1]) by mta03.idc.renesas.com with ESMTP id n395MJ1I023966; Thu, 9 Apr 2009 14:22:19 +0900 (JST) Received: from PG10870.renesas.com ([172.30.8.159]) by ims05.idc.renesas.com (Sendmail) with ESMTPA id <0KHT007SUIX6O2@ims05.idc.renesas.com>; Thu, 09 Apr 2009 14:22:18 +0900 (JST) Date: Thu, 09 Apr 2009 13:38:00 +0900 From: Kuninori Morimoto Subject: [PATCH] sh7786: modify usb setup timeout judgment bug. To: Paul Mundt Cc: SH-Linux , juha_motorsportcom@luukku.com 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 for nice advice. Reported-by: "Juha Leppanen" Signed-off-by: Kuninori Morimoto --- > Paul Can you test this patch on Urquell board please ? arch/sh/kernel/cpu/sh4a/setup-sh7786.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7786.c b/arch/sh/kernel/cpu/sh4a/setup-sh7786.c index 5a47e1c..ee30e68 100644 --- a/arch/sh/kernel/cpu/sh4a/setup-sh7786.c +++ b/arch/sh/kernel/cpu/sh4a/setup-sh7786.c @@ -127,6 +127,7 @@ void __init sh7786_usb_use_exclock(void) static void __init sh7786_usb_setup(void) { int i = 1000000; + u32 val; /* * USB initial settings @@ -143,11 +144,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--) { + val = __raw_readl(USBST) & ACT_PLL_STATUS; + if (ACT_PLL_STATUS == val) + break; cpu_relax(); + } - if (i) { + if (ACT_PLL_STATUS == val) { /* Set the PHY RST bit */ __raw_writel(PHY_ENB | PLL_ENB | PHY_RST, USBPCTL1); printk(KERN_INFO "sh7786 usb setup done\n");