All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 10/12] i8042: Handle a duplicate power-on-reset response
Date: Wed, 11 Nov 2015 10:05:46 -0700	[thread overview]
Message-ID: <1447261548-14304-11-git-send-email-sjg@chromium.org> (raw)
In-Reply-To: <1447261548-14304-1-git-send-email-sjg@chromium.org>

Sometimes we seem to get 0xaa twice which causes the config read to fail.
This causes chromebook_link to fail to set up the keyboard.

Add a check for this and read the config again when detected.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---

Changes in v3:
- Fix 'QUICK' typo

Changes in v2:
- Use device tree to handle this quirk

 drivers/input/i8042.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c
index e5e2926..661d7fd 100644
--- a/drivers/input/i8042.c
+++ b/drivers/input/i8042.c
@@ -15,13 +15,20 @@
 #include <keyboard.h>
 #include <asm/io.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 /* defines */
 #define in8(p)		inb(p)
 #define out8(p, v)	outb(v, p)
 
+enum {
+	QUIRK_DUP_POR	= 1 << 0,
+};
+
 /* locals */
 struct i8042_kbd_priv {
 	bool extended;	/* true if an extended keycode is expected next */
+	int quirks;	/* quirks that we support */
 };
 
 static unsigned char ext_key_map[] = {
@@ -113,7 +120,7 @@ static int kbd_cmd_write(int cmd, int data)
 	return kbd_write(I8042_DATA_REG, data);
 }
 
-static int kbd_reset(void)
+static int kbd_reset(int quirk)
 {
 	int config;
 
@@ -132,6 +139,10 @@ static int kbd_reset(void)
 	if (config == -1)
 		goto err;
 
+	/* Sometimes get a second byte */
+	else if ((quirk & QUIRK_DUP_POR) && config == KBD_POR)
+		config = kbd_cmd_read(CMD_RD_CONFIG);
+
 	config |= CONFIG_AT_TRANS;
 	config &= ~(CONFIG_KIRQ_EN | CONFIG_MIRQ_EN);
 	if (kbd_cmd_write(CMD_WR_CONFIG, config))
@@ -246,6 +257,7 @@ static int i8042_kbd_check(struct input_config *input)
 static int i8042_start(struct udevice *dev)
 {
 	struct keyboard_priv *uc_priv = dev_get_uclass_priv(dev);
+	struct i8042_kbd_priv *priv = dev_get_priv(dev);
 	struct input_config *input = &uc_priv->input;
 	int keymap, try;
 	char *penv;
@@ -264,7 +276,7 @@ static int i8042_start(struct udevice *dev)
 			keymap = KBD_GER;
 	}
 
-	for (try = 0; kbd_reset() != 0; try++) {
+	for (try = 0; kbd_reset(priv->quirks) != 0; try++) {
 		if (try >= KBD_RESET_TRIES)
 			return -1;
 	}
@@ -294,10 +306,15 @@ static int i8042_start(struct udevice *dev)
 static int i8042_kbd_probe(struct udevice *dev)
 {
 	struct keyboard_priv *uc_priv = dev_get_uclass_priv(dev);
+	struct i8042_kbd_priv *priv = dev_get_priv(dev);
 	struct stdio_dev *sdev = &uc_priv->sdev;
 	struct input_config *input = &uc_priv->input;
 	int ret;
 
+	if (fdtdec_get_bool(gd->fdt_blob, dev->of_offset,
+			    "intel,duplicate-por"))
+		priv->quirks |= QUIRK_DUP_POR;
+
 	/* Register the device. i8042_start() will be called soon */
 	input->dev = dev;
 	input->read_keys = i8042_kbd_check;
-- 
2.6.0.rc2.230.g3dd15c0

  parent reply	other threads:[~2015-11-11 17:05 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-11 17:05 [U-Boot] [PATCH v3 00/12] dm: input: Move keyboard drivers to driver model Simon Glass
2015-11-11 17:05 ` [U-Boot] [PATCH v3 01/12] input: Support the German keymap Simon Glass
2015-11-12  3:51   ` Bin Meng
2015-11-14  2:04     ` Simon Glass
2015-11-11 17:05 ` [U-Boot] [PATCH v3 02/12] input: Adjust structure of code in process_modifier() Simon Glass
2015-11-12 13:39   ` Bin Meng
2015-11-14  2:04     ` Simon Glass
2015-11-11 17:05 ` [U-Boot] [PATCH v3 03/12] input: Handle caps lock Simon Glass
2015-11-12 13:50   ` Bin Meng
2015-11-14  2:04     ` Simon Glass
2015-11-11 17:05 ` [U-Boot] [PATCH v3 04/12] input: Allow updating of keyboard LEDs Simon Glass
2015-11-12 13:50   ` Bin Meng
2015-11-14  2:04     ` Simon Glass
2015-11-11 17:05 ` [U-Boot] [PATCH v3 05/12] input: i8042: Convert to use the input library Simon Glass
2015-11-12 13:50   ` Bin Meng
2015-11-14  2:04     ` Simon Glass
2015-11-11 17:05 ` [U-Boot] [PATCH v3 06/12] input: Add a Kconfig option for the i8042 keyboard Simon Glass
2015-11-14  2:04   ` Simon Glass
2015-11-11 17:05 ` [U-Boot] [PATCH v3 07/12] x86: Add an i8042 device for boards that have it Simon Glass
2015-11-14  2:04   ` Simon Glass
2015-11-11 17:05 ` [U-Boot] [PATCH v3 08/12] Drop CONFIG_ISA_KEYBOARD Simon Glass
2015-11-14  2:04   ` Simon Glass
2015-11-11 17:05 ` [U-Boot] [PATCH v3 09/12] input: Convert i8042 to driver model Simon Glass
2015-11-12 13:50   ` Bin Meng
2015-11-14  2:04     ` Simon Glass
2015-11-11 17:05 ` Simon Glass [this message]
2015-11-14  2:04   ` [U-Boot] [PATCH v3 10/12] i8042: Handle a duplicate power-on-reset response Simon Glass
2015-11-11 17:05 ` [U-Boot] [PATCH v3 11/12] video: input: Clean up after i8042 conversion Simon Glass
2015-11-14  2:04   ` Simon Glass
2015-11-11 17:05 ` [U-Boot] [PATCH v3 12/12] input: Convert 'keyboard' driver to use input library Simon Glass
2015-11-14  2:04   ` Simon Glass
2015-11-11 21:56 ` [U-Boot] [PATCH v3 00/12] dm: input: Move keyboard drivers to driver model Simon Glass
2015-11-12  3:56   ` Bin Meng
2015-11-12 13:33     ` Bin Meng
2015-11-12 19:57       ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1447261548-14304-11-git-send-email-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.