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: 16717 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ye0-f197.google.com (mail-ye0-f197.google.com [209.85.213.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6856D20F2F for ; Mon, 6 May 2013 12:21:22 +0000 (UTC) Received: by mail-ye0-f197.google.com with SMTP id q11sf5856372yen.4 for ; Mon, 06 May 2013 05:21:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=MjQJ21mcaFaUQK17PTwSJSAzGQjk3aF5EdzAjc4mNGI=; b=QbXHqabJtyfCQ5kpuVZd+mbuJiH9QlyjmHcRQwmTIWAU0HLWQujHVmOvgu9ZAwiXv8 KehDqmKQhGc2lPfrt04ZFTvUluVcEXcubYlL43COXazndX9KLN7zXXTK3euwXy8nKbaA /OHpimsYQBaGyt9PHNWn5CJRq9YC3gwVuInXVmit81t1ki7FPT7czE0pWm+nvozlGf3Q oRnG7CDtw0y7glofbizu39JSfJaEVDwrIogDNH+jWuSbJkoGppCewt8DyTGXk3aG2Gtj 0i18uCU8Hp7czg8UwjNLRRjfGtnxhm1Ye8TjT0HZlJyVllazhordKqpYQwxoyZEK0D9F 1rGA== X-Received: by 10.59.2.42 with SMTP id bl10mr18218009ved.29.1367842865610; Mon, 06 May 2013 05:21:05 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.37.33 with SMTP id v1ls2775839qej.76.gmail; Mon, 06 May 2013 05:21:05 -0700 (PDT) X-Received: by 10.52.103.50 with SMTP id ft18mr5652118vdb.108.1367842865437; Mon, 06 May 2013 05:21:05 -0700 (PDT) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id sc6si9732378vdc.47.2013.05.06.05.21.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 06 May 2013 05:21:05 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.173; Received: by mail-vc0-f173.google.com with SMTP id ht11so3008220vcb.32 for ; Mon, 06 May 2013 05:21:05 -0700 (PDT) X-Received: by 10.220.189.9 with SMTP id dc9mr6647046vcb.8.1367842865310; Mon, 06 May 2013 05:21:05 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.127.98 with SMTP id nf2csp45196veb; Mon, 6 May 2013 05:21:04 -0700 (PDT) X-Received: by 10.68.35.138 with SMTP id h10mr14222965pbj.49.1367842864210; Mon, 06 May 2013 05:21:04 -0700 (PDT) Received: from mail-da0-x236.google.com (mail-da0-x236.google.com [2607:f8b0:400e:c00::236]) by mx.google.com with ESMTPS id ra8si15398669pab.62.2013.05.06.05.21.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 06 May 2013 05:21:04 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400e:c00::236 is neither permitted nor denied by best guess record for domain of pranavkumar@linaro.org) client-ip=2607:f8b0:400e:c00::236; Received: by mail-da0-f54.google.com with SMTP id u36so1810480dak.13 for ; Mon, 06 May 2013 05:21:03 -0700 (PDT) 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 Cc: kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, rusty@rustcorp.com.au, linaro-kernel@lists.linaro.org, patches@linaro.org, anup.patel@linaro.org, amit.shah@redhat.com, Pranavkumar Sawargaonkar 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: ALoCoQnHR4bJ7qWyfcwCkQywmI6RBW7WpLwZ+qKjPoRH9B+dVQ6f6CXY2DryeUEf4LaIhY2v9Rdy X-Original-Sender: pranavkumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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, }, {} };