From patchwork Fri Oct 12 01:15:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 191028 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 C83FE2C007B for ; Fri, 12 Oct 2012 12:16:38 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1F9C24A01F; Fri, 12 Oct 2012 03:16:37 +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 iV2s9Y7XuBGS; Fri, 12 Oct 2012 03:16:36 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 467C04A019; Fri, 12 Oct 2012 03:16:33 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 121CA4A021 for ; Fri, 12 Oct 2012 03:16:32 +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 ScCyL1bApI8f for ; Fri, 12 Oct 2012 03:16:30 +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-ea0-f202.google.com (mail-ea0-f202.google.com [209.85.215.202]) by theia.denx.de (Postfix) with ESMTPS id 8230D4A023 for ; Fri, 12 Oct 2012 03:16:21 +0200 (CEST) Received: by mail-ea0-f202.google.com with SMTP id q10so63442eaa.3 for ; Thu, 11 Oct 2012 18:16:21 -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:in-reply-to:references :x-gm-message-state; bh=dh4Q01locnwL0wGHauSi9MZvNM4NfTOBHiDljjX1vso=; b=JUQIgemvtRMFh32W2xzWYVIyIVk3526eXroXHdgKaErs6JAbGBG/Jfmef1hUouYU4G 10l+5LVWYSs3B0d8rKT+lEfRgL4KVCMEu5G3OU1KbLvg8vP1tLoLH1QFQe8bhtPwoA69 cvl00qb6y92UsmqJPT4F8yHp/mizzdVDK07iGxWPymQBMvVQDkMsPBWNPsNS1FvA3rUO GmXHnSvP+KcecCLDjnARuAQylatcBGEppSl3jYz541+HPsCRQl9K61wj9S2AMzTIJxKH x/eVTTsk75UY9agncdWILSeKal5mPf1n7L3eHhJWCKzEAuwu1IXipUmy0PYCsHSmE2uD Y9Jw== Received: by 10.180.84.74 with SMTP id w10mr179714wiy.4.1350004581502; Thu, 11 Oct 2012 18:16:21 -0700 (PDT) Received: from hpza9.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id z4si36544wiw.1.2012.10.11.18.16.21 (version=TLSv1/SSLv3 cipher=AES128-SHA); Thu, 11 Oct 2012 18:16:21 -0700 (PDT) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by hpza9.eem.corp.google.com (Postfix) with ESMTP id 1DBFD5C0050; Thu, 11 Oct 2012 18:16:21 -0700 (PDT) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 746EE16107B; Thu, 11 Oct 2012 18:16:20 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Thu, 11 Oct 2012 18:15:51 -0700 Message-Id: <1350004554-18506-3-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1350004554-18506-1-git-send-email-sjg@chromium.org> References: <1350004554-18506-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQnSDAWh/IQCznrEGZ/F5Wx3hxLWK2lbxaoSgkakJH9dB1hfwifWFUfssINXWoPaggye24+sAGyL8g7sfBkDQgLnenepLnWg5OT5jM1fhk6ZUTEz0QT+aHMQ/fBYF7z6zk5FncvfukPysJAsMDAxoZddMM8LkC6jR34q1cJ1rQVMsFz05615qk2QVzcplEx77u7HbSSF Cc: Tom Rini , Louis Yung-Chieh Lo Subject: [U-Boot] [PATCH 3/5] input: i8042: Provide feature to disable keyboard before booting kernel 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: Louis Yung-Chieh Lo The BIOS leaves the keyboard enabled during boot time so that any keystroke would interfere kernel driver initialization. Add a way to disable the keyboard to make sure no scancode will be generated during the boot time. Note that the keyboard will be re-enabled again after the kernel driver is up. This code can be called from the board functions. Signed-off-by: Louis Yung-Chieh Lo Signed-off-by: Louis Yung-Chieh Lo Signed-off-by: Simon Glass --- drivers/input/i8042.c | 38 ++++++++++++++++++++++++++++++++++++++ include/i8042.h | 13 +++++++++++++ 2 files changed, 51 insertions(+), 0 deletions(-) diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c index cae2d0a..6b51eb5 100644 --- a/drivers/input/i8042.c +++ b/drivers/input/i8042.c @@ -331,6 +331,44 @@ int __board_i8042_skip(void) } int board_i8042_skip(void) __attribute__((weak, alias("__board_i8042_skip"))); +void i8042_flush(void) +{ + int timeout; + + /* + * The delay is to give the keyboard controller some time to fill the + * next byte. + */ + while (1) { + timeout = 100; /* wait for no longer than 100us */ + while (timeout > 0 && !(in8(I8042_STATUS_REG) & 0x01)) { + udelay(1); + timeout--; + } + + /* Try to pull next byte if not timeout. */ + if (in8(I8042_STATUS_REG) & 0x01) + in8(I8042_DATA_REG); + else + break; + } +} + +int i8042_disable(void) +{ + if (kbd_input_empty() == 0) + return -1; + + /* Disable keyboard */ + out8(I8042_COMMAND_REG, 0xad); + + if (kbd_input_empty() == 0) + return -1; + + return 0; +} + + /******************************************************************************* * * i8042_kbd_init - reset keyboard and init state flags diff --git a/include/i8042.h b/include/i8042.h index 1395289..c3e4e02 100644 --- a/include/i8042.h +++ b/include/i8042.h @@ -69,6 +69,19 @@ /* exports */ +/** + * Flush all buffer from keyboard controller to host. + */ +void i8042_flush(void); + +/** + * Disables the keyboard so that key strokes no longer generate scancodes to + * the host. + * + * @return 0 if ok, -1 if keyboard input was found while disabling + */ +int i8042_disable(void); + int i8042_kbd_init(void); int i8042_tstc(void); int i8042_getc(void);