From patchwork Sat Oct 13 00:02:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 191249 X-Patchwork-Delegate: trini@ti.com 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 9FC1D2C0089 for ; Sat, 13 Oct 2012 11:02:29 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id ADEBC4A109; Sat, 13 Oct 2012 02:02:27 +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 K+x1AhlUKFBd; Sat, 13 Oct 2012 02:02:27 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 23FFE4A0FC; Sat, 13 Oct 2012 02:02:26 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7DAF74A102 for ; Sat, 13 Oct 2012 02:02:24 +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 8mwlr3aPuicO for ; Sat, 13 Oct 2012 02:02:22 +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 mail-gg0-f202.google.com (mail-gg0-f202.google.com [209.85.161.202]) by theia.denx.de (Postfix) with ESMTPS id D49854A103 for ; Sat, 13 Oct 2012 02:02:14 +0200 (CEST) Received: by mail-gg0-f202.google.com with SMTP id i4so411925ggm.3 for ; Fri, 12 Oct 2012 17:02:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=Yq22T7jylWcOquQJLWhyS+zQBm63QwWDm3eMS4MxnDY=; b=Em91hv95SMaOOlKeWXOz8iN63yqnF+lF3jajxkiwh8pkoS3Dlsht7UkUo/+uuyeqAT ZnKGhh5y0v9jC7WDKU+a7kjBdbQ1od4IVbZVDEaSAkNAIkdxMr4QFpOaqnnhUpc/FQIs O8NtcI9vRvBtzruxwrTIUkupggXAcuCK/c1yr8CAF7Zh5W2crPB4aZq63UdriINuC+2u pdn373wsgGNQ9izzlrCOygmdEwmsfBRD+rkszczTR6lZHPACzCIL/po39rk9hrFZkboB lxau6itptDnTTAyVj+OYRdxAUY+dtrYEUHi6eoU+Qk6dQ2WQ0DzUyXvMGTJb7xAzZAOt YOzw== Received: by 10.236.83.39 with SMTP id p27mr4055644yhe.27.1350086529898; Fri, 12 Oct 2012 17:02:09 -0700 (PDT) Received: from wpzn4.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id t29si826396yha.0.2012.10.12.17.02.09 (version=TLSv1/SSLv3 cipher=AES128-SHA); Fri, 12 Oct 2012 17:02:09 -0700 (PDT) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by wpzn4.hot.corp.google.com (Postfix) with ESMTP id C6ECC1E0043; Fri, 12 Oct 2012 17:02:09 -0700 (PDT) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 53991160AB4; Fri, 12 Oct 2012 17:02:09 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Fri, 12 Oct 2012 17:02:01 -0700 Message-Id: <1350086525-22030-1-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.7.3 X-Gm-Message-State: ALoCoQnj4mI1PBO6z9z3cdoOmN2e0SXrMAIXthwbKGsFTYgPvCe98igHgXeaWXVolciBNfQoZa/yx6R4/CiqSUrfFzo72U8wyQeFH41iVzAkYAn4bSlbQy6oLwnyBDGZydZfb7j0rbRwKhRxxcsNfaDBFLMYpsOC+AsB9gUfvlbaP4Gu1LzZpofD3eqQvOkPpDU6UzKjsQCx Cc: Tom Rini Subject: [U-Boot] [PATCH v2 1/5] input: Use finer grain udelays while waitng for the i8042 keyboard buffer to empty 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: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Gabe Black On x86, the i8042 keyboard controller driver frequently waits for the keyboard input buffer to be empty to make sure the controller has had a chance to process the data it was given. The way the delay loop was structured, if the controller hadn't cleared the corresponding status bit immediately, it would wait 1ms before checking again. If the keyboard responded quickly but not instantly, the driver would still wait a full 1ms when perhaps 1us would have been sufficient. Because udelay is a busy wait anyway, this change decreases the delay between checks to 1us. Also, this change gets rid of a hardcoded 250ms delay. On Stumpy, this saves 100-150ms during boot. Signed-off-by: Gabe Black Signed-off-by: Simon Glass --- Changes in v2: - Add constants for i8042 status registers drivers/input/i8042.c | 9 +++------ include/i8042.h | 6 ++++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c index c3bc536..6839c6b 100644 --- a/drivers/input/i8042.c +++ b/drivers/input/i8042.c @@ -607,11 +607,10 @@ static void kbd_led_set(void) static int kbd_input_empty(void) { - int kbdTimeout = KBD_TIMEOUT; + int kbdTimeout = KBD_TIMEOUT * 1000; - /* wait for input buf empty */ - while ((in8(I8042_STATUS_REG) & 0x02) && kbdTimeout--) - udelay(1000); + while ((in8(I8042_STATUS_REG) & I8042_STATUS_IN_DATA) && kbdTimeout--) + udelay(1); return kbdTimeout != -1; } @@ -625,8 +624,6 @@ static int kbd_reset(void) out8(I8042_DATA_REG, 0xff); - udelay(250000); - if (kbd_input_empty() == 0) return -1; diff --git a/include/i8042.h b/include/i8042.h index 1395289..aeb3f09 100644 --- a/include/i8042.h +++ b/include/i8042.h @@ -39,6 +39,12 @@ #define I8042_STATUS_REG (CONFIG_SYS_ISA_IO + 0x0064) /* keyboard status read */ #define I8042_COMMAND_REG (CONFIG_SYS_ISA_IO + 0x0064) /* keyboard ctrl write */ +enum { + /* Output register (I8042_DATA_REG) has data for system */ + I8042_STATUS_OUT_DATA = 1 << 0, + I8042_STATUS_IN_DATA = 1 << 1, +}; + #define KBD_US 0 /* default US layout */ #define KBD_GER 1 /* german layout */