From patchwork Fri Oct 12 01:15:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 191030 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 C83EE2C007B for ; Fri, 12 Oct 2012 12:17:05 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F0ACF4A025; Fri, 12 Oct 2012 03:16:51 +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 7wiXeuxC2vr0; Fri, 12 Oct 2012 03:16:51 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 42C5B4A03F; Fri, 12 Oct 2012 03:16:38 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A97EA4A02D for ; Fri, 12 Oct 2012 03:16:34 +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 1GWGu9XD3wkE for ; Fri, 12 Oct 2012 03:16:32 +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-qc0-f202.google.com (mail-qc0-f202.google.com [209.85.216.202]) by theia.denx.de (Postfix) with ESMTPS id 8A18E4A026 for ; Fri, 12 Oct 2012 03:16:22 +0200 (CEST) Received: by mail-qc0-f202.google.com with SMTP id s25so293418qcq.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=qQgwQT8jCzVxUEeqf2cRT69+1r+99tjWf6WJD1HnBGA=; b=ILlOPK6GaQqbNuEMQ/FyT9jhxnx2AYGMcarCgr2RGXQaFoj/ekhsUNap79GVKTXCYd xphD85kRoWmI9nAJujLRGcMD9DneILq9+ljIGiaqwndSGm4t1NJ2vhJDB2ML9l7z3m6L BRKeAwArR0S3vkoZAvCc9xPRZBCTucg7rGj0+WbDY7LmH+e6xHVDj7fNfuGSTo3Sqrw+ I981XaV9fCM8XBiR3yTvsqrwE9Rc7Z/tzTOTK/MSZZ4m2J3awdPH1sgRolVq9FZiDEBC jJ47kfzoa17EUqIV9AUcEeDchtnXAc+JIxGuEzSLM/D/gqHJVxhBeEdbpLr++nIOmpB4 Gk/w== Received: by 10.236.78.199 with SMTP id g47mr1883162yhe.0.1350004581016; Thu, 11 Oct 2012 18:16:21 -0700 (PDT) Received: from wpzn3.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id u17si283592ank.0.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 wpzn3.hot.corp.google.com (Postfix) with ESMTP id D3B25100047; Thu, 11 Oct 2012 18:16:20 -0700 (PDT) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 8D03C1610CA; Thu, 11 Oct 2012 18:16:20 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Thu, 11 Oct 2012 18:15:52 -0700 Message-Id: <1350004554-18506-4-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: ALoCoQmt/6js9GV/bcqa2yr+qn09umIdNphBAknUMU5EMJeuhDr22bP8amLqbc2KEHi6qD7cRY6cX42w9Os8j2Ha292imcbu4jkzPtszLOelpB+HSqwgcsAdL8kBBJd2NG8rynDArwOlBPHciyV1P9xLI1LeX6PV3+viOP1aUOvrBKCuWOIvRRL4h3a0GaPvv+j+XYultOn/ Cc: Tom Rini , Marc Jones Subject: [U-Boot] [PATCH 4/5] input: Fix i8042 keyboard reset 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: Marc Jones The i8042 keyboard reset was not checking the results of the output buffer after the reset command. This can jam up some KBC/keyboards. Also, remove a write to the wrong register and the CONFIG setting around the incorrect write. Signed-off-by: Marc Jones Signed-off-by: Simon Glass --- drivers/input/i8042.c | 32 +++++++++++++++++++++++++++----- 1 files changed, 27 insertions(+), 5 deletions(-) diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c index 6b51eb5..65611ec 100644 --- a/drivers/input/i8042.c +++ b/drivers/input/i8042.c @@ -666,31 +666,53 @@ static int kbd_input_empty(void) /******************************************************************************/ +static int wait_until_kbd_output_full(void) +{ + int kbdTimeout = KBD_TIMEOUT * 1000; + + while (((in8(I8042_STATUS_REG) & 0x01) == 0) && kbdTimeout--) + udelay(1); + + return kbdTimeout != -1; +} + +/******************************************************************************/ + static int kbd_reset(void) { + /* KB Reset */ if (kbd_input_empty() == 0) return -1; out8(I8042_DATA_REG, 0xff); + if (wait_until_kbd_output_full() == 0) + return -1; + + if (in8(I8042_DATA_REG) != 0xfa) /* ACK */ + return -1; + + if (wait_until_kbd_output_full() == 0) + return -1; + + if (in8(I8042_DATA_REG) != 0xaa) /* Test Pass*/ + return -1; + if (kbd_input_empty() == 0) return -1; -#ifdef CONFIG_USE_CPCIDVI + /* Set KBC mode */ out8(I8042_COMMAND_REG, 0x60); -#else - out8(I8042_DATA_REG, 0x60); -#endif if (kbd_input_empty() == 0) return -1; out8(I8042_DATA_REG, 0x45); - if (kbd_input_empty() == 0) return -1; + /* Enable Keyboard */ out8(I8042_COMMAND_REG, 0xae); if (kbd_input_empty() == 0)