diff mbox

[U-Boot,2/6] x86: video: Allow keyboard presence to be controlled by device tree

Message ID 1423619993-4730-2-git-send-email-sjg@chromium.org
State Superseded
Delegated to: Simon Glass
Headers show

Commit Message

Simon Glass Feb. 11, 2015, 1:59 a.m. UTC
At present a VGA console assumes a keyboard unless a CONFIG option is set.
This difference can be dealt with by a device tree option, allowing boards
that are otherwise the same to use the same configuration.

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

 doc/README.fdt-control      | 16 ++++++++++++++++
 drivers/video/cfb_console.c | 29 +++++++++++++++++++----------
 2 files changed, 35 insertions(+), 10 deletions(-)

Comments

Anatolij Gustschin Feb. 11, 2015, 7:57 a.m. UTC | #1
Hi Simon,

On Tue, 10 Feb 2015 18:59:49 -0700
Simon Glass <sjg@chromium.org> wrote:

> At present a VGA console assumes a keyboard unless a CONFIG option is set.
> This difference can be dealt with by a device tree option, allowing boards
> that are otherwise the same to use the same configuration.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Acked-by: Anatolij Gustschin <agust@denx.de>
diff mbox

Patch

diff --git a/doc/README.fdt-control b/doc/README.fdt-control
index d8fe4a8..e6d5ed0 100644
--- a/doc/README.fdt-control
+++ b/doc/README.fdt-control
@@ -171,6 +171,22 @@  After board configuration is done, fdt supported u-boot can be build in two ways
     $ make DEVICE_TREE=<dts-file-name>
 
 
+Configuration Options
+---------------------
+
+A number of run-time configuration options are provided in the /config node
+of the control device tree. You can access these using fdtdec_get_config_int(),
+fdtdec_get_config_bool() and fdtdec_get_config_string().
+
+Available options are:
+
+silent-console
+	If present and non-zero, the console is silenced by default on boot.
+
+no-keyboard
+	Tells U-Boot not to expect an attached keyboard with a VGA console
+
+
 Limitations
 -----------
 
diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c
index a81affa..fcaaa7f 100644
--- a/drivers/video/cfb_console.c
+++ b/drivers/video/cfb_console.c
@@ -87,6 +87,7 @@ 
  */
 
 #include <common.h>
+#include <fdtdec.h>
 #include <version.h>
 #include <malloc.h>
 #include <linux/compiler.h>
@@ -2251,6 +2252,7 @@  int drv_video_init(void)
 {
 	int skip_dev_init;
 	struct stdio_dev console_dev;
+	bool have_keyboard;
 
 	/* Check if video initialization should be skipped */
 	if (board_video_skip())
@@ -2262,11 +2264,18 @@  int drv_video_init(void)
 	if (board_cfb_skip())
 		return 0;
 
-#if !defined(CONFIG_VGA_AS_SINGLE_DEVICE)
-	debug("KBD: Keyboard init ...\n");
-	skip_dev_init |= (VIDEO_KBD_INIT_FCT == -1);
+#if defined(CONFIG_VGA_AS_SINGLE_DEVICE)
+	have_keyboard = false;
+#elif defined(CONFIG_OF_CONTROL)
+	have_keyboard = !fdtdec_get_config_bool(gd->fdt_blob,
+						"u-boot,no-keyboard");
+#else
+	have_keyboard = true;
 #endif
-
+	if (have_keyboard) {
+		debug("KBD: Keyboard init ...\n");
+		skip_dev_init |= (VIDEO_KBD_INIT_FCT == -1);
+	}
 	if (skip_dev_init)
 		return 0;
 
@@ -2278,12 +2287,12 @@  int drv_video_init(void)
 	console_dev.putc = video_putc;	/* 'putc' function */
 	console_dev.puts = video_puts;	/* 'puts' function */
 
-#if !defined(CONFIG_VGA_AS_SINGLE_DEVICE)
-	/* Also init console device */
-	console_dev.flags |= DEV_FLAGS_INPUT;
-	console_dev.tstc = VIDEO_TSTC_FCT;	/* 'tstc' function */
-	console_dev.getc = VIDEO_GETC_FCT;	/* 'getc' function */
-#endif /* CONFIG_VGA_AS_SINGLE_DEVICE */
+	if (have_keyboard) {
+		/* Also init console device */
+		console_dev.flags |= DEV_FLAGS_INPUT;
+		console_dev.tstc = VIDEO_TSTC_FCT;	/* 'tstc' function */
+		console_dev.getc = VIDEO_GETC_FCT;	/* 'getc' function */
+	}
 
 	if (stdio_register(&console_dev) != 0)
 		return 0;