]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - drivers/input/tegra-kbc.c
Merge branch 'master' of git://git.denx.de/u-boot-usb
[people/ms/u-boot.git] / drivers / input / tegra-kbc.c
index f164791bee6128fcf0b3bce5ec55cfb1db916ee6..0ef94f7a00bb26c72bfb2d07b60f63dc9030d77b 100644 (file)
@@ -2,23 +2,7 @@
  *  (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
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
@@ -30,7 +14,7 @@
 #include <asm/io.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/funcmux.h>
-#include <asm/arch/timer.h>
+#include <asm/arch-tegra/timer.h>
 #include <linux/input.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -63,6 +47,7 @@ static struct keyb {
        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 */
+       unsigned char created;          /* 1 if driver has been created */
 
        /*
         * After init we must wait a short time before polling the keyboard.
@@ -196,7 +181,7 @@ static void kbd_wait_for_fifo_init(struct keyb *config)
  * @param input                Input configuration
  * @return 1, to indicate that we have something to look at
  */
-int tegra_kbc_check(struct input_config *input)
+static int tegra_kbc_check(struct input_config *input)
 {
        kbd_wait_for_fifo_init(&config);
        check_for_keys(&config);
@@ -209,7 +194,7 @@ int tegra_kbc_check(struct input_config *input)
  *
  * @return 0 if no keys available, 1 if keys are available
  */
-static int kbd_tstc(void)
+static int kbd_tstc(struct stdio_dev *dev)
 {
        /* Just get input to do this for us */
        return input_tstc(&config.input);
@@ -222,7 +207,7 @@ static int kbd_tstc(void)
  *
  * @return ASCII key code, or 0 if no key, or -1 if error
  */
-static int kbd_getc(void)
+static int kbd_getc(struct stdio_dev *dev)
 {
        /* Just get input to do this for us */
        return input_getc(&config.input);
@@ -304,8 +289,12 @@ static void tegra_kbc_open(void)
  *
  * @return 0 if ok, -ve on error
  */
-static int init_tegra_keyboard(void)
+static int init_tegra_keyboard(struct stdio_dev *dev)
 {
+       /* check if already created */
+       if (config.created)
+               return 0;
+
 #ifdef CONFIG_OF_CONTROL
        int     node;
 
@@ -321,9 +310,11 @@ static int init_tegra_keyboard(void)
                debug("%s: No keyboard register found\n", __func__);
                return -1;
        }
+       input_set_delays(&config.input, KBC_REPEAT_DELAY_MS,
+                       KBC_REPEAT_RATE_MS);
 
        /* Decode the keyboard matrix information (16 rows, 8 columns) */
-       if (key_matrix_init(&config.matrix, 16, 8)) {
+       if (key_matrix_init(&config.matrix, 16, 8, 1)) {
                debug("%s: Could not init key matrix\n", __func__);
                return -1;
        }
@@ -347,6 +338,7 @@ static int init_tegra_keyboard(void)
        config_kbc_gpio(config.kbc);
 
        tegra_kbc_open();
+       config.created = 1;
        debug("%s: Tegra keyboard ready\n", __func__);
 
        return 0;
@@ -355,9 +347,10 @@ static int init_tegra_keyboard(void)
 int drv_keyboard_init(void)
 {
        struct stdio_dev dev;
+       char *stdinname = getenv("stdin");
+       int error;
 
-       if (input_init(&config.input, 0, KBC_REPEAT_DELAY_MS,
-                       KBC_REPEAT_RATE_MS)) {
+       if (input_init(&config.input, 0)) {
                debug("%s: Cannot set up input\n", __func__);
                return -1;
        }
@@ -371,5 +364,13 @@ int drv_keyboard_init(void)
        dev.start = init_tegra_keyboard;
 
        /* Register the device. init_tegra_keyboard() will be called soon */
-       return input_stdio_register(&dev);
+       error = input_stdio_register(&dev);
+       if (error)
+               return error;
+#ifdef CONFIG_CONSOLE_MUX
+       error = iomux_doenv(stdin, stdinname);
+       if (error)
+               return error;
+#endif
+       return 0;
 }