From patchwork Sun Dec 18 17:34:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dirk Behme X-Patchwork-Id: 132105 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BC37BB7046 for ; Mon, 19 Dec 2011 04:37:50 +1100 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1RcKdM-0002Hx-In; Sun, 18 Dec 2011 17:34:48 +0000 Received: from mail-ee0-f49.google.com ([74.125.83.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1RcKdI-0002Hj-4F for linux-arm-kernel@lists.infradead.org; Sun, 18 Dec 2011 17:34:45 +0000 Received: by eekc13 with SMTP id c13so3569516eek.36 for ; Sun, 18 Dec 2011 09:34:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:mime-version :content-type:content-transfer-encoding; bh=/Ci9+w3fKzQu3qkIeuklQDNZ3spcTHH0FUI7Bf9bDU8=; b=ncgAwuHiGQLnvc84DqeA5QvXJJhciTuBOi6f0fDZy6ZiVf6L27UWK+EV95IFGfSydx sQyqvoxDJBO5An0H90FzgXo3esNIVsqmu+Gg4K+c397jm1zQt6HNuClBeqWmJY1ooSqW KsGwgsJ2xDkolVq6J6oOE1EDxhSwciLMcvLzU= Received: by 10.14.95.9 with SMTP id o9mr2923613eef.125.1324229681334; Sun, 18 Dec 2011 09:34:41 -0800 (PST) Received: from asterix.localdomain (p4FEE1F89.dip.t-dialin.net. [79.238.31.137]) by mx.google.com with ESMTPS id z54sm32895972eeh.5.2011.12.18.09.34.39 (version=SSLv3 cipher=OTHER); Sun, 18 Dec 2011 09:34:40 -0800 (PST) From: Dirk Behme To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/2] imx: Add save/restore functions for UART control regs Date: Sun, 18 Dec 2011 18:34:14 +0100 Message-Id: <1324229655-5538-1-git-send-email-dirk.behme@gmail.com> X-Mailer: git-send-email 1.7.7.4 MIME-Version: 1.0 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (dirk.behme[at]googlemail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Sascha Hauer , Dirk Behme , linux-serial@vger.kernel.org, =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Fabio Estevam , Saleem Abdulrasool X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org Factor out the uart save/restore functionality instead of having the same code several times in the driver. Signed-off-by: Dirk Behme CC: Saleem Abdulrasool CC: Sascha Hauer CC: Fabio Estevam CC: Uwe Kleine-König CC: linux-serial@vger.kernel.org --- drivers/tty/serial/imx.c | 38 +++++++++++++++++++++++++++++++------- 1 files changed, 31 insertions(+), 7 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 163fc90..6a01c2a 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -260,6 +260,31 @@ static inline int is_imx21_uart(struct imx_port *sport) } /* + * Save and restore functions for UCR1, UCR2 and UCR3 registers + */ +static void imx_console_mode(struct uart_port *port, + unsigned int *ucr1, + unsigned int *ucr2, + unsigned int *ucr3) +{ + /* save control registers */ + *ucr1 = readl(port->membase + UCR1); + *ucr2 = readl(port->membase + UCR2); + *ucr3 = readl(port->membase + UCR3); +} + +static void imx_console_restore(struct uart_port *port, + unsigned int ucr1, + unsigned int ucr2, + unsigned int ucr3) +{ + /* restore control registers */ + writel(ucr1, port->membase + UCR1); + writel(ucr2, port->membase + UCR2); + writel(ucr3, port->membase + UCR3); +} + +/* * Handle any change of modem status signal since we were last called. */ static void imx_mctrl_check(struct imx_port *sport) @@ -1118,13 +1143,13 @@ static void imx_console_write(struct console *co, const char *s, unsigned int count) { struct imx_port *sport = imx_ports[co->index]; - unsigned int old_ucr1, old_ucr2, ucr1; + unsigned int old_ucr1, old_ucr2, old_ucr3, ucr1; /* - * First, save UCR1/2 and then disable interrupts + * First, save UCR1/2/3 and then disable interrupts */ - ucr1 = old_ucr1 = readl(sport->port.membase + UCR1); - old_ucr2 = readl(sport->port.membase + UCR2); + imx_console_mode(&sport->port, &old_ucr1, &old_ucr2, &old_ucr3); + ucr1 = old_ucr1; if (is_imx1_uart(sport)) ucr1 |= IMX1_UCR1_UARTCLKEN; @@ -1139,12 +1164,11 @@ imx_console_write(struct console *co, const char *s, unsigned int count) /* * Finally, wait for transmitter to become empty - * and restore UCR1/2 + * and restore UCR1/2/3 */ while (!(readl(sport->port.membase + USR2) & USR2_TXDC)); - writel(old_ucr1, sport->port.membase + UCR1); - writel(old_ucr2, sport->port.membase + UCR2); + imx_console_restore(&sport->port, old_ucr1, old_ucr2, old_ucr3); } /*