Skip to contentSkip to conversation

tegra: Enable keyboard with matrix keyboard driver

PATCH Superseded Simon Glass 5 participants 16 messages Jan 17, 2012 – Jan 20, 2012 3 messages not in the archive

Subsystems (4)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v3 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 hot-off-the press Tegra 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.

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()

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

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               |    2 +
 drivers/input/input.c                |  410 ++++++++++++++++++++++++++
 drivers/input/tegra-kbc.c            |  536 ++++++++++++++++++++++++++++++++++
 include/configs/seaboard.h           |    9 +
 include/configs/tegra2-common.h      |    9 +-
 include/fdtdec.h                     |   33 ++
 include/input.h                      |  140 +++++++++
 include/linux/input.h                |  155 ++++++++++
 include/tegra-kbc.h                  |   33 ++
 lib/fdtdec.c                         |   25 ++
 13 files changed, 1399 insertions(+), 1 deletions(-)
 create mode 100644 drivers/input/input.c
 create mode 100644 drivers/input/tegra-kbc.c
 create mode 100644 include/input.h
 create mode 100644 include/linux/input.h
 create mode 100644 include/tegra-kbc.h
Signature · 1 line
1.7.7.3

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

#2 lore raw

PATCH v3 1/9 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 64e2f88..9fd4e38 100644
@@ -325,3 +325,35 @@ int fdtdec_setup_gpio(struct fdt_gpio_state *gpio);
  * @return
  */
 int fdtdec_decode_periph_id(const void *blob, int node);
+
+/*
+ * 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 db377c7..140310d 100644
@@ -462,3 +462,27 @@ int fdtdec_decode_periph_id(const void *blob, int node)
 
 	return cell[1];
 }
+
+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
#3 lore raw

Re: [PATCH v3 1/9] fdt: Add fdtdec functions to read byte array

Quoted 7 lines · On Tuesday 17 January 2012 01:11:14 Simon Glass wrote:

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.

seems like getting s-o-b from Anton should be fairly easy ;)

(there's a few other patches in this series with that problem) -mike

_______________________________________________
U-Boot mailing list
[email protected]
http://lists.denx.de/mailman/listinfo/u-boot

A message that is not in the archive (sent off-list or not yet received): 201201170130.48257.vapier-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org

#5 lore raw

Re: [PATCH v3 1/9] fdt: Add fdtdec functions to read byte array

Hi Mike,

Quoted 11 lines · Mike Frysinger
Quoted 7 lines · On Tuesday 17 January 2012 01:11:14 Simon Glass wrote:

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.

seems like getting s-o-b from Anton should be fairly easy ;)

I have the jellybeans ready. I will make a list of those I need - it is a pretty long list now. Does patchwork pick it up automatically if they reply to the list?

Regards,
Simon

Quoted 2 lines

(there's a few other patches in this series with that problem) -mike

#6 lore raw

Re: [PATCH v3 1/9] fdt: Add fdtdec functions to read byte array

Quoted 8 lines · On Tuesday 17 January 2012 02:11:58 Simon Glass wrote:
Quoted 7 lines · Mike Frysinger
Quoted 6 lines · On Tuesday 17 January 2012 01:11:14 Simon Glass wrote:

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.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

seems like getting s-o-b from Anton should be fairly easy ;)

I have the jellybeans ready. I will make a list of those I need - it is a pretty long list now. Does patchwork pick it up automatically if they reply to the list?

i believe it does if they reply to the patch in question. at least, it should be easy to check (have him reply and then d/l it via patchwork). -mike

_______________________________________________
U-Boot mailing list
[email protected]
http://lists.denx.de/mailman/listinfo/u-boot

#7 lore raw

PATCH v3 5/9 tegra: fdt: Add keyboard controller definition

In reply to a message not in the archive

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 33d6972..3d435aa 100644
@@ -216,4 +216,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): 1326780682-10260-6-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org

#9 lore raw

Re: [PATCH v3 5/9] tegra: fdt: Add keyboard controller definition

arch/arm/dts/tegra20.dtsi line 223

Quoted 11 lines · Simon Glass

From: Anton Staff <[email protected]>

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

arch/arm/dts/tegra20.dtsi +4 -0
 
+	kbc@7000e200 {
+		compatible = "nvidia,tegra20-kbc";
+		reg = <0x7000e200 0x0078>;
+	};

The KBC has interrupts to, which should be added to the .dtsi even if you don't use them.

I think you want:

interrupts = <0 85 0x04>;

Signature · 1 line
nvpublic
#10 lore raw

PATCH v3 6/9 tegra: fdt: Add keyboard definitions for Seaboard

In reply to a message not in the archive

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 cc9abe2..a720992 100644
@@ -140,4 +140,31 @@
 			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
#11 lore raw

PATCH v3 2/9 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
#12 lore raw

PATCH v3 3/9 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

 drivers/input/Makefile |    1 +
 drivers/input/input.c  |  410 ++++++++++++++++++++++++++++++++++++++++++++++++
 include/input.h        |  140 ++++++++++++++++
 3 files changed, 551 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 +410 -0

410 lines not on this page · raw message

include/input.h new file +140 -0

140 lines not on this page · raw message

Signature · 1 line
1.7.7.3
#13 lore raw

PATCH v3 4/9 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 f84ec74..a5ff890 100644
@@ -163,6 +163,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
#14 lore raw

PATCH v3 4/9 tegra: Add keyboard support to funcmux

Quoted 7 lines · Simon Glass

Add funcmux support for the default keyboard mapping.

arch/arm/cpu/armv7/tegra2/funcmux.c +1 -0
 
+	case PERIPH_ID_KBC:

arch/arm/cpu/armv7/tegra2/funcmux.c int funcmux_select(enum periph_id id, int config) · line 176

Quoted 10 lines
arch/arm/cpu/armv7/tegra2/funcmux.c +10 -0
+		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);

Don't you only want to pull up the rows (or the columns) not both? I guess it won't hurt to do both, but it's probably wasting power.

Signature · 1 line
nvpublic
#15 lore raw

PATCH v3 7/9 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 intent is to make this driver purely about dealing with the hardware and converting its key matrix into key codes.

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

Modified by Simon Glass <[email protected]> for device tree, input layer 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()

 drivers/input/Makefile    |    1 +
 drivers/input/tegra-kbc.c |  536 +++++++++++++++++++++++++++++++++++++++++++++
 include/fdtdec.h          |    1 +
 include/tegra-kbc.h       |   33 +++
 lib/fdtdec.c              |    1 +
 5 files changed, 572 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/tegra-kbc.c
 create mode 100644 include/tegra-kbc.h
drivers/input/Makefile +1 -0
index d06acb9..798a2ad 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 +536 -0

536 lines not on this page · raw message

include/fdtdec.h +1 -0
index 9fd4e38..e705124 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..7803f10
@@ -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_cnt;
+	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 140310d..48abf02 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
#16 lore raw

PATCH v3 7/9 tegra: Add tegra keyboard driver

Quoted 4 lines · 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.

...

Quoted 1 line

+static uchar *create_keymap(u32 *data, int len, int map_keycode, int *pos)

...

drivers/input/tegra-kbc.c line 410

Quoted 2 lines
drivers/input/tegra-kbc.c new file +2 -0
+               entry = row * KBC_MAX_COL + col;
+               map[entry] = key_code;

This needs to be range-checked.

Quoted 8 lines
drivers/input/tegra-kbc.c new file +7 -0
+               if (pos && map_keycode == key_code)
+                       *pos = entry;
+       }
+
+       return map;
+}
 
+static int fdt_decode_kbc(const void *blob, int node, struct keyb *config)

...

drivers/input/tegra-kbc.c line 450

Quoted 5 lines
drivers/input/tegra-kbc.c new file +5 -0
+               /* 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;

"linux," not "l,". Why not just strcmp against the two values simply and directly; the above matches against totally bogus stuff like "l,bogus-cruft-keymap".

drivers/input/tegra-kbc.c line 452

Quoted 2 lines
drivers/input/tegra-kbc.c new file +2 -0
+
+               len -= 8;

No need for that right?

Quoted 1 line

+static int init_tegra_keyboard(void)

...

drivers/input/tegra-kbc.c line 500

Quoted 5 lines
drivers/input/tegra-kbc.c new file +5 -0
+       if (config.fn_keycode) {
+               if (input_add_table(&config.input, KEY_FN, -1,
+                                       config.fn_keycode, KBC_KEY_COUNT))
+                       return -1;
+       }

I don't see anywhere that calls input_add_table() for config.plain_keycode.

drivers/input/tegra-kbc.c line 525

Quoted 9 lines
drivers/input/tegra-kbc.c new file +9 -0
+int drv_keyboard_init(void)
+{
+       struct stdio_dev dev;
+
+       if (input_init(&config.input, 0)) {
+               debug("%s: Cannot set up input\n", __func__);
+               return -1;
+       }
+       config.input.read_keys = tegra_kbc_check;

Don't you want to set up config.input.* before passing it to input_init() which might in theory use it?

include/tegra-kbc.h

Quoted 3 lines
include/tegra-kbc.h +1 -0
 
+#define KEY_IS_MODIFIER(key) ((key) >= KEY_FIRST_MODIFIER)

Shouldn't that be in the input layer or the file that defines the key codes?

Signature · 1 line
nvpublic
#17 lore raw

PATCH v3 8/9 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 6c38f51..97ac6cd 100644
@@ -133,11 +133,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
#18 lore raw

PATCH v3 9/9 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 b31ac0c..d2d0115 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