From patchwork Fri Oct 13 09:01:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 10003799 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 870296037E for ; Fri, 13 Oct 2017 09:03:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B184283FF for ; Fri, 13 Oct 2017 09:03:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6FFF529002; Fri, 13 Oct 2017 09:03:15 +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 E0F52283FF for ; Fri, 13 Oct 2017 09:03:14 +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=HgiSyntX+rfju+HDNzj3p/VOwgLxLY8RDbFMZKx6yt4=; b=BlDGPKMBZuW831KB+q9VT2L5UN TRsg5RGog05wdtBpifC38zxXUrKU905WzrPREw6AYkKVC6+gEoUbv06vL72R+dPZQ6H1gXFDHFJJw U6nIFFaRRBM3bWBshUrP1oLokUavDZDlTA4BIAyfycrsT4U2Or6SL4D3DFOHCXjtrpit3ewucTPKg Ka7C8UsL6tWh9HAdbGD6XOPL0xkm4Q6VT4tq3nSYNi4HlYZwvzuh4822KJv17gvz1e169hL0WiLds yIFBy4X+vGlIMgQ5tC+KFnH8jNo61yYkGY1F/iw11vWBdfdNy0I6P9z6CxnD/V1I+V7hE+zuah9EO 4dWwZUmw==; 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 1e2vs5-0007Cb-7r; Fri, 13 Oct 2017 09:03:09 +0000 Received: from mail.free-electrons.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e2vrT-0006Sm-7i for linux-arm-kernel@lists.infradead.org; Fri, 13 Oct 2017 09:03:01 +0000 Received: by mail.free-electrons.com (Postfix, from userid 110) id 5758F20822; Fri, 13 Oct 2017 11:02:07 +0200 (CEST) Received: from localhost.localdomain (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id DBCF0207F7; Fri, 13 Oct 2017 11:02:06 +0200 (CEST) From: Miquel Raynal To: Greg Kroah-Hartman , Linus Walleij , Jason Cooper , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Jiri Slaby , Catalin Marinas , Will Deacon Subject: [PATCH v2 04/16] serial: mvebu-uart: support probe of multiple ports Date: Fri, 13 Oct 2017 11:01:48 +0200 Message-Id: <20171013090200.31034-5-miquel.raynal@free-electrons.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171013090200.31034-1-miquel.raynal@free-electrons.com> References: <20171013090200.31034-1-miquel.raynal@free-electrons.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171013_020231_976096_AC7B76EA X-CRM114-Status: GOOD ( 15.85 ) 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: Thomas Petazzoni , devicetree@vger.kernel.org, Allen Yan , Antoine Tenart , Nadav Haklai , linux-gpio@vger.kernel.org, linux-serial@vger.kernel.org, Miquel Raynal , Wilson Ding , linux-arm-kernel@lists.infradead.org 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 From: Allen Yan Until now, the mvebu-uart driver only supported probing a single UART port. However, some platforms have multiple instances of this UART controller, and therefore the driver should support multiple ports. In order to achieve this, we make sure to assign port->line properly, instead of hardcoding it to zero. Signed-off-by: Allen Yan Signed-off-by: Miquel Raynal Acked-by: Gregory CLEMENT Acked-by: Gregory CLEMENT --- Changes since v1: using multiple UART ports with this driver is not a problem anymore if not using a device tree. drivers/tty/serial/mvebu-uart.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/mvebu-uart.c b/drivers/tty/serial/mvebu-uart.c index 7e0a3e9fee15..f3c7271db32b 100644 --- a/drivers/tty/serial/mvebu-uart.c +++ b/drivers/tty/serial/mvebu-uart.c @@ -547,20 +547,36 @@ static struct uart_driver mvebu_uart_driver = { #endif }; +/* Counter to keep track of each UART port id when not using CONFIG_OF */ +static int uart_num_counter; + static int mvebu_uart_probe(struct platform_device *pdev) { struct resource *reg = platform_get_resource(pdev, IORESOURCE_MEM, 0); struct resource *irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); struct uart_port *port; struct mvebu_uart_data *data; - int ret; + int ret, id; if (!reg || !irq) { dev_err(&pdev->dev, "no registers/irq defined\n"); return -EINVAL; } - port = &mvebu_uart_ports[0]; + /* Assume that all UART ports have a DT alias or none has */ + id = of_alias_get_id(pdev->dev.of_node, "serial"); + if (!pdev->dev.of_node || id < 0) + pdev->id = uart_num_counter++; + else + pdev->id = id; + + if (pdev->id >= MVEBU_NR_UARTS) { + dev_err(&pdev->dev, "cannot have more than %d UART ports\n", + MVEBU_NR_UARTS); + return -EINVAL; + } + + port = &mvebu_uart_ports[pdev->id]; spin_lock_init(&port->lock); @@ -572,7 +588,7 @@ static int mvebu_uart_probe(struct platform_device *pdev) port->fifosize = 32; port->iotype = UPIO_MEM32; port->flags = UPF_FIXED_PORT; - port->line = 0; /* single port: force line number to 0 */ + port->line = pdev->id; port->irq = irq->start; port->irqflags = 0;