aboutsummaryrefslogtreecommitdiffstats
path: root/xen/drivers
diff options
context:
space:
mode:
authorJulien Grall <julien.grall@linaro.org>2013-04-27 21:02:04 +0100
committerIan Campbell <ian.campbell@citrix.com>2013-05-13 11:59:59 +0100
commit2a403a18dd34050d9439ce78576fca5f5d03d69d (patch)
tree01b6e3521b6dba232bc6ae6c3136e4a204b1bf17 /xen/drivers
parent2be37b2cda31fc1b5f11deb912249bc54803f055 (diff)
downloadxen-2a403a18dd34050d9439ce78576fca5f5d03d69d.tar.gz
xen-2a403a18dd34050d9439ce78576fca5f5d03d69d.tar.bz2
xen-2a403a18dd34050d9439ce78576fca5f5d03d69d.zip
xen/arm: Add generic UART to get the device in the device tree
This generic UART will find the right UART via xen command line with dtuart=myserial. "myserial" is the alias of the UART in the device tree. Xen will retrieve the information via the device tree and call the initialization function for this specific UART thanks to the device API. Signed-off-by: Julien Grall <julien.grall@linaro.org> Acked-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Keir Fraser <keir@xen.org>
Diffstat (limited to 'xen/drivers')
-rw-r--r--xen/drivers/char/Makefile1
-rw-r--r--xen/drivers/char/dt-uart.c69
-rw-r--r--xen/drivers/char/serial.c6
3 files changed, 76 insertions, 0 deletions
diff --git a/xen/drivers/char/Makefile b/xen/drivers/char/Makefile
index ab2246d61d..9c067f973c 100644
--- a/xen/drivers/char/Makefile
+++ b/xen/drivers/char/Makefile
@@ -2,4 +2,5 @@ obj-y += console.o
obj-$(HAS_NS16550) += ns16550.o
obj-$(HAS_PL011) += pl011.o
obj-$(HAS_EHCI) += ehci-dbgp.o
+obj-$(CONFIG_ARM) += dt-uart.o
obj-y += serial.o
diff --git a/xen/drivers/char/dt-uart.c b/xen/drivers/char/dt-uart.c
new file mode 100644
index 0000000000..93bb0f5845
--- /dev/null
+++ b/xen/drivers/char/dt-uart.c
@@ -0,0 +1,69 @@
+/*
+ * xen/drivers/char/dt-uart.c
+ *
+ * Generic uart retrieved via the device tree
+ *
+ * Julien Grall <julien.grall@linaro.org>
+ * Copyright (c) 2013 Linaro Limited.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <asm/device.h>
+#include <asm/early_printk.h>
+#include <asm/types.h>
+#include <xen/console.h>
+#include <xen/device_tree.h>
+#include <xen/serial.h>
+
+/*
+ * Configure UART port with a string:
+ * alias,options
+ *
+ * @alias: alias used in the device tree for the UART
+ * @options: UART speficic options (see in each UART driver)
+ */
+static char __initdata opt_dtuart[30] = "";
+string_param("dtuart", opt_dtuart);
+
+void __init dt_uart_init(void)
+{
+ struct dt_device_node *dev;
+ int ret;
+ const char *devalias = opt_dtuart;
+ char *options;
+
+ if ( !console_has("dtuart") || !strcmp(opt_dtuart, "") )
+ {
+ early_printk("No console\n");
+ return;
+ }
+
+ options = strchr(opt_dtuart, ',');
+ if ( options != NULL )
+ *(options++) = '\0';
+ else
+ options = "";
+
+ early_printk("Looking for UART console %s\n", devalias);
+ dev = dt_find_node_by_alias(devalias);
+
+ if ( !dev )
+ {
+ early_printk("Unable to find device \"%s\"\n", devalias);
+ return;
+ }
+
+ ret = device_init(dev, DEVICE_SERIAL, options);
+
+ if ( ret )
+ early_printk("Unable to initialize serial: %d\n", ret);
+}
diff --git a/xen/drivers/char/serial.c b/xen/drivers/char/serial.c
index 0ae7e4daeb..e1c3f475af 100644
--- a/xen/drivers/char/serial.c
+++ b/xen/drivers/char/serial.c
@@ -271,6 +271,12 @@ int __init serial_parse_handle(char *conf)
goto common;
}
+ if ( !strncmp(conf, "dtuart", 5) )
+ {
+ handle = SERHND_DTUART;
+ goto common;
+ }
+
if ( strncmp(conf, "com", 3) )
goto fail;