From patchwork Wed Jun 29 00:55:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chanho Park X-Patchwork-Id: 12899131 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DF6AAC43334 for ; Wed, 29 Jun 2022 00:59:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:References:MIME-Version:Message-Id:Date :Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=QkeYsMxEo6FBt9yvz7dOKY6VfG1OL3A/baGMuWaNBsA=; b=NdFT8d0JlixLP8 woJUzprnA0ZlY3qgoTHt0cnR2hvlzTwbJxKAVDEtTFlZwE9UdKUIi0eySAdJueZnBU+NX8lmIJE1w B2bQX2O3Kn/rQQgpGVZ7f/xEELQ+nUiuZRnOl7XEJA3M9rjK2biQnxmM1bNAo9eUJr0bLU2p4TRKC 118/+zBZT/a9T62M23wlwEWID8V0vFHN2h8TBcVR14iNZEnJfsUeKvrEj99w7OBlmdWF9JlbwWk0q qzhebiH1xiEV3Qz/Wc79zGaLKLKt2yy1as4l7ZEbRDInRDFP6DiPyv8yzWv2/Kx3RQdGCKYMNNiUN Dy5PeV+LzR07uJ9hRhIw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o6M1r-008plm-Jw; Wed, 29 Jun 2022 00:58:03 +0000 Received: from mailout3.samsung.com ([203.254.224.33]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o6M1n-008pl2-2m for linux-arm-kernel@lists.infradead.org; Wed, 29 Jun 2022 00:58:01 +0000 Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20220629005752epoutp03665bb586c52111505648df4854524eb5~88XrcrIk31573215732epoutp03K for ; Wed, 29 Jun 2022 00:57:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20220629005752epoutp03665bb586c52111505648df4854524eb5~88XrcrIk31573215732epoutp03K DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1656464272; bh=eOELwGthOhj4Twna3ildIS47IEDsUa9r0d3IFwQZJ6A=; h=From:To:Cc:Subject:Date:References:From; b=bf6UKFEQfUhBA7WJykhR8p5JjNRV8IItcakltrCiiTHhjGOJ75Lnd9QTzLUfZoVfD DynoTSOctpkSbFETaVTg8vN2dVgUxJUH4QiTtNkCyQqQVhnSJPVbv33dqgkSImn6YH tD3aOxL0D8HfhcstKbwzumTeAgjFW5iaAub8PNns= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20220629005752epcas2p37291981f31d1dfa105a63243b2b7ee25~88XqtAuf_0406604066epcas2p3R; Wed, 29 Jun 2022 00:57:52 +0000 (GMT) Received: from epsmges2p4.samsung.com (unknown [182.195.36.89]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4LXjk73b5Jz4x9QF; Wed, 29 Jun 2022 00:57:51 +0000 (GMT) Received: from epcas2p3.samsung.com ( [182.195.41.55]) by epsmges2p4.samsung.com (Symantec Messaging Gateway) with SMTP id 6F.DA.09662.F83ABB26; Wed, 29 Jun 2022 09:57:51 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas2p4.samsung.com (KnoxPortal) with ESMTPA id 20220629005750epcas2p418cd79922d1b3f13eda761ee3fcd3e17~88XplYyCc1396813968epcas2p42; Wed, 29 Jun 2022 00:57:50 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220629005750epsmtrp1f14bb8b05b530a4eed95963062a9530d~88XpkTe2V2342623426epsmtrp1V; Wed, 29 Jun 2022 00:57:50 +0000 (GMT) X-AuditID: b6c32a48-9f7ff700000025be-69-62bba38fb47e Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id A5.F9.08802.E83ABB26; Wed, 29 Jun 2022 09:57:50 +0900 (KST) Received: from localhost.localdomain (unknown [10.229.9.51]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220629005750epsmtip253cacbd8a1c3fc11e613a68383f03128~88XpXTri22587325873epsmtip2w; Wed, 29 Jun 2022 00:57:50 +0000 (GMT) From: Chanho Park To: Krzysztof Kozlowski , Greg Kroah-Hartman Cc: Jiri Slaby , Alim Akhtar , Hector Martin , Jaewon Kim , Vincent Whitchurch , linux-samsung-soc@vger.kernel.org, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Chanho Park Subject: [PATCH v2] tty: serial: samsung_tty: support more than 4 uart ports Date: Wed, 29 Jun 2022 09:55:38 +0900 Message-Id: <20220629005538.60132-1-chanho61.park@samsung.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprNJsWRmVeSWpSXmKPExsWy7bCmuW7/4t1JBr0LpC0ezNvGZnF5v7ZF 8+L1bBY7Go6wWrybK2Ox9/VWdotNj6+xWsw4v4/J4sziXnaL09cWsFuc3+bvwO1xfV2Ax6ZV nWwed67tYfPYP3cNu8fmJfUei5ftZPPo27KK0ePzJrkAjq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y1tCj+UWIozEg21mIuKEwHdFGOKLgQA AA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrDLMWRmVeSWpSXmKPExsWy7bCSvG7f4t1JBp8uGFs8mLeNzeLyfm2L 5sXr2Sx2NBxhtXg3V8Zi7+ut7BabHl9jtZhxfh+TxZnFvewWp68tYLc4v83fgdvj+roAj02r Otk87lzbw+axf+4ado/NS+o9Fi/byebRt2UVo8fnTXIBHFFcNimpOZllqUX6dglcGS+3fGYt 6FauePbxEmsD4yyZLkYODgkBE4krT4BMLg4hgR2MEk279rN3MXICxWUlnr3bAWULS9xvOcIK UfSeUeL+52PMIAk2AV2JLc9fMYLYIgLZEmu/7GUDKWIWeM4ksW/qVBaQDcICPhL7t+SC1LAI qEpM/PwIrJ5XwE5i8ZZFUAvkJTbM72WGiAtKnJz5hAXEZgaKN2+dzTyBkW8WktQsJKkFjEyr GCVTC4pz03OLDQuM8lLL9YoTc4tL89L1kvNzNzGCA1xLawfjnlUf9A4xMnEwHmKU4GBWEuFd eGZnkhBvSmJlVWpRfnxRaU5q8SFGaQ4WJXHeC10n44UE0hNLUrNTUwtSi2CyTBycUg1MBdnT NphvvxPlPyeX+at0tO6rGwERVWKGkj81g1ccOrn/7EPT6uN/VzD+kGs6GLAoqGWpQIvNPYb2 0+v+5L79//HOt5IZk6KZt5cG1GgUznOY+z7rxtq9KkVK8YvTFSdL6n4WnubYzT6VQzW25ZbM q6kXDC61mexKna7rbNojeVbGZumti6XrHtTJbHbW/Nm65Jj2VknDqsWXRG9l7DCV4q/a+/XX et6uyZoMqt1P//Q86nA9a6gs1b9x5f8dl8WeTeji6TLYmOlrM1Nie6n+nwrpUp39yzlv+0wO 5s0qmzw5emnJihvHMtxzlNxmHPt184H4nzdHVySE3gm2TXyjdOhvzbtt3jl3tG+qsiQpKrEU ZyQaajEXFScCAKF8yKPfAgAA X-CMS-MailID: 20220629005750epcas2p418cd79922d1b3f13eda761ee3fcd3e17 X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220629005750epcas2p418cd79922d1b3f13eda761ee3fcd3e17 References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220628_175759_642786_FBC39C7B X-CRM114-Status: GOOD ( 23.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Regarding Exynos Auto v9 SoC, it supports uarts up to 12. However, the maximum number of the ports has been derived from CONFIG_SERIAL_SAMSUNG_UARTS and tightly coupled with the config for previous Samsung SoCs such as s3c24xx and s3c64xx. To overcome this limitation, this changes the usage of the definition to UART_NR which is widely used from other serial drivers. This also defines the value to 12 only for ARM64 SoCs to not affect the change to previous arm32 SoCs. Instead of enumerating all the ports as predefined arrays, this introduces s3c24xx_serial_init_port_default that is initializing the structure as the default value. Signed-off-by: Chanho Park Reviewed-by: Krzysztof Kozlowski Reviewed-by: Hector Martin --- Changes from v1: - Remove initial value assignment of s3c24xx_serial_ports by assigning them dynamically as suggested by Greg and Krzysztof. drivers/tty/serial/samsung_tty.c | 82 ++++++++++---------------------- 1 file changed, 25 insertions(+), 57 deletions(-) diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c index 03ef4ff506fd..8971fbb49fa3 100644 --- a/drivers/tty/serial/samsung_tty.c +++ b/drivers/tty/serial/samsung_tty.c @@ -48,6 +48,12 @@ #define S3C24XX_SERIAL_MAJOR 204 #define S3C24XX_SERIAL_MINOR 64 +#ifdef CONFIG_ARM64 +#define UART_NR 12 +#else +#define UART_NR CONFIG_SERIAL_SAMSUNG_UARTS +#endif + #define S3C24XX_TX_PIO 1 #define S3C24XX_TX_DMA 2 #define S3C24XX_RX_PIO 1 @@ -87,7 +93,7 @@ struct s3c24xx_uart_info { struct s3c24xx_serial_drv_data { const struct s3c24xx_uart_info info; const struct s3c2410_uartcfg def_cfg; - const unsigned int fifosize[CONFIG_SERIAL_SAMSUNG_UARTS]; + const unsigned int fifosize[UART_NR]; }; struct s3c24xx_uart_dma { @@ -1810,67 +1816,27 @@ static const struct uart_ops apple_s5l_serial_ops = { static struct uart_driver s3c24xx_uart_drv = { .owner = THIS_MODULE, .driver_name = "s3c2410_serial", - .nr = CONFIG_SERIAL_SAMSUNG_UARTS, + .nr = UART_NR, .cons = S3C24XX_SERIAL_CONSOLE, .dev_name = S3C24XX_SERIAL_NAME, .major = S3C24XX_SERIAL_MAJOR, .minor = S3C24XX_SERIAL_MINOR, }; -#define __PORT_LOCK_UNLOCKED(i) \ - __SPIN_LOCK_UNLOCKED(s3c24xx_serial_ports[i].port.lock) -static struct s3c24xx_uart_port -s3c24xx_serial_ports[CONFIG_SERIAL_SAMSUNG_UARTS] = { - [0] = { - .port = { - .lock = __PORT_LOCK_UNLOCKED(0), - .iotype = UPIO_MEM, - .uartclk = 0, - .fifosize = 16, - .ops = &s3c24xx_serial_ops, - .flags = UPF_BOOT_AUTOCONF, - .line = 0, - } - }, - [1] = { - .port = { - .lock = __PORT_LOCK_UNLOCKED(1), - .iotype = UPIO_MEM, - .uartclk = 0, - .fifosize = 16, - .ops = &s3c24xx_serial_ops, - .flags = UPF_BOOT_AUTOCONF, - .line = 1, - } - }, -#if CONFIG_SERIAL_SAMSUNG_UARTS > 2 - [2] = { - .port = { - .lock = __PORT_LOCK_UNLOCKED(2), - .iotype = UPIO_MEM, - .uartclk = 0, - .fifosize = 16, - .ops = &s3c24xx_serial_ops, - .flags = UPF_BOOT_AUTOCONF, - .line = 2, - } - }, -#endif -#if CONFIG_SERIAL_SAMSUNG_UARTS > 3 - [3] = { - .port = { - .lock = __PORT_LOCK_UNLOCKED(3), - .iotype = UPIO_MEM, - .uartclk = 0, - .fifosize = 16, - .ops = &s3c24xx_serial_ops, - .flags = UPF_BOOT_AUTOCONF, - .line = 3, - } - } -#endif -}; -#undef __PORT_LOCK_UNLOCKED +static struct s3c24xx_uart_port s3c24xx_serial_ports[UART_NR]; + +static void s3c24xx_serial_init_port_default(int index) { + struct uart_port *port = &s3c24xx_serial_ports[index].port; + + spin_lock_init(&port->lock); + + port->iotype = UPIO_MEM; + port->uartclk = 0; + port->fifosize = 16; + port->ops = &s3c24xx_serial_ops; + port->flags = UPF_BOOT_AUTOCONF; + port->line = index; +} /* s3c24xx_serial_resetport * @@ -2186,6 +2152,8 @@ static int s3c24xx_serial_probe(struct platform_device *pdev) } ourport = &s3c24xx_serial_ports[index]; + s3c24xx_serial_init_port_default(index); + ourport->drv_data = s3c24xx_get_driver_data(pdev); if (!ourport->drv_data) { dev_err(&pdev->dev, "could not find driver data\n"); @@ -2584,7 +2552,7 @@ s3c24xx_serial_console_setup(struct console *co, char *options) /* is this a valid port */ - if (co->index == -1 || co->index >= CONFIG_SERIAL_SAMSUNG_UARTS) + if (co->index == -1 || co->index >= UART_NR) co->index = 0; port = &s3c24xx_serial_ports[co->index].port;