From patchwork Tue Jun 28 12:40:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chanho Park X-Patchwork-Id: 585769 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C18BCC433EF for ; Tue, 28 Jun 2022 12:43:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344649AbiF1MnP (ORCPT ); Tue, 28 Jun 2022 08:43:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346023AbiF1MnI (ORCPT ); Tue, 28 Jun 2022 08:43:08 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1F78FFB for ; Tue, 28 Jun 2022 05:43:05 -0700 (PDT) Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20220628124303epoutp03de9c6506e19db47406a57baedf809230~8yWF1OR0z2338223382epoutp036 for ; Tue, 28 Jun 2022 12:43:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20220628124303epoutp03de9c6506e19db47406a57baedf809230~8yWF1OR0z2338223382epoutp036 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/SwWOxoOMJq8W6ujMXe11vZLTY9vsZqMeP8PiaLM4t72S1OX1vAbnF+m78Dj8f1 dQEem1Z1snncubaHzWPeyUCP/XPXsHtsXlLvsXjZTjaPvi2rGD0+b5IL4IzKtslITUxJLVJI zUvOT8nMS7dV8g6Od443NTMw1DW0tDBXUshLzE21VXLxCdB1y8wBulZJoSwxpxQoFJBYXKyk b2dTlF9akqqQkV9cYquUWpCSU2BeoFecmFtcmpeul5daYmVoYGBkClSYkJ1x/ex6poJnwhUv 9q9ja2A8LNDFyMEhIWAi8eGIQhcjF4eQwA5GiWML37NCOJ8YJfoOHGOHcL4xSpx8NZWxi5ET rOPp/S9MEIm9jBLL5l6BqvrIKPGuZS9YFZuArsSW56/AbBGBbIk57ZtYQWxmgaXMEv/WRIDY wgLOEqebLjGB2CwCqhJnVh4Fs3kF7CWmH3jJBLFNXmLD/F5miLigxMmZT1gg5shLNG+dzQyy WEKgk0Ni/Z9PTBAPuUgsnuQF0Sss8er4FnYIW0riZX8blF0ssXTWJyaI3gZGicvbfrFBJIwl Zj1rZwSZwyygKbF+lz7ESGWJI7eg1vJJdBz+yw4R5pXoaBOCaFSXOLB9OguELSvRPeczK4Tt IbFkyRqw64UEYiX+3D3LPIFRfhaSZ2YheWYWwt4FjMy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K78MzOJCHelMTKqtSi/Pii0pzU4kOM0hwsSuK8F7pOxgsJpCeWpGanphakFsFk mTg4pRqYWBNdo5wSovV06n4+znoQJsMoUjhZ/6GIodjlI84JS8PEJvh5CDd4mmR9OzjLi+H+ c9t58jrG/0QjK5ekBr68e+3S5Ufqi7X2qyzY93+3yRoFlYNi4vuLKu5PMdOPsdrvP3H/s7Ib k7cW8R++ms6150XX2eV56Vdu3s299a41repCQ3dCdrMxj4XE7+i+MB7Gm43554Rs9WKcVGOu 5n0x6n4jHZ32sMlEtf3El7z72fdvNyq/jf/E5czqvKFfrGRn2Iny25+4vV8uX9Jm19XgU/lo eVDz6tuuP6+1Tpts9P7Wwfo6223sERcbttneCPW6fu1C1I0ZfpLxtRX3poptbJlYKMw9qT04 qnfV+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: Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.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 --- 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 | \