From patchwork Tue Jun 28 12:40:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chanho Park X-Patchwork-Id: 12898232 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 196BFC433EF for ; Tue, 28 Jun 2022 12:44:25 +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=S3CAOLF2OmcaWkADowlzCKA7fR0i5dWNEyJoJTsmPpo=; b=VH6iaEx+h3BKRh 5TR3Vg23KXM/Ja+AdvY25P4EMm1wWSQCwt5JQMxUKinw9vFfvrNwiiYHogCWHwCtbKOA2ZJxWgnW/ 3EhNGRb1Hg+wvy1Aj0Fs1neUQIrJ0ULgapdD1s/nibPnJ9Z3saRBfVHNDhZ4I6P6V+hQB4c0Qk/1h ZUkSm2I1+bqCzsPnz2tBhSpqEdK537rUhA/HnEWBEpQRyxaIRuXSF/ua9GMnPA2YfHNmsoSEo9ymN p0++LmMPchsDZcW1B71OtnDp+Twt0aCdIWR+N0rYjUDZfKDD+S6IqsFrblUZwqigSm+cX/3btp1SB 37vetf3qIHbncqtXivtg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o6AYl-006D3K-CN; Tue, 28 Jun 2022 12:43:15 +0000 Received: from mailout4.samsung.com ([203.254.224.34]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o6AYf-006D1p-99 for linux-arm-kernel@lists.infradead.org; Tue, 28 Jun 2022 12:43:14 +0000 Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20220628124303epoutp049b2ecfb18e0c61cd37387019dfc5b2a3~8yWF0r1Qb2378723787epoutp04N for ; Tue, 28 Jun 2022 12:43:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20220628124303epoutp049b2ecfb18e0c61cd37387019dfc5b2a3~8yWF0r1Qb2378723787epoutp04N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1656420183; bh=+0PnWVexSB7CE5anTJ4hPT4pppULPbUlfWwvDmuFTk0=; h=From:To:Cc:Subject:Date:References:From; b=lkMj7ygD5WWVv8InwErdnDmE50UgKvwatVkzAerpkqdmZUPwkkN4JvAUZK4gvzG1M uEeAG3YQl44F/A5ybr8NI08B6qL3lXql4b/VeEeh4bN4yCXcrOas++4zOxiMi4/alf 1FROUdntx4meZ26mGfTlrCiD6KJMm8Hy1oqu64iw= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas2p2.samsung.com (KnoxPortal) with ESMTP id 20220628124302epcas2p2b6ea0128b1f2b2eac2c228be06783bd2~8yWE7HFEz0617506175epcas2p2Q; Tue, 28 Jun 2022 12:43:02 +0000 (GMT) Received: from epsmges2p2.samsung.com (unknown [182.195.36.89]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4LXPQG0HwCz4x9Ps; Tue, 28 Jun 2022 12:43:02 +0000 (GMT) Received: from epcas2p3.samsung.com ( [182.195.41.55]) by epsmges2p2.samsung.com (Symantec Messaging Gateway) with SMTP id 61.EE.09650.557FAB26; Tue, 28 Jun 2022 21:43:01 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas2p4.samsung.com (KnoxPortal) with ESMTPA id 20220628124300epcas2p45f1e3a7051bb93ecba778cf7d96720d3~8yWDVHal00453404534epcas2p4J; Tue, 28 Jun 2022 12:43:00 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220628124300epsmtrp17cf85c072bfd9d4d6ee448a667f940c2~8yWDUGZsd1310713107epsmtrp1F; Tue, 28 Jun 2022 12:43:00 +0000 (GMT) X-AuditID: b6c32a46-0a3ff700000025b2-6a-62baf755a302 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 08.84.08905.457FAB26; Tue, 28 Jun 2022 21:43:00 +0900 (KST) Received: from localhost.localdomain (unknown [10.229.9.51]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220628124300epsmtip2b27bb665dd378f3334a17e0e2bcc460d~8yWDC2hzu0953609536epsmtip2F; Tue, 28 Jun 2022 12:43:00 +0000 (GMT) From: Chanho Park To: Krzysztof Kozlowski , Greg Kroah-Hartman Cc: Jiri Slaby , Alim Akhtar , Hector Martin , Jaewon Kim , Vincent Whitchurch , =?utf-8?q?Ilpo_J=C3=A4rvi?= =?utf-8?q?nen?= , 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: loopback mode support Date: Tue, 28 Jun 2022 21:40:50 +0900 Message-Id: <20220628124050.144398-1-chanho61.park@samsung.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKJsWRmVeSWpSXmKPExsWy7bCmuW7o911JBkfvWFs8mLeNzeLyfm2L 5sXr2Sw6d/SwWOxoOMJq8W6ujMXe11vZLTY9vsZqM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V+hIlluKMREMt5qLiRADI3BAf6gIAAA== X-CMS-MailID: 20220628124300epcas2p45f1e3a7051bb93ecba778cf7d96720d3 X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220628124300epcas2p45f1e3a7051bb93ecba778cf7d96720d3 References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220628_054313_029442_51ADFDFC X-CRM114-Status: GOOD ( 19.90 ) 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 Internal loopback mode can be supported by setting UCON register's Loopback Mode bit. The mode & bit can be supported since s3c2410 and later SoCs. The prefix of LOOPBACK / BIT(5) naming should be also changed to S3C2410_ to avoid confusion. We can test it by linux-serial-test program with -k option. The tool will set TIOCM_LOOP mode when the option is specified. -k, --loopback Use internal hardware loop back Signed-off-by: Chanho Park Reviewed-by: Ilpo Järvinen --- Changes from v1: - Drop TIOCM_LOOP return from s3c24xx_serial_get_mctrl as pointed out by Ilpo. Documentation/driver-api/serial/driver.rst indicates the bit is only for set_mctrl. - Change the loopback bit definition from S3C2443_UCON_LOOPBACK to S3C2410_UCON_LOOPBACK because it has been supported since s3c2410. - Remove the unnecessary footnote and put a blank line before Signed-off-by drivers/tty/serial/samsung_tty.c | 8 ++++++++ include/linux/serial_s3c.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c index d5ca904def34..03ef4ff506fd 100644 --- a/drivers/tty/serial/samsung_tty.c +++ b/drivers/tty/serial/samsung_tty.c @@ -1012,6 +1012,7 @@ static unsigned int s3c24xx_serial_get_mctrl(struct uart_port *port) static void s3c24xx_serial_set_mctrl(struct uart_port *port, unsigned int mctrl) { unsigned int umcon = rd_regl(port, S3C2410_UMCON); + unsigned int ucon = rd_reg(port, S3C2410_UCON); if (mctrl & TIOCM_RTS) umcon |= S3C2410_UMCOM_RTS_LOW; @@ -1019,6 +1020,13 @@ static void s3c24xx_serial_set_mctrl(struct uart_port *port, unsigned int mctrl) umcon &= ~S3C2410_UMCOM_RTS_LOW; wr_regl(port, S3C2410_UMCON, umcon); + + if (mctrl & TIOCM_LOOP) + ucon |= S3C2410_UCON_LOOPBACK; + else + ucon &= ~S3C2410_UCON_LOOPBACK; + + wr_regl(port, S3C2410_UCON, ucon); } static void s3c24xx_serial_break_ctl(struct uart_port *port, int break_state) diff --git a/include/linux/serial_s3c.h b/include/linux/serial_s3c.h index dec15f5b3dec..1672cf0810ef 100644 --- a/include/linux/serial_s3c.h +++ b/include/linux/serial_s3c.h @@ -83,7 +83,7 @@ #define S3C2410_UCON_RXIRQMODE (1<<0) #define S3C2410_UCON_RXFIFO_TOI (1<<7) #define S3C2443_UCON_RXERR_IRQEN (1<<6) -#define S3C2443_UCON_LOOPBACK (1<<5) +#define S3C2410_UCON_LOOPBACK (1<<5) #define S3C2410_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \ S3C2410_UCON_RXILEVEL | \