From patchwork Mon Sep 29 11:48:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 4995561 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 62524BEEA6 for ; Mon, 29 Sep 2014 11:53:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 78E8D2025B for ; Mon, 29 Sep 2014 11:53:47 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 926C4201CE for ; Mon, 29 Sep 2014 11:53:46 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XYZU1-0003ID-JY; Mon, 29 Sep 2014 11:51:13 +0000 Received: from mail-pa0-x229.google.com ([2607:f8b0:400e:c03::229]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XYZTa-0002gZ-BC for linux-arm-kernel@lists.infradead.org; Mon, 29 Sep 2014 11:50:47 +0000 Received: by mail-pa0-f41.google.com with SMTP id eu11so1996233pac.14 for ; Mon, 29 Sep 2014 04:50:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CDGgFHpkpd/NexwdDQVxoDuMmvZoM+p8aSI8T6qKPrA=; b=OfYlw1GNMP7A980yGfT+ZlRmVFoDP6p3KOy/fQHNKa4oF4WCEHNKbIbv9hbjoRPlrM xyTZaKIhF/wYfb25B5+O6WJQZJSY1Iy5JjS7UVE1B5Gq0GPDSc4+E/rL8SRrouAL+bAE rwFjLhlTIfddPwl5u9icC3Xi1iRCLYjfivBLf2rjZI/9ABLwxjNbk7wbsZ7v0w193g1z WDJTymo4U8QvEZXijFzzDhkifQ7MiGlXHNB2fXrlywZh5+972bxseTyXVF0/h+OvnZaH pm54FDdUQw0VvM+4RzFhBI8ASwpl7w4uAYcLI6ESxC3+KtyocsRjQPsmtguqWMnoFg4K UVWA== X-Received: by 10.66.233.201 with SMTP id ty9mr2451379pac.99.1411991425429; Mon, 29 Sep 2014 04:50:25 -0700 (PDT) Received: from chunyanzhangubtpc.local.spreadtrum.com ([106.37.8.227]) by mx.google.com with ESMTPSA id i13sm11631318pdm.93.2014.09.29.04.50.13 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 29 Sep 2014 04:50:24 -0700 (PDT) From: zhang.lyra@gmail.com To: catalin.marinas@arm.com, gregkh@linuxfoundation.org, ijc+devicetree@hellion.org.uk, jslaby@suse.cz, galak@codeaurora.org, broonie@linaro.org, mark.rutland@arm.com, m-karicheri2@ti.com, pawel.moll@arm.com, artagnon@gmail.com, rrichter@cavium.com, robh+dt@kernel.org, will.deacon@arm.com, orsonzhai@gmail.com, geng.ren@spreadtrum.com, zhizhou.zhang@spreadtrum.com Subject: [PATCH 5/6] tty/serial: Add Spreadtrum's serial earlycon Date: Mon, 29 Sep 2014 19:48:33 +0800 Message-Id: <1411991314-6636-6-git-send-email-zhang.lyra@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1411991314-6636-1-git-send-email-zhang.lyra@gmail.com> References: <1411991314-6636-1-git-send-email-zhang.lyra@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140929_045046_447289_C388A5C9 X-CRM114-Status: GOOD ( 16.55 ) X-Spam-Score: -0.1 (/) Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "chunyan.zhang" Adds earlycon support for the Spreadtrum's serial. Signed-off-by: chunyan.zhang --- drivers/tty/serial/Kconfig | 12 ++++++ drivers/tty/serial/Makefile | 1 + drivers/tty/serial/serial_sprd_early.c | 64 ++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 drivers/tty/serial/serial_sprd_early.c diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 26cec64..ede16e6 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -85,6 +85,18 @@ config SERIAL_EARLYCON_ARM_SEMIHOST with "earlycon=smh" on the kernel command line. The console is enabled when early_param is processed. +config SERIAL_EARLYCON_SPRD + bool "Early console using SPRD serial" + depends on ARM64 + select SERIAL_CORE + select SERIAL_CORE_CONSOLE + select SERIAL_EARLYCON + help + Support for early debug console using SPRD serial. This enables + the console before standard serial driver is probed. This is enabled + with "earlycon=serial_sprd" on the kernel command line. The console is + enabled when early_param is processed. + config SERIAL_SB1250_DUART tristate "BCM1xxx on-chip DUART serial support" depends on SIBYTE_SB1xxx_SOC=y diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile index 0080cc3..3ea9edc 100644 --- a/drivers/tty/serial/Makefile +++ b/drivers/tty/serial/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_SERIAL_21285) += 21285.o obj-$(CONFIG_SERIAL_EARLYCON) += earlycon.o obj-$(CONFIG_SERIAL_EARLYCON_ARM_SEMIHOST) += earlycon-arm-semihost.o +obj-$(CONFIG_SERIAL_EARLYCON_SPRD) += serial_sprd_early.o # These Sparc drivers have to appear before others such as 8250 # which share ttySx minor node space. Otherwise console device diff --git a/drivers/tty/serial/serial_sprd_early.c b/drivers/tty/serial/serial_sprd_early.c new file mode 100644 index 0000000..059e109 --- /dev/null +++ b/drivers/tty/serial/serial_sprd_early.c @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2012 Spreadtrum Communications Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include + +/*offset*/ +#define ARM_UART_TXD 0x0000 +#define ARM_UART_RXD 0x0004 +#define ARM_UART_STS0 0x0008 +#define ARM_UART_STS1 0x000C +#define ARM_UART_IEN 0x0010 +#define ARM_UART_ICLR 0x0014 +#define ARM_UART_CTL0 0x0018 +#define ARM_UART_CTL1 0x001C +#define ARM_UART_CTL2 0x0020 +#define ARM_UART_CLKD0 0x0024 +#define ARM_UART_CLKD1 0x0028 +#define ARM_UART_STS2 0x002C + +/*line status */ +#define UART_LSR_TX_OVER (0x1<<15) + +static void serial_sprd_putc(struct uart_port *port, int c) +{ + while (!(readl(port->membase + ARM_UART_STS0) & UART_LSR_TX_OVER)) + ; + writeb(c, port->membase + ARM_UART_TXD); +} + +static void serial_sprd_early_write(struct console *con, const char *s, + unsigned n) +{ + struct earlycon_device *dev = con->data; + + uart_console_write(&dev->port, s, n, serial_sprd_putc); +} + +static int __init serial_sprd_early_console_setup( + struct earlycon_device *device, + const char *opt) +{ + if (!device->port.membase) + return -ENODEV; + + device->con->write = serial_sprd_early_write; + return 0; +} +EARLYCON_DECLARE(serial_sprd, serial_sprd_early_console_setup); +OF_EARLYCON_DECLARE(serial_sprd, "sprd,serial", + serial_sprd_early_console_setup);