From patchwork Mon Jan 23 12:26:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 9532437 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 BAB296042F for ; Mon, 23 Jan 2017 12:27:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF84627B2F for ; Mon, 23 Jan 2017 12:27:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A223C28304; Mon, 23 Jan 2017 12:27:40 +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=-1.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=no 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 2C1F827B2F for ; Mon, 23 Jan 2017 12:27:40 +0000 (UTC) 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 1cVdij-0004gO-DW; Mon, 23 Jan 2017 12:27:37 +0000 Received: from mail-wm0-f66.google.com ([74.125.82.66]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cVdif-0004fl-7W for linux-arm-kernel@lists.infradead.org; Mon, 23 Jan 2017 12:27:35 +0000 Received: by mail-wm0-f66.google.com with SMTP id r126so26045549wmr.3 for ; Mon, 23 Jan 2017 04:27:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id; bh=mfhyZ7fVcuTGe/UZHtaXLPFNXyVsIsvWAfQQQxcddJI=; b=BhCtXa+yAPfxICIDdSPM32yvnnk5i42lHKta+/HuZuwP7VBx7s8061bKoZvnhro7cs qxBjUnrUBJ+M+/4BPqjvPvOZCRp/KXmY0QLiiEskLR8495YX0qHxWwluIHZs24frbSDb siJPgANj+wCepf0P5avFtQo7vq8recsGntaZAs1iInhFyypFrPOFGXWeNxGfdgyrhDai d+uMNDS1CX84VJwYF0WZ7a2Z/PXSoAWjC2NL/xennNrozFOV4m/F7xpLaCUzj0mlFpfC zlllAPVLJpmysn/NEytXySd3vyLjza5tnmiJcht8pm4w9voD5vfQHR4ChT35Au7JeLdP c15A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=mfhyZ7fVcuTGe/UZHtaXLPFNXyVsIsvWAfQQQxcddJI=; b=q/OTvZcJ3kDoR0Shn5wJ9x+yYmxDka4my5uqKrORhBabzPgmwParhYx+QMd6xATzFT Ki3MXWOQEk2X2cCGTv6nvWunKzHQPc8YMZisUVr+vdCgg2FGpXiKLVFLtzbJIm2qUDfE u8CawMwkvIm/BUUjYDCGwRFL9PQ8sl/4Q53+PnsU021kruyOdmd1QgeJKnWVYxXto51F HSrFdVE6r5yTBViQbYKqILVVF+LRDQhRlxSiV4G28+UzbS9pD+KvsocBlnWuxTJbxUPm VbHuLxVdYk8W7Exe32u784PfpPl3Wca3lO5rYWRbWR9JJrIwIUjIWuyEVNqGEeLKklOd 38Aw== X-Gm-Message-State: AIkVDXKhD5r/1mIHutTeu/koMxGtOiS9cRTv268sQS7+S9xahlSqu+n0wqqsmLNcTb8YWQ== X-Received: by 10.223.170.221 with SMTP id i29mr28937823wrc.131.1485174370717; Mon, 23 Jan 2017 04:26:10 -0800 (PST) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id w126sm28881995wmw.0.2017.01.23.04.26.09 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 23 Jan 2017 04:26:10 -0800 (PST) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu Subject: [PATCH] serial: xuartps: Enable uart loopback mode Date: Mon, 23 Jan 2017 13:26:08 +0100 Message-Id: X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170123_042733_431714_FB959D16 X-CRM114-Status: GOOD ( 10.11 ) 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: Greg Kroah-Hartman , =?UTF-8?q?S=C3=B6ren=20Brinkmann?= , linux-serial@vger.kernel.org, Jiri Slaby , Yasir-Khan , 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: Yasir-Khan This patch adds xilinx uart loopback support by modifying the cdns_uart_set_mctrl function to handle the switch to loopback mode. After this patch, the loopback mode can be enabled/disabled by setting/clearing the TIOCM_LOOP modem bit via TIOCMBIS/TIOCMBIC ioctls respectively. Signed-off-by: Yasir-Khan Signed-off-by: Michal Simek --- drivers/tty/serial/xilinx_uartps.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index dd4c02fa4820..ad77d0ed0c46 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -93,6 +93,7 @@ #define CDNS_UART_MR_CLKSEL 0x00000001 /* Pre-scalar selection */ #define CDNS_UART_MR_CHMODE_L_LOOP 0x00000200 /* Local loop back mode */ #define CDNS_UART_MR_CHMODE_NORM 0x00000000 /* Normal mode */ +#define CDNS_UART_MR_CHMODE_MASK 0x00000300 /* Mask for mode bits */ #define CDNS_UART_MR_STOPMODE_2_BIT 0x00000080 /* 2 stop bits */ #define CDNS_UART_MR_STOPMODE_1_BIT 0x00000000 /* 1 stop bit */ @@ -998,17 +999,25 @@ static unsigned int cdns_uart_get_mctrl(struct uart_port *port) static void cdns_uart_set_mctrl(struct uart_port *port, unsigned int mctrl) { u32 val; + u32 mode_reg; val = readl(port->membase + CDNS_UART_MODEMCR); + mode_reg = readl(port->membase + CDNS_UART_MR); val &= ~(CDNS_UART_MODEMCR_RTS | CDNS_UART_MODEMCR_DTR); + mode_reg &= ~CDNS_UART_MR_CHMODE_MASK; if (mctrl & TIOCM_RTS) val |= CDNS_UART_MODEMCR_RTS; if (mctrl & TIOCM_DTR) val |= CDNS_UART_MODEMCR_DTR; + if (mctrl & TIOCM_LOOP) + mode_reg |= CDNS_UART_MR_CHMODE_L_LOOP; + else + mode_reg |= CDNS_UART_MR_CHMODE_NORM; writel(val, port->membase + CDNS_UART_MODEMCR); + writel(mode_reg, port->membase + CDNS_UART_MR); } #ifdef CONFIG_CONSOLE_POLL