All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v4 0/10] tegra: Enable keyboard with matrix keyboard driver
@ 2012-04-17 19:01 Simon Glass
  2012-04-17 19:01   ` [U-Boot] " Simon Glass
                   ` (9 more replies)
  0 siblings, 10 replies; 24+ messages in thread
From: Simon Glass @ 2012-04-17 19:01 UTC (permalink / raw)
  To: u-boot

Tegra2 has a built-in a keyboard controller which we can use to scan
a matrix keyboard. This series brings in a driver for this and adds
support for the QUERTY keyboard on Seaboard as an example.

This version uses the keyboard device-tree definition here:

http://patchwork.ozlabs.org/patch/134093/

so it should work seemlessly with the kernel keyboard device tree node.

Part of this series is an input library which is not tied to Tegra,
but hopes to be more generic. It supports converting key codes (or scan
codes as they are currently called) into ASCII characters, an input FIFO,
multiple key maps and dealing with duplicate key codes under key-repeat
situations (when a key is held down). Half of this library is taken from
keyboard.c and expanded to keep its state in a structure. The other half
of this library is new.

Another part of the series is a keyboard matrix library, which understands
how to convert (row, column) information into key codes in a device tree.

Both of these new libraries are used by the Tegra driver.

If this input library is accepted, then I will update keyboard.c and
i8042.c to use it. If not, then I could subsume it into the Tegra driver
for now. Or I could do something else. But it didn't seem right to add
a third key decoder (ignoring USB which does its own thing).

Changes in v2:
- Remove status = "okay" since this is the default anyway
- Use correct name for get_prop_check_min_len() function

Changes in v3:
- Add new patch for generic keyboard input handler
- Adjust decode logic to work with new Linux fdt keyboard binding
- Bring in linux/input.h header file in new patch
- Move to new Linux device tree mapping for Tegra keyboard
- Use funcmux to set up keyboard pinmux
- Use new input library to handle key decode, fifo, getc()/tstc()

Changes in v4:
- Implement key auto-repeat in the input layer
- Move matrix keyboard handling into a separate module
- Simplify driver as much as possible using input/key matrix layers
- Use new key_matrix handler to deal with key matrix decode

Anton Staff (3):
  fdt: Add fdtdec functions to read byte array
  tegra: fdt: Add keyboard controller definition
  tegra: fdt: Add keyboard definitions for Seaboard

Bernie Thompson (1):
  input: Add support for keyboard matrix decoding from an fdt

Rakesh Iyer (1):
  tegra: Add tegra keyboard driver

Simon Glass (5):
  input: Add linux/input.h for key code support
  input: Add generic keyboard input handler
  tegra: Add keyboard support to funcmux
  tegra: Switch on console mux and use environment for console
  tegra: Enable keyboard for Seaboard

 arch/arm/cpu/armv7/tegra2/funcmux.c  |   16 ++
 arch/arm/dts/tegra20.dtsi            |    5 +
 board/nvidia/dts/tegra2-seaboard.dts |   27 +++
 drivers/input/Makefile               |    3 +
 drivers/input/input.c                |  429 ++++++++++++++++++++++++++++++++++
 drivers/input/key_matrix.c           |  208 ++++++++++++++++
 drivers/input/tegra-kbc.c            |  375 +++++++++++++++++++++++++++++
 include/configs/seaboard.h           |    9 +
 include/configs/tegra2-common.h      |    9 +-
 include/fdtdec.h                     |   33 +++
 include/input.h                      |  145 ++++++++++++
 include/key_matrix.h                 |   99 ++++++++
 include/linux/input.h                |  155 ++++++++++++
 include/tegra-kbc.h                  |   33 +++
 lib/fdtdec.c                         |   25 ++
 15 files changed, 1570 insertions(+), 1 deletions(-)
 create mode 100644 drivers/input/input.c
 create mode 100644 drivers/input/key_matrix.c
 create mode 100644 drivers/input/tegra-kbc.c
 create mode 100644 include/input.h
 create mode 100644 include/key_matrix.h
 create mode 100644 include/linux/input.h
 create mode 100644 include/tegra-kbc.h

-- 
1.7.7.3

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v4 01/10] fdt: Add fdtdec functions to read byte array
  2012-04-17 19:01 [U-Boot] [PATCH v4 0/10] tegra: Enable keyboard with matrix keyboard driver Simon Glass
@ 2012-04-17 19:01   ` Simon Glass
  2012-04-17 19:01 ` [U-Boot] [PATCH v4 02/10] input: Add linux/input.h for key code support Simon Glass
                     ` (8 subsequent siblings)
  9 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2012-04-17 19:01 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Anton Staff, Devicetree Discuss, Jerry Van Baren, Tom Warren

From: Anton Staff <robotboy@chromium.org>

Sometimes we don't need a full cell for each value. This provides
a simple function to read a byte array, both with and without
copying it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Use correct name for get_prop_check_min_len() function

 include/fdtdec.h |   32 ++++++++++++++++++++++++++++++++
 lib/fdtdec.c     |   24 ++++++++++++++++++++++++
 2 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/include/fdtdec.h b/include/fdtdec.h
index 7bae2f8..5140f4a 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -350,3 +350,35 @@ int fdtdec_decode_gpio(const void *blob, int node, const char *prop_name,
  * @return 0 if all ok or gpio was FDT_GPIO_NONE; -1 on error
  */
 int fdtdec_setup_gpio(struct fdt_gpio_state *gpio);
+
+/*
+ * Look up a property in a node and return its contents in a byte
+ * array of given length. The property must have at least enough data for
+ * the array (count bytes). It may have more, but this will be ignored.
+ *
+ * @param blob		FDT blob
+ * @param node		node to examine
+ * @param prop_name	name of property to find
+ * @param array		array to fill with data
+ * @param count		number of array elements
+ * @return 0 if ok, or -FDT_ERR_MISSING if the property is not found,
+ *		or -FDT_ERR_BADLAYOUT if not enough data
+ */
+int fdtdec_get_byte_array(const void *blob, int node, const char *prop_name,
+		u8 *array, int count);
+
+/**
+ * Look up a property in a node and return a pointer to its contents as a
+ * byte array of given length. The property must have at least enough data
+ * for the array (count bytes). It may have more, but this will be ignored.
+ * The data is not copied.
+ *
+ * @param blob		FDT blob
+ * @param node		node to examine
+ * @param prop_name	name of property to find
+ * @param count		number of array elements
+ * @return pointer to byte array if found, or NULL if the property is not
+ *		found or there is not enough data
+ */
+const u8 *fdtdec_locate_byte_array(const void *blob, int node,
+			     const char *prop_name, int count);
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 2eb5b41..585dd6d 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -487,3 +487,27 @@ int fdtdec_setup_gpio(struct fdt_gpio_state *gpio)
 		return -1;
 	return 0;
 }
+
+int fdtdec_get_byte_array(const void *blob, int node, const char *prop_name,
+		u8 *array, int count)
+{
+	const u8 *cell;
+	int err;
+
+	cell = get_prop_check_min_len(blob, node, prop_name, count, &err);
+	if (!err)
+		memcpy(array, cell, count);
+	return err;
+}
+
+const u8 *fdtdec_locate_byte_array(const void *blob, int node,
+			     const char *prop_name, int count)
+{
+	const u8 *cell;
+	int err;
+
+	cell = get_prop_check_min_len(blob, node, prop_name, count, &err);
+	if (err)
+		return NULL;
+	return cell;
+}
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [U-Boot] [PATCH v4 01/10] fdt: Add fdtdec functions to read byte array
@ 2012-04-17 19:01   ` Simon Glass
  0 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2012-04-17 19:01 UTC (permalink / raw)
  To: u-boot

From: Anton Staff <robotboy@chromium.org>

Sometimes we don't need a full cell for each value. This provides
a simple function to read a byte array, both with and without
copying it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Use correct name for get_prop_check_min_len() function

 include/fdtdec.h |   32 ++++++++++++++++++++++++++++++++
 lib/fdtdec.c     |   24 ++++++++++++++++++++++++
 2 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/include/fdtdec.h b/include/fdtdec.h
index 7bae2f8..5140f4a 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -350,3 +350,35 @@ int fdtdec_decode_gpio(const void *blob, int node, const char *prop_name,
  * @return 0 if all ok or gpio was FDT_GPIO_NONE; -1 on error
  */
 int fdtdec_setup_gpio(struct fdt_gpio_state *gpio);
+
+/*
+ * Look up a property in a node and return its contents in a byte
+ * array of given length. The property must have at least enough data for
+ * the array (count bytes). It may have more, but this will be ignored.
+ *
+ * @param blob		FDT blob
+ * @param node		node to examine
+ * @param prop_name	name of property to find
+ * @param array		array to fill with data
+ * @param count		number of array elements
+ * @return 0 if ok, or -FDT_ERR_MISSING if the property is not found,
+ *		or -FDT_ERR_BADLAYOUT if not enough data
+ */
+int fdtdec_get_byte_array(const void *blob, int node, const char *prop_name,
+		u8 *array, int count);
+
+/**
+ * Look up a property in a node and return a pointer to its contents as a
+ * byte array of given length. The property must have at least enough data
+ * for the array (count bytes). It may have more, but this will be ignored.
+ * The data is not copied.
+ *
+ * @param blob		FDT blob
+ * @param node		node to examine
+ * @param prop_name	name of property to find
+ * @param count		number of array elements
+ * @return pointer to byte array if found, or NULL if the property is not
+ *		found or there is not enough data
+ */
+const u8 *fdtdec_locate_byte_array(const void *blob, int node,
+			     const char *prop_name, int count);
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 2eb5b41..585dd6d 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -487,3 +487,27 @@ int fdtdec_setup_gpio(struct fdt_gpio_state *gpio)
 		return -1;
 	return 0;
 }
+
+int fdtdec_get_byte_array(const void *blob, int node, const char *prop_name,
+		u8 *array, int count)
+{
+	const u8 *cell;
+	int err;
+
+	cell = get_prop_check_min_len(blob, node, prop_name, count, &err);
+	if (!err)
+		memcpy(array, cell, count);
+	return err;
+}
+
+const u8 *fdtdec_locate_byte_array(const void *blob, int node,
+			     const char *prop_name, int count)
+{
+	const u8 *cell;
+	int err;
+
+	cell = get_prop_check_min_len(blob, node, prop_name, count, &err);
+	if (err)
+		return NULL;
+	return cell;
+}
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [U-Boot] [PATCH v4 02/10] input: Add linux/input.h for key code support
  2012-04-17 19:01 [U-Boot] [PATCH v4 0/10] tegra: Enable keyboard with matrix keyboard driver Simon Glass
  2012-04-17 19:01   ` [U-Boot] " Simon Glass
@ 2012-04-17 19:01 ` Simon Glass
  2012-04-17 19:01 ` [U-Boot] [PATCH v4 03/10] input: Add generic keyboard input handler Simon Glass
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2012-04-17 19:01 UTC (permalink / raw)
  To: u-boot

We want to able to decode Linux fdt keymaps, so bring part of this
enormous header file over to U-Boot.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v3:
- Bring in linux/input.h header file in new patch

 include/linux/input.h |  155 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 155 insertions(+), 0 deletions(-)
 create mode 100644 include/linux/input.h

diff --git a/include/linux/input.h b/include/linux/input.h
new file mode 100644
index 0000000..44aec76
--- /dev/null
+++ b/include/linux/input.h
@@ -0,0 +1,155 @@
+/*
+ * Copyright (c) 1999-2002 Vojtech Pavlik
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#ifndef _LINUX_INPUT_H
+#define _LINUX_INPUT_H
+
+/*
+ * Keys and buttons
+ *
+ * Most of the keys/buttons are modeled after USB HUT 1.12
+ * (see http://www.usb.org/developers/hidpage).
+ * Abbreviations in the comments:
+ * AC - Application Control
+ * AL - Application Launch Button
+ * SC - System Control
+ */
+
+#define KEY_RESERVED		0
+#define KEY_ESC			1
+#define KEY_1			2
+#define KEY_2			3
+#define KEY_3			4
+#define KEY_4			5
+#define KEY_5			6
+#define KEY_6			7
+#define KEY_7			8
+#define KEY_8			9
+#define KEY_9			10
+#define KEY_0			11
+#define KEY_MINUS		12
+#define KEY_EQUAL		13
+#define KEY_BACKSPACE		14
+#define KEY_TAB			15
+#define KEY_Q			16
+#define KEY_W			17
+#define KEY_E			18
+#define KEY_R			19
+#define KEY_T			20
+#define KEY_Y			21
+#define KEY_U			22
+#define KEY_I			23
+#define KEY_O			24
+#define KEY_P			25
+#define KEY_LEFTBRACE		26
+#define KEY_RIGHTBRACE		27
+#define KEY_ENTER		28
+#define KEY_LEFTCTRL		29
+#define KEY_A			30
+#define KEY_S			31
+#define KEY_D			32
+#define KEY_F			33
+#define KEY_G			34
+#define KEY_H			35
+#define KEY_J			36
+#define KEY_K			37
+#define KEY_L			38
+#define KEY_SEMICOLON		39
+#define KEY_APOSTROPHE		40
+#define KEY_GRAVE		41
+#define KEY_LEFTSHIFT		42
+#define KEY_BACKSLASH		43
+#define KEY_Z			44
+#define KEY_X			45
+#define KEY_C			46
+#define KEY_V			47
+#define KEY_B			48
+#define KEY_N			49
+#define KEY_M			50
+#define KEY_COMMA		51
+#define KEY_DOT			52
+#define KEY_SLASH		53
+#define KEY_RIGHTSHIFT		54
+#define KEY_KPASTERISK		55
+#define KEY_LEFTALT		56
+#define KEY_SPACE		57
+#define KEY_CAPSLOCK		58
+#define KEY_F1			59
+#define KEY_F2			60
+#define KEY_F3			61
+#define KEY_F4			62
+#define KEY_F5			63
+#define KEY_F6			64
+#define KEY_F7			65
+#define KEY_F8			66
+#define KEY_F9			67
+#define KEY_F10			68
+#define KEY_NUMLOCK		69
+#define KEY_SCROLLLOCK		70
+#define KEY_KP7			71
+#define KEY_KP8			72
+#define KEY_KP9			73
+#define KEY_KPMINUS		74
+#define KEY_KP4			75
+#define KEY_KP5			76
+#define KEY_KP6			77
+#define KEY_KPPLUS		78
+#define KEY_KP1			79
+#define KEY_KP2			80
+#define KEY_KP3			81
+#define KEY_KP0			82
+#define KEY_KPDOT		83
+
+#define KEY_ZENKAKUHANKAKU	85
+#define KEY_102ND		86
+#define KEY_F11			87
+#define KEY_F12			88
+#define KEY_RO			89
+#define KEY_KATAKANA		90
+#define KEY_HIRAGANA		91
+#define KEY_HENKAN		92
+#define KEY_KATAKANAHIRAGANA	93
+#define KEY_MUHENKAN		94
+#define KEY_KPJPCOMMA		95
+#define KEY_KPENTER		96
+#define KEY_RIGHTCTRL		97
+#define KEY_KPSLASH		98
+#define KEY_SYSRQ		99
+#define KEY_RIGHTALT		100
+#define KEY_LINEFEED		101
+#define KEY_HOME		102
+#define KEY_UP			103
+#define KEY_PAGEUP		104
+#define KEY_LEFT		105
+#define KEY_RIGHT		106
+#define KEY_END			107
+#define KEY_DOWN		108
+#define KEY_PAGEDOWN		109
+#define KEY_INSERT		110
+#define KEY_DELETE		111
+#define KEY_MACRO		112
+#define KEY_MUTE		113
+#define KEY_VOLUMEDOWN		114
+#define KEY_VOLUMEUP		115
+#define KEY_POWER		116	/* SC System Power Down */
+#define KEY_KPEQUAL		117
+#define KEY_KPPLUSMINUS		118
+#define KEY_PAUSE		119
+#define KEY_SCALE		120	/* AL Compiz Scale (Expose) */
+
+#define KEY_KPCOMMA		121
+#define KEY_HANGEUL		122
+#define KEY_HANGUEL		KEY_HANGEUL
+#define KEY_HANJA		123
+#define KEY_YEN			124
+#define KEY_LEFTMETA		125
+#define KEY_RIGHTMETA		126
+#define KEY_COMPOSE		127
+#define KEY_FN			0x1d0
+
+#endif
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [U-Boot] [PATCH v4 03/10] input: Add generic keyboard input handler
  2012-04-17 19:01 [U-Boot] [PATCH v4 0/10] tegra: Enable keyboard with matrix keyboard driver Simon Glass
  2012-04-17 19:01   ` [U-Boot] " Simon Glass
  2012-04-17 19:01 ` [U-Boot] [PATCH v4 02/10] input: Add linux/input.h for key code support Simon Glass
@ 2012-04-17 19:01 ` Simon Glass
  2012-04-17 19:01 ` [U-Boot] [PATCH v4 04/10] input: Add support for keyboard matrix decoding from an fdt Simon Glass
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2012-04-17 19:01 UTC (permalink / raw)
  To: u-boot

Add a module which understands converting key codes (or scan codes)
to ASCII characters. It includes FIFO support and can call back to
drivers to read new characters when its FIFO is empty.

Keycode maps are provided for un-modified, shift and ctrl keys.

The plan is to use this module where such mapping is required.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v3:
- Add new patch for generic keyboard input handler

Changes in v4:
- Implement key auto-repeat in the input layer

 drivers/input/Makefile |    1 +
 drivers/input/input.c  |  429 ++++++++++++++++++++++++++++++++++++++++++++++++
 include/input.h        |  145 ++++++++++++++++
 3 files changed, 575 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/input.c
 create mode 100644 include/input.h

diff --git a/drivers/input/Makefile b/drivers/input/Makefile
index 1f4dad3..d06acb9 100644
--- a/drivers/input/Makefile
+++ b/drivers/input/Makefile
@@ -30,6 +30,7 @@ ifdef CONFIG_PS2KBD
 COBJS-y += keyboard.o pc_keyb.o
 COBJS-$(CONFIG_PS2MULT) += ps2mult.o ps2ser.o
 endif
+COBJS-y += input.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
diff --git a/drivers/input/input.c b/drivers/input/input.c
new file mode 100644
index 0000000..9beebe3
--- /dev/null
+++ b/drivers/input/input.c
@@ -0,0 +1,429 @@
+/*
+ * Translate key codes into ASCII
+ *
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * (C) Copyright 2004 DENX Software Engineering, Wolfgang Denk, wd at denx.de
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <input.h>
+#include <linux/input.h>
+
+enum {
+	/* These correspond to the lights on the keyboard */
+	FLAG_NUM_LOCK		= 1 << 0,
+	FLAG_CAPS_LOCK		= 1 << 1,
+	FLAG_SCROLL_LOCK	= 1 << 2,
+
+	/* Special flag ORed with key code to indicate release */
+	KEY_RELEASE		= 1 << 15,
+	KEY_MASK		= 0xfff,
+};
+
+/*
+ * These takes map key codes to ASCII. 0xff means no key, or special key.
+ * Three tables are provided - one for plain keys, one for when the shift
+ * 'modifier' key is pressed and one for when the ctrl modifier key is
+ * pressed.
+ */
+static const uchar kbd_plain_xlate[] = {
+	0xff, 0x1b, '1',  '2',  '3',  '4',  '5',  '6',
+	'7',  '8',  '9',  '0',  '-',  '=', '\b', '\t',	/* 0x00 - 0x0f */
+	'q',  'w',  'e',  'r',  't',  'y',  'u',  'i',
+	'o',  'p',  '[',  ']', '\r', 0xff,  'a',  's',  /* 0x10 - 0x1f */
+	'd',  'f',  'g',  'h',  'j',  'k',  'l',  ';',
+	'\'',  '`', 0xff, '\\', 'z',  'x',  'c',  'v',	/* 0x20 - 0x2f */
+	'b',  'n',  'm',  ',' ,  '.', '/', 0xff, 0xff, 0xff,
+	' ', 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,	/* 0x30 - 0x3f */
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,  '7',
+	'8',  '9',  '-',  '4',  '5',  '6',  '+',  '1',	/* 0x40 - 0x4f */
+	'2',  '3',  '0',  '.', 0xff, 0xff, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,	/* 0x50 - 0x5F */
+	'\r', 0xff, 0xff
+};
+
+static unsigned char kbd_shift_xlate[] = {
+	0xff, 0x1b, '!', '@', '#', '$', '%', '^',
+	'&', '*', '(', ')', '_', '+', '\b', '\t',	/* 0x00 - 0x0f */
+	'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I',
+	'O', 'P', '{', '}', '\r', 0xff, 'A', 'S',	/* 0x10 - 0x1f */
+	'D', 'F', 'G', 'H', 'J', 'K', 'L', ':',
+	'"', '~', 0xff, '|', 'Z', 'X', 'C', 'V',	/* 0x20 - 0x2f */
+	'B', 'N', 'M', '<', '>', '?', 0xff, 0xff, 0xff,
+	' ', 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,	/* 0x30 - 0x3f */
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, '7',
+	'8', '9', '-', '4', '5', '6', '+', '1',	/* 0x40 - 0x4f */
+	'2', '3', '0', '.', 0xff, 0xff, 0xff, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,	/* 0x50 - 0x5F */
+	'\r', 0xff, 0xff
+};
+
+static unsigned char kbd_ctrl_xlate[] = {
+	0xff, 0x1b, '1', 0x00, '3', '4', '5', 0x1E,
+	'7', '8', '9', '0', 0x1F, '=', '\b', '\t',	/* 0x00 - 0x0f */
+	0x11, 0x17, 0x05, 0x12, 0x14, 0x18, 0x15, 0x09,
+	0x0f, 0x10, 0x1b, 0x1d, '\n', 0xff, 0x01, 0x13,	/* 0x10 - 0x1f */
+	0x04, 0x06, 0x08, 0x09, 0x0a, 0x0b, 0x0c, ';',
+	'\'', '~', 0x00, 0x1c, 0x1a, 0x18, 0x03, 0x16,	/* 0x20 - 0x2f */
+	0x02, 0x0e, 0x0d, '<', '>', '?', 0xff, 0xff,
+	0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,	/* 0x30 - 0x3f */
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, '7',
+	'8', '9', '-', '4', '5', '6', '+', '1',		/* 0x40 - 0x4f */
+	'2', '3', '0', '.', 0xff, 0xff, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,	/* 0x50 - 0x5F */
+	'\r', 0xff, 0xff
+};
+
+
+int input_queue_ascii(struct input_config *config, int ch)
+{
+	if (config->fifo_in + 1 == INPUT_BUFFER_LEN) {
+		if (!config->fifo_out)
+			return -1; /* buffer full */
+		else
+			config->fifo_in = 0;
+	} else {
+		if (config->fifo_in + 1 == config->fifo_out)
+			return -1; /* buffer full */
+		config->fifo_in++;
+	}
+	config->fifo[config->fifo_in] = (uchar)ch;
+
+	return 0;
+}
+
+int input_tstc(struct input_config *config)
+{
+	if (config->fifo_in == config->fifo_out && config->read_keys) {
+		if (!(*config->read_keys)(config))
+			return 0;
+	}
+	return config->fifo_in != config->fifo_out;
+}
+
+int input_getc(struct input_config *config)
+{
+	int err = 0;
+
+	while (config->fifo_in == config->fifo_out) {
+		if (config->read_keys)
+			err = (*config->read_keys)(config);
+		if (err)
+			return -1;
+	}
+
+	if (++config->fifo_out == INPUT_BUFFER_LEN)
+		config->fifo_out = 0;
+
+	return config->fifo[config->fifo_out];
+}
+
+/**
+ * Process a modifier/special key press or release and decide which key
+ * translation array should be used as a result.
+ *
+ * TODO: Should keep track of modifier press/release
+ *
+ * @param config	Input state
+ * @param key		Key code to process
+ * @param release	0 if a press, 1 if a release
+ * @return pointer to keycode->ascii translation table that should be used
+ */
+static struct input_key_xlate *process_modifier(struct input_config *config,
+						int key, int release)
+{
+	struct input_key_xlate *table;
+	int flip = -1;
+	int i;
+
+	/* Start with the main table, and see what modifiers change it */
+	assert(config->num_tables > 0);
+	table = &config->table[0];
+	for (i = 1; i < config->num_tables; i++) {
+		struct input_key_xlate *tab = &config->table[i];
+
+		if (key == tab->left_keycode || key == tab->right_keycode)
+			table = tab;
+	}
+
+	/* Handle the lighted keys */
+	if (!release) {
+		switch (key) {
+		case KEY_SCROLLLOCK:
+			flip = FLAG_SCROLL_LOCK;
+			break;
+		case KEY_NUMLOCK:
+			flip = FLAG_NUM_LOCK;
+			break;
+		case KEY_CAPSLOCK:
+			flip = FLAG_CAPS_LOCK;
+			break;
+		}
+	}
+
+	if (flip != -1) {
+		int leds = 0;
+
+		config->leds ^= flip;
+		if (config->flags & FLAG_NUM_LOCK)
+			leds |= INPUT_LED_NUM;
+		if (config->flags & FLAG_CAPS_LOCK)
+			leds |= INPUT_LED_CAPS;
+		if (config->flags & FLAG_SCROLL_LOCK)
+			leds |= INPUT_LED_SCROLL;
+		config->leds = leds;
+	}
+
+	return table;
+}
+
+/**
+ * Search an int array for a key value
+ *
+ * @param array	Array to search
+ * @param count	Number of elements in array
+ * @param key	Key value to find
+ * @return element where value was first found, -1 if none
+ */
+static int array_search(int *array, int count, int key)
+{
+	int i;
+
+	for (i = 0; i < count; i++) {
+		if (array[i] == key)
+			return i;
+	}
+
+	return -1;
+}
+
+/**
+ * Sort an array so that those elements that exist in the ordering are
+ * first in the array, and in the same order as the ordering. The algorithm
+ * is O(count * ocount) and designed for small arrays.
+ *
+ * TODO: Move this to common / lib?
+ *
+ * @param dest		Array with elements to sort, also destination array
+ * @param count		Number of elements to sort
+ * @param order		Array containing ordering elements
+ * @param ocount	Number of ordering elements
+ * @return number of elements in dest that are in order (these will be@the
+ *	start of dest).
+ */
+static int sort_array_by_ordering(int *dest, int count, int *order,
+				   int ocount)
+{
+	int temp[count];
+	int dest_count;
+	int same;	/* number of elements which are the same */
+	int i;
+
+	/* setup output items, copy items to be sorted into our temp area */
+	memcpy(temp, dest, count * sizeof(*dest));
+	dest_count = 0;
+
+	/* work through the ordering, move over the elements we agree on */
+	for (i = 0; i < ocount; i++) {
+		if (array_search(temp, count, order[i]) != -1)
+			dest[dest_count++] = order[i];
+	}
+	same = dest_count;
+
+	/* now move over the elements that are not in the ordering */
+	for (i = 0; i < count; i++) {
+		if (array_search(order, ocount, temp[i]) == -1)
+			dest[dest_count++] = temp[i];
+	}
+	assert(dest_count == count);
+	return same;
+}
+
+/**
+ * Check a list of key codes against the previous key scan
+ *
+ * Given a list of new key codes, we check how many of these are the same
+ * as last time.
+ *
+ * @param config	Input state
+ * @param keycode	List of key codes to examine
+ * @param num_keycodes	Number of key codes
+ * @param same		Returns number of key codes which are the same
+ */
+static int input_check_keycodes(struct input_config *config,
+			   int keycode[], int num_keycodes, int *same)
+{
+	/* Select the 'plain' xlate table to start with */
+	if (!config->num_tables) {
+		debug("%s: No xlate tables: cannot decode keys\n", __func__);
+		return -1;
+	}
+
+	/* sort the keycodes into the same order as the previous ones */
+	*same = sort_array_by_ordering(keycode, num_keycodes,
+			config->prev_keycodes, config->num_prev_keycodes);
+
+	memcpy(config->prev_keycodes, keycode, num_keycodes * sizeof(int));
+	config->num_prev_keycodes = num_keycodes;
+
+	return *same != num_keycodes;
+}
+
+/**
+ * Convert a list of key codes into ASCII
+ *
+ * You must call input_check_keycodes() before this. It turns the keycode
+ * list into a list of ASCII characters which are ready to send to the
+ * input layer.
+ *
+ * Characters which were seen last time do not generate fresh ASCII output.
+ *
+ * @param config	Input state
+ * @param keycode	List of key codes to examine
+ * @param num_keycodes	Number of key codes
+ * @param same		Number of key codes which are the same
+ */
+static int input_keycodes_to_ascii(struct input_config *config,
+		int keycode[], int num_keycodes, char output_ch[], int same)
+{
+	struct input_key_xlate *table;
+	int ch_count;
+	int i;
+
+	table = &config->table[0];
+
+	/* deal with modifiers first */
+	for (i = 0; i < num_keycodes; i++) {
+		int key = keycode[i] & KEY_MASK;
+
+		if (key >= table->num_entries || table->xlate[key] == 0xff) {
+			table = process_modifier(config, key,
+					keycode[i] & KEY_RELEASE);
+		}
+	}
+
+	/* now find normal keys */
+	for (i = ch_count = 0; i < num_keycodes; i++) {
+		int key = keycode[i];
+
+		if (key < table->num_entries && i >= same) {
+			int ch = table->xlate[key];
+
+			/* If a normal key with an ASCII value, add it! */
+			if (ch != 0xff)
+				output_ch[ch_count++] = (uchar)ch;
+		}
+	}
+
+	/* ok, so return keys */
+	return ch_count;
+}
+
+int input_send_keycodes(struct input_config *config,
+			int keycode[], int num_keycodes)
+{
+	char ch[num_keycodes];
+	int count, i, same = 0;
+	int is_repeat = 0;
+	unsigned delay_ms;
+
+	config->modifiers = 0;
+	if (!input_check_keycodes(config, keycode, num_keycodes, &same)) {
+		/*
+		 * Same as last time - is it time for another repeat?
+		 * TODO(sjg at chromium.org) We drop repeats here and since
+		 * the caller may not call in again for a while, our
+		 * auto-repeat speed is not quite correct. We should
+		 * insert another character if we later realise that we
+		 * have missed a repeat slot.
+		 */
+		is_repeat = (int)get_timer(config->next_repeat_ms) >= 0;
+		if (!is_repeat)
+			return 0;
+	}
+
+	count = input_keycodes_to_ascii(config, keycode, num_keycodes,
+					ch, is_repeat ? 0 : same);
+	for (i = 0; i < count; i++)
+		input_queue_ascii(config, ch[i]);
+	delay_ms = is_repeat ?
+			config->repeat_rate_ms :
+			config->repeat_delay_ms;
+
+	config->next_repeat_ms = get_timer(0) + delay_ms;
+	return 0;
+}
+
+int input_add_table(struct input_config *config, int left_keycode,
+		    int right_keycode, const uchar *xlate, int num_entries)
+{
+	struct input_key_xlate *table;
+
+	if (config->num_tables == INPUT_MAX_MODIFIERS) {
+		debug("%s: Too many modifier tables\n", __func__);
+		return -1;
+	}
+
+	table = &config->table[config->num_tables++];
+	table->left_keycode = left_keycode;
+	table->right_keycode = right_keycode;
+	table->xlate = xlate;
+	table->num_entries = num_entries;
+
+	return 0;
+}
+
+int input_init(struct input_config *config, int leds, int repeat_delay_ms,
+	       int repeat_rate_ms)
+{
+	memset(config, '\0', sizeof(*config));
+	config->leds = leds;
+	config->repeat_delay_ms = repeat_delay_ms;
+	config->repeat_rate_ms = repeat_rate_ms;
+	if (input_add_table(config, -1, -1,
+			kbd_plain_xlate, ARRAY_SIZE(kbd_plain_xlate)) ||
+		input_add_table(config, KEY_LEFTSHIFT, KEY_RIGHTSHIFT,
+			kbd_shift_xlate, ARRAY_SIZE(kbd_shift_xlate)) ||
+		input_add_table(config, KEY_LEFTCTRL, KEY_RIGHTCTRL,
+			kbd_ctrl_xlate, ARRAY_SIZE(kbd_ctrl_xlate))) {
+		debug("%s: Could not add modifier tables\n", __func__);
+		return -1;
+	}
+
+	return 0;
+}
+
+int input_stdio_register(struct stdio_dev *dev)
+{
+	int error;
+
+	error = stdio_register(dev);
+
+	/* check if this is the standard input device */
+	if (!error && strcmp(getenv("stdin"), dev->name) == 0) {
+		/* reassign the console */
+		if (OVERWRITE_CONSOLE ||
+				console_assign(stdin, dev->name))
+			return -1;
+	}
+
+	return 0;
+}
diff --git a/include/input.h b/include/input.h
new file mode 100644
index 0000000..cbe2e20
--- /dev/null
+++ b/include/input.h
@@ -0,0 +1,145 @@
+/*
+ * Keyboard input helper functions (too small to be called a layer)
+ *
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _INPUT_H
+#define _INPUT_H
+
+enum {
+	INPUT_MAX_MODIFIERS	= 4,
+	INPUT_BUFFER_LEN	= 16,
+};
+
+enum {
+	/* Keyboard LEDs */
+	INPUT_LED_SCROLL	= 1 << 0,
+	INPUT_LED_CAPS		= 1 << 1,
+	INPUT_LED_NUM		= 1 << 2,
+};
+
+/*
+ * This table translates key codes to ASCII. Most of the entries are ASCII
+ * codes, but entries after KEY_FIRST_MOD indicate that this key is a
+ * modifier key, like shift, ctrl. KEY_FIRST_MOD + MOD_SHIFT is the shift
+ * key, for example.
+ */
+struct input_key_xlate {
+	/* keycode of the modifiers which select this table, -1 if none */
+	int left_keycode;
+	int right_keycode;
+	const uchar *xlate;	/* keycode to ASCII table */
+	int num_entries;	/* number of entries in this table */
+};
+
+struct input_config {
+	uchar fifo[INPUT_BUFFER_LEN];
+	int fifo_in, fifo_out;
+
+	/* Which modifiers are active (1 bit for each MOD_... value) */
+	uchar modifiers;
+	uchar flags;		/* active state keys (FLAGS_...) */
+	uchar leds;		/* active LEDS (INPUT_LED_...) */
+	uchar num_tables;	/* number of modifier tables */
+	int prev_keycodes[INPUT_BUFFER_LEN];	/* keys held last time */
+	int num_prev_keycodes;	/* number of prev keys */
+	struct input_key_xlate table[INPUT_MAX_MODIFIERS];
+
+	/**
+	 * Function the input helper calls to scan the keyboard
+	 *
+	 * @param config	Input state
+	 * @return 0 if no keys read, otherwise number of keys read, or 1 if
+	 *		unknown
+	 */
+	int (*read_keys)(struct input_config *config);
+	unsigned int next_repeat_ms;	/* Next time we repeat a key */
+	unsigned int repeat_delay_ms;	/* Time before autorepeat starts */
+	unsigned int repeat_rate_ms;	/* Autorepeat rate in ms */
+};
+
+/**
+ * Convert a list of key codes into ASCII and send them
+ *
+ * @param config	Input state
+ * @param keycode	List of key codes to examine
+ * @param num_keycodes	Number of key codes
+ */
+int input_send_keycodes(struct input_config *config, int keycode[], int count);
+
+/**
+ * Add a new key translation table to the input
+ *
+ * @param config	Input state
+ * @param left_keycode	Key to hold to get into this table
+ * @param right_keycode	Another key to hold to get into this table
+ * @param xlate		Conversion table from key codes to ASCII
+ * @param num_entries	Number of entries in xlate table
+ */
+int input_add_table(struct input_config *config, int left_keycode,
+		    int right_keycode, const uchar *xlate, int num_entries);
+
+/**
+ * Test if keys are available to be read
+ *
+ * @param config	Input state
+ * @return 0 if no keys available, 1 if keys are available
+ */
+int input_tstc(struct input_config *config);
+
+/**
+ * Read a key
+ *
+ * TODO: U-Boot wants 0 for no key, but Ctrl-@ is a valid key...
+ *
+ * @param config	Input state
+ * @return key, or 0 if no key, or -1 if error
+ */
+int input_getc(struct input_config *config);
+
+/**
+ * Register a new device with stdio and switch to it if wanted
+ *
+ * @param dev	Pointer to device
+ * @return 0 if ok, -1 on error
+ */
+int input_stdio_register(struct stdio_dev *dev);
+
+/**
+ * Set up the input handler with basic key maps.
+ *
+ * @param config	Input state
+ * @param leds		Initial LED value (INPUT_LED_ mask), 0 suggested
+ * @param repeat_delay_ms	Delay before key auto-repeat starts (in ms)
+ * @param repeat_rate_ms	Delay between successive key repeats (in ms)
+ * @return 0 if ok, -1 on error
+ */
+int input_init(struct input_config *config, int leds, int repeat_delay_ms,
+	       int repeat_rate_ms);
+
+#ifdef CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE
+extern int overwrite_console(void);
+#define OVERWRITE_CONSOLE overwrite_console()
+#else
+#define OVERWRITE_CONSOLE 0
+#endif /* CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE */
+
+#endif
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [U-Boot] [PATCH v4 04/10] input: Add support for keyboard matrix decoding from an fdt
  2012-04-17 19:01 [U-Boot] [PATCH v4 0/10] tegra: Enable keyboard with matrix keyboard driver Simon Glass
                   ` (2 preceding siblings ...)
  2012-04-17 19:01 ` [U-Boot] [PATCH v4 03/10] input: Add generic keyboard input handler Simon Glass
@ 2012-04-17 19:01 ` Simon Glass
  2012-04-17 19:01 ` [U-Boot] [PATCH v4 05/10] tegra: Add keyboard support to funcmux Simon Glass
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2012-04-17 19:01 UTC (permalink / raw)
  To: u-boot

From: Bernie Thompson <bhthompson@chromium.org>

Matrix keyboards require a key map to be set up, and must also deal with
key ghosting.

Create a keyboard matrix management implementation which can be leveraged
by various keyboard drivers. This includes code to read the keymap from
the FDT and perform debouncing.

Signed-off-by: Bernie Thompson <bhthompson@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v4:
- Move matrix keyboard handling into a separate module

 drivers/input/Makefile     |    1 +
 drivers/input/key_matrix.c |  208 ++++++++++++++++++++++++++++++++++++++++++++
 include/key_matrix.h       |   99 +++++++++++++++++++++
 3 files changed, 308 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/key_matrix.c
 create mode 100644 include/key_matrix.h

diff --git a/drivers/input/Makefile b/drivers/input/Makefile
index d06acb9..b8d8623 100644
--- a/drivers/input/Makefile
+++ b/drivers/input/Makefile
@@ -31,6 +31,7 @@ COBJS-y += keyboard.o pc_keyb.o
 COBJS-$(CONFIG_PS2MULT) += ps2mult.o ps2ser.o
 endif
 COBJS-y += input.o
+COBJS-y += key_matrix.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
diff --git a/drivers/input/key_matrix.c b/drivers/input/key_matrix.c
new file mode 100644
index 0000000..84b898f
--- /dev/null
+++ b/drivers/input/key_matrix.c
@@ -0,0 +1,208 @@
+/*
+ * Manage Keyboard Matrices
+ *
+ * Copyright (c) 2012 The Chromium OS Authors.
+ * (C) Copyright 2004 DENX Software Engineering, Wolfgang Denk, wd at denx.de
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <fdtdec.h>
+#include <key_matrix.h>
+#include <malloc.h>
+#include <linux/input.h>
+
+/**
+ * Determine if the current keypress configuration can cause key ghosting
+ *
+ * We figure this out by seeing if we have two or more keys in the same
+ * column, as well as two or more keys in the same row.
+ *
+ * @param config	Keyboard matrix config
+ * @param keys		List of keys to check
+ * @param valid		Number of valid keypresses to check
+ * @return 0 if no ghosting is possible, 1 if it is
+ */
+static int has_ghosting(struct key_matrix *config, struct key_matrix_key *keys,
+			int valid)
+{
+	int key_in_same_col = 0, key_in_same_row = 0;
+	int i, j;
+
+	for (i = 0; i < valid; i++) {
+		/*
+		 * Find 2 keys such that one key is in the same row
+		 * and the other is in the same column as the i-th key.
+		 */
+		for (j = i + 1; j < valid; j++) {
+			if (keys[j].col == keys[i].col)
+				key_in_same_col = 1;
+			if (keys[j].row == keys[i].row)
+				key_in_same_row = 1;
+		}
+	}
+
+	if (key_in_same_col && key_in_same_row)
+		return 1;
+	else
+		return 0;
+}
+
+int key_matrix_decode(struct key_matrix *config, struct key_matrix_key keys[],
+		      int num_keys, int keycode[], int max_keycodes)
+{
+	const u8 *keymap;
+	int valid, upto;
+	int pos;
+
+	debug("%s: num_keys = %d\n", __func__, num_keys);
+	keymap = config->plain_keycode;
+	for (valid = upto = 0; upto < num_keys; upto++) {
+		struct key_matrix_key *key = &keys[upto];
+
+		debug("  valid=%d, row=%d, col=%d\n", key->valid, key->row,
+		      key->col);
+		if (!key->valid)
+			continue;
+		pos = key->row * config->num_cols + key->col;
+		if (config->fn_keycode && pos == config->fn_pos)
+			keymap = config->fn_keycode;
+
+		/* Convert the (row, col) values into a keycode */
+		if (valid < max_keycodes)
+			keycode[valid++] = keymap[pos];
+		debug("    keycode=%d\n", keymap[pos]);
+	}
+
+	/* For a ghost key config, ignore the keypresses for this iteration. */
+	if (valid >= 3 && has_ghosting(config, keys, valid)) {
+		valid = 0;
+		debug("    ghosting detected!\n");
+	}
+	debug("  %d valid keycodes found\n", valid);
+
+	return valid;
+}
+
+/**
+ * Create a new keycode map from some provided data
+ *
+ * This decodes a keycode map in the format used by the fdt, which is one
+ * word per entry, with the row, col and keycode encoded in that word.
+ *
+ * We create a (row x col) size byte array with each entry containing the
+ * keycode for that (row, col). We also search for map_keycode and return
+ * its position if found (this is used for finding the Fn key).
+ *
+ * @param config        Key matrix dimensions structure
+ * @param data          Keycode data
+ * @param len           Number of entries in keycode table
+ * @param map_keycode   Key code to find in the map
+ * @param pos           Returns position of map_keycode, if found, else -1
+ * @return map  Pointer to allocated map
+ */
+static uchar *create_keymap(struct key_matrix *config, u32 *data, int len,
+			    int map_keycode, int *pos)
+{
+	uchar *map;
+
+	if (pos)
+		*pos = -1;
+	map = (uchar *)calloc(1, config->key_count);
+	if (!map) {
+		debug("%s: failed to malloc %d bytes\n", __func__,
+			config->key_count);
+		return NULL;
+	}
+
+	for (; len >= sizeof(u32); data++, len -= 4) {
+		u32 tmp = fdt32_to_cpu(*data);
+		int key_code, row, col;
+		int entry;
+
+		row = (tmp >> 24) & 0xff;
+		col = (tmp >> 16) & 0xff;
+		key_code = tmp & 0xffff;
+		entry = row * config->num_cols + col;
+		map[entry] = key_code;
+		if (pos && map_keycode == key_code)
+			*pos = entry;
+	}
+
+	return map;
+}
+
+int key_matrix_decode_fdt(struct key_matrix *config, const void *blob,
+			  int node)
+{
+	const struct fdt_property *prop;
+	int offset;
+
+	/* Check each property name for ones that we understand */
+	for (offset = fdt_first_property_offset(blob, node);
+		      offset > 0;
+		      offset = fdt_next_property_offset(blob, offset)) {
+		const char *name;
+		int len;
+
+		prop = fdt_get_property_by_offset(blob, offset, NULL);
+		name = fdt_string(blob, fdt32_to_cpu(prop->nameoff));
+		len = strlen(name);
+
+		/* Name needs to match "1,<type>keymap" */
+		debug("%s: property '%s'\n", __func__, name);
+		if (strncmp(name, "1,", 2) || len < 8 ||
+		    strcmp(name + len - 6, "keymap"))
+			continue;
+
+		len -= 8;
+		if (len == 0) {
+			config->plain_keycode = create_keymap(config,
+				(u32 *)prop->data, fdt32_to_cpu(prop->len),
+				KEY_FN, &config->fn_pos);
+		} else if (0 == strncmp(name + 2, "fn-", len)) {
+			config->fn_keycode = create_keymap(config,
+				(u32 *)prop->data, fdt32_to_cpu(prop->len),
+				-1, NULL);
+		} else {
+			debug("%s: unrecognised property '%s'\n", __func__,
+			      name);
+		}
+	}
+	debug("%s: Decoded key maps %p, %p from fdt\n", __func__,
+	      config->plain_keycode, config->fn_keycode);
+
+	if (!config->plain_keycode) {
+		debug("%s: cannot find keycode-plain map\n", __func__);
+		return -1;
+	}
+
+	return 0;
+}
+
+int key_matrix_init(struct key_matrix *config, int rows, int cols)
+{
+	memset(config, '\0', sizeof(*config));
+	config->num_rows = rows;
+	config->num_cols = cols;
+	config->key_count = rows * cols;
+	assert(config->key_count > 0);
+
+	return 0;
+}
diff --git a/include/key_matrix.h b/include/key_matrix.h
new file mode 100644
index 0000000..f413314
--- /dev/null
+++ b/include/key_matrix.h
@@ -0,0 +1,99 @@
+/*
+ * Keyboard matrix helper functions
+ *
+ * Copyright (c) 2012 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _KEY_MATRIX_H
+#define _KEY_MATRIX_H
+
+#include <common.h>
+
+/* Information about a matrix keyboard */
+struct key_matrix {
+	/* Dimensions of the keyboard matrix, in rows and columns */
+	int num_rows;
+	int num_cols;
+	int key_count;	/* number of keys in the matrix (= rows * cols) */
+
+	/*
+	 * Information about keycode mappings. The plain_keycode array must
+	 * exist but fn may be NULL in which case it is not decoded.
+	 */
+	const u8 *plain_keycode;        /* key code for each row / column */
+	const u8 *fn_keycode;           /* ...when Fn held down */
+	int fn_pos;                     /* position of Fn key in key (or -1) */
+};
+
+/* Information about a particular key (row, column pair) in the matrix */
+struct key_matrix_key {
+	uint8_t row;	/* row number (0 = first) */
+	uint8_t col;	/* column number (0 = first) */
+	uint8_t valid;	/* 1 if valid, 0 to ignore this */
+};
+
+/**
+ * Decode a set of pressed keys into key codes
+ *
+ * Given a list of keys that are pressed, this converts this list into
+ * a list of key codes. Each of the keys has a valid flag, which can be
+ * used to mark a particular key as invalid (so that it is ignored).
+ *
+ * The plain keymap is used, unless the Fn key is detected along the way,
+ * at which point we switch to the Fn key map.
+ *
+ * If key ghosting is detected, we simply ignore the keys and return 0.
+ *
+ * @param config        Keyboard matrix config
+ * @param keys		List of keys to process (each is row, col)
+ * @param num_keys	Number of keys to process
+ * @param keycode	Returns a list of key codes, decoded from input
+ * @param max_keycodes	Size of key codes array (suggest 8)
+ *
+ */
+int key_matrix_decode(struct key_matrix *config, struct key_matrix_key *keys,
+		      int num_keys, int keycode[], int max_keycodes);
+
+/**
+ * Read the keyboard configuration out of the fdt.
+ *
+ * Decode properties of named "linux,<type>keymap" where <type> is either
+ * empty, or "fn-". Then set up the plain key map (and the FN keymap if
+ * present).
+ *
+ * @param config        Keyboard matrix config
+ * @param blob          FDT blob
+ * @param node          Node containing compatible data
+ * @return 0 if ok, -1 on error
+ */
+int key_matrix_decode_fdt(struct key_matrix *config, const void *blob,
+			  int node);
+
+/**
+ * Set up a new key matrix.
+ *
+ * @param config	Keyboard matrix config
+ * @param rows		Number of rows in key matrix
+ * @param cols		Number of columns in key matrix
+ * @return 0 if ok, -1 on error
+ */
+int key_matrix_init(struct key_matrix *config, int rows, int cols);
+
+#endif
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [U-Boot] [PATCH v4 05/10] tegra: Add keyboard support to funcmux
  2012-04-17 19:01 [U-Boot] [PATCH v4 0/10] tegra: Enable keyboard with matrix keyboard driver Simon Glass
                   ` (3 preceding siblings ...)
  2012-04-17 19:01 ` [U-Boot] [PATCH v4 04/10] input: Add support for keyboard matrix decoding from an fdt Simon Glass
@ 2012-04-17 19:01 ` Simon Glass
  2012-04-23 20:56   ` Stephen Warren
  2012-04-17 19:01   ` [U-Boot] " Simon Glass
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 24+ messages in thread
From: Simon Glass @ 2012-04-17 19:01 UTC (permalink / raw)
  To: u-boot

Add funcmux support for the default keyboard mapping.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v3:
- Use funcmux to set up keyboard pinmux

 arch/arm/cpu/armv7/tegra2/funcmux.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/arch/arm/cpu/armv7/tegra2/funcmux.c b/arch/arm/cpu/armv7/tegra2/funcmux.c
index 8931d5e..53e85ff 100644
--- a/arch/arm/cpu/armv7/tegra2/funcmux.c
+++ b/arch/arm/cpu/armv7/tegra2/funcmux.c
@@ -176,6 +176,22 @@ int funcmux_select(enum periph_id id, int config)
 		}
 		break;
 
+	case PERIPH_ID_KBC:
+		if (config == FUNCMUX_DEFAULT) {
+			enum pmux_pingrp grp[] = {PINGRP_KBCA, PINGRP_KBCB,
+				PINGRP_KBCC, PINGRP_KBCD, PINGRP_KBCE,
+				PINGRP_KBCF};
+			int i;
+
+			for (i = 0; i < ARRAY_SIZE(grp); i++) {
+				pinmux_tristate_disable(grp[i]);
+				pinmux_set_func(grp[i], PMUX_FUNC_KBC);
+				pinmux_set_pullupdown(grp[i], PMUX_PULL_UP);
+			}
+
+			break;
+		}
+
 	default:
 		debug("%s: invalid periph_id %d", __func__, id);
 		return -1;
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v4 06/10] tegra: fdt: Add keyboard controller definition
  2012-04-17 19:01 [U-Boot] [PATCH v4 0/10] tegra: Enable keyboard with matrix keyboard driver Simon Glass
@ 2012-04-17 19:01   ` Simon Glass
  2012-04-17 19:01 ` [U-Boot] [PATCH v4 02/10] input: Add linux/input.h for key code support Simon Glass
                     ` (8 subsequent siblings)
  9 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2012-04-17 19:01 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Anton Staff, Jerry Van Baren, Tom Warren, Devicetree Discuss

From: Anton Staff <robotboy@chromium.org>

The Tegra keyboard controller provides a simple interface to a matrix
keyboard.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/arm/dts/tegra20.dtsi |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/arch/arm/dts/tegra20.dtsi b/arch/arm/dts/tegra20.dtsi
index 018a3c8..5d214f2 100644
--- a/arch/arm/dts/tegra20.dtsi
+++ b/arch/arm/dts/tegra20.dtsi
@@ -206,4 +206,9 @@
 		compatible = "nvidia,tegra20-nand";
 		reg = <0x70008000 0x100>;
 	};
+
+	kbc@7000e200 {
+		compatible = "nvidia,tegra20-kbc";
+		reg = <0x7000e200 0x0078>;
+	};
 };
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [U-Boot] [PATCH v4 06/10] tegra: fdt: Add keyboard controller definition
@ 2012-04-17 19:01   ` Simon Glass
  0 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2012-04-17 19:01 UTC (permalink / raw)
  To: u-boot

From: Anton Staff <robotboy@chromium.org>

The Tegra keyboard controller provides a simple interface to a matrix
keyboard.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/arm/dts/tegra20.dtsi |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/arch/arm/dts/tegra20.dtsi b/arch/arm/dts/tegra20.dtsi
index 018a3c8..5d214f2 100644
--- a/arch/arm/dts/tegra20.dtsi
+++ b/arch/arm/dts/tegra20.dtsi
@@ -206,4 +206,9 @@
 		compatible = "nvidia,tegra20-nand";
 		reg = <0x70008000 0x100>;
 	};
+
+	kbc at 7000e200 {
+		compatible = "nvidia,tegra20-kbc";
+		reg = <0x7000e200 0x0078>;
+	};
 };
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v4 07/10] tegra: fdt: Add keyboard definitions for Seaboard
  2012-04-17 19:01 [U-Boot] [PATCH v4 0/10] tegra: Enable keyboard with matrix keyboard driver Simon Glass
@ 2012-04-17 19:01     ` Simon Glass
  2012-04-17 19:01 ` [U-Boot] [PATCH v4 02/10] input: Add linux/input.h for key code support Simon Glass
                       ` (8 subsequent siblings)
  9 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2012-04-17 19:01 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Anton Staff, Jerry Van Baren, Tom Warren, Devicetree Discuss

From: Anton Staff <robotboy-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>

Seaboard uses a QUERTY keyboard. We add key codes for this to
enable key scanning to work.

Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
Changes in v2:
- Remove status = "okay" since this is the default anyway

Changes in v3:
- Move to new Linux device tree mapping for Tegra keyboard

 board/nvidia/dts/tegra2-seaboard.dts |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/board/nvidia/dts/tegra2-seaboard.dts b/board/nvidia/dts/tegra2-seaboard.dts
index 72a5f5d..db72ef2 100644
--- a/board/nvidia/dts/tegra2-seaboard.dts
+++ b/board/nvidia/dts/tegra2-seaboard.dts
@@ -142,4 +142,31 @@
 			nvidia,page-spare-bytes = <64>;
 		};
 	};
+
+	kbc@7000e200 {
+		linux,keymap = <0x00020011 0x0003001f 0x0004001e 0x0005002c
+			0x000701d0 0x0107007d 0x02060064 0x02070038 0x03000006
+			0x03010005 0x03020013 0x03030012 0x03040021 0x03050020
+			0x0306002d 0x04000008 0x04010007 0x04020014 0x04030023
+			0x04040022 0x0405002f 0x0406002e 0x04070039 0x0500000a
+			0x05010009 0x05020016 0x05030015 0x05040024 0x05050031
+			0x05060030 0x0507002b 0x0600000c 0x0601000b 0x06020018
+			0x06030017 0x06040026 0x06050025 0x06060033 0x06070032
+			0x0701000d 0x0702001b 0x0703001c 0x0707008b 0x08040036
+			0x0805002a 0x09050061 0x0907001d 0x0b00001a 0x0b010019
+			0x0b020028 0x0b030027 0x0b040035 0x0b050034 0x0c000044
+			0x0c010043 0x0c02000e 0x0c030004 0x0c040003 0x0c050067
+			0x0c0600d2 0x0c070077 0x0d00006e 0x0d01006f 0x0d030068
+			0x0d04006d 0x0d05006a 0x0d06006c 0x0d070069 0x0e000057
+			0x0e010058 0x0e020042 0x0e030010 0x0e04003e 0x0e05003d
+			0x0e060002 0x0e070041 0x0f000001 0x0f010029 0x0f02003f
+			0x0f03000f 0x0f04003b 0x0f05003c 0x0f06003a 0x0f070040
+			0x14000047 0x15000049 0x15010048 0x1502004b 0x1504004f
+			0x16010062 0x1602004d 0x1603004c 0x16040051 0x16050050
+			0x16070052 0x1b010037 0x1b03004a 0x1b04004e 0x1b050053
+			0x1c050073 0x1d030066 0x1d04006b 0x1d0500e0 0x1d060072
+			0x1d0700e1 0x1e000045 0x1e010046 0x1e020071
+			0x1f04008a>;
+		linux,fn-keymap = <0x05040002>;
+	};
 };
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [U-Boot] [PATCH v4 07/10] tegra: fdt: Add keyboard definitions for Seaboard
@ 2012-04-17 19:01     ` Simon Glass
  0 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2012-04-17 19:01 UTC (permalink / raw)
  To: u-boot

From: Anton Staff <robotboy@chromium.org>

Seaboard uses a QUERTY keyboard. We add key codes for this to
enable key scanning to work.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Remove status = "okay" since this is the default anyway

Changes in v3:
- Move to new Linux device tree mapping for Tegra keyboard

 board/nvidia/dts/tegra2-seaboard.dts |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/board/nvidia/dts/tegra2-seaboard.dts b/board/nvidia/dts/tegra2-seaboard.dts
index 72a5f5d..db72ef2 100644
--- a/board/nvidia/dts/tegra2-seaboard.dts
+++ b/board/nvidia/dts/tegra2-seaboard.dts
@@ -142,4 +142,31 @@
 			nvidia,page-spare-bytes = <64>;
 		};
 	};
+
+	kbc at 7000e200 {
+		linux,keymap = <0x00020011 0x0003001f 0x0004001e 0x0005002c
+			0x000701d0 0x0107007d 0x02060064 0x02070038 0x03000006
+			0x03010005 0x03020013 0x03030012 0x03040021 0x03050020
+			0x0306002d 0x04000008 0x04010007 0x04020014 0x04030023
+			0x04040022 0x0405002f 0x0406002e 0x04070039 0x0500000a
+			0x05010009 0x05020016 0x05030015 0x05040024 0x05050031
+			0x05060030 0x0507002b 0x0600000c 0x0601000b 0x06020018
+			0x06030017 0x06040026 0x06050025 0x06060033 0x06070032
+			0x0701000d 0x0702001b 0x0703001c 0x0707008b 0x08040036
+			0x0805002a 0x09050061 0x0907001d 0x0b00001a 0x0b010019
+			0x0b020028 0x0b030027 0x0b040035 0x0b050034 0x0c000044
+			0x0c010043 0x0c02000e 0x0c030004 0x0c040003 0x0c050067
+			0x0c0600d2 0x0c070077 0x0d00006e 0x0d01006f 0x0d030068
+			0x0d04006d 0x0d05006a 0x0d06006c 0x0d070069 0x0e000057
+			0x0e010058 0x0e020042 0x0e030010 0x0e04003e 0x0e05003d
+			0x0e060002 0x0e070041 0x0f000001 0x0f010029 0x0f02003f
+			0x0f03000f 0x0f04003b 0x0f05003c 0x0f06003a 0x0f070040
+			0x14000047 0x15000049 0x15010048 0x1502004b 0x1504004f
+			0x16010062 0x1602004d 0x1603004c 0x16040051 0x16050050
+			0x16070052 0x1b010037 0x1b03004a 0x1b04004e 0x1b050053
+			0x1c050073 0x1d030066 0x1d04006b 0x1d0500e0 0x1d060072
+			0x1d0700e1 0x1e000045 0x1e010046 0x1e020071
+			0x1f04008a>;
+		linux,fn-keymap = <0x05040002>;
+	};
 };
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [U-Boot] [PATCH v4 08/10] tegra: Add tegra keyboard driver
  2012-04-17 19:01 [U-Boot] [PATCH v4 0/10] tegra: Enable keyboard with matrix keyboard driver Simon Glass
                   ` (6 preceding siblings ...)
       [not found] ` <1334689297-13489-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
@ 2012-04-17 19:01 ` Simon Glass
  2012-04-23 21:07   ` Stephen Warren
  2012-04-17 19:01 ` [U-Boot] [PATCH v4 09/10] tegra: Switch on console mux and use environment for console Simon Glass
  2012-04-17 19:01 ` [U-Boot] [PATCH v4 10/10] tegra: Enable keyboard for Seaboard Simon Glass
  9 siblings, 1 reply; 24+ messages in thread
From: Simon Glass @ 2012-04-17 19:01 UTC (permalink / raw)
  To: u-boot

From: Rakesh Iyer <riyer@nvidia.com>

Add support for internal matrix keyboard controller for Nvidia Tegra
platforms. This driver uses the fdt decode function to obtain its key
codes.

Support for the Ctrl modifier is provided. The left and right ctrl keys are
dealt with in the same way.

This uses the new keyboard input library (drivers/input/input.c) to decode
keys and handle most of the common input logic. The new key matrix library
is also used to decode (row, column) key positions into key codes.

The intent is to make this driver purely about dealing with the hardware.

Key detection before the driver is loaded is supported. This key will be
picked up when the keyboard driver is initialized.

Modified by Bernie Thompson <bhthompson@chromium.org> and
Simon Glass <sjg@chromium.org> for device tree, input layer, key matrix
and various other things.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v3:
- Adjust decode logic to work with new Linux fdt keyboard binding
- Use new input library to handle key decode, fifo, getc()/tstc()

Changes in v4:
- Simplify driver as much as possible using input/key matrix layers
- Use new key_matrix handler to deal with key matrix decode

 drivers/input/Makefile    |    1 +
 drivers/input/tegra-kbc.c |  375 +++++++++++++++++++++++++++++++++++++++++++++
 include/fdtdec.h          |    1 +
 include/tegra-kbc.h       |   33 ++++
 lib/fdtdec.c              |    1 +
 5 files changed, 411 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/tegra-kbc.c
 create mode 100644 include/tegra-kbc.h

diff --git a/drivers/input/Makefile b/drivers/input/Makefile
index b8d8623..8b51dff 100644
--- a/drivers/input/Makefile
+++ b/drivers/input/Makefile
@@ -26,6 +26,7 @@ include $(TOPDIR)/config.mk
 LIB	:= $(obj)libinput.o
 
 COBJS-$(CONFIG_I8042_KBD) += i8042.o
+COBJS-$(CONFIG_TEGRA2_KEYBOARD) += tegra-kbc.o
 ifdef CONFIG_PS2KBD
 COBJS-y += keyboard.o pc_keyb.o
 COBJS-$(CONFIG_PS2MULT) += ps2mult.o ps2ser.o
diff --git a/drivers/input/tegra-kbc.c b/drivers/input/tegra-kbc.c
new file mode 100644
index 0000000..f164791
--- /dev/null
+++ b/drivers/input/tegra-kbc.c
@@ -0,0 +1,375 @@
+/*
+ *  (C) Copyright 2011
+ *  NVIDIA Corporation <www.nvidia.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <fdtdec.h>
+#include <input.h>
+#include <key_matrix.h>
+#include <stdio_dev.h>
+#include <tegra-kbc.h>
+#include <asm/io.h>
+#include <asm/arch/clock.h>
+#include <asm/arch/funcmux.h>
+#include <asm/arch/timer.h>
+#include <linux/input.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+enum {
+	KBC_MAX_GPIO		= 24,
+	KBC_MAX_KPENT		= 8,	/* size of keypress entry queue */
+};
+
+#define KBC_FIFO_TH_CNT_SHIFT		14
+#define KBC_DEBOUNCE_CNT_SHIFT		4
+#define KBC_CONTROL_FIFO_CNT_INT_EN	(1 << 3)
+#define KBC_CONTROL_KBC_EN		(1 << 0)
+#define KBC_INT_FIFO_CNT_INT_STATUS	(1 << 2)
+#define KBC_KPENT_VALID			(1 << 7)
+#define KBC_ST_STATUS			(1 << 3)
+
+enum {
+	KBC_DEBOUNCE_COUNT	= 2,
+	KBC_REPEAT_RATE_MS	= 30,
+	KBC_REPEAT_DELAY_MS	= 240,
+	KBC_CLOCK_KHZ		= 32,	/* Keyboard uses a 32KHz clock */
+};
+
+/* keyboard controller config and state */
+static struct keyb {
+	struct input_config input;	/* The input layer */
+	struct key_matrix matrix;	/* The key matrix layer */
+
+	struct kbc_tegra *kbc;		/* tegra keyboard controller */
+	unsigned char inited;		/* 1 if keyboard has been inited */
+	unsigned char first_scan;	/* 1 if this is our first key scan */
+
+	/*
+	 * After init we must wait a short time before polling the keyboard.
+	 * This gives the tegra keyboard controller time to react after reset
+	 * and lets us grab keys pressed during reset.
+	 */
+	unsigned int init_dly_ms;	/* Delay before we can read keyboard */
+	unsigned int start_time_ms;	/* Time that we inited (in ms) */
+	unsigned int last_poll_ms;	/* Time we should last polled */
+	unsigned int next_repeat_ms;	/* Next time we repeat a key */
+} config;
+
+/**
+ * reads the keyboard fifo for current keypresses
+ *
+ * @param config	Keyboard config
+ * @param fifo		Place to put fifo results
+ * @param max_keycodes	Maximum number of key codes to put in the fifo
+ * @return number of items put into fifo
+ */
+static int tegra_kbc_find_keys(struct keyb *config, int *fifo,
+			       int max_keycodes)
+{
+	struct key_matrix_key keys[KBC_MAX_KPENT], *key;
+	u32 kp_ent = 0;
+	int i;
+
+	for (key = keys, i = 0; i < KBC_MAX_KPENT; i++, key++) {
+		/* Get next word */
+		if (!(i & 3))
+			kp_ent = readl(&config->kbc->kp_ent[i / 4]);
+
+		key->valid = (kp_ent & KBC_KPENT_VALID) != 0;
+		key->row = (kp_ent >> 3) & 0xf;
+		key->col = kp_ent & 0x7;
+
+		/* Shift to get next entry */
+		kp_ent >>= 8;
+	}
+	return key_matrix_decode(&config->matrix, keys, KBC_MAX_KPENT, fifo,
+				 max_keycodes);
+}
+
+/**
+ * Process all the keypress sequences in fifo and send key codes
+ *
+ * The fifo contains zero or more keypress sets. Each set
+ * consists of from 1-8 keycodes, representing the keycodes which
+ * were simultaneously pressed during that scan.
+ *
+ * This function works through each set and generates ASCII characters
+ * for each. Not that one set may produce more than one ASCII characters -
+ * for example holding down 'd' and 'f' at the same time will generate
+ * two ASCII characters.
+ *
+ * Note: if fifo_cnt is 0, we will tell the input layer that no keys are
+ * pressed.
+ *
+ * @param config	Keyboard config
+ * @param fifo_cnt	Number of entries in the keyboard fifo
+ */
+static void process_fifo(struct keyb *config, int fifo_cnt)
+{
+	int fifo[KBC_MAX_KPENT];
+	int cnt = 0;
+
+	/* Always call input_send_keycodes() at least once */
+	do {
+		if (fifo_cnt)
+			cnt = tegra_kbc_find_keys(config, fifo, KBC_MAX_KPENT);
+
+		input_send_keycodes(&config->input, fifo, cnt);
+	} while (--fifo_cnt > 0);
+}
+
+/**
+ * Check the keyboard controller and emit ASCII characters for any keys that
+ * are pressed.
+ *
+ * @param config	Keyboard config
+ */
+static void check_for_keys(struct keyb *config)
+{
+	int fifo_cnt;
+
+	if (!config->first_scan &&
+			get_timer(config->last_poll_ms) < KBC_REPEAT_RATE_MS)
+		return;
+	config->last_poll_ms = get_timer(0);
+	config->first_scan = 0;
+
+	/*
+	 * Once we get here we know the keyboard has been scanned. So if there
+	 * scan waiting for us, we know that nothing is held down.
+	 */
+	fifo_cnt = (readl(&config->kbc->interrupt) >> 4) & 0xf;
+	process_fifo(config, fifo_cnt);
+}
+
+/**
+ * In order to detect keys pressed on boot, wait for the hardware to
+ * complete scanning the keys. This includes time to transition from
+ * Wkup mode to Continous polling mode and the repoll time. We can
+ * deduct the time that's already elapsed.
+ *
+ * @param config	Keyboard config
+ */
+static void kbd_wait_for_fifo_init(struct keyb *config)
+{
+	if (!config->inited) {
+		unsigned long elapsed_time;
+		long delay_ms;
+
+		elapsed_time = get_timer(config->start_time_ms);
+		delay_ms = config->init_dly_ms - elapsed_time;
+		if (delay_ms > 0) {
+			udelay(delay_ms * 1000);
+			debug("%s: delay %ldms\n", __func__, delay_ms);
+		}
+
+		config->inited = 1;
+	}
+}
+
+/**
+ * Check the tegra keyboard, and send any keys that are pressed.
+ *
+ * This is called by input_tstc() and input_getc() when they need more
+ * characters
+ *
+ * @param input		Input configuration
+ * @return 1, to indicate that we have something to look at
+ */
+int tegra_kbc_check(struct input_config *input)
+{
+	kbd_wait_for_fifo_init(&config);
+	check_for_keys(&config);
+
+	return 1;
+}
+
+/**
+ * Test if keys are available to be read
+ *
+ * @return 0 if no keys available, 1 if keys are available
+ */
+static int kbd_tstc(void)
+{
+	/* Just get input to do this for us */
+	return input_tstc(&config.input);
+}
+
+/**
+ * Read a key
+ *
+ * TODO: U-Boot wants 0 for no key, but Ctrl-@ is a valid key...
+ *
+ * @return ASCII key code, or 0 if no key, or -1 if error
+ */
+static int kbd_getc(void)
+{
+	/* Just get input to do this for us */
+	return input_getc(&config.input);
+}
+
+/* configures keyboard GPIO registers to use the rows and columns */
+static void config_kbc_gpio(struct kbc_tegra *kbc)
+{
+	int i;
+
+	for (i = 0; i < KBC_MAX_GPIO; i++) {
+		u32 row_cfg, col_cfg;
+		u32 r_shift = 5 * (i % 6);
+		u32 c_shift = 4 * (i % 8);
+		u32 r_mask = 0x1f << r_shift;
+		u32 c_mask = 0xf << c_shift;
+		u32 r_offs = i / 6;
+		u32 c_offs = i / 8;
+
+		row_cfg = readl(&kbc->row_cfg[r_offs]);
+		col_cfg = readl(&kbc->col_cfg[c_offs]);
+
+		row_cfg &= ~r_mask;
+		col_cfg &= ~c_mask;
+
+		if (i < config.matrix.num_rows) {
+			row_cfg |= ((i << 1) | 1) << r_shift;
+		} else {
+			col_cfg |= (((i - config.matrix.num_rows) << 1) | 1)
+					<< c_shift;
+		}
+
+		writel(row_cfg, &kbc->row_cfg[r_offs]);
+		writel(col_cfg, &kbc->col_cfg[c_offs]);
+	}
+}
+
+/**
+ * Start up the keyboard device
+ */
+static void tegra_kbc_open(void)
+{
+	struct kbc_tegra *kbc = config.kbc;
+	unsigned int scan_period;
+	u32 val;
+
+	/*
+	 * We will scan at twice the keyboard repeat rate, so that there is
+	 * always a scan ready when we check it in check_for_keys().
+	 */
+	scan_period = KBC_REPEAT_RATE_MS / 2;
+	writel(scan_period * KBC_CLOCK_KHZ, &kbc->rpt_dly);
+	writel(scan_period * KBC_CLOCK_KHZ, &kbc->init_dly);
+	/*
+	 * Before reading from the keyboard we must wait for the init_dly
+	 * plus the rpt_delay, plus 2ms for the row scan time.
+	 */
+	config.init_dly_ms = scan_period * 2 + 2;
+
+	val = KBC_DEBOUNCE_COUNT << KBC_DEBOUNCE_CNT_SHIFT;
+	val |= 1 << KBC_FIFO_TH_CNT_SHIFT;	/* fifo interrupt threshold */
+	val |= KBC_CONTROL_KBC_EN;		/* enable */
+	writel(val, &kbc->control);
+
+	config.start_time_ms = get_timer(0);
+	config.last_poll_ms = config.next_repeat_ms = get_timer(0);
+	config.first_scan = 1;
+}
+
+/**
+ * Set up the tegra keyboard. This is called by the stdio device handler
+ *
+ * We want to do this init when the keyboard is actually used rather than
+ * at start-up, since keyboard input may not currently be selected.
+ *
+ * Once the keyboard starts there will be a period during which we must
+ * wait for the keyboard to init. We do this only when a key is first
+ * read - see kbd_wait_for_fifo_init().
+ *
+ * @return 0 if ok, -ve on error
+ */
+static int init_tegra_keyboard(void)
+{
+#ifdef CONFIG_OF_CONTROL
+	int	node;
+
+	node = fdtdec_next_compatible(gd->fdt_blob, 0,
+					  COMPAT_NVIDIA_TEGRA20_KBC);
+	if (node < 0) {
+		debug("%s: cannot locate keyboard node\n", __func__);
+		return node;
+	}
+	config.kbc = (struct kbc_tegra *)fdtdec_get_addr(gd->fdt_blob,
+		       node, "reg");
+	if ((fdt_addr_t)config.kbc == FDT_ADDR_T_NONE) {
+		debug("%s: No keyboard register found\n", __func__);
+		return -1;
+	}
+
+	/* Decode the keyboard matrix information (16 rows, 8 columns) */
+	if (key_matrix_init(&config.matrix, 16, 8)) {
+		debug("%s: Could not init key matrix\n", __func__);
+		return -1;
+	}
+	if (key_matrix_decode_fdt(&config.matrix, gd->fdt_blob, node)) {
+		debug("%s: Could not decode key matrix from fdt\n", __func__);
+		return -1;
+	}
+	if (config.matrix.fn_keycode) {
+		if (input_add_table(&config.input, KEY_FN, -1,
+				    config.matrix.fn_keycode,
+				    config.matrix.key_count))
+			return -1;
+	}
+#else
+#error "Tegra keyboard driver requires FDT definitions"
+#endif
+
+	/* Set up pin mux and enable the clock */
+	funcmux_select(PERIPH_ID_KBC, FUNCMUX_DEFAULT);
+	clock_enable(PERIPH_ID_KBC);
+	config_kbc_gpio(config.kbc);
+
+	tegra_kbc_open();
+	debug("%s: Tegra keyboard ready\n", __func__);
+
+	return 0;
+}
+
+int drv_keyboard_init(void)
+{
+	struct stdio_dev dev;
+
+	if (input_init(&config.input, 0, KBC_REPEAT_DELAY_MS,
+			KBC_REPEAT_RATE_MS)) {
+		debug("%s: Cannot set up input\n", __func__);
+		return -1;
+	}
+	config.input.read_keys = tegra_kbc_check;
+
+	memset(&dev, '\0', sizeof(dev));
+	strcpy(dev.name, "tegra-kbc");
+	dev.flags = DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
+	dev.getc = kbd_getc;
+	dev.tstc = kbd_tstc;
+	dev.start = init_tegra_keyboard;
+
+	/* Register the device. init_tegra_keyboard() will be called soon */
+	return input_stdio_register(&dev);
+}
diff --git a/include/fdtdec.h b/include/fdtdec.h
index 5140f4a..2286958 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -63,6 +63,7 @@ enum fdt_compat_id {
 	COMPAT_NVIDIA_TEGRA20_EMC,	/* Tegra2 memory controller */
 	COMPAT_NVIDIA_TEGRA20_EMC_TABLE, /* Tegra2 memory timing table */
 	COMPAT_NVIDIA_TEGRA20_NAND,	/* Tegra2 NAND controller */
+	COMPAT_NVIDIA_TEGRA20_KBC,	/* Tegra2 Keyboard */
 
 	COMPAT_COUNT,
 };
diff --git a/include/tegra-kbc.h b/include/tegra-kbc.h
new file mode 100644
index 0000000..f331c79
--- /dev/null
+++ b/include/tegra-kbc.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef __include_tegra_kbc_h__
+#define __include_tegra_kbc_h__
+
+#include <common.h>
+
+#define KEY_IS_MODIFIER(key) ((key) >= KEY_FIRST_MODIFIER)
+
+struct kbc_tegra {
+	u32 control;
+	u32 interrupt;
+	u32 row_cfg[4];
+	u32 col_cfg[3];
+	u32 timeout_dly;
+	u32 init_dly;
+	u32 rpt_dly;
+	u32 kp_ent[2];
+	u32 row_mask[16];
+};
+
+#ifdef CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE
+extern int overwrite_console(void);
+#define OVERWRITE_CONSOLE overwrite_console()
+#else
+#define OVERWRITE_CONSOLE 0
+#endif /* CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE */
+
+#endif /* __include_tegra_kbc_h__ */
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 585dd6d..3005134 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -43,6 +43,7 @@ static const char * const compat_names[COMPAT_COUNT] = {
 	COMPAT(NVIDIA_TEGRA20_EMC, "nvidia,tegra20-emc"),
 	COMPAT(NVIDIA_TEGRA20_EMC_TABLE, "nvidia,tegra20-emc-table"),
 	COMPAT(NVIDIA_TEGRA20_NAND, "nvidia,tegra20-nand"),
+	COMPAT(NVIDIA_TEGRA20_KBC, "nvidia,tegra20-kbc"),
 };
 
 const char *fdtdec_get_compatible(enum fdt_compat_id id)
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [U-Boot] [PATCH v4 09/10] tegra: Switch on console mux and use environment for console
  2012-04-17 19:01 [U-Boot] [PATCH v4 0/10] tegra: Enable keyboard with matrix keyboard driver Simon Glass
                   ` (7 preceding siblings ...)
  2012-04-17 19:01 ` [U-Boot] [PATCH v4 08/10] tegra: Add tegra keyboard driver Simon Glass
@ 2012-04-17 19:01 ` Simon Glass
  2012-04-23 21:10   ` Stephen Warren
  2012-04-17 19:01 ` [U-Boot] [PATCH v4 10/10] tegra: Enable keyboard for Seaboard Simon Glass
  9 siblings, 1 reply; 24+ messages in thread
From: Simon Glass @ 2012-04-17 19:01 UTC (permalink / raw)
  To: u-boot

All tegra boards will use these options by default.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 include/configs/tegra2-common.h |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/include/configs/tegra2-common.h b/include/configs/tegra2-common.h
index c5870dd..068ce88 100644
--- a/include/configs/tegra2-common.h
+++ b/include/configs/tegra2-common.h
@@ -132,11 +132,18 @@
 
 #define CONFIG_SYS_NO_FLASH
 
-/* Environment information */
+/* Environment information, boards can override if required */
+#define CONFIG_CONSOLE_MUX
+#define CONFIG_SYS_CONSOLE_IS_IN_ENV
+#define TEGRA2_DEVICE_SETTINGS	"stdin=serial\0" \
+					"stdout=serial\0" \
+					"stderr=serial\0"
+
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	"console=ttyS0,115200n8\0" \
 	"mem=" TEGRA2_SYSMEM "\0" \
 	"smpflag=smp\0" \
+	TEGRA2_DEVICE_SETTINGS
 
 #define CONFIG_LOADADDR		0x408000	/* def. location for kernel */
 #define CONFIG_BOOTDELAY	2		/* -1 to disable auto boot */
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [U-Boot] [PATCH v4 10/10] tegra: Enable keyboard for Seaboard
  2012-04-17 19:01 [U-Boot] [PATCH v4 0/10] tegra: Enable keyboard with matrix keyboard driver Simon Glass
                   ` (8 preceding siblings ...)
  2012-04-17 19:01 ` [U-Boot] [PATCH v4 09/10] tegra: Switch on console mux and use environment for console Simon Glass
@ 2012-04-17 19:01 ` Simon Glass
  2012-04-20 23:57   ` Allen Martin
  2012-04-23 21:12   ` Stephen Warren
  9 siblings, 2 replies; 24+ messages in thread
From: Simon Glass @ 2012-04-17 19:01 UTC (permalink / raw)
  To: u-boot

This enables the standard keyboard on Seaboard.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 include/configs/seaboard.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/include/configs/seaboard.h b/include/configs/seaboard.h
index 3306622..1ee7e12 100644
--- a/include/configs/seaboard.h
+++ b/include/configs/seaboard.h
@@ -114,4 +114,13 @@
 
 /* Somewhat oddly, the NAND base address must be a config option */
 #define CONFIG_SYS_NAND_BASE	TEGRA2_NAND_BASE
+
+/* Enable keyboard */
+#define CONFIG_TEGRA2_KEYBOARD
+#define CONFIG_KEYBOARD
+
+#undef TEGRA2_DEVICE_SETTINGS
+#define TEGRA2_DEVICE_SETTINGS	"stdin=serial,tegra-kbc\0" \
+					"stdout=serial\0" \
+					"stderr=serial\0"
 #endif /* __CONFIG_H */
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [U-Boot] [PATCH v4 10/10] tegra: Enable keyboard for Seaboard
  2012-04-17 19:01 ` [U-Boot] [PATCH v4 10/10] tegra: Enable keyboard for Seaboard Simon Glass
@ 2012-04-20 23:57   ` Allen Martin
  2012-04-21  1:17     ` Simon Glass
  2012-04-23 21:12   ` Stephen Warren
  1 sibling, 1 reply; 24+ messages in thread
From: Allen Martin @ 2012-04-20 23:57 UTC (permalink / raw)
  To: u-boot

On Tue, Apr 17, 2012 at 12:01:37PM -0700, Simon Glass wrote:
> This enables the standard keyboard on Seaboard.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> 
>  include/configs/seaboard.h |    9 +++++++++
>  1 files changed, 9 insertions(+), 0 deletions(-)
> 
> diff --git a/include/configs/seaboard.h b/include/configs/seaboard.h
> index 3306622..1ee7e12 100644
> --- a/include/configs/seaboard.h
> +++ b/include/configs/seaboard.h
> @@ -114,4 +114,13 @@
>  
>  /* Somewhat oddly, the NAND base address must be a config option */
>  #define CONFIG_SYS_NAND_BASE	TEGRA2_NAND_BASE
> +
> +/* Enable keyboard */
> +#define CONFIG_TEGRA2_KEYBOARD
> +#define CONFIG_KEYBOARD
> +
> +#undef TEGRA2_DEVICE_SETTINGS
> +#define TEGRA2_DEVICE_SETTINGS	"stdin=serial,tegra-kbc\0" \

"usbkbd" would be nice for the springbank version of seaboard,
although that requires CONFIG_USB_KEYBOARD and
CONFIG_SYS_USB_EVENT_POLL as well, so maybe I should just post a
separate patch.

-Allen
-- 
nvpublic

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [U-Boot] [PATCH v4 10/10] tegra: Enable keyboard for Seaboard
  2012-04-20 23:57   ` Allen Martin
@ 2012-04-21  1:17     ` Simon Glass
  0 siblings, 0 replies; 24+ messages in thread
From: Simon Glass @ 2012-04-21  1:17 UTC (permalink / raw)
  To: u-boot

Hi Allen,

On Fri, Apr 20, 2012 at 4:57 PM, Allen Martin <amartin@nvidia.com> wrote:
> On Tue, Apr 17, 2012 at 12:01:37PM -0700, Simon Glass wrote:
>> This enables the standard keyboard on Seaboard.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>
>> ?include/configs/seaboard.h | ? ?9 +++++++++
>> ?1 files changed, 9 insertions(+), 0 deletions(-)
>>
>> diff --git a/include/configs/seaboard.h b/include/configs/seaboard.h
>> index 3306622..1ee7e12 100644
>> --- a/include/configs/seaboard.h
>> +++ b/include/configs/seaboard.h
>> @@ -114,4 +114,13 @@
>>
>> ?/* Somewhat oddly, the NAND base address must be a config option */
>> ?#define CONFIG_SYS_NAND_BASE TEGRA2_NAND_BASE
>> +
>> +/* Enable keyboard */
>> +#define CONFIG_TEGRA2_KEYBOARD
>> +#define CONFIG_KEYBOARD
>> +
>> +#undef TEGRA2_DEVICE_SETTINGS
>> +#define TEGRA2_DEVICE_SETTINGS ? ? ? "stdin=serial,tegra-kbc\0" \
>
> "usbkbd" would be nice for the springbank version of seaboard,
> although that requires CONFIG_USB_KEYBOARD and
> CONFIG_SYS_USB_EVENT_POLL as well, so maybe I should just post a
> separate patch.

Sounds good.

Regards,
Simon

>
> -Allen
> --
> nvpublic

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [U-Boot] [PATCH v4 05/10] tegra: Add keyboard support to funcmux
  2012-04-17 19:01 ` [U-Boot] [PATCH v4 05/10] tegra: Add keyboard support to funcmux Simon Glass
@ 2012-04-23 20:56   ` Stephen Warren
  0 siblings, 0 replies; 24+ messages in thread
From: Stephen Warren @ 2012-04-23 20:56 UTC (permalink / raw)
  To: u-boot

On 04/17/2012 01:01 PM, Simon Glass wrote:
> Add funcmux support for the default keyboard mapping.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Acked-by: Stephen Warren <swarren@wwwdotorg.org>

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 06/10] tegra: fdt: Add keyboard controller definition
  2012-04-17 19:01   ` [U-Boot] " Simon Glass
@ 2012-04-23 20:57     ` Stephen Warren
  -1 siblings, 0 replies; 24+ messages in thread
From: Stephen Warren @ 2012-04-23 20:57 UTC (permalink / raw)
  To: Simon Glass
  Cc: Anton Staff, Devicetree Discuss, U-Boot Mailing List,
	Jerry Van Baren, Tom Warren

On 04/17/2012 01:01 PM, Simon Glass wrote:
> From: Anton Staff <robotboy@chromium.org>
> 
> The Tegra keyboard controller provides a simple interface to a matrix
> keyboard.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Acked-by: Stephen Warren <swarren@wwwdotorg.org>

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [U-Boot] [PATCH v4 06/10] tegra: fdt: Add keyboard controller definition
@ 2012-04-23 20:57     ` Stephen Warren
  0 siblings, 0 replies; 24+ messages in thread
From: Stephen Warren @ 2012-04-23 20:57 UTC (permalink / raw)
  To: u-boot

On 04/17/2012 01:01 PM, Simon Glass wrote:
> From: Anton Staff <robotboy@chromium.org>
> 
> The Tegra keyboard controller provides a simple interface to a matrix
> keyboard.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Acked-by: Stephen Warren <swarren@wwwdotorg.org>

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v4 07/10] tegra: fdt: Add keyboard definitions for Seaboard
  2012-04-17 19:01     ` [U-Boot] " Simon Glass
@ 2012-04-23 20:59       ` Stephen Warren
  -1 siblings, 0 replies; 24+ messages in thread
From: Stephen Warren @ 2012-04-23 20:59 UTC (permalink / raw)
  To: Simon Glass
  Cc: Anton Staff, Devicetree Discuss, U-Boot Mailing List,
	Jerry Van Baren, Tom Warren

On 04/17/2012 01:01 PM, Simon Glass wrote:
> From: Anton Staff <robotboy@chromium.org>
> 
> Seaboard uses a QUERTY keyboard. We add key codes for this to

Q*W*ERTY?

Do you want to add the nvidia,ghost-filter property so that ghost
filtering is enabled? See the Tegra KBC binding documentation in the
kernel (which I don't see included in these patches for reference)
Documentation/devicetree/bindings/input/tegra-kbc.txt.

Otherwise,
Acked-by: Stephen Warren <swarren@wwwdotorg.org>

(note: I didn't actually validate any of the content of the keymap)

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [U-Boot] [PATCH v4 07/10] tegra: fdt: Add keyboard definitions for Seaboard
@ 2012-04-23 20:59       ` Stephen Warren
  0 siblings, 0 replies; 24+ messages in thread
From: Stephen Warren @ 2012-04-23 20:59 UTC (permalink / raw)
  To: u-boot

On 04/17/2012 01:01 PM, Simon Glass wrote:
> From: Anton Staff <robotboy@chromium.org>
> 
> Seaboard uses a QUERTY keyboard. We add key codes for this to

Q*W*ERTY?

Do you want to add the nvidia,ghost-filter property so that ghost
filtering is enabled? See the Tegra KBC binding documentation in the
kernel (which I don't see included in these patches for reference)
Documentation/devicetree/bindings/input/tegra-kbc.txt.

Otherwise,
Acked-by: Stephen Warren <swarren@wwwdotorg.org>

(note: I didn't actually validate any of the content of the keymap)

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [U-Boot] [PATCH v4 08/10] tegra: Add tegra keyboard driver
  2012-04-17 19:01 ` [U-Boot] [PATCH v4 08/10] tegra: Add tegra keyboard driver Simon Glass
@ 2012-04-23 21:07   ` Stephen Warren
  0 siblings, 0 replies; 24+ messages in thread
From: Stephen Warren @ 2012-04-23 21:07 UTC (permalink / raw)
  To: u-boot

On 04/17/2012 01:01 PM, Simon Glass wrote:
> Add support for internal matrix keyboard controller for Nvidia Tegra
> platforms. This driver uses the fdt decode function to obtain its key
> codes.

> +	KBC_REPEAT_RATE_MS	= 30,
> +	KBC_REPEAT_DELAY_MS	= 240,

At least the repeat delay is in device tree, and perhaps repeat rate
should be added to it?

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [U-Boot] [PATCH v4 09/10] tegra: Switch on console mux and use environment for console
  2012-04-17 19:01 ` [U-Boot] [PATCH v4 09/10] tegra: Switch on console mux and use environment for console Simon Glass
@ 2012-04-23 21:10   ` Stephen Warren
  0 siblings, 0 replies; 24+ messages in thread
From: Stephen Warren @ 2012-04-23 21:10 UTC (permalink / raw)
  To: u-boot

On 04/17/2012 01:01 PM, Simon Glass wrote:
> All tegra boards will use these options by default.

Well, there are certainly Tegra boards without matrix keyboards, so I'm
not entirely sure that's actually true...

That said, I don't see a real problem with the generic mainline U-Boot
assuming this will be true (people using it in products can always
adjust their config as they see fit)

So,
Acked-by: Stephen Warren <swarren@wwwdotorg.org>

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [U-Boot] [PATCH v4 10/10] tegra: Enable keyboard for Seaboard
  2012-04-17 19:01 ` [U-Boot] [PATCH v4 10/10] tegra: Enable keyboard for Seaboard Simon Glass
  2012-04-20 23:57   ` Allen Martin
@ 2012-04-23 21:12   ` Stephen Warren
  1 sibling, 0 replies; 24+ messages in thread
From: Stephen Warren @ 2012-04-23 21:12 UTC (permalink / raw)
  To: u-boot

On 04/17/2012 01:01 PM, Simon Glass wrote:
> This enables the standard keyboard on Seaboard.

Hmmm. I wonder what this patch will do to the Springbank variant of
Seaboard, which actually contains a USB keyboard rather than a Tegra KBC
keyboard? It looks like the relevant pins on Tegra are simply not
connected, so coupled with the pull-up in the KBC's funcmux setting,
this should work out OK; the keyboard will just appear idle.

So,
Acked-by: Stephen Warren <swarren@wwwdotorg.org>

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2012-04-23 21:12 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-17 19:01 [U-Boot] [PATCH v4 0/10] tegra: Enable keyboard with matrix keyboard driver Simon Glass
2012-04-17 19:01 ` [PATCH v4 01/10] fdt: Add fdtdec functions to read byte array Simon Glass
2012-04-17 19:01   ` [U-Boot] " Simon Glass
2012-04-17 19:01 ` [U-Boot] [PATCH v4 02/10] input: Add linux/input.h for key code support Simon Glass
2012-04-17 19:01 ` [U-Boot] [PATCH v4 03/10] input: Add generic keyboard input handler Simon Glass
2012-04-17 19:01 ` [U-Boot] [PATCH v4 04/10] input: Add support for keyboard matrix decoding from an fdt Simon Glass
2012-04-17 19:01 ` [U-Boot] [PATCH v4 05/10] tegra: Add keyboard support to funcmux Simon Glass
2012-04-23 20:56   ` Stephen Warren
2012-04-17 19:01 ` [PATCH v4 06/10] tegra: fdt: Add keyboard controller definition Simon Glass
2012-04-17 19:01   ` [U-Boot] " Simon Glass
2012-04-23 20:57   ` Stephen Warren
2012-04-23 20:57     ` [U-Boot] " Stephen Warren
     [not found] ` <1334689297-13489-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2012-04-17 19:01   ` [PATCH v4 07/10] tegra: fdt: Add keyboard definitions for Seaboard Simon Glass
2012-04-17 19:01     ` [U-Boot] " Simon Glass
2012-04-23 20:59     ` Stephen Warren
2012-04-23 20:59       ` [U-Boot] " Stephen Warren
2012-04-17 19:01 ` [U-Boot] [PATCH v4 08/10] tegra: Add tegra keyboard driver Simon Glass
2012-04-23 21:07   ` Stephen Warren
2012-04-17 19:01 ` [U-Boot] [PATCH v4 09/10] tegra: Switch on console mux and use environment for console Simon Glass
2012-04-23 21:10   ` Stephen Warren
2012-04-17 19:01 ` [U-Boot] [PATCH v4 10/10] tegra: Enable keyboard for Seaboard Simon Glass
2012-04-20 23:57   ` Allen Martin
2012-04-21  1:17     ` Simon Glass
2012-04-23 21:12   ` Stephen Warren

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.