All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 00/28] dm: input: Move keyboard drivers to driver model
@ 2015-09-09  4:32 Simon Glass
  2015-09-09  4:32 ` [U-Boot] [PATCH 01/28] dm: input: Create a keyboard uclass Simon Glass
                   ` (27 more replies)
  0 siblings, 28 replies; 60+ messages in thread
From: Simon Glass @ 2015-09-09  4:32 UTC (permalink / raw)
  To: u-boot

This series adds a new uclass for keyboards and converts some drivers
over to use it.

This series includes some work to remove code duplication in the keyboard
drivers by updating them to use the input library (input.c). This unifies
the keycode decoding logic in one place. In order to do this some
enhancements are needed to the input library and these are also included.

The cros_ec and tegra_kbc drivers are converted to use driver model.

The i8042 driver is converted also, after various tidy-ups. The driver has
some strange interactions with the cfb_console driver. This is removed in
this series which is possible because the only user is x86. Some i8042
features have been dropped (the only deliberate one is the flashing cursor
which does not seem to be used by any board).

Also the i8042 driver currently has its own keycode decoding logic. This
series removes it in favour of the input library. Therefore testing of this
new driver would be appreciated. So far I have only been able to test on
link, which does not have a full keyboard. Also, while German keyboard
support is implemented, I am unable to test that either.

These changes can be considered the first step towards moving stdio to
driver model. For that to be useful we need to convert LCD and video also.

Note: This series is missing the code to call the update_leds() method when
the LEDs change. This needs to be added to keyboard_tstc() and
keyboard_getc(). If someone is able to test this I can send a patch for that
also.


Simon Glass (28):
  dm: input: Create a keyboard uclass
  input: Add a device pointer to the input config
  input: Return -ENOSPC when there is not space
  input: Add the keycode translation tables separately
  cros_ec: Use udevice instead of cros_ec_dev for keyboard functions
  dm: stdio: Plumb in the new keyboard uclass
  dm: tegra: Convert keyboard driver to driver model
  dm: cros_ec: Convert cros_ec keyboard driver to driver model
  video: Drop unused console functions
  i8042: Use functions to handle register access
  i8042: Handle a duplicate power-on-reset response
  i8042: Adjust kbd_reset() to collect all failures
  i8042: Adjust keyboard init to assume success
  input: Correct keycode for Ctrl-Y
  input: Add a few more keyboard keycodes
  input: Add a function to add a keycode to the existing set
  input: Allow repeat filtering to be disabled
  input: Support the German keymap
  input: Adjust structure of code in process_modifier()
  input: Handle caps lock
  input: Allow updating of keyboard LEDs
  input: i8042: Convert to use the input library
  input: Add a Kconfig option for the i8042 keyboard
  x86: Add an i8042 device for boards that have it
  Drop CONFIG_ISA_KEYBOARD
  input: Convert i8042 to driver model
  video: input: Clean up after i8042 conversion
  input: Convert 'keyboard' driver to use input library

 README                           |  42 +--
 arch/arm/Kconfig                 |   1 +
 arch/arm/mach-tegra/Kconfig      |   1 +
 arch/sandbox/Kconfig             |   3 +
 arch/x86/Kconfig                 |   6 +
 arch/x86/dts/bayleybay.dts       |   1 +
 arch/x86/dts/chromebook_link.dts |   1 +
 arch/x86/dts/keyboard.dtsi       |   5 +
 board/kosagi/novena/novena.c     |   1 +
 board/mpl/pip405/README          |   4 -
 common/stdio.c                   |  31 +-
 common/usb_kbd.c                 |   6 -
 drivers/input/Kconfig            |  19 ++
 drivers/input/Makefile           |   4 +-
 drivers/input/cros_ec_keyb.c     | 147 ++++-----
 drivers/input/i8042.c            | 632 ++++++++++-----------------------------
 drivers/input/input.c            | 202 ++++++++++---
 drivers/input/keyboard-uclass.c  |  84 ++++++
 drivers/input/keyboard.c         | 290 +++---------------
 drivers/input/tegra-kbc.c        | 242 +++++++--------
 drivers/misc/cros_ec.c           |  14 +-
 drivers/video/cfb_console.c      |  82 +----
 include/configs/MIP405.h         |   5 -
 include/configs/MPC8536DS.h      |   1 -
 include/configs/MPC8544DS.h      |   1 -
 include/configs/MPC8572DS.h      |   1 -
 include/configs/MPC8641HPCN.h    |   1 -
 include/configs/PIP405.h         |   5 -
 include/configs/x86-chromebook.h |   2 +-
 include/configs/x86-common.h     |   2 +-
 include/cros_ec.h                |   4 +-
 include/fdtdec.h                 |   1 -
 include/i8042.h                  |   6 -
 include/input.h                  |  65 +++-
 include/keyboard.h               |  83 +++++
 lib/fdtdec.c                     |   1 -
 36 files changed, 866 insertions(+), 1130 deletions(-)
 create mode 100644 arch/x86/dts/keyboard.dtsi
 create mode 100644 drivers/input/keyboard-uclass.c

-- 
2.6.0.rc0.131.gf624c3d

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 01/28] dm: input: Create a keyboard uclass
  2015-09-09  4:32 [U-Boot] [PATCH 00/28] dm: input: Move keyboard drivers to driver model Simon Glass
@ 2015-09-09  4:32 ` Simon Glass
  2015-09-09 12:17   ` Marek Vasut
  2015-09-15  6:11   ` Bin Meng
  2015-09-09  4:32 ` [U-Boot] [PATCH 02/28] input: Add a device pointer to the input config Simon Glass
                   ` (26 subsequent siblings)
  27 siblings, 2 replies; 60+ messages in thread
From: Simon Glass @ 2015-09-09  4:32 UTC (permalink / raw)
  To: u-boot

Add a uclass for keyboard input, mirroring the existing stdio methods.
This is enabled by a new CONFIG_DM_KEYBOARD option.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/usb_kbd.c                |  6 ---
 drivers/input/Kconfig           |  9 +++++
 drivers/input/Makefile          |  2 +
 drivers/input/keyboard-uclass.c | 84 +++++++++++++++++++++++++++++++++++++++++
 include/keyboard.h              | 78 ++++++++++++++++++++++++++++++++++++++
 5 files changed, 173 insertions(+), 6 deletions(-)
 create mode 100644 drivers/input/keyboard-uclass.c

diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index 8037ebf..05668fc 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -648,12 +648,6 @@ U_BOOT_DRIVER(usb_kbd) = {
 	.probe = usb_kbd_probe,
 };
 
-/* TODO(sjg at chromium.org): Move this into a common location */
-UCLASS_DRIVER(keyboard) = {
-	.id		= UCLASS_KEYBOARD,
-	.name		= "keyboard",
-};
-
 static const struct usb_device_id kbd_id_table[] = {
 	{
 		.match_flags = USB_DEVICE_ID_MATCH_INT_CLASS |
diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
index bb00de7..447c4c3 100644
--- a/drivers/input/Kconfig
+++ b/drivers/input/Kconfig
@@ -1,3 +1,12 @@
+config DM_KEYBOARD
+	bool "Enable driver model keyboard support"
+	depends on DM
+	help
+	  This adds a uclass for keyboards and implements keyboard support
+	  using driver model. The API is implemented by keyboard.h and
+	  includes methods to start/stop the device, check for available
+	  input and update LEDs if the keyboard has them.
+
 config CROS_EC_KEYB
 	bool "Enable Chrome OS EC keyboard support"
 	help
diff --git a/drivers/input/Makefile b/drivers/input/Makefile
index b1161c5..9388dfe 100644
--- a/drivers/input/Makefile
+++ b/drivers/input/Makefile
@@ -5,6 +5,8 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
+obj-$(CONFIG_DM_KEYBOARD) += keyboard-uclass.o
+
 obj-$(CONFIG_I8042_KBD) += i8042.o
 obj-$(CONFIG_TEGRA_KEYBOARD) += tegra-kbc.o
 obj-$(CONFIG_TWL4030_INPUT) += twl4030.o
diff --git a/drivers/input/keyboard-uclass.c b/drivers/input/keyboard-uclass.c
new file mode 100644
index 0000000..1c564dc
--- /dev/null
+++ b/drivers/input/keyboard-uclass.c
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2015 Google, Inc
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <keyboard.h>
+
+static int keyboard_start(struct stdio_dev *sdev)
+{
+	struct udevice *dev = sdev->priv;
+	struct keyboard_ops *ops = keyboard_get_ops(dev);
+
+	if (ops->start)
+		return ops->start(dev);
+
+	return 0;
+}
+
+static int keyboard_stop(struct stdio_dev *sdev)
+{
+	struct udevice *dev = sdev->priv;
+	struct keyboard_ops *ops = keyboard_get_ops(dev);
+
+	if (ops->stop)
+		return ops->stop(dev);
+
+	return 0;
+}
+
+static int keyboard_tstc(struct stdio_dev *sdev)
+{
+	struct udevice *dev = sdev->priv;
+	struct keyboard_priv *priv = dev_get_uclass_priv(dev);
+
+	/* Just get input to do this for us if we can */
+	if (priv->input.dev)
+		return input_tstc(&priv->input);
+
+	return -ENOSYS;
+}
+
+static int keyboard_getc(struct stdio_dev *sdev)
+{
+	struct udevice *dev = sdev->priv;
+	struct keyboard_priv *priv = dev_get_uclass_priv(dev);
+
+	/* Just get input to do this for us if we can */
+	if (priv->input.dev)
+		return input_getc(&priv->input);
+
+	return -ENOSYS;
+}
+
+static int keyboard_pre_probe(struct udevice *dev)
+{
+	struct keyboard_priv *priv = dev_get_uclass_priv(dev);
+	struct stdio_dev *sdev = &priv->sdev;
+	int ret;
+
+	strlcpy(sdev->name, dev->name, sizeof(sdev->name));
+	sdev->flags = DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
+	sdev->getc = keyboard_getc;
+	sdev->tstc = keyboard_tstc;
+	sdev->start = keyboard_start;
+	sdev->stop = keyboard_stop;
+	sdev->priv = dev;
+	ret = input_init(&priv->input, 0);
+	if (ret) {
+		debug("%s: Cannot set up input\n", __func__);
+		return ret;
+	}
+
+	return 0;
+}
+
+UCLASS_DRIVER(keyboard) = {
+	.id		= UCLASS_KEYBOARD,
+	.name		= "keyboard",
+	.pre_probe	= keyboard_pre_probe,
+	.per_device_auto_alloc_size = sizeof(struct keyboard_priv),
+};
diff --git a/include/keyboard.h b/include/keyboard.h
index 88ae12b..a8b68cb 100644
--- a/include/keyboard.h
+++ b/include/keyboard.h
@@ -1,6 +1,83 @@
 #ifndef __KEYBOARD_H
 #define __KEYBOARD_H
 
+#ifdef CONFIG_DM_KEYBOARD
+#include <input.h>
+#include <stdio_dev.h>
+
+/**
+ * struct keyboard_priv - information about a keyboard, for the uclass
+ *
+ * @sdev:	stdio device
+ * @input:	input configuration (the driver may use this if desired)
+ */
+struct keyboard_priv {
+	struct stdio_dev sdev;
+
+	/*
+	 * This is set up by the uclass but will only be used if the driver
+	 * sets input.dev to its device pointer (it is initially NULL).
+	 */
+	struct input_config input;
+};
+
+/**
+ * struct keyboard_ops - keyboard device operations
+ */
+struct keyboard_ops {
+	/**
+	 * start() - enable the keyboard ready for use
+	 *
+	 * @dev:	Device to enable
+	 * @return 0 if OK, -ve on error
+	 */
+	int (*start)(struct udevice *dev);
+
+	/**
+	 * stop() - disable the keyboard when no-longer needed
+	 *
+	 * @dev:	Device to disable
+	 * @return 0 if OK, -ve on error
+	 */
+	int (*stop)(struct udevice *dev);
+
+	/**
+	 * tstc() - check if a key is available
+	 *
+	 * @dev:	Device to check
+	 * @return 0 if no key is available, 1 if a key is available
+	 */
+	int (*tstc)(struct udevice *dev);
+
+	/**
+	 * getc() - get a key
+	 *
+	 * TODO(sjg at chromium.org): At present this method may wait if it calls
+	 * input_getc().
+	 *
+	 * @dev:	Device to read from
+	 * @return -EAGAIN if no key is available, otherwise key value read
+	 *	   (as ASCII).
+	 */
+	int (*getc)(struct udevice *dev);
+
+	/**
+	 * update_leds() - update keyboard LEDs
+	 *
+	 * This is called when the LEDs have changed and need to be updated.
+	 * For example, if 'caps lock' is pressed then this method will be
+	 * called with the new LED value.
+	 *
+	 * @dev:	Device to update
+	 * @leds:	New LED mask (see INPUT_LED_... in input.h)
+	 */
+	int (*update_leds)(struct udevice *dev, int leds);
+};
+
+#define keyboard_get_ops(dev)	((struct keyboard_ops *)(dev)->driver->ops)
+
+#else
+
 #ifdef CONFIG_PS2MULT
 #include <ps2mult.h>
 #endif
@@ -18,5 +95,6 @@ extern int kbd_init (void);
 extern void handle_scancode(unsigned char scancode);
 extern int kbd_init_hw(void);
 extern void pckbd_leds(unsigned char leds);
+#endif /* !CONFIG_DM_KEYBOARD */
 
 #endif /* __KEYBOARD_H */
-- 
2.6.0.rc0.131.gf624c3d

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 02/28] input: Add a device pointer to the input config
  2015-09-09  4:32 [U-Boot] [PATCH 00/28] dm: input: Move keyboard drivers to driver model Simon Glass
  2015-09-09  4:32 ` [U-Boot] [PATCH 01/28] dm: input: Create a keyboard uclass Simon Glass
@ 2015-09-09  4:32 ` Simon Glass
  2015-09-15  6:11   ` Bin Meng
  2015-09-09  4:32 ` [U-Boot] [PATCH 03/28] input: Return -ENOSPC when there is not space Simon Glass
                   ` (25 subsequent siblings)
  27 siblings, 1 reply; 60+ messages in thread
From: Simon Glass @ 2015-09-09  4:32 UTC (permalink / raw)
  To: u-boot

The read_keys() method in input is passed a struct input_config. Add a
device pointer there so that we can find out the device that is referred
to with driver model.

Once all drivers are converted we can update the input structure to use
driver model instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 include/input.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/input.h b/include/input.h
index 26e2ad7..7bccc8e 100644
--- a/include/input.h
+++ b/include/input.h
@@ -36,6 +36,7 @@ struct input_key_xlate {
 };
 
 struct input_config {
+	struct udevice *dev;
 	uchar fifo[INPUT_BUFFER_LEN];
 	int fifo_in, fifo_out;
 
-- 
2.6.0.rc0.131.gf624c3d

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 03/28] input: Return -ENOSPC when there is not space
  2015-09-09  4:32 [U-Boot] [PATCH 00/28] dm: input: Move keyboard drivers to driver model Simon Glass
  2015-09-09  4:32 ` [U-Boot] [PATCH 01/28] dm: input: Create a keyboard uclass Simon Glass
  2015-09-09  4:32 ` [U-Boot] [PATCH 02/28] input: Add a device pointer to the input config Simon Glass
@ 2015-09-09  4:32 ` Simon Glass
  2015-09-15  6:11   ` Bin Meng
  2015-09-09  4:32 ` [U-Boot] [PATCH 04/28] input: Add the keycode translation tables separately Simon Glass
                   ` (24 subsequent siblings)
  27 siblings, 1 reply; 60+ messages in thread
From: Simon Glass @ 2015-09-09  4:32 UTC (permalink / raw)
  To: u-boot

Return a useful error instead of -1 when something goes wrong.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/input/input.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/input/input.c b/drivers/input/input.c
index 007b855..9033935 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -8,6 +8,7 @@
  */
 
 #include <common.h>
+#include <errno.h>
 #include <stdio_dev.h>
 #include <input.h>
 #include <linux/input.h>
@@ -467,7 +468,7 @@ int input_init(struct input_config *config, int leds)
 		input_add_table(config, KEY_LEFTCTRL, KEY_RIGHTCTRL,
 			kbd_ctrl_xlate, ARRAY_SIZE(kbd_ctrl_xlate))) {
 		debug("%s: Could not add modifier tables\n", __func__);
-		return -1;
+		return -ENOSPC;
 	}
 
 	return 0;
-- 
2.6.0.rc0.131.gf624c3d

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 04/28] input: Add the keycode translation tables separately
  2015-09-09  4:32 [U-Boot] [PATCH 00/28] dm: input: Move keyboard drivers to driver model Simon Glass
                   ` (2 preceding siblings ...)
  2015-09-09  4:32 ` [U-Boot] [PATCH 03/28] input: Return -ENOSPC when there is not space Simon Glass
@ 2015-09-09  4:32 ` Simon Glass
  2015-09-15  6:11   ` Bin Meng
  2015-09-09  4:32 ` [U-Boot] [PATCH 05/28] cros_ec: Use udevice instead of cros_ec_dev for keyboard functions Simon Glass
                   ` (23 subsequent siblings)
  27 siblings, 1 reply; 60+ messages in thread
From: Simon Glass @ 2015-09-09  4:32 UTC (permalink / raw)
  To: u-boot

Require the caller to add the keycode translation tables separately so that
it can select which ones to use. In a later patch we will add the option to
add German tables.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 board/kosagi/novena/novena.c |  1 +
 drivers/input/cros_ec_keyb.c |  1 +
 drivers/input/input.c        | 21 ++++++++++++---------
 drivers/input/tegra-kbc.c    |  1 +
 include/input.h              | 10 ++++++++++
 5 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/board/kosagi/novena/novena.c b/board/kosagi/novena/novena.c
index 69f5be3..48cbb0f 100644
--- a/board/kosagi/novena/novena.c
+++ b/board/kosagi/novena/novena.c
@@ -88,6 +88,7 @@ int drv_keyboard_init(void)
 		debug("%s: Cannot set up input\n", __func__);
 		return -1;
 	}
+	input_add_tables(&button_input);
 	button_input.read_keys = novena_gpio_button_read_keys;
 
 	error = input_stdio_register(&dev);
diff --git a/drivers/input/cros_ec_keyb.c b/drivers/input/cros_ec_keyb.c
index a31aa77..eaab86f 100644
--- a/drivers/input/cros_ec_keyb.c
+++ b/drivers/input/cros_ec_keyb.c
@@ -255,6 +255,7 @@ int drv_keyboard_init(void)
 		return -1;
 	}
 	config.input.read_keys = cros_ec_kbc_check;
+	input_add_tables(&config.input);
 
 	memset(&dev, '\0', sizeof(dev));
 	strcpy(dev.name, "cros-ec-keyb");
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 9033935..0f11ae6 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -457,19 +457,22 @@ void input_set_delays(struct input_config *config, int repeat_delay_ms,
 	config->repeat_rate_ms = repeat_rate_ms;
 }
 
+int input_add_tables(struct input_config *config)
+{
+	input_add_table(config, -1, -1,
+			kbd_plain_xlate, ARRAY_SIZE(kbd_plain_xlate));
+	input_add_table(config, KEY_LEFTSHIFT, KEY_RIGHTSHIFT,
+			kbd_shift_xlate, ARRAY_SIZE(kbd_shift_xlate));
+	input_add_table(config, KEY_LEFTCTRL, KEY_RIGHTCTRL,
+			kbd_ctrl_xlate, ARRAY_SIZE(kbd_ctrl_xlate));
+
+	return 0;
+}
+
 int input_init(struct input_config *config, int leds)
 {
 	memset(config, '\0', sizeof(*config));
 	config->leds = leds;
-	if (input_add_table(config, -1, -1,
-			kbd_plain_xlate, ARRAY_SIZE(kbd_plain_xlate)) ||
-		input_add_table(config, KEY_LEFTSHIFT, KEY_RIGHTSHIFT,
-			kbd_shift_xlate, ARRAY_SIZE(kbd_shift_xlate)) ||
-		input_add_table(config, KEY_LEFTCTRL, KEY_RIGHTCTRL,
-			kbd_ctrl_xlate, ARRAY_SIZE(kbd_ctrl_xlate))) {
-		debug("%s: Could not add modifier tables\n", __func__);
-		return -ENOSPC;
-	}
 
 	return 0;
 }
diff --git a/drivers/input/tegra-kbc.c b/drivers/input/tegra-kbc.c
index c9c9fac..3310f84 100644
--- a/drivers/input/tegra-kbc.c
+++ b/drivers/input/tegra-kbc.c
@@ -355,6 +355,7 @@ int drv_keyboard_init(void)
 		return -1;
 	}
 	config.input.read_keys = tegra_kbc_check;
+	input_add_tables(input);
 
 	memset(&dev, '\0', sizeof(dev));
 	strcpy(dev.name, "tegra-kbc");
diff --git a/include/input.h b/include/input.h
index 7bccc8e..71f3538 100644
--- a/include/input.h
+++ b/include/input.h
@@ -123,6 +123,16 @@ void input_set_delays(struct input_config *config, int repeat_delay_ms,
 	       int repeat_rate_ms);
 
 /**
+ * Set up the key map tables
+ *
+ * This must be called after input_init() or keycode decoding will not work.
+ *
+ * @param config	Input state
+ * @return 0 if ok, -1 on error
+ */
+int input_add_tables(struct input_config *config);
+
+/**
  * Set up the input handler with basic key maps.
  *
  * @param config	Input state
-- 
2.6.0.rc0.131.gf624c3d

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 05/28] cros_ec: Use udevice instead of cros_ec_dev for keyboard functions
  2015-09-09  4:32 [U-Boot] [PATCH 00/28] dm: input: Move keyboard drivers to driver model Simon Glass
                   ` (3 preceding siblings ...)
  2015-09-09  4:32 ` [U-Boot] [PATCH 04/28] input: Add the keycode translation tables separately Simon Glass
@ 2015-09-09  4:32 ` Simon Glass
  2015-09-09  4:32 ` [U-Boot] [PATCH 06/28] dm: stdio: Plumb in the new keyboard uclass Simon Glass
                   ` (22 subsequent siblings)
  27 siblings, 0 replies; 60+ messages in thread
From: Simon Glass @ 2015-09-09  4:32 UTC (permalink / raw)
  To: u-boot

In preparation for converting the cros_ec keyboard driver to driver model,
adjust the cros_ec functions it will use to use a normal struct udevice.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/input/cros_ec_keyb.c |  4 ++--
 drivers/misc/cros_ec.c       | 14 +++++++++-----
 include/cros_ec.h            |  4 ++--
 3 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/input/cros_ec_keyb.c b/drivers/input/cros_ec_keyb.c
index eaab86f..88397b0 100644
--- a/drivers/input/cros_ec_keyb.c
+++ b/drivers/input/cros_ec_keyb.c
@@ -54,7 +54,7 @@ static int check_for_keys(struct keyb *config,
 	unsigned int row, col, bit, data;
 	int num_keys;
 
-	if (cros_ec_scan_keyboard(config->dev, &scan)) {
+	if (cros_ec_scan_keyboard(config->dev->dev, &scan)) {
 		debug("%s: keyboard scan failed\n", __func__);
 		return -EIO;
 	}
@@ -139,7 +139,7 @@ int cros_ec_kbc_check(struct input_config *input)
 	 * may return 0 before all keys have been read from the EC.
 	 */
 	do {
-		irq_pending = cros_ec_interrupt_pending(config.dev);
+		irq_pending = cros_ec_interrupt_pending(config.dev->dev);
 		if (irq_pending) {
 			num_keys = check_for_keys(&config, keys, KBC_MAX_KEYS,
 						  &same);
diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c
index ba36795..e3229ef 100644
--- a/drivers/misc/cros_ec.c
+++ b/drivers/misc/cros_ec.c
@@ -358,9 +358,11 @@ static int ec_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,
 	return len;
 }
 
-int cros_ec_scan_keyboard(struct cros_ec_dev *dev, struct mbkp_keyscan *scan)
+int cros_ec_scan_keyboard(struct udevice *dev, struct mbkp_keyscan *scan)
 {
-	if (ec_command(dev, EC_CMD_MKBP_STATE, 0, NULL, 0, scan,
+	struct cros_ec_dev *cdev = dev_get_uclass_priv(dev);
+
+	if (ec_command(cdev, EC_CMD_MKBP_STATE, 0, NULL, 0, scan,
 		       sizeof(scan->data)) != sizeof(scan->data))
 		return -1;
 
@@ -549,13 +551,15 @@ int cros_ec_reboot(struct cros_ec_dev *dev, enum ec_reboot_cmd cmd,
 	return 0;
 }
 
-int cros_ec_interrupt_pending(struct cros_ec_dev *dev)
+int cros_ec_interrupt_pending(struct udevice *dev)
 {
+	struct cros_ec_dev *cdev = dev_get_uclass_priv(dev);
+
 	/* no interrupt support : always poll */
-	if (!dm_gpio_is_valid(&dev->ec_int))
+	if (!dm_gpio_is_valid(&cdev->ec_int))
 		return -ENOENT;
 
-	return dm_gpio_get_value(&dev->ec_int);
+	return dm_gpio_get_value(&cdev->ec_int);
 }
 
 int cros_ec_info(struct cros_ec_dev *dev, struct ec_response_mkbp_info *info)
diff --git a/include/cros_ec.h b/include/cros_ec.h
index b926934..5fa5f6f 100644
--- a/include/cros_ec.h
+++ b/include/cros_ec.h
@@ -81,7 +81,7 @@ int cros_ec_read_id(struct cros_ec_dev *dev, char *id, int maxlen);
  * @param scan		Place to put the scan results
  * @return 0 if ok, -1 on error
  */
-int cros_ec_scan_keyboard(struct cros_ec_dev *dev, struct mbkp_keyscan *scan);
+int cros_ec_scan_keyboard(struct udevice *dev, struct mbkp_keyscan *scan);
 
 /**
  * Read which image is currently running on the CROS-EC device.
@@ -125,7 +125,7 @@ int cros_ec_reboot(struct cros_ec_dev *dev, enum ec_reboot_cmd cmd,
  * @param dev		CROS-EC device
  * @return 0 if no interrupt is pending
  */
-int cros_ec_interrupt_pending(struct cros_ec_dev *dev);
+int cros_ec_interrupt_pending(struct udevice *dev);
 
 enum {
 	CROS_EC_OK,
-- 
2.6.0.rc0.131.gf624c3d

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 06/28] dm: stdio: Plumb in the new keyboard uclass
  2015-09-09  4:32 [U-Boot] [PATCH 00/28] dm: input: Move keyboard drivers to driver model Simon Glass
                   ` (4 preceding siblings ...)
  2015-09-09  4:32 ` [U-Boot] [PATCH 05/28] cros_ec: Use udevice instead of cros_ec_dev for keyboard functions Simon Glass
@ 2015-09-09  4:32 ` Simon Glass
  2015-09-15  6:11   ` Bin Meng
  2015-10-30 20:24   ` Simon Glass
  2015-09-09  4:32 ` [U-Boot] [PATCH 07/28] dm: tegra: Convert keyboard driver to driver model Simon Glass
                   ` (21 subsequent siblings)
  27 siblings, 2 replies; 60+ messages in thread
From: Simon Glass @ 2015-09-09  4:32 UTC (permalink / raw)
  To: u-boot

When driver model is used for keyboards we must scan the available keyboards
and register them with stdio. Add code to do this.

At some point (once LCD/video is converted) we should be able to convert
stdio to driver model and avoid these dual data structures.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/stdio.c | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/common/stdio.c b/common/stdio.c
index adbfc89..71cc32e 100644
--- a/common/stdio.c
+++ b/common/stdio.c
@@ -11,6 +11,7 @@
 
 #include <config.h>
 #include <common.h>
+#include <dm.h>
 #include <errno.h>
 #include <stdarg.h>
 #include <malloc.h>
@@ -24,6 +25,8 @@
 #include <i2c.h>
 #endif
 
+#include <dm/device-internal.h>
+
 DECLARE_GLOBAL_DATA_PTR;
 
 static struct stdio_dev devs;
@@ -245,6 +248,32 @@ int stdio_init_tables(void)
 
 int stdio_add_devices(void)
 {
+#ifdef CONFIG_DM_KEYBOARD
+	struct udevice *dev;
+	struct uclass *uc;
+	int ret;
+
+	/*
+	 * For now we probe all the devices here. At some point this should be
+	 * done only when the devices are required - e.g. we have a list of
+	 * input devices to start up in the stdin environment variable. That
+	 * work probably makes more sense when stdio itself is converted to
+	 * driver model.
+	 *
+	 * TODO(sjg at chromium.org): Convert changing uclass_first_device() etc.
+	 * to return the device even on error. Then we could use that here.
+	 */
+	ret = uclass_get(UCLASS_KEYBOARD, &uc);
+	if (ret)
+		return ret;
+
+	/* Don't report errors to the caller - assume that they are non-fatal */
+	uclass_foreach_dev(dev, uc) {
+		ret = device_probe(dev);
+		if (ret)
+			printf("Failed to probe keyboard '%s'\n", dev->name);
+	}
+#endif
 #ifdef CONFIG_SYS_I2C
 	i2c_init_all();
 #else
@@ -258,7 +287,7 @@ int stdio_add_devices(void)
 #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
 	drv_video_init ();
 #endif
-#ifdef CONFIG_KEYBOARD
+#if defined(CONFIG_KEYBOARD) && !defined(CONFIG_DM_KEYBOARD)
 	drv_keyboard_init ();
 #endif
 #ifdef CONFIG_LOGBUFFER
-- 
2.6.0.rc0.131.gf624c3d

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 07/28] dm: tegra: Convert keyboard driver to driver model
  2015-09-09  4:32 [U-Boot] [PATCH 00/28] dm: input: Move keyboard drivers to driver model Simon Glass
                   ` (5 preceding siblings ...)
  2015-09-09  4:32 ` [U-Boot] [PATCH 06/28] dm: stdio: Plumb in the new keyboard uclass Simon Glass
@ 2015-09-09  4:32 ` Simon Glass
  2015-09-09  4:32 ` [U-Boot] [PATCH 08/28] dm: cros_ec: Convert cros_ec " Simon Glass
                   ` (20 subsequent siblings)
  27 siblings, 0 replies; 60+ messages in thread
From: Simon Glass @ 2015-09-09  4:32 UTC (permalink / raw)
  To: u-boot

Adjust the tegra keyboard driver to support driver model, using the new
uclass. Make this the default for all Tegra boards so that those that use
a keyboard will build correctly with this driver.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/arm/mach-tegra/Kconfig |   1 +
 drivers/input/tegra-kbc.c   | 243 ++++++++++++++++++++------------------------
 include/fdtdec.h            |   1 -
 lib/fdtdec.c                |   1 -
 4 files changed, 112 insertions(+), 134 deletions(-)

diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig
index a5b7e0d..de2454e 100644
--- a/arch/arm/mach-tegra/Kconfig
+++ b/arch/arm/mach-tegra/Kconfig
@@ -12,6 +12,7 @@ config TEGRA_ARMV7_COMMON
 	select DM_I2C
 	select DM_SPI
 	select DM_GPIO
+	select DM_KEYBOARD
 
 choice
 	prompt "Tegra SoC select"
diff --git a/drivers/input/tegra-kbc.c b/drivers/input/tegra-kbc.c
index 3310f84..a7137f1 100644
--- a/drivers/input/tegra-kbc.c
+++ b/drivers/input/tegra-kbc.c
@@ -6,8 +6,10 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <fdtdec.h>
 #include <input.h>
+#include <keyboard.h>
 #include <key_matrix.h>
 #include <stdio_dev.h>
 #include <tegra-kbc.h>
@@ -40,14 +42,13 @@ enum {
 };
 
 /* keyboard controller config and state */
-static struct keyb {
-	struct input_config input;	/* The input layer */
+struct tegra_kbd_priv {
+	struct input_config *input;	/* The input layer */
 	struct key_matrix matrix;	/* The key matrix layer */
 
 	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.
@@ -58,17 +59,17 @@ static struct keyb {
 	unsigned int start_time_ms;	/* Time that we inited (in ms) */
 	unsigned int last_poll_ms;	/* Time we should last polled */
 	unsigned int next_repeat_ms;	/* Next time we repeat a key */
-} config;
+};
 
 /**
  * reads the keyboard fifo for current keypresses
  *
- * @param config	Keyboard config
+ * @param priv		Keyboard private data
  * @param fifo		Place to put fifo results
  * @param max_keycodes	Maximum number of key codes to put in the fifo
  * @return number of items put into fifo
  */
-static int tegra_kbc_find_keys(struct keyb *config, int *fifo,
+static int tegra_kbc_find_keys(struct tegra_kbd_priv *priv, int *fifo,
 			       int max_keycodes)
 {
 	struct key_matrix_key keys[KBC_MAX_KPENT], *key;
@@ -78,7 +79,7 @@ static int tegra_kbc_find_keys(struct keyb *config, int *fifo,
 	for (key = keys, i = 0; i < KBC_MAX_KPENT; i++, key++) {
 		/* Get next word */
 		if (!(i & 3))
-			kp_ent = readl(&config->kbc->kp_ent[i / 4]);
+			kp_ent = readl(&priv->kbc->kp_ent[i / 4]);
 
 		key->valid = (kp_ent & KBC_KPENT_VALID) != 0;
 		key->row = (kp_ent >> 3) & 0xf;
@@ -87,7 +88,7 @@ static int tegra_kbc_find_keys(struct keyb *config, int *fifo,
 		/* Shift to get next entry */
 		kp_ent >>= 8;
 	}
-	return key_matrix_decode(&config->matrix, keys, KBC_MAX_KPENT, fifo,
+	return key_matrix_decode(&priv->matrix, keys, KBC_MAX_KPENT, fifo,
 				 max_keycodes);
 }
 
@@ -106,10 +107,10 @@ static int tegra_kbc_find_keys(struct keyb *config, int *fifo,
  * Note: if fifo_cnt is 0, we will tell the input layer that no keys are
  * pressed.
  *
- * @param config	Keyboard config
+ * @param priv		Keyboard private data
  * @param fifo_cnt	Number of entries in the keyboard fifo
  */
-static void process_fifo(struct keyb *config, int fifo_cnt)
+static void process_fifo(struct tegra_kbd_priv *priv, int fifo_cnt)
 {
 	int fifo[KBC_MAX_KPENT];
 	int cnt = 0;
@@ -117,9 +118,9 @@ static void process_fifo(struct keyb *config, int fifo_cnt)
 	/* Always call input_send_keycodes() at least once */
 	do {
 		if (fifo_cnt)
-			cnt = tegra_kbc_find_keys(config, fifo, KBC_MAX_KPENT);
+			cnt = tegra_kbc_find_keys(priv, fifo, KBC_MAX_KPENT);
 
-		input_send_keycodes(&config->input, fifo, cnt);
+		input_send_keycodes(priv->input, fifo, cnt);
 	} while (--fifo_cnt > 0);
 }
 
@@ -127,24 +128,24 @@ static void process_fifo(struct keyb *config, int fifo_cnt)
  * Check the keyboard controller and emit ASCII characters for any keys that
  * are pressed.
  *
- * @param config	Keyboard config
+ * @param priv		Keyboard private data
  */
-static void check_for_keys(struct keyb *config)
+static void check_for_keys(struct tegra_kbd_priv *priv)
 {
 	int fifo_cnt;
 
-	if (!config->first_scan &&
-			get_timer(config->last_poll_ms) < KBC_REPEAT_RATE_MS)
+	if (!priv->first_scan &&
+	    get_timer(priv->last_poll_ms) < KBC_REPEAT_RATE_MS)
 		return;
-	config->last_poll_ms = get_timer(0);
-	config->first_scan = 0;
+	priv->last_poll_ms = get_timer(0);
+	priv->first_scan = 0;
 
 	/*
 	 * Once we get here we know the keyboard has been scanned. So if there
 	 * scan waiting for us, we know that nothing is held down.
 	 */
-	fifo_cnt = (readl(&config->kbc->interrupt) >> 4) & 0xf;
-	process_fifo(config, fifo_cnt);
+	fifo_cnt = (readl(&priv->kbc->interrupt) >> 4) & 0xf;
+	process_fifo(priv, fifo_cnt);
 }
 
 /**
@@ -153,22 +154,22 @@ static void check_for_keys(struct keyb *config)
  * Wkup mode to Continous polling mode and the repoll time. We can
  * deduct the time that's already elapsed.
  *
- * @param config	Keyboard config
+ * @param priv		Keyboard private data
  */
-static void kbd_wait_for_fifo_init(struct keyb *config)
+static void kbd_wait_for_fifo_init(struct tegra_kbd_priv *priv)
 {
-	if (!config->inited) {
+	if (!priv->inited) {
 		unsigned long elapsed_time;
 		long delay_ms;
 
-		elapsed_time = get_timer(config->start_time_ms);
-		delay_ms = config->init_dly_ms - elapsed_time;
+		elapsed_time = get_timer(priv->start_time_ms);
+		delay_ms = priv->init_dly_ms - elapsed_time;
 		if (delay_ms > 0) {
 			udelay(delay_ms * 1000);
 			debug("%s: delay %ldms\n", __func__, delay_ms);
 		}
 
-		config->inited = 1;
+		priv->inited = 1;
 	}
 }
 
@@ -183,38 +184,16 @@ static void kbd_wait_for_fifo_init(struct keyb *config)
  */
 static int tegra_kbc_check(struct input_config *input)
 {
-	kbd_wait_for_fifo_init(&config);
-	check_for_keys(&config);
-
-	return 1;
-}
+	struct tegra_kbd_priv *priv = dev_get_priv(input->dev);
 
-/**
- * Test if keys are available to be read
- *
- * @return 0 if no keys available, 1 if keys are available
- */
-static int kbd_tstc(struct stdio_dev *dev)
-{
-	/* Just get input to do this for us */
-	return input_tstc(&config.input);
-}
+	kbd_wait_for_fifo_init(priv);
+	check_for_keys(priv);
 
-/**
- * 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(struct stdio_dev *dev)
-{
-	/* Just get input to do this for us */
-	return input_getc(&config.input);
+	return 1;
 }
 
 /* configures keyboard GPIO registers to use the rows and columns */
-static void config_kbc_gpio(struct kbc_tegra *kbc)
+static void config_kbc_gpio(struct tegra_kbd_priv *priv, struct kbc_tegra *kbc)
 {
 	int i;
 
@@ -233,10 +212,10 @@ static void config_kbc_gpio(struct kbc_tegra *kbc)
 		row_cfg &= ~r_mask;
 		col_cfg &= ~c_mask;
 
-		if (i < config.matrix.num_rows) {
+		if (i < priv->matrix.num_rows) {
 			row_cfg |= ((i << 1) | 1) << r_shift;
 		} else {
-			col_cfg |= (((i - config.matrix.num_rows) << 1) | 1)
+			col_cfg |= (((i - priv->matrix.num_rows) << 1) | 1)
 					<< c_shift;
 		}
 
@@ -248,9 +227,9 @@ static void config_kbc_gpio(struct kbc_tegra *kbc)
 /**
  * Start up the keyboard device
  */
-static void tegra_kbc_open(void)
+static void tegra_kbc_open(struct tegra_kbd_priv *priv)
 {
-	struct kbc_tegra *kbc = config.kbc;
+	struct kbc_tegra *kbc = priv->kbc;
 	unsigned int scan_period;
 	u32 val;
 
@@ -265,16 +244,32 @@ static void tegra_kbc_open(void)
 	 * Before reading from the keyboard we must wait for the init_dly
 	 * plus the rpt_delay, plus 2ms for the row scan time.
 	 */
-	config.init_dly_ms = scan_period * 2 + 2;
+	priv->init_dly_ms = scan_period * 2 + 2;
 
 	val = KBC_DEBOUNCE_COUNT << KBC_DEBOUNCE_CNT_SHIFT;
 	val |= 1 << KBC_FIFO_TH_CNT_SHIFT;	/* fifo interrupt threshold */
 	val |= KBC_CONTROL_KBC_EN;		/* enable */
 	writel(val, &kbc->control);
 
-	config.start_time_ms = get_timer(0);
-	config.last_poll_ms = config.next_repeat_ms = get_timer(0);
-	config.first_scan = 1;
+	priv->start_time_ms = get_timer(0);
+	priv->last_poll_ms = get_timer(0);
+	priv->next_repeat_ms = priv->last_poll_ms;
+	priv->first_scan = 1;
+}
+
+static int tegra_kbd_start(struct udevice *dev)
+{
+	struct tegra_kbd_priv *priv = dev_get_priv(dev);
+
+	/* Set up pin mux and enable the clock */
+	funcmux_select(PERIPH_ID_KBC, FUNCMUX_DEFAULT);
+	clock_enable(PERIPH_ID_KBC);
+	config_kbc_gpio(priv, priv->kbc);
+
+	tegra_kbc_open(priv);
+	debug("%s: Tegra keyboard ready\n", __func__);
+
+	return 0;
 }
 
 /**
@@ -289,89 +284,73 @@ static void tegra_kbc_open(void)
  *
  * @return 0 if ok, -ve on error
  */
-static int init_tegra_keyboard(struct stdio_dev *dev)
+static int tegra_kbd_probe(struct udevice *dev)
 {
-	/* check if already created */
-	if (config.created)
-		return 0;
-
-#if CONFIG_IS_ENABLED(OF_CONTROL)
-	int	node;
-
-	node = fdtdec_next_compatible(gd->fdt_blob, 0,
-					  COMPAT_NVIDIA_TEGRA20_KBC);
-	if (node < 0) {
-		debug("%s: cannot locate keyboard node\n", __func__);
-		return node;
-	}
-	config.kbc = (struct kbc_tegra *)fdtdec_get_addr(gd->fdt_blob,
-		       node, "reg");
-	if ((fdt_addr_t)config.kbc == FDT_ADDR_T_NONE) {
+	struct tegra_kbd_priv *priv = dev_get_priv(dev);
+	struct keyboard_priv *uc_priv = dev_get_uclass_priv(dev);
+	struct stdio_dev *sdev = &uc_priv->sdev;
+	struct input_config *input = &uc_priv->input;
+	int node = dev->of_offset;
+	int ret;
+
+	priv->kbc = (struct kbc_tegra *)dev_get_addr(dev);
+	if ((fdt_addr_t)priv->kbc == FDT_ADDR_T_NONE) {
 		debug("%s: No keyboard register found\n", __func__);
-		return -1;
+		return -EINVAL;
 	}
-	input_set_delays(&config.input, KBC_REPEAT_DELAY_MS,
-			KBC_REPEAT_RATE_MS);
+	input_set_delays(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, 1)) {
-		debug("%s: Could not init key matrix\n", __func__);
-		return -1;
+	ret = key_matrix_init(&priv->matrix, 16, 8, 1);
+	if (ret) {
+		debug("%s: Could not init key matrix: %d\n", __func__, ret);
+		return ret;
 	}
-	if (key_matrix_decode_fdt(&config.matrix, gd->fdt_blob, node)) {
-		debug("%s: Could not decode key matrix from fdt\n", __func__);
-		return -1;
+	ret = key_matrix_decode_fdt(&priv->matrix, gd->fdt_blob, node);
+	if (ret) {
+		debug("%s: Could not decode key matrix from fdt: %d\n",
+		      __func__, ret);
+		return ret;
 	}
-	if (config.matrix.fn_keycode) {
-		if (input_add_table(&config.input, KEY_FN, -1,
-				    config.matrix.fn_keycode,
-				    config.matrix.key_count))
-			return -1;
+	if (priv->matrix.fn_keycode) {
+		ret = input_add_table(input, KEY_FN, -1,
+				      priv->matrix.fn_keycode,
+				      priv->matrix.key_count);
+		if (ret) {
+			debug("%s: input_add_table() failed\n", __func__);
+			return ret;
+		}
 	}
-#else
-#error "Tegra keyboard driver requires FDT definitions"
-#endif
-
-	/* Set up pin mux and enable the clock */
-	funcmux_select(PERIPH_ID_KBC, FUNCMUX_DEFAULT);
-	clock_enable(PERIPH_ID_KBC);
-	config_kbc_gpio(config.kbc);
 
-	tegra_kbc_open();
-	config.created = 1;
-	debug("%s: Tegra keyboard ready\n", __func__);
+	/* Register the device. init_tegra_keyboard() will be called soon */
+	priv->input = input;
+	input->dev = dev;
+	input->read_keys = tegra_kbc_check;
+	input_add_tables(input);
+	strcpy(sdev->name, "tegra-kbc");
+	ret = input_stdio_register(sdev);
+	if (ret) {
+		debug("%s: input_stdio_register() failed\n", __func__);
+		return ret;
+	}
 
 	return 0;
 }
 
-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__);
-		return -1;
-	}
-	config.input.read_keys = tegra_kbc_check;
-	input_add_tables(input);
+static const struct keyboard_ops tegra_kbd_ops = {
+	.start	= tegra_kbd_start,
+};
 
-	memset(&dev, '\0', sizeof(dev));
-	strcpy(dev.name, "tegra-kbc");
-	dev.flags = DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
-	dev.getc = kbd_getc;
-	dev.tstc = kbd_tstc;
-	dev.start = init_tegra_keyboard;
+static const struct udevice_id tegra_kbd_ids[] = {
+	{ .compatible = "nvidia,tegra20-kbc" },
+	{ }
+};
 
-	/* Register the device. init_tegra_keyboard() will be called soon */
-	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;
-}
+U_BOOT_DRIVER(tegra_kbd) = {
+	.name	= "tegra_kbd",
+	.id	= UCLASS_KEYBOARD,
+	.of_match = tegra_kbd_ids,
+	.probe = tegra_kbd_probe,
+	.ops	= &tegra_kbd_ops,
+	.priv_auto_alloc_size = sizeof(struct tegra_kbd_priv),
+};
diff --git a/include/fdtdec.h b/include/fdtdec.h
index a422ece..f62099f 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -118,7 +118,6 @@ enum fdt_compat_id {
 	COMPAT_UNKNOWN,
 	COMPAT_NVIDIA_TEGRA20_EMC,	/* Tegra20 memory controller */
 	COMPAT_NVIDIA_TEGRA20_EMC_TABLE, /* Tegra20 memory timing table */
-	COMPAT_NVIDIA_TEGRA20_KBC,	/* Tegra20 Keyboard */
 	COMPAT_NVIDIA_TEGRA20_NAND,	/* Tegra2 NAND controller */
 	COMPAT_NVIDIA_TEGRA20_PWM,	/* Tegra 2 PWM controller */
 	COMPAT_NVIDIA_TEGRA124_DC,	/* Tegra 124 Display controller */
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 5770094..41a5334 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -24,7 +24,6 @@ static const char * const compat_names[COMPAT_COUNT] = {
 	COMPAT(UNKNOWN, "<none>"),
 	COMPAT(NVIDIA_TEGRA20_EMC, "nvidia,tegra20-emc"),
 	COMPAT(NVIDIA_TEGRA20_EMC_TABLE, "nvidia,tegra20-emc-table"),
-	COMPAT(NVIDIA_TEGRA20_KBC, "nvidia,tegra20-kbc"),
 	COMPAT(NVIDIA_TEGRA20_NAND, "nvidia,tegra20-nand"),
 	COMPAT(NVIDIA_TEGRA20_PWM, "nvidia,tegra20-pwm"),
 	COMPAT(NVIDIA_TEGRA124_DC, "nvidia,tegra124-dc"),
-- 
2.6.0.rc0.131.gf624c3d

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 08/28] dm: cros_ec: Convert cros_ec keyboard driver to driver model
  2015-09-09  4:32 [U-Boot] [PATCH 00/28] dm: input: Move keyboard drivers to driver model Simon Glass
                   ` (6 preceding siblings ...)
  2015-09-09  4:32 ` [U-Boot] [PATCH 07/28] dm: tegra: Convert keyboard driver to driver model Simon Glass
@ 2015-09-09  4:32 ` Simon Glass
  2015-09-09  4:32 ` [U-Boot] [PATCH 09/28] video: Drop unused console functions Simon Glass
                   ` (19 subsequent siblings)
  27 siblings, 0 replies; 60+ messages in thread
From: Simon Glass @ 2015-09-09  4:32 UTC (permalink / raw)
  To: u-boot

Adjust the cros_ec keyboard driver to support driver model. Make this the
default for all Exynos boards so that those that use a keyboard will build
correctly with this driver.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 README                       |   5 --
 arch/arm/Kconfig             |   1 +
 arch/sandbox/Kconfig         |   3 +
 drivers/input/cros_ec_keyb.c | 148 +++++++++++++++++--------------------------
 4 files changed, 62 insertions(+), 95 deletions(-)

diff --git a/README b/README
index 1acc355..08f2f70 100644
--- a/README
+++ b/README
@@ -1803,11 +1803,6 @@ CBFS (Coreboot Filesystem) support
 		Export function i8042_kbd_init, i8042_tstc and i8042_getc
 		for cfb_console. Supports cursor blinking.
 
-		CONFIG_CROS_EC_KEYB
-		Enables a Chrome OS keyboard using the CROS_EC interface.
-		This uses CROS_EC to communicate with a second microcontroller
-		which provides key scans on request.
-
 - Video support:
 		CONFIG_VIDEO
 
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 8085a24..218e9ce 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -450,6 +450,7 @@ config ARCH_EXYNOS
 	select DM_SERIAL
 	select DM_SPI
 	select DM_GPIO
+	select DM_KEYBOARD
 
 config ARCH_S5PC1XX
 	bool "Samsung S5PC1XX"
diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig
index f078c9e..25e316c 100644
--- a/arch/sandbox/Kconfig
+++ b/arch/sandbox/Kconfig
@@ -17,4 +17,7 @@ config PCI
 	  used on some devices to allow the CPU to communicate with its
 	  peripherals.
 
+config DM_KEYBOARD
+	default y
+
 endmenu
diff --git a/drivers/input/cros_ec_keyb.c b/drivers/input/cros_ec_keyb.c
index 88397b0..fe5caea 100644
--- a/drivers/input/cros_ec_keyb.c
+++ b/drivers/input/cros_ec_keyb.c
@@ -8,9 +8,11 @@
 
 #include <common.h>
 #include <cros_ec.h>
+#include <dm.h>
 #include <errno.h>
 #include <fdtdec.h>
 #include <input.h>
+#include <keyboard.h>
 #include <key_matrix.h>
 #include <stdio_dev.h>
 
@@ -22,31 +24,29 @@ enum {
 	KBC_REPEAT_DELAY_MS	= 240,
 };
 
-static struct keyb {
-	struct cros_ec_dev *dev;		/* The CROS_EC device */
-	struct input_config input;	/* The input layer */
+struct cros_ec_keyb_priv {
+	struct input_config *input;	/* The input layer */
 	struct key_matrix matrix;	/* The key matrix layer */
 	int key_rows;			/* Number of keyboard rows */
 	int key_cols;			/* Number of keyboard columns */
 	int ghost_filter;		/* 1 to enable ghost filter, else 0 */
-	int inited;			/* 1 if keyboard is ready */
-} config;
+};
 
 
 /**
  * Check the keyboard controller and return a list of key matrix positions
  * for which a key is pressed
  *
- * @param config	Keyboard config
+ * @param dev		Keyboard device
  * @param keys		List of keys that we have detected
  * @param max_count	Maximum number of keys to return
  * @param samep		Set to true if this scan repeats the last, else false
  * @return number of pressed keys, 0 for none, -EIO on error
  */
-static int check_for_keys(struct keyb *config,
-			   struct key_matrix_key *keys, int max_count,
-			   bool *samep)
+static int check_for_keys(struct udevice *dev, struct key_matrix_key *keys,
+			  int max_count, bool *samep)
 {
+	struct cros_ec_keyb_priv *priv = dev_get_priv(dev);
 	struct key_matrix_key *key;
 	static struct mbkp_keyscan last_scan;
 	static bool last_scan_valid;
@@ -54,7 +54,7 @@ static int check_for_keys(struct keyb *config,
 	unsigned int row, col, bit, data;
 	int num_keys;
 
-	if (cros_ec_scan_keyboard(config->dev->dev, &scan)) {
+	if (cros_ec_scan_keyboard(dev->parent, &scan)) {
 		debug("%s: keyboard scan failed\n", __func__);
 		return -EIO;
 	}
@@ -69,9 +69,9 @@ static int check_for_keys(struct keyb *config,
 	last_scan_valid = true;
 	memcpy(&last_scan, &scan, sizeof(last_scan));
 
-	for (col = num_keys = bit = 0; col < config->matrix.num_cols;
+	for (col = num_keys = bit = 0; col < priv->matrix.num_cols;
 			col++) {
-		for (row = 0; row < config->matrix.num_rows; row++) {
+		for (row = 0; row < priv->matrix.num_rows; row++) {
 			unsigned int mask = 1 << (bit & 7);
 
 			data = scan.data[bit / 8];
@@ -89,28 +89,6 @@ static int check_for_keys(struct keyb *config,
 }
 
 /**
- * Test if keys are available to be read
- *
- * @return 0 if no keys available, 1 if keys are available
- */
-static int kbd_tstc(struct stdio_dev *dev)
-{
-	/* Just get input to do this for us */
-	return config.inited ? input_tstc(&config.input) : 0;
-}
-
-/**
- * Read a key
- *
- * @return ASCII key code, or 0 if no key, or -1 if error
- */
-static int kbd_getc(struct stdio_dev *dev)
-{
-	/* Just get input to do this for us */
-	return config.inited ? input_getc(&config.input) : 0;
-}
-
-/**
  * Check the keyboard, and send any keys that are pressed.
  *
  * This is called by input_tstc() and input_getc() when they need more
@@ -121,6 +99,8 @@ static int kbd_getc(struct stdio_dev *dev)
  */
 int cros_ec_kbc_check(struct input_config *input)
 {
+	struct udevice *dev = input->dev;
+	struct cros_ec_keyb_priv *priv = dev_get_priv(dev);
 	static struct key_matrix_key last_keys[KBC_MAX_KEYS];
 	static int last_num_keys;
 	struct key_matrix_key keys[KBC_MAX_KEYS];
@@ -139,9 +119,9 @@ int cros_ec_kbc_check(struct input_config *input)
 	 * may return 0 before all keys have been read from the EC.
 	 */
 	do {
-		irq_pending = cros_ec_interrupt_pending(config.dev->dev);
+		irq_pending = cros_ec_interrupt_pending(dev->parent);
 		if (irq_pending) {
-			num_keys = check_for_keys(&config, keys, KBC_MAX_KEYS,
+			num_keys = check_for_keys(dev, keys, KBC_MAX_KEYS,
 						  &same);
 			if (num_keys < 0)
 				return 0;
@@ -158,7 +138,7 @@ int cros_ec_kbc_check(struct input_config *input)
 
 		if (num_keys < 0)
 			return -1;
-		num_keycodes = key_matrix_decode(&config.matrix, keys,
+		num_keycodes = key_matrix_decode(&priv->matrix, keys,
 				num_keys, keycodes, KBC_MAX_KEYS);
 		sent = input_send_keycodes(input, keycodes, num_keycodes);
 
@@ -182,7 +162,7 @@ int cros_ec_kbc_check(struct input_config *input)
  * @return 0 if ok, -1 on error
  */
 static int cros_ec_keyb_decode_fdt(const void *blob, int node,
-				struct keyb *config)
+				struct cros_ec_keyb_priv *config)
 {
 	/*
 	 * Get keyboard rows and columns - at present we are limited to
@@ -202,68 +182,56 @@ static int cros_ec_keyb_decode_fdt(const void *blob, int node,
 	return 0;
 }
 
-/**
- * Set up the keyboard. This is called by the stdio device handler.
- *
- * We want to do this init when the keyboard is actually used rather than
- * at start-up, since keyboard input may not currently be selected.
- *
- * @return 0 if ok, -1 on error
- */
-static int cros_ec_init_keyboard(struct stdio_dev *dev)
+static int cros_ec_kbd_probe(struct udevice *dev)
 {
+	struct cros_ec_keyb_priv *priv = dev_get_priv(dev);
+	struct keyboard_priv *uc_priv = dev_get_uclass_priv(dev);
+	struct stdio_dev *sdev = &uc_priv->sdev;
+	struct input_config *input = &uc_priv->input;
 	const void *blob = gd->fdt_blob;
-	int node;
+	int node = dev->of_offset;
+	int ret;
 
-	config.dev = board_get_cros_ec_dev();
-	if (!config.dev) {
-		debug("%s: no cros_ec device: cannot init keyboard\n",
-		      __func__);
+	if (cros_ec_keyb_decode_fdt(blob, node, priv))
 		return -1;
-	}
-	node = fdtdec_next_compatible(blob, 0, COMPAT_GOOGLE_CROS_EC_KEYB);
-	if (node < 0) {
-		debug("%s: Node not found\n", __func__);
-		return -1;
-	}
-	if (cros_ec_keyb_decode_fdt(blob, node, &config))
-		return -1;
-	input_set_delays(&config.input, KBC_REPEAT_DELAY_MS,
-			 KBC_REPEAT_RATE_MS);
-	if (key_matrix_init(&config.matrix, config.key_rows,
-			config.key_cols, config.ghost_filter)) {
+	input_set_delays(input, KBC_REPEAT_DELAY_MS, KBC_REPEAT_RATE_MS);
+	ret = key_matrix_init(&priv->matrix, priv->key_rows, priv->key_cols,
+			      priv->ghost_filter);
+	if (ret) {
 		debug("%s: cannot init key matrix\n", __func__);
-		return -1;
+		return ret;
 	}
-	if (key_matrix_decode_fdt(&config.matrix, gd->fdt_blob, node)) {
+	ret = key_matrix_decode_fdt(&priv->matrix, gd->fdt_blob, node);
+	if (ret) {
 		debug("%s: Could not decode key matrix from fdt\n", __func__);
-		return -1;
+		return ret;
 	}
-	config.inited = 1;
-	debug("%s: Matrix keyboard %dx%d ready\n", __func__, config.key_rows,
-	      config.key_cols);
+	debug("%s: Matrix keyboard %dx%d ready\n", __func__, priv->key_rows,
+	      priv->key_cols);
 
-	return 0;
-}
+	priv->input = input;
+	input->dev = dev;
+	input_add_tables(input);
+	input->read_keys = cros_ec_kbc_check;
+	strcpy(sdev->name, "cros-ec-keyb");
 
-int drv_keyboard_init(void)
-{
-	struct stdio_dev dev;
+	/* Register the device. cros_ec_init_keyboard() will be called soon */
+	return input_stdio_register(sdev);
+}
 
-	if (input_init(&config.input, 0)) {
-		debug("%s: Cannot set up input\n", __func__);
-		return -1;
-	}
-	config.input.read_keys = cros_ec_kbc_check;
-	input_add_tables(&config.input);
+static const struct keyboard_ops cros_ec_kbd_ops = {
+};
 
-	memset(&dev, '\0', sizeof(dev));
-	strcpy(dev.name, "cros-ec-keyb");
-	dev.flags = DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
-	dev.getc = kbd_getc;
-	dev.tstc = kbd_tstc;
-	dev.start = cros_ec_init_keyboard;
+static const struct udevice_id cros_ec_kbd_ids[] = {
+	{ .compatible = "google,cros-ec-keyb" },
+	{ }
+};
 
-	/* Register the device. cros_ec_init_keyboard() will be called soon */
-	return input_stdio_register(&dev);
-}
+U_BOOT_DRIVER(cros_ec_kbd) = {
+	.name	= "cros_ec_kbd",
+	.id	= UCLASS_KEYBOARD,
+	.of_match = cros_ec_kbd_ids,
+	.probe = cros_ec_kbd_probe,
+	.ops	= &cros_ec_kbd_ops,
+	.priv_auto_alloc_size = sizeof(struct cros_ec_keyb_priv),
+};
-- 
2.6.0.rc0.131.gf624c3d

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 09/28] video: Drop unused console functions
  2015-09-09  4:32 [U-Boot] [PATCH 00/28] dm: input: Move keyboard drivers to driver model Simon Glass
                   ` (7 preceding siblings ...)
  2015-09-09  4:32 ` [U-Boot] [PATCH 08/28] dm: cros_ec: Convert cros_ec " Simon Glass
@ 2015-09-09  4:32 ` Simon Glass
  2015-09-15  6:11   ` Bin Meng
  2015-09-09  4:32 ` [U-Boot] [PATCH 10/28] i8042: Use functions to handle register access Simon Glass
                   ` (18 subsequent siblings)
  27 siblings, 1 reply; 60+ messages in thread
From: Simon Glass @ 2015-09-09  4:32 UTC (permalink / raw)
  To: u-boot

CONFIG_CONSOLE_CURSOR, CONFIG_SYS_CONSOLE_BLINK_COUNT and
CONFIG_CONSOLE_TIME are not used by any board. The implementation is not
great and stands in the way of a refactor of i8042. Drop these for now.
They can be re-introduced quite easily later, perhaps with driver model
RTC support.

When reintroducing, it might be useful to make a few changes:
- Blink time would be more useful than blink count
- The confusing #ifdefs should be avoided
- The time functions should support driver model
- It would be best keyed off console_tstc() or some similar idle loop
    rather than a particular input driver (i8042 in this case)

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 README                        |  7 -----
 drivers/input/i8042.c         | 23 ----------------
 drivers/video/cfb_console.c   | 62 +++++++------------------------------------
 include/configs/MPC8536DS.h   |  1 -
 include/configs/MPC8544DS.h   |  1 -
 include/configs/MPC8572DS.h   |  1 -
 include/configs/MPC8641HPCN.h |  1 -
 7 files changed, 9 insertions(+), 87 deletions(-)

diff --git a/README b/README
index 08f2f70..54c1d08 100644
--- a/README
+++ b/README
@@ -890,13 +890,6 @@ The following options need to be configured:
 						(i.e. i8042_tstc)
 			VIDEO_GETC_FCT		get char fct
 						(i.e. i8042_getc)
-			CONFIG_CONSOLE_CURSOR	cursor drawing on/off
-						(requires blink timer
-						cf. i8042.c)
-			CONFIG_SYS_CONSOLE_BLINK_COUNT blink interval (cf. i8042.c)
-			CONFIG_CONSOLE_TIME	display time/date info in
-						upper right corner
-						(requires CONFIG_CMD_DATE)
 			CONFIG_VIDEO_LOGO	display Linux logo in
 						upper left corner
 			CONFIG_VIDEO_BMP_LOGO	use bmp_logo.h instead of
diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c
index 9b5fa32..7b95b21 100644
--- a/drivers/input/i8042.c
+++ b/drivers/input/i8042.c
@@ -17,12 +17,6 @@
 #define in8(p)		inb(p)
 #define out8(p, v)	outb(v, p)
 
-#ifdef CONFIG_CONSOLE_CURSOR
-extern void console_cursor(int state);
-static int blink_count = CONFIG_SYS_CONSOLE_BLINK_COUNT;
-static int cursor_state;
-#endif
-
 /* locals */
 
 static int kbd_input = -1;		/* no input yet */
@@ -598,15 +592,6 @@ int i8042_tstc(struct stdio_dev *dev)
 {
 	unsigned char scan_code = 0;
 
-#ifdef CONFIG_CONSOLE_CURSOR
-	if (--blink_count == 0) {
-		cursor_state ^= 1;
-		console_cursor(cursor_state);
-		blink_count = CONFIG_SYS_CONSOLE_BLINK_COUNT;
-		udelay(10);
-	}
-#endif
-
 	if ((in8(I8042_STS_REG) & STATUS_OBF) == 0) {
 		return 0;
 	} else {
@@ -635,14 +620,6 @@ int i8042_getc(struct stdio_dev *dev)
 
 	while (kbd_input == -1) {
 		while ((in8(I8042_STS_REG) & STATUS_OBF) == 0) {
-#ifdef CONFIG_CONSOLE_CURSOR
-			if (--blink_count == 0) {
-				cursor_state ^= 1;
-				console_cursor(cursor_state);
-				blink_count = CONFIG_SYS_CONSOLE_BLINK_COUNT;
-			}
-			udelay(10);
-#endif
 		}
 		scan_code = in8(I8042_DATA_REG);
 		if (scan_code != 0xfa)
diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c
index aa7ca86..1b5c3e0 100644
--- a/drivers/video/cfb_console.c
+++ b/drivers/video/cfb_console.c
@@ -43,13 +43,6 @@
  * VIDEO_TSTC_FCT	      - keyboard_tstc function
  * VIDEO_GETC_FCT	      - keyboard_getc function
  *
- * CONFIG_CONSOLE_CURSOR      - on/off drawing cursor is done with
- *				delay loop in VIDEO_TSTC_FCT (i8042)
- *
- * CONFIG_SYS_CONSOLE_BLINK_COUNT - value for delay loop - blink rate
- * CONFIG_CONSOLE_TIME	      - display time/date in upper right
- *				corner, needs CONFIG_CMD_DATE and
- *				CONFIG_CONSOLE_CURSOR
  * CONFIG_VIDEO_LOGO	      - display Linux Logo in upper left corner.
  *				Use CONFIG_SPLASH_SCREEN_ALIGN with
  *				environment variable "splashpos" to place
@@ -198,9 +191,6 @@
 
 /*
  * Cursor definition:
- * CONFIG_CONSOLE_CURSOR:  Uses a timer function (see drivers/input/i8042.c)
- *			   to let the cursor blink. Uses the macros
- *			   CURSOR_OFF and CURSOR_ON.
  * CONFIG_VIDEO_SW_CURSOR: Draws a cursor after the last character. No
  *			   blinking is provided. Uses the macros CURSOR_SET
  *			   and CURSOR_OFF.
@@ -210,42 +200,29 @@
  *			   must disable the hardware register of the graphic
  *			   chip. Otherwise a blinking field is displayed
  */
-#if !defined(CONFIG_CONSOLE_CURSOR) && \
-    !defined(CONFIG_VIDEO_SW_CURSOR) && \
-    !defined(CONFIG_VIDEO_HW_CURSOR)
+#if !defined(CONFIG_VIDEO_SW_CURSOR) && !defined(CONFIG_VIDEO_HW_CURSOR)
 /* no Cursor defined */
 #define CURSOR_ON
 #define CURSOR_OFF
 #define CURSOR_SET
 #endif
 
-#if defined(CONFIG_CONSOLE_CURSOR) || defined(CONFIG_VIDEO_SW_CURSOR)
-#if defined(CURSOR_ON) || \
-	(defined(CONFIG_CONSOLE_CURSOR) && defined(CONFIG_VIDEO_SW_CURSOR))
-#error	only one of CONFIG_CONSOLE_CURSOR, CONFIG_VIDEO_SW_CURSOR, \
-	or CONFIG_VIDEO_HW_CURSOR can be defined
+#if defined(CONFIG_VIDEO_SW_CURSOR)
+#if defined(CONFIG_VIDEO_HW_CURSOR)
+#error	only one of CONFIG_VIDEO_SW_CURSOR or CONFIG_VIDEO_HW_CURSOR can be \
+	defined
 #endif
 void console_cursor(int state);
 
 #define CURSOR_ON  console_cursor(1)
 #define CURSOR_OFF console_cursor(0)
 #define CURSOR_SET video_set_cursor()
-#endif /* CONFIG_CONSOLE_CURSOR || CONFIG_VIDEO_SW_CURSOR */
-
-#ifdef	CONFIG_CONSOLE_CURSOR
-#ifndef	CONFIG_CONSOLE_TIME
-#error	CONFIG_CONSOLE_CURSOR must be defined for CONFIG_CONSOLE_TIME
-#endif
-#ifndef CONFIG_I8042_KBD
-#warning Cursor drawing on/off needs timer function s.a. drivers/input/i8042.c
-#endif
-#endif /* CONFIG_CONSOLE_CURSOR */
-
+#endif /* CONFIG_VIDEO_SW_CURSOR */
 
 #ifdef CONFIG_VIDEO_HW_CURSOR
 #ifdef	CURSOR_ON
-#error	only one of CONFIG_CONSOLE_CURSOR, CONFIG_VIDEO_SW_CURSOR, \
-	or CONFIG_VIDEO_HW_CURSOR can be defined
+#error	only one of CONFIG_VIDEO_SW_CURSOR or CONFIG_VIDEO_HW_CURSOR can be \
+	defined
 #endif
 #define CURSOR_ON
 #define CURSOR_OFF
@@ -626,7 +603,7 @@ static void video_putchar(int xx, int yy, unsigned char c)
 	video_drawchars(xx, yy + video_logo_height, &c, 1);
 }
 
-#if defined(CONFIG_CONSOLE_CURSOR) || defined(CONFIG_VIDEO_SW_CURSOR)
+#if defined(CONFIG_VIDEO_SW_CURSOR)
 static void video_set_cursor(void)
 {
 	if (cursor_state)
@@ -651,27 +628,6 @@ static void video_invertchar(int xx, int yy)
 
 void console_cursor(int state)
 {
-#ifdef CONFIG_CONSOLE_TIME
-	struct rtc_time tm;
-	char info[16];
-
-	/* time update only if cursor is on (faster scroll) */
-	if (state) {
-		rtc_get(&tm);
-
-		sprintf(info, " %02d:%02d:%02d ", tm.tm_hour, tm.tm_min,
-			tm.tm_sec);
-		video_drawstring(VIDEO_VISIBLE_COLS - 10 * VIDEO_FONT_WIDTH,
-				 VIDEO_INFO_Y, (uchar *) info);
-
-		sprintf(info, "%02d.%02d.%04d", tm.tm_mday, tm.tm_mon,
-			tm.tm_year);
-		video_drawstring(VIDEO_VISIBLE_COLS - 10 * VIDEO_FONT_WIDTH,
-				 VIDEO_INFO_Y + 1 * VIDEO_FONT_HEIGHT,
-				 (uchar *) info);
-	}
-#endif
-
 	if (cursor_state != state) {
 		if (cursor_state) {
 			/* turn off the cursor */
diff --git a/include/configs/MPC8536DS.h b/include/configs/MPC8536DS.h
index 1312438..fad7215 100644
--- a/include/configs/MPC8536DS.h
+++ b/include/configs/MPC8536DS.h
@@ -533,7 +533,6 @@
 #define CONFIG_VGA_AS_SINGLE_DEVICE
 #define CONFIG_ATI_RADEON_FB
 #define CONFIG_VIDEO_LOGO
-/*#define CONFIG_CONSOLE_CURSOR*/
 #define CONFIG_SYS_ISA_IO_BASE_ADDRESS CONFIG_SYS_PCIE3_IO_VIRT
 #endif
 
diff --git a/include/configs/MPC8544DS.h b/include/configs/MPC8544DS.h
index 67fac70..79f402e 100644
--- a/include/configs/MPC8544DS.h
+++ b/include/configs/MPC8544DS.h
@@ -298,7 +298,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);
 #define CONFIG_VGA_AS_SINGLE_DEVICE
 #define CONFIG_ATI_RADEON_FB
 #define CONFIG_VIDEO_LOGO
-/*#define CONFIG_CONSOLE_CURSOR*/
 #define CONFIG_SYS_ISA_IO_BASE_ADDRESS VIDEO_IO_OFFSET
 #endif
 
diff --git a/include/configs/MPC8572DS.h b/include/configs/MPC8572DS.h
index f3334ad..d1f2e66 100644
--- a/include/configs/MPC8572DS.h
+++ b/include/configs/MPC8572DS.h
@@ -496,7 +496,6 @@
 #define CONFIG_VGA_AS_SINGLE_DEVICE
 #define CONFIG_ATI_RADEON_FB
 #define CONFIG_VIDEO_LOGO
-/*#define CONFIG_CONSOLE_CURSOR*/
 #define CONFIG_SYS_ISA_IO_BASE_ADDRESS VIDEO_IO_OFFSET
 #endif
 
diff --git a/include/configs/MPC8641HPCN.h b/include/configs/MPC8641HPCN.h
index f20ee79..3e23bcf 100644
--- a/include/configs/MPC8641HPCN.h
+++ b/include/configs/MPC8641HPCN.h
@@ -404,7 +404,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);
 #define CONFIG_VGA_AS_SINGLE_DEVICE
 #define CONFIG_ATI_RADEON_FB
 #define CONFIG_VIDEO_LOGO
-/*#define CONFIG_CONSOLE_CURSOR*/
 #define CONFIG_SYS_ISA_IO_BASE_ADDRESS CONFIG_SYS_PCIE2_IO_VIRT
 #endif
 
-- 
2.6.0.rc0.131.gf624c3d

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 10/28] i8042: Use functions to handle register access
  2015-09-09  4:32 [U-Boot] [PATCH 00/28] dm: input: Move keyboard drivers to driver model Simon Glass
                   ` (8 preceding siblings ...)
  2015-09-09  4:32 ` [U-Boot] [PATCH 09/28] video: Drop unused console functions Simon Glass
@ 2015-09-09  4:32 ` Simon Glass
  2015-09-15  6:12   ` Bin Meng
  2015-09-09  4:32 ` [U-Boot] [PATCH 11/28] i8042: Handle a duplicate power-on-reset response Simon Glass
                   ` (17 subsequent siblings)
  27 siblings, 1 reply; 60+ messages in thread
From: Simon Glass @ 2015-09-09  4:32 UTC (permalink / raw)
  To: u-boot

At present the register access in kbd_reset() is quite primitive. This makes
it hard to follow.

Create functions to read and write data, both to a single register, and via
the command/data approach.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/input/i8042.c | 75 ++++++++++++++++++++++++++++++---------------------
 1 file changed, 44 insertions(+), 31 deletions(-)

diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c
index 7b95b21..dbd4b00 100644
--- a/drivers/input/i8042.c
+++ b/drivers/input/i8042.c
@@ -446,53 +446,66 @@ static void kbd_conv_char(unsigned char scan_code)
 	return;
 }
 
-static int kbd_reset(void)
+static int kbd_write(int reg, int value)
 {
-	u8 config;
-
-	/* controller self test */
-	if (kbd_input_empty() == 0)
-		return -1;
-	out8(I8042_CMD_REG, CMD_SELF_TEST);
-	if (kbd_output_full() == 0)
-		return -1;
-	if (in8(I8042_DATA_REG) != KBC_TEST_OK)
+	if (!kbd_input_empty())
 		return -1;
+	out8(reg, value);
 
-	/* keyboard reset */
-	if (kbd_input_empty() == 0)
+	return 0;
+}
+
+static int kbd_read(int reg)
+{
+	if (!kbd_output_full())
 		return -1;
-	out8(I8042_DATA_REG, CMD_RESET_KBD);
-	if (kbd_output_full() == 0)
+
+	return in8(reg);
+}
+
+static int kbd_cmd_read(int cmd)
+{
+	if (kbd_write(I8042_CMD_REG, cmd))
 		return -1;
-	if (in8(I8042_DATA_REG) != KBD_ACK)
+
+	return kbd_read(I8042_DATA_REG);
+}
+
+static int kbd_cmd_write(int cmd, int data)
+{
+	if (kbd_write(I8042_CMD_REG, cmd))
 		return -1;
-	if (kbd_output_full() == 0)
+
+	return kbd_write(I8042_DATA_REG, data);
+}
+
+static int kbd_reset(void)
+{
+	int config;
+
+	/* controller self test */
+	if (kbd_cmd_read(CMD_SELF_TEST) != KBC_TEST_OK)
 		return -1;
-	if (in8(I8042_DATA_REG) != KBD_POR)
+
+	/* keyboard reset */
+	if (kbd_write(I8042_DATA_REG, CMD_RESET_KBD) ||
+	    kbd_read(I8042_DATA_REG) != KBD_ACK ||
+	    kbd_read(I8042_DATA_REG) != KBD_POR)
 		return -1;
 
 	/* set AT translation and disable irq */
-	if (kbd_input_empty() == 0)
-		return -1;
-	out8(I8042_CMD_REG, CMD_RD_CONFIG);
-	if (kbd_output_full() == 0)
+	config = kbd_cmd_read(CMD_RD_CONFIG);
+	if (config == -1)
 		return -1;
-	config = in8(I8042_DATA_REG);
+
 	config |= CONFIG_AT_TRANS;
 	config &= ~(CONFIG_KIRQ_EN | CONFIG_MIRQ_EN);
-	if (kbd_input_empty() == 0)
+	if (kbd_cmd_write(CMD_WR_CONFIG, config))
 		return -1;
-	out8(I8042_CMD_REG, CMD_WR_CONFIG);
-	if (kbd_input_empty() == 0)
-		return -1;
-	out8(I8042_DATA_REG, config);
 
 	/* enable keyboard */
-	if (kbd_input_empty() == 0)
-		return -1;
-	out8(I8042_CMD_REG, CMD_KBD_EN);
-	if (kbd_input_empty() == 0)
+	if (kbd_write(I8042_CMD_REG, CMD_KBD_EN) ||
+	    !kbd_input_empty())
 		return -1;
 
 	return 0;
-- 
2.6.0.rc0.131.gf624c3d

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 11/28] i8042: Handle a duplicate power-on-reset response
  2015-09-09  4:32 [U-Boot] [PATCH 00/28] dm: input: Move keyboard drivers to driver model Simon Glass
                   ` (9 preceding siblings ...)
  2015-09-09  4:32 ` [U-Boot] [PATCH 10/28] i8042: Use functions to handle register access Simon Glass
@ 2015-09-09  4:32 ` Simon Glass
  2015-09-15  6:12   ` Bin Meng
  2015-09-09  4:32 ` [U-Boot] [PATCH 12/28] i8042: Adjust kbd_reset() to collect all failures Simon Glass
                   ` (16 subsequent siblings)
  27 siblings, 1 reply; 60+ messages in thread
From: Simon Glass @ 2015-09-09  4:32 UTC (permalink / raw)
  To: u-boot

Sometimes we seem to get 0xaa twice which causes the config read to fail.
This causes chromebook_link to fail to set up the keyboard.

Add a check for this and read the config again when detected.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/input/i8042.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c
index dbd4b00..c6a92a2 100644
--- a/drivers/input/i8042.c
+++ b/drivers/input/i8042.c
@@ -497,6 +497,8 @@ static int kbd_reset(void)
 	config = kbd_cmd_read(CMD_RD_CONFIG);
 	if (config == -1)
 		return -1;
+	else if (config == KBD_POR)	/* Sometimes get a second byte */
+		config = kbd_cmd_read(CMD_RD_CONFIG);
 
 	config |= CONFIG_AT_TRANS;
 	config &= ~(CONFIG_KIRQ_EN | CONFIG_MIRQ_EN);
-- 
2.6.0.rc0.131.gf624c3d

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 12/28] i8042: Adjust kbd_reset() to collect all failures
  2015-09-09  4:32 [U-Boot] [PATCH 00/28] dm: input: Move keyboard drivers to driver model Simon Glass
                   ` (10 preceding siblings ...)
  2015-09-09  4:32 ` [U-Boot] [PATCH 11/28] i8042: Handle a duplicate power-on-reset response Simon Glass
@ 2015-09-09  4:32 ` Simon Glass
  2015-09-15  6:12   ` Bin Meng
  2015-09-09  4:32 ` [U-Boot] [PATCH 13/28] i8042: Adjust keyboard init to assume success Simon Glass
                   ` (15 subsequent siblings)
  27 siblings, 1 reply; 60+ messages in thread
From: Simon Glass @ 2015-09-09  4:32 UTC (permalink / raw)
  To: u-boot

Rather than lots of 'return' statements, use goto to a single return.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/input/i8042.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c
index c6a92a2..ef01bd0 100644
--- a/drivers/input/i8042.c
+++ b/drivers/input/i8042.c
@@ -485,32 +485,35 @@ static int kbd_reset(void)
 
 	/* controller self test */
 	if (kbd_cmd_read(CMD_SELF_TEST) != KBC_TEST_OK)
-		return -1;
+		goto err;
 
 	/* keyboard reset */
 	if (kbd_write(I8042_DATA_REG, CMD_RESET_KBD) ||
 	    kbd_read(I8042_DATA_REG) != KBD_ACK ||
 	    kbd_read(I8042_DATA_REG) != KBD_POR)
-		return -1;
+		goto err;
 
 	/* set AT translation and disable irq */
 	config = kbd_cmd_read(CMD_RD_CONFIG);
 	if (config == -1)
-		return -1;
+		goto err;
 	else if (config == KBD_POR)	/* Sometimes get a second byte */
 		config = kbd_cmd_read(CMD_RD_CONFIG);
 
 	config |= CONFIG_AT_TRANS;
 	config &= ~(CONFIG_KIRQ_EN | CONFIG_MIRQ_EN);
 	if (kbd_cmd_write(CMD_WR_CONFIG, config))
-		return -1;
+		goto err;
 
 	/* enable keyboard */
 	if (kbd_write(I8042_CMD_REG, CMD_KBD_EN) ||
 	    !kbd_input_empty())
-		return -1;
+		goto err;
 
 	return 0;
+err:
+	debug("%s: Keyboard failure\n", __func__);
+	return -1;
 }
 
 static int kbd_controller_present(void)
-- 
2.6.0.rc0.131.gf624c3d

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 13/28] i8042: Adjust keyboard init to assume success
  2015-09-09  4:32 [U-Boot] [PATCH 00/28] dm: input: Move keyboard drivers to driver model Simon Glass
                   ` (11 preceding siblings ...)
  2015-09-09  4:32 ` [U-Boot] [PATCH 12/28] i8042: Adjust kbd_reset() to collect all failures Simon Glass
@ 2015-09-09  4:32 ` Simon Glass
  2015-09-15  6:12   ` Bin Meng
  2015-09-09  4:32 ` [U-Boot] [PATCH 14/28] input: Correct keycode for Ctrl-Y Simon Glass
                   ` (14 subsequent siblings)
  27 siblings, 1 reply; 60+ messages in thread
From: Simon Glass @ 2015-09-09  4:32 UTC (permalink / raw)
  To: u-boot

Modify i8042_kbd_init() so that the normal pass is sucessful init and
failure exits early. This will make the code easier to extend and is easier
to read.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/input/i8042.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c
index ef01bd0..1c6a31e 100644
--- a/drivers/input/i8042.c
+++ b/drivers/input/i8042.c
@@ -587,18 +587,17 @@ int i8042_kbd_init(void)
 			keymap = KBD_GER;
 	}
 
-	for (try = 0; try < KBD_RESET_TRIES; try++) {
-		if (kbd_reset() == 0) {
-			kbd_mapping = keymap;
-			kbd_flags   = NORMAL;
-			kbd_state   = 0;
-			kbd_led_set();
-
-			return 0;
-		}
+	for (try = 0; kbd_reset() != 0; try++) {
+		if (try >= KBD_RESET_TRIES)
+			return -1;
 	}
 
-	return -1;
+	kbd_mapping = keymap;
+	kbd_flags   = NORMAL;
+	kbd_state   = 0;
+	kbd_led_set();
+
+	return 0;
 }
 
 /*
-- 
2.6.0.rc0.131.gf624c3d

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 14/28] input: Correct keycode for Ctrl-Y
  2015-09-09  4:32 [U-Boot] [PATCH 00/28] dm: input: Move keyboard drivers to driver model Simon Glass
                   ` (12 preceding siblings ...)
  2015-09-09  4:32 ` [U-Boot] [PATCH 13/28] i8042: Adjust keyboard init to assume success Simon Glass
@ 2015-09-09  4:32 ` Simon Glass
  2015-09-09  4:32 ` [U-Boot] [PATCH 15/28] input: Add a few more keyboard keycodes Simon Glass
                   ` (13 subsequent siblings)
  27 siblings, 0 replies; 60+ messages in thread
From: Simon Glass @ 2015-09-09  4:32 UTC (permalink / raw)
  To: u-boot

This code is currently incorrect, perhaps due to a typo. Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/input/input.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/input.c b/drivers/input/input.c
index 0f11ae6..95006a9 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -65,7 +65,7 @@ static unsigned char kbd_shift_xlate[] = {
 static unsigned char kbd_ctrl_xlate[] = {
 	0xff, 0x1b, '1', 0x00, '3', '4', '5', 0x1E,
 	'7', '8', '9', '0', 0x1F, '=', '\b', '\t',	/* 0x00 - 0x0f */
-	0x11, 0x17, 0x05, 0x12, 0x14, 0x18, 0x15, 0x09,
+	0x11, 0x17, 0x05, 0x12, 0x14, 0x19, 0x15, 0x09,
 	0x0f, 0x10, 0x1b, 0x1d, '\n', 0xff, 0x01, 0x13,	/* 0x10 - 0x1f */
 	0x04, 0x06, 0x08, 0x09, 0x0a, 0x0b, 0x0c, ';',
 	'\'', '~', 0x00, 0x1c, 0x1a, 0x18, 0x03, 0x16,	/* 0x20 - 0x2f */
-- 
2.6.0.rc0.131.gf624c3d

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 15/28] input: Add a few more keyboard keycodes
  2015-09-09  4:32 [U-Boot] [PATCH 00/28] dm: input: Move keyboard drivers to driver model Simon Glass
                   ` (13 preceding siblings ...)
  2015-09-09  4:32 ` [U-Boot] [PATCH 14/28] input: Correct keycode for Ctrl-Y Simon Glass
@ 2015-09-09  4:32 ` Simon Glass
  2015-09-15  6:12   ` Bin Meng
  2015-09-09  4:32 ` [U-Boot] [PATCH 16/28] input: Add a function to add a keycode to the existing set Simon Glass
                   ` (12 subsequent siblings)
  27 siblings, 1 reply; 60+ messages in thread
From: Simon Glass @ 2015-09-09  4:32 UTC (permalink / raw)
  To: u-boot

The  slash and * are missing from the keycode tables. Add these so that
these keypad keys can be used.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/input/input.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/input/input.c b/drivers/input/input.c
index 95006a9..ec49d0f 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -43,7 +43,7 @@ static const uchar kbd_plain_xlate[] = {
 	'8',  '9',  '-',  '4',  '5',  '6',  '+',  '1',	/* 0x40 - 0x4f */
 	'2',  '3',  '0',  '.', 0xff, 0xff, 0xff, 0xff,
 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,	/* 0x50 - 0x5F */
-	'\r', 0xff, 0xff
+	'\r', 0xff, '/',  '*',
 };
 
 static unsigned char kbd_shift_xlate[] = {
@@ -59,7 +59,7 @@ static unsigned char kbd_shift_xlate[] = {
 	'8', '9', '-', '4', '5', '6', '+', '1',	/* 0x40 - 0x4f */
 	'2', '3', '0', '.', 0xff, 0xff, 0xff, 0xff, 0xff,
 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,	/* 0x50 - 0x5F */
-	'\r', 0xff, 0xff
+	'\r', 0xff, '/',  '*',
 };
 
 static unsigned char kbd_ctrl_xlate[] = {
@@ -75,7 +75,7 @@ static unsigned char kbd_ctrl_xlate[] = {
 	'8', '9', '-', '4', '5', '6', '+', '1',		/* 0x40 - 0x4f */
 	'2', '3', '0', '.', 0xff, 0xff, 0xff, 0xff,
 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,	/* 0x50 - 0x5F */
-	'\r', 0xff, 0xff
+	'\r', 0xff, '/',  '*',
 };
 
 /*
-- 
2.6.0.rc0.131.gf624c3d

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 16/28] input: Add a function to add a keycode to the existing set
  2015-09-09  4:32 [U-Boot] [PATCH 00/28] dm: input: Move keyboard drivers to driver model Simon Glass
                   ` (14 preceding siblings ...)
  2015-09-09  4:32 ` [U-Boot] [PATCH 15/28] input: Add a few more keyboard keycodes Simon Glass
@ 2015-09-09  4:32 ` Simon Glass
  2015-09-09  4:32 ` [U-Boot] [PATCH 17/28] input: Allow repeat filtering to be disabled Simon Glass
                   ` (11 subsequent siblings)
  27 siblings, 0 replies; 60+ messages in thread
From: Simon Glass @ 2015-09-09  4:32 UTC (permalink / raw)
  To: u-boot

Most keyboards can be scanned to produce a list of the keycodes which are
depressed. With the i8042 keyboard this scanning is done internally and
only the processed results are returned.

In this case, when a key is pressed, a 'make' code is sent. When the key
is released an 'unmake' code is sent. This means that the driver needs to
keep track of which keys are pressed. It also means that any protocol error
can lead to stuck keys.

In order to support this type of keyboard, add a function when can be used
to provide a single keycode and either add it to the list of what is pressed
or remove it from the list. Then the normal input_send_keycodes() function
can be used to actually do the decoding work.

Add debugging to display the ASCII characters written to the input queue
also.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/input/input.c | 46 ++++++++++++++++++++++++++++++++++++++++++----
 include/input.h       | 20 ++++++++++++++++++++
 2 files changed, 62 insertions(+), 4 deletions(-)

diff --git a/drivers/input/input.c b/drivers/input/input.c
index ec49d0f..c7b6d52 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -107,6 +107,7 @@ static int input_queue_ascii(struct input_config *config, int ch)
 			return -1; /* buffer full */
 		config->fifo_in++;
 	}
+	debug(" {%02x} ", ch);
 	config->fifo[config->fifo_in] = (uchar)ch;
 
 	return 0;
@@ -394,8 +395,8 @@ static int input_keycodes_to_ascii(struct input_config *config,
 	return ch_count;
 }
 
-int input_send_keycodes(struct input_config *config,
-			int keycode[], int num_keycodes)
+static int _input_send_keycodes(struct input_config *config, int keycode[],
+				int num_keycodes, bool do_send)
 {
 	char ch[num_keycodes * ANSI_CHAR_MAX];
 	int count, i, same = 0;
@@ -420,8 +421,10 @@ int input_send_keycodes(struct input_config *config,
 
 	count = input_keycodes_to_ascii(config, keycode, num_keycodes,
 					ch, sizeof(ch), is_repeat ? 0 : same);
-	for (i = 0; i < count; i++)
-		input_queue_ascii(config, ch[i]);
+	if (do_send) {
+		for (i = 0; i < count; i++)
+			input_queue_ascii(config, ch[i]);
+	}
 	delay_ms = is_repeat ?
 			config->repeat_rate_ms :
 			config->repeat_delay_ms;
@@ -431,6 +434,41 @@ int input_send_keycodes(struct input_config *config,
 	return count;
 }
 
+int input_send_keycodes(struct input_config *config, int keycode[],
+			int num_keycodes)
+{
+	return _input_send_keycodes(config, keycode, num_keycodes, true);
+}
+
+int input_add_keycode(struct input_config *config, int new_keycode,
+		      bool release)
+{
+	int keycode[INPUT_MAX_MODIFIERS + 1];
+	int count, i;
+
+	/* Add the old keycodes which are not removed by this new one */
+	for (i = 0, count = 0; i < config->num_prev_keycodes; i++) {
+		int code = config->prev_keycodes[i];
+
+		if (new_keycode == code) {
+			if (release)
+				continue;
+			new_keycode = -1;
+		}
+		keycode[count++] = code;
+	}
+
+	if (!release && new_keycode != -1)
+		keycode[count++] = new_keycode;
+	debug("\ncodes for %02x/%d: ", new_keycode, release);
+	for (i = 0; i < count; i++)
+		debug("%02x ", keycode[i]);
+	debug("\n");
+
+	/* Don't output any ASCII characters if this is a key release */
+	return _input_send_keycodes(config, keycode, count, !release);
+}
+
 int input_add_table(struct input_config *config, int left_keycode,
 		    int right_keycode, const uchar *xlate, int num_entries)
 {
diff --git a/include/input.h b/include/input.h
index 71f3538..9942d6f 100644
--- a/include/input.h
+++ b/include/input.h
@@ -76,6 +76,26 @@ struct stdio_dev;
 int input_send_keycodes(struct input_config *config, int keycode[], int count);
 
 /**
+ * Add a new keycode to an existing list of keycodes
+ *
+ * This can be used to handle keyboards which do their own scanning. An
+ * internal list of depressed keys is maintained by the input library. Then
+ * this function is called to add a new key to the list (when a 'make code' is
+ * received), or remove a key (when a 'break code' is received).
+ *
+ * This function looks after maintenance of the list of active keys, and calls
+ * input_send_keycodes() with its updated list.
+ *
+ * @param config	Input state
+ * @param new_keycode	New keycode to add/remove
+ * @param release	true if this key was released, false if depressed
+ * @return number of ascii characters sent, or 0 if none, or -1 for an
+ *	internal error
+ */
+int input_add_keycode(struct input_config *config, int new_keycode,
+		      bool release);
+
+/**
  * Add a new key translation table to the input
  *
  * @param config	Input state
-- 
2.6.0.rc0.131.gf624c3d

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 17/28] input: Allow repeat filtering to be disabled
  2015-09-09  4:32 [U-Boot] [PATCH 00/28] dm: input: Move keyboard drivers to driver model Simon Glass
                   ` (15 preceding siblings ...)
  2015-09-09  4:32 ` [U-Boot] [PATCH 16/28] input: Add a function to add a keycode to the existing set Simon Glass
@ 2015-09-09  4:32 ` Simon Glass
  2015-10-30 20:24   ` Simon Glass
  2015-09-09  4:32 ` [U-Boot] [PATCH 18/28] input: Support the German keymap Simon Glass
                   ` (10 subsequent siblings)
  27 siblings, 1 reply; 60+ messages in thread
From: Simon Glass @ 2015-09-09  4:32 UTC (permalink / raw)
  To: u-boot

Generally the input library handles processing of a list of scanned keys.
Repeated keys need to be generated based on a timer in this case, since all
that is provided is a list of keys current depressed.

Keyboards which do their own scanning will resend codes when they want to
inject a repeating key. Provide a function which tells the input library to
accept repeating keys and not to try to second-guess the caller.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/input/input.c |  9 +++++++--
 include/input.h       | 19 +++++++++++++++++++
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/drivers/input/input.c b/drivers/input/input.c
index c7b6d52..c488f3a 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -413,8 +413,8 @@ static int _input_send_keycodes(struct input_config *config, int keycode[],
 		 * insert another character if we later realise that we
 		 * have missed a repeat slot.
 		 */
-		is_repeat = config->repeat_rate_ms &&
-			(int)get_timer(config->next_repeat_ms) >= 0;
+		is_repeat = config->allow_repeats || (config->repeat_rate_ms &&
+			(int)get_timer(config->next_repeat_ms) >= 0);
 		if (!is_repeat)
 			return 0;
 	}
@@ -495,6 +495,11 @@ void input_set_delays(struct input_config *config, int repeat_delay_ms,
 	config->repeat_rate_ms = repeat_rate_ms;
 }
 
+void input_allow_repeats(struct input_config *config, bool allow_repeats)
+{
+	config->allow_repeats = allow_repeats;
+}
+
 int input_add_tables(struct input_config *config)
 {
 	input_add_table(config, -1, -1,
diff --git a/include/input.h b/include/input.h
index 9942d6f..e56f500 100644
--- a/include/input.h
+++ b/include/input.h
@@ -57,6 +57,7 @@ struct input_config {
 	 *		unknown
 	 */
 	int (*read_keys)(struct input_config *config);
+	bool allow_repeats;		/* Don't filter out repeats */
 	unsigned int next_repeat_ms;	/* Next time we repeat a key */
 	unsigned int repeat_delay_ms;	/* Time before autorepeat starts */
 	unsigned int repeat_rate_ms;	/* Autorepeat rate in ms */
@@ -143,6 +144,24 @@ void input_set_delays(struct input_config *config, int repeat_delay_ms,
 	       int repeat_rate_ms);
 
 /**
+ * Tell the input layer whether to allow the caller to determine repeats
+ *
+ * Generally the input library handles processing of a list of scanned keys.
+ * Repeated keys need to be generated based on a timer in this case, since all
+ * that is provided is a list of keys current depressed.
+ *
+ * Keyboards which do their own scanning will resend codes when they want to
+ * inject a repeating key. This function can be called at start-up to select
+ * this behaviour.
+ *
+ * @param config	Input state
+ * @param allow_repeats	true to repeat depressed keys every time
+ *			input_send_keycodes() is called, false to do normal
+ *			keyboard repeat processing with a timer.
+ */
+void input_allow_repeats(struct input_config *config, bool allow_repeats);
+
+/**
  * Set up the key map tables
  *
  * This must be called after input_init() or keycode decoding will not work.
-- 
2.6.0.rc0.131.gf624c3d

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 18/28] input: Support the German keymap
  2015-09-09  4:32 [U-Boot] [PATCH 00/28] dm: input: Move keyboard drivers to driver model Simon Glass
                   ` (16 preceding siblings ...)
  2015-09-09  4:32 ` [U-Boot] [PATCH 17/28] input: Allow repeat filtering to be disabled Simon Glass
@ 2015-09-09  4:32 ` Simon Glass
  2015-09-15  6:12   ` Bin Meng
  2015-09-09  4:32 ` [U-Boot] [PATCH 19/28] input: Adjust structure of code in process_modifier() Simon Glass
                   ` (9 subsequent siblings)
  27 siblings, 1 reply; 60+ messages in thread
From: Simon Glass @ 2015-09-09  4:32 UTC (permalink / raw)
  To: u-boot

Add support for the German keymap, taken from i8042.c. This can be selected
when the input library it initialised.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 board/kosagi/novena/novena.c |  2 +-
 drivers/input/cros_ec_keyb.c |  2 +-
 drivers/input/input.c        | 82 ++++++++++++++++++++++++++++++++++++++++----
 drivers/input/tegra-kbc.c    |  2 +-
 include/input.h              |  3 +-
 5 files changed, 80 insertions(+), 11 deletions(-)

diff --git a/board/kosagi/novena/novena.c b/board/kosagi/novena/novena.c
index 48cbb0f..0b61365 100644
--- a/board/kosagi/novena/novena.c
+++ b/board/kosagi/novena/novena.c
@@ -88,7 +88,7 @@ int drv_keyboard_init(void)
 		debug("%s: Cannot set up input\n", __func__);
 		return -1;
 	}
-	input_add_tables(&button_input);
+	input_add_tables(&button_input, false);
 	button_input.read_keys = novena_gpio_button_read_keys;
 
 	error = input_stdio_register(&dev);
diff --git a/drivers/input/cros_ec_keyb.c b/drivers/input/cros_ec_keyb.c
index fe5caea..9bc4555 100644
--- a/drivers/input/cros_ec_keyb.c
+++ b/drivers/input/cros_ec_keyb.c
@@ -211,7 +211,7 @@ static int cros_ec_kbd_probe(struct udevice *dev)
 
 	priv->input = input;
 	input->dev = dev;
-	input_add_tables(input);
+	input_add_tables(input, false);
 	input->read_keys = cros_ec_kbc_check;
 	strcpy(sdev->name, "cros-ec-keyb");
 
diff --git a/drivers/input/input.c b/drivers/input/input.c
index c488f3a..a54449e 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -78,6 +78,60 @@ static unsigned char kbd_ctrl_xlate[] = {
 	'\r', 0xff, '/',  '*',
 };
 
+static const uchar kbd_plain_xlate_german[] = {
+	0xff, 0x1b,  '1',  '2',  '3',  '4',  '5',  '6', /* scan 00-07 */
+	 '7',  '8',  '9',  '0', 0xe1, '\'', 0x08, '\t', /* scan 08-0F */
+	 'q',  'w',  'e',  'r',  't',  'z',  'u',  'i', /* scan 10-17 */
+	 'o',  'p', 0x81,  '+', '\r', 0xff,  'a',  's', /* scan 18-1F */
+	 'd',  'f',  'g',  'h',  'j',  'k',  'l', 0x94, /* scan 20-27 */
+	0x84,  '^', 0xff,  '#',  'y',  'x',  'c',  'v', /* scan 28-2F */
+	 'b',  'n',  'm',  ',',  '.',  '-', 0xff,  '*', /* scan 30-37 */
+	 ' ',  ' ', 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 38-3F */
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,  '7', /* scan 40-47 */
+	 '8',  '9',  '-',  '4',  '5',  '6',  '+',  '1', /* scan 48-4F */
+	 '2',  '3',  '0',  ',', 0xff, 0xff,  '<', 0xff, /* scan 50-57 */
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 58-5F */
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 60-67 */
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 68-6F */
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 70-77 */
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 78-7F */
+	'\r', 0xff,  '/',  '*',
+};
+
+static unsigned char kbd_shift_xlate_german[] = {
+	   0xff, 0x1b,  '!',  '"', 0x15,  '$',  '%',  '&', /* scan 00-07 */
+	 '/',  '(',  ')',  '=',  '?',  '`', 0x08, '\t', /* scan 08-0F */
+	 'Q',  'W',  'E',  'R',  'T',  'Z',  'U',  'I', /* scan 10-17 */
+	 'O',  'P', 0x9a,  '*', '\r', 0xff,  'A',  'S', /* scan 18-1F */
+	 'D',  'F',  'G',  'H',  'J',  'K',  'L', 0x99, /* scan 20-27 */
+	0x8e, 0xf8, 0xff, '\'',  'Y',  'X',  'C',  'V', /* scan 28-2F */
+	 'B',  'N',  'M',  ';',  ':',  '_', 0xff,  '*', /* scan 30-37 */
+	 ' ',  ' ', 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 38-3F */
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,  '7', /* scan 40-47 */
+	 '8',  '9',  '-',  '4',  '5',  '6',  '+',  '1', /* scan 48-4F */
+	 '2',  '3',  '0',  ',', 0xff, 0xff,  '>', 0xff, /* scan 50-57 */
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 58-5F */
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 60-67 */
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 68-6F */
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 70-77 */
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 78-7F */
+	'\r', 0xff,  '/',  '*',
+};
+
+static unsigned char kbd_right_alt_xlate_german[] = {
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 00-07 */
+	 '{',  '[',  ']',  '}', '\\', 0xff, 0xff, 0xff, /* scan 08-0F */
+	 '@', 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 10-17 */
+	0xff, 0xff, 0xff,  '~', 0xff, 0xff, 0xff, 0xff, /* scan 18-1F */
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 20-27 */
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 28-2F */
+	0xff, 0xff, 0xe6, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 30-37 */
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 38-3F */
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 40-47 */
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 48-4F */
+	0xff, 0xff, 0xff, 0xff, 0xff, 0xff,  '|', 0xff, /* scan 50-57 */
+};
+
 /*
  * Scan key code to ANSI 3.64 escape sequence table.  This table is
  * incomplete in that it does not include all possible extra keys.
@@ -500,14 +554,28 @@ void input_allow_repeats(struct input_config *config, bool allow_repeats)
 	config->allow_repeats = allow_repeats;
 }
 
-int input_add_tables(struct input_config *config)
+int input_add_tables(struct input_config *config, bool german)
 {
-	input_add_table(config, -1, -1,
-			kbd_plain_xlate, ARRAY_SIZE(kbd_plain_xlate));
-	input_add_table(config, KEY_LEFTSHIFT, KEY_RIGHTSHIFT,
-			kbd_shift_xlate, ARRAY_SIZE(kbd_shift_xlate));
-	input_add_table(config, KEY_LEFTCTRL, KEY_RIGHTCTRL,
-			kbd_ctrl_xlate, ARRAY_SIZE(kbd_ctrl_xlate));
+	if (german) {
+		input_add_table(config, -1, -1,
+				kbd_plain_xlate_german,
+				ARRAY_SIZE(kbd_plain_xlate_german));
+		input_add_table(config, KEY_LEFTSHIFT, KEY_RIGHTSHIFT,
+				kbd_shift_xlate_german,
+				ARRAY_SIZE(kbd_shift_xlate_german));
+		input_add_table(config, KEY_LEFTCTRL, KEY_RIGHTCTRL,
+				kbd_ctrl_xlate, ARRAY_SIZE(kbd_ctrl_xlate));
+	} else {
+		input_add_table(config, -1, -1,
+				kbd_plain_xlate, ARRAY_SIZE(kbd_plain_xlate));
+		input_add_table(config, KEY_LEFTSHIFT, KEY_RIGHTSHIFT,
+				kbd_shift_xlate, ARRAY_SIZE(kbd_shift_xlate));
+		input_add_table(config, KEY_LEFTCTRL, KEY_RIGHTCTRL,
+				kbd_ctrl_xlate, ARRAY_SIZE(kbd_ctrl_xlate));
+		input_add_table(config, -1, KEY_RIGHTALT,
+				kbd_right_alt_xlate_german,
+				ARRAY_SIZE(kbd_right_alt_xlate_german));
+	}
 
 	return 0;
 }
diff --git a/drivers/input/tegra-kbc.c b/drivers/input/tegra-kbc.c
index a7137f1..951cbb4 100644
--- a/drivers/input/tegra-kbc.c
+++ b/drivers/input/tegra-kbc.c
@@ -326,7 +326,7 @@ static int tegra_kbd_probe(struct udevice *dev)
 	priv->input = input;
 	input->dev = dev;
 	input->read_keys = tegra_kbc_check;
-	input_add_tables(input);
+	input_add_tables(input, false);
 	strcpy(sdev->name, "tegra-kbc");
 	ret = input_stdio_register(sdev);
 	if (ret) {
diff --git a/include/input.h b/include/input.h
index e56f500..c1af259 100644
--- a/include/input.h
+++ b/include/input.h
@@ -167,9 +167,10 @@ void input_allow_repeats(struct input_config *config, bool allow_repeats);
  * This must be called after input_init() or keycode decoding will not work.
  *
  * @param config	Input state
+ * @param german	true to use German keyboard layout, false for US
  * @return 0 if ok, -1 on error
  */
-int input_add_tables(struct input_config *config);
+int input_add_tables(struct input_config *config, bool german);
 
 /**
  * Set up the input handler with basic key maps.
-- 
2.6.0.rc0.131.gf624c3d

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 19/28] input: Adjust structure of code in process_modifier()
  2015-09-09  4:32 [U-Boot] [PATCH 00/28] dm: input: Move keyboard drivers to driver model Simon Glass
                   ` (17 preceding siblings ...)
  2015-09-09  4:32 ` [U-Boot] [PATCH 18/28] input: Support the German keymap Simon Glass
@ 2015-09-09  4:32 ` Simon Glass
  2015-09-09  4:32 ` [U-Boot] [PATCH 20/28] input: Handle caps lock Simon Glass
                   ` (8 subsequent siblings)
  27 siblings, 0 replies; 60+ messages in thread
From: Simon Glass @ 2015-09-09  4:32 UTC (permalink / raw)
  To: u-boot

Move all the '!release' code into one block so that it is clear that it only
applies on key release.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/input/input.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/input/input.c b/drivers/input/input.c
index a54449e..256845f 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -208,7 +208,6 @@ static struct input_key_xlate *process_modifier(struct input_config *config,
 						int key, int release)
 {
 	struct input_key_xlate *table;
-	int flip = -1;
 	int i;
 
 	/* Start with the main table, and see what modifiers change it */
@@ -223,6 +222,8 @@ static struct input_key_xlate *process_modifier(struct input_config *config,
 
 	/* Handle the lighted keys */
 	if (!release) {
+		int flip = -1;
+
 		switch (key) {
 		case KEY_SCROLLLOCK:
 			flip = FLAG_SCROLL_LOCK;
@@ -234,19 +235,19 @@ static struct input_key_xlate *process_modifier(struct input_config *config,
 			flip = FLAG_CAPS_LOCK;
 			break;
 		}
-	}
 
-	if (flip != -1) {
-		int leds = 0;
-
-		config->leds ^= flip;
-		if (config->flags & FLAG_NUM_LOCK)
-			leds |= INPUT_LED_NUM;
-		if (config->flags & FLAG_CAPS_LOCK)
-			leds |= INPUT_LED_CAPS;
-		if (config->flags & FLAG_SCROLL_LOCK)
-			leds |= INPUT_LED_SCROLL;
-		config->leds = leds;
+		if (flip != -1) {
+			int leds = 0;
+
+			config->leds ^= flip;
+			if (config->flags & FLAG_NUM_LOCK)
+				leds |= INPUT_LED_NUM;
+			if (config->flags & FLAG_CAPS_LOCK)
+				leds |= INPUT_LED_CAPS;
+			if (config->flags & FLAG_SCROLL_LOCK)
+				leds |= INPUT_LED_SCROLL;
+			config->leds = leds;
+		}
 	}
 
 	return table;
-- 
2.6.0.rc0.131.gf624c3d

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 20/28] input: Handle caps lock
  2015-09-09  4:32 [U-Boot] [PATCH 00/28] dm: input: Move keyboard drivers to driver model Simon Glass
                   ` (18 preceding siblings ...)
  2015-09-09  4:32 ` [U-Boot] [PATCH 19/28] input: Adjust structure of code in process_modifier() Simon Glass
@ 2015-09-09  4:32 ` Simon Glass
  2015-09-09  4:32 ` [U-Boot] [PATCH 21/28] input: Allow updating of keyboard LEDs Simon Glass
                   ` (7 subsequent siblings)
  27 siblings, 0 replies; 60+ messages in thread
From: Simon Glass @ 2015-09-09  4:32 UTC (permalink / raw)
  To: u-boot

When caps lock is enabled we should convert lower case to upper case. Add
this to the input key processing so that caps lock works correctly.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/input/input.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/input/input.c b/drivers/input/input.c
index 256845f..c5fd8e9 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -424,16 +424,19 @@ static int input_keycodes_to_ascii(struct input_config *config,
 	/* Start conversion by looking for the first new keycode (by same). */
 	for (i = same; i < num_keycodes; i++) {
 		int key = keycode[i];
-		int ch = (key < table->num_entries) ? table->xlate[key] : 0xff;
+		int ch;
 
 		/*
 		 * For a normal key (with an ASCII value), add it; otherwise
 		 * translate special key to escape sequence if possible.
 		 */
-		if (ch != 0xff) {
-			if (ch_count < max_chars)
-				output_ch[ch_count] = (uchar)ch;
-			ch_count++;
+		if (key < table->num_entries) {
+			ch = table->xlate[key];
+			if ((config->flags & FLAG_CAPS_LOCK) &&
+			    ch >= 'a' && ch <= 'z')
+				ch -= 'a' - 'A';
+			if (ch_count < max_chars && ch != 0xff)
+				output_ch[ch_count++] = (uchar)ch;
 		} else {
 			ch_count += input_keycode_to_ansi364(config, key,
 						output_ch, max_chars);
-- 
2.6.0.rc0.131.gf624c3d

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 21/28] input: Allow updating of keyboard LEDs
  2015-09-09  4:32 [U-Boot] [PATCH 00/28] dm: input: Move keyboard drivers to driver model Simon Glass
                   ` (19 preceding siblings ...)
  2015-09-09  4:32 ` [U-Boot] [PATCH 20/28] input: Handle caps lock Simon Glass
@ 2015-09-09  4:32 ` Simon Glass
  2015-09-09  4:32 ` [U-Boot] [PATCH 22/28] input: i8042: Convert to use the input library Simon Glass
                   ` (6 subsequent siblings)
  27 siblings, 0 replies; 60+ messages in thread
From: Simon Glass @ 2015-09-09  4:32 UTC (permalink / raw)
  To: u-boot

Add a function which returns a new keyboard LED value when the LEDs need
updating.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/input/input.c |  9 +++++++++
 include/input.h       | 14 +++++++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/input/input.c b/drivers/input/input.c
index c5fd8e9..51d7e8f 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -247,6 +247,7 @@ static struct input_key_xlate *process_modifier(struct input_config *config,
 			if (config->flags & FLAG_SCROLL_LOCK)
 				leds |= INPUT_LED_SCROLL;
 			config->leds = leds;
+			config->leds_changed = flip;
 		}
 	}
 
@@ -558,6 +559,14 @@ void input_allow_repeats(struct input_config *config, bool allow_repeats)
 	config->allow_repeats = allow_repeats;
 }
 
+int input_leds_changed(struct input_config *config)
+{
+	if (config->leds_changed)
+		return config->leds;
+
+	return -1;
+}
+
 int input_add_tables(struct input_config *config, bool german)
 {
 	if (german) {
diff --git a/include/input.h b/include/input.h
index c1af259..ad120e4 100644
--- a/include/input.h
+++ b/include/input.h
@@ -43,7 +43,8 @@ struct input_config {
 	/* Which modifiers are active (1 bit for each MOD_... value) */
 	uchar modifiers;
 	uchar flags;		/* active state keys (FLAGS_...) */
-	uchar leds;		/* active LEDS (INPUT_LED_...) */
+	uchar leds;		/* active LEDs (INPUT_LED_...) */
+	uchar leds_changed;	/* LEDs that just changed */
 	uchar num_tables;	/* number of modifier tables */
 	int prev_keycodes[INPUT_BUFFER_LEN];	/* keys held last time */
 	int num_prev_keycodes;	/* number of prev keys */
@@ -162,6 +163,17 @@ void input_set_delays(struct input_config *config, int repeat_delay_ms,
 void input_allow_repeats(struct input_config *config, bool allow_repeats);
 
 /**
+ * Check if keyboard LEDs need to be updated
+ *
+ * This can be called after input_tstc() to see if keyboard LEDs need
+ * updating.
+ *
+ * @param config	Input state
+ * @return -1 if no LEDs need updating, other value if they do
+ */
+int input_leds_changed(struct input_config *config);
+
+/**
  * Set up the key map tables
  *
  * This must be called after input_init() or keycode decoding will not work.
-- 
2.6.0.rc0.131.gf624c3d

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 22/28] input: i8042: Convert to use the input library
  2015-09-09  4:32 [U-Boot] [PATCH 00/28] dm: input: Move keyboard drivers to driver model Simon Glass
                   ` (20 preceding siblings ...)
  2015-09-09  4:32 ` [U-Boot] [PATCH 21/28] input: Allow updating of keyboard LEDs Simon Glass
@ 2015-09-09  4:32 ` Simon Glass
  2015-09-15  6:12   ` Bin Meng
  2015-09-09  4:32 ` [U-Boot] [PATCH 23/28] input: Add a Kconfig option for the i8042 keyboard Simon Glass
                   ` (5 subsequent siblings)
  27 siblings, 1 reply; 60+ messages in thread
From: Simon Glass @ 2015-09-09  4:32 UTC (permalink / raw)
  To: u-boot

At present the i8042 driver has its own logic and keymaps. In an effort to
unify the code, move it over to use the input library. This changes most of
the keycode-processing logic since it is now in that library. The main
responsibilities of the driver are now to handle the LEDs, deal with the
PS/2 extended keycodes and initialise the the keyboard.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/input/i8042.c | 491 +++++++-------------------------------------------
 1 file changed, 70 insertions(+), 421 deletions(-)

diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c
index 1c6a31e..5ebb571 100644
--- a/drivers/input/i8042.c
+++ b/drivers/input/i8042.c
@@ -7,251 +7,18 @@
 
 /* i8042.c - Intel 8042 keyboard driver routines */
 
-/* includes */
-
 #include <common.h>
-#include <asm/io.h>
 #include <i8042.h>
+#include <input.h>
+#include <asm/io.h>
 
 /* defines */
 #define in8(p)		inb(p)
 #define out8(p, v)	outb(v, p)
 
 /* locals */
-
-static int kbd_input = -1;		/* no input yet */
-static int kbd_mapping = KBD_US;	/* default US keyboard */
-static int kbd_flags = NORMAL;		/* after reset */
-static int kbd_state;			/* unshift code */
-
-static unsigned char kbd_fct_map[144] = {
-	/* kbd_fct_map table for scan code */
-	 0,  AS,  AS,  AS,  AS,  AS,  AS,  AS, /* scan 00-07 */
-	AS,  AS,  AS,  AS,  AS,  AS,  AS,  AS, /* scan 08-0F */
-	AS,  AS,  AS,  AS,  AS,  AS,  AS,  AS, /* scan 10-17 */
-	AS,  AS,  AS,  AS,  AS,  CN,  AS,  AS, /* scan 18-1F */
-	AS,  AS,  AS,  AS,  AS,  AS,  AS,  AS, /* scan 20-27 */
-	AS,  AS,  SH,  AS,  AS,  AS,  AS,  AS, /* scan 28-2F */
-	AS,  AS,  AS,  AS,  AS,  AS,  SH,  AS, /* scan 30-37 */
-	AS,  AS,  CP,   0,   0,   0,   0,   0, /* scan 38-3F */
-	 0,   0,   0,   0,   0,  NM,  ST,  ES, /* scan 40-47 */
-	ES,  ES,  ES,  ES,  ES,  ES,  ES,  ES, /* scan 48-4F */
-	ES,  ES,  ES,  ES,   0,   0,  AS,   0, /* scan 50-57 */
-	 0,   0,   0,   0,   0,   0,   0,   0, /* scan 58-5F */
-	 0,   0,   0,   0,   0,   0,   0,   0, /* scan 60-67 */
-	 0,   0,   0,   0,   0,   0,   0,   0, /* scan 68-6F */
-	AS,   0,   0,  AS,   0,   0,  AS,   0, /* scan 70-77 */
-	 0,  AS,   0,   0,   0,  AS,   0,   0, /* scan 78-7F */
-	AS,  CN,  AS,  AS,  AK,  ST,  EX,  EX, /* enhanced */
-	AS,  EX,  EX,  AS,  EX,  AS,  EX,  EX  /* enhanced */
-	};
-
-static unsigned char kbd_key_map[2][5][144] = {
-	{ /* US keyboard */
-	{ /* unshift code */
-	   0, 0x1b,  '1',  '2',  '3',  '4',  '5',  '6', /* scan 00-07 */
-	 '7',  '8',  '9',  '0',  '-',  '=', 0x08, '\t', /* scan 08-0F */
-	 'q',  'w',  'e',  'r',  't',  'y',  'u',  'i', /* scan 10-17 */
-	 'o',  'p',  '[',  ']', '\r',   CN,  'a',  's', /* scan 18-1F */
-	 'd',  'f',  'g',  'h',  'j',  'k',  'l',  ';', /* scan 20-27 */
-	'\'',  '`',   SH, '\\',  'z',  'x',  'c',  'v', /* scan 28-2F */
-	 'b',  'n',  'm',  ',',  '.',  '/',   SH,  '*', /* scan 30-37 */
-	 ' ',  ' ',   CP,    0,    0,    0,    0,    0, /* scan 38-3F */
-	   0,    0,    0,    0,    0,   NM,   ST,  '7', /* scan 40-47 */
-	 '8',  '9',  '-',  '4',  '5',  '6',  '+',  '1', /* scan 48-4F */
-	 '2',  '3',  '0',  '.',    0,    0,    0,    0, /* scan 50-57 */
-	   0,    0,    0,    0,    0,    0,    0,    0, /* scan 58-5F */
-	   0,    0,    0,    0,    0,    0,    0,    0, /* scan 60-67 */
-	   0,    0,    0,    0,    0,    0,    0,    0, /* scan 68-6F */
-	   0,    0,    0,    0,    0,    0,    0,    0, /* scan 70-77 */
-	   0,    0,    0,    0,    0,    0,    0,    0, /* scan 78-7F */
-	'\r',   CN,  '/',  '*',  ' ',   ST,  'F',  'A', /* extended */
-	   0,  'D',  'C',    0,  'B',    0,  '@',  'P'  /* extended */
-	},
-	{ /* shift code */
-	   0, 0x1b,  '!',  '@',  '#',  '$',  '%',  '^', /* scan 00-07 */
-	 '&',  '*',  '(',  ')',  '_',  '+', 0x08, '\t', /* scan 08-0F */
-	 'Q',  'W',  'E',  'R',  'T',  'Y',  'U',  'I', /* scan 10-17 */
-	 'O',  'P',  '{',  '}', '\r',   CN,  'A',  'S', /* scan 18-1F */
-	 'D',  'F',  'G',  'H',  'J',  'K',  'L',  ':', /* scan 20-27 */
-	 '"',  '~',   SH,  '|',  'Z',  'X',  'C',  'V', /* scan 28-2F */
-	 'B',  'N',  'M',  '<',  '>',  '?',   SH,  '*', /* scan 30-37 */
-	 ' ',  ' ',   CP,    0,    0,    0,    0,    0, /* scan 38-3F */
-	   0,    0,    0,    0,    0,   NM,   ST,  '7', /* scan 40-47 */
-	 '8',  '9',  '-',  '4',  '5',  '6',  '+',  '1', /* scan 48-4F */
-	 '2',  '3',  '0',  '.',    0,    0,    0,    0, /* scan 50-57 */
-	   0,    0,    0,    0,    0,    0,    0,    0, /* scan 58-5F */
-	   0,    0,    0,    0,    0,    0,    0,    0, /* scan 60-67 */
-	   0,    0,    0,    0,    0,    0,    0,    0, /* scan 68-6F */
-	   0,    0,    0,    0,    0,    0,    0,    0, /* scan 70-77 */
-	   0,    0,    0,    0,    0,    0,    0,    0, /* scan 78-7F */
-	'\r',   CN,  '/',  '*',  ' ',   ST,  'F',  'A', /* extended */
-	   0,  'D',  'C',    0,  'B',    0,  '@',  'P'  /* extended */
-	},
-	{ /* control code */
-	0xff, 0x1b, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, /* scan 00-07 */
-	0x1e, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, '\t', /* scan 08-0F */
-	0x11, 0x17, 0x05, 0x12, 0x14, 0x19, 0x15, 0x09, /* scan 10-17 */
-	0x0f, 0x10, 0x1b, 0x1d, '\r',   CN, 0x01, 0x13, /* scan 18-1F */
-	0x04, 0x06, 0x07, 0x08, 0x0a, 0x0b, 0x0c, 0xff, /* scan 20-27 */
-	0xff, 0x1c,   SH, 0xff, 0x1a, 0x18, 0x03, 0x16, /* scan 28-2F */
-	0x02, 0x0e, 0x0d, 0xff, 0xff, 0xff,   SH, 0xff, /* scan 30-37 */
-	0xff, 0xff,   CP, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 38-3F */
-	0xff, 0xff, 0xff, 0xff, 0xff,   NM,   ST, 0xff, /* scan 40-47 */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 48-4F */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 50-57 */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 58-5F */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 60-67 */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 68-6F */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 70-77 */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 78-7F */
-	'\r',   CN,  '/',  '*',  ' ',   ST, 0xff, 0xff, /* extended */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff  /* extended */
-	},
-	{ /* non numeric code */
-	   0, 0x1b,  '1',  '2',  '3',  '4',  '5',  '6', /* scan 00-07 */
-	 '7',  '8',  '9',  '0',  '-',  '=', 0x08, '\t', /* scan 08-0F */
-	 'q',  'w',  'e',  'r',  't',  'y',  'u',  'i', /* scan 10-17 */
-	 'o',  'p',  '[',  ']', '\r',   CN,  'a',  's', /* scan 18-1F */
-	 'd',  'f',  'g',  'h',  'j',  'k',  'l',  ';', /* scan 20-27 */
-	'\'',  '`',   SH, '\\',  'z',  'x',  'c',  'v', /* scan 28-2F */
-	 'b',  'n',  'm',  ',',  '.',  '/',   SH,  '*', /* scan 30-37 */
-	 ' ',  ' ',   CP,    0,    0,    0,    0,    0, /* scan 38-3F */
-	   0,    0,    0,    0,    0,   NM,   ST,  'w', /* scan 40-47 */
-	 'x',  'y',  'l',  't',  'u',  'v',  'm',  'q', /* scan 48-4F */
-	 'r',  's',  'p',  'n',    0,    0,    0,    0, /* scan 50-57 */
-	   0,    0,    0,    0,    0,    0,    0,    0, /* scan 58-5F */
-	   0,    0,    0,    0,    0,    0,    0,    0, /* scan 60-67 */
-	   0,    0,    0,    0,    0,    0,    0,    0, /* scan 68-6F */
-	   0,    0,    0,    0,    0,    0,    0,    0, /* scan 70-77 */
-	   0,    0,    0,    0,    0,    0,    0,    0, /* scan 78-7F */
-	'\r',   CN,  '/',  '*',  ' ',   ST,  'F',  'A', /* extended */
-	   0,  'D',  'C',    0,  'B',    0,  '@',  'P'  /* extended */
-	},
-	{ /* right alt mode - not used in US keyboard */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 00-07 */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 08-0F */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 10-17 */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 18-1F */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 20-27 */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 28-2F */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 30-37 */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 38-3F */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 40-47 */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 48-4F */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 50-57 */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 58-5F */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 60-67 */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 68-6F */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 70-77 */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 78-7F */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* extended */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff  /* extended */
-	}
-	},
-	{ /* German keyboard */
-	{ /* unshift code */
-	   0, 0x1b,  '1',  '2',  '3',  '4',  '5',  '6', /* scan 00-07 */
-	 '7',  '8',  '9',  '0', 0xe1, '\'', 0x08, '\t', /* scan 08-0F */
-	 'q',  'w',  'e',  'r',  't',  'z',  'u',  'i', /* scan 10-17 */
-	 'o',  'p', 0x81,  '+', '\r',   CN,  'a',  's', /* scan 18-1F */
-	 'd',  'f',  'g',  'h',  'j',  'k',  'l', 0x94, /* scan 20-27 */
-	0x84,  '^',   SH,  '#',  'y',  'x',  'c',  'v', /* scan 28-2F */
-	 'b',  'n',  'm',  ',',  '.',  '-',   SH,  '*', /* scan 30-37 */
-	 ' ',  ' ',   CP,    0,    0,    0,    0,    0, /* scan 38-3F */
-	   0,    0,    0,    0,    0,   NM,   ST,  '7', /* scan 40-47 */
-	 '8',  '9',  '-',  '4',  '5',  '6',  '+',  '1', /* scan 48-4F */
-	 '2',  '3',  '0',  ',',    0,    0,  '<',    0, /* scan 50-57 */
-	   0,    0,    0,    0,    0,    0,    0,    0, /* scan 58-5F */
-	   0,    0,    0,    0,    0,    0,    0,    0, /* scan 60-67 */
-	   0,    0,    0,    0,    0,    0,    0,    0, /* scan 68-6F */
-	   0,    0,    0,    0,    0,    0,    0,    0, /* scan 70-77 */
-	   0,    0,    0,    0,    0,    0,    0,    0, /* scan 78-7F */
-	'\r',   CN,  '/',  '*',  ' ',   ST,  'F',  'A', /* extended */
-	   0,  'D',  'C',    0,  'B',    0,  '@',  'P'  /* extended */
-	},
-	{ /* shift code */
-	   0, 0x1b,  '!',  '"', 0x15,  '$',  '%',  '&', /* scan 00-07 */
-	 '/',  '(',  ')',  '=',  '?',  '`', 0x08, '\t', /* scan 08-0F */
-	 'Q',  'W',  'E',  'R',  'T',  'Z',  'U',  'I', /* scan 10-17 */
-	 'O',  'P', 0x9a,  '*', '\r',   CN,  'A',  'S', /* scan 18-1F */
-	 'D',  'F',  'G',  'H',  'J',  'K',  'L', 0x99, /* scan 20-27 */
-	0x8e, 0xf8,   SH, '\'',  'Y',  'X',  'C',  'V', /* scan 28-2F */
-	 'B',  'N',  'M',  ';',  ':',  '_',   SH,  '*', /* scan 30-37 */
-	 ' ',  ' ',   CP,    0,    0,    0,    0,    0, /* scan 38-3F */
-	   0,    0,    0,    0,    0,   NM,   ST,  '7', /* scan 40-47 */
-	 '8',  '9',  '-',  '4',  '5',  '6',  '+',  '1', /* scan 48-4F */
-	 '2',  '3',  '0',  ',',    0,    0,  '>',    0, /* scan 50-57 */
-	   0,    0,    0,    0,    0,    0,    0,    0, /* scan 58-5F */
-	   0,    0,    0,    0,    0,    0,    0,    0, /* scan 60-67 */
-	   0,    0,    0,    0,    0,    0,    0,    0, /* scan 68-6F */
-	   0,    0,    0,    0,    0,    0,    0,    0, /* scan 70-77 */
-	   0,    0,    0,    0,    0,    0,    0,    0, /* scan 78-7F */
-	'\r',   CN,  '/',  '*',  ' ',   ST,  'F',  'A', /* extended */
-	   0,  'D',  'C',    0,  'B',    0,  '@',  'P'  /* extended */
-	},
-	{ /* control code */
-	0xff, 0x1b, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, /* scan 00-07 */
-	0x1e, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, '\t', /* scan 08-0F */
-	0x11, 0x17, 0x05, 0x12, 0x14, 0x19, 0x15, 0x09, /* scan 10-17 */
-	0x0f, 0x10, 0x1b, 0x1d, '\r',   CN, 0x01, 0x13, /* scan 18-1F */
-	0x04, 0x06, 0x07, 0x08, 0x0a, 0x0b, 0x0c, 0xff, /* scan 20-27 */
-	0xff, 0x1c,   SH, 0xff, 0x1a, 0x18, 0x03, 0x16, /* scan 28-2F */
-	0x02, 0x0e, 0x0d, 0xff, 0xff, 0xff,   SH, 0xff, /* scan 30-37 */
-	0xff, 0xff,   CP, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 38-3F */
-	0xff, 0xff, 0xff, 0xff, 0xff,   NM,   ST, 0xff, /* scan 40-47 */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 48-4F */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 50-57 */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 58-5F */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 60-67 */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 68-6F */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 70-77 */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 78-7F */
-	'\r',   CN,  '/',  '*',  ' ',   ST, 0xff, 0xff, /* extended */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff  /* extended */
-	},
-	{ /* non numeric code */
-	   0, 0x1b,  '1',  '2',  '3',  '4',  '5',  '6', /* scan 00-07 */
-	 '7',  '8',  '9',  '0', 0xe1, '\'', 0x08, '\t', /* scan 08-0F */
-	 'q',  'w',  'e',  'r',  't',  'z',  'u',  'i', /* scan 10-17 */
-	 'o',  'p', 0x81,  '+', '\r',   CN,  'a',  's', /* scan 18-1F */
-	 'd',  'f',  'g',  'h',  'j',  'k',  'l', 0x94, /* scan 20-27 */
-	0x84,  '^',   SH,    0,  'y',  'x',  'c',  'v', /* scan 28-2F */
-	 'b',  'n',  'm',  ',',  '.',  '-',   SH,  '*', /* scan 30-37 */
-	 ' ',  ' ',   CP,    0,    0,    0,    0,    0, /* scan 38-3F */
-	   0,    0,    0,    0,    0,   NM,   ST,  'w', /* scan 40-47 */
-	 'x',  'y',  'l',  't',  'u',  'v',  'm',  'q', /* scan 48-4F */
-	 'r',  's',  'p',  'n',    0,    0,  '<',    0, /* scan 50-57 */
-	   0,    0,    0,    0,    0,    0,    0,    0, /* scan 58-5F */
-	   0,    0,    0,    0,    0,    0,    0,    0, /* scan 60-67 */
-	   0,    0,    0,    0,    0,    0,    0,    0, /* scan 68-6F */
-	   0,    0,    0,    0,    0,    0,    0,    0, /* scan 70-77 */
-	   0,    0,    0,    0,    0,    0,    0,    0, /* scan 78-7F */
-	'\r',   CN,  '/',  '*',  ' ',   ST,  'F',  'A', /* extended */
-	   0,  'D',  'C',    0,  'B',    0,  '@',  'P'  /* extended */
-	},
-	{ /* right alt mode - is used in German keyboard */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 00-07 */
-	 '{',  '[',  ']',  '}', '\\', 0xff, 0xff, 0xff, /* scan 08-0F */
-	 '@', 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 10-17 */
-	0xff, 0xff, 0xff,  '~', 0xff, 0xff, 0xff, 0xff, /* scan 18-1F */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 20-27 */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 28-2F */
-	0xff, 0xff, 0xe6, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 30-37 */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 38-3F */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 40-47 */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 48-4F */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff,  '|', 0xff, /* scan 50-57 */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 58-5F */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 60-67 */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 68-6F */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 70-77 */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 78-7F */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* extended */
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff  /* extended */
-	}
-	}
-	};
+static struct input_config config;
+static bool extended;
 
 static unsigned char ext_key_map[] = {
 	0x1c, /* keypad enter */
@@ -293,157 +60,12 @@ static int kbd_output_full(void)
 	return kbd_timeout != -1;
 }
 
-static void kbd_led_set(void)
+static void kbd_led_set(int flags)
 {
 	kbd_input_empty();
 	out8(I8042_DATA_REG, CMD_SET_KBD_LED);
 	kbd_input_empty();
-	out8(I8042_DATA_REG, (kbd_flags & 0x7));
-}
-
-static void kbd_normal(unsigned char scan_code)
-{
-	unsigned char chr;
-
-	if ((kbd_flags & BRK) == NORMAL) {
-		chr = kbd_key_map[kbd_mapping][kbd_state][scan_code];
-		if ((chr == 0xff) || (chr == 0x00))
-			return;
-
-		/* if caps lock convert upper to lower */
-		if (((kbd_flags & CAPS) == CAPS) &&
-		    (chr >= 'a' && chr <= 'z')) {
-			chr -= 'a' - 'A';
-		}
-		kbd_input = chr;
-	}
-}
-
-static void kbd_shift(unsigned char scan_code)
-{
-	if ((kbd_flags & BRK) == BRK) {
-		kbd_state = AS;
-		kbd_flags &= (~SHIFT);
-	} else {
-		kbd_state = SH;
-		kbd_flags |= SHIFT;
-	}
-}
-
-static void kbd_ctrl(unsigned char scan_code)
-{
-	if ((kbd_flags & BRK) == BRK) {
-		kbd_state = AS;
-		kbd_flags &= (~CTRL);
-	} else {
-		kbd_state = CN;
-		kbd_flags |= CTRL;
-	}
-}
-
-static void kbd_num(unsigned char scan_code)
-{
-	if ((kbd_flags & BRK) == NORMAL) {
-		kbd_flags ^= NUM;
-		kbd_state = (kbd_flags & NUM) ? AS : NM;
-		kbd_led_set();
-	}
-}
-
-static void kbd_alt(unsigned char scan_code)
-{
-	if ((kbd_flags & BRK) == BRK) {
-		kbd_state = AS;
-		kbd_flags &= (~ALT);
-	} else {
-		kbd_state = AK;
-		kbd_flags &= ALT;
-	}
-}
-
-static void kbd_caps(unsigned char scan_code)
-{
-	if ((kbd_flags & BRK) == NORMAL) {
-		kbd_flags ^= CAPS;
-		kbd_led_set();
-	}
-}
-
-static void kbd_scroll(unsigned char scan_code)
-{
-	if ((kbd_flags & BRK) == NORMAL) {
-		kbd_flags ^= STP;
-		kbd_led_set();
-		if (kbd_flags & STP)
-			kbd_input = 0x13;
-		else
-			kbd_input = 0x11;
-	}
-}
-
-static void kbd_conv_char(unsigned char scan_code)
-{
-	if (scan_code == 0xe0) {
-		kbd_flags |= EXT;
-		return;
-	}
-
-	/* if high bit of scan_code, set break flag */
-	if (scan_code & 0x80)
-		kbd_flags |=  BRK;
-	else
-		kbd_flags &= ~BRK;
-
-	if ((scan_code == 0xe1) || (kbd_flags & E1)) {
-		if (scan_code == 0xe1) {
-			kbd_flags ^= BRK;	/* reset the break flag */
-			kbd_flags ^= E1;	/* bitwise EXOR with E1 flag */
-		}
-		return;
-	}
-
-	scan_code &= 0x7f;
-
-	if (kbd_flags & EXT) {
-		int i;
-
-		kbd_flags ^= EXT;
-		for (i = 0; ext_key_map[i]; i++) {
-			if (ext_key_map[i] == scan_code) {
-				scan_code = 0x80 + i;
-				break;
-			}
-		}
-		/* not found ? */
-		if (!ext_key_map[i])
-			return;
-	}
-
-	switch (kbd_fct_map[scan_code]) {
-	case AS:
-		kbd_normal(scan_code);
-		break;
-	case SH:
-		kbd_shift(scan_code);
-		break;
-	case CN:
-		kbd_ctrl(scan_code);
-		break;
-	case NM:
-		kbd_num(scan_code);
-		break;
-	case AK:
-		kbd_alt(scan_code);
-		break;
-	case CP:
-		kbd_caps(scan_code);
-		break;
-	case ST:
-		kbd_scroll(scan_code);
-		break;
-	}
-
-	return;
+	out8(I8042_DATA_REG, flags & 0x7);
 }
 
 static int kbd_write(int reg, int value)
@@ -568,11 +190,50 @@ int i8042_disable(void)
 	return 0;
 }
 
+static int i8042_kbd_check(struct input_config *input)
+{
+	if ((in8(I8042_STS_REG) & STATUS_OBF) == 0) {
+		return 0;
+	} else {
+		bool release = false;
+		int scan_code;
+		int i;
+
+		scan_code = in8(I8042_DATA_REG);
+		if (scan_code == 0xfa) {
+			return 0;
+		} else if (scan_code == 0xe0) {
+			extended = true;
+			return 0;
+		}
+		if (scan_code & 0x80) {
+			scan_code &= 0x7f;
+			release = true;
+		}
+		if (extended) {
+			extended = false;
+			for (i = 0; ext_key_map[i]; i++) {
+				if (ext_key_map[i] == scan_code) {
+					scan_code = 0x60 + i;
+					break;
+				}
+			}
+			/* not found ? */
+			if (!ext_key_map[i])
+				return 0;
+		}
+
+		input_add_keycode(&config, scan_code, release);
+		return 1;
+	}
+}
+
 /* i8042_kbd_init - reset keyboard and init state flags */
 int i8042_kbd_init(void)
 {
 	int keymap, try;
 	char *penv;
+	int ret;
 
 	if (!kbd_controller_present() || board_i8042_skip()) {
 		debug("i8042 keyboard controller is not present\n");
@@ -592,58 +253,46 @@ int i8042_kbd_init(void)
 			return -1;
 	}
 
-	kbd_mapping = keymap;
-	kbd_flags   = NORMAL;
-	kbd_state   = 0;
-	kbd_led_set();
+	ret = input_init(&config, 0, keymap == KBD_GER);
+	if (ret)
+		return ret;
+	config.read_keys = i8042_kbd_check;
+	input_allow_repeats(&config, true);
+
+	kbd_led_set(NORMAL);
 
 	return 0;
 }
 
-/*
- * i8042_tstc - test if keyboard input is available
+/**
+ * check_leds() - Check the keyboard LEDs and update them it needed
  *
- * option: cursor blinking if called in a loop
+ * @ret:	Value to return
+ * @return value of @ret
  */
-int i8042_tstc(struct stdio_dev *dev)
+static int check_leds(int ret)
 {
-	unsigned char scan_code = 0;
+	int leds;
 
-	if ((in8(I8042_STS_REG) & STATUS_OBF) == 0) {
-		return 0;
-	} else {
-		scan_code = in8(I8042_DATA_REG);
-		if (scan_code == 0xfa)
-			return 0;
-
-		kbd_conv_char(scan_code);
+	leds = input_leds_changed(&config);
+	if (leds >= 0)
+		kbd_led_set(leds);
 
-		if (kbd_input != -1)
-			return 1;
-	}
+	return ret;
+}
 
-	return 0;
+/*
+ * i8042_tstc - test if keyboard input is available
+ */
+int i8042_tstc(struct stdio_dev *dev)
+{
+	return check_leds(input_tstc(&config));
 }
 
 /*
  * i8042_getc - wait till keyboard input is available
- *
- * option: turn on/off cursor while waiting
  */
 int i8042_getc(struct stdio_dev *dev)
 {
-	int ret_chr;
-	unsigned char scan_code;
-
-	while (kbd_input == -1) {
-		while ((in8(I8042_STS_REG) & STATUS_OBF) == 0) {
-		}
-		scan_code = in8(I8042_DATA_REG);
-		if (scan_code != 0xfa)
-			kbd_conv_char(scan_code);
-	}
-	ret_chr = kbd_input;
-	kbd_input = -1;
-
-	return ret_chr;
+	return check_leds(input_getc(&config));
 }
-- 
2.6.0.rc0.131.gf624c3d

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 23/28] input: Add a Kconfig option for the i8042 keyboard
  2015-09-09  4:32 [U-Boot] [PATCH 00/28] dm: input: Move keyboard drivers to driver model Simon Glass
                   ` (21 preceding siblings ...)
  2015-09-09  4:32 ` [U-Boot] [PATCH 22/28] input: i8042: Convert to use the input library Simon Glass
@ 2015-09-09  4:32 ` Simon Glass
  2015-09-15  6:12   ` Bin Meng
  2015-09-09  4:32 ` [U-Boot] [PATCH 24/28] x86: Add an i8042 device for boards that have it Simon Glass
                   ` (4 subsequent siblings)
  27 siblings, 1 reply; 60+ messages in thread
From: Simon Glass @ 2015-09-09  4:32 UTC (permalink / raw)
  To: u-boot

Add a new option CONFIG_I8042_KEYB which will replace the current
CONFIG_I8042_KBD. This new name fits better with existing drivers.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/input/Kconfig | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
index 447c4c3..d560328 100644
--- a/drivers/input/Kconfig
+++ b/drivers/input/Kconfig
@@ -13,3 +13,13 @@ config CROS_EC_KEYB
 	  Most ARM Chromebooks use an EC to provide access to the keyboard.
 	  Messages are used to request key scans from the EC and these are
 	  then decoded into keys by this driver.
+
+config I8042_KEYB
+	bool "Enable Intel i8042 keyboard support"
+	depends on DM_KEYBOARD
+	help
+	  This adds a driver for the i8042 keyboard controller, allowing the
+	  keyboard to be used on devices which support this controller. The
+	  driver handles English and German keyboards - set the environment
+	  variable 'keymap' to "de" to select German. Keyboard repeat is
+	  handled by the keyboard itself.
-- 
2.6.0.rc0.131.gf624c3d

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 24/28] x86: Add an i8042 device for boards that have it
  2015-09-09  4:32 [U-Boot] [PATCH 00/28] dm: input: Move keyboard drivers to driver model Simon Glass
                   ` (22 preceding siblings ...)
  2015-09-09  4:32 ` [U-Boot] [PATCH 23/28] input: Add a Kconfig option for the i8042 keyboard Simon Glass
@ 2015-09-09  4:32 ` Simon Glass
  2015-09-15  6:12   ` Bin Meng
  2015-09-09  4:32 ` [U-Boot] [PATCH 25/28] Drop CONFIG_ISA_KEYBOARD Simon Glass
                   ` (3 subsequent siblings)
  27 siblings, 1 reply; 60+ messages in thread
From: Simon Glass @ 2015-09-09  4:32 UTC (permalink / raw)
  To: u-boot

Some boards have an i8042 device. Enable the driver for all x86 boards, and
add a device tree node for those which may have this keyboard.

Also adjust the configuration so that i8042 is always separate from the VGA,
and rename the stdin driver accordingly. With this commit the keyboard will
not work, but it is fixed in the next commit.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/x86/Kconfig                 | 6 ++++++
 arch/x86/dts/bayleybay.dts       | 1 +
 arch/x86/dts/chromebook_link.dts | 1 +
 arch/x86/dts/keyboard.dtsi       | 5 +++++
 include/configs/x86-chromebook.h | 2 +-
 include/configs/x86-common.h     | 2 +-
 6 files changed, 15 insertions(+), 2 deletions(-)
 create mode 100644 arch/x86/dts/keyboard.dtsi

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 5e42d7d..72a66ea 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -401,6 +401,12 @@ config PCIE_ECAM_SIZE
 	  so a default 0x10000000 size covers all of the 256 buses which is the
 	  maximum number of PCI buses as defined by the PCI specification.
 
+config I8042_KEYB
+	default y
+
+config DM_KEYBOARD
+	default y
+
 source "arch/x86/lib/efi/Kconfig"
 
 endmenu
diff --git a/arch/x86/dts/bayleybay.dts b/arch/x86/dts/bayleybay.dts
index d646987..58d97c8 100644
--- a/arch/x86/dts/bayleybay.dts
+++ b/arch/x86/dts/bayleybay.dts
@@ -10,6 +10,7 @@
 #include <dt-bindings/interrupt-router/intel-irq.h>
 
 /include/ "skeleton.dtsi"
+/include/ "keyboard.dtsi"
 /include/ "serial.dtsi"
 /include/ "rtc.dtsi"
 
diff --git a/arch/x86/dts/chromebook_link.dts b/arch/x86/dts/chromebook_link.dts
index 4291141..a52c84f 100644
--- a/arch/x86/dts/chromebook_link.dts
+++ b/arch/x86/dts/chromebook_link.dts
@@ -1,6 +1,7 @@
 /dts-v1/;
 
 /include/ "skeleton.dtsi"
+/include/ "keyboard.dtsi"
 /include/ "serial.dtsi"
 /include/ "rtc.dtsi"
 
diff --git a/arch/x86/dts/keyboard.dtsi b/arch/x86/dts/keyboard.dtsi
new file mode 100644
index 0000000..000751b
--- /dev/null
+++ b/arch/x86/dts/keyboard.dtsi
@@ -0,0 +1,5 @@
+/ {
+	keyboard {
+		compatible = "intel,i8042-keyboard";
+	};
+};
diff --git a/include/configs/x86-chromebook.h b/include/configs/x86-chromebook.h
index 2be8850..4ff8b94 100644
--- a/include/configs/x86-chromebook.h
+++ b/include/configs/x86-chromebook.h
@@ -51,7 +51,7 @@
 #define CONFIG_ENV_IS_IN_SPI_FLASH
 #define CONFIG_ENV_OFFSET		0x003f8000
 
-#define CONFIG_STD_DEVICES_SETTINGS     "stdin=usbkbd,vga,serial\0" \
+#define CONFIG_STD_DEVICES_SETTINGS     "stdin=usbkbd,i8042-kbd,serial\0" \
 					"stdout=vga,serial\0" \
 					"stderr=vga,serial\0"
 
diff --git a/include/configs/x86-common.h b/include/configs/x86-common.h
index 3f153f2..ff8fe0f 100644
--- a/include/configs/x86-common.h
+++ b/include/configs/x86-common.h
@@ -147,7 +147,7 @@
 #define CONFIG_VIDEO
 #define CONFIG_VIDEO_SW_CURSOR
 #define VIDEO_FB_16BPP_WORD_SWAP
-#define CONFIG_I8042_KBD
+#define CONFIG_VGA_AS_SINGLE_DEVICE
 #define CONFIG_CFB_CONSOLE
 #define CONFIG_CONSOLE_SCROLL_LINES 5
 
-- 
2.6.0.rc0.131.gf624c3d

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 25/28] Drop CONFIG_ISA_KEYBOARD
  2015-09-09  4:32 [U-Boot] [PATCH 00/28] dm: input: Move keyboard drivers to driver model Simon Glass
                   ` (23 preceding siblings ...)
  2015-09-09  4:32 ` [U-Boot] [PATCH 24/28] x86: Add an i8042 device for boards that have it Simon Glass
@ 2015-09-09  4:32 ` Simon Glass
  2015-09-15  6:12   ` Bin Meng
  2015-09-09  4:32 ` [U-Boot] [PATCH 26/28] input: Convert i8042 to driver model Simon Glass
                   ` (2 subsequent siblings)
  27 siblings, 1 reply; 60+ messages in thread
From: Simon Glass @ 2015-09-09  4:32 UTC (permalink / raw)
  To: u-boot

This option is mentioned but does not do anything. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 README                   | 11 ++++++-----
 board/mpl/pip405/README  |  4 ----
 include/configs/MIP405.h |  5 -----
 include/configs/PIP405.h |  5 -----
 4 files changed, 6 insertions(+), 19 deletions(-)

diff --git a/README b/README
index 54c1d08..dd857c4 100644
--- a/README
+++ b/README
@@ -1785,17 +1785,18 @@ CBFS (Coreboot Filesystem) support
 		a default value of 65536 will be defined.
 
 - Keyboard Support:
-		CONFIG_ISA_KEYBOARD
-
-		Define this to enable standard (PC-Style) keyboard
-		support
-
 		CONFIG_I8042_KBD
 		Standard PC keyboard driver with US (is default) and
 		GERMAN key layout (switch via environment 'keymap=de') support.
 		Export function i8042_kbd_init, i8042_tstc and i8042_getc
 		for cfb_console. Supports cursor blinking.
 
+		CONFIG_CROS_EC_KEYB
+		Enables a Chrome OS keyboard using the CROS_EC interface.
+		This uses CROS_EC to communicate with a second microcontroller
+		which provides key scans on request.
+		See Kconfig help for available keyboard drivers.
+
 - Video support:
 		CONFIG_VIDEO
 
diff --git a/board/mpl/pip405/README b/board/mpl/pip405/README
index 012db1c..1b73dbe 100644
--- a/board/mpl/pip405/README
+++ b/board/mpl/pip405/README
@@ -114,10 +114,6 @@ RTC
 ----
 CONFIG_RTC_MC146818		MC146818 RTC support
 
-Keyboard:
----------
-CONFIG_ISA_KEYBOARD		Standard (PC-Style) Keyboard support
-
 Video:
 ------
 CONFIG_VIDEO_CT69000		Enable Chips & Technologies 69000 Video chip
diff --git a/include/configs/MIP405.h b/include/configs/MIP405.h
index cb21b73..5bbc0de 100644
--- a/include/configs/MIP405.h
+++ b/include/configs/MIP405.h
@@ -364,11 +364,6 @@
 #define CONFIG_ISO_PARTITION /* Experimental */
 
 /************************************************************
- * Keyboard support
- ************************************************************/
-#undef CONFIG_ISA_KEYBOARD
-
-/************************************************************
  * Video support
  ************************************************************/
 #define CONFIG_VIDEO			/*To enable video controller support */
diff --git a/include/configs/PIP405.h b/include/configs/PIP405.h
index c9d08e6..265fa12 100644
--- a/include/configs/PIP405.h
+++ b/include/configs/PIP405.h
@@ -321,11 +321,6 @@
 #define CONFIG_ISO_PARTITION /* Experimental */
 
 /************************************************************
- * Keyboard support
- ************************************************************/
-#define CONFIG_ISA_KEYBOARD
-
-/************************************************************
  * Video support
  ************************************************************/
 #define CONFIG_VIDEO			/*To enable video controller support */
-- 
2.6.0.rc0.131.gf624c3d

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 26/28] input: Convert i8042 to driver model
  2015-09-09  4:32 [U-Boot] [PATCH 00/28] dm: input: Move keyboard drivers to driver model Simon Glass
                   ` (24 preceding siblings ...)
  2015-09-09  4:32 ` [U-Boot] [PATCH 25/28] Drop CONFIG_ISA_KEYBOARD Simon Glass
@ 2015-09-09  4:32 ` Simon Glass
  2015-09-15  6:12   ` Bin Meng
  2015-09-09  4:32 ` [U-Boot] [PATCH 27/28] video: input: Clean up after i8042 conversion Simon Glass
  2015-09-09  4:32 ` [U-Boot] [PATCH 28/28] input: Convert 'keyboard' driver to use input library Simon Glass
  27 siblings, 1 reply; 60+ messages in thread
From: Simon Glass @ 2015-09-09  4:32 UTC (permalink / raw)
  To: u-boot

Adjust this driver to support driver model. The only users are x86 boards
so this should be safe.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/input/Makefile |   2 +-
 drivers/input/i8042.c  | 113 ++++++++++++++++++++++++++++++++-----------------
 include/i8042.h        |   6 ---
 3 files changed, 76 insertions(+), 45 deletions(-)

diff --git a/drivers/input/Makefile b/drivers/input/Makefile
index 9388dfe..5f15265 100644
--- a/drivers/input/Makefile
+++ b/drivers/input/Makefile
@@ -7,7 +7,7 @@
 
 obj-$(CONFIG_DM_KEYBOARD) += keyboard-uclass.o
 
-obj-$(CONFIG_I8042_KBD) += i8042.o
+obj-$(CONFIG_I8042_KEYB) += i8042.o
 obj-$(CONFIG_TEGRA_KEYBOARD) += tegra-kbc.o
 obj-$(CONFIG_TWL4030_INPUT) += twl4030.o
 obj-$(CONFIG_CROS_EC_KEYB) += cros_ec_keyb.o
diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c
index 5ebb571..3649e2f 100644
--- a/drivers/input/i8042.c
+++ b/drivers/input/i8042.c
@@ -8,8 +8,11 @@
 /* i8042.c - Intel 8042 keyboard driver routines */
 
 #include <common.h>
+#include <dm.h>
+#include <errno.h>
 #include <i8042.h>
 #include <input.h>
+#include <keyboard.h>
 #include <asm/io.h>
 
 /* defines */
@@ -17,8 +20,9 @@
 #define out8(p, v)	outb(v, p)
 
 /* locals */
-static struct input_config config;
-static bool extended;
+struct i8042_kbd_priv {
+	bool extended;	/* true if an extended keycode is expected next */
+};
 
 static unsigned char ext_key_map[] = {
 	0x1c, /* keypad enter */
@@ -60,12 +64,20 @@ static int kbd_output_full(void)
 	return kbd_timeout != -1;
 }
 
-static void kbd_led_set(int flags)
+/**
+ * check_leds() - Check the keyboard LEDs and update them it needed
+ *
+ * @ret:	Value to return
+ * @return value of @ret
+ */
+static int i8042_kbd_update_leds(struct udevice *dev, int leds)
 {
 	kbd_input_empty();
 	out8(I8042_DATA_REG, CMD_SET_KBD_LED);
 	kbd_input_empty();
-	out8(I8042_DATA_REG, flags & 0x7);
+	out8(I8042_DATA_REG, leds & 0x7);
+
+	return 0;
 }
 
 static int kbd_write(int reg, int value)
@@ -146,6 +158,8 @@ static int kbd_controller_present(void)
 /*
  * Implement a weak default function for boards that optionally
  * need to skip the i8042 initialization.
+ *
+ * TODO(sjg at chromium.org): Use device tree for this?
  */
 int __weak board_i8042_skip(void)
 {
@@ -192,6 +206,8 @@ int i8042_disable(void)
 
 static int i8042_kbd_check(struct input_config *input)
 {
+	struct i8042_kbd_priv *priv = dev_get_priv(input->dev);
+
 	if ((in8(I8042_STS_REG) & STATUS_OBF) == 0) {
 		return 0;
 	} else {
@@ -203,15 +219,15 @@ static int i8042_kbd_check(struct input_config *input)
 		if (scan_code == 0xfa) {
 			return 0;
 		} else if (scan_code == 0xe0) {
-			extended = true;
+			priv->extended = true;
 			return 0;
 		}
 		if (scan_code & 0x80) {
 			scan_code &= 0x7f;
 			release = true;
 		}
-		if (extended) {
-			extended = false;
+		if (priv->extended) {
+			priv->extended = false;
 			for (i = 0; ext_key_map[i]; i++) {
 				if (ext_key_map[i] == scan_code) {
 					scan_code = 0x60 + i;
@@ -223,21 +239,23 @@ static int i8042_kbd_check(struct input_config *input)
 				return 0;
 		}
 
-		input_add_keycode(&config, scan_code, release);
+		input_add_keycode(input, scan_code, release);
 		return 1;
 	}
 }
 
 /* i8042_kbd_init - reset keyboard and init state flags */
-int i8042_kbd_init(void)
+static int i8042_start(struct udevice *dev)
 {
+	struct keyboard_priv *uc_priv = dev_get_uclass_priv(dev);
+	struct input_config *input = &uc_priv->input;
 	int keymap, try;
 	char *penv;
 	int ret;
 
 	if (!kbd_controller_present() || board_i8042_skip()) {
 		debug("i8042 keyboard controller is not present\n");
-		return -1;
+		return -ENOENT;
 	}
 
 	/* Init keyboard device (default US layout) */
@@ -253,46 +271,65 @@ int i8042_kbd_init(void)
 			return -1;
 	}
 
-	ret = input_init(&config, 0, keymap == KBD_GER);
+	ret = input_add_tables(input, keymap == KBD_GER);
 	if (ret)
 		return ret;
-	config.read_keys = i8042_kbd_check;
-	input_allow_repeats(&config, true);
 
-	kbd_led_set(NORMAL);
+	i8042_kbd_update_leds(dev, NORMAL);
+	debug("%s: started\n", __func__);
 
 	return 0;
 }
 
 /**
- * check_leds() - Check the keyboard LEDs and update them it needed
+ * Set up the i8042 keyboard. This is called by the stdio device handler
  *
- * @ret:	Value to return
- * @return value of @ret
+ * We want to do this init when the keyboard is actually used rather than
+ * at start-up, since keyboard input may not currently be selected.
+ *
+ * Once the keyboard starts there will be a period during which we must
+ * wait for the keyboard to init. We do this only when a key is first
+ * read - see kbd_wait_for_fifo_init().
+ *
+ * @return 0 if ok, -ve on error
  */
-static int check_leds(int ret)
+static int i8042_kbd_probe(struct udevice *dev)
 {
-	int leds;
-
-	leds = input_leds_changed(&config);
-	if (leds >= 0)
-		kbd_led_set(leds);
+	struct keyboard_priv *uc_priv = dev_get_uclass_priv(dev);
+	struct stdio_dev *sdev = &uc_priv->sdev;
+	struct input_config *input = &uc_priv->input;
+	int ret;
 
-	return ret;
-}
+	/* Register the device. i8042_start() will be called soon */
+	input->dev = dev;
+	input->read_keys = i8042_kbd_check;
+	input_allow_repeats(input, true);
+	strcpy(sdev->name, "i8042-kbd");
+	ret = input_stdio_register(sdev);
+	if (ret) {
+		debug("%s: input_stdio_register() failed\n", __func__);
+		return ret;
+	}
+	debug("%s: ready\n", __func__);
 
-/*
- * i8042_tstc - test if keyboard input is available
- */
-int i8042_tstc(struct stdio_dev *dev)
-{
-	return check_leds(input_tstc(&config));
+	return 0;
 }
 
-/*
- * i8042_getc - wait till keyboard input is available
- */
-int i8042_getc(struct stdio_dev *dev)
-{
-	return check_leds(input_getc(&config));
-}
+static const struct keyboard_ops i8042_kbd_ops = {
+	.start	= i8042_start,
+	.update_leds	= i8042_kbd_update_leds,
+};
+
+static const struct udevice_id i8042_kbd_ids[] = {
+	{ .compatible = "intel,i8042-keyboard" },
+	{ }
+};
+
+U_BOOT_DRIVER(i8042_kbd) = {
+	.name	= "i8042_kbd",
+	.id	= UCLASS_KEYBOARD,
+	.of_match = i8042_kbd_ids,
+	.probe = i8042_kbd_probe,
+	.ops	= &i8042_kbd_ops,
+	.priv_auto_alloc_size = sizeof(struct i8042_kbd_priv),
+};
diff --git a/include/i8042.h b/include/i8042.h
index e0afce1..9723b6a 100644
--- a/include/i8042.h
+++ b/include/i8042.h
@@ -87,10 +87,4 @@ void i8042_flush(void);
  */
 int i8042_disable(void);
 
-struct stdio_dev;
-
-int i8042_kbd_init(void);
-int i8042_tstc(struct stdio_dev *dev);
-int i8042_getc(struct stdio_dev *dev);
-
 #endif /* _I8042_H_ */
-- 
2.6.0.rc0.131.gf624c3d

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 27/28] video: input: Clean up after i8042 conversion
  2015-09-09  4:32 [U-Boot] [PATCH 00/28] dm: input: Move keyboard drivers to driver model Simon Glass
                   ` (25 preceding siblings ...)
  2015-09-09  4:32 ` [U-Boot] [PATCH 26/28] input: Convert i8042 to driver model Simon Glass
@ 2015-09-09  4:32 ` Simon Glass
  2015-09-15  6:12   ` Bin Meng
  2015-09-09  4:32 ` [U-Boot] [PATCH 28/28] input: Convert 'keyboard' driver to use input library Simon Glass
  27 siblings, 1 reply; 60+ messages in thread
From: Simon Glass @ 2015-09-09  4:32 UTC (permalink / raw)
  To: u-boot

Now that i8042 uses driver model, adjust other mentions of it and remove old
code that is no-longer used. Update the README and unify the keyboard text
into one place.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 README                      | 33 +++++++++++----------------------
 drivers/video/cfb_console.c | 20 ++++----------------
 2 files changed, 15 insertions(+), 38 deletions(-)

diff --git a/README b/README
index dd857c4..d1f9b38 100644
--- a/README
+++ b/README
@@ -885,11 +885,11 @@ The following options need to be configured:
 						(0-5, cf. cfb_console.c)
 			VIDEO_FB_ADRS		framebuffer address
 			VIDEO_KBD_INIT_FCT	keyboard int fct
-						(i.e. i8042_kbd_init())
+						(i.e. rx51_kp_init())
 			VIDEO_TSTC_FCT		test char fct
-						(i.e. i8042_tstc)
+						(i.e. rx51_kp_tstc)
 			VIDEO_GETC_FCT		get char fct
-						(i.e. i8042_getc)
+						(i.e. rx51_kp_getc)
 			CONFIG_VIDEO_LOGO	display Linux logo in
 						upper left corner
 			CONFIG_VIDEO_BMP_LOGO	use bmp_logo.h instead of
@@ -1785,18 +1785,16 @@ CBFS (Coreboot Filesystem) support
 		a default value of 65536 will be defined.
 
 - Keyboard Support:
-		CONFIG_I8042_KBD
-		Standard PC keyboard driver with US (is default) and
-		GERMAN key layout (switch via environment 'keymap=de') support.
-		Export function i8042_kbd_init, i8042_tstc and i8042_getc
-		for cfb_console. Supports cursor blinking.
-
-		CONFIG_CROS_EC_KEYB
-		Enables a Chrome OS keyboard using the CROS_EC interface.
-		This uses CROS_EC to communicate with a second microcontroller
-		which provides key scans on request.
 		See Kconfig help for available keyboard drivers.
 
+		CONFIG_KEYBOARD
+
+		Define this to enable a custom keyboard support.
+		This simply calls drv_keyboard_init() which must be
+		defined in your board-specific files. This option is deprecated
+		and is only used by novena. For new boards, driver model
+		instead.
+
 - Video support:
 		CONFIG_VIDEO
 
@@ -1856,15 +1854,6 @@ CBFS (Coreboot Filesystem) support
 		boot.  See the documentation file README.video for a
 		description of this variable.
 
-
-- Keyboard Support:
-		CONFIG_KEYBOARD
-
-		Define this to enable a custom keyboard support.
-		This simply calls drv_keyboard_init() which must be
-		defined in your board-specific files.
-		The only board using this so far is RBC823.
-
 - LCD Support:	CONFIG_LCD
 
 		Define this to enable LCD support (for output to LCD
diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c
index 1b5c3e0..fde0bd4 100644
--- a/drivers/video/cfb_console.c
+++ b/drivers/video/cfb_console.c
@@ -15,8 +15,10 @@
  * logo can be placed in the upper left corner and additional board
  * information strings (that normally goes to serial port) can be drawn.
  *
- * The console driver can use the standard PC keyboard interface (i8042)
- * for character input. Character output goes to a memory mapped video
+ * The console driver can use a keyboard interface for character input
+ * but this is deprecated. Only rk51 uses it.
+ *
+ * Character output goes to a memory-mapped video
  * framebuffer with little or big-endian organisation.
  * With environment setting 'console=serial' the console i/o can be
  * forced to serial port.
@@ -38,7 +40,6 @@
  * VIDEO_DATA_FORMAT	      - graphical data format GDF
  * VIDEO_FB_ADRS	      - start of video memory
  *
- * CONFIG_I8042_KBD	      - AT Keyboard driver for i8042
  * VIDEO_KBD_INIT_FCT	      - init function for keyboard
  * VIDEO_TSTC_FCT	      - keyboard_tstc function
  * VIDEO_GETC_FCT	      - keyboard_getc function
@@ -158,19 +159,6 @@
 #define VIDEO_FB_ADRS		(pGD->frameAdrs)
 
 /*
- * Console device defines with i8042 keyboard controller
- * Any other keyboard controller must change this section
- */
-
-#ifdef	CONFIG_I8042_KBD
-#include <i8042.h>
-
-#define VIDEO_KBD_INIT_FCT	i8042_kbd_init()
-#define VIDEO_TSTC_FCT		i8042_tstc
-#define VIDEO_GETC_FCT		i8042_getc
-#endif
-
-/*
  * Console device
  */
 
-- 
2.6.0.rc0.131.gf624c3d

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 28/28] input: Convert 'keyboard' driver to use input library
  2015-09-09  4:32 [U-Boot] [PATCH 00/28] dm: input: Move keyboard drivers to driver model Simon Glass
                   ` (26 preceding siblings ...)
  2015-09-09  4:32 ` [U-Boot] [PATCH 27/28] video: input: Clean up after i8042 conversion Simon Glass
@ 2015-09-09  4:32 ` Simon Glass
  27 siblings, 0 replies; 60+ messages in thread
From: Simon Glass @ 2015-09-09  4:32 UTC (permalink / raw)
  To: u-boot

This has duplicated scan code tables and logic. We can use the input
library to implement most of the features here.

This needs testing. The only supported board appears to be TQM5200.
Unfortunately no maintainer is listed for this board.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/input/keyboard.c | 290 +++++++----------------------------------------
 include/keyboard.h       |   5 +
 2 files changed, 43 insertions(+), 252 deletions(-)

diff --git a/drivers/input/keyboard.c b/drivers/input/keyboard.c
index be0f333..0836c63 100644
--- a/drivers/input/keyboard.c
+++ b/drivers/input/keyboard.c
@@ -9,290 +9,76 @@
  ***********************************************************************/
 
 #include <common.h>
-
-#include <stdio_dev.h>
+#include <input.h>
 #include <keyboard.h>
+#include <stdio_dev.h>
 
-#undef KBG_DEBUG
-
-#ifdef KBG_DEBUG
-#define	PRINTF(fmt,args...)	printf (fmt ,##args)
-#else
-#define PRINTF(fmt,args...)
-#endif
-
-
-#define	DEVNAME			"kbd"
-
-#define	LED_SCR			0x01	/* scroll lock led */
-#define	LED_CAP			0x04	/* caps lock led */
-#define	LED_NUM			0x02	/* num lock led */
-
-#define	KBD_BUFFER_LEN		0x20  /* size of the keyboardbuffer */
+static struct input_config config;
 
-#if defined(CONFIG_MPC5xxx) || defined(CONFIG_MPC8540) || defined(CONFIG_MPC8541) || defined(CONFIG_MPC8555)
-int ps2ser_check(void);
+static int kbd_read_keys(struct input_config *config)
+{
+#if defined(CONFIG_MPC5xxx) || defined(CONFIG_MPC8540) || \
+		defined(CONFIG_MPC8541) || defined(CONFIG_MPC8555)
+	/* no ISR is used, so received chars must be polled */
+	ps2ser_check();
 #endif
 
-static volatile char kbd_buffer[KBD_BUFFER_LEN];
-static volatile int in_pointer = 0;
-static volatile int out_pointer = 0;
+	return 1;
+}
 
-static unsigned char leds = 0;
-static unsigned char num_lock = 0;
-static unsigned char caps_lock = 0;
-static unsigned char scroll_lock = 0;
-static unsigned char shift = 0;
-static unsigned char ctrl = 0;
-static unsigned char alt = 0;
-static unsigned char e0 = 0;
+static int check_leds(int ret)
+{
+	int leds;
 
-/******************************************************************
- * Queue handling
- ******************************************************************/
+	leds = input_leds_changed(&config);
+	if (leds >= 0)
+		pckbd_leds(leds);
 
-/* puts character in the queue and sets up the in and out pointer */
-static void kbd_put_queue(char data)
-{
-	if((in_pointer+1)==KBD_BUFFER_LEN) {
-		if(out_pointer==0) {
-			return; /* buffer full */
-		} else{
-			in_pointer=0;
-		}
-	} else {
-		if((in_pointer+1)==out_pointer)
-			return; /* buffer full */
-		in_pointer++;
-	}
-	kbd_buffer[in_pointer]=data;
-	return;
+	return ret;
 }
 
 /* test if a character is in the queue */
 static int kbd_testc(struct stdio_dev *dev)
 {
-#if defined(CONFIG_MPC5xxx) || defined(CONFIG_MPC8540) || defined(CONFIG_MPC8541) || defined(CONFIG_MPC8555)
-	/* no ISR is used, so received chars must be polled */
-	ps2ser_check();
-#endif
-	if(in_pointer==out_pointer)
-		return(0); /* no data */
-	else
-		return(1);
+	return check_leds(input_tstc(&config));
 }
 
 /* gets the character from the queue */
 static int kbd_getc(struct stdio_dev *dev)
 {
-	char c;
-	while(in_pointer==out_pointer) {
-#if defined(CONFIG_MPC5xxx) || defined(CONFIG_MPC8540) || defined(CONFIG_MPC8541) || defined(CONFIG_MPC8555)
-	/* no ISR is used, so received chars must be polled */
-	ps2ser_check();
-#endif
-	;}
-	if((out_pointer+1)==KBD_BUFFER_LEN)
-		out_pointer=0;
-	else
-		out_pointer++;
-	c=kbd_buffer[out_pointer];
-	return (int)c;
-
+	return check_leds(input_getc(&config));
 }
 
-/* Simple translation table for the keys */
-
-static unsigned char kbd_plain_xlate[] = {
-	0xff,0x1b, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=','\b','\t',	/* 0x00 - 0x0f */
-	 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']','\r',0xff, 'a', 's',	/* 0x10 - 0x1f */
-	 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';','\'', '`',0xff,'\\', 'z', 'x', 'c', 'v',	/* 0x20 - 0x2f */
-	 'b', 'n', 'm', ',', '.', '/',0xff,0xff,0xff, ' ',0xff,0xff,0xff,0xff,0xff,0xff,	/* 0x30 - 0x3f */
-	0xff,0xff,0xff,0xff,0xff,0xff,0xff, '7', '8', '9', '-', '4', '5', '6', '+', '1',	/* 0x40 - 0x4f */
-	 '2', '3', '0', '.',0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,  /* 0x50 - 0x5F */
-	'\r',0xff,0xff
-	};
-
-static unsigned char kbd_shift_xlate[] = {
-	0xff,0x1b, '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+','\b','\t',	/* 0x00 - 0x0f */
-	 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}','\r',0xff, 'A', 'S',	/* 0x10 - 0x1f */
-	 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', '~',0xff, '|', 'Z', 'X', 'C', 'V',	/* 0x20 - 0x2f */
-	 'B', 'N', 'M', '<', '>', '?',0xff,0xff,0xff, ' ',0xff,0xff,0xff,0xff,0xff,0xff,	/* 0x30 - 0x3f */
-	0xff,0xff,0xff,0xff,0xff,0xff,0xff, '7', '8', '9', '-', '4', '5', '6', '+', '1',	/* 0x40 - 0x4f */
-	 '2', '3', '0', '.',0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,  /* 0x50 - 0x5F */
-	'\r',0xff,0xff
-	};
-
-static unsigned char kbd_ctrl_xlate[] = {
-	0xff,0x1b, '1',0x00, '3', '4', '5',0x1E, '7', '8', '9', '0',0x1F, '=','\b','\t',	/* 0x00 - 0x0f */
-	0x11,0x17,0x05,0x12,0x14,0x18,0x15,0x09,0x0f,0x10,0x1b,0x1d,'\n',0xff,0x01,0x13,	/* 0x10 - 0x1f */
-	0x04,0x06,0x08,0x09,0x0a,0x0b,0x0c, ';','\'', '~',0x00,0x1c,0x1a,0x18,0x03,0x16,	/* 0x20 - 0x2f */
-	0x02,0x0e,0x0d, '<', '>', '?',0xff,0xff,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,	/* 0x30 - 0x3f */
-	0xff,0xff,0xff,0xff,0xff,0xff,0xff, '7', '8', '9', '-', '4', '5', '6', '+', '1',	/* 0x40 - 0x4f */
-	 '2', '3', '0', '.',0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,  /* 0x50 - 0x5F */
-	'\r',0xff,0xff
-	};
-
-
-void handle_scancode(unsigned char scancode)
+void handle_scancode(unsigned char scan_code)
 {
-	unsigned char keycode;
+	bool release = false;
 
-	/*  Convert scancode to keycode */
-	PRINTF("scancode %x\n",scancode);
-	if(scancode==0xe0) {
-		e0=1; /* special charakters */
-		return;
-	}
-	if(e0==1) {
-		e0=0; /* delete flag */
-		if(!(	((scancode&0x7F)==0x38)|| /* the right ctrl key */
-					((scancode&0x7F)==0x1D)|| /* the right alt key */
-					((scancode&0x7F)==0x35)||	/* the right '/' key */
-					((scancode&0x7F)==0x1C) ))  /* the right enter key */
-			/* we swallow unknown e0 codes */
-			return;
-	}
-	/* special cntrl keys */
-	switch(scancode) {
-	case 0x2A:
-	case 0x36: /* shift pressed */
-		shift=1;
-		return; /* do nothing else */
-	case 0xAA:
-	case 0xB6: /* shift released */
-		shift=0;
-		return; /* do nothing else */
-	case 0x38: /* alt pressed */
-		alt=1;
-		return; /* do nothing else */
-	case 0xB8: /* alt released */
-		alt=0;
-		return; /* do nothing else */
-	case 0x1d: /* ctrl pressed */
-		ctrl=1;
-		return; /* do nothing else */
-	case 0x9d: /* ctrl released */
-		ctrl=0;
-		return; /* do nothing else */
-	case 0x46: /* scrollock pressed */
-		scroll_lock=~scroll_lock;
-		if(scroll_lock==0)
-			leds&=~LED_SCR; /* switch LED off */
-		else
-			leds|=LED_SCR; /* switch on LED */
-		pckbd_leds(leds);
-		return; /* do nothing else */
-	case 0x3A: /* capslock pressed */
-		caps_lock=~caps_lock;
-		if(caps_lock==0)
-			leds&=~LED_CAP; /* switch caps_lock off */
-		else
-			leds|=LED_CAP; /* switch on LED */
-		pckbd_leds(leds);
-		return;
-	case 0x45: /* numlock pressed */
-		num_lock=~num_lock;
-		if(num_lock==0)
-			leds&=~LED_NUM; /* switch LED off */
-		else
-			leds|=LED_NUM;  /* switch on LED */
-		pckbd_leds(leds);
-		return;
-	case 0xC6: /* scroll lock released */
-	case 0xC5: /* num lock released */
-	case 0xBA: /* caps lock released */
-		return; /* just swallow */
-	}
-#if 1
-	if((scancode&0x80)==0x80) /* key released */
-		return;
-#else
-	if((scancode&0x80)==0x00) /* key pressed */
-		return;
-	scancode &= ~0x80;
-#endif
-	/* now, decide which table we need */
-	if(scancode > (sizeof(kbd_plain_xlate)/sizeof(kbd_plain_xlate[0]))) { /* scancode not in list */
-		PRINTF("unkown scancode %X\n",scancode);
-		return; /* swallow it */
-	}
-	/* setup plain code first */
-	keycode=kbd_plain_xlate[scancode];
-	if(caps_lock==1) { /* caps_lock is pressed, overwrite plain code */
-		if(scancode > (sizeof(kbd_shift_xlate)/sizeof(kbd_shift_xlate[0]))) { /* scancode not in list */
-			PRINTF("unkown caps-locked scancode %X\n",scancode);
-			return; /* swallow it */
-		}
-		keycode=kbd_shift_xlate[scancode];
-		if(keycode<'A') { /* we only want the alphas capital */
-			keycode=kbd_plain_xlate[scancode];
-		}
-	}
-	if(shift==1) { /* shift overwrites caps_lock */
-		if(scancode > (sizeof(kbd_shift_xlate)/sizeof(kbd_shift_xlate[0]))) { /* scancode not in list */
-			PRINTF("unkown shifted scancode %X\n",scancode);
-			return; /* swallow it */
-		}
-		keycode=kbd_shift_xlate[scancode];
-	}
-	if(ctrl==1) { /* ctrl overwrites caps_lock and shift */
-		if(scancode > (sizeof(kbd_ctrl_xlate)/sizeof(kbd_ctrl_xlate[0]))) { /* scancode not in list */
-			PRINTF("unkown ctrl scancode %X\n",scancode);
-			return; /* swallow it */
-		}
-		keycode=kbd_ctrl_xlate[scancode];
-	}
-	/* check if valid keycode */
-	if(keycode==0xff) {
-		PRINTF("unkown scancode %X\n",scancode);
-		return; /* swallow unknown codes */
+	/* Compare with i8042_kbd_check() in i8042.c if some logic is missing */
+	if (scan_code & 0x80) {
+		scan_code &= 0x7f;
+		release = true;
 	}
 
-	kbd_put_queue(keycode);
-	PRINTF("%x\n",keycode);
+	input_add_keycode(&config, scan_code, release);
 }
 
-/******************************************************************
- * Init
- ******************************************************************/
-
-#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 */
-
+/* TODO: convert to driver model */
 int kbd_init (void)
 {
-	int error;
-	struct stdio_dev kbddev ;
-	char *stdinname  = getenv ("stdin");
+	struct stdio_dev kbddev;
+	struct input_config *input = &config;
 
 	if(kbd_init_hw()==-1)
 		return -1;
 	memset (&kbddev, 0, sizeof(kbddev));
-	strcpy(kbddev.name, DEVNAME);
+	strcpy(kbddev.name, "kbd");
 	kbddev.flags =  DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
-	kbddev.getc = kbd_getc ;
-	kbddev.tstc = kbd_testc ;
+	kbddev.getc = kbd_getc;
+	kbddev.tstc = kbd_testc;
 
-	error = stdio_register (&kbddev);
-	if(error==0) {
-		/* check if this is the standard input device */
-		if(strcmp(stdinname,DEVNAME)==0) {
-			/* reassign the console */
-			if(OVERWRITE_CONSOLE) {
-				return 1;
-			}
-			error=console_assign(stdin,DEVNAME);
-			if(error==0)
-				return 1;
-			else
-				return error;
-		}
-		return 1;
-	}
-	return error;
+	input_init(input, 0);
+	input->read_keys = kbd_read_keys;
+	input_add_tables(input, true);
+
+	return input_stdio_register(&kbddev);
 }
diff --git a/include/keyboard.h b/include/keyboard.h
index a8b68cb..0b72241 100644
--- a/include/keyboard.h
+++ b/include/keyboard.h
@@ -97,4 +97,9 @@ extern int kbd_init_hw(void);
 extern void pckbd_leds(unsigned char leds);
 #endif /* !CONFIG_DM_KEYBOARD */
 
+#if defined(CONFIG_MPC5xxx) || defined(CONFIG_MPC8540) || \
+		defined(CONFIG_MPC8541) || defined(CONFIG_MPC8555)
+int ps2ser_check(void);
+#endif
+
 #endif /* __KEYBOARD_H */
-- 
2.6.0.rc0.131.gf624c3d

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 01/28] dm: input: Create a keyboard uclass
  2015-09-09  4:32 ` [U-Boot] [PATCH 01/28] dm: input: Create a keyboard uclass Simon Glass
@ 2015-09-09 12:17   ` Marek Vasut
  2015-09-15  6:11   ` Bin Meng
  1 sibling, 0 replies; 60+ messages in thread
From: Marek Vasut @ 2015-09-09 12:17 UTC (permalink / raw)
  To: u-boot

On Wednesday, September 09, 2015 at 06:32:24 AM, Simon Glass wrote:
> Add a uclass for keyboard input, mirroring the existing stdio methods.
> This is enabled by a new CONFIG_DM_KEYBOARD option.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---

[...]

> +static int keyboard_pre_probe(struct udevice *dev)
> +{
> +	struct keyboard_priv *priv = dev_get_uclass_priv(dev);
> +	struct stdio_dev *sdev = &priv->sdev;
> +	int ret;
> +
> +	strlcpy(sdev->name, dev->name, sizeof(sdev->name));
> +	sdev->flags = DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
> +	sdev->getc = keyboard_getc;
> +	sdev->tstc = keyboard_tstc;
> +	sdev->start = keyboard_start;
> +	sdev->stop = keyboard_stop;
> +	sdev->priv = dev;
> +	ret = input_init(&priv->input, 0);
> +	if (ret) {
> +		debug("%s: Cannot set up input\n", __func__);

Some better identification of the failing input here would be nice.

> +		return ret;
> +	}
> +
> +	return 0;
> +}

Otherwise,

Reviewed-by: Marek Vasut <marex@denx.de>

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 01/28] dm: input: Create a keyboard uclass
  2015-09-09  4:32 ` [U-Boot] [PATCH 01/28] dm: input: Create a keyboard uclass Simon Glass
  2015-09-09 12:17   ` Marek Vasut
@ 2015-09-15  6:11   ` Bin Meng
  2015-10-18 23:17     ` Simon Glass
  1 sibling, 1 reply; 60+ messages in thread
From: Bin Meng @ 2015-09-15  6:11 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On Wed, Sep 9, 2015 at 12:32 PM, Simon Glass <sjg@chromium.org> wrote:
> Add a uclass for keyboard input, mirroring the existing stdio methods.
> This is enabled by a new CONFIG_DM_KEYBOARD option.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  common/usb_kbd.c                |  6 ---
>  drivers/input/Kconfig           |  9 +++++
>  drivers/input/Makefile          |  2 +
>  drivers/input/keyboard-uclass.c | 84 +++++++++++++++++++++++++++++++++++++++++
>  include/keyboard.h              | 78 ++++++++++++++++++++++++++++++++++++++
>  5 files changed, 173 insertions(+), 6 deletions(-)
>  create mode 100644 drivers/input/keyboard-uclass.c
>
> diff --git a/common/usb_kbd.c b/common/usb_kbd.c
> index 8037ebf..05668fc 100644
> --- a/common/usb_kbd.c
> +++ b/common/usb_kbd.c
> @@ -648,12 +648,6 @@ U_BOOT_DRIVER(usb_kbd) = {
>         .probe = usb_kbd_probe,
>  };
>
> -/* TODO(sjg at chromium.org): Move this into a common location */
> -UCLASS_DRIVER(keyboard) = {
> -       .id             = UCLASS_KEYBOARD,
> -       .name           = "keyboard",
> -};
> -
>  static const struct usb_device_id kbd_id_table[] = {
>         {
>                 .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS |
> diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
> index bb00de7..447c4c3 100644
> --- a/drivers/input/Kconfig
> +++ b/drivers/input/Kconfig
> @@ -1,3 +1,12 @@
> +config DM_KEYBOARD
> +       bool "Enable driver model keyboard support"
> +       depends on DM
> +       help
> +         This adds a uclass for keyboards and implements keyboard support
> +         using driver model. The API is implemented by keyboard.h and
> +         includes methods to start/stop the device, check for available
> +         input and update LEDs if the keyboard has them.
> +
>  config CROS_EC_KEYB
>         bool "Enable Chrome OS EC keyboard support"
>         help
> diff --git a/drivers/input/Makefile b/drivers/input/Makefile
> index b1161c5..9388dfe 100644
> --- a/drivers/input/Makefile
> +++ b/drivers/input/Makefile
> @@ -5,6 +5,8 @@
>  # SPDX-License-Identifier:     GPL-2.0+
>  #
>
> +obj-$(CONFIG_DM_KEYBOARD) += keyboard-uclass.o
> +
>  obj-$(CONFIG_I8042_KBD) += i8042.o
>  obj-$(CONFIG_TEGRA_KEYBOARD) += tegra-kbc.o
>  obj-$(CONFIG_TWL4030_INPUT) += twl4030.o
> diff --git a/drivers/input/keyboard-uclass.c b/drivers/input/keyboard-uclass.c
> new file mode 100644
> index 0000000..1c564dc
> --- /dev/null
> +++ b/drivers/input/keyboard-uclass.c
> @@ -0,0 +1,84 @@
> +/*
> + * Copyright (c) 2015 Google, Inc
> + *
> + * SPDX-License-Identifier:    GPL-2.0+
> + */
> +
> +#include <common.h>
> +#include <dm.h>
> +#include <keyboard.h>
> +
> +static int keyboard_start(struct stdio_dev *sdev)
> +{
> +       struct udevice *dev = sdev->priv;
> +       struct keyboard_ops *ops = keyboard_get_ops(dev);
> +
> +       if (ops->start)
> +               return ops->start(dev);
> +
> +       return 0;

Should we return -ENOSYS here?

> +}
> +
> +static int keyboard_stop(struct stdio_dev *sdev)
> +{
> +       struct udevice *dev = sdev->priv;
> +       struct keyboard_ops *ops = keyboard_get_ops(dev);
> +
> +       if (ops->stop)
> +               return ops->stop(dev);
> +
> +       return 0;

Ditto.

> +}
> +
> +static int keyboard_tstc(struct stdio_dev *sdev)
> +{
> +       struct udevice *dev = sdev->priv;
> +       struct keyboard_priv *priv = dev_get_uclass_priv(dev);
> +
> +       /* Just get input to do this for us if we can */
> +       if (priv->input.dev)
> +               return input_tstc(&priv->input);

else if (op->tstc)
    return ops->tstc(dev);

?

> +
> +       return -ENOSYS;
> +}
> +
> +static int keyboard_getc(struct stdio_dev *sdev)
> +{
> +       struct udevice *dev = sdev->priv;
> +       struct keyboard_priv *priv = dev_get_uclass_priv(dev);
> +
> +       /* Just get input to do this for us if we can */
> +       if (priv->input.dev)
> +               return input_getc(&priv->input);

Ditto.

> +
> +       return -ENOSYS;
> +}
> +
> +static int keyboard_pre_probe(struct udevice *dev)
> +{
> +       struct keyboard_priv *priv = dev_get_uclass_priv(dev);
> +       struct stdio_dev *sdev = &priv->sdev;
> +       int ret;
> +
> +       strlcpy(sdev->name, dev->name, sizeof(sdev->name));
> +       sdev->flags = DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
> +       sdev->getc = keyboard_getc;
> +       sdev->tstc = keyboard_tstc;
> +       sdev->start = keyboard_start;
> +       sdev->stop = keyboard_stop;
> +       sdev->priv = dev;
> +       ret = input_init(&priv->input, 0);
> +       if (ret) {
> +               debug("%s: Cannot set up input\n", __func__);
> +               return ret;
> +       }
> +
> +       return 0;
> +}
> +
> +UCLASS_DRIVER(keyboard) = {
> +       .id             = UCLASS_KEYBOARD,
> +       .name           = "keyboard",
> +       .pre_probe      = keyboard_pre_probe,
> +       .per_device_auto_alloc_size = sizeof(struct keyboard_priv),
> +};
> diff --git a/include/keyboard.h b/include/keyboard.h
> index 88ae12b..a8b68cb 100644
> --- a/include/keyboard.h
> +++ b/include/keyboard.h
> @@ -1,6 +1,83 @@
>  #ifndef __KEYBOARD_H
>  #define __KEYBOARD_H
>
> +#ifdef CONFIG_DM_KEYBOARD
> +#include <input.h>
> +#include <stdio_dev.h>
> +
> +/**
> + * struct keyboard_priv - information about a keyboard, for the uclass
> + *
> + * @sdev:      stdio device
> + * @input:     input configuration (the driver may use this if desired)
> + */
> +struct keyboard_priv {
> +       struct stdio_dev sdev;
> +
> +       /*
> +        * This is set up by the uclass but will only be used if the driver
> +        * sets input.dev to its device pointer (it is initially NULL).
> +        */
> +       struct input_config input;
> +};
> +
> +/**
> + * struct keyboard_ops - keyboard device operations
> + */
> +struct keyboard_ops {
> +       /**
> +        * start() - enable the keyboard ready for use
> +        *
> +        * @dev:        Device to enable
> +        * @return 0 if OK, -ve on error
> +        */
> +       int (*start)(struct udevice *dev);
> +
> +       /**
> +        * stop() - disable the keyboard when no-longer needed
> +        *
> +        * @dev:        Device to disable
> +        * @return 0 if OK, -ve on error
> +        */
> +       int (*stop)(struct udevice *dev);
> +
> +       /**
> +        * tstc() - check if a key is available
> +        *
> +        * @dev:        Device to check
> +        * @return 0 if no key is available, 1 if a key is available

Should we change the return value to bool?

> +        */
> +       int (*tstc)(struct udevice *dev);
> +
> +       /**
> +        * getc() - get a key
> +        *
> +        * TODO(sjg at chromium.org): At present this method may wait if it calls
> +        * input_getc().
> +        *
> +        * @dev:        Device to read from
> +        * @return -EAGAIN if no key is available, otherwise key value read
> +        *         (as ASCII).
> +        */
> +       int (*getc)(struct udevice *dev);
> +
> +       /**
> +        * update_leds() - update keyboard LEDs
> +        *
> +        * This is called when the LEDs have changed and need to be updated.
> +        * For example, if 'caps lock' is pressed then this method will be
> +        * called with the new LED value.
> +        *
> +        * @dev:        Device to update
> +        * @leds:       New LED mask (see INPUT_LED_... in input.h)
> +        */
> +       int (*update_leds)(struct udevice *dev, int leds);
> +};
> +
> +#define keyboard_get_ops(dev)  ((struct keyboard_ops *)(dev)->driver->ops)
> +
> +#else
> +
>  #ifdef CONFIG_PS2MULT
>  #include <ps2mult.h>
>  #endif
> @@ -18,5 +95,6 @@ extern int kbd_init (void);
>  extern void handle_scancode(unsigned char scancode);
>  extern int kbd_init_hw(void);
>  extern void pckbd_leds(unsigned char leds);
> +#endif /* !CONFIG_DM_KEYBOARD */
>
>  #endif /* __KEYBOARD_H */
> --

Regards,
Bin

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 02/28] input: Add a device pointer to the input config
  2015-09-09  4:32 ` [U-Boot] [PATCH 02/28] input: Add a device pointer to the input config Simon Glass
@ 2015-09-15  6:11   ` Bin Meng
  0 siblings, 0 replies; 60+ messages in thread
From: Bin Meng @ 2015-09-15  6:11 UTC (permalink / raw)
  To: u-boot

On Wed, Sep 9, 2015 at 12:32 PM, Simon Glass <sjg@chromium.org> wrote:
> The read_keys() method in input is passed a struct input_config. Add a
> device pointer there so that we can find out the device that is referred
> to with driver model.
>
> Once all drivers are converted we can update the input structure to use
> driver model instead.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  include/input.h | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/include/input.h b/include/input.h
> index 26e2ad7..7bccc8e 100644
> --- a/include/input.h
> +++ b/include/input.h
> @@ -36,6 +36,7 @@ struct input_key_xlate {
>  };
>
>  struct input_config {
> +       struct udevice *dev;
>         uchar fifo[INPUT_BUFFER_LEN];
>         int fifo_in, fifo_out;
>
> --

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 03/28] input: Return -ENOSPC when there is not space
  2015-09-09  4:32 ` [U-Boot] [PATCH 03/28] input: Return -ENOSPC when there is not space Simon Glass
@ 2015-09-15  6:11   ` Bin Meng
  0 siblings, 0 replies; 60+ messages in thread
From: Bin Meng @ 2015-09-15  6:11 UTC (permalink / raw)
  To: u-boot

On Wed, Sep 9, 2015 at 12:32 PM, Simon Glass <sjg@chromium.org> wrote:
> Return a useful error instead of -1 when something goes wrong.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  drivers/input/input.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/input/input.c b/drivers/input/input.c
> index 007b855..9033935 100644
> --- a/drivers/input/input.c
> +++ b/drivers/input/input.c
> @@ -8,6 +8,7 @@
>   */
>
>  #include <common.h>
> +#include <errno.h>
>  #include <stdio_dev.h>
>  #include <input.h>
>  #include <linux/input.h>
> @@ -467,7 +468,7 @@ int input_init(struct input_config *config, int leds)
>                 input_add_table(config, KEY_LEFTCTRL, KEY_RIGHTCTRL,
>                         kbd_ctrl_xlate, ARRAY_SIZE(kbd_ctrl_xlate))) {
>                 debug("%s: Could not add modifier tables\n", __func__);
> -               return -1;
> +               return -ENOSPC;
>         }
>
>         return 0;
> --

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 04/28] input: Add the keycode translation tables separately
  2015-09-09  4:32 ` [U-Boot] [PATCH 04/28] input: Add the keycode translation tables separately Simon Glass
@ 2015-09-15  6:11   ` Bin Meng
  2015-10-18 23:17     ` Simon Glass
  0 siblings, 1 reply; 60+ messages in thread
From: Bin Meng @ 2015-09-15  6:11 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On Wed, Sep 9, 2015 at 12:32 PM, Simon Glass <sjg@chromium.org> wrote:
> Require the caller to add the keycode translation tables separately so that
> it can select which ones to use. In a later patch we will add the option to
> add German tables.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  board/kosagi/novena/novena.c |  1 +
>  drivers/input/cros_ec_keyb.c |  1 +
>  drivers/input/input.c        | 21 ++++++++++++---------
>  drivers/input/tegra-kbc.c    |  1 +
>  include/input.h              | 10 ++++++++++
>  5 files changed, 25 insertions(+), 9 deletions(-)
>
> diff --git a/board/kosagi/novena/novena.c b/board/kosagi/novena/novena.c
> index 69f5be3..48cbb0f 100644
> --- a/board/kosagi/novena/novena.c
> +++ b/board/kosagi/novena/novena.c
> @@ -88,6 +88,7 @@ int drv_keyboard_init(void)
>                 debug("%s: Cannot set up input\n", __func__);
>                 return -1;
>         }
> +       input_add_tables(&button_input);
>         button_input.read_keys = novena_gpio_button_read_keys;
>
>         error = input_stdio_register(&dev);
> diff --git a/drivers/input/cros_ec_keyb.c b/drivers/input/cros_ec_keyb.c
> index a31aa77..eaab86f 100644
> --- a/drivers/input/cros_ec_keyb.c
> +++ b/drivers/input/cros_ec_keyb.c
> @@ -255,6 +255,7 @@ int drv_keyboard_init(void)
>                 return -1;
>         }
>         config.input.read_keys = cros_ec_kbc_check;
> +       input_add_tables(&config.input);
>
>         memset(&dev, '\0', sizeof(dev));
>         strcpy(dev.name, "cros-ec-keyb");
> diff --git a/drivers/input/input.c b/drivers/input/input.c
> index 9033935..0f11ae6 100644
> --- a/drivers/input/input.c
> +++ b/drivers/input/input.c
> @@ -457,19 +457,22 @@ void input_set_delays(struct input_config *config, int repeat_delay_ms,
>         config->repeat_rate_ms = repeat_rate_ms;
>  }
>
> +int input_add_tables(struct input_config *config)
> +{
> +       input_add_table(config, -1, -1,
> +                       kbd_plain_xlate, ARRAY_SIZE(kbd_plain_xlate));
> +       input_add_table(config, KEY_LEFTSHIFT, KEY_RIGHTSHIFT,
> +                       kbd_shift_xlate, ARRAY_SIZE(kbd_shift_xlate));
> +       input_add_table(config, KEY_LEFTCTRL, KEY_RIGHTCTRL,
> +                       kbd_ctrl_xlate, ARRAY_SIZE(kbd_ctrl_xlate));

Should we return error codes here? In previous patch, we've added -ENOSPC.

> +
> +       return 0;
> +}
> +
>  int input_init(struct input_config *config, int leds)
>  {
>         memset(config, '\0', sizeof(*config));
>         config->leds = leds;
> -       if (input_add_table(config, -1, -1,
> -                       kbd_plain_xlate, ARRAY_SIZE(kbd_plain_xlate)) ||
> -               input_add_table(config, KEY_LEFTSHIFT, KEY_RIGHTSHIFT,
> -                       kbd_shift_xlate, ARRAY_SIZE(kbd_shift_xlate)) ||
> -               input_add_table(config, KEY_LEFTCTRL, KEY_RIGHTCTRL,
> -                       kbd_ctrl_xlate, ARRAY_SIZE(kbd_ctrl_xlate))) {
> -               debug("%s: Could not add modifier tables\n", __func__);
> -               return -ENOSPC;
> -       }
>
>         return 0;
>  }
> diff --git a/drivers/input/tegra-kbc.c b/drivers/input/tegra-kbc.c
> index c9c9fac..3310f84 100644
> --- a/drivers/input/tegra-kbc.c
> +++ b/drivers/input/tegra-kbc.c
> @@ -355,6 +355,7 @@ int drv_keyboard_init(void)
>                 return -1;
>         }
>         config.input.read_keys = tegra_kbc_check;
> +       input_add_tables(input);
>
>         memset(&dev, '\0', sizeof(dev));
>         strcpy(dev.name, "tegra-kbc");
> diff --git a/include/input.h b/include/input.h
> index 7bccc8e..71f3538 100644
> --- a/include/input.h
> +++ b/include/input.h
> @@ -123,6 +123,16 @@ void input_set_delays(struct input_config *config, int repeat_delay_ms,
>                int repeat_rate_ms);
>
>  /**
> + * Set up the key map tables
> + *
> + * This must be called after input_init() or keycode decoding will not work.
> + *
> + * @param config       Input state
> + * @return 0 if ok, -1 on error
> + */
> +int input_add_tables(struct input_config *config);
> +
> +/**
>   * Set up the input handler with basic key maps.
>   *
>   * @param config       Input state
> --

Regards,
Bin

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 06/28] dm: stdio: Plumb in the new keyboard uclass
  2015-09-09  4:32 ` [U-Boot] [PATCH 06/28] dm: stdio: Plumb in the new keyboard uclass Simon Glass
@ 2015-09-15  6:11   ` Bin Meng
  2015-10-18 23:17     ` Simon Glass
  2015-10-30 20:24   ` Simon Glass
  1 sibling, 1 reply; 60+ messages in thread
From: Bin Meng @ 2015-09-15  6:11 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On Wed, Sep 9, 2015 at 12:32 PM, Simon Glass <sjg@chromium.org> wrote:
> When driver model is used for keyboards we must scan the available keyboards
> and register them with stdio. Add code to do this.
>
> At some point (once LCD/video is converted) we should be able to convert
> stdio to driver model and avoid these dual data structures.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

Please see one question below.

>  common/stdio.c | 31 ++++++++++++++++++++++++++++++-
>  1 file changed, 30 insertions(+), 1 deletion(-)
>
> diff --git a/common/stdio.c b/common/stdio.c
> index adbfc89..71cc32e 100644
> --- a/common/stdio.c
> +++ b/common/stdio.c
> @@ -11,6 +11,7 @@
>
>  #include <config.h>
>  #include <common.h>
> +#include <dm.h>
>  #include <errno.h>
>  #include <stdarg.h>
>  #include <malloc.h>
> @@ -24,6 +25,8 @@
>  #include <i2c.h>
>  #endif
>
> +#include <dm/device-internal.h>
> +
>  DECLARE_GLOBAL_DATA_PTR;
>
>  static struct stdio_dev devs;
> @@ -245,6 +248,32 @@ int stdio_init_tables(void)
>
>  int stdio_add_devices(void)
>  {
> +#ifdef CONFIG_DM_KEYBOARD
> +       struct udevice *dev;
> +       struct uclass *uc;
> +       int ret;
> +
> +       /*
> +        * For now we probe all the devices here. At some point this should be
> +        * done only when the devices are required - e.g. we have a list of
> +        * input devices to start up in the stdin environment variable. That
> +        * work probably makes more sense when stdio itself is converted to
> +        * driver model.
> +        *
> +        * TODO(sjg at chromium.org): Convert changing uclass_first_device() etc.
> +        * to return the device even on error. Then we could use that here.
> +        */
> +       ret = uclass_get(UCLASS_KEYBOARD, &uc);
> +       if (ret)
> +               return ret;
> +
> +       /* Don't report errors to the caller - assume that they are non-fatal */
> +       uclass_foreach_dev(dev, uc) {
> +               ret = device_probe(dev);
> +               if (ret)
> +                       printf("Failed to probe keyboard '%s'\n", dev->name);
> +       }
> +#endif
>  #ifdef CONFIG_SYS_I2C
>         i2c_init_all();
>  #else
> @@ -258,7 +287,7 @@ int stdio_add_devices(void)
>  #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
>         drv_video_init ();
>  #endif
> -#ifdef CONFIG_KEYBOARD
> +#if defined(CONFIG_KEYBOARD) && !defined(CONFIG_DM_KEYBOARD)

Should we remove this non-dm driver call completely?

>         drv_keyboard_init ();
>  #endif
>  #ifdef CONFIG_LOGBUFFER
> --

Regards,
Bin

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 09/28] video: Drop unused console functions
  2015-09-09  4:32 ` [U-Boot] [PATCH 09/28] video: Drop unused console functions Simon Glass
@ 2015-09-15  6:11   ` Bin Meng
  2015-10-18 23:17     ` Simon Glass
  0 siblings, 1 reply; 60+ messages in thread
From: Bin Meng @ 2015-09-15  6:11 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On Wed, Sep 9, 2015 at 12:32 PM, Simon Glass <sjg@chromium.org> wrote:
> CONFIG_CONSOLE_CURSOR, CONFIG_SYS_CONSOLE_BLINK_COUNT and
> CONFIG_CONSOLE_TIME are not used by any board. The implementation is not
> great and stands in the way of a refactor of i8042. Drop these for now.
> They can be re-introduced quite easily later, perhaps with driver model
> RTC support.

RTC?

>
> When reintroducing, it might be useful to make a few changes:
> - Blink time would be more useful than blink count
> - The confusing #ifdefs should be avoided
> - The time functions should support driver model
> - It would be best keyed off console_tstc() or some similar idle loop
>     rather than a particular input driver (i8042 in this case)
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  README                        |  7 -----
>  drivers/input/i8042.c         | 23 ----------------
>  drivers/video/cfb_console.c   | 62 +++++++------------------------------------
>  include/configs/MPC8536DS.h   |  1 -
>  include/configs/MPC8544DS.h   |  1 -
>  include/configs/MPC8572DS.h   |  1 -
>  include/configs/MPC8641HPCN.h |  1 -
>  7 files changed, 9 insertions(+), 87 deletions(-)
>
> diff --git a/README b/README
> index 08f2f70..54c1d08 100644
> --- a/README
> +++ b/README
> @@ -890,13 +890,6 @@ The following options need to be configured:
>                                                 (i.e. i8042_tstc)
>                         VIDEO_GETC_FCT          get char fct
>                                                 (i.e. i8042_getc)
> -                       CONFIG_CONSOLE_CURSOR   cursor drawing on/off
> -                                               (requires blink timer
> -                                               cf. i8042.c)
> -                       CONFIG_SYS_CONSOLE_BLINK_COUNT blink interval (cf. i8042.c)
> -                       CONFIG_CONSOLE_TIME     display time/date info in
> -                                               upper right corner
> -                                               (requires CONFIG_CMD_DATE)
>                         CONFIG_VIDEO_LOGO       display Linux logo in
>                                                 upper left corner
>                         CONFIG_VIDEO_BMP_LOGO   use bmp_logo.h instead of
> diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c
> index 9b5fa32..7b95b21 100644
> --- a/drivers/input/i8042.c
> +++ b/drivers/input/i8042.c
> @@ -17,12 +17,6 @@
>  #define in8(p)         inb(p)
>  #define out8(p, v)     outb(v, p)
>
> -#ifdef CONFIG_CONSOLE_CURSOR
> -extern void console_cursor(int state);
> -static int blink_count = CONFIG_SYS_CONSOLE_BLINK_COUNT;
> -static int cursor_state;
> -#endif
> -
>  /* locals */
>
>  static int kbd_input = -1;             /* no input yet */
> @@ -598,15 +592,6 @@ int i8042_tstc(struct stdio_dev *dev)
>  {
>         unsigned char scan_code = 0;
>
> -#ifdef CONFIG_CONSOLE_CURSOR
> -       if (--blink_count == 0) {
> -               cursor_state ^= 1;
> -               console_cursor(cursor_state);
> -               blink_count = CONFIG_SYS_CONSOLE_BLINK_COUNT;
> -               udelay(10);
> -       }
> -#endif
> -
>         if ((in8(I8042_STS_REG) & STATUS_OBF) == 0) {
>                 return 0;
>         } else {
> @@ -635,14 +620,6 @@ int i8042_getc(struct stdio_dev *dev)
>
>         while (kbd_input == -1) {
>                 while ((in8(I8042_STS_REG) & STATUS_OBF) == 0) {
> -#ifdef CONFIG_CONSOLE_CURSOR
> -                       if (--blink_count == 0) {
> -                               cursor_state ^= 1;
> -                               console_cursor(cursor_state);
> -                               blink_count = CONFIG_SYS_CONSOLE_BLINK_COUNT;
> -                       }
> -                       udelay(10);
> -#endif
>                 }
>                 scan_code = in8(I8042_DATA_REG);
>                 if (scan_code != 0xfa)
> diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c
> index aa7ca86..1b5c3e0 100644
> --- a/drivers/video/cfb_console.c
> +++ b/drivers/video/cfb_console.c
> @@ -43,13 +43,6 @@
>   * VIDEO_TSTC_FCT            - keyboard_tstc function
>   * VIDEO_GETC_FCT            - keyboard_getc function
>   *
> - * CONFIG_CONSOLE_CURSOR      - on/off drawing cursor is done with
> - *                             delay loop in VIDEO_TSTC_FCT (i8042)
> - *
> - * CONFIG_SYS_CONSOLE_BLINK_COUNT - value for delay loop - blink rate
> - * CONFIG_CONSOLE_TIME       - display time/date in upper right
> - *                             corner, needs CONFIG_CMD_DATE and
> - *                             CONFIG_CONSOLE_CURSOR
>   * CONFIG_VIDEO_LOGO         - display Linux Logo in upper left corner.
>   *                             Use CONFIG_SPLASH_SCREEN_ALIGN with
>   *                             environment variable "splashpos" to place
> @@ -198,9 +191,6 @@
>
>  /*
>   * Cursor definition:
> - * CONFIG_CONSOLE_CURSOR:  Uses a timer function (see drivers/input/i8042.c)
> - *                        to let the cursor blink. Uses the macros
> - *                        CURSOR_OFF and CURSOR_ON.
>   * CONFIG_VIDEO_SW_CURSOR: Draws a cursor after the last character. No
>   *                        blinking is provided. Uses the macros CURSOR_SET
>   *                        and CURSOR_OFF.
> @@ -210,42 +200,29 @@
>   *                        must disable the hardware register of the graphic
>   *                        chip. Otherwise a blinking field is displayed
>   */
> -#if !defined(CONFIG_CONSOLE_CURSOR) && \
> -    !defined(CONFIG_VIDEO_SW_CURSOR) && \
> -    !defined(CONFIG_VIDEO_HW_CURSOR)
> +#if !defined(CONFIG_VIDEO_SW_CURSOR) && !defined(CONFIG_VIDEO_HW_CURSOR)
>  /* no Cursor defined */
>  #define CURSOR_ON
>  #define CURSOR_OFF
>  #define CURSOR_SET
>  #endif
>
> -#if defined(CONFIG_CONSOLE_CURSOR) || defined(CONFIG_VIDEO_SW_CURSOR)
> -#if defined(CURSOR_ON) || \
> -       (defined(CONFIG_CONSOLE_CURSOR) && defined(CONFIG_VIDEO_SW_CURSOR))
> -#error only one of CONFIG_CONSOLE_CURSOR, CONFIG_VIDEO_SW_CURSOR, \
> -       or CONFIG_VIDEO_HW_CURSOR can be defined
> +#if defined(CONFIG_VIDEO_SW_CURSOR)
> +#if defined(CONFIG_VIDEO_HW_CURSOR)

#if defined(CURSOR_ON) || defined(CONFIG_VIDEO_HW_CURSOR) ?

> +#error only one of CONFIG_VIDEO_SW_CURSOR or CONFIG_VIDEO_HW_CURSOR can be \
> +       defined
>  #endif
>  void console_cursor(int state);
>
>  #define CURSOR_ON  console_cursor(1)
>  #define CURSOR_OFF console_cursor(0)
>  #define CURSOR_SET video_set_cursor()
> -#endif /* CONFIG_CONSOLE_CURSOR || CONFIG_VIDEO_SW_CURSOR */
> -
> -#ifdef CONFIG_CONSOLE_CURSOR
> -#ifndef        CONFIG_CONSOLE_TIME
> -#error CONFIG_CONSOLE_CURSOR must be defined for CONFIG_CONSOLE_TIME
> -#endif
> -#ifndef CONFIG_I8042_KBD
> -#warning Cursor drawing on/off needs timer function s.a. drivers/input/i8042.c
> -#endif
> -#endif /* CONFIG_CONSOLE_CURSOR */
> -
> +#endif /* CONFIG_VIDEO_SW_CURSOR */
>
>  #ifdef CONFIG_VIDEO_HW_CURSOR
>  #ifdef CURSOR_ON
> -#error only one of CONFIG_CONSOLE_CURSOR, CONFIG_VIDEO_SW_CURSOR, \
> -       or CONFIG_VIDEO_HW_CURSOR can be defined
> +#error only one of CONFIG_VIDEO_SW_CURSOR or CONFIG_VIDEO_HW_CURSOR can be \
> +       defined
>  #endif
>  #define CURSOR_ON
>  #define CURSOR_OFF
> @@ -626,7 +603,7 @@ static void video_putchar(int xx, int yy, unsigned char c)
>         video_drawchars(xx, yy + video_logo_height, &c, 1);
>  }
>
> -#if defined(CONFIG_CONSOLE_CURSOR) || defined(CONFIG_VIDEO_SW_CURSOR)
> +#if defined(CONFIG_VIDEO_SW_CURSOR)
>  static void video_set_cursor(void)
>  {
>         if (cursor_state)
> @@ -651,27 +628,6 @@ static void video_invertchar(int xx, int yy)
>
>  void console_cursor(int state)
>  {
> -#ifdef CONFIG_CONSOLE_TIME
> -       struct rtc_time tm;
> -       char info[16];
> -
> -       /* time update only if cursor is on (faster scroll) */
> -       if (state) {
> -               rtc_get(&tm);
> -
> -               sprintf(info, " %02d:%02d:%02d ", tm.tm_hour, tm.tm_min,
> -                       tm.tm_sec);
> -               video_drawstring(VIDEO_VISIBLE_COLS - 10 * VIDEO_FONT_WIDTH,
> -                                VIDEO_INFO_Y, (uchar *) info);
> -
> -               sprintf(info, "%02d.%02d.%04d", tm.tm_mday, tm.tm_mon,
> -                       tm.tm_year);
> -               video_drawstring(VIDEO_VISIBLE_COLS - 10 * VIDEO_FONT_WIDTH,
> -                                VIDEO_INFO_Y + 1 * VIDEO_FONT_HEIGHT,
> -                                (uchar *) info);
> -       }
> -#endif
> -
>         if (cursor_state != state) {
>                 if (cursor_state) {
>                         /* turn off the cursor */
> diff --git a/include/configs/MPC8536DS.h b/include/configs/MPC8536DS.h
> index 1312438..fad7215 100644
> --- a/include/configs/MPC8536DS.h
> +++ b/include/configs/MPC8536DS.h
> @@ -533,7 +533,6 @@
>  #define CONFIG_VGA_AS_SINGLE_DEVICE
>  #define CONFIG_ATI_RADEON_FB
>  #define CONFIG_VIDEO_LOGO
> -/*#define CONFIG_CONSOLE_CURSOR*/
>  #define CONFIG_SYS_ISA_IO_BASE_ADDRESS CONFIG_SYS_PCIE3_IO_VIRT
>  #endif
>
> diff --git a/include/configs/MPC8544DS.h b/include/configs/MPC8544DS.h
> index 67fac70..79f402e 100644
> --- a/include/configs/MPC8544DS.h
> +++ b/include/configs/MPC8544DS.h
> @@ -298,7 +298,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);
>  #define CONFIG_VGA_AS_SINGLE_DEVICE
>  #define CONFIG_ATI_RADEON_FB
>  #define CONFIG_VIDEO_LOGO
> -/*#define CONFIG_CONSOLE_CURSOR*/
>  #define CONFIG_SYS_ISA_IO_BASE_ADDRESS VIDEO_IO_OFFSET
>  #endif
>
> diff --git a/include/configs/MPC8572DS.h b/include/configs/MPC8572DS.h
> index f3334ad..d1f2e66 100644
> --- a/include/configs/MPC8572DS.h
> +++ b/include/configs/MPC8572DS.h
> @@ -496,7 +496,6 @@
>  #define CONFIG_VGA_AS_SINGLE_DEVICE
>  #define CONFIG_ATI_RADEON_FB
>  #define CONFIG_VIDEO_LOGO
> -/*#define CONFIG_CONSOLE_CURSOR*/
>  #define CONFIG_SYS_ISA_IO_BASE_ADDRESS VIDEO_IO_OFFSET
>  #endif
>
> diff --git a/include/configs/MPC8641HPCN.h b/include/configs/MPC8641HPCN.h
> index f20ee79..3e23bcf 100644
> --- a/include/configs/MPC8641HPCN.h
> +++ b/include/configs/MPC8641HPCN.h
> @@ -404,7 +404,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);
>  #define CONFIG_VGA_AS_SINGLE_DEVICE
>  #define CONFIG_ATI_RADEON_FB
>  #define CONFIG_VIDEO_LOGO
> -/*#define CONFIG_CONSOLE_CURSOR*/
>  #define CONFIG_SYS_ISA_IO_BASE_ADDRESS CONFIG_SYS_PCIE2_IO_VIRT
>  #endif
>
> --

Regards,
Bin

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 10/28] i8042: Use functions to handle register access
  2015-09-09  4:32 ` [U-Boot] [PATCH 10/28] i8042: Use functions to handle register access Simon Glass
@ 2015-09-15  6:12   ` Bin Meng
  0 siblings, 0 replies; 60+ messages in thread
From: Bin Meng @ 2015-09-15  6:12 UTC (permalink / raw)
  To: u-boot

On Wed, Sep 9, 2015 at 12:32 PM, Simon Glass <sjg@chromium.org> wrote:
> At present the register access in kbd_reset() is quite primitive. This makes
> it hard to follow.
>
> Create functions to read and write data, both to a single register, and via
> the command/data approach.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  drivers/input/i8042.c | 75 ++++++++++++++++++++++++++++++---------------------
>  1 file changed, 44 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c
> index 7b95b21..dbd4b00 100644
> --- a/drivers/input/i8042.c
> +++ b/drivers/input/i8042.c
> @@ -446,53 +446,66 @@ static void kbd_conv_char(unsigned char scan_code)
>         return;
>  }
>
> -static int kbd_reset(void)
> +static int kbd_write(int reg, int value)
>  {
> -       u8 config;
> -
> -       /* controller self test */
> -       if (kbd_input_empty() == 0)
> -               return -1;
> -       out8(I8042_CMD_REG, CMD_SELF_TEST);
> -       if (kbd_output_full() == 0)
> -               return -1;
> -       if (in8(I8042_DATA_REG) != KBC_TEST_OK)
> +       if (!kbd_input_empty())
>                 return -1;
> +       out8(reg, value);
>
> -       /* keyboard reset */
> -       if (kbd_input_empty() == 0)
> +       return 0;
> +}
> +
> +static int kbd_read(int reg)
> +{
> +       if (!kbd_output_full())
>                 return -1;
> -       out8(I8042_DATA_REG, CMD_RESET_KBD);
> -       if (kbd_output_full() == 0)
> +
> +       return in8(reg);
> +}
> +
> +static int kbd_cmd_read(int cmd)
> +{
> +       if (kbd_write(I8042_CMD_REG, cmd))
>                 return -1;
> -       if (in8(I8042_DATA_REG) != KBD_ACK)
> +
> +       return kbd_read(I8042_DATA_REG);
> +}
> +
> +static int kbd_cmd_write(int cmd, int data)
> +{
> +       if (kbd_write(I8042_CMD_REG, cmd))
>                 return -1;
> -       if (kbd_output_full() == 0)
> +
> +       return kbd_write(I8042_DATA_REG, data);
> +}
> +
> +static int kbd_reset(void)
> +{
> +       int config;
> +
> +       /* controller self test */
> +       if (kbd_cmd_read(CMD_SELF_TEST) != KBC_TEST_OK)
>                 return -1;
> -       if (in8(I8042_DATA_REG) != KBD_POR)
> +
> +       /* keyboard reset */
> +       if (kbd_write(I8042_DATA_REG, CMD_RESET_KBD) ||
> +           kbd_read(I8042_DATA_REG) != KBD_ACK ||
> +           kbd_read(I8042_DATA_REG) != KBD_POR)
>                 return -1;
>
>         /* set AT translation and disable irq */
> -       if (kbd_input_empty() == 0)
> -               return -1;
> -       out8(I8042_CMD_REG, CMD_RD_CONFIG);
> -       if (kbd_output_full() == 0)
> +       config = kbd_cmd_read(CMD_RD_CONFIG);
> +       if (config == -1)
>                 return -1;
> -       config = in8(I8042_DATA_REG);
> +
>         config |= CONFIG_AT_TRANS;
>         config &= ~(CONFIG_KIRQ_EN | CONFIG_MIRQ_EN);
> -       if (kbd_input_empty() == 0)
> +       if (kbd_cmd_write(CMD_WR_CONFIG, config))
>                 return -1;
> -       out8(I8042_CMD_REG, CMD_WR_CONFIG);
> -       if (kbd_input_empty() == 0)
> -               return -1;
> -       out8(I8042_DATA_REG, config);
>
>         /* enable keyboard */
> -       if (kbd_input_empty() == 0)
> -               return -1;
> -       out8(I8042_CMD_REG, CMD_KBD_EN);
> -       if (kbd_input_empty() == 0)
> +       if (kbd_write(I8042_CMD_REG, CMD_KBD_EN) ||
> +           !kbd_input_empty())
>                 return -1;
>
>         return 0;
> --

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

Tested on Intel Crown Bay and QEMU
Tested-by: Bin Meng <bmeng.cn@gmail.com>

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 11/28] i8042: Handle a duplicate power-on-reset response
  2015-09-09  4:32 ` [U-Boot] [PATCH 11/28] i8042: Handle a duplicate power-on-reset response Simon Glass
@ 2015-09-15  6:12   ` Bin Meng
  0 siblings, 0 replies; 60+ messages in thread
From: Bin Meng @ 2015-09-15  6:12 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On Wed, Sep 9, 2015 at 12:32 PM, Simon Glass <sjg@chromium.org> wrote:
> Sometimes we seem to get 0xaa twice which causes the config read to fail.
> This causes chromebook_link to fail to set up the keyboard.
>
> Add a check for this and read the config again when detected.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  drivers/input/i8042.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c
> index dbd4b00..c6a92a2 100644
> --- a/drivers/input/i8042.c
> +++ b/drivers/input/i8042.c
> @@ -497,6 +497,8 @@ static int kbd_reset(void)
>         config = kbd_cmd_read(CMD_RD_CONFIG);
>         if (config == -1)
>                 return -1;
> +       else if (config == KBD_POR)     /* Sometimes get a second byte */
> +               config = kbd_cmd_read(CMD_RD_CONFIG);
>
>         config |= CONFIG_AT_TRANS;
>         config &= ~(CONFIG_KIRQ_EN | CONFIG_MIRQ_EN);
> --

This unfortunately breaks QEMU, that sometimes (not every time)
keyboard is not working. Maybe we should create a device tree property
to control such quirk?

Regards,
Bin

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 12/28] i8042: Adjust kbd_reset() to collect all failures
  2015-09-09  4:32 ` [U-Boot] [PATCH 12/28] i8042: Adjust kbd_reset() to collect all failures Simon Glass
@ 2015-09-15  6:12   ` Bin Meng
  0 siblings, 0 replies; 60+ messages in thread
From: Bin Meng @ 2015-09-15  6:12 UTC (permalink / raw)
  To: u-boot

On Wed, Sep 9, 2015 at 12:32 PM, Simon Glass <sjg@chromium.org> wrote:
> Rather than lots of 'return' statements, use goto to a single return.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  drivers/input/i8042.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c
> index c6a92a2..ef01bd0 100644
> --- a/drivers/input/i8042.c
> +++ b/drivers/input/i8042.c
> @@ -485,32 +485,35 @@ static int kbd_reset(void)
>
>         /* controller self test */
>         if (kbd_cmd_read(CMD_SELF_TEST) != KBC_TEST_OK)
> -               return -1;
> +               goto err;
>
>         /* keyboard reset */
>         if (kbd_write(I8042_DATA_REG, CMD_RESET_KBD) ||
>             kbd_read(I8042_DATA_REG) != KBD_ACK ||
>             kbd_read(I8042_DATA_REG) != KBD_POR)
> -               return -1;
> +               goto err;
>
>         /* set AT translation and disable irq */
>         config = kbd_cmd_read(CMD_RD_CONFIG);
>         if (config == -1)
> -               return -1;
> +               goto err;
>         else if (config == KBD_POR)     /* Sometimes get a second byte */
>                 config = kbd_cmd_read(CMD_RD_CONFIG);
>
>         config |= CONFIG_AT_TRANS;
>         config &= ~(CONFIG_KIRQ_EN | CONFIG_MIRQ_EN);
>         if (kbd_cmd_write(CMD_WR_CONFIG, config))
> -               return -1;
> +               goto err;
>
>         /* enable keyboard */
>         if (kbd_write(I8042_CMD_REG, CMD_KBD_EN) ||
>             !kbd_input_empty())
> -               return -1;
> +               goto err;
>
>         return 0;
> +err:
> +       debug("%s: Keyboard failure\n", __func__);
> +       return -1;
>  }
>
>  static int kbd_controller_present(void)
> --

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 13/28] i8042: Adjust keyboard init to assume success
  2015-09-09  4:32 ` [U-Boot] [PATCH 13/28] i8042: Adjust keyboard init to assume success Simon Glass
@ 2015-09-15  6:12   ` Bin Meng
  0 siblings, 0 replies; 60+ messages in thread
From: Bin Meng @ 2015-09-15  6:12 UTC (permalink / raw)
  To: u-boot

On Wed, Sep 9, 2015 at 12:32 PM, Simon Glass <sjg@chromium.org> wrote:
> Modify i8042_kbd_init() so that the normal pass is sucessful init and
> failure exits early. This will make the code easier to extend and is easier
> to read.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  drivers/input/i8042.c | 19 +++++++++----------
>  1 file changed, 9 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c
> index ef01bd0..1c6a31e 100644
> --- a/drivers/input/i8042.c
> +++ b/drivers/input/i8042.c
> @@ -587,18 +587,17 @@ int i8042_kbd_init(void)
>                         keymap = KBD_GER;
>         }
>
> -       for (try = 0; try < KBD_RESET_TRIES; try++) {
> -               if (kbd_reset() == 0) {
> -                       kbd_mapping = keymap;
> -                       kbd_flags   = NORMAL;
> -                       kbd_state   = 0;
> -                       kbd_led_set();
> -
> -                       return 0;
> -               }
> +       for (try = 0; kbd_reset() != 0; try++) {
> +               if (try >= KBD_RESET_TRIES)
> +                       return -1;
>         }
>
> -       return -1;
> +       kbd_mapping = keymap;
> +       kbd_flags   = NORMAL;
> +       kbd_state   = 0;
> +       kbd_led_set();
> +
> +       return 0;
>  }
>
>  /*
> --

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 15/28] input: Add a few more keyboard keycodes
  2015-09-09  4:32 ` [U-Boot] [PATCH 15/28] input: Add a few more keyboard keycodes Simon Glass
@ 2015-09-15  6:12   ` Bin Meng
  0 siblings, 0 replies; 60+ messages in thread
From: Bin Meng @ 2015-09-15  6:12 UTC (permalink / raw)
  To: u-boot

On Wed, Sep 9, 2015 at 12:32 PM, Simon Glass <sjg@chromium.org> wrote:
> The  slash and * are missing from the keycode tables. Add these so that

nits: there are two spaces before 'slash'

> these keypad keys can be used.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  drivers/input/input.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/input/input.c b/drivers/input/input.c
> index 95006a9..ec49d0f 100644
> --- a/drivers/input/input.c
> +++ b/drivers/input/input.c
> @@ -43,7 +43,7 @@ static const uchar kbd_plain_xlate[] = {
>         '8',  '9',  '-',  '4',  '5',  '6',  '+',  '1',  /* 0x40 - 0x4f */
>         '2',  '3',  '0',  '.', 0xff, 0xff, 0xff, 0xff,
>         0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x50 - 0x5F */
> -       '\r', 0xff, 0xff
> +       '\r', 0xff, '/',  '*',
>  };
>
>  static unsigned char kbd_shift_xlate[] = {
> @@ -59,7 +59,7 @@ static unsigned char kbd_shift_xlate[] = {
>         '8', '9', '-', '4', '5', '6', '+', '1', /* 0x40 - 0x4f */
>         '2', '3', '0', '.', 0xff, 0xff, 0xff, 0xff, 0xff,
>         0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,       /* 0x50 - 0x5F */
> -       '\r', 0xff, 0xff
> +       '\r', 0xff, '/',  '*',
>  };
>
>  static unsigned char kbd_ctrl_xlate[] = {
> @@ -75,7 +75,7 @@ static unsigned char kbd_ctrl_xlate[] = {
>         '8', '9', '-', '4', '5', '6', '+', '1',         /* 0x40 - 0x4f */
>         '2', '3', '0', '.', 0xff, 0xff, 0xff, 0xff,
>         0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x50 - 0x5F */
> -       '\r', 0xff, 0xff
> +       '\r', 0xff, '/',  '*',
>  };
>
>  /*
> --

Regards,
Bin

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 18/28] input: Support the German keymap
  2015-09-09  4:32 ` [U-Boot] [PATCH 18/28] input: Support the German keymap Simon Glass
@ 2015-09-15  6:12   ` Bin Meng
  2015-10-18 23:17     ` Simon Glass
  0 siblings, 1 reply; 60+ messages in thread
From: Bin Meng @ 2015-09-15  6:12 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On Wed, Sep 9, 2015 at 12:32 PM, Simon Glass <sjg@chromium.org> wrote:
> Add support for the German keymap, taken from i8042.c. This can be selected
> when the input library it initialised.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  board/kosagi/novena/novena.c |  2 +-
>  drivers/input/cros_ec_keyb.c |  2 +-
>  drivers/input/input.c        | 82 ++++++++++++++++++++++++++++++++++++++++----
>  drivers/input/tegra-kbc.c    |  2 +-
>  include/input.h              |  3 +-
>  5 files changed, 80 insertions(+), 11 deletions(-)
>
> diff --git a/board/kosagi/novena/novena.c b/board/kosagi/novena/novena.c
> index 48cbb0f..0b61365 100644
> --- a/board/kosagi/novena/novena.c
> +++ b/board/kosagi/novena/novena.c
> @@ -88,7 +88,7 @@ int drv_keyboard_init(void)
>                 debug("%s: Cannot set up input\n", __func__);
>                 return -1;
>         }
> -       input_add_tables(&button_input);
> +       input_add_tables(&button_input, false);
>         button_input.read_keys = novena_gpio_button_read_keys;
>
>         error = input_stdio_register(&dev);
> diff --git a/drivers/input/cros_ec_keyb.c b/drivers/input/cros_ec_keyb.c
> index fe5caea..9bc4555 100644
> --- a/drivers/input/cros_ec_keyb.c
> +++ b/drivers/input/cros_ec_keyb.c
> @@ -211,7 +211,7 @@ static int cros_ec_kbd_probe(struct udevice *dev)
>
>         priv->input = input;
>         input->dev = dev;
> -       input_add_tables(input);
> +       input_add_tables(input, false);
>         input->read_keys = cros_ec_kbc_check;
>         strcpy(sdev->name, "cros-ec-keyb");
>
> diff --git a/drivers/input/input.c b/drivers/input/input.c
> index c488f3a..a54449e 100644
> --- a/drivers/input/input.c
> +++ b/drivers/input/input.c
> @@ -78,6 +78,60 @@ static unsigned char kbd_ctrl_xlate[] = {
>         '\r', 0xff, '/',  '*',
>  };
>
> +static const uchar kbd_plain_xlate_german[] = {
> +       0xff, 0x1b,  '1',  '2',  '3',  '4',  '5',  '6', /* scan 00-07 */
> +        '7',  '8',  '9',  '0', 0xe1, '\'', 0x08, '\t', /* scan 08-0F */
> +        'q',  'w',  'e',  'r',  't',  'z',  'u',  'i', /* scan 10-17 */
> +        'o',  'p', 0x81,  '+', '\r', 0xff,  'a',  's', /* scan 18-1F */
> +        'd',  'f',  'g',  'h',  'j',  'k',  'l', 0x94, /* scan 20-27 */
> +       0x84,  '^', 0xff,  '#',  'y',  'x',  'c',  'v', /* scan 28-2F */
> +        'b',  'n',  'm',  ',',  '.',  '-', 0xff,  '*', /* scan 30-37 */
> +        ' ',  ' ', 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 38-3F */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,  '7', /* scan 40-47 */
> +        '8',  '9',  '-',  '4',  '5',  '6',  '+',  '1', /* scan 48-4F */
> +        '2',  '3',  '0',  ',', 0xff, 0xff,  '<', 0xff, /* scan 50-57 */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 58-5F */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 60-67 */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 68-6F */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 70-77 */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 78-7F */
> +       '\r', 0xff,  '/',  '*',
> +};
> +
> +static unsigned char kbd_shift_xlate_german[] = {
> +          0xff, 0x1b,  '!',  '"', 0x15,  '$',  '%',  '&', /* scan 00-07 */
> +        '/',  '(',  ')',  '=',  '?',  '`', 0x08, '\t', /* scan 08-0F */
> +        'Q',  'W',  'E',  'R',  'T',  'Z',  'U',  'I', /* scan 10-17 */
> +        'O',  'P', 0x9a,  '*', '\r', 0xff,  'A',  'S', /* scan 18-1F */
> +        'D',  'F',  'G',  'H',  'J',  'K',  'L', 0x99, /* scan 20-27 */
> +       0x8e, 0xf8, 0xff, '\'',  'Y',  'X',  'C',  'V', /* scan 28-2F */
> +        'B',  'N',  'M',  ';',  ':',  '_', 0xff,  '*', /* scan 30-37 */
> +        ' ',  ' ', 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 38-3F */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,  '7', /* scan 40-47 */
> +        '8',  '9',  '-',  '4',  '5',  '6',  '+',  '1', /* scan 48-4F */
> +        '2',  '3',  '0',  ',', 0xff, 0xff,  '>', 0xff, /* scan 50-57 */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 58-5F */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 60-67 */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 68-6F */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 70-77 */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 78-7F */
> +       '\r', 0xff,  '/',  '*',
> +};
> +
> +static unsigned char kbd_right_alt_xlate_german[] = {
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 00-07 */
> +        '{',  '[',  ']',  '}', '\\', 0xff, 0xff, 0xff, /* scan 08-0F */
> +        '@', 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 10-17 */
> +       0xff, 0xff, 0xff,  '~', 0xff, 0xff, 0xff, 0xff, /* scan 18-1F */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 20-27 */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 28-2F */
> +       0xff, 0xff, 0xe6, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 30-37 */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 38-3F */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 40-47 */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 48-4F */
> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff,  '|', 0xff, /* scan 50-57 */
> +};
> +
>  /*
>   * Scan key code to ANSI 3.64 escape sequence table.  This table is
>   * incomplete in that it does not include all possible extra keys.
> @@ -500,14 +554,28 @@ void input_allow_repeats(struct input_config *config, bool allow_repeats)
>         config->allow_repeats = allow_repeats;
>  }
>
> -int input_add_tables(struct input_config *config)
> +int input_add_tables(struct input_config *config, bool german)
>  {
> -       input_add_table(config, -1, -1,
> -                       kbd_plain_xlate, ARRAY_SIZE(kbd_plain_xlate));
> -       input_add_table(config, KEY_LEFTSHIFT, KEY_RIGHTSHIFT,
> -                       kbd_shift_xlate, ARRAY_SIZE(kbd_shift_xlate));
> -       input_add_table(config, KEY_LEFTCTRL, KEY_RIGHTCTRL,
> -                       kbd_ctrl_xlate, ARRAY_SIZE(kbd_ctrl_xlate));
> +       if (german) {
> +               input_add_table(config, -1, -1,
> +                               kbd_plain_xlate_german,
> +                               ARRAY_SIZE(kbd_plain_xlate_german));
> +               input_add_table(config, KEY_LEFTSHIFT, KEY_RIGHTSHIFT,
> +                               kbd_shift_xlate_german,
> +                               ARRAY_SIZE(kbd_shift_xlate_german));
> +               input_add_table(config, KEY_LEFTCTRL, KEY_RIGHTCTRL,
> +                               kbd_ctrl_xlate, ARRAY_SIZE(kbd_ctrl_xlate));
> +       } else {
> +               input_add_table(config, -1, -1,
> +                               kbd_plain_xlate, ARRAY_SIZE(kbd_plain_xlate));
> +               input_add_table(config, KEY_LEFTSHIFT, KEY_RIGHTSHIFT,
> +                               kbd_shift_xlate, ARRAY_SIZE(kbd_shift_xlate));
> +               input_add_table(config, KEY_LEFTCTRL, KEY_RIGHTCTRL,
> +                               kbd_ctrl_xlate, ARRAY_SIZE(kbd_ctrl_xlate));
> +               input_add_table(config, -1, KEY_RIGHTALT,
> +                               kbd_right_alt_xlate_german,
> +                               ARRAY_SIZE(kbd_right_alt_xlate_german));
> +       }
>
>         return 0;
>  }
> diff --git a/drivers/input/tegra-kbc.c b/drivers/input/tegra-kbc.c
> index a7137f1..951cbb4 100644
> --- a/drivers/input/tegra-kbc.c
> +++ b/drivers/input/tegra-kbc.c
> @@ -326,7 +326,7 @@ static int tegra_kbd_probe(struct udevice *dev)
>         priv->input = input;
>         input->dev = dev;
>         input->read_keys = tegra_kbc_check;
> -       input_add_tables(input);
> +       input_add_tables(input, false);
>         strcpy(sdev->name, "tegra-kbc");
>         ret = input_stdio_register(sdev);
>         if (ret) {
> diff --git a/include/input.h b/include/input.h
> index e56f500..c1af259 100644
> --- a/include/input.h
> +++ b/include/input.h
> @@ -167,9 +167,10 @@ void input_allow_repeats(struct input_config *config, bool allow_repeats);
>   * This must be called after input_init() or keycode decoding will not work.
>   *
>   * @param config       Input state
> + * @param german       true to use German keyboard layout, false for US
>   * @return 0 if ok, -1 on error
>   */
> -int input_add_tables(struct input_config *config);
> +int input_add_tables(struct input_config *config, bool german);

Can we create some extensible parameter for keyboard layout? What if
in the future we add a 3rd layout?

>
>  /**
>   * Set up the input handler with basic key maps.
> --

Regards,
Bin

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 22/28] input: i8042: Convert to use the input library
  2015-09-09  4:32 ` [U-Boot] [PATCH 22/28] input: i8042: Convert to use the input library Simon Glass
@ 2015-09-15  6:12   ` Bin Meng
  0 siblings, 0 replies; 60+ messages in thread
From: Bin Meng @ 2015-09-15  6:12 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On Wed, Sep 9, 2015 at 12:32 PM, Simon Glass <sjg@chromium.org> wrote:
> At present the i8042 driver has its own logic and keymaps. In an effort to
> unify the code, move it over to use the input library. This changes most of
> the keycode-processing logic since it is now in that library. The main
> responsibilities of the driver are now to handle the LEDs, deal with the
> PS/2 extended keycodes and initialise the the keyboard.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  drivers/input/i8042.c | 491 +++++++-------------------------------------------
>  1 file changed, 70 insertions(+), 421 deletions(-)
>
> diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c
> index 1c6a31e..5ebb571 100644
> --- a/drivers/input/i8042.c
> +++ b/drivers/input/i8042.c
> @@ -7,251 +7,18 @@
>
>  /* i8042.c - Intel 8042 keyboard driver routines */
>
> -/* includes */
> -
>  #include <common.h>
> -#include <asm/io.h>
>  #include <i8042.h>
> +#include <input.h>
> +#include <asm/io.h>
>
>  /* defines */
>  #define in8(p)         inb(p)
>  #define out8(p, v)     outb(v, p)
>
>  /* locals */
> -
> -static int kbd_input = -1;             /* no input yet */
> -static int kbd_mapping = KBD_US;       /* default US keyboard */
> -static int kbd_flags = NORMAL;         /* after reset */
> -static int kbd_state;                  /* unshift code */
> -
> -static unsigned char kbd_fct_map[144] = {
> -       /* kbd_fct_map table for scan code */
> -        0,  AS,  AS,  AS,  AS,  AS,  AS,  AS, /* scan 00-07 */
> -       AS,  AS,  AS,  AS,  AS,  AS,  AS,  AS, /* scan 08-0F */
> -       AS,  AS,  AS,  AS,  AS,  AS,  AS,  AS, /* scan 10-17 */
> -       AS,  AS,  AS,  AS,  AS,  CN,  AS,  AS, /* scan 18-1F */
> -       AS,  AS,  AS,  AS,  AS,  AS,  AS,  AS, /* scan 20-27 */
> -       AS,  AS,  SH,  AS,  AS,  AS,  AS,  AS, /* scan 28-2F */
> -       AS,  AS,  AS,  AS,  AS,  AS,  SH,  AS, /* scan 30-37 */
> -       AS,  AS,  CP,   0,   0,   0,   0,   0, /* scan 38-3F */
> -        0,   0,   0,   0,   0,  NM,  ST,  ES, /* scan 40-47 */
> -       ES,  ES,  ES,  ES,  ES,  ES,  ES,  ES, /* scan 48-4F */
> -       ES,  ES,  ES,  ES,   0,   0,  AS,   0, /* scan 50-57 */
> -        0,   0,   0,   0,   0,   0,   0,   0, /* scan 58-5F */
> -        0,   0,   0,   0,   0,   0,   0,   0, /* scan 60-67 */
> -        0,   0,   0,   0,   0,   0,   0,   0, /* scan 68-6F */
> -       AS,   0,   0,  AS,   0,   0,  AS,   0, /* scan 70-77 */
> -        0,  AS,   0,   0,   0,  AS,   0,   0, /* scan 78-7F */
> -       AS,  CN,  AS,  AS,  AK,  ST,  EX,  EX, /* enhanced */
> -       AS,  EX,  EX,  AS,  EX,  AS,  EX,  EX  /* enhanced */
> -       };
> -
> -static unsigned char kbd_key_map[2][5][144] = {
> -       { /* US keyboard */
> -       { /* unshift code */
> -          0, 0x1b,  '1',  '2',  '3',  '4',  '5',  '6', /* scan 00-07 */
> -        '7',  '8',  '9',  '0',  '-',  '=', 0x08, '\t', /* scan 08-0F */
> -        'q',  'w',  'e',  'r',  't',  'y',  'u',  'i', /* scan 10-17 */
> -        'o',  'p',  '[',  ']', '\r',   CN,  'a',  's', /* scan 18-1F */
> -        'd',  'f',  'g',  'h',  'j',  'k',  'l',  ';', /* scan 20-27 */
> -       '\'',  '`',   SH, '\\',  'z',  'x',  'c',  'v', /* scan 28-2F */
> -        'b',  'n',  'm',  ',',  '.',  '/',   SH,  '*', /* scan 30-37 */
> -        ' ',  ' ',   CP,    0,    0,    0,    0,    0, /* scan 38-3F */
> -          0,    0,    0,    0,    0,   NM,   ST,  '7', /* scan 40-47 */
> -        '8',  '9',  '-',  '4',  '5',  '6',  '+',  '1', /* scan 48-4F */
> -        '2',  '3',  '0',  '.',    0,    0,    0,    0, /* scan 50-57 */
> -          0,    0,    0,    0,    0,    0,    0,    0, /* scan 58-5F */
> -          0,    0,    0,    0,    0,    0,    0,    0, /* scan 60-67 */
> -          0,    0,    0,    0,    0,    0,    0,    0, /* scan 68-6F */
> -          0,    0,    0,    0,    0,    0,    0,    0, /* scan 70-77 */
> -          0,    0,    0,    0,    0,    0,    0,    0, /* scan 78-7F */
> -       '\r',   CN,  '/',  '*',  ' ',   ST,  'F',  'A', /* extended */
> -          0,  'D',  'C',    0,  'B',    0,  '@',  'P'  /* extended */
> -       },
> -       { /* shift code */
> -          0, 0x1b,  '!',  '@',  '#',  '$',  '%',  '^', /* scan 00-07 */
> -        '&',  '*',  '(',  ')',  '_',  '+', 0x08, '\t', /* scan 08-0F */
> -        'Q',  'W',  'E',  'R',  'T',  'Y',  'U',  'I', /* scan 10-17 */
> -        'O',  'P',  '{',  '}', '\r',   CN,  'A',  'S', /* scan 18-1F */
> -        'D',  'F',  'G',  'H',  'J',  'K',  'L',  ':', /* scan 20-27 */
> -        '"',  '~',   SH,  '|',  'Z',  'X',  'C',  'V', /* scan 28-2F */
> -        'B',  'N',  'M',  '<',  '>',  '?',   SH,  '*', /* scan 30-37 */
> -        ' ',  ' ',   CP,    0,    0,    0,    0,    0, /* scan 38-3F */
> -          0,    0,    0,    0,    0,   NM,   ST,  '7', /* scan 40-47 */
> -        '8',  '9',  '-',  '4',  '5',  '6',  '+',  '1', /* scan 48-4F */
> -        '2',  '3',  '0',  '.',    0,    0,    0,    0, /* scan 50-57 */
> -          0,    0,    0,    0,    0,    0,    0,    0, /* scan 58-5F */
> -          0,    0,    0,    0,    0,    0,    0,    0, /* scan 60-67 */
> -          0,    0,    0,    0,    0,    0,    0,    0, /* scan 68-6F */
> -          0,    0,    0,    0,    0,    0,    0,    0, /* scan 70-77 */
> -          0,    0,    0,    0,    0,    0,    0,    0, /* scan 78-7F */
> -       '\r',   CN,  '/',  '*',  ' ',   ST,  'F',  'A', /* extended */
> -          0,  'D',  'C',    0,  'B',    0,  '@',  'P'  /* extended */
> -       },
> -       { /* control code */
> -       0xff, 0x1b, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, /* scan 00-07 */
> -       0x1e, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, '\t', /* scan 08-0F */
> -       0x11, 0x17, 0x05, 0x12, 0x14, 0x19, 0x15, 0x09, /* scan 10-17 */
> -       0x0f, 0x10, 0x1b, 0x1d, '\r',   CN, 0x01, 0x13, /* scan 18-1F */
> -       0x04, 0x06, 0x07, 0x08, 0x0a, 0x0b, 0x0c, 0xff, /* scan 20-27 */
> -       0xff, 0x1c,   SH, 0xff, 0x1a, 0x18, 0x03, 0x16, /* scan 28-2F */
> -       0x02, 0x0e, 0x0d, 0xff, 0xff, 0xff,   SH, 0xff, /* scan 30-37 */
> -       0xff, 0xff,   CP, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 38-3F */
> -       0xff, 0xff, 0xff, 0xff, 0xff,   NM,   ST, 0xff, /* scan 40-47 */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 48-4F */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 50-57 */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 58-5F */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 60-67 */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 68-6F */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 70-77 */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 78-7F */
> -       '\r',   CN,  '/',  '*',  ' ',   ST, 0xff, 0xff, /* extended */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff  /* extended */
> -       },
> -       { /* non numeric code */
> -          0, 0x1b,  '1',  '2',  '3',  '4',  '5',  '6', /* scan 00-07 */
> -        '7',  '8',  '9',  '0',  '-',  '=', 0x08, '\t', /* scan 08-0F */
> -        'q',  'w',  'e',  'r',  't',  'y',  'u',  'i', /* scan 10-17 */
> -        'o',  'p',  '[',  ']', '\r',   CN,  'a',  's', /* scan 18-1F */
> -        'd',  'f',  'g',  'h',  'j',  'k',  'l',  ';', /* scan 20-27 */
> -       '\'',  '`',   SH, '\\',  'z',  'x',  'c',  'v', /* scan 28-2F */
> -        'b',  'n',  'm',  ',',  '.',  '/',   SH,  '*', /* scan 30-37 */
> -        ' ',  ' ',   CP,    0,    0,    0,    0,    0, /* scan 38-3F */
> -          0,    0,    0,    0,    0,   NM,   ST,  'w', /* scan 40-47 */
> -        'x',  'y',  'l',  't',  'u',  'v',  'm',  'q', /* scan 48-4F */
> -        'r',  's',  'p',  'n',    0,    0,    0,    0, /* scan 50-57 */
> -          0,    0,    0,    0,    0,    0,    0,    0, /* scan 58-5F */
> -          0,    0,    0,    0,    0,    0,    0,    0, /* scan 60-67 */
> -          0,    0,    0,    0,    0,    0,    0,    0, /* scan 68-6F */
> -          0,    0,    0,    0,    0,    0,    0,    0, /* scan 70-77 */
> -          0,    0,    0,    0,    0,    0,    0,    0, /* scan 78-7F */
> -       '\r',   CN,  '/',  '*',  ' ',   ST,  'F',  'A', /* extended */
> -          0,  'D',  'C',    0,  'B',    0,  '@',  'P'  /* extended */
> -       },
> -       { /* right alt mode - not used in US keyboard */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 00-07 */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 08-0F */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 10-17 */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 18-1F */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 20-27 */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 28-2F */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 30-37 */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 38-3F */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 40-47 */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 48-4F */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 50-57 */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 58-5F */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 60-67 */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 68-6F */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 70-77 */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 78-7F */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* extended */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff  /* extended */
> -       }
> -       },
> -       { /* German keyboard */
> -       { /* unshift code */
> -          0, 0x1b,  '1',  '2',  '3',  '4',  '5',  '6', /* scan 00-07 */
> -        '7',  '8',  '9',  '0', 0xe1, '\'', 0x08, '\t', /* scan 08-0F */
> -        'q',  'w',  'e',  'r',  't',  'z',  'u',  'i', /* scan 10-17 */
> -        'o',  'p', 0x81,  '+', '\r',   CN,  'a',  's', /* scan 18-1F */
> -        'd',  'f',  'g',  'h',  'j',  'k',  'l', 0x94, /* scan 20-27 */
> -       0x84,  '^',   SH,  '#',  'y',  'x',  'c',  'v', /* scan 28-2F */
> -        'b',  'n',  'm',  ',',  '.',  '-',   SH,  '*', /* scan 30-37 */
> -        ' ',  ' ',   CP,    0,    0,    0,    0,    0, /* scan 38-3F */
> -          0,    0,    0,    0,    0,   NM,   ST,  '7', /* scan 40-47 */
> -        '8',  '9',  '-',  '4',  '5',  '6',  '+',  '1', /* scan 48-4F */
> -        '2',  '3',  '0',  ',',    0,    0,  '<',    0, /* scan 50-57 */
> -          0,    0,    0,    0,    0,    0,    0,    0, /* scan 58-5F */
> -          0,    0,    0,    0,    0,    0,    0,    0, /* scan 60-67 */
> -          0,    0,    0,    0,    0,    0,    0,    0, /* scan 68-6F */
> -          0,    0,    0,    0,    0,    0,    0,    0, /* scan 70-77 */
> -          0,    0,    0,    0,    0,    0,    0,    0, /* scan 78-7F */
> -       '\r',   CN,  '/',  '*',  ' ',   ST,  'F',  'A', /* extended */
> -          0,  'D',  'C',    0,  'B',    0,  '@',  'P'  /* extended */
> -       },
> -       { /* shift code */
> -          0, 0x1b,  '!',  '"', 0x15,  '$',  '%',  '&', /* scan 00-07 */
> -        '/',  '(',  ')',  '=',  '?',  '`', 0x08, '\t', /* scan 08-0F */
> -        'Q',  'W',  'E',  'R',  'T',  'Z',  'U',  'I', /* scan 10-17 */
> -        'O',  'P', 0x9a,  '*', '\r',   CN,  'A',  'S', /* scan 18-1F */
> -        'D',  'F',  'G',  'H',  'J',  'K',  'L', 0x99, /* scan 20-27 */
> -       0x8e, 0xf8,   SH, '\'',  'Y',  'X',  'C',  'V', /* scan 28-2F */
> -        'B',  'N',  'M',  ';',  ':',  '_',   SH,  '*', /* scan 30-37 */
> -        ' ',  ' ',   CP,    0,    0,    0,    0,    0, /* scan 38-3F */
> -          0,    0,    0,    0,    0,   NM,   ST,  '7', /* scan 40-47 */
> -        '8',  '9',  '-',  '4',  '5',  '6',  '+',  '1', /* scan 48-4F */
> -        '2',  '3',  '0',  ',',    0,    0,  '>',    0, /* scan 50-57 */
> -          0,    0,    0,    0,    0,    0,    0,    0, /* scan 58-5F */
> -          0,    0,    0,    0,    0,    0,    0,    0, /* scan 60-67 */
> -          0,    0,    0,    0,    0,    0,    0,    0, /* scan 68-6F */
> -          0,    0,    0,    0,    0,    0,    0,    0, /* scan 70-77 */
> -          0,    0,    0,    0,    0,    0,    0,    0, /* scan 78-7F */
> -       '\r',   CN,  '/',  '*',  ' ',   ST,  'F',  'A', /* extended */
> -          0,  'D',  'C',    0,  'B',    0,  '@',  'P'  /* extended */
> -       },
> -       { /* control code */
> -       0xff, 0x1b, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, /* scan 00-07 */
> -       0x1e, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, '\t', /* scan 08-0F */
> -       0x11, 0x17, 0x05, 0x12, 0x14, 0x19, 0x15, 0x09, /* scan 10-17 */
> -       0x0f, 0x10, 0x1b, 0x1d, '\r',   CN, 0x01, 0x13, /* scan 18-1F */
> -       0x04, 0x06, 0x07, 0x08, 0x0a, 0x0b, 0x0c, 0xff, /* scan 20-27 */
> -       0xff, 0x1c,   SH, 0xff, 0x1a, 0x18, 0x03, 0x16, /* scan 28-2F */
> -       0x02, 0x0e, 0x0d, 0xff, 0xff, 0xff,   SH, 0xff, /* scan 30-37 */
> -       0xff, 0xff,   CP, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 38-3F */
> -       0xff, 0xff, 0xff, 0xff, 0xff,   NM,   ST, 0xff, /* scan 40-47 */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 48-4F */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 50-57 */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 58-5F */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 60-67 */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 68-6F */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 70-77 */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 78-7F */
> -       '\r',   CN,  '/',  '*',  ' ',   ST, 0xff, 0xff, /* extended */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff  /* extended */
> -       },
> -       { /* non numeric code */
> -          0, 0x1b,  '1',  '2',  '3',  '4',  '5',  '6', /* scan 00-07 */
> -        '7',  '8',  '9',  '0', 0xe1, '\'', 0x08, '\t', /* scan 08-0F */
> -        'q',  'w',  'e',  'r',  't',  'z',  'u',  'i', /* scan 10-17 */
> -        'o',  'p', 0x81,  '+', '\r',   CN,  'a',  's', /* scan 18-1F */
> -        'd',  'f',  'g',  'h',  'j',  'k',  'l', 0x94, /* scan 20-27 */
> -       0x84,  '^',   SH,    0,  'y',  'x',  'c',  'v', /* scan 28-2F */
> -        'b',  'n',  'm',  ',',  '.',  '-',   SH,  '*', /* scan 30-37 */
> -        ' ',  ' ',   CP,    0,    0,    0,    0,    0, /* scan 38-3F */
> -          0,    0,    0,    0,    0,   NM,   ST,  'w', /* scan 40-47 */
> -        'x',  'y',  'l',  't',  'u',  'v',  'm',  'q', /* scan 48-4F */
> -        'r',  's',  'p',  'n',    0,    0,  '<',    0, /* scan 50-57 */
> -          0,    0,    0,    0,    0,    0,    0,    0, /* scan 58-5F */
> -          0,    0,    0,    0,    0,    0,    0,    0, /* scan 60-67 */
> -          0,    0,    0,    0,    0,    0,    0,    0, /* scan 68-6F */
> -          0,    0,    0,    0,    0,    0,    0,    0, /* scan 70-77 */
> -          0,    0,    0,    0,    0,    0,    0,    0, /* scan 78-7F */
> -       '\r',   CN,  '/',  '*',  ' ',   ST,  'F',  'A', /* extended */
> -          0,  'D',  'C',    0,  'B',    0,  '@',  'P'  /* extended */
> -       },
> -       { /* right alt mode - is used in German keyboard */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 00-07 */
> -        '{',  '[',  ']',  '}', '\\', 0xff, 0xff, 0xff, /* scan 08-0F */
> -        '@', 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 10-17 */
> -       0xff, 0xff, 0xff,  '~', 0xff, 0xff, 0xff, 0xff, /* scan 18-1F */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 20-27 */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 28-2F */
> -       0xff, 0xff, 0xe6, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 30-37 */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 38-3F */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 40-47 */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 48-4F */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff,  '|', 0xff, /* scan 50-57 */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 58-5F */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 60-67 */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 68-6F */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 70-77 */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 78-7F */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* extended */
> -       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff  /* extended */
> -       }
> -       }
> -       };
> +static struct input_config config;
> +static bool extended;
>
>  static unsigned char ext_key_map[] = {
>         0x1c, /* keypad enter */
> @@ -293,157 +60,12 @@ static int kbd_output_full(void)
>         return kbd_timeout != -1;
>  }
>
> -static void kbd_led_set(void)
> +static void kbd_led_set(int flags)
>  {
>         kbd_input_empty();
>         out8(I8042_DATA_REG, CMD_SET_KBD_LED);
>         kbd_input_empty();
> -       out8(I8042_DATA_REG, (kbd_flags & 0x7));
> -}
> -
> -static void kbd_normal(unsigned char scan_code)
> -{
> -       unsigned char chr;
> -
> -       if ((kbd_flags & BRK) == NORMAL) {
> -               chr = kbd_key_map[kbd_mapping][kbd_state][scan_code];
> -               if ((chr == 0xff) || (chr == 0x00))
> -                       return;
> -
> -               /* if caps lock convert upper to lower */
> -               if (((kbd_flags & CAPS) == CAPS) &&
> -                   (chr >= 'a' && chr <= 'z')) {
> -                       chr -= 'a' - 'A';
> -               }
> -               kbd_input = chr;
> -       }
> -}
> -
> -static void kbd_shift(unsigned char scan_code)
> -{
> -       if ((kbd_flags & BRK) == BRK) {
> -               kbd_state = AS;
> -               kbd_flags &= (~SHIFT);
> -       } else {
> -               kbd_state = SH;
> -               kbd_flags |= SHIFT;
> -       }
> -}
> -
> -static void kbd_ctrl(unsigned char scan_code)
> -{
> -       if ((kbd_flags & BRK) == BRK) {
> -               kbd_state = AS;
> -               kbd_flags &= (~CTRL);
> -       } else {
> -               kbd_state = CN;
> -               kbd_flags |= CTRL;
> -       }
> -}
> -
> -static void kbd_num(unsigned char scan_code)
> -{
> -       if ((kbd_flags & BRK) == NORMAL) {
> -               kbd_flags ^= NUM;
> -               kbd_state = (kbd_flags & NUM) ? AS : NM;
> -               kbd_led_set();
> -       }
> -}
> -
> -static void kbd_alt(unsigned char scan_code)
> -{
> -       if ((kbd_flags & BRK) == BRK) {
> -               kbd_state = AS;
> -               kbd_flags &= (~ALT);
> -       } else {
> -               kbd_state = AK;
> -               kbd_flags &= ALT;
> -       }
> -}
> -
> -static void kbd_caps(unsigned char scan_code)
> -{
> -       if ((kbd_flags & BRK) == NORMAL) {
> -               kbd_flags ^= CAPS;
> -               kbd_led_set();
> -       }
> -}
> -
> -static void kbd_scroll(unsigned char scan_code)
> -{
> -       if ((kbd_flags & BRK) == NORMAL) {
> -               kbd_flags ^= STP;
> -               kbd_led_set();
> -               if (kbd_flags & STP)
> -                       kbd_input = 0x13;
> -               else
> -                       kbd_input = 0x11;
> -       }
> -}
> -
> -static void kbd_conv_char(unsigned char scan_code)
> -{
> -       if (scan_code == 0xe0) {
> -               kbd_flags |= EXT;
> -               return;
> -       }
> -
> -       /* if high bit of scan_code, set break flag */
> -       if (scan_code & 0x80)
> -               kbd_flags |=  BRK;
> -       else
> -               kbd_flags &= ~BRK;
> -
> -       if ((scan_code == 0xe1) || (kbd_flags & E1)) {
> -               if (scan_code == 0xe1) {
> -                       kbd_flags ^= BRK;       /* reset the break flag */
> -                       kbd_flags ^= E1;        /* bitwise EXOR with E1 flag */
> -               }
> -               return;
> -       }
> -
> -       scan_code &= 0x7f;
> -
> -       if (kbd_flags & EXT) {
> -               int i;
> -
> -               kbd_flags ^= EXT;
> -               for (i = 0; ext_key_map[i]; i++) {
> -                       if (ext_key_map[i] == scan_code) {
> -                               scan_code = 0x80 + i;
> -                               break;
> -                       }
> -               }
> -               /* not found ? */
> -               if (!ext_key_map[i])
> -                       return;
> -       }
> -
> -       switch (kbd_fct_map[scan_code]) {
> -       case AS:
> -               kbd_normal(scan_code);
> -               break;
> -       case SH:
> -               kbd_shift(scan_code);
> -               break;
> -       case CN:
> -               kbd_ctrl(scan_code);
> -               break;
> -       case NM:
> -               kbd_num(scan_code);
> -               break;
> -       case AK:
> -               kbd_alt(scan_code);
> -               break;
> -       case CP:
> -               kbd_caps(scan_code);
> -               break;
> -       case ST:
> -               kbd_scroll(scan_code);
> -               break;
> -       }
> -
> -       return;
> +       out8(I8042_DATA_REG, flags & 0x7);
>  }
>
>  static int kbd_write(int reg, int value)
> @@ -568,11 +190,50 @@ int i8042_disable(void)
>         return 0;
>  }
>
> +static int i8042_kbd_check(struct input_config *input)
> +{
> +       if ((in8(I8042_STS_REG) & STATUS_OBF) == 0) {
> +               return 0;
> +       } else {
> +               bool release = false;
> +               int scan_code;
> +               int i;
> +
> +               scan_code = in8(I8042_DATA_REG);
> +               if (scan_code == 0xfa) {
> +                       return 0;
> +               } else if (scan_code == 0xe0) {
> +                       extended = true;
> +                       return 0;
> +               }
> +               if (scan_code & 0x80) {
> +                       scan_code &= 0x7f;
> +                       release = true;
> +               }
> +               if (extended) {
> +                       extended = false;
> +                       for (i = 0; ext_key_map[i]; i++) {
> +                               if (ext_key_map[i] == scan_code) {
> +                                       scan_code = 0x60 + i;
> +                                       break;
> +                               }
> +                       }
> +                       /* not found ? */
> +                       if (!ext_key_map[i])
> +                               return 0;
> +               }
> +
> +               input_add_keycode(&config, scan_code, release);
> +               return 1;
> +       }
> +}
> +
>  /* i8042_kbd_init - reset keyboard and init state flags */
>  int i8042_kbd_init(void)
>  {
>         int keymap, try;
>         char *penv;
> +       int ret;
>
>         if (!kbd_controller_present() || board_i8042_skip()) {
>                 debug("i8042 keyboard controller is not present\n");
> @@ -592,58 +253,46 @@ int i8042_kbd_init(void)
>                         return -1;
>         }
>
> -       kbd_mapping = keymap;
> -       kbd_flags   = NORMAL;
> -       kbd_state   = 0;
> -       kbd_led_set();
> +       ret = input_init(&config, 0, keymap == KBD_GER);

I think this should be: input_add_tables(&config, keymap == KBD_GER).

> +       if (ret)
> +               return ret;
> +       config.read_keys = i8042_kbd_check;
> +       input_allow_repeats(&config, true);
> +
> +       kbd_led_set(NORMAL);
>
>         return 0;
>  }
>
> -/*
> - * i8042_tstc - test if keyboard input is available
> +/**
> + * check_leds() - Check the keyboard LEDs and update them it needed
>   *
> - * option: cursor blinking if called in a loop
> + * @ret:       Value to return
> + * @return value of @ret
>   */
> -int i8042_tstc(struct stdio_dev *dev)
> +static int check_leds(int ret)
>  {
> -       unsigned char scan_code = 0;
> +       int leds;
>
> -       if ((in8(I8042_STS_REG) & STATUS_OBF) == 0) {
> -               return 0;
> -       } else {
> -               scan_code = in8(I8042_DATA_REG);
> -               if (scan_code == 0xfa)
> -                       return 0;
> -
> -               kbd_conv_char(scan_code);
> +       leds = input_leds_changed(&config);
> +       if (leds >= 0)
> +               kbd_led_set(leds);
>
> -               if (kbd_input != -1)
> -                       return 1;
> -       }
> +       return ret;
> +}
>
> -       return 0;
> +/*
> + * i8042_tstc - test if keyboard input is available
> + */

Please use single line comment instead.

> +int i8042_tstc(struct stdio_dev *dev)
> +{
> +       return check_leds(input_tstc(&config));
>  }
>
>  /*
>   * i8042_getc - wait till keyboard input is available
> - *
> - * option: turn on/off cursor while waiting
>   */

Please use single line comment instead.

>  int i8042_getc(struct stdio_dev *dev)
>  {
> -       int ret_chr;
> -       unsigned char scan_code;
> -
> -       while (kbd_input == -1) {
> -               while ((in8(I8042_STS_REG) & STATUS_OBF) == 0) {
> -               }
> -               scan_code = in8(I8042_DATA_REG);
> -               if (scan_code != 0xfa)
> -                       kbd_conv_char(scan_code);
> -       }
> -       ret_chr = kbd_input;
> -       kbd_input = -1;
> -
> -       return ret_chr;
> +       return check_leds(input_getc(&config));
>  }
> --

With this commit (plus the input_add_tables fix above), i8042 LED does
not work any more on Intel Crown Bay. When pressing 'Caps Lock' or
'Num Lock', U-Boot just hangs.

Regards,
Bin

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 23/28] input: Add a Kconfig option for the i8042 keyboard
  2015-09-09  4:32 ` [U-Boot] [PATCH 23/28] input: Add a Kconfig option for the i8042 keyboard Simon Glass
@ 2015-09-15  6:12   ` Bin Meng
  0 siblings, 0 replies; 60+ messages in thread
From: Bin Meng @ 2015-09-15  6:12 UTC (permalink / raw)
  To: u-boot

On Wed, Sep 9, 2015 at 12:32 PM, Simon Glass <sjg@chromium.org> wrote:
> Add a new option CONFIG_I8042_KEYB which will replace the current
> CONFIG_I8042_KBD. This new name fits better with existing drivers.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  drivers/input/Kconfig | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
> index 447c4c3..d560328 100644
> --- a/drivers/input/Kconfig
> +++ b/drivers/input/Kconfig
> @@ -13,3 +13,13 @@ config CROS_EC_KEYB
>           Most ARM Chromebooks use an EC to provide access to the keyboard.
>           Messages are used to request key scans from the EC and these are
>           then decoded into keys by this driver.
> +
> +config I8042_KEYB
> +       bool "Enable Intel i8042 keyboard support"
> +       depends on DM_KEYBOARD
> +       help
> +         This adds a driver for the i8042 keyboard controller, allowing the
> +         keyboard to be used on devices which support this controller. The
> +         driver handles English and German keyboards - set the environment
> +         variable 'keymap' to "de" to select German. Keyboard repeat is
> +         handled by the keyboard itself.
> --

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 24/28] x86: Add an i8042 device for boards that have it
  2015-09-09  4:32 ` [U-Boot] [PATCH 24/28] x86: Add an i8042 device for boards that have it Simon Glass
@ 2015-09-15  6:12   ` Bin Meng
  2015-10-18 23:17     ` Simon Glass
  0 siblings, 1 reply; 60+ messages in thread
From: Bin Meng @ 2015-09-15  6:12 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On Wed, Sep 9, 2015 at 12:32 PM, Simon Glass <sjg@chromium.org> wrote:
> Some boards have an i8042 device. Enable the driver for all x86 boards, and
> add a device tree node for those which may have this keyboard.
>
> Also adjust the configuration so that i8042 is always separate from the VGA,
> and rename the stdin driver accordingly. With this commit the keyboard will
> not work, but it is fixed in the next commit.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  arch/x86/Kconfig                 | 6 ++++++
>  arch/x86/dts/bayleybay.dts       | 1 +
>  arch/x86/dts/chromebook_link.dts | 1 +
>  arch/x86/dts/keyboard.dtsi       | 5 +++++
>  include/configs/x86-chromebook.h | 2 +-
>  include/configs/x86-common.h     | 2 +-
>  6 files changed, 15 insertions(+), 2 deletions(-)
>  create mode 100644 arch/x86/dts/keyboard.dtsi
>
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index 5e42d7d..72a66ea 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -401,6 +401,12 @@ config PCIE_ECAM_SIZE
>           so a default 0x10000000 size covers all of the 256 buses which is the
>           maximum number of PCI buses as defined by the PCI specification.
>
> +config I8042_KEYB
> +       default y
> +
> +config DM_KEYBOARD
> +       default y
> +

I am not in favor of adding driver options in the arch Kconfig. We
specify other drivers in the boards' defconfig files. Can we move
these two to defconfig too?

>  source "arch/x86/lib/efi/Kconfig"
>
>  endmenu
> diff --git a/arch/x86/dts/bayleybay.dts b/arch/x86/dts/bayleybay.dts
> index d646987..58d97c8 100644
> --- a/arch/x86/dts/bayleybay.dts
> +++ b/arch/x86/dts/bayleybay.dts
> @@ -10,6 +10,7 @@
>  #include <dt-bindings/interrupt-router/intel-irq.h>
>
>  /include/ "skeleton.dtsi"
> +/include/ "keyboard.dtsi"
>  /include/ "serial.dtsi"
>  /include/ "rtc.dtsi"
>
> diff --git a/arch/x86/dts/chromebook_link.dts b/arch/x86/dts/chromebook_link.dts
> index 4291141..a52c84f 100644
> --- a/arch/x86/dts/chromebook_link.dts
> +++ b/arch/x86/dts/chromebook_link.dts
> @@ -1,6 +1,7 @@
>  /dts-v1/;
>
>  /include/ "skeleton.dtsi"
> +/include/ "keyboard.dtsi"
>  /include/ "serial.dtsi"
>  /include/ "rtc.dtsi"
>
> diff --git a/arch/x86/dts/keyboard.dtsi b/arch/x86/dts/keyboard.dtsi
> new file mode 100644
> index 0000000..000751b
> --- /dev/null
> +++ b/arch/x86/dts/keyboard.dtsi
> @@ -0,0 +1,5 @@
> +/ {
> +       keyboard {
> +               compatible = "intel,i8042-keyboard";
> +       };
> +};
> diff --git a/include/configs/x86-chromebook.h b/include/configs/x86-chromebook.h
> index 2be8850..4ff8b94 100644
> --- a/include/configs/x86-chromebook.h
> +++ b/include/configs/x86-chromebook.h
> @@ -51,7 +51,7 @@
>  #define CONFIG_ENV_IS_IN_SPI_FLASH
>  #define CONFIG_ENV_OFFSET              0x003f8000
>
> -#define CONFIG_STD_DEVICES_SETTINGS     "stdin=usbkbd,vga,serial\0" \
> +#define CONFIG_STD_DEVICES_SETTINGS     "stdin=usbkbd,i8042-kbd,serial\0" \
>                                         "stdout=vga,serial\0" \
>                                         "stderr=vga,serial\0"
>
> diff --git a/include/configs/x86-common.h b/include/configs/x86-common.h
> index 3f153f2..ff8fe0f 100644
> --- a/include/configs/x86-common.h
> +++ b/include/configs/x86-common.h
> @@ -147,7 +147,7 @@
>  #define CONFIG_VIDEO
>  #define CONFIG_VIDEO_SW_CURSOR
>  #define VIDEO_FB_16BPP_WORD_SWAP
> -#define CONFIG_I8042_KBD
> +#define CONFIG_VGA_AS_SINGLE_DEVICE

Can we remove CONFIG_VGA_AS_SINGLE_DEVICE from all x86 board config.h
files to avoid duplication?

>  #define CONFIG_CFB_CONSOLE
>  #define CONFIG_CONSOLE_SCROLL_LINES 5
>
> --

Regards,
Bin

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 25/28] Drop CONFIG_ISA_KEYBOARD
  2015-09-09  4:32 ` [U-Boot] [PATCH 25/28] Drop CONFIG_ISA_KEYBOARD Simon Glass
@ 2015-09-15  6:12   ` Bin Meng
  0 siblings, 0 replies; 60+ messages in thread
From: Bin Meng @ 2015-09-15  6:12 UTC (permalink / raw)
  To: u-boot

On Wed, Sep 9, 2015 at 12:32 PM, Simon Glass <sjg@chromium.org> wrote:
> This option is mentioned but does not do anything. Drop it.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  README                   | 11 ++++++-----
>  board/mpl/pip405/README  |  4 ----
>  include/configs/MIP405.h |  5 -----
>  include/configs/PIP405.h |  5 -----
>  4 files changed, 6 insertions(+), 19 deletions(-)
>
> diff --git a/README b/README
> index 54c1d08..dd857c4 100644
> --- a/README
> +++ b/README
> @@ -1785,17 +1785,18 @@ CBFS (Coreboot Filesystem) support
>                 a default value of 65536 will be defined.
>
>  - Keyboard Support:
> -               CONFIG_ISA_KEYBOARD
> -
> -               Define this to enable standard (PC-Style) keyboard
> -               support
> -
>                 CONFIG_I8042_KBD
>                 Standard PC keyboard driver with US (is default) and
>                 GERMAN key layout (switch via environment 'keymap=de') support.
>                 Export function i8042_kbd_init, i8042_tstc and i8042_getc
>                 for cfb_console. Supports cursor blinking.
>
> +               CONFIG_CROS_EC_KEYB
> +               Enables a Chrome OS keyboard using the CROS_EC interface.
> +               This uses CROS_EC to communicate with a second microcontroller
> +               which provides key scans on request.
> +               See Kconfig help for available keyboard drivers.
> +
>  - Video support:
>                 CONFIG_VIDEO
>
> diff --git a/board/mpl/pip405/README b/board/mpl/pip405/README
> index 012db1c..1b73dbe 100644
> --- a/board/mpl/pip405/README
> +++ b/board/mpl/pip405/README
> @@ -114,10 +114,6 @@ RTC
>  ----
>  CONFIG_RTC_MC146818            MC146818 RTC support
>
> -Keyboard:
> ----------
> -CONFIG_ISA_KEYBOARD            Standard (PC-Style) Keyboard support
> -
>  Video:
>  ------
>  CONFIG_VIDEO_CT69000           Enable Chips & Technologies 69000 Video chip
> diff --git a/include/configs/MIP405.h b/include/configs/MIP405.h
> index cb21b73..5bbc0de 100644
> --- a/include/configs/MIP405.h
> +++ b/include/configs/MIP405.h
> @@ -364,11 +364,6 @@
>  #define CONFIG_ISO_PARTITION /* Experimental */
>
>  /************************************************************
> - * Keyboard support
> - ************************************************************/
> -#undef CONFIG_ISA_KEYBOARD
> -
> -/************************************************************
>   * Video support
>   ************************************************************/
>  #define CONFIG_VIDEO                   /*To enable video controller support */
> diff --git a/include/configs/PIP405.h b/include/configs/PIP405.h
> index c9d08e6..265fa12 100644
> --- a/include/configs/PIP405.h
> +++ b/include/configs/PIP405.h
> @@ -321,11 +321,6 @@
>  #define CONFIG_ISO_PARTITION /* Experimental */
>
>  /************************************************************
> - * Keyboard support
> - ************************************************************/
> -#define CONFIG_ISA_KEYBOARD
> -
> -/************************************************************
>   * Video support
>   ************************************************************/
>  #define CONFIG_VIDEO                   /*To enable video controller support */
> --

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 26/28] input: Convert i8042 to driver model
  2015-09-09  4:32 ` [U-Boot] [PATCH 26/28] input: Convert i8042 to driver model Simon Glass
@ 2015-09-15  6:12   ` Bin Meng
  2015-10-18 23:17     ` Simon Glass
  0 siblings, 1 reply; 60+ messages in thread
From: Bin Meng @ 2015-09-15  6:12 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On Wed, Sep 9, 2015 at 12:32 PM, Simon Glass <sjg@chromium.org> wrote:
> Adjust this driver to support driver model. The only users are x86 boards
> so this should be safe.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---

After updating QEMU to use the DM i8042 driver below:

diff --git a/arch/x86/dts/qemu-x86_i440fx.dts b/arch/x86/dts/qemu-x86_i440fx.dts
index fc74cd0..14782b3 100644
--- a/arch/x86/dts/qemu-x86_i440fx.dts
+++ b/arch/x86/dts/qemu-x86_i440fx.dts
@@ -11,6 +11,7 @@
 /include/ "skeleton.dtsi"
 /include/ "serial.dtsi"
 /include/ "rtc.dtsi"
+/include/ "keyboard.dtsi"

 / {
        model = "QEMU x86 (I440FX)";
diff --git a/include/configs/qemu-x86.h b/include/configs/qemu-x86.h
index 1b544c1..9daf943 100644
--- a/include/configs/qemu-x86.h
+++ b/include/configs/qemu-x86.h
@@ -30,7 +30,7 @@

 #define CONFIG_PCI_PNP

-#define CONFIG_STD_DEVICES_SETTINGS    "stdin=serial,vga\0" \
+#define CONFIG_STD_DEVICES_SETTINGS    "stdin=serial,i8042-kbd\0" \
                                        "stdout=serial,vga\0" \
                                        "stderr=serial,vga\0"


The i8042 still does not work. I've applied the same changes to Crown
Bay. i8042 does not work either. Could you please have a look?

>
>  drivers/input/Makefile |   2 +-
>  drivers/input/i8042.c  | 113 ++++++++++++++++++++++++++++++++-----------------
>  include/i8042.h        |   6 ---
>  3 files changed, 76 insertions(+), 45 deletions(-)
>
> diff --git a/drivers/input/Makefile b/drivers/input/Makefile
> index 9388dfe..5f15265 100644
> --- a/drivers/input/Makefile
> +++ b/drivers/input/Makefile
> @@ -7,7 +7,7 @@
>
>  obj-$(CONFIG_DM_KEYBOARD) += keyboard-uclass.o
>
> -obj-$(CONFIG_I8042_KBD) += i8042.o
> +obj-$(CONFIG_I8042_KEYB) += i8042.o
>  obj-$(CONFIG_TEGRA_KEYBOARD) += tegra-kbc.o
>  obj-$(CONFIG_TWL4030_INPUT) += twl4030.o
>  obj-$(CONFIG_CROS_EC_KEYB) += cros_ec_keyb.o
> diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c
> index 5ebb571..3649e2f 100644
> --- a/drivers/input/i8042.c
> +++ b/drivers/input/i8042.c
> @@ -8,8 +8,11 @@
>  /* i8042.c - Intel 8042 keyboard driver routines */
>
>  #include <common.h>
> +#include <dm.h>
> +#include <errno.h>
>  #include <i8042.h>
>  #include <input.h>
> +#include <keyboard.h>
>  #include <asm/io.h>
>
>  /* defines */
> @@ -17,8 +20,9 @@
>  #define out8(p, v)     outb(v, p)
>
>  /* locals */
> -static struct input_config config;
> -static bool extended;
> +struct i8042_kbd_priv {
> +       bool extended;  /* true if an extended keycode is expected next */
> +};
>
>  static unsigned char ext_key_map[] = {
>         0x1c, /* keypad enter */
> @@ -60,12 +64,20 @@ static int kbd_output_full(void)
>         return kbd_timeout != -1;
>  }
>
> -static void kbd_led_set(int flags)
> +/**
> + * check_leds() - Check the keyboard LEDs and update them it needed
> + *
> + * @ret:       Value to return
> + * @return value of @ret
> + */
> +static int i8042_kbd_update_leds(struct udevice *dev, int leds)
>  {
>         kbd_input_empty();
>         out8(I8042_DATA_REG, CMD_SET_KBD_LED);
>         kbd_input_empty();
> -       out8(I8042_DATA_REG, flags & 0x7);
> +       out8(I8042_DATA_REG, leds & 0x7);
> +
> +       return 0;
>  }
>
>  static int kbd_write(int reg, int value)
> @@ -146,6 +158,8 @@ static int kbd_controller_present(void)
>  /*
>   * Implement a weak default function for boards that optionally
>   * need to skip the i8042 initialization.
> + *
> + * TODO(sjg at chromium.org): Use device tree for this?
>   */
>  int __weak board_i8042_skip(void)
>  {
> @@ -192,6 +206,8 @@ int i8042_disable(void)
>
>  static int i8042_kbd_check(struct input_config *input)
>  {
> +       struct i8042_kbd_priv *priv = dev_get_priv(input->dev);
> +
>         if ((in8(I8042_STS_REG) & STATUS_OBF) == 0) {
>                 return 0;
>         } else {
> @@ -203,15 +219,15 @@ static int i8042_kbd_check(struct input_config *input)
>                 if (scan_code == 0xfa) {
>                         return 0;
>                 } else if (scan_code == 0xe0) {
> -                       extended = true;
> +                       priv->extended = true;
>                         return 0;
>                 }
>                 if (scan_code & 0x80) {
>                         scan_code &= 0x7f;
>                         release = true;
>                 }
> -               if (extended) {
> -                       extended = false;
> +               if (priv->extended) {
> +                       priv->extended = false;
>                         for (i = 0; ext_key_map[i]; i++) {
>                                 if (ext_key_map[i] == scan_code) {
>                                         scan_code = 0x60 + i;
> @@ -223,21 +239,23 @@ static int i8042_kbd_check(struct input_config *input)
>                                 return 0;
>                 }
>
> -               input_add_keycode(&config, scan_code, release);
> +               input_add_keycode(input, scan_code, release);
>                 return 1;
>         }
>  }
>
>  /* i8042_kbd_init - reset keyboard and init state flags */
> -int i8042_kbd_init(void)
> +static int i8042_start(struct udevice *dev)
>  {
> +       struct keyboard_priv *uc_priv = dev_get_uclass_priv(dev);
> +       struct input_config *input = &uc_priv->input;
>         int keymap, try;
>         char *penv;
>         int ret;
>
>         if (!kbd_controller_present() || board_i8042_skip()) {
>                 debug("i8042 keyboard controller is not present\n");
> -               return -1;
> +               return -ENOENT;
>         }
>
>         /* Init keyboard device (default US layout) */
> @@ -253,46 +271,65 @@ int i8042_kbd_init(void)
>                         return -1;
>         }
>
> -       ret = input_init(&config, 0, keymap == KBD_GER);
> +       ret = input_add_tables(input, keymap == KBD_GER);
>         if (ret)
>                 return ret;
> -       config.read_keys = i8042_kbd_check;
> -       input_allow_repeats(&config, true);
>
> -       kbd_led_set(NORMAL);
> +       i8042_kbd_update_leds(dev, NORMAL);
> +       debug("%s: started\n", __func__);
>
>         return 0;
>  }
>
>  /**
> - * check_leds() - Check the keyboard LEDs and update them it needed
> + * Set up the i8042 keyboard. This is called by the stdio device handler
>   *
> - * @ret:       Value to return
> - * @return value of @ret
> + * We want to do this init when the keyboard is actually used rather than
> + * at start-up, since keyboard input may not currently be selected.
> + *
> + * Once the keyboard starts there will be a period during which we must
> + * wait for the keyboard to init. We do this only when a key is first
> + * read - see kbd_wait_for_fifo_init().
> + *
> + * @return 0 if ok, -ve on error
>   */
> -static int check_leds(int ret)
> +static int i8042_kbd_probe(struct udevice *dev)
>  {
> -       int leds;
> -
> -       leds = input_leds_changed(&config);
> -       if (leds >= 0)
> -               kbd_led_set(leds);
> +       struct keyboard_priv *uc_priv = dev_get_uclass_priv(dev);
> +       struct stdio_dev *sdev = &uc_priv->sdev;
> +       struct input_config *input = &uc_priv->input;
> +       int ret;
>
> -       return ret;
> -}
> +       /* Register the device. i8042_start() will be called soon */
> +       input->dev = dev;
> +       input->read_keys = i8042_kbd_check;
> +       input_allow_repeats(input, true);
> +       strcpy(sdev->name, "i8042-kbd");
> +       ret = input_stdio_register(sdev);
> +       if (ret) {
> +               debug("%s: input_stdio_register() failed\n", __func__);
> +               return ret;
> +       }
> +       debug("%s: ready\n", __func__);
>
> -/*
> - * i8042_tstc - test if keyboard input is available
> - */
> -int i8042_tstc(struct stdio_dev *dev)
> -{
> -       return check_leds(input_tstc(&config));
> +       return 0;
>  }
>
> -/*
> - * i8042_getc - wait till keyboard input is available
> - */
> -int i8042_getc(struct stdio_dev *dev)
> -{
> -       return check_leds(input_getc(&config));
> -}
> +static const struct keyboard_ops i8042_kbd_ops = {
> +       .start  = i8042_start,
> +       .update_leds    = i8042_kbd_update_leds,
> +};
> +
> +static const struct udevice_id i8042_kbd_ids[] = {
> +       { .compatible = "intel,i8042-keyboard" },
> +       { }
> +};
> +
> +U_BOOT_DRIVER(i8042_kbd) = {
> +       .name   = "i8042_kbd",
> +       .id     = UCLASS_KEYBOARD,
> +       .of_match = i8042_kbd_ids,
> +       .probe = i8042_kbd_probe,
> +       .ops    = &i8042_kbd_ops,
> +       .priv_auto_alloc_size = sizeof(struct i8042_kbd_priv),
> +};
> diff --git a/include/i8042.h b/include/i8042.h
> index e0afce1..9723b6a 100644
> --- a/include/i8042.h
> +++ b/include/i8042.h
> @@ -87,10 +87,4 @@ void i8042_flush(void);
>   */
>  int i8042_disable(void);
>
> -struct stdio_dev;
> -
> -int i8042_kbd_init(void);
> -int i8042_tstc(struct stdio_dev *dev);
> -int i8042_getc(struct stdio_dev *dev);
> -
>  #endif /* _I8042_H_ */
> --

Regards,
Bin

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 27/28] video: input: Clean up after i8042 conversion
  2015-09-09  4:32 ` [U-Boot] [PATCH 27/28] video: input: Clean up after i8042 conversion Simon Glass
@ 2015-09-15  6:12   ` Bin Meng
  0 siblings, 0 replies; 60+ messages in thread
From: Bin Meng @ 2015-09-15  6:12 UTC (permalink / raw)
  To: u-boot

On Wed, Sep 9, 2015 at 12:32 PM, Simon Glass <sjg@chromium.org> wrote:
> Now that i8042 uses driver model, adjust other mentions of it and remove old
> code that is no-longer used. Update the README and unify the keyboard text
> into one place.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  README                      | 33 +++++++++++----------------------
>  drivers/video/cfb_console.c | 20 ++++----------------
>  2 files changed, 15 insertions(+), 38 deletions(-)
>
> diff --git a/README b/README
> index dd857c4..d1f9b38 100644
> --- a/README
> +++ b/README
> @@ -885,11 +885,11 @@ The following options need to be configured:
>                                                 (0-5, cf. cfb_console.c)
>                         VIDEO_FB_ADRS           framebuffer address
>                         VIDEO_KBD_INIT_FCT      keyboard int fct
> -                                               (i.e. i8042_kbd_init())
> +                                               (i.e. rx51_kp_init())
>                         VIDEO_TSTC_FCT          test char fct
> -                                               (i.e. i8042_tstc)
> +                                               (i.e. rx51_kp_tstc)
>                         VIDEO_GETC_FCT          get char fct
> -                                               (i.e. i8042_getc)
> +                                               (i.e. rx51_kp_getc)
>                         CONFIG_VIDEO_LOGO       display Linux logo in
>                                                 upper left corner
>                         CONFIG_VIDEO_BMP_LOGO   use bmp_logo.h instead of
> @@ -1785,18 +1785,16 @@ CBFS (Coreboot Filesystem) support
>                 a default value of 65536 will be defined.
>
>  - Keyboard Support:
> -               CONFIG_I8042_KBD
> -               Standard PC keyboard driver with US (is default) and
> -               GERMAN key layout (switch via environment 'keymap=de') support.
> -               Export function i8042_kbd_init, i8042_tstc and i8042_getc
> -               for cfb_console. Supports cursor blinking.
> -
> -               CONFIG_CROS_EC_KEYB
> -               Enables a Chrome OS keyboard using the CROS_EC interface.
> -               This uses CROS_EC to communicate with a second microcontroller
> -               which provides key scans on request.
>                 See Kconfig help for available keyboard drivers.
>
> +               CONFIG_KEYBOARD
> +
> +               Define this to enable a custom keyboard support.
> +               This simply calls drv_keyboard_init() which must be
> +               defined in your board-specific files. This option is deprecated
> +               and is only used by novena. For new boards, driver model
> +               instead.
> +
>  - Video support:
>                 CONFIG_VIDEO
>
> @@ -1856,15 +1854,6 @@ CBFS (Coreboot Filesystem) support
>                 boot.  See the documentation file README.video for a
>                 description of this variable.
>
> -
> -- Keyboard Support:
> -               CONFIG_KEYBOARD
> -
> -               Define this to enable a custom keyboard support.
> -               This simply calls drv_keyboard_init() which must be
> -               defined in your board-specific files.
> -               The only board using this so far is RBC823.
> -
>  - LCD Support: CONFIG_LCD
>
>                 Define this to enable LCD support (for output to LCD
> diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c
> index 1b5c3e0..fde0bd4 100644
> --- a/drivers/video/cfb_console.c
> +++ b/drivers/video/cfb_console.c
> @@ -15,8 +15,10 @@
>   * logo can be placed in the upper left corner and additional board
>   * information strings (that normally goes to serial port) can be drawn.
>   *
> - * The console driver can use the standard PC keyboard interface (i8042)
> - * for character input. Character output goes to a memory mapped video
> + * The console driver can use a keyboard interface for character input
> + * but this is deprecated. Only rk51 uses it.
> + *
> + * Character output goes to a memory-mapped video
>   * framebuffer with little or big-endian organisation.
>   * With environment setting 'console=serial' the console i/o can be
>   * forced to serial port.
> @@ -38,7 +40,6 @@
>   * VIDEO_DATA_FORMAT         - graphical data format GDF
>   * VIDEO_FB_ADRS             - start of video memory
>   *
> - * CONFIG_I8042_KBD          - AT Keyboard driver for i8042
>   * VIDEO_KBD_INIT_FCT        - init function for keyboard
>   * VIDEO_TSTC_FCT            - keyboard_tstc function
>   * VIDEO_GETC_FCT            - keyboard_getc function
> @@ -158,19 +159,6 @@
>  #define VIDEO_FB_ADRS          (pGD->frameAdrs)
>
>  /*
> - * Console device defines with i8042 keyboard controller
> - * Any other keyboard controller must change this section
> - */
> -
> -#ifdef CONFIG_I8042_KBD
> -#include <i8042.h>
> -
> -#define VIDEO_KBD_INIT_FCT     i8042_kbd_init()
> -#define VIDEO_TSTC_FCT         i8042_tstc
> -#define VIDEO_GETC_FCT         i8042_getc
> -#endif
> -
> -/*
>   * Console device
>   */
>
> --

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 01/28] dm: input: Create a keyboard uclass
  2015-09-15  6:11   ` Bin Meng
@ 2015-10-18 23:17     ` Simon Glass
  0 siblings, 0 replies; 60+ messages in thread
From: Simon Glass @ 2015-10-18 23:17 UTC (permalink / raw)
  To: u-boot

Hi Bin,

On 15 September 2015 at 00:11, Bin Meng <bmeng.cn@gmail.com> wrote:
> Hi Simon,
>
> On Wed, Sep 9, 2015 at 12:32 PM, Simon Glass <sjg@chromium.org> wrote:
>> Add a uclass for keyboard input, mirroring the existing stdio methods.
>> This is enabled by a new CONFIG_DM_KEYBOARD option.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>
>>  common/usb_kbd.c                |  6 ---
>>  drivers/input/Kconfig           |  9 +++++
>>  drivers/input/Makefile          |  2 +
>>  drivers/input/keyboard-uclass.c | 84 +++++++++++++++++++++++++++++++++++++++++
>>  include/keyboard.h              | 78 ++++++++++++++++++++++++++++++++++++++
>>  5 files changed, 173 insertions(+), 6 deletions(-)
>>  create mode 100644 drivers/input/keyboard-uclass.c
>>
>> diff --git a/common/usb_kbd.c b/common/usb_kbd.c
>> index 8037ebf..05668fc 100644
>> --- a/common/usb_kbd.c
>> +++ b/common/usb_kbd.c
>> @@ -648,12 +648,6 @@ U_BOOT_DRIVER(usb_kbd) = {
>>         .probe = usb_kbd_probe,
>>  };
>>
>> -/* TODO(sjg at chromium.org): Move this into a common location */
>> -UCLASS_DRIVER(keyboard) = {
>> -       .id             = UCLASS_KEYBOARD,
>> -       .name           = "keyboard",
>> -};
>> -
>>  static const struct usb_device_id kbd_id_table[] = {
>>         {
>>                 .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS |
>> diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
>> index bb00de7..447c4c3 100644
>> --- a/drivers/input/Kconfig
>> +++ b/drivers/input/Kconfig
>> @@ -1,3 +1,12 @@
>> +config DM_KEYBOARD
>> +       bool "Enable driver model keyboard support"
>> +       depends on DM
>> +       help
>> +         This adds a uclass for keyboards and implements keyboard support
>> +         using driver model. The API is implemented by keyboard.h and
>> +         includes methods to start/stop the device, check for available
>> +         input and update LEDs if the keyboard has them.
>> +
>>  config CROS_EC_KEYB
>>         bool "Enable Chrome OS EC keyboard support"
>>         help
>> diff --git a/drivers/input/Makefile b/drivers/input/Makefile
>> index b1161c5..9388dfe 100644
>> --- a/drivers/input/Makefile
>> +++ b/drivers/input/Makefile
>> @@ -5,6 +5,8 @@
>>  # SPDX-License-Identifier:     GPL-2.0+
>>  #
>>
>> +obj-$(CONFIG_DM_KEYBOARD) += keyboard-uclass.o
>> +
>>  obj-$(CONFIG_I8042_KBD) += i8042.o
>>  obj-$(CONFIG_TEGRA_KEYBOARD) += tegra-kbc.o
>>  obj-$(CONFIG_TWL4030_INPUT) += twl4030.o
>> diff --git a/drivers/input/keyboard-uclass.c b/drivers/input/keyboard-uclass.c
>> new file mode 100644
>> index 0000000..1c564dc
>> --- /dev/null
>> +++ b/drivers/input/keyboard-uclass.c
>> @@ -0,0 +1,84 @@
>> +/*
>> + * Copyright (c) 2015 Google, Inc
>> + *
>> + * SPDX-License-Identifier:    GPL-2.0+
>> + */
>> +
>> +#include <common.h>
>> +#include <dm.h>
>> +#include <keyboard.h>
>> +
>> +static int keyboard_start(struct stdio_dev *sdev)
>> +{
>> +       struct udevice *dev = sdev->priv;
>> +       struct keyboard_ops *ops = keyboard_get_ops(dev);
>> +
>> +       if (ops->start)
>> +               return ops->start(dev);
>> +
>> +       return 0;
>
> Should we return -ENOSYS here?

No, several keyboards don't need to do do anything here.

>
>> +}
>> +
>> +static int keyboard_stop(struct stdio_dev *sdev)
>> +{
>> +       struct udevice *dev = sdev->priv;
>> +       struct keyboard_ops *ops = keyboard_get_ops(dev);
>> +
>> +       if (ops->stop)
>> +               return ops->stop(dev);
>> +
>> +       return 0;
>
> Ditto.
>
>> +}
>> +
>> +static int keyboard_tstc(struct stdio_dev *sdev)
>> +{
>> +       struct udevice *dev = sdev->priv;
>> +       struct keyboard_priv *priv = dev_get_uclass_priv(dev);
>> +
>> +       /* Just get input to do this for us if we can */
>> +       if (priv->input.dev)
>> +               return input_tstc(&priv->input);
>
> else if (op->tstc)
>     return ops->tstc(dev);
>
> ?

Well nothing uses it yet, and I'm hoping they won't, but OK.

>
>> +
>> +       return -ENOSYS;
>> +}
>> +
>> +static int keyboard_getc(struct stdio_dev *sdev)
>> +{
>> +       struct udevice *dev = sdev->priv;
>> +       struct keyboard_priv *priv = dev_get_uclass_priv(dev);
>> +
>> +       /* Just get input to do this for us if we can */
>> +       if (priv->input.dev)
>> +               return input_getc(&priv->input);
>
> Ditto.
>
>> +
>> +       return -ENOSYS;
>> +}
>> +
>> +static int keyboard_pre_probe(struct udevice *dev)
>> +{
>> +       struct keyboard_priv *priv = dev_get_uclass_priv(dev);
>> +       struct stdio_dev *sdev = &priv->sdev;
>> +       int ret;
>> +
>> +       strlcpy(sdev->name, dev->name, sizeof(sdev->name));
>> +       sdev->flags = DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
>> +       sdev->getc = keyboard_getc;
>> +       sdev->tstc = keyboard_tstc;
>> +       sdev->start = keyboard_start;
>> +       sdev->stop = keyboard_stop;
>> +       sdev->priv = dev;
>> +       ret = input_init(&priv->input, 0);
>> +       if (ret) {
>> +               debug("%s: Cannot set up input\n", __func__);
>> +               return ret;
>> +       }
>> +
>> +       return 0;
>> +}
>> +
>> +UCLASS_DRIVER(keyboard) = {
>> +       .id             = UCLASS_KEYBOARD,
>> +       .name           = "keyboard",
>> +       .pre_probe      = keyboard_pre_probe,
>> +       .per_device_auto_alloc_size = sizeof(struct keyboard_priv),
>> +};
>> diff --git a/include/keyboard.h b/include/keyboard.h
>> index 88ae12b..a8b68cb 100644
>> --- a/include/keyboard.h
>> +++ b/include/keyboard.h
>> @@ -1,6 +1,83 @@
>>  #ifndef __KEYBOARD_H
>>  #define __KEYBOARD_H
>>
>> +#ifdef CONFIG_DM_KEYBOARD
>> +#include <input.h>
>> +#include <stdio_dev.h>
>> +
>> +/**
>> + * struct keyboard_priv - information about a keyboard, for the uclass
>> + *
>> + * @sdev:      stdio device
>> + * @input:     input configuration (the driver may use this if desired)
>> + */
>> +struct keyboard_priv {
>> +       struct stdio_dev sdev;
>> +
>> +       /*
>> +        * This is set up by the uclass but will only be used if the driver
>> +        * sets input.dev to its device pointer (it is initially NULL).
>> +        */
>> +       struct input_config input;
>> +};
>> +
>> +/**
>> + * struct keyboard_ops - keyboard device operations
>> + */
>> +struct keyboard_ops {
>> +       /**
>> +        * start() - enable the keyboard ready for use
>> +        *
>> +        * @dev:        Device to enable
>> +        * @return 0 if OK, -ve on error
>> +        */
>> +       int (*start)(struct udevice *dev);
>> +
>> +       /**
>> +        * stop() - disable the keyboard when no-longer needed
>> +        *
>> +        * @dev:        Device to disable
>> +        * @return 0 if OK, -ve on error
>> +        */
>> +       int (*stop)(struct udevice *dev);
>> +
>> +       /**
>> +        * tstc() - check if a key is available
>> +        *
>> +        * @dev:        Device to check
>> +        * @return 0 if no key is available, 1 if a key is available
>
> Should we change the return value to bool?

It can return an error - I'll update the comment.

>
>> +        */
>> +       int (*tstc)(struct udevice *dev);
>> +
>> +       /**
>> +        * getc() - get a key
>> +        *
>> +        * TODO(sjg at chromium.org): At present this method may wait if it calls
>> +        * input_getc().
>> +        *
>> +        * @dev:        Device to read from
>> +        * @return -EAGAIN if no key is available, otherwise key value read
>> +        *         (as ASCII).
>> +        */
>> +       int (*getc)(struct udevice *dev);
>> +
>> +       /**
>> +        * update_leds() - update keyboard LEDs
>> +        *
>> +        * This is called when the LEDs have changed and need to be updated.
>> +        * For example, if 'caps lock' is pressed then this method will be
>> +        * called with the new LED value.
>> +        *
>> +        * @dev:        Device to update
>> +        * @leds:       New LED mask (see INPUT_LED_... in input.h)
>> +        */
>> +       int (*update_leds)(struct udevice *dev, int leds);
>> +};
>> +
>> +#define keyboard_get_ops(dev)  ((struct keyboard_ops *)(dev)->driver->ops)
>> +
>> +#else
>> +
>>  #ifdef CONFIG_PS2MULT
>>  #include <ps2mult.h>
>>  #endif
>> @@ -18,5 +95,6 @@ extern int kbd_init (void);
>>  extern void handle_scancode(unsigned char scancode);
>>  extern int kbd_init_hw(void);
>>  extern void pckbd_leds(unsigned char leds);
>> +#endif /* !CONFIG_DM_KEYBOARD */
>>
>>  #endif /* __KEYBOARD_H */
>> --
>
> Regards,
> Bin

Regards,
Simon

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 04/28] input: Add the keycode translation tables separately
  2015-09-15  6:11   ` Bin Meng
@ 2015-10-18 23:17     ` Simon Glass
  0 siblings, 0 replies; 60+ messages in thread
From: Simon Glass @ 2015-10-18 23:17 UTC (permalink / raw)
  To: u-boot

Hi Bin,

On 15 September 2015 at 00:11, Bin Meng <bmeng.cn@gmail.com> wrote:
> Hi Simon,
>
> On Wed, Sep 9, 2015 at 12:32 PM, Simon Glass <sjg@chromium.org> wrote:
>> Require the caller to add the keycode translation tables separately so that
>> it can select which ones to use. In a later patch we will add the option to
>> add German tables.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>
>>  board/kosagi/novena/novena.c |  1 +
>>  drivers/input/cros_ec_keyb.c |  1 +
>>  drivers/input/input.c        | 21 ++++++++++++---------
>>  drivers/input/tegra-kbc.c    |  1 +
>>  include/input.h              | 10 ++++++++++
>>  5 files changed, 25 insertions(+), 9 deletions(-)
>>
>> diff --git a/board/kosagi/novena/novena.c b/board/kosagi/novena/novena.c
>> index 69f5be3..48cbb0f 100644
>> --- a/board/kosagi/novena/novena.c
>> +++ b/board/kosagi/novena/novena.c
>> @@ -88,6 +88,7 @@ int drv_keyboard_init(void)
>>                 debug("%s: Cannot set up input\n", __func__);
>>                 return -1;
>>         }
>> +       input_add_tables(&button_input);
>>         button_input.read_keys = novena_gpio_button_read_keys;
>>
>>         error = input_stdio_register(&dev);
>> diff --git a/drivers/input/cros_ec_keyb.c b/drivers/input/cros_ec_keyb.c
>> index a31aa77..eaab86f 100644
>> --- a/drivers/input/cros_ec_keyb.c
>> +++ b/drivers/input/cros_ec_keyb.c
>> @@ -255,6 +255,7 @@ int drv_keyboard_init(void)
>>                 return -1;
>>         }
>>         config.input.read_keys = cros_ec_kbc_check;
>> +       input_add_tables(&config.input);
>>
>>         memset(&dev, '\0', sizeof(dev));
>>         strcpy(dev.name, "cros-ec-keyb");
>> diff --git a/drivers/input/input.c b/drivers/input/input.c
>> index 9033935..0f11ae6 100644
>> --- a/drivers/input/input.c
>> +++ b/drivers/input/input.c
>> @@ -457,19 +457,22 @@ void input_set_delays(struct input_config *config, int repeat_delay_ms,
>>         config->repeat_rate_ms = repeat_rate_ms;
>>  }
>>
>> +int input_add_tables(struct input_config *config)
>> +{
>> +       input_add_table(config, -1, -1,
>> +                       kbd_plain_xlate, ARRAY_SIZE(kbd_plain_xlate));
>> +       input_add_table(config, KEY_LEFTSHIFT, KEY_RIGHTSHIFT,
>> +                       kbd_shift_xlate, ARRAY_SIZE(kbd_shift_xlate));
>> +       input_add_table(config, KEY_LEFTCTRL, KEY_RIGHTCTRL,
>> +                       kbd_ctrl_xlate, ARRAY_SIZE(kbd_ctrl_xlate));
>
> Should we return error codes here? In previous patch, we've added -ENOSPC.

It can't actually happen since there is always enough space for 3
items and this is called at the start. Still it looks strange to not
check errors so I will add it.

[snip]

Regards,
Simon

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 06/28] dm: stdio: Plumb in the new keyboard uclass
  2015-09-15  6:11   ` Bin Meng
@ 2015-10-18 23:17     ` Simon Glass
  0 siblings, 0 replies; 60+ messages in thread
From: Simon Glass @ 2015-10-18 23:17 UTC (permalink / raw)
  To: u-boot

Hi Bin,

On 15 September 2015 at 00:11, Bin Meng <bmeng.cn@gmail.com> wrote:
> Hi Simon,
>
> On Wed, Sep 9, 2015 at 12:32 PM, Simon Glass <sjg@chromium.org> wrote:
>> When driver model is used for keyboards we must scan the available keyboards
>> and register them with stdio. Add code to do this.
>>
>> At some point (once LCD/video is converted) we should be able to convert
>> stdio to driver model and avoid these dual data structures.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>
>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
>
> Please see one question below.
>
>>  common/stdio.c | 31 ++++++++++++++++++++++++++++++-
>>  1 file changed, 30 insertions(+), 1 deletion(-)
>>
>> diff --git a/common/stdio.c b/common/stdio.c
>> index adbfc89..71cc32e 100644
>> --- a/common/stdio.c
>> +++ b/common/stdio.c
>> @@ -11,6 +11,7 @@
>>
>>  #include <config.h>
>>  #include <common.h>
>> +#include <dm.h>
>>  #include <errno.h>
>>  #include <stdarg.h>
>>  #include <malloc.h>
>> @@ -24,6 +25,8 @@
>>  #include <i2c.h>
>>  #endif
>>
>> +#include <dm/device-internal.h>
>> +
>>  DECLARE_GLOBAL_DATA_PTR;
>>
>>  static struct stdio_dev devs;
>> @@ -245,6 +248,32 @@ int stdio_init_tables(void)
>>
>>  int stdio_add_devices(void)
>>  {
>> +#ifdef CONFIG_DM_KEYBOARD
>> +       struct udevice *dev;
>> +       struct uclass *uc;
>> +       int ret;
>> +
>> +       /*
>> +        * For now we probe all the devices here. At some point this should be
>> +        * done only when the devices are required - e.g. we have a list of
>> +        * input devices to start up in the stdin environment variable. That
>> +        * work probably makes more sense when stdio itself is converted to
>> +        * driver model.
>> +        *
>> +        * TODO(sjg at chromium.org): Convert changing uclass_first_device() etc.
>> +        * to return the device even on error. Then we could use that here.
>> +        */
>> +       ret = uclass_get(UCLASS_KEYBOARD, &uc);
>> +       if (ret)
>> +               return ret;
>> +
>> +       /* Don't report errors to the caller - assume that they are non-fatal */
>> +       uclass_foreach_dev(dev, uc) {
>> +               ret = device_probe(dev);
>> +               if (ret)
>> +                       printf("Failed to probe keyboard '%s'\n", dev->name);
>> +       }
>> +#endif
>>  #ifdef CONFIG_SYS_I2C
>>         i2c_init_all();
>>  #else
>> @@ -258,7 +287,7 @@ int stdio_add_devices(void)
>>  #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
>>         drv_video_init ();
>>  #endif
>> -#ifdef CONFIG_KEYBOARD
>> +#if defined(CONFIG_KEYBOARD) && !defined(CONFIG_DM_KEYBOARD)
>
> Should we remove this non-dm driver call completely?

We can once 'novena' is converted over.

>
>>         drv_keyboard_init ();
>>  #endif
>>  #ifdef CONFIG_LOGBUFFER
>> --

Regards,
Simon

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 09/28] video: Drop unused console functions
  2015-09-15  6:11   ` Bin Meng
@ 2015-10-18 23:17     ` Simon Glass
  0 siblings, 0 replies; 60+ messages in thread
From: Simon Glass @ 2015-10-18 23:17 UTC (permalink / raw)
  To: u-boot

Hi Bin,

On 15 September 2015 at 00:11, Bin Meng <bmeng.cn@gmail.com> wrote:
> Hi Simon,
>
> On Wed, Sep 9, 2015 at 12:32 PM, Simon Glass <sjg@chromium.org> wrote:
>> CONFIG_CONSOLE_CURSOR, CONFIG_SYS_CONSOLE_BLINK_COUNT and
>> CONFIG_CONSOLE_TIME are not used by any board. The implementation is not
>> great and stands in the way of a refactor of i8042. Drop these for now.
>> They can be re-introduced quite easily later, perhaps with driver model
>> RTC support.
>
> RTC?

Yes - they use the real-time clock for this feature.

>
>>
>> When reintroducing, it might be useful to make a few changes:
>> - Blink time would be more useful than blink count
>> - The confusing #ifdefs should be avoided
>> - The time functions should support driver model
>> - It would be best keyed off console_tstc() or some similar idle loop
>>     rather than a particular input driver (i8042 in this case)
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>
>>  README                        |  7 -----
>>  drivers/input/i8042.c         | 23 ----------------
>>  drivers/video/cfb_console.c   | 62 +++++++------------------------------------
>>  include/configs/MPC8536DS.h   |  1 -
>>  include/configs/MPC8544DS.h   |  1 -
>>  include/configs/MPC8572DS.h   |  1 -
>>  include/configs/MPC8641HPCN.h |  1 -
>>  7 files changed, 9 insertions(+), 87 deletions(-)
>>
>> diff --git a/README b/README
>> index 08f2f70..54c1d08 100644
>> --- a/README
>> +++ b/README
>> @@ -890,13 +890,6 @@ The following options need to be configured:
>>                                                 (i.e. i8042_tstc)
>>                         VIDEO_GETC_FCT          get char fct
>>                                                 (i.e. i8042_getc)
>> -                       CONFIG_CONSOLE_CURSOR   cursor drawing on/off
>> -                                               (requires blink timer
>> -                                               cf. i8042.c)
>> -                       CONFIG_SYS_CONSOLE_BLINK_COUNT blink interval (cf. i8042.c)
>> -                       CONFIG_CONSOLE_TIME     display time/date info in
>> -                                               upper right corner
>> -                                               (requires CONFIG_CMD_DATE)
>>                         CONFIG_VIDEO_LOGO       display Linux logo in
>>                                                 upper left corner
>>                         CONFIG_VIDEO_BMP_LOGO   use bmp_logo.h instead of
>> diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c
>> index 9b5fa32..7b95b21 100644
>> --- a/drivers/input/i8042.c
>> +++ b/drivers/input/i8042.c
>> @@ -17,12 +17,6 @@
>>  #define in8(p)         inb(p)
>>  #define out8(p, v)     outb(v, p)
>>
>> -#ifdef CONFIG_CONSOLE_CURSOR
>> -extern void console_cursor(int state);
>> -static int blink_count = CONFIG_SYS_CONSOLE_BLINK_COUNT;
>> -static int cursor_state;
>> -#endif
>> -
>>  /* locals */
>>
>>  static int kbd_input = -1;             /* no input yet */
>> @@ -598,15 +592,6 @@ int i8042_tstc(struct stdio_dev *dev)
>>  {
>>         unsigned char scan_code = 0;
>>
>> -#ifdef CONFIG_CONSOLE_CURSOR
>> -       if (--blink_count == 0) {
>> -               cursor_state ^= 1;
>> -               console_cursor(cursor_state);
>> -               blink_count = CONFIG_SYS_CONSOLE_BLINK_COUNT;
>> -               udelay(10);
>> -       }
>> -#endif
>> -
>>         if ((in8(I8042_STS_REG) & STATUS_OBF) == 0) {
>>                 return 0;
>>         } else {
>> @@ -635,14 +620,6 @@ int i8042_getc(struct stdio_dev *dev)
>>
>>         while (kbd_input == -1) {
>>                 while ((in8(I8042_STS_REG) & STATUS_OBF) == 0) {
>> -#ifdef CONFIG_CONSOLE_CURSOR
>> -                       if (--blink_count == 0) {
>> -                               cursor_state ^= 1;
>> -                               console_cursor(cursor_state);
>> -                               blink_count = CONFIG_SYS_CONSOLE_BLINK_COUNT;
>> -                       }
>> -                       udelay(10);
>> -#endif
>>                 }
>>                 scan_code = in8(I8042_DATA_REG);
>>                 if (scan_code != 0xfa)
>> diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c
>> index aa7ca86..1b5c3e0 100644
>> --- a/drivers/video/cfb_console.c
>> +++ b/drivers/video/cfb_console.c
>> @@ -43,13 +43,6 @@
>>   * VIDEO_TSTC_FCT            - keyboard_tstc function
>>   * VIDEO_GETC_FCT            - keyboard_getc function
>>   *
>> - * CONFIG_CONSOLE_CURSOR      - on/off drawing cursor is done with
>> - *                             delay loop in VIDEO_TSTC_FCT (i8042)
>> - *
>> - * CONFIG_SYS_CONSOLE_BLINK_COUNT - value for delay loop - blink rate
>> - * CONFIG_CONSOLE_TIME       - display time/date in upper right
>> - *                             corner, needs CONFIG_CMD_DATE and
>> - *                             CONFIG_CONSOLE_CURSOR
>>   * CONFIG_VIDEO_LOGO         - display Linux Logo in upper left corner.
>>   *                             Use CONFIG_SPLASH_SCREEN_ALIGN with
>>   *                             environment variable "splashpos" to place
>> @@ -198,9 +191,6 @@
>>
>>  /*
>>   * Cursor definition:
>> - * CONFIG_CONSOLE_CURSOR:  Uses a timer function (see drivers/input/i8042.c)
>> - *                        to let the cursor blink. Uses the macros
>> - *                        CURSOR_OFF and CURSOR_ON.
>>   * CONFIG_VIDEO_SW_CURSOR: Draws a cursor after the last character. No
>>   *                        blinking is provided. Uses the macros CURSOR_SET
>>   *                        and CURSOR_OFF.
>> @@ -210,42 +200,29 @@
>>   *                        must disable the hardware register of the graphic
>>   *                        chip. Otherwise a blinking field is displayed
>>   */
>> -#if !defined(CONFIG_CONSOLE_CURSOR) && \
>> -    !defined(CONFIG_VIDEO_SW_CURSOR) && \
>> -    !defined(CONFIG_VIDEO_HW_CURSOR)
>> +#if !defined(CONFIG_VIDEO_SW_CURSOR) && !defined(CONFIG_VIDEO_HW_CURSOR)
>>  /* no Cursor defined */
>>  #define CURSOR_ON
>>  #define CURSOR_OFF
>>  #define CURSOR_SET
>>  #endif
>>
>> -#if defined(CONFIG_CONSOLE_CURSOR) || defined(CONFIG_VIDEO_SW_CURSOR)
>> -#if defined(CURSOR_ON) || \
>> -       (defined(CONFIG_CONSOLE_CURSOR) && defined(CONFIG_VIDEO_SW_CURSOR))
>> -#error only one of CONFIG_CONSOLE_CURSOR, CONFIG_VIDEO_SW_CURSOR, \
>> -       or CONFIG_VIDEO_HW_CURSOR can be defined
>> +#if defined(CONFIG_VIDEO_SW_CURSOR)
>> +#if defined(CONFIG_VIDEO_HW_CURSOR)
>
> #if defined(CURSOR_ON) || defined(CONFIG_VIDEO_HW_CURSOR) ?

I don't think so, but the whole thing is quite confusing.

Regards,
Simon

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 18/28] input: Support the German keymap
  2015-09-15  6:12   ` Bin Meng
@ 2015-10-18 23:17     ` Simon Glass
  0 siblings, 0 replies; 60+ messages in thread
From: Simon Glass @ 2015-10-18 23:17 UTC (permalink / raw)
  To: u-boot

Hi Bin,

On 15 September 2015 at 00:12, Bin Meng <bmeng.cn@gmail.com> wrote:
> Hi Simon,
>
> On Wed, Sep 9, 2015 at 12:32 PM, Simon Glass <sjg@chromium.org> wrote:
>> Add support for the German keymap, taken from i8042.c. This can be selected
>> when the input library it initialised.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>
>>  board/kosagi/novena/novena.c |  2 +-
>>  drivers/input/cros_ec_keyb.c |  2 +-
>>  drivers/input/input.c        | 82 ++++++++++++++++++++++++++++++++++++++++----
>>  drivers/input/tegra-kbc.c    |  2 +-
>>  include/input.h              |  3 +-
>>  5 files changed, 80 insertions(+), 11 deletions(-)
>>
>> diff --git a/board/kosagi/novena/novena.c b/board/kosagi/novena/novena.c
>> index 48cbb0f..0b61365 100644
>> --- a/board/kosagi/novena/novena.c
>> +++ b/board/kosagi/novena/novena.c
>> @@ -88,7 +88,7 @@ int drv_keyboard_init(void)
>>                 debug("%s: Cannot set up input\n", __func__);
>>                 return -1;
>>         }
>> -       input_add_tables(&button_input);
>> +       input_add_tables(&button_input, false);
>>         button_input.read_keys = novena_gpio_button_read_keys;
>>
>>         error = input_stdio_register(&dev);
>> diff --git a/drivers/input/cros_ec_keyb.c b/drivers/input/cros_ec_keyb.c
>> index fe5caea..9bc4555 100644
>> --- a/drivers/input/cros_ec_keyb.c
>> +++ b/drivers/input/cros_ec_keyb.c
>> @@ -211,7 +211,7 @@ static int cros_ec_kbd_probe(struct udevice *dev)
>>
>>         priv->input = input;
>>         input->dev = dev;
>> -       input_add_tables(input);
>> +       input_add_tables(input, false);
>>         input->read_keys = cros_ec_kbc_check;
>>         strcpy(sdev->name, "cros-ec-keyb");
>>
>> diff --git a/drivers/input/input.c b/drivers/input/input.c
>> index c488f3a..a54449e 100644
>> --- a/drivers/input/input.c
>> +++ b/drivers/input/input.c
>> @@ -78,6 +78,60 @@ static unsigned char kbd_ctrl_xlate[] = {
>>         '\r', 0xff, '/',  '*',
>>  };
>>
>> +static const uchar kbd_plain_xlate_german[] = {
>> +       0xff, 0x1b,  '1',  '2',  '3',  '4',  '5',  '6', /* scan 00-07 */
>> +        '7',  '8',  '9',  '0', 0xe1, '\'', 0x08, '\t', /* scan 08-0F */
>> +        'q',  'w',  'e',  'r',  't',  'z',  'u',  'i', /* scan 10-17 */
>> +        'o',  'p', 0x81,  '+', '\r', 0xff,  'a',  's', /* scan 18-1F */
>> +        'd',  'f',  'g',  'h',  'j',  'k',  'l', 0x94, /* scan 20-27 */
>> +       0x84,  '^', 0xff,  '#',  'y',  'x',  'c',  'v', /* scan 28-2F */
>> +        'b',  'n',  'm',  ',',  '.',  '-', 0xff,  '*', /* scan 30-37 */
>> +        ' ',  ' ', 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 38-3F */
>> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,  '7', /* scan 40-47 */
>> +        '8',  '9',  '-',  '4',  '5',  '6',  '+',  '1', /* scan 48-4F */
>> +        '2',  '3',  '0',  ',', 0xff, 0xff,  '<', 0xff, /* scan 50-57 */
>> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 58-5F */
>> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 60-67 */
>> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 68-6F */
>> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 70-77 */
>> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 78-7F */
>> +       '\r', 0xff,  '/',  '*',
>> +};
>> +
>> +static unsigned char kbd_shift_xlate_german[] = {
>> +          0xff, 0x1b,  '!',  '"', 0x15,  '$',  '%',  '&', /* scan 00-07 */
>> +        '/',  '(',  ')',  '=',  '?',  '`', 0x08, '\t', /* scan 08-0F */
>> +        'Q',  'W',  'E',  'R',  'T',  'Z',  'U',  'I', /* scan 10-17 */
>> +        'O',  'P', 0x9a,  '*', '\r', 0xff,  'A',  'S', /* scan 18-1F */
>> +        'D',  'F',  'G',  'H',  'J',  'K',  'L', 0x99, /* scan 20-27 */
>> +       0x8e, 0xf8, 0xff, '\'',  'Y',  'X',  'C',  'V', /* scan 28-2F */
>> +        'B',  'N',  'M',  ';',  ':',  '_', 0xff,  '*', /* scan 30-37 */
>> +        ' ',  ' ', 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 38-3F */
>> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,  '7', /* scan 40-47 */
>> +        '8',  '9',  '-',  '4',  '5',  '6',  '+',  '1', /* scan 48-4F */
>> +        '2',  '3',  '0',  ',', 0xff, 0xff,  '>', 0xff, /* scan 50-57 */
>> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 58-5F */
>> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 60-67 */
>> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 68-6F */
>> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 70-77 */
>> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 78-7F */
>> +       '\r', 0xff,  '/',  '*',
>> +};
>> +
>> +static unsigned char kbd_right_alt_xlate_german[] = {
>> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 00-07 */
>> +        '{',  '[',  ']',  '}', '\\', 0xff, 0xff, 0xff, /* scan 08-0F */
>> +        '@', 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 10-17 */
>> +       0xff, 0xff, 0xff,  '~', 0xff, 0xff, 0xff, 0xff, /* scan 18-1F */
>> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 20-27 */
>> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 28-2F */
>> +       0xff, 0xff, 0xe6, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 30-37 */
>> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 38-3F */
>> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 40-47 */
>> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* scan 48-4F */
>> +       0xff, 0xff, 0xff, 0xff, 0xff, 0xff,  '|', 0xff, /* scan 50-57 */
>> +};
>> +
>>  /*
>>   * Scan key code to ANSI 3.64 escape sequence table.  This table is
>>   * incomplete in that it does not include all possible extra keys.
>> @@ -500,14 +554,28 @@ void input_allow_repeats(struct input_config *config, bool allow_repeats)
>>         config->allow_repeats = allow_repeats;
>>  }
>>
>> -int input_add_tables(struct input_config *config)
>> +int input_add_tables(struct input_config *config, bool german)
>>  {
>> -       input_add_table(config, -1, -1,
>> -                       kbd_plain_xlate, ARRAY_SIZE(kbd_plain_xlate));
>> -       input_add_table(config, KEY_LEFTSHIFT, KEY_RIGHTSHIFT,
>> -                       kbd_shift_xlate, ARRAY_SIZE(kbd_shift_xlate));
>> -       input_add_table(config, KEY_LEFTCTRL, KEY_RIGHTCTRL,
>> -                       kbd_ctrl_xlate, ARRAY_SIZE(kbd_ctrl_xlate));
>> +       if (german) {
>> +               input_add_table(config, -1, -1,
>> +                               kbd_plain_xlate_german,
>> +                               ARRAY_SIZE(kbd_plain_xlate_german));
>> +               input_add_table(config, KEY_LEFTSHIFT, KEY_RIGHTSHIFT,
>> +                               kbd_shift_xlate_german,
>> +                               ARRAY_SIZE(kbd_shift_xlate_german));
>> +               input_add_table(config, KEY_LEFTCTRL, KEY_RIGHTCTRL,
>> +                               kbd_ctrl_xlate, ARRAY_SIZE(kbd_ctrl_xlate));
>> +       } else {
>> +               input_add_table(config, -1, -1,
>> +                               kbd_plain_xlate, ARRAY_SIZE(kbd_plain_xlate));
>> +               input_add_table(config, KEY_LEFTSHIFT, KEY_RIGHTSHIFT,
>> +                               kbd_shift_xlate, ARRAY_SIZE(kbd_shift_xlate));
>> +               input_add_table(config, KEY_LEFTCTRL, KEY_RIGHTCTRL,
>> +                               kbd_ctrl_xlate, ARRAY_SIZE(kbd_ctrl_xlate));
>> +               input_add_table(config, -1, KEY_RIGHTALT,
>> +                               kbd_right_alt_xlate_german,
>> +                               ARRAY_SIZE(kbd_right_alt_xlate_german));
>> +       }
>>
>>         return 0;
>>  }
>> diff --git a/drivers/input/tegra-kbc.c b/drivers/input/tegra-kbc.c
>> index a7137f1..951cbb4 100644
>> --- a/drivers/input/tegra-kbc.c
>> +++ b/drivers/input/tegra-kbc.c
>> @@ -326,7 +326,7 @@ static int tegra_kbd_probe(struct udevice *dev)
>>         priv->input = input;
>>         input->dev = dev;
>>         input->read_keys = tegra_kbc_check;
>> -       input_add_tables(input);
>> +       input_add_tables(input, false);
>>         strcpy(sdev->name, "tegra-kbc");
>>         ret = input_stdio_register(sdev);
>>         if (ret) {
>> diff --git a/include/input.h b/include/input.h
>> index e56f500..c1af259 100644
>> --- a/include/input.h
>> +++ b/include/input.h
>> @@ -167,9 +167,10 @@ void input_allow_repeats(struct input_config *config, bool allow_repeats);
>>   * This must be called after input_init() or keycode decoding will not work.
>>   *
>>   * @param config       Input state
>> + * @param german       true to use German keyboard layout, false for US
>>   * @return 0 if ok, -1 on error
>>   */
>> -int input_add_tables(struct input_config *config);
>> +int input_add_tables(struct input_config *config, bool german);
>
> Can we create some extensible parameter for keyboard layout? What if
> in the future we add a 3rd layout?

We could, but U-Boot has been running for >10 years with only two. So
I think that would be a premature feature. Keyboards are quite rare
and the need for special characters in U-Boot is even rarer.

Regards,
Simon

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 24/28] x86: Add an i8042 device for boards that have it
  2015-09-15  6:12   ` Bin Meng
@ 2015-10-18 23:17     ` Simon Glass
  0 siblings, 0 replies; 60+ messages in thread
From: Simon Glass @ 2015-10-18 23:17 UTC (permalink / raw)
  To: u-boot

Hi Bin,

On 15 September 2015 at 00:12, Bin Meng <bmeng.cn@gmail.com> wrote:
> Hi Simon,
>
> On Wed, Sep 9, 2015 at 12:32 PM, Simon Glass <sjg@chromium.org> wrote:
>> Some boards have an i8042 device. Enable the driver for all x86 boards, and
>> add a device tree node for those which may have this keyboard.
>>
>> Also adjust the configuration so that i8042 is always separate from the VGA,
>> and rename the stdin driver accordingly. With this commit the keyboard will
>> not work, but it is fixed in the next commit.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>
>>  arch/x86/Kconfig                 | 6 ++++++
>>  arch/x86/dts/bayleybay.dts       | 1 +
>>  arch/x86/dts/chromebook_link.dts | 1 +
>>  arch/x86/dts/keyboard.dtsi       | 5 +++++
>>  include/configs/x86-chromebook.h | 2 +-
>>  include/configs/x86-common.h     | 2 +-
>>  6 files changed, 15 insertions(+), 2 deletions(-)
>>  create mode 100644 arch/x86/dts/keyboard.dtsi
>>
>> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
>> index 5e42d7d..72a66ea 100644
>> --- a/arch/x86/Kconfig
>> +++ b/arch/x86/Kconfig
>> @@ -401,6 +401,12 @@ config PCIE_ECAM_SIZE
>>           so a default 0x10000000 size covers all of the 256 buses which is the
>>           maximum number of PCI buses as defined by the PCI specification.
>>
>> +config I8042_KEYB
>> +       default y
>> +
>> +config DM_KEYBOARD
>> +       default y
>> +
>
> I am not in favor of adding driver options in the arch Kconfig. We
> specify other drivers in the boards' defconfig files. Can we move
> these two to defconfig too?

The idea is that x86 has moved to use driver model for keyboard. Any
new boards should also. This option will be removed when everything is
converted so I don't think it should be exposed too widely.

>
>>  source "arch/x86/lib/efi/Kconfig"
>>
>>  endmenu
>> diff --git a/arch/x86/dts/bayleybay.dts b/arch/x86/dts/bayleybay.dts
>> index d646987..58d97c8 100644
>> --- a/arch/x86/dts/bayleybay.dts
>> +++ b/arch/x86/dts/bayleybay.dts
>> @@ -10,6 +10,7 @@
>>  #include <dt-bindings/interrupt-router/intel-irq.h>
>>
>>  /include/ "skeleton.dtsi"
>> +/include/ "keyboard.dtsi"
>>  /include/ "serial.dtsi"
>>  /include/ "rtc.dtsi"
>>
>> diff --git a/arch/x86/dts/chromebook_link.dts b/arch/x86/dts/chromebook_link.dts
>> index 4291141..a52c84f 100644
>> --- a/arch/x86/dts/chromebook_link.dts
>> +++ b/arch/x86/dts/chromebook_link.dts
>> @@ -1,6 +1,7 @@
>>  /dts-v1/;
>>
>>  /include/ "skeleton.dtsi"
>> +/include/ "keyboard.dtsi"
>>  /include/ "serial.dtsi"
>>  /include/ "rtc.dtsi"
>>
>> diff --git a/arch/x86/dts/keyboard.dtsi b/arch/x86/dts/keyboard.dtsi
>> new file mode 100644
>> index 0000000..000751b
>> --- /dev/null
>> +++ b/arch/x86/dts/keyboard.dtsi
>> @@ -0,0 +1,5 @@
>> +/ {
>> +       keyboard {
>> +               compatible = "intel,i8042-keyboard";
>> +       };
>> +};
>> diff --git a/include/configs/x86-chromebook.h b/include/configs/x86-chromebook.h
>> index 2be8850..4ff8b94 100644
>> --- a/include/configs/x86-chromebook.h
>> +++ b/include/configs/x86-chromebook.h
>> @@ -51,7 +51,7 @@
>>  #define CONFIG_ENV_IS_IN_SPI_FLASH
>>  #define CONFIG_ENV_OFFSET              0x003f8000
>>
>> -#define CONFIG_STD_DEVICES_SETTINGS     "stdin=usbkbd,vga,serial\0" \
>> +#define CONFIG_STD_DEVICES_SETTINGS     "stdin=usbkbd,i8042-kbd,serial\0" \
>>                                         "stdout=vga,serial\0" \
>>                                         "stderr=vga,serial\0"
>>
>> diff --git a/include/configs/x86-common.h b/include/configs/x86-common.h
>> index 3f153f2..ff8fe0f 100644
>> --- a/include/configs/x86-common.h
>> +++ b/include/configs/x86-common.h
>> @@ -147,7 +147,7 @@
>>  #define CONFIG_VIDEO
>>  #define CONFIG_VIDEO_SW_CURSOR
>>  #define VIDEO_FB_16BPP_WORD_SWAP
>> -#define CONFIG_I8042_KBD
>> +#define CONFIG_VGA_AS_SINGLE_DEVICE
>
> Can we remove CONFIG_VGA_AS_SINGLE_DEVICE from all x86 board config.h
> files to avoid duplication?

Will do.

>
>>  #define CONFIG_CFB_CONSOLE
>>  #define CONFIG_CONSOLE_SCROLL_LINES 5

Regards,
Simon

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 26/28] input: Convert i8042 to driver model
  2015-09-15  6:12   ` Bin Meng
@ 2015-10-18 23:17     ` Simon Glass
  2015-10-19  1:53       ` Simon Glass
  2015-10-19  3:01       ` Bin Meng
  0 siblings, 2 replies; 60+ messages in thread
From: Simon Glass @ 2015-10-18 23:17 UTC (permalink / raw)
  To: u-boot

Hi Bin,

On 15 September 2015 at 00:12, Bin Meng <bmeng.cn@gmail.com> wrote:
> Hi Simon,
>
> On Wed, Sep 9, 2015 at 12:32 PM, Simon Glass <sjg@chromium.org> wrote:
>> Adjust this driver to support driver model. The only users are x86 boards
>> so this should be safe.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>
> After updating QEMU to use the DM i8042 driver below:
>
> diff --git a/arch/x86/dts/qemu-x86_i440fx.dts b/arch/x86/dts/qemu-x86_i440fx.dts
> index fc74cd0..14782b3 100644
> --- a/arch/x86/dts/qemu-x86_i440fx.dts
> +++ b/arch/x86/dts/qemu-x86_i440fx.dts
> @@ -11,6 +11,7 @@
>  /include/ "skeleton.dtsi"
>  /include/ "serial.dtsi"
>  /include/ "rtc.dtsi"
> +/include/ "keyboard.dtsi"
>
>  / {
>         model = "QEMU x86 (I440FX)";
> diff --git a/include/configs/qemu-x86.h b/include/configs/qemu-x86.h
> index 1b544c1..9daf943 100644
> --- a/include/configs/qemu-x86.h
> +++ b/include/configs/qemu-x86.h
> @@ -30,7 +30,7 @@
>
>  #define CONFIG_PCI_PNP
>
> -#define CONFIG_STD_DEVICES_SETTINGS    "stdin=serial,vga\0" \
> +#define CONFIG_STD_DEVICES_SETTINGS    "stdin=serial,i8042-kbd\0" \
>                                         "stdout=serial,vga\0" \
>                                         "stderr=serial,vga\0"
>
>
> The i8042 still does not work. I've applied the same changes to Crown
> Bay. i8042 does not work either. Could you please have a look?
>

It's hard for me to debug this on hardware. I should be able to use
qemu though. Is there anything special needed to make it use that
keyboard?

Regards,
Simon

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 26/28] input: Convert i8042 to driver model
  2015-10-18 23:17     ` Simon Glass
@ 2015-10-19  1:53       ` Simon Glass
  2015-10-19  3:01       ` Bin Meng
  1 sibling, 0 replies; 60+ messages in thread
From: Simon Glass @ 2015-10-19  1:53 UTC (permalink / raw)
  To: u-boot

Hi Bin,

On 18 October 2015 at 17:17, Simon Glass <sjg@chromium.org> wrote:
> Hi Bin,
>
> On 15 September 2015 at 00:12, Bin Meng <bmeng.cn@gmail.com> wrote:
>> Hi Simon,
>>
>> On Wed, Sep 9, 2015 at 12:32 PM, Simon Glass <sjg@chromium.org> wrote:
>>> Adjust this driver to support driver model. The only users are x86 boards
>>> so this should be safe.
>>>
>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>> ---
>>
>> After updating QEMU to use the DM i8042 driver below:
>>
>> diff --git a/arch/x86/dts/qemu-x86_i440fx.dts b/arch/x86/dts/qemu-x86_i440fx.dts
>> index fc74cd0..14782b3 100644
>> --- a/arch/x86/dts/qemu-x86_i440fx.dts
>> +++ b/arch/x86/dts/qemu-x86_i440fx.dts
>> @@ -11,6 +11,7 @@
>>  /include/ "skeleton.dtsi"
>>  /include/ "serial.dtsi"
>>  /include/ "rtc.dtsi"
>> +/include/ "keyboard.dtsi"
>>
>>  / {
>>         model = "QEMU x86 (I440FX)";
>> diff --git a/include/configs/qemu-x86.h b/include/configs/qemu-x86.h
>> index 1b544c1..9daf943 100644
>> --- a/include/configs/qemu-x86.h
>> +++ b/include/configs/qemu-x86.h
>> @@ -30,7 +30,7 @@
>>
>>  #define CONFIG_PCI_PNP
>>
>> -#define CONFIG_STD_DEVICES_SETTINGS    "stdin=serial,vga\0" \
>> +#define CONFIG_STD_DEVICES_SETTINGS    "stdin=serial,i8042-kbd\0" \
>>                                         "stdout=serial,vga\0" \
>>                                         "stderr=serial,vga\0"
>>
>>
>> The i8042 still does not work. I've applied the same changes to Crown
>> Bay. i8042 does not work either. Could you please have a look?
>>
>
> It's hard for me to debug this on hardware. I should be able to use
> qemu though. Is there anything special needed to make it use that
> keyboard?

Actually it works for me with qemu.

However it is intermittent, as it was before my series. So there is
something else going on.

Regards,
Simon

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 26/28] input: Convert i8042 to driver model
  2015-10-18 23:17     ` Simon Glass
  2015-10-19  1:53       ` Simon Glass
@ 2015-10-19  3:01       ` Bin Meng
  2015-10-19  3:07         ` Simon Glass
  1 sibling, 1 reply; 60+ messages in thread
From: Bin Meng @ 2015-10-19  3:01 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On Mon, Oct 19, 2015 at 7:17 AM, Simon Glass <sjg@chromium.org> wrote:
> Hi Bin,
>
> On 15 September 2015 at 00:12, Bin Meng <bmeng.cn@gmail.com> wrote:
>> Hi Simon,
>>
>> On Wed, Sep 9, 2015 at 12:32 PM, Simon Glass <sjg@chromium.org> wrote:
>>> Adjust this driver to support driver model. The only users are x86 boards
>>> so this should be safe.
>>>
>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>> ---
>>
>> After updating QEMU to use the DM i8042 driver below:
>>
>> diff --git a/arch/x86/dts/qemu-x86_i440fx.dts b/arch/x86/dts/qemu-x86_i440fx.dts
>> index fc74cd0..14782b3 100644
>> --- a/arch/x86/dts/qemu-x86_i440fx.dts
>> +++ b/arch/x86/dts/qemu-x86_i440fx.dts
>> @@ -11,6 +11,7 @@
>>  /include/ "skeleton.dtsi"
>>  /include/ "serial.dtsi"
>>  /include/ "rtc.dtsi"
>> +/include/ "keyboard.dtsi"
>>
>>  / {
>>         model = "QEMU x86 (I440FX)";
>> diff --git a/include/configs/qemu-x86.h b/include/configs/qemu-x86.h
>> index 1b544c1..9daf943 100644
>> --- a/include/configs/qemu-x86.h
>> +++ b/include/configs/qemu-x86.h
>> @@ -30,7 +30,7 @@
>>
>>  #define CONFIG_PCI_PNP
>>
>> -#define CONFIG_STD_DEVICES_SETTINGS    "stdin=serial,vga\0" \
>> +#define CONFIG_STD_DEVICES_SETTINGS    "stdin=serial,i8042-kbd\0" \
>>                                         "stdout=serial,vga\0" \
>>                                         "stderr=serial,vga\0"
>>
>>
>> The i8042 still does not work. I've applied the same changes to Crown
>> Bay. i8042 does not work either. Could you please have a look?
>>
>
> It's hard for me to debug this on hardware. I should be able to use
> qemu though. Is there anything special needed to make it use that
> keyboard?
>

I will have another try (and debug if it is needed) on Crown Bay when
you send the v2 series.

Regards,
Bin

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 26/28] input: Convert i8042 to driver model
  2015-10-19  3:01       ` Bin Meng
@ 2015-10-19  3:07         ` Simon Glass
  0 siblings, 0 replies; 60+ messages in thread
From: Simon Glass @ 2015-10-19  3:07 UTC (permalink / raw)
  To: u-boot

Hi Bin,

On 18 October 2015 at 21:01, Bin Meng <bmeng.cn@gmail.com> wrote:
> Hi Simon,
>
> On Mon, Oct 19, 2015 at 7:17 AM, Simon Glass <sjg@chromium.org> wrote:
>> Hi Bin,
>>
>> On 15 September 2015 at 00:12, Bin Meng <bmeng.cn@gmail.com> wrote:
>>> Hi Simon,
>>>
>>> On Wed, Sep 9, 2015 at 12:32 PM, Simon Glass <sjg@chromium.org> wrote:
>>>> Adjust this driver to support driver model. The only users are x86 boards
>>>> so this should be safe.
>>>>
>>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>>> ---
>>>
>>> After updating QEMU to use the DM i8042 driver below:
>>>
>>> diff --git a/arch/x86/dts/qemu-x86_i440fx.dts b/arch/x86/dts/qemu-x86_i440fx.dts
>>> index fc74cd0..14782b3 100644
>>> --- a/arch/x86/dts/qemu-x86_i440fx.dts
>>> +++ b/arch/x86/dts/qemu-x86_i440fx.dts
>>> @@ -11,6 +11,7 @@
>>>  /include/ "skeleton.dtsi"
>>>  /include/ "serial.dtsi"
>>>  /include/ "rtc.dtsi"
>>> +/include/ "keyboard.dtsi"
>>>
>>>  / {
>>>         model = "QEMU x86 (I440FX)";
>>> diff --git a/include/configs/qemu-x86.h b/include/configs/qemu-x86.h
>>> index 1b544c1..9daf943 100644
>>> --- a/include/configs/qemu-x86.h
>>> +++ b/include/configs/qemu-x86.h
>>> @@ -30,7 +30,7 @@
>>>
>>>  #define CONFIG_PCI_PNP
>>>
>>> -#define CONFIG_STD_DEVICES_SETTINGS    "stdin=serial,vga\0" \
>>> +#define CONFIG_STD_DEVICES_SETTINGS    "stdin=serial,i8042-kbd\0" \
>>>                                         "stdout=serial,vga\0" \
>>>                                         "stderr=serial,vga\0"
>>>
>>>
>>> The i8042 still does not work. I've applied the same changes to Crown
>>> Bay. i8042 does not work either. Could you please have a look?
>>>
>>
>> It's hard for me to debug this on hardware. I should be able to use
>> qemu though. Is there anything special needed to make it use that
>> keyboard?
>>
>
> I will have another try (and debug if it is needed) on Crown Bay when
> you send the v2 series.

Thanks - also note that I have not fixed the hang on caps lock that
you reported.

Regards,
Simon

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 06/28] dm: stdio: Plumb in the new keyboard uclass
  2015-09-09  4:32 ` [U-Boot] [PATCH 06/28] dm: stdio: Plumb in the new keyboard uclass Simon Glass
  2015-09-15  6:11   ` Bin Meng
@ 2015-10-30 20:24   ` Simon Glass
  1 sibling, 0 replies; 60+ messages in thread
From: Simon Glass @ 2015-10-30 20:24 UTC (permalink / raw)
  To: u-boot

Applied to u-boot-dm.

^ permalink raw reply	[flat|nested] 60+ messages in thread

* [U-Boot] [PATCH 17/28] input: Allow repeat filtering to be disabled
  2015-09-09  4:32 ` [U-Boot] [PATCH 17/28] input: Allow repeat filtering to be disabled Simon Glass
@ 2015-10-30 20:24   ` Simon Glass
  0 siblings, 0 replies; 60+ messages in thread
From: Simon Glass @ 2015-10-30 20:24 UTC (permalink / raw)
  To: u-boot

Applied to u-boot-dm.

^ permalink raw reply	[flat|nested] 60+ messages in thread

end of thread, other threads:[~2015-10-30 20:24 UTC | newest]

Thread overview: 60+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-09  4:32 [U-Boot] [PATCH 00/28] dm: input: Move keyboard drivers to driver model Simon Glass
2015-09-09  4:32 ` [U-Boot] [PATCH 01/28] dm: input: Create a keyboard uclass Simon Glass
2015-09-09 12:17   ` Marek Vasut
2015-09-15  6:11   ` Bin Meng
2015-10-18 23:17     ` Simon Glass
2015-09-09  4:32 ` [U-Boot] [PATCH 02/28] input: Add a device pointer to the input config Simon Glass
2015-09-15  6:11   ` Bin Meng
2015-09-09  4:32 ` [U-Boot] [PATCH 03/28] input: Return -ENOSPC when there is not space Simon Glass
2015-09-15  6:11   ` Bin Meng
2015-09-09  4:32 ` [U-Boot] [PATCH 04/28] input: Add the keycode translation tables separately Simon Glass
2015-09-15  6:11   ` Bin Meng
2015-10-18 23:17     ` Simon Glass
2015-09-09  4:32 ` [U-Boot] [PATCH 05/28] cros_ec: Use udevice instead of cros_ec_dev for keyboard functions Simon Glass
2015-09-09  4:32 ` [U-Boot] [PATCH 06/28] dm: stdio: Plumb in the new keyboard uclass Simon Glass
2015-09-15  6:11   ` Bin Meng
2015-10-18 23:17     ` Simon Glass
2015-10-30 20:24   ` Simon Glass
2015-09-09  4:32 ` [U-Boot] [PATCH 07/28] dm: tegra: Convert keyboard driver to driver model Simon Glass
2015-09-09  4:32 ` [U-Boot] [PATCH 08/28] dm: cros_ec: Convert cros_ec " Simon Glass
2015-09-09  4:32 ` [U-Boot] [PATCH 09/28] video: Drop unused console functions Simon Glass
2015-09-15  6:11   ` Bin Meng
2015-10-18 23:17     ` Simon Glass
2015-09-09  4:32 ` [U-Boot] [PATCH 10/28] i8042: Use functions to handle register access Simon Glass
2015-09-15  6:12   ` Bin Meng
2015-09-09  4:32 ` [U-Boot] [PATCH 11/28] i8042: Handle a duplicate power-on-reset response Simon Glass
2015-09-15  6:12   ` Bin Meng
2015-09-09  4:32 ` [U-Boot] [PATCH 12/28] i8042: Adjust kbd_reset() to collect all failures Simon Glass
2015-09-15  6:12   ` Bin Meng
2015-09-09  4:32 ` [U-Boot] [PATCH 13/28] i8042: Adjust keyboard init to assume success Simon Glass
2015-09-15  6:12   ` Bin Meng
2015-09-09  4:32 ` [U-Boot] [PATCH 14/28] input: Correct keycode for Ctrl-Y Simon Glass
2015-09-09  4:32 ` [U-Boot] [PATCH 15/28] input: Add a few more keyboard keycodes Simon Glass
2015-09-15  6:12   ` Bin Meng
2015-09-09  4:32 ` [U-Boot] [PATCH 16/28] input: Add a function to add a keycode to the existing set Simon Glass
2015-09-09  4:32 ` [U-Boot] [PATCH 17/28] input: Allow repeat filtering to be disabled Simon Glass
2015-10-30 20:24   ` Simon Glass
2015-09-09  4:32 ` [U-Boot] [PATCH 18/28] input: Support the German keymap Simon Glass
2015-09-15  6:12   ` Bin Meng
2015-10-18 23:17     ` Simon Glass
2015-09-09  4:32 ` [U-Boot] [PATCH 19/28] input: Adjust structure of code in process_modifier() Simon Glass
2015-09-09  4:32 ` [U-Boot] [PATCH 20/28] input: Handle caps lock Simon Glass
2015-09-09  4:32 ` [U-Boot] [PATCH 21/28] input: Allow updating of keyboard LEDs Simon Glass
2015-09-09  4:32 ` [U-Boot] [PATCH 22/28] input: i8042: Convert to use the input library Simon Glass
2015-09-15  6:12   ` Bin Meng
2015-09-09  4:32 ` [U-Boot] [PATCH 23/28] input: Add a Kconfig option for the i8042 keyboard Simon Glass
2015-09-15  6:12   ` Bin Meng
2015-09-09  4:32 ` [U-Boot] [PATCH 24/28] x86: Add an i8042 device for boards that have it Simon Glass
2015-09-15  6:12   ` Bin Meng
2015-10-18 23:17     ` Simon Glass
2015-09-09  4:32 ` [U-Boot] [PATCH 25/28] Drop CONFIG_ISA_KEYBOARD Simon Glass
2015-09-15  6:12   ` Bin Meng
2015-09-09  4:32 ` [U-Boot] [PATCH 26/28] input: Convert i8042 to driver model Simon Glass
2015-09-15  6:12   ` Bin Meng
2015-10-18 23:17     ` Simon Glass
2015-10-19  1:53       ` Simon Glass
2015-10-19  3:01       ` Bin Meng
2015-10-19  3:07         ` Simon Glass
2015-09-09  4:32 ` [U-Boot] [PATCH 27/28] video: input: Clean up after i8042 conversion Simon Glass
2015-09-15  6:12   ` Bin Meng
2015-09-09  4:32 ` [U-Boot] [PATCH 28/28] input: Convert 'keyboard' driver to use input library Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.