From patchwork Mon May 6 12:19:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: PranavkumarSawargaonkar X-Patchwork-Id: 2523911 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id 080D7DF230 for ; Mon, 6 May 2013 12:22:51 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UZKQc-0005IL-Sq; Mon, 06 May 2013 12:22:03 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UZKQB-0003Nb-E4; Mon, 06 May 2013 12:21:35 +0000 Received: from mail-da0-x22e.google.com ([2607:f8b0:400e:c00::22e]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UZKQ1-0003IF-SG for linux-arm-kernel@lists.infradead.org; Mon, 06 May 2013 12:21:27 +0000 Received: by mail-da0-f46.google.com with SMTP id e20so1813590dak.19 for ; Mon, 06 May 2013 05:21:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=MjQJ21mcaFaUQK17PTwSJSAzGQjk3aF5EdzAjc4mNGI=; b=EYr6ihSZVkK3+83U0DqPSQnHzgOd5S9QG8ATiTsMj3hhDtkOL3ZuzghKX0YJ709we3 udP+vs7p+n2a+U34o+xjbeDvRSC2i9rnvBF46SrsxPgB0PU3T81wXYgU+khAr056RqFw xUOni+RX4YiKqscq0eJP/FW4U22MiuugPvEaUOC8mjCzOo5fa1cubtzU1rxd3gYE1FkY LmzM9uCQjDEB3mLTh1FOi19XpUhodtlrcqbmOWB9ylwoC8PQU0DmCzsEzzONzSOZlp5z B4SGhRcmDagF1sKlqu+35nN2ZPzZQ0AAGyYeKM/FjBTiGIzlCNXUEe4XYfyLMGruSF74 TQAw== X-Received: by 10.68.20.74 with SMTP id l10mr25862018pbe.150.1367842863341; Mon, 06 May 2013 05:21:03 -0700 (PDT) Received: from pnqlab006.amcc.com ([182.72.18.82]) by mx.google.com with ESMTPSA id zy5sm23689902pbb.43.2013.05.06.05.21.00 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 06 May 2013 05:21:02 -0700 (PDT) From: Pranavkumar Sawargaonkar To: linux-arm-kernel@lists.infradead.org Subject: [PATCH V2 3/3] arm64: earlyprintk support for virtio-mmio console. Date: Mon, 6 May 2013 17:49:51 +0530 Message-Id: <1367842791-30285-4-git-send-email-pranavkumar@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1367842791-30285-1-git-send-email-pranavkumar@linaro.org> References: <1367842791-30285-1-git-send-email-pranavkumar@linaro.org> X-Gm-Message-State: ALoCoQnb1BqLWGlbUsjWxOtetCVumRVyfn80PjyisYXBQIrXpRZRzzT9b08waICfj+oPKeEeoToS X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130506_082126_049842_4FFBDF0E X-CRM114-Status: GOOD ( 12.82 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linaro-kernel@lists.linaro.org, anup.patel@linaro.org, patches@linaro.org, rusty@rustcorp.com.au, linux-kernel@vger.kernel.org, amit.shah@redhat.com, kvmarm@lists.cs.columbia.edu, Pranavkumar Sawargaonkar X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 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 This patch implements earlyprintk based on virtio console using emerg_wr config register. Kernel args for using this will be: earlyprintk=virtio-console, Signed-off-by: Pranavkumar Sawargaonkar Signed-off-by: Anup Patel --- arch/arm64/kernel/early_printk.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/arch/arm64/kernel/early_printk.c b/arch/arm64/kernel/early_printk.c index ac974f4..ea3d2f5 100644 --- a/arch/arm64/kernel/early_printk.c +++ b/arch/arm64/kernel/early_printk.c @@ -25,6 +25,9 @@ #include #include +#include +#include +#include static void __iomem *early_base; static void (*printch)(char ch); @@ -53,6 +56,37 @@ static void smh_printch(char ch) } /* + * VIRTIO MMIO console single character Tx. + */ +static void virtio_console_printch(char ch) +{ + u32 tmp; + static u32 init_done; + static u32 can_write; + struct virtio_console_config *p = early_base + VIRTIO_MMIO_CONFIG; + + if (!init_done) { + tmp = readl_relaxed(early_base + VIRTIO_MMIO_DEVICE_ID); + if (tmp != VIRTIO_ID_CONSOLE) { + init_done = 1; + return; + } + + tmp = readl_relaxed(early_base + VIRTIO_MMIO_HOST_FEATURES); + if (!(tmp & (1 << VIRTIO_CONSOLE_F_EMERG_WRITE))) { + init_done = 1; + return; + } + + init_done = 1; + can_write = 1; + } + + if (can_write) + writeb_relaxed(ch, &p->emerg_wr); +} + +/* * 8250/16550 (8-bit aligned registers) single character TX. */ static void uart8250_8bit_printch(char ch) @@ -82,6 +116,7 @@ static const struct earlycon_match earlycon_match[] __initconst = { { .name = "smh", .printch = smh_printch, }, { .name = "uart8250-8bit", .printch = uart8250_8bit_printch, }, { .name = "uart8250-32bit", .printch = uart8250_32bit_printch, }, + { .name = "virtio-console", .printch = virtio_console_printch, }, {} };