From patchwork Mon Oct 20 11:28:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 39045 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 72F64203C5 for ; Mon, 20 Oct 2014 11:28:49 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id hi2sf2435922wib.9 for ; Mon, 20 Oct 2014 04:28:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=Ct9jl0lFzdRp6sppPpkVnehf3ExQQ6m9C1nHjKfMWuw=; b=LjoUZjtfU/rDB5JbJDMm+RdYvqx9/NP2kXiK24SzwNJWad7+gS709MZ+7me3gAXeU5 IzF4nrfZZ9kPcLFMDfQ0LQfx1/mJldx9h3HooFTYSVRZkbKxMfBHM+LtoEGmT2HATEjb qIjW3zm33MgenCdwzJrlegIMr5I0tcCFBNM31O3kBXJZvSXGcEi9W4IjIP0c0QdzXqEq bzgn6z/eKcSocKl2SqSeEeAsgaXDdcV8DtK4mJtI5aH0VmMeyAqMiUV4THhkqKrfCy9e /o25CCDwiX9c7jr8mi72nMlXqoPiJ8aa0RlLJ55978jwUPNzEtcOMtH706zvjlBeAto3 g4lQ== X-Gm-Message-State: ALoCoQmKbtuOy5j0NORar6oLLPT7AVQfdXH/HlkJyIY97WT6A+ogZtte+B6rQ/c/xbWnkEkftsZp X-Received: by 10.181.27.135 with SMTP id jg7mr2365921wid.5.1413804528614; Mon, 20 Oct 2014 04:28:48 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.41 with SMTP id q9ls382290lag.67.gmail; Mon, 20 Oct 2014 04:28:48 -0700 (PDT) X-Received: by 10.152.206.11 with SMTP id lk11mr27217656lac.42.1413804528451; Mon, 20 Oct 2014 04:28:48 -0700 (PDT) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com. [209.85.217.170]) by mx.google.com with ESMTPS id qr5si7548869lbb.54.2014.10.20.04.28.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 Oct 2014 04:28:48 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) client-ip=209.85.217.170; Received: by mail-lb0-f170.google.com with SMTP id u10so3705523lbd.29 for ; Mon, 20 Oct 2014 04:28:48 -0700 (PDT) X-Received: by 10.112.97.135 with SMTP id ea7mr26913785lbb.46.1413804528316; Mon, 20 Oct 2014 04:28:48 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp284269lbz; Mon, 20 Oct 2014 04:28:47 -0700 (PDT) X-Received: by 10.70.100.229 with SMTP id fb5mr2929350pdb.126.1413804524959; Mon, 20 Oct 2014 04:28:44 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wv1si7472665pab.224.2014.10.20.04.28.44 for ; Mon, 20 Oct 2014 04:28:44 -0700 (PDT) Received-SPF: none (google.com: linux-samsung-soc-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753493AbaJTL2n (ORCPT + 6 others); Mon, 20 Oct 2014 07:28:43 -0400 Received: from mailout3.w1.samsung.com ([210.118.77.13]:53262 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753217AbaJTL2n (ORCPT ); Mon, 20 Oct 2014 07:28:43 -0400 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NDQ00JZ8QOJC820@mailout3.w1.samsung.com> for linux-samsung-soc@vger.kernel.org; Mon, 20 Oct 2014 12:31:31 +0100 (BST) X-AuditID: cbfec7f5-b7f956d000005ed7-3e-5444f1e7a20f Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id D3.AA.24279.7E1F4445; Mon, 20 Oct 2014 12:28:39 +0100 (BST) Received: from amdc1339.digital.local ([106.116.147.30]) by eusync3.samsung.com (Oracle Communications Messaging Server 7u4-23.01 (7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0NDQ00J30QJKF930@eusync3.samsung.com>; Mon, 20 Oct 2014 12:28:39 +0100 (BST) From: Marek Szyprowski To: linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Marek Szyprowski , Alim Akhtar , thomas.ab@samsung.com, Tomasz Figa , Kyungmin Park , Rob Herring Subject: [PATCH v3 1/2] serial: samsung: Add support for early console Date: Mon, 20 Oct 2014 13:28:30 +0200 Message-id: <1413804511-32441-2-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 In-reply-to: <1413804511-32441-1-git-send-email-m.szyprowski@samsung.com> References: <1413804511-32441-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrCJMWRmVeSWpSXmKPExsVy+t/xq7rPP7qEGEzeaGTxYN42NouzTW/Y LTY9vsZqMeP8PiaLtUfuslt8//aNzaJjGaPFql1/GB04PHbOusvusXlJvUffllWMHp83yQWw RHHZpKTmZJalFunbJXBlPHi4i7mgXbfi/NFJjA2Mq9W6GDk5JARMJP7/+cEMYYtJXLi3nq2L kYtDSGApo8TxdfMYQRJCAn1MEj+u6YLYbAKGEl1vu9hAbBEBb4nJZ/6ygzQwC7xglOh+9gts krCAm0T74ptgNouAqsSzyw2sIDavgIfE5ZMTGSG2yUn8f7mCCcTmFPCU2Ll1ERPEMg+J/gMv 2SYw8i5gZFjFKJpamlxQnJSea6RXnJhbXJqXrpecn7uJERJSX3cwLj1mdYhRgINRiYd3h5lL iBBrYllxZe4hRgkOZiURXoc3QCHelMTKqtSi/Pii0pzU4kOMTBycUg2Mh4KWrxPduaU389nz vR/2cnI89u3gb53xYtbseIaFRy7fbtq5+bzhBSFVrhvnf21XaH6XeNn5A6fsuSub3Xr1Oa2+ zPiyl/1Co6G6advtxfvvt2R83r1Q6/hFcZ4gwyP/wiafuBLGwHjkeuiSosMTVuVL5fqsnBvX fHTH1q4S7ZClHy6c9j91gUOJpTgj0VCLuag4EQD2iCKlBwIAAA== Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: m.szyprowski@samsung.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Tomasz Figa This patch adds support for early console initialized from device tree and kernel command line to all variants of Samsung serial driver. Signed-off-by: Tomasz Figa [mszyprow: added support for command line based initialization, fixed comments, added documentation] Signed-off-by: Marek Szyprowski Reviewed-by: Alim Akhtar Tested-by: Alim Akhtar --- Documentation/kernel-parameters.txt | 12 +++++ drivers/tty/serial/Kconfig | 1 + drivers/tty/serial/samsung.c | 103 ++++++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+) diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 7dbe5ec9d9cd..24f363108ab3 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -961,6 +961,18 @@ bytes respectively. Such letter suffixes can also be entirely omitted. smh Use ARM semihosting calls for early console. + s3c2410, + s3c2412, + s3c2440, + s3c6400, + s5pv210, + exynos4210, + Use early console provided by serial driver available + on Samsung SoCs, requires selecting proper type and + a correct base address of the selected UART port. The + serial port must already be setup and configured. + Options are not yet supported. + earlyprintk= [X86,SH,BLACKFIN,ARM,M68k] earlyprintk=vga earlyprintk=efi diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 649b784081c7..50997be6cf6d 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -241,6 +241,7 @@ config SERIAL_SAMSUNG tristate "Samsung SoC serial support" depends on PLAT_SAMSUNG || ARCH_EXYNOS select SERIAL_CORE + select SERIAL_EARLYCON help Support for the on-chip UARTs on the Samsung S3C24XX series CPUs, providing /dev/ttySAC0, 1 and 2 (note, some machines may not diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c index c78f43a481ce..8ad453a5d845 100644 --- a/drivers/tty/serial/samsung.c +++ b/drivers/tty/serial/samsung.c @@ -1856,6 +1856,109 @@ static struct platform_driver samsung_serial_driver = { module_platform_driver(samsung_serial_driver); +/* + * Early console. + */ + +struct samsung_early_console_data { + u32 txfull_mask; +}; + +static void samsung_early_busyuart(struct uart_port *port) +{ + while (!(readl(port->membase + S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXFE)) + ; +} + +static void samsung_early_busyuart_fifo(struct uart_port *port) +{ + struct samsung_early_console_data *data = port->private_data; + + while (readl(port->membase + S3C2410_UFSTAT) & data->txfull_mask) + ; +} + +static void samsung_early_putc(struct uart_port *port, int c) +{ + if (readl(port->membase + S3C2410_UFCON) & S3C2410_UFCON_FIFOMODE) + samsung_early_busyuart_fifo(port); + else + samsung_early_busyuart(port); + + writeb(c, port->membase + S3C2410_UTXH); +} + +static void samsung_early_write(struct console *con, const char *s, unsigned n) +{ + struct earlycon_device *dev = con->data; + + uart_console_write(&dev->port, s, n, samsung_early_putc); +} + +static int __init samsung_early_console_setup(struct earlycon_device *device, + const char *opt) +{ + if (!device->port.membase) + return -ENODEV; + + device->con->write = samsung_early_write; + return 0; +} + +/* S3C2410 */ +static struct samsung_early_console_data s3c2410_early_console_data = { + .txfull_mask = S3C2410_UFSTAT_TXFULL, +}; + +static int __init s3c2410_early_console_setup(struct earlycon_device *device, + const char *opt) +{ + device->port.private_data = &s3c2410_early_console_data; + return samsung_early_console_setup(device, opt); +} +OF_EARLYCON_DECLARE(s3c2410, "samsung,s3c2410-uart", + s3c2410_early_console_setup); +EARLYCON_DECLARE(s3c2410, s3c2410_early_console_setup); + +/* S3C2412, S3C2440, S3C64xx */ +static struct samsung_early_console_data s3c2440_early_console_data = { + .txfull_mask = S3C2440_UFSTAT_TXFULL, +}; + +static int __init s3c2440_early_console_setup(struct earlycon_device *device, + const char *opt) +{ + device->port.private_data = &s3c2440_early_console_data; + return samsung_early_console_setup(device, opt); +} +OF_EARLYCON_DECLARE(s3c2412, "samsung,s3c2412-uart", + s3c2440_early_console_setup); +OF_EARLYCON_DECLARE(s3c2440, "samsung,s3c2440-uart", + s3c2440_early_console_setup); +OF_EARLYCON_DECLARE(s3c6400, "samsung,s3c6400-uart", + s3c2440_early_console_setup); +EARLYCON_DECLARE(s3c2412, s3c2440_early_console_setup); +EARLYCON_DECLARE(s3c2440, s3c2440_early_console_setup); +EARLYCON_DECLARE(s3c6400, s3c2440_early_console_setup); + +/* S5PV210, EXYNOS */ +static struct samsung_early_console_data s5pv210_early_console_data = { + .txfull_mask = S5PV210_UFSTAT_TXFULL, +}; + +static int __init s5pv210_early_console_setup(struct earlycon_device *device, + const char *opt) +{ + device->port.private_data = &s5pv210_early_console_data; + return samsung_early_console_setup(device, opt); +} +OF_EARLYCON_DECLARE(s5pv210, "samsung,s5pv210-uart", + s5pv210_early_console_setup); +OF_EARLYCON_DECLARE(exynos4210, "samsung,exynos4210-uart", + s5pv210_early_console_setup); +EARLYCON_DECLARE(s5pv210, s5pv210_early_console_setup); +EARLYCON_DECLARE(exynos4210, s5pv210_early_console_setup); + MODULE_ALIAS("platform:samsung-uart"); MODULE_DESCRIPTION("Samsung SoC Serial port driver"); MODULE_AUTHOR("Ben Dooks ");