aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiodrag Dinic <miodrag.dinic@imgtec.com>2017-08-29 09:53:20 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-08-31 12:58:45 -0400
commit3840ed9548f778717aaab5eab744da798c3ea055 (patch)
tree322458246a1fa3351a5d4331e1102bccbffe5aad
parent7157d2be23da9f8860c69e2b79184a4e02701dad (diff)
tty: goldfish: Implement support for kernel 'earlycon' parameter
Add early console functionality to the Goldfish tty driver. When 'earlycon' kernel command line parameter is used with no options, the early console is determined by the 'stdout-path' property in device tree's 'chosen' node. This is illustrated in the following device tree source example: Device tree example: chosen { stdout-path = "/goldfish_tty@1f004000"; }; goldfish_tty@1f004000 { interrupts = <0xc>; reg = <0x1f004000 0x0 0x1000>; compatible = "google,goldfish-tty"; }; Signed-off-by: Miodrag Dinic <miodrag.dinic@imgtec.com> Signed-off-by: Goran Ferenc <goran.ferenc@imgtec.com> Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/Kconfig3
-rw-r--r--drivers/tty/goldfish.c26
2 files changed, 29 insertions, 0 deletions
diff --git a/drivers/tty/Kconfig b/drivers/tty/Kconfig
index 95103054c0e4..873e0ba89737 100644
--- a/drivers/tty/Kconfig
+++ b/drivers/tty/Kconfig
@@ -392,6 +392,9 @@ config PPC_EARLY_DEBUG_EHV_BC_HANDLE
392config GOLDFISH_TTY 392config GOLDFISH_TTY
393 tristate "Goldfish TTY Driver" 393 tristate "Goldfish TTY Driver"
394 depends on GOLDFISH 394 depends on GOLDFISH
395 select SERIAL_CORE
396 select SERIAL_CORE_CONSOLE
397 select SERIAL_EARLYCON
395 help 398 help
396 Console and system TTY driver for the Goldfish virtual platform. 399 Console and system TTY driver for the Goldfish virtual platform.
397 400
diff --git a/drivers/tty/goldfish.c b/drivers/tty/goldfish.c
index 757e17ff7aa4..381e981dee06 100644
--- a/drivers/tty/goldfish.c
+++ b/drivers/tty/goldfish.c
@@ -1,6 +1,7 @@
1/* 1/*
2 * Copyright (C) 2007 Google, Inc. 2 * Copyright (C) 2007 Google, Inc.
3 * Copyright (C) 2012 Intel, Inc. 3 * Copyright (C) 2012 Intel, Inc.
4 * Copyright (C) 2017 Imagination Technologies Ltd.
4 * 5 *
5 * This software is licensed under the terms of the GNU General Public 6 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and 7 * License version 2, as published by the Free Software Foundation, and
@@ -24,6 +25,7 @@
24#include <linux/goldfish.h> 25#include <linux/goldfish.h>
25#include <linux/mm.h> 26#include <linux/mm.h>
26#include <linux/dma-mapping.h> 27#include <linux/dma-mapping.h>
28#include <linux/serial_core.h>
27 29
28/* Goldfish tty register's offsets */ 30/* Goldfish tty register's offsets */
29#define GOLDFISH_TTY_REG_BYTES_READY 0x04 31#define GOLDFISH_TTY_REG_BYTES_READY 0x04
@@ -440,6 +442,30 @@ static int goldfish_tty_remove(struct platform_device *pdev)
440 return 0; 442 return 0;
441} 443}
442 444
445static void gf_early_console_putchar(struct uart_port *port, int ch)
446{
447 __raw_writel(ch, port->membase);
448}
449
450static void gf_early_write(struct console *con, const char *s, unsigned int n)
451{
452 struct earlycon_device *dev = con->data;
453
454 uart_console_write(&dev->port, s, n, gf_early_console_putchar);
455}
456
457static int __init gf_earlycon_setup(struct earlycon_device *device,
458 const char *opt)
459{
460 if (!device->port.membase)
461 return -ENODEV;
462
463 device->con->write = gf_early_write;
464 return 0;
465}
466
467OF_EARLYCON_DECLARE(early_gf_tty, "google,goldfish-tty", gf_earlycon_setup);
468
443static const struct of_device_id goldfish_tty_of_match[] = { 469static const struct of_device_id goldfish_tty_of_match[] = {
444 { .compatible = "google,goldfish-tty", }, 470 { .compatible = "google,goldfish-tty", },
445 {}, 471 {},