From patchwork Wed Oct 18 14:14:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 10014803 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F28A460215 for ; Wed, 18 Oct 2017 14:22:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E562728DE0 for ; Wed, 18 Oct 2017 14:22:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D9F2D28DE2; Wed, 18 Oct 2017 14:22:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 30A1628DE0 for ; Wed, 18 Oct 2017 14:22:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=MfVmWexDD/L09FdeDVzqTkCwybvPGlJkq7+oZ4xJ1wY=; b=HGv2vzs5igpoXbYWv1zCGkgwQb 7jEIFalxtF5faBBye7AdTfZ8WQRm6urnvG9w9y+W159bjLHPB+PdxMkmNcuED6Zit/oWP9wgU2WHF dhV5flCb/JfWk8FERvf7fzzN/wPyJJ4BhB65/fuPHdZkI8IIFJwxpLtoNUhlto1EcjNAUgFRGSZu1 IgysOeSPON4SwDdCvjCdblQJ1BxbkgS0LVyc55MIdkITckQQWnTCtPS92jjfJVLuvpEhcLV2tjeNW r0IQbbwx9O9fjsc0PQRiCe1M89UN+OIiS4vNTmk8lfEqMg2qZ9Z3GOXx02z/mtx/+6xumbsBEMM3V ojpzqWIg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e4pFF-0004Jp-6f; Wed, 18 Oct 2017 14:22:53 +0000 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e4p7r-000608-6y for linux-arm-kernel@lists.infradead.org; Wed, 18 Oct 2017 14:15:20 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D0CD315BF; Wed, 18 Oct 2017 07:14:57 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7ACF83F483; Wed, 18 Oct 2017 07:14:56 -0700 (PDT) From: Dave Martin To: linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH 2/3] tty: amba-pl011: earlycon: Unify earlycon backends Date: Wed, 18 Oct 2017 15:14:47 +0100 Message-Id: <1508336088-3948-3-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1508336088-3948-1-git-send-email-Dave.Martin@arm.com> References: <1508336088-3948-1-git-send-email-Dave.Martin@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171018_071515_372929_CB02D360 X-CRM114-Status: GOOD ( 12.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andre Przywara , Stephen Boyd , Russell King , Andy Gross , linux-serial@vger.kernel.org, Greg Kroah-Hartman , Bhupinder Thakur MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Now that the generic pl011 and qdf2400_e44 earlycon backends differ only in the choice of vendor_data and minor initialisation detatils that are detectable based on vendor_data, there's no strong need for them to be separate. This patch factors common earlyon setup into a new function pl011_early_console_setup_common(), which does generic setup and stashes a pointer to the relevant vendor_data struct in port->private_data (which appears otherwise unused by the amba-pl011 driver). The qdf2400_e44-specific earlycon write/putc functions would now be identical to the pl011 versions, so they are deleted. Signed-off-by: Dave Martin --- drivers/tty/serial/amba-pl011.c | 53 ++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 33 deletions(-) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index fd9e08c..084ed3f 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -2436,29 +2436,9 @@ static struct console amba_console = { #define AMBA_CONSOLE (&amba_console) -static void qdf2400_e44_putc(struct uart_port *port, int c) -{ - const struct vendor_data *vendor = &vendor_qdt_qdf2400_e44; - const u16 *reg_offset = vendor->reg_offset; - - while (__pl011_read(port, reg_offset, REG_FR) & UART01x_FR_TXFF) - cpu_relax(); - __pl011_write(c, port, reg_offset, REG_DR); - while (!__pl011_tx_empty(port, reg_offset, vendor)) - cpu_relax(); -} - -static void qdf2400_e44_early_write(struct console *con, const char *s, unsigned n) -{ - struct earlycon_device *dev = con->data; - - wmb(); - uart_console_write(&dev->port, s, n, qdf2400_e44_putc); -} - static void pl011_putc(struct uart_port *port, int c) { - const struct vendor_data *vendor = &vendor_arm; + const struct vendor_data *vendor = port->private_data; const u16 *reg_offset = vendor->reg_offset; while (__pl011_read(port, reg_offset, REG_FR) & UART01x_FR_TXFF) @@ -2476,6 +2456,22 @@ static void pl011_early_write(struct console *con, const char *s, unsigned n) uart_console_write(&dev->port, s, n, pl011_putc); } +static int __init +pl011_early_console_setup_common(struct earlycon_device *device, + const struct vendor_data *vendor) +{ + if (!device->port.membase) + return -ENODEV; + + device->port.private_data = (void *)vendor; + if (vendor->access_32b) + device->port.iotype = UPIO_MEM32; + + device->con->write = pl011_early_write; + + return 0; +} + /* * On non-ACPI systems, earlycon is enabled by specifying * "earlycon=pl011,
" on the kernel command line. @@ -2491,12 +2487,7 @@ static void pl011_early_write(struct console *con, const char *s, unsigned n) static int __init pl011_early_console_setup(struct earlycon_device *device, const char *opt) { - if (!device->port.membase) - return -ENODEV; - - device->con->write = pl011_early_write; - - return 0; + return pl011_early_console_setup_common(device, &vendor_arm); } OF_EARLYCON_DECLARE(pl011, "arm,pl011", pl011_early_console_setup); OF_EARLYCON_DECLARE(pl011, "arm,sbsa-uart", pl011_early_console_setup); @@ -2515,12 +2506,8 @@ static int __init qdf2400_e44_early_console_setup(struct earlycon_device *device, const char *opt) { - if (!device->port.membase) - return -ENODEV; - - device->port.iotype = UPIO_MEM32; - device->con->write = qdf2400_e44_early_write; - return 0; + return pl011_early_console_setup_common(device, + &vendor_qdt_qdf2400_e44); } EARLYCON_DECLARE(qdf2400_e44, qdf2400_e44_early_console_setup);