Received: by 10.223.164.202 with SMTP id h10csp1194207wrb; Tue, 7 Nov 2017 23:52:36 -0800 (PST) X-Google-Smtp-Source: ABhQp+TyObpVzQ69+9RRUhkw+drnaPBPx0iVdDx0E+ctAZpo6oVDc0EdWCtHpUInjIrewfabe0Fu X-Received: by 10.84.131.197 with SMTP id d63mr1484458pld.414.1510127556251; Tue, 07 Nov 2017 23:52:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510127556; cv=none; d=google.com; s=arc-20160816; b=vGBDkgnQoJ2z+3hIKYxG+nNxyEO5JzNL73ZSrJCHV3WNDm9nklws+48r7oPsNhTaxY CTMUYDk7BGOaOuIMNhzyQz7FjBcq1172M0UbHBZcL9lVhahfwFppOce5bENDmulMa8La fAVd1In+QWERIHDe3WijNOHTFGFQ+PXr9k4LlzhNvsMRtCUAWdeKWUwcBpgc1FMEk9gD xW0u4G8TAU1imhRuFdVydj43s75El13MFn8wTyXHFlEeQw25IOpkBKuFXFmuGj44Bn0/ lFFQhAdUtVUd+nb1yb3r5HGFusC5GXdnjK58NKb5wniCT9m4B/tio+qBMYEsy0L9UsFm eOSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=iuwlqMbUf2T+jAKioxnQrxC3FgaivdEK9z4Z3Db56eo=; b=LElydr9kku0YRNpHHA+IvXGGY8pBsvASRkKmnp2mLR0o6NJ8SYuwa+shRpIWwizJW2 0DaVdu3fmYwoiF/ZKHiLBQioX2gMa+r+F4cH5z4uzjgKnJDC/2fXMdpqUZLuFtvbwgnr s39N/Cg9pv9iZtBBwsGD7n1Hm4MNSD37+koZGW6MoVcUUD0AY+VRX04u9SY6xsoi5gcY 1sJcm9GKRcGxVRJPJisKn63x5WGkzbc64u9iaU0TwuhWFw53Pl3mtG2DmGo5POjEqkVI yUbEzoxZOqAkb4GqxhIkxAxufEyQAiVf9+hXJKlSrHcVuZXzsluc2XvQ6r2qe4sQBdku PkbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=W1d+bx5q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f31si3127760plf.339.2017.11.07.23.52.23; Tue, 07 Nov 2017 23:52:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=W1d+bx5q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932345AbdKHGbU (ORCPT + 91 others); Wed, 8 Nov 2017 01:31:20 -0500 Received: from mail-pl0-f65.google.com ([209.85.160.65]:46938 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753779AbdKHGUD (ORCPT ); Wed, 8 Nov 2017 01:20:03 -0500 Received: by mail-pl0-f65.google.com with SMTP id y61so664252plh.3; Tue, 07 Nov 2017 22:20:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=iuwlqMbUf2T+jAKioxnQrxC3FgaivdEK9z4Z3Db56eo=; b=W1d+bx5qY94IT1B+7WNXLSlwuOyDwy0pLR/fUPxnBjuYag6x61sKf3W1BCK8gBgXXk Med2me+YGa4xwxLT0tUf1miCUS7MVaKmMHWl9kkwya1IqjLQoZv4XFqxKqiUa8xF7lvd nLcnWGkAr2fq6WzCKuRF1Jg0M/mxvZOU07Zb0kchZdMp505quZPzkLaFuFbdY//5h79+ aa8fkLShMi1eG6zaG+z1jGXf+eb9yi5DMrWOcNeMCkKWut/buhY48MgHhCALnYHQSgKi t9Rxa5ZALUBYllE3QJcC8rGx0YGmxA3vxoG1VQptWPegMiTr5aQRqfwYzefUBHy0z77S QxiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=iuwlqMbUf2T+jAKioxnQrxC3FgaivdEK9z4Z3Db56eo=; b=RqzFAh/io44Cc+I9Alk3Wrea6eCWSvFUOornnVtrdEEtmnUGpQwJO216I586mdinNl RCoFIoQKCdijb60hyqbJT2A9n8mEzjn3tejlScIHXuzP51TWMZA66IdvWei5/XKv/gQ+ YXF4oOyBzjKa6sMiD175Wo6vP0qF4p3jgByWAQF1ESATufl37Hmig1Vr5wqAUfobIPQk CiuHygQd/Jxnkdt2cgioSwxSAfCi3yCR5x5nRMRFQIFi5i1HDProBVBsDHXj53ouNtkU 2qpZSXNZycr0bA2H73EP6yelBhGFm6Qu4VQevSIZjNwecg7tt4oNbCgq0sVrPUkgm3C5 lUKQ== X-Gm-Message-State: AJaThX7zQtBichwufrZfxSPTGNh27ezmBXWiENlkla6Z4A2yFqtifQEY sjKFMS9nkr/Rs/R1S+jmE2A= X-Received: by 10.159.211.4 with SMTP id bc4mr1278956plb.160.1510122002758; Tue, 07 Nov 2017 22:20:02 -0800 (PST) Received: from app09.andestech.com ([118.163.51.199]) by smtp.gmail.com with ESMTPSA id a4sm6581339pfj.72.2017.11.07.22.20.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Nov 2017 22:20:02 -0800 (PST) From: Greentime Hu To: greentime@andestech.com, linux-kernel@vger.kernel.org, arnd@arndb.de, linux-arch@vger.kernel.org, tglx@linutronix.de, jason@lakedaemon.net, marc.zyngier@arm.com, robh+dt@kernel.org, netdev@vger.kernel.org Cc: green.hu@gmail.com, Rick Chen Subject: [PATCH 03/31] nds32: Support early_printk Date: Wed, 8 Nov 2017 13:54:51 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greentime Hu Signed-off-by: Rick Chen Signed-off-by: Greentime Hu --- arch/nds32/kernel/early_printk.c | 124 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 arch/nds32/kernel/early_printk.c diff --git a/arch/nds32/kernel/early_printk.c b/arch/nds32/kernel/early_printk.c new file mode 100644 index 0000000..269c3cd --- /dev/null +++ b/arch/nds32/kernel/early_printk.c @@ -0,0 +1,124 @@ +/* + * Copyright (C) 2005-2017 Andes Technology Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include + +#include + +extern void __iomem *early_io_map(phys_addr_t phys); +static void __iomem *early_base; +static void (*printch) (char ch); + +/* + * 8250/16550 (8-bit aligned registers) single character TX. + */ +static void uart8250_8bit_printch(char ch) +{ + while (!(readb(early_base + UART_LSR) & UART_LSR_THRE)) ; + writeb(ch, early_base + UART_TX); +} + +/* + * 8250/16550 (32-bit aligned registers) single character TX. + */ +static void uart8250_32bit_printch(char ch) +{ + while (!(readl(early_base + (UART_LSR << 2)) & UART_LSR_THRE)) ; + writel(ch, early_base + (UART_TX << 2)); +} + +struct earlycon_match { + const char *name; + void (*printch) (char ch); +}; + +static const struct earlycon_match earlycon_match[] __initconst = { + {.name = "uart8250-8bit",.printch = uart8250_8bit_printch,}, + {.name = "uart8250-32bit",.printch = uart8250_32bit_printch,}, + {} +}; + +static void early_write(struct console *con, const char *s, unsigned n) +{ + while (n-- > 0) { + if (*s == '\n') + printch('\r'); + printch(*s); + s++; + } +} + +static struct console early_console_dev = { + .name = "earlycon", + .write = early_write, + .flags = CON_PRINTBUFFER | CON_BOOT, + .index = -1, +}; + +/* + * Parse earlyprintk=... parameter in the format: + * + * [,][,] + * + * and register the early console. It is assumed that the UART has been + * initialised by the bootloader already. + */ +static int __init setup_early_printk(char *buf) +{ + const struct earlycon_match *match = earlycon_match; + phys_addr_t paddr = 0; + + if (!buf) { + pr_warning("No earlyprintk arguments passed.\n"); + return 0; + } + + while (match->name) { + size_t len = strlen(match->name); + if (!strncmp(buf, match->name, len)) { + buf += len; + break; + } + match++; + } + if (!match->name) { + pr_warning("Unknown earlyprintk arguments: %s\n", buf); + return 0; + } + + /* I/O address */ + if (!strncmp(buf, ",0x", 3)) { + char *e; + paddr = simple_strtoul(buf + 1, &e, 16); + buf = e; + } + + if (paddr) + early_base = early_io_map(paddr); + + if (!strcmp(CONFIG_NDS32_BUILTIN_DTB, "ae3xx")) + early_base += 32; + + printch = match->printch; + register_console(&early_console_dev); + + return 0; +} + +early_param("earlyprintk", setup_early_printk); -- 1.7.9.5 From 1583546507458333964@xxx Thu Nov 09 00:33:52 +0000 2017 X-GM-THRID: 1583546507458333964 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread