]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/input/tegra-kbc.c
dm: Add GPIO support and tests
[karo-tx-uboot.git] / drivers / input / tegra-kbc.c
index ab7a9e33ee0bf86e1539bc8e90a2b250d13c8f36..f137f930a9fb3c36d41a923730dabafc9fa3c8eb 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>
@@ -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.
@@ -306,6 +291,10 @@ static void tegra_kbc_open(void)
  */
 static int init_tegra_keyboard(void)
 {
+       /* check if already created */
+       if (config.created)
+               return 0;
+
 #ifdef CONFIG_OF_CONTROL
        int     node;
 
@@ -349,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;
@@ -357,6 +347,8 @@ 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)) {
                debug("%s: Cannot set up input\n", __func__);
@@ -372,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;
 }