Skip to contentSkip to conversation

tegra: Enable keyboard with matrix keyboard driver

PATCH Superseded Simon Glass 4 participants 19 messages Apr 17, 2012 – Apr 23, 2012 1 message not in the archive

Subsystems (4)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v4 cover tegra: Enable keyboard with matrix keyboard driver

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
Signature · 1 line
1.7.7.3
#1 lore raw

PATCH v4 1/10 fdt: Add fdtdec functions to read byte array

From: Anton Staff <[email protected]>

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.

---
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(-)
include/fdtdec.h +32 -0
index 7bae2f8..5140f4a 100644
@@ -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);
lib/fdtdec.c +24 -0
index 2eb5b41..585dd6d 100644
@@ -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;
+}
Signature · 1 line
1.7.7.3
#2 lore raw

PATCH v4 2/10 input: Add linux/input.h for key code support

In reply to Simon Glass

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

---
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
include/linux/input.h new file +155 -0
new file mode 100644
index 0000000..44aec76
@@ -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
Signature · 1 line
1.7.7.3
#3 lore raw

PATCH v4 3/10 input: Add generic keyboard input handler

In reply to Simon Glass

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.

---
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
drivers/input/Makefile +1 -0
index 1f4dad3..d06acb9 100644
@@ -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)
drivers/input/input.c new file +429 -0

429 lines not on this page · raw message

include/input.h new file +145 -0

145 lines not on this page · raw message

Signature · 1 line
1.7.7.3
#4 lore raw

PATCH v4 4/10 input: Add support for keyboard matrix decoding from an fdt

In reply to Simon Glass

From: Bernie Thompson <[email protected]>

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.

---
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
drivers/input/Makefile +1 -0
index d06acb9..b8d8623 100644
@@ -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)
drivers/input/key_matrix.c new file +208 -0

208 lines not on this page · raw message

include/key_matrix.h new file +99 -0

99 lines not on this page · raw message

Signature · 1 line
1.7.7.3
#5 lore raw

PATCH v4 5/10 tegra: Add keyboard support to funcmux

In reply to Simon Glass

Add funcmux support for the default keyboard mapping.

---
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(-)
arch/arm/cpu/armv7/tegra2/funcmux.c +16 -0
index 8931d5e..53e85ff 100644
@@ -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;
Signature · 1 line
1.7.7.3
#7 lore raw

PATCH v4 6/10 tegra: fdt: Add keyboard controller definition

In reply to Simon Glass

From: Anton Staff <[email protected]>

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

---

 arch/arm/dts/tegra20.dtsi |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
arch/arm/dts/tegra20.dtsi +5 -0
index 018a3c8..5d214f2 100644
@@ -206,4 +206,9 @@
 		compatible = "nvidia,tegra20-nand";
 		reg = <0x70008000 0x100>;
 	};
+
+	kbc@7000e200 {
+		compatible = "nvidia,tegra20-kbc";
+		reg = <0x7000e200 0x0078>;
+	};
 };
Signature · 1 line
1.7.7.3

A message that is not in the archive (sent off-list or not yet received): 1334689297-13489-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org

#10 lore raw

PATCH v4 7/10 tegra: fdt: Add keyboard definitions for Seaboard

From: Anton Staff <[email protected]>

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

---
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(-)
board/nvidia/dts/tegra2-seaboard.dts +27 -0
index 72a5f5d..db72ef2 100644
@@ -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>;
+	};
 };
Signature · 1 line
1.7.7.3
Acked-by on v4 7/10
#11 lore raw

Re: [PATCH v4 07/10] tegra: fdt: Add keyboard definitions for Seaboard

Quoted 3 lines · Simon Glass

From: Anton Staff <[email protected]>

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,

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

#12 lore raw

PATCH v4 8/10 tegra: Add tegra keyboard driver

In reply to Simon Glass

From: Rakesh Iyer <[email protected]>

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 <[email protected]> and Simon Glass <[email protected]> for device tree, input layer, key matrix and various other things.

---
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
drivers/input/Makefile +1 -0
index b8d8623..8b51dff 100644
@@ -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
drivers/input/tegra-kbc.c new file +375 -0

375 lines not on this page · raw message

include/fdtdec.h +1 -0
index 5140f4a..2286958 100644
@@ -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,
 };
include/tegra-kbc.h new file +33 -0
new file mode 100644
index 0000000..f331c79
@@ -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__ */
lib/fdtdec.c +1 -0
index 585dd6d..3005134 100644
@@ -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)
Signature · 1 line
1.7.7.3
#13 lore raw

PATCH v4 8/10 tegra: Add tegra keyboard driver

drivers/input/tegra-kbc.c line 54

Quoted 6 lines · Simon Glass

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

drivers/input/tegra-kbc.c new file +2 -0
+	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?

#14 lore raw

PATCH v4 9/10 tegra: Switch on console mux and use environment for console

In reply to Simon Glass

All tegra boards will use these options by default.

---

 include/configs/tegra2-common.h |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
include/configs/tegra2-common.h +8 -1
index c5870dd..068ce88 100644
@@ -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 */
Signature · 1 line
1.7.7.3
#15 lore raw

PATCH v4 9/10 tegra: Switch on console mux and use environment for console

Quoted 1 line · Simon Glass

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,

#16 lore raw

PATCH v4 10/10 tegra: Enable keyboard for Seaboard

In reply to Simon Glass

This enables the standard keyboard on Seaboard.

---

 include/configs/seaboard.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
include/configs/seaboard.h +9 -0
index 3306622..1ee7e12 100644
@@ -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 */
Signature · 1 line
1.7.7.3
#17 lore raw

PATCH v4 10/10 tegra: Enable keyboard for Seaboard

Quoted 13 lines · Simon Glass

This enables the standard keyboard on Seaboard.

---

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

include/configs/seaboard.h line 123

Quoted 10 lines
include/configs/seaboard.h +7 -0
@@ -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

Signature · 1 line
nvpublic
#18 lore raw

PATCH v4 10/10 tegra: Enable keyboard for Seaboard

Hi Allen,

Quoted 15 lines · Allen Martin
Quoted 14 lines · Simon Glass

This enables the standard keyboard on Seaboard.

---

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

include/configs/seaboard.h +0 -0
index 3306622..1ee7e12 100644
@@ -114,4 +114,13 @@
 
Quoted 14 lines

include/configs/seaboard.h

Quoted 9 lines

?/* Somewhat oddly, the NAND base address must be a config option */ ?#define CONFIG_SYS_NAND_BASE TEGRA2_NAND_BASE

include/configs/seaboard.h +7 -0
+
+/* 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

Quoted 4 lines

-Allen
--
nvpublic

#19 lore raw

PATCH v4 10/10 tegra: Enable keyboard for Seaboard

In reply to Simon Glass
Quoted 1 line · Simon Glass

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,