aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Herring <robh@kernel.org>2014-04-18 18:19:58 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-04-24 19:32:27 -0400
commitd50d7269ebcb438afa346cdffce0f4e2a1b9e831 (patch)
tree7095e7a34467771f9b0e3c2f113cbeb6e7ff5145
parent0d3c673e7881e691991b2a4745bd4f149603baa2 (diff)
tty/serial: add arm/arm64 semihosting earlycon
Add earlycon support for the arm/arm64 semihosting debug serial interface. This allows enabling a debug console when early_params are processed. This is based on the arm64 earlyprintk smh support and is intended to replace it. Signed-off-by: Rob Herring <robh@kernel.org> Cc: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--Documentation/kernel-parameters.txt2
-rw-r--r--drivers/tty/serial/Kconfig10
-rw-r--r--drivers/tty/serial/Makefile1
-rw-r--r--drivers/tty/serial/earlycon-arm-semihost.c61
4 files changed, 74 insertions, 0 deletions
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 2609ead7ff55..4946d8e58d53 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -899,6 +899,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
899 must already be setup and configured. Options are not 899 must already be setup and configured. Options are not
900 yet supported. 900 yet supported.
901 901
902 smh Use ARM semihosting calls for early console.
903
902 earlyprintk= [X86,SH,BLACKFIN,ARM] 904 earlyprintk= [X86,SH,BLACKFIN,ARM]
903 earlyprintk=vga 905 earlyprintk=vga
904 earlyprintk=efi 906 earlyprintk=efi
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index 4290d05875b1..988fa2b6243b 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -73,6 +73,16 @@ config SERIAL_AMBA_PL011_CONSOLE
73 your boot loader (lilo or loadlin) about how to pass options to the 73 your boot loader (lilo or loadlin) about how to pass options to the
74 kernel at boot time.) 74 kernel at boot time.)
75 75
76config SERIAL_EARLYCON_ARM_SEMIHOST
77 bool "Early console using ARM semihosting"
78 depends on ARM64 || ARM
79 select SERIAL_EARLYCON
80 help
81 Support for early debug console using ARM semihosting. This enables
82 the console before standard serial driver is probed. This is enabled
83 with "earlycon=smh" on the kernel command line. The console is
84 enabled when early_param is processed.
85
76config SERIAL_SB1250_DUART 86config SERIAL_SB1250_DUART
77 tristate "BCM1xxx on-chip DUART serial support" 87 tristate "BCM1xxx on-chip DUART serial support"
78 depends on SIBYTE_SB1xxx_SOC=y 88 depends on SIBYTE_SB1xxx_SOC=y
diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile
index 28048178f308..3a5be4633333 100644
--- a/drivers/tty/serial/Makefile
+++ b/drivers/tty/serial/Makefile
@@ -6,6 +6,7 @@ obj-$(CONFIG_SERIAL_CORE) += serial_core.o
6obj-$(CONFIG_SERIAL_21285) += 21285.o 6obj-$(CONFIG_SERIAL_21285) += 21285.o
7 7
8obj-$(CONFIG_SERIAL_EARLYCON) += earlycon.o 8obj-$(CONFIG_SERIAL_EARLYCON) += earlycon.o
9obj-$(CONFIG_SERIAL_EARLYCON_ARM_SEMIHOST) += earlycon-arm-semihost.o
9 10
10# These Sparc drivers have to appear before others such as 8250 11# These Sparc drivers have to appear before others such as 8250
11# which share ttySx minor node space. Otherwise console device 12# which share ttySx minor node space. Otherwise console device
diff --git a/drivers/tty/serial/earlycon-arm-semihost.c b/drivers/tty/serial/earlycon-arm-semihost.c
new file mode 100644
index 000000000000..383db10fbb49
--- /dev/null
+++ b/drivers/tty/serial/earlycon-arm-semihost.c
@@ -0,0 +1,61 @@
1/*
2 * Copyright (C) 2012 ARM Ltd.
3 * Author: Marc Zyngier <marc.zyngier@arm.com>
4 *
5 * Adapted for ARM and earlycon:
6 * Copyright (C) 2014 Linaro Ltd.
7 * Author: Rob Herring <robh@kernel.org>
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21#include <linux/kernel.h>
22#include <linux/console.h>
23#include <linux/init.h>
24#include <linux/serial_core.h>
25
26#ifdef CONFIG_THUMB2_KERNEL
27#define SEMIHOST_SWI "0xab"
28#else
29#define SEMIHOST_SWI "0x123456"
30#endif
31
32/*
33 * Semihosting-based debug console
34 */
35static void smh_putc(struct uart_port *port, int c)
36{
37#ifdef CONFIG_ARM64
38 asm volatile("mov x1, %0\n"
39 "mov x0, #3\n"
40 "hlt 0xf000\n"
41 : : "r" (&c) : "x0", "x1", "memory");
42#else
43 asm volatile("mov r1, %0\n"
44 "mov r0, #3\n"
45 "svc " SEMIHOST_SWI "\n"
46 : : "r" (&c) : "r0", "r1", "memory");
47#endif
48}
49
50static void smh_write(struct console *con, const char *s, unsigned n)
51{
52 struct earlycon_device *dev = con->data;
53 uart_console_write(&dev->port, s, n, smh_putc);
54}
55
56int __init early_smh_setup(struct earlycon_device *device, const char *opt)
57{
58 device->con->write = smh_write;
59 return 0;
60}
61EARLYCON_DECLARE(smh, early_smh_setup);