From patchwork Wed Aug 21 12:39:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 171948 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp912823ily; Wed, 21 Aug 2019 05:39:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqxdwgDPzXCDv8M0KMQIeRJ2QPoBZyLeOEyXOoYDozTLCMxd3EUd3SCXX4evRsbzLgh5950f X-Received: by 2002:a63:b904:: with SMTP id z4mr28336796pge.388.1566391164286; Wed, 21 Aug 2019 05:39:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566391164; cv=none; d=google.com; s=arc-20160816; b=EJyNaUMejaNfORwnnXOczkhtIr1he0twDYV70yV2PZJtFObbI5VbZ/Nxuu8jkzgh4F tHEnkrniY88l6yapbmgPbs42Be3soCQH1oZbsC29pdga/BqwOpkinlZGNxBcQdVZcF1Q EQZ6jEsXJqXVDOxc3lUrt5XS+ueF/yay1Y/Yh3EUbSS02WcJMmuzhm/XKjO1Y9FMq+Ch EDI1gG5K8rPi2lskjIHqXtwnhcHrHCj+VZIVKQEvxWRtuR2mxSfODNGd8Vyu1/ZIbDoi y2C66i9UB8PUZ9K/tOPwXqOtv5RxMHbWkUboPhUaVYy0MQTcKRSPmzavig7414zBIpa4 5Ikw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=omDwMrCmxk+7Xa7lFfgeuxa3H+tBB5SvsVtJ1gAu9m8=; b=AWzN9jsaIJcqJ3LvnvlMlEgeW6fjFSgGVVGysB3XYMxQavnmCbGmoysuZ4pIqKfrO7 vuPg4Dy6KsD3fLjOPKHieU5wm3jI9uj9YKUh4Pyhr76KcGrROtnZnkEHjHs+NMSjGVtp THWkk5KxmzdNZq6jibJEH/F8vDgZUt61gT7OiRxqofp7Ayb2fOcwfBUrlEli9XxiGEr6 BWfuTZoqfovJDQTRBWxE4eNN04qrYmrVGjYww5kwumhLSW7a0MoZ3w+OCvM402j8hZOy 0vnc/dN3LfRSlaJFHAtYqWlNobxmPCUE7a92dzDrIuuB4wyv0KflkvhsAQM30R2Wub5I Kr8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Yozs2A9r; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p3si2215089pjr.38.2019.08.21.05.39.24; Wed, 21 Aug 2019 05:39:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Yozs2A9r; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727251AbfHUMjX (ORCPT + 1 other); Wed, 21 Aug 2019 08:39:23 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:40490 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726227AbfHUMjX (ORCPT ); Wed, 21 Aug 2019 08:39:23 -0400 Received: by mail-pl1-f195.google.com with SMTP id h3so1277713pls.7 for ; Wed, 21 Aug 2019 05:39:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=omDwMrCmxk+7Xa7lFfgeuxa3H+tBB5SvsVtJ1gAu9m8=; b=Yozs2A9rBctqQEgyDcF4/wFS7L1lIhPOEhmkSZGKBb+/DVB8bYA74yRG4BfC1dwOKf p5EeZ+bWwbyVI++xjdHKzEnuXMnRtCKxmFTh+mxSzxwVxjEpvg+Fo42PrIegTm8lMHng Q0qbZ0l7GAmn94mbT7jEDSCPV0YKeb6jYQyuECAVQZToh3w7hdS41XgnsmlK9NKlYuB/ VkL9D62LOk33Jgk7gQolCOInt4TwTo9RWQmzu9GD/I0dphlCHyrpUFD5mjUCcrUd5uja ZS/un4d/SI3xRV4auwVYlkw5PU8kE5CNsrehWc9bR/pmR0c1tafl4kXHdjcCqZk+WPPq 68aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=omDwMrCmxk+7Xa7lFfgeuxa3H+tBB5SvsVtJ1gAu9m8=; b=bUOiaX7MGgWaeNToSHmy78K88YJ0140dulCzqvodWxNiyqZOTYz6fuTFbuD/9uWkUm 4mBWLqdCd4kiTWqsdmHcVi0PZhFo98HmiH5Uj9CxEFWty3EUTG1NfsauhIduUVJmcDKe d6zyV6naG2RzCaspWCpwWRGGV87UbE0MjHRxmiiKBstjg+n4Dl1Fmt6DjebIR3+crwt7 iYgXnpIk1Pkh3cDNfALQagd+GSryKJ+HxcGenW1ITUa6/tHu2Z7ZQA8c/INBysS0ccZB Ljl6Qjbf67vZhE8PQG4zNHi6gSDzY5mIzAN4y15JAxSfUDAKckxai+nyLh1jiKETk3ZY pRHw== X-Gm-Message-State: APjAAAUIv9W7+HLeIeJl0xINu63JevTcvrhZptxidZgM+NEPLUSYznK2 VH5lM96xB5H8BPWkCU0CclBOaQ== X-Received: by 2002:a17:902:7d8b:: with SMTP id a11mr33463555plm.306.1566391162920; Wed, 21 Aug 2019 05:39:22 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id i124sm25677411pfe.61.2019.08.21.05.39.19 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Aug 2019 05:39:22 -0700 (PDT) From: Baolin Wang To: gregkh@linuxfoundation.org, jslaby@suse.com Cc: orsonzhai@gmail.com, zhang.lyra@gmail.com, cixi.geng@unisoc.com, lanqing.liu@unisoc.com, baolin.wang@linaro.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] serial: sprd: Add loopback function support Date: Wed, 21 Aug 2019 20:39:09 +0800 Message-Id: <1275cd9968f1ceb5ac049cc23f1e508025cd552f.1566375260.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Add loopback function support for Spreadtrum serial controller. Signed-off-by: Baolin Wang --- drivers/tty/serial/sprd_serial.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) -- 1.7.9.5 diff --git a/drivers/tty/serial/sprd_serial.c b/drivers/tty/serial/sprd_serial.c index 73d71a4..85fc57c 100644 --- a/drivers/tty/serial/sprd_serial.c +++ b/drivers/tty/serial/sprd_serial.c @@ -79,6 +79,7 @@ /* control register 1 */ #define SPRD_CTL1 0x001C #define SPRD_DMA_EN BIT(15) +#define SPRD_LOOPBACK_EN BIT(14) #define RX_HW_FLOW_CTL_THLD BIT(6) #define RX_HW_FLOW_CTL_EN BIT(7) #define TX_HW_FLOW_CTL_EN BIT(8) @@ -164,7 +165,14 @@ static unsigned int sprd_get_mctrl(struct uart_port *port) static void sprd_set_mctrl(struct uart_port *port, unsigned int mctrl) { - /* nothing to do */ + u32 val = serial_in(port, SPRD_CTL1); + + if (mctrl & TIOCM_LOOP) + val |= SPRD_LOOPBACK_EN; + else + val &= ~SPRD_LOOPBACK_EN; + + serial_out(port, SPRD_CTL1, val); } static void sprd_stop_rx(struct uart_port *port)