summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorAnton Staaf <robotboy@chromium.org>2011-06-27 11:26:29 -0700
committerSimon Glass <sjg@chromium.org>2011-08-29 10:39:42 -0700
commitb8c589e180bbc16a92908303732eb362539e7a7a (patch)
tree0f62a0c8169a8d4992ef6ff15f498ecea51f985f /drivers
parentd92feb3dc8786fbc1d4f3cb0dfc71595c73bf90c (diff)
arm: Tegra: Add FDT support to keyboard driver
This makes the Tegra keyboard driver use the fdt decode function to obtain its key codes. Signed-off-by: Anton Staaf <robotboy@chromium.org> BUG=chromium-os:11623 TEST=boot U-Boot; type plain, shift and fn keys and check that the correct output results Change-Id: I103789b14ed22693dbc7bc3e162e0df5bdb5ad8c Reviewed-on: http://gerrit.chromium.org/gerrit/3255 Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rwxr-xr-xdrivers/input/tegra-kbc.c46
1 files changed, 35 insertions, 11 deletions
diff --git a/drivers/input/tegra-kbc.c b/drivers/input/tegra-kbc.c
index cb6fbcaec7f..db5bc289728 100755
--- a/drivers/input/tegra-kbc.c
+++ b/drivers/input/tegra-kbc.c
@@ -28,13 +28,16 @@
#include <asm/arch/clock.h>
#include <asm/arch/pinmux.h>
#include <tegra-kbc.h>
+#include <fdt_decode.h>
+
+DECLARE_GLOBAL_DATA_PTR;
#define DEVNAME "tegra-kbc"
-#define KBC_MAX_GPIO 24
-#define KBC_MAX_KPENT 8
-#define KBC_MAX_ROW 16
-#define KBC_MAX_COL 8
+enum {
+ KBC_MAX_GPIO = 24,
+ KBC_MAX_KPENT = 8,
+};
#define KBC_MAX_KEY (KBC_MAX_ROW * KBC_MAX_COL)
@@ -60,9 +63,15 @@
/* kbc globals */
unsigned int kbc_repoll_time;
int kbc_last_keypress;
-int *kbc_plain_keycode;
-int *kbc_fn_keycode;
-int *kbc_shift_keycode;
+
+/* These are key maps for each modifier: each has KBC_KEY_COUNT entries */
+u8 *kbc_plain_keycode;
+u8 *kbc_fn_keycode;
+u8 *kbc_shift_keycode;
+
+#ifdef CONFIG_OF_CONTROL
+struct fdt_kbc config; /* Our keyboard config */
+#endif
static int tegra_kbc_keycode(int r, int c, int modifier)
{
@@ -396,6 +405,25 @@ int drv_keyboard_init(void)
struct stdio_dev kbddev;
char *stdinname;
+#ifdef CONFIG_OF_CONTROL
+ int node;
+
+ node = fdt_decode_next_compatible(gd->blob, 0,
+ COMPAT_NVIDIA_TEGRA250_KBC);
+ if (node < 0)
+ return node;
+ if (fdt_decode_kbc(gd->blob, node, &config))
+ return -1;
+ assert(FDT_KBC_KEY_COUNT == KBC_KEY_COUNT);
+ kbc_plain_keycode = config.plain_keycode;
+ kbc_shift_keycode = config.shift_keycode;
+ kbc_fn_keycode = config.fn_keycode;
+#else
+ kbc_plain_keycode = board_keyboard_config.plain_keycode;
+ kbc_shift_keycode = board_keyboard_config.shift_keycode;
+ kbc_fn_keycode = board_keyboard_config.fn_keycode;
+#endif
+
config_kbc_pinmux();
/*
@@ -405,10 +433,6 @@ int drv_keyboard_init(void)
*/
clock_enable(PERIPH_ID_KBC);
- kbc_plain_keycode = board_keyboard_config.plain_keycode;
- kbc_shift_keycode = board_keyboard_config.shift_keycode;
- kbc_fn_keycode = board_keyboard_config.function_keycode;
-
stdinname = getenv("stdin");
memset(&kbddev, 0, sizeof(kbddev));
strcpy(kbddev.name, DEVNAME);