From patchwork Mon Sep 22 13:14:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 37679 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4B9CF20C03 for ; Mon, 22 Sep 2014 13:14:31 +0000 (UTC) Received: by mail-lb0-f198.google.com with SMTP id 10sf3020811lbg.9 for ; Mon, 22 Sep 2014 06:14:30 -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=jbx/SMz4WKUmxbZbyB1fk3IxtBpaW5A7i/c1X+BHQDg=; b=YHdg8cdUZkJcgGtHJfDPcTXXybPbA9cViiWwBDcWAJYaZ0PsZuVcz+D5dcVQTKHMdH /uIZrnwq8sLmbDbx4TFW30irmiy7LwZWFARyKXQa4N/ePKz98LjWbUWHuLqNoDzT7GIh iizdGKtFxYR/XVxQ2nDqNtfXbetjZ3r/jb22qHVTsAYQh4yjCXUzqlwbgdUs5u/LtpiY iKC7zDv39TJNOCySqyrPmim8Xn7rhC4bNUS6favgWPh+fkejiHZtnojOnH/NUZuLLuaB E2A3/sDIQS87Lilock/ebg8LaWeErdmujDeJdMGWWd123vATRgTECC16hX7eAc4FaPCZ rxIQ== X-Gm-Message-State: ALoCoQmuwnakjcQ/mrQHoyTh7zpzDZp67TCXBQQPDMuft2+Zt7WEvHI7/upVteiQkWUsLVI7+7cl X-Received: by 10.112.190.102 with SMTP id gp6mr443382lbc.10.1411391670089; Mon, 22 Sep 2014 06:14:30 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.42.230 with SMTP id r6ls547661lal.92.gmail; Mon, 22 Sep 2014 06:14:29 -0700 (PDT) X-Received: by 10.152.7.145 with SMTP id j17mr2891693laa.77.1411391669762; Mon, 22 Sep 2014 06:14:29 -0700 (PDT) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com [209.85.215.54]) by mx.google.com with ESMTPS id a9si14471171lak.39.2014.09.22.06.14.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Sep 2014 06:14:29 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by mail-la0-f54.google.com with SMTP id ge10so6706056lab.13 for ; Mon, 22 Sep 2014 06:14:29 -0700 (PDT) X-Received: by 10.152.5.168 with SMTP id t8mr3220931lat.67.1411391669650; Mon, 22 Sep 2014 06:14:29 -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.130.169 with SMTP id of9csp231631lbb; Mon, 22 Sep 2014 06:14:26 -0700 (PDT) X-Received: by 10.66.102.105 with SMTP id fn9mr13781679pab.105.1411391665619; Mon, 22 Sep 2014 06:14:25 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id vx2si15698357pbc.67.2014.09.22.06.14.24 for ; Mon, 22 Sep 2014 06:14:25 -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 S1753834AbaIVNOY (ORCPT + 6 others); Mon, 22 Sep 2014 09:14:24 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:57041 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753934AbaIVNOX (ORCPT ); Mon, 22 Sep 2014 09:14:23 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NCB003F90WLJL30@mailout4.w1.samsung.com> for linux-samsung-soc@vger.kernel.org; Mon, 22 Sep 2014 14:17:09 +0100 (BST) X-AuditID: cbfec7f4-b7f156d0000063c7-fb-542020ad320f Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 38.27.25543.DA020245; Mon, 22 Sep 2014 14:14:21 +0100 (BST) Received: from amdc1339.digital.local ([106.116.147.30]) by eusync2.samsung.com (Oracle Communications Messaging Server 7u4-23.01 (7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0NCB0014U0RS8760@eusync2.samsung.com>; Mon, 22 Sep 2014 14:14:21 +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/RFC 1/2] serial: samsung: Add support for of_earlycon Date: Mon, 22 Sep 2014 15:14:14 +0200 Message-id: <1411391655-6291-2-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 In-reply-to: <1411391655-6291-1-git-send-email-m.szyprowski@samsung.com> References: <1411391655-6291-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrMJMWRmVeSWpSXmKPExsVy+t/xK7prFRRCDBa1CVg8mLeNzeJs0xt2 i02Pr7FazDi/j8li7ZG77Bbfv31js+hYxmixatcfRgcOj52z7rJ7bF5S79G3ZRWjx+dNcgEs UVw2Kak5mWWpRfp2CVwZf7ZkFKxQrPi0eBZjA+NmmS5GTg4JAROJ2fNmskDYYhIX7q1n62Lk 4hASWMoo0X3rByOE08ck8ajxFCNIFZuAoUTX2y42EFtEwFti8pm/7CBFzAIvgDqe/WIGSQgL uEqc3nqfHcRmEVCV2NR+DmwFr4C7xPvN76DWyUn8f7mCCcTmFPCQeP96DmsXIwfQNneJxX35 Exh5FzAyrGIUTS1NLihOSs811CtOzC0uzUvXS87P3cQICagvOxgXH7M6xCjAwajEw7ugST5E iDWxrLgy9xCjBAezkghvkLRCiBBvSmJlVWpRfnxRaU5q8SFGJg5OqQZGt6eHS+4Zy1ql1EY+ zLo0pS5oRWC+4t+ES2tZbFboz58kc194+7aDDxXY1tcxd2ztlg50NPAWfj2z/8ZMtguXK7lM WmqvXJ3PY3VdcJrfFq+5TW/Pt+9OUlKMdHdxXcAhKH9vSavla819zA/miJ+O0dR/uLw4c0NB kFXs5T0GiroH7S/ZfT6kxFKckWioxVxUnAgAZtj5XwYCAAA= 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.215.54 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 to all variants of Samsung serial driver. Signed-off-by: Tomasz Figa Signed-off-by: Marek Szyprowski --- drivers/tty/serial/Kconfig | 1 + drivers/tty/serial/samsung.c | 97 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 26cec64dadd7..e87a2dfd9080 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -222,6 +222,7 @@ config SERIAL_SAMSUNG tristate "Samsung SoC serial support" depends on PLAT_SAMSUNG 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..71829ce2410d 100644 --- a/drivers/tty/serial/samsung.c +++ b/drivers/tty/serial/samsung.c @@ -1856,6 +1856,103 @@ 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, S3C2412 */ +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); + +/* 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); + +/* 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); + MODULE_ALIAS("platform:samsung-uart"); MODULE_DESCRIPTION("Samsung SoC Serial port driver"); MODULE_AUTHOR("Ben Dooks ");