linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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
Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	"chunyan.zhang" <chunyan.zhang@spreadtrum.com>
Subject: [PATCH 5/6] tty/serial: Add Spreadtrum's serial earlycon
Date: Mon, 29 Sep 2014 19:48:33 +0800	[thread overview]
Message-ID: <1411991314-6636-6-git-send-email-zhang.lyra@gmail.com> (raw)
In-Reply-To: <1411991314-6636-1-git-send-email-zhang.lyra@gmail.com>

From: "chunyan.zhang" <chunyan.zhang@spreadtrum.com>

Adds earlycon support for the Spreadtrum's serial.

Signed-off-by: chunyan.zhang <chunyan.zhang@spreadtrum.com>
---
 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 <linux/kernel.h>
+#include <linux/console.h>
+#include <linux/init.h>
+#include <linux/serial_core.h>
+#include <linux/of.h>
+
+/*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);
-- 
1.7.9.5


  parent reply	other threads:[~2014-09-29 11:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-29 11:48 [PATCH 0/6] Add Spreadtrum Shark64 SoC support zhang.lyra
2014-09-29 11:48 ` [PATCH 1/6] Documentation: DT: Add bindings for Spreadtrum serial zhang.lyra
2014-09-29 11:48 ` [PATCH 2/6] arm64: Add DTS support for Spreadtrum's Shark64 SoC zhang.lyra
2014-09-29 14:55   ` Andreas Färber
2014-09-29 11:48 ` [PATCH 3/6] arm64: dts/Makefile: Add " zhang.lyra
2014-09-29 14:46   ` Andreas Färber
2014-09-29 11:48 ` [PATCH 4/6] arm64: Add support for Spreadtrum's Shark64 SoC in Kconfig and defconfig zhang.lyra
2014-09-29 11:48 ` zhang.lyra [this message]
2014-09-29 11:48 ` [PATCH 6/6] Documentation: Add entry for Spreadtrum's Shark64 SoC zhang.lyra
2014-09-29 12:04 [PATCH 0/6] Add Spreadtrum Shark64 SoC support zhang.lyra
2014-09-29 12:04 ` [PATCH 5/6] tty/serial: Add Spreadtrum's serial earlycon zhang.lyra
2014-09-29 13:36   ` Arnd Bergmann
2014-10-01 13:55     ` Rob Herring
2014-09-29 14:53   ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1411991314-6636-6-git-send-email-zhang.lyra@gmail.com \
    --to=zhang.lyra@gmail.com \
    --cc=artagnon@gmail.com \
    --cc=broonie@linaro.org \
    --cc=catalin.marinas@arm.com \
    --cc=chunyan.zhang@spreadtrum.com \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=geng.ren@spreadtrum.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=jslaby@suse.cz \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m-karicheri2@ti.com \
    --cc=mark.rutland@arm.com \
    --cc=orsonzhai@gmail.com \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=rrichter@cavium.com \
    --cc=will.deacon@arm.com \
    --cc=zhizhou.zhang@spreadtrum.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).