From patchwork Tue Dec 20 00:23:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishanth Menon X-Patchwork-Id: 88529 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp1454211qgi; Mon, 19 Dec 2016 16:25:45 -0800 (PST) X-Received: by 10.157.4.66 with SMTP id 60mr10202563otc.205.1482193545382; Mon, 19 Dec 2016 16:25:45 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id v5si9974346oib.55.2016.12.19.16.25.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Dec 2016 16:25:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=ti.com Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cJ8E0-0000em-3Q; Tue, 20 Dec 2016 00:24:12 +0000 Received: from fllnx209.ext.ti.com ([198.47.19.16]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cJ8Dt-0000PS-1X for linux-arm-kernel@lists.infradead.org; Tue, 20 Dec 2016 00:24:06 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id uBK0Nemk018683; Mon, 19 Dec 2016 18:23:40 -0600 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id uBK0NeGj005543; Mon, 19 Dec 2016 18:23:40 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.294.0; Mon, 19 Dec 2016 18:23:39 -0600 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id uBK0NdhX027653; Mon, 19 Dec 2016 18:23:39 -0600 From: Nishanth Menon To: Jiri Slaby Subject: [PATCH] tty: hvc_dcc: Add basic early_con support Date: Mon, 19 Dec 2016 18:23:36 -0600 Message-ID: <20161220002336.28733-1-nm@ti.com> X-Mailer: git-send-email 2.11.0.65.geff96d7 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161219_162405_214155_E7B7B1AE X-CRM114-Status: UNSURE ( 8.29 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -3.3 (---) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-3.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -1.4 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nishanth Menon , Greg Kroah-Hartman , Timur Tabi , linux-kernel@vger.kernel.org, Christopher Covington , linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org In some cases, earlycon can help catch errors with kernel boot prior to standard console is available. Example bootargs: console=hvc0 earlycon=hvcdcc Signed-off-by: Nishanth Menon --- Based on: v4.9 tag Also applies on: next-20161219 Tested on Simulation environment (which did not have serial console option) drivers/tty/hvc/hvc_dcc.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) -- 2.11.0.65.geff96d7 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/drivers/tty/hvc/hvc_dcc.c b/drivers/tty/hvc/hvc_dcc.c index 82f240fb98f0..1ec06e550656 100644 --- a/drivers/tty/hvc/hvc_dcc.c +++ b/drivers/tty/hvc/hvc_dcc.c @@ -10,7 +10,9 @@ * GNU General Public License for more details. */ +#include #include +#include #include #include @@ -94,3 +96,45 @@ static int __init hvc_dcc_init(void) return PTR_ERR_OR_ZERO(p); } device_initcall(hvc_dcc_init); + +static int hvc_dcc_earlyputc(int c) +{ + unsigned long count = 0xFFFFFFFF; + static bool dead_dcc_earlycon; + + if (dead_dcc_earlycon) + return -EBUSY; + + while (count--) { + if (!(__dcc_getstatus() & DCC_STATUS_TX)) + break; + } + if (!count) { + dead_dcc_earlycon = true; + return -EBUSY; + } + __dcc_putchar(c); + return 0; +} + +static void hvc_dcc_earlywrite(struct console *con, const char *s, + unsigned int n) +{ + int r; + + while (n--) { + r = hvc_dcc_earlyputc(*s); + if (r) + break; + s++; + } +} + +static int +__init early_hvc_dcc_setup(struct earlycon_device *device, const char *opt) +{ + device->con->write = hvc_dcc_earlywrite; + return 0; +} + +EARLYCON_DECLARE(hvcdcc, early_hvc_dcc_setup);