Signed-off-by: Andrey Danin <danind...@mail.ru> --- drivers/input/Makefile | 1 + drivers/input/tegra-nvec-kbc.c | 131 +++++++++++++++++++++++++++++++++++ include/configs/tegra-common-post.h | 2 + 3 files changed, 134 insertions(+), 0 deletions(-) create mode 100644 drivers/input/tegra-nvec-kbc.c
diff --git a/drivers/input/Makefile b/drivers/input/Makefile index 0805e86..20ef7b2 100644 --- a/drivers/input/Makefile +++ b/drivers/input/Makefile @@ -27,6 +27,7 @@ LIB := $(obj)libinput.o COBJS-$(CONFIG_I8042_KBD) += i8042.o COBJS-$(CONFIG_TEGRA_KEYBOARD) += tegra-kbc.o +COBJS-$(CONFIG_TEGRA_NVEC_KEYBOARD) += tegra-nvec-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-nvec-kbc.c b/drivers/input/tegra-nvec-kbc.c new file mode 100644 index 0000000..2799492 --- /dev/null +++ b/drivers/input/tegra-nvec-kbc.c @@ -0,0 +1,131 @@ +/* + * (C) Copyright 2011,2013 + * Andrey Danin <danind...@mail.ru> + * 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 <input.h> +#include <asm/arch-tegra/tegra_nvec_events.h> +#include <asm/arch-tegra/tegra_nvec_keyboard.h> + +enum { + KBC_MAX_KPENT = 8, +}; + +/* keyboard config/state */ +static struct keyb { + struct input_config input; /* The input layer */ +} config; + + +/** + * Check the tegra nvec 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_nvec_kbc_check(struct input_config *input) +{ + int res = 0; + int fifo[KBC_MAX_KPENT]; + int cnt = 0; + + if (!nvec_have_keys()) + nvec_read_events(); + + while (nvec_have_keys() && cnt < KBC_MAX_KPENT) { + res = 1; + fifo[cnt++] = nvec_pop_key(); + if (cnt == KBC_MAX_KPENT) { + input_send_keycodes(input, fifo, cnt); + cnt = 0; + } + } + + if (cnt > 0) + input_send_keycodes(input, fifo, cnt); + + return res; +} + +/** + * 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); +} + + +int drv_keyboard_init(void) +{ + struct stdio_dev dev; + char *stdinname = getenv("stdin"); + int error; + + if (input_init(&config.input, 0)) { + printf("nvec kbc: cannot set up input\n"); + return -1; + } + config.input.read_keys = tegra_nvec_kbc_check; + + memset(&dev, '\0', sizeof(dev)); + strcpy(dev.name, "tegra-nvec-kbc"); + dev.flags = DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM; + dev.getc = kbd_getc; + dev.tstc = kbd_tstc; + + /* Register the device. init_tegra_keyboard() will be called soon */ + error = input_stdio_register(&dev); + if (error) { + printf("nvec kbc: failed to register stdio device, %d\n", + error); + return error; + } +#ifdef CONFIG_CONSOLE_MUX + error = iomux_doenv(stdin, stdinname); + if (error) { + printf("nvec kbc: iomux_doenv failed, %d\n", error); + return error; + } +#endif + return 0; +} diff --git a/include/configs/tegra-common-post.h b/include/configs/tegra-common-post.h index 6ed2fde..b01a072 100644 --- a/include/configs/tegra-common-post.h +++ b/include/configs/tegra-common-post.h @@ -121,6 +121,8 @@ #ifdef CONFIG_TEGRA_KEYBOARD #define STDIN_KBD_KBC ",tegra-kbc" +#elif defined(CONFIG_TEGRA_NVEC_KEYBOARD) +#define STDIN_KBD_KBC ",tegra-nvec-kbc" #else #define STDIN_KBD_KBC "" #endif -- 1.7.1 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot