Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751584AbdF1P6G (ORCPT ); Wed, 28 Jun 2017 11:58:06 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:50611 "EHLO mail.rt-rk.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751652AbdF1P50 (ORCPT ); Wed, 28 Jun 2017 11:57:26 -0400 From: Aleksandar Markovic To: linux-mips@linux-mips.org Cc: Miodrag Dinic , Goran Ferenc , Aleksandar Markovic , Douglas Leung , Greg Kroah-Hartman , James Hogan , Jiri Slaby , linux-kernel@vger.kernel.org, Paul Burton , Petar Jovanovic , Raghu Gandham Subject: [PATCH v2 7/7] tty: goldfish: Implement support for kernel 'earlycon' parameter Date: Wed, 28 Jun 2017 17:56:31 +0200 Message-Id: <1498665399-29007-8-git-send-email-aleksandar.markovic@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498665399-29007-1-git-send-email-aleksandar.markovic@rt-rk.com> References: <1498665399-29007-1-git-send-email-aleksandar.markovic@rt-rk.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2770 Lines: 96 From: Miodrag Dinic 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", "generic,goldfish-tty"; }; Signed-off-by: Miodrag Dinic Signed-off-by: Goran Ferenc Signed-off-by: Aleksandar Markovic --- drivers/tty/Kconfig | 3 +++ drivers/tty/goldfish.c | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/drivers/tty/Kconfig b/drivers/tty/Kconfig index 9510305..873e0ba 100644 --- a/drivers/tty/Kconfig +++ b/drivers/tty/Kconfig @@ -392,6 +392,9 @@ config PPC_EARLY_DEBUG_EHV_BC_HANDLE config GOLDFISH_TTY tristate "Goldfish TTY Driver" depends on GOLDFISH + select SERIAL_CORE + select SERIAL_CORE_CONSOLE + select SERIAL_EARLYCON help Console and system TTY driver for the Goldfish virtual platform. diff --git a/drivers/tty/goldfish.c b/drivers/tty/goldfish.c index acd50fa..22b7ad5 100644 --- a/drivers/tty/goldfish.c +++ b/drivers/tty/goldfish.c @@ -1,6 +1,7 @@ /* * Copyright (C) 2007 Google, Inc. * Copyright (C) 2012 Intel, Inc. + * Copyright (C) 2017 Imagination Technologies Ltd. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -24,6 +25,7 @@ #include #include #include +#include enum { GOLDFISH_TTY_PUT_CHAR = 0x00, @@ -427,6 +429,30 @@ static int goldfish_tty_remove(struct platform_device *pdev) return 0; } +static void gf_early_console_putchar(struct uart_port *port, int ch) +{ + __raw_writel(ch, port->membase); +} + +static void gf_early_write(struct console *con, const char *s, unsigned int n) +{ + struct earlycon_device *dev = con->data; + + uart_console_write(&dev->port, s, n, gf_early_console_putchar); +} + +static int __init gf_earlycon_setup(struct earlycon_device *device, + const char *opt) +{ + if (!device->port.membase) + return -ENODEV; + + device->con->write = gf_early_write; + return 0; +} + +OF_EARLYCON_DECLARE(early_gf_tty, "google,goldfish-tty", gf_earlycon_setup); + static const struct of_device_id goldfish_tty_of_match[] = { { .compatible = "google,goldfish-tty", }, {}, -- 2.7.4