--- /dev/null
+/*
+ * 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);
+}
#ifndef __XEN_SERIAL_H__
#define __XEN_SERIAL_H__
+#include <xen/init.h>
#include <xen/spinlock.h>
struct cpu_user_regs;
};
/* 'Serial handles' are composed from the following fields. */
-#define SERHND_IDX (3<<0) /* COM1, COM2, or DBGP? */
+#define SERHND_IDX (3<<0) /* COM1, COM2, DBGP, DTUART? */
# define SERHND_COM1 (0<<0)
# define SERHND_COM2 (1<<0)
# define SERHND_DBGP (2<<0)
+# define SERHND_DTUART (0<<0) /* Steal SERHND_COM1 value */
#define SERHND_HI (1<<2) /* Mux/demux each transferred char by MSB. */
#define SERHND_LO (1<<3) /* Ditto, except that the MSB is cleared. */
#define SERHND_COOKED (1<<4) /* Newline/carriage-return translation? */
void ehci_dbgp_init(void);
void pl011_init(int index, unsigned long register_base_address);
+void __init dt_uart_init(void);
struct physdev_dbgp_op;
int dbgp_op(const struct physdev_dbgp_op *);