Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752430AbdF3MFe (ORCPT ); Fri, 30 Jun 2017 08:05:34 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:37575 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751954AbdF3MFP (ORCPT ); Fri, 30 Jun 2017 08:05:15 -0400 From: Romain Perier To: Greg Kroah-Hartman Cc: linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Nandor Han , Romain Perier Subject: [PATCH 4/7] serial: imx: Simplify DMA disablement Date: Fri, 30 Jun 2017 14:04:43 +0200 Message-Id: <20170630120446.13994-5-romain.perier@collabora.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170630120446.13994-1-romain.perier@collabora.com> References: <20170630120446.13994-1-romain.perier@collabora.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1782 Lines: 63 From: Nandor Han This commits simplify the function imx_disable_dma() by moving the code for disabling RX and TX DMAs to dedicated functions. Also move away CTSC and CTS as this is not related to DMA. Signed-off-by: Nandor Han Signed-off-by: Romain Perier --- drivers/tty/serial/imx.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 81fb413..e8cf7cf 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -1208,6 +1208,24 @@ static int imx_uart_dma_init(struct imx_port *sport) return ret; } +static void imx_stop_tx_dma(struct imx_port *sport) +{ + unsigned long temp; + + temp = readl(sport->port.membase + UCR1); + temp &= ~UCR1_TDMAEN; + writel(temp, sport->port.membase + UCR1); +} + +static void imx_stop_rx_dma(struct imx_port *sport) +{ + unsigned long temp; + + temp = readl(sport->port.membase + UCR1); + temp &= ~(UCR1_RDMAEN | UCR1_ATDMAEN); + writel(temp, sport->port.membase + UCR1); +} + static void imx_enable_dma(struct imx_port *sport) { unsigned long temp; @@ -1233,17 +1251,8 @@ static void imx_enable_dma(struct imx_port *sport) static void imx_disable_dma(struct imx_port *sport) { - unsigned long temp; - - /* clear UCR1 */ - temp = readl(sport->port.membase + UCR1); - temp &= ~(UCR1_RDMAEN | UCR1_TDMAEN | UCR1_ATDMAEN); - writel(temp, sport->port.membase + UCR1); - - /* clear UCR2 */ - temp = readl(sport->port.membase + UCR2); - temp &= ~(UCR2_CTSC | UCR2_CTS | UCR2_ATEN); - writel(temp, sport->port.membase + UCR2); + imx_stop_rx_dma(sport); + imx_stop_tx_dma(sport); imx_setup_ufcr(sport, TXTL_DEFAULT, RXTL_DEFAULT); -- 1.8.3.1