From patchwork Mon Sep 29 12:04:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 4995751 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D27959F1D4 for ; Mon, 29 Sep 2014 12:08:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A9B98201B4 for ; Mon, 29 Sep 2014 12:08:37 +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 53CFD201B9 for ; Mon, 29 Sep 2014 12:08:36 +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 1XYZiq-0006IG-BV; Mon, 29 Sep 2014 12:06:32 +0000 Received: from mail-pd0-x22b.google.com ([2607:f8b0:400e:c02::22b]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XYZiU-0005s3-63 for linux-arm-kernel@lists.infradead.org; Mon, 29 Sep 2014 12:06:11 +0000 Received: by mail-pd0-f171.google.com with SMTP id ft15so1421238pdb.30 for ; Mon, 29 Sep 2014 05:05:49 -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=YstqOeBI6rNIoEWaUA3hGzyjI1LR79/YpAGPxwGhQv7Qu55h1FQ4NuMAmyP4yigN1k 6FAxPlNJGTEHRFhTe80/Gi+G9xB5YFC4+L0fLiAik37LRe/wTHk2+3T0GHT+Ws2pvneZ gmlZXthVZjMwx0TjX2HZPtf6hkAV90S5M4dvHKIQmCm6mPO8cH9x6CiUDyCG9QCkkVkd 94AagZ6992xfou4eP+0uh7lcak1aY3ekiTB8ks+AeJt1ReLolQRuzNxNRRK1KvU5CIpC YsNUZlSLhjVHaItWQ3V/DcbZPRBTO/wfKj648k/3vr8WSrRl7MUOkJJ/tqymzzI8krg8 XG1Q== X-Received: by 10.66.222.97 with SMTP id ql1mr58974502pac.119.1411992349334; Mon, 29 Sep 2014 05:05:49 -0700 (PDT) Received: from chunyanzhangubtpc.local.spreadtrum.com ([117.136.0.134]) by mx.google.com with ESMTPSA id nj3sm12181967pdb.70.2014.09.29.05.05.43 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 29 Sep 2014 05:05:48 -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 20:04:52 +0800 Message-Id: <1411992293-7729-6-git-send-email-zhang.lyra@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1411992293-7729-1-git-send-email-zhang.lyra@gmail.com> References: <1411992293-7729-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_050610_270645_9F73BB1F X-CRM114-Status: GOOD ( 16.55 ) X-Spam-Score: -0.8 (/) 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);