From patchwork Thu Mar 31 13:40:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksey Makarov X-Patchwork-Id: 8713441 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 71639C0553 for ; Thu, 31 Mar 2016 13:46:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B556620221 for ; Thu, 31 Mar 2016 13:46:37 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C4A8820138 for ; Thu, 31 Mar 2016 13:46:36 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1alcu9-0000DP-2X; Thu, 31 Mar 2016 13:44:57 +0000 Received: from mail-lf0-x229.google.com ([2a00:1450:4010:c07::229]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1alcsn-0007kB-6G for linux-arm-kernel@lists.infradead.org; Thu, 31 Mar 2016 13:43:36 +0000 Received: by mail-lf0-x229.google.com with SMTP id e133so59912070lfe.3 for ; Thu, 31 Mar 2016 06:43:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=b0P7T4KN/eCJt+GW2l/Z9AvP7Sta7/HFdNQawhDIXcI=; b=fn2HCkPjj7Hbaateo0upXtivMKU4I5bpnoFrBRpAomR++7Y2sx0AQzFze3OHN9QRRp PEfWoA8hrKyMXkYDo6i3LGQ/sjz6wtjWxWQrMDjj2Bk7Oi/xtwG5PQnyH2VwNH/Gmdo7 RUOoJv7j3wVocSnphQfI23ByjYsT1D4uxq07I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=b0P7T4KN/eCJt+GW2l/Z9AvP7Sta7/HFdNQawhDIXcI=; b=NKuizvjY9hZRTajTvBhSL381eQAcTx6fdSgty9hqHUvbaQwQvFpvxhHrazvkuWbw8a WMN60aldGj/rGRbMDnfqnKo7szYqCbem8nIWZ+tF6g3Al8kh65kK1UrlBAGfykJSJlIV 1UH30g5Hpx8ZronUMC78s2CES05hsqkEAao+zE4RE5dKOU363MNRFVcRjFaBfZkxePbs PkHhKVZQjwogRxPrd4GVPauhb+9ziYzaNEcVBPJ8XvU0qAbBZthbAXERGhDLQP6npzZj RXiUByS0HT9C+Kk/mxsKYO8sLMwx8mtktUmPv+lbYYj0oCgtvfSdIu7PdACtmLW3XYYk AFZA== X-Gm-Message-State: AD7BkJKG3Ky9tIGpjbUYOHBJcAqFlqgFO/jCnKgdbWSPn+rGkx/4aD9CyWv70XTvpTId1hlG X-Received: by 10.25.137.215 with SMTP id l206mr5579193lfd.140.1459431791349; Thu, 31 Mar 2016 06:43:11 -0700 (PDT) Received: from turnip.localdomain (nivc-213.auriga.ru. [80.240.102.213]) by smtp.gmail.com with ESMTPSA id mi9sm1285984lbc.27.2016.03.31.06.43.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 Mar 2016 06:43:10 -0700 (PDT) From: Aleksey Makarov To: Russell King , Greg Kroah-Hartman Subject: [PATCH v7 5/5] serial: pl011: add console matching function Date: Thu, 31 Mar 2016 16:40:27 +0300 Message-Id: <1459431629-27934-6-git-send-email-aleksey.makarov@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1459431629-27934-1-git-send-email-aleksey.makarov@linaro.org> References: <1459431629-27934-1-git-send-email-aleksey.makarov@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160331_064333_627551_7042C821 X-CRM114-Status: GOOD ( 16.63 ) X-Spam-Score: -2.7 (--) 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: "Zheng, Lv" , Peter Hurley , Graeme Gregory , Andy Shevchenko , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, Leif Lindholm , linux-acpi@vger.kernel.org, Aleksey Makarov , Yury Norov , Christopher Covington , linux-serial@vger.kernel.org, Jiri Slaby , Al Stone , linux-arm-kernel@lists.infradead.org, Len Brown MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds function pl011_console_match() that implements method match of struct console. It allows to match consoles against data specified in a string, for example taken from command line or compiled by ACPI SPCR table handler. Signed-off-by: Aleksey Makarov Reviewed-by: Peter Hurley Acked-by: Greg Kroah-Hartman --- drivers/tty/serial/amba-pl011.c | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index 7c198e0..4139b64 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -2287,12 +2287,68 @@ static int __init pl011_console_setup(struct console *co, char *options) return uart_set_options(&uap->port, co, baud, parity, bits, flow); } +/** + * pl011_console_match - non-standard console matching + * @co: registering console + * @name: name from console command line + * @idx: index from console command line + * @options: ptr to option string from console command line + * + * Only attempts to match console command lines of the form: + * console=pl011,mmio|mmio32,[,] + * console=pl011,0x[,] + * This form is used to register an initial earlycon boot console and + * replace it with the amba_console at pl011 driver init. + * + * Performs console setup for a match (as required by interface) + * If no are specified, then assume the h/w is already setup. + * + * Returns 0 if console matches; otherwise non-zero to use default matching + */ +static int __init pl011_console_match(struct console *co, char *name, int idx, + char *options) +{ + char match[] = "pl011"; /* pl011-specific earlycon name */ + unsigned char iotype; + unsigned long addr; + int i; + + if (strncmp(name, match, 5) != 0) + return -ENODEV; + + if (uart_parse_earlycon(options, &iotype, &addr, &options)) + return -ENODEV; + + /* try to match the port specified on the command line */ + for (i = 0; i < ARRAY_SIZE(amba_ports); i++) { + struct uart_port *port; + + if (!amba_ports[i]) + continue; + + port = &amba_ports[i]->port; + + if (port->iotype != iotype) + continue; + if ((iotype == UPIO_MEM || iotype == UPIO_MEM32) && + (port->mapbase != addr)) + continue; + + co->index = i; + port->cons = co; + return pl011_console_setup(co, options); + } + + return -ENODEV; +} + static struct uart_driver amba_reg; static struct console amba_console = { .name = "ttyAMA", .write = pl011_console_write, .device = uart_console_device, .setup = pl011_console_setup, + .match = pl011_console_match, .flags = CON_PRINTBUFFER, .index = -1, .data = &amba_reg,