From patchwork Fri Apr 26 11:04:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: PranavkumarSawargaonkar X-Patchwork-Id: 16420 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f199.google.com (mail-ve0-f199.google.com [209.85.128.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C23B12397A for ; Fri, 26 Apr 2013 11:07:52 +0000 (UTC) Received: by mail-ve0-f199.google.com with SMTP id m1sf3466689ves.10 for ; Fri, 26 Apr 2013 04:06:57 -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=nEqZXG2Fgn6ID7W5SuduHpY9aX8wv7ELAmpqrRE3NWo=; b=Oa+20EwE/8/lOzd2ZtOD+NUL26rAJ2CltVOpQzNhJvTmlV5DokbFtn9NLsvNj+ZkfL oUdKwIdOh3txmzcgVafTU9St1pvDWb04vLuhn1MMdhEx4WGpGWj64y4XZig0P2nhjI9L UvFZfcZzUFdwzLFYB/d/Lth3KbcNJk95B9iNAKFdmSRn6df7y4B0VEGkduJjaxHIYXGU hCop6yMJ6+kjRIhGX8GbohZTVfKNK0wxgZBGAd84YK8B8IOelGQOCF5RrQNfRGvUSIAX jTG63JFY18BN0tPhlszLGz+aONX59t3gkhGrklHR4YuIPrkXmWMC7k5EWmHjKCCAycR0 jWbw== X-Received: by 10.236.160.1 with SMTP id t1mr9492450yhk.54.1366974417282; Fri, 26 Apr 2013 04:06:57 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.0.163 with SMTP id 3ls1824999qef.58.gmail; Fri, 26 Apr 2013 04:06:57 -0700 (PDT) X-Received: by 10.52.231.231 with SMTP id tj7mr24602984vdc.111.1366974417087; Fri, 26 Apr 2013 04:06:57 -0700 (PDT) Received: from mail-vb0-x229.google.com (mail-vb0-x229.google.com [2607:f8b0:400c:c02::229]) by mx.google.com with ESMTPS id sa4si5148242vdc.101.2013.04.26.04.06.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 26 Apr 2013 04:06:57 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::229 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c02::229; Received: by mail-vb0-f41.google.com with SMTP id f12so1499326vbg.28 for ; Fri, 26 Apr 2013 04:06:57 -0700 (PDT) X-Received: by 10.58.181.201 with SMTP id dy9mr28983766vec.34.1366974416904; Fri, 26 Apr 2013 04:06:56 -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 nf2csp63328veb; Fri, 26 Apr 2013 04:06:56 -0700 (PDT) X-Received: by 10.66.41.11 with SMTP id b11mr47546440pal.183.1366974415984; Fri, 26 Apr 2013 04:06:55 -0700 (PDT) Received: from mail-da0-x234.google.com (mail-da0-x234.google.com [2607:f8b0:400e:c00::234]) by mx.google.com with ESMTPS id ie4si10138317pbc.329.2013.04.26.04.06.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 26 Apr 2013 04:06:55 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400e:c00::234 is neither permitted nor denied by best guess record for domain of pranavkumar@linaro.org) client-ip=2607:f8b0:400e:c00::234; Received: by mail-da0-f52.google.com with SMTP id j17so1888942dan.11 for ; Fri, 26 Apr 2013 04:06:55 -0700 (PDT) X-Received: by 10.66.220.197 with SMTP id py5mr30504025pac.86.1366974415579; Fri, 26 Apr 2013 04:06:55 -0700 (PDT) Received: from pnqlab006.amcc.com ([182.72.18.82]) by mx.google.com with ESMTPSA id l4sm11310280pbo.6.2013.04.26.04.06.52 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 26 Apr 2013 04:06:55 -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, Pranavkumar Sawargaonkar Subject: [PATCH 2/2] arm64: earlyprintk support for virtio-mmio console Date: Fri, 26 Apr 2013 16:34:56 +0530 Message-Id: <1366974299-17877-3-git-send-email-pranavkumar@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1366974299-17877-1-git-send-email-pranavkumar@linaro.org> References: <1366974299-17877-1-git-send-email-pranavkumar@linaro.org> X-Gm-Message-State: ALoCoQmcIh1L7m66og73rDODhewmF23el0PlZrMkBdpl6oFJDAwUVBUwEc1/lLZAVyKlUDWDvv65 X-Original-Sender: pranavkumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::229 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 early_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..52ac6b0 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_EARLY_WRITE))) { + init_done = 1; + return; + } + + init_done = 1; + can_write = 1; + } + + if (can_write) + writeb_relaxed(ch, &p->early_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, }, {} };