From patchwork Fri Dec 9 12:42:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 130371 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 7A18AB6F62 for ; Fri, 9 Dec 2011 23:45:29 +1100 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1RYzmh-0004Xo-DC; Fri, 09 Dec 2011 12:42:39 +0000 Received: from mail-gy0-f177.google.com ([209.85.160.177]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1RYzmd-0004XM-8C for linux-arm-kernel@lists.infradead.org; Fri, 09 Dec 2011 12:42:36 +0000 Received: by ghrr19 with SMTP id r19so2602258ghr.36 for ; Fri, 09 Dec 2011 04:42:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; bh=8sKOCupbj+cPi1m1m0kZbFXb4UP6VVV9Ca/bziQqK4A=; b=X5kLoxs7DopLfVJmujNaAR0jA5rtxVjpRIBhjVseqykBmp8U2vYcHs6A41LpxZKr1X h7M6H5RO/64/9BCEmH2fGVBWaLYb9oaqKAqy0MFI82Ol+LHXeUvb16p5ka9Btr5hmwJu Ze2eaUszmaN62TWpRGVE3pDBwGQYouVkVDuos= Received: by 10.236.156.5 with SMTP id l5mr11087765yhk.29.1323434553299; Fri, 09 Dec 2011 04:42:33 -0800 (PST) Received: from localhost.localdomain ([187.106.61.185]) by mx.google.com with ESMTPS id o7sm14773698yhl.15.2011.12.09.04.42.30 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 09 Dec 2011 04:42:32 -0800 (PST) From: Fabio Estevam To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/2] tty: serial: imx: Allow UART to be a source for wakeup Date: Fri, 9 Dec 2011 10:42:20 -0200 Message-Id: <1323434541-27689-1-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 1.7.1 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.160.177 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (festevam[at]gmail.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: Fabio Estevam , Fabio Estevam , shawn.guo@freescale.com, kernel@pengutronix.de 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: , MIME-Version: 1.0 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 Allow UART to be a source for wakeup from low power mode. Signed-off-by: Fabio Estevam Acked-by: Shawn Guo Tested-by: Richard Zhao --- .../bindings/tty/serial/fsl-imx-uart.txt | 2 + arch/arm/plat-mxc/include/mach/imx-uart.h | 1 + drivers/tty/serial/imx.c | 35 ++++++++++++++++++++ 3 files changed, 38 insertions(+), 0 deletions(-) diff --git a/Documentation/devicetree/bindings/tty/serial/fsl-imx-uart.txt b/Documentation/devicetree/bindings/tty/serial/fsl-imx-uart.txt index a9c0406..676cc39 100644 --- a/Documentation/devicetree/bindings/tty/serial/fsl-imx-uart.txt +++ b/Documentation/devicetree/bindings/tty/serial/fsl-imx-uart.txt @@ -8,6 +8,8 @@ Required properties: Optional properties: - fsl,uart-has-rtscts : Indicate the uart has rts and cts - fsl,irda-mode : Indicate the uart supports irda mode +- fsl,uart-can-wake : Indicate that uart can be a source for wakeup from +low-power mode Example: diff --git a/arch/arm/plat-mxc/include/mach/imx-uart.h b/arch/arm/plat-mxc/include/mach/imx-uart.h index 4adec9b..0ba6c6b 100644 --- a/arch/arm/plat-mxc/include/mach/imx-uart.h +++ b/arch/arm/plat-mxc/include/mach/imx-uart.h @@ -21,6 +21,7 @@ #define IMXUART_HAVE_RTSCTS (1<<0) #define IMXUART_IRDA (1<<1) +#define IMXUART_CANWAKE (1<<2) struct imxuart_platform_data { int (*init)(struct platform_device *pdev); diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 163fc90..f9bee68 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -200,6 +200,7 @@ struct imx_port { int txirq,rxirq,rtsirq; unsigned int have_rtscts:1; unsigned int use_irda:1; + unsigned int can_wake:1; unsigned int irda_inv_rx:1; unsigned int irda_inv_tx:1; unsigned short trcv_delay; /* transceiver delay */ @@ -566,6 +567,9 @@ static irqreturn_t imx_int(int irq, void *dev_id) if (sts & USR1_RTSD) imx_rtsint(irq, dev_id); + if (sts & USR1_AWAKE) + writel(USR1_AWAKE, sport->port.membase + USR1); + return IRQ_HANDLED; } @@ -660,6 +664,7 @@ static int imx_setup_ufcr(struct imx_port *sport, unsigned int mode) static int imx_startup(struct uart_port *port) { struct imx_port *sport = (struct imx_port *)port; + struct tty_struct *tty; int retval; unsigned long flags, temp; @@ -791,6 +796,8 @@ static int imx_startup(struct uart_port *port) if (pdata->irda_enable) pdata->irda_enable(1); } + tty = sport->port.state->port.tty; + device_set_wakeup_enable(tty->dev, 1); return 0; @@ -1269,6 +1276,15 @@ static struct uart_driver imx_reg = { static int serial_imx_suspend(struct platform_device *dev, pm_message_t state) { struct imx_port *sport = platform_get_drvdata(dev); + unsigned int val; + + if (device_may_wakeup(&dev->dev)) { + enable_irq_wake(sport->rxirq); + /* enable wakeup from i.MX UART */ + val = readl(sport->port.membase + UCR3); + val |= UCR3_AWAKEN; + writel(val, sport->port.membase + UCR3); + } if (sport) uart_suspend_port(&imx_reg, &sport->port); @@ -1279,6 +1295,17 @@ static int serial_imx_suspend(struct platform_device *dev, pm_message_t state) static int serial_imx_resume(struct platform_device *dev) { struct imx_port *sport = platform_get_drvdata(dev); + unsigned int val; + + if (device_may_wakeup(&dev->dev)) { + enable_irq_wake(sport->rxirq); + /* enable wakeup from i.MX UART */ + val = readl(sport->port.membase + UCR3); + val &= ~UCR3_AWAKEN; + writel(val, sport->port.membase + UCR3); + + disable_irq_wake(sport->rxirq); + } if (sport) uart_resume_port(&imx_reg, &sport->port); @@ -1311,6 +1338,9 @@ static int serial_imx_probe_dt(struct imx_port *sport, if (of_get_property(np, "fsl,irda-mode", NULL)) sport->use_irda = 1; + if (of_get_property(np, "fsl,uart-can-wake", NULL)) + sport->can_wake = 1; + sport->devdata = of_id->data; return 0; @@ -1408,6 +1438,11 @@ static int serial_imx_probe(struct platform_device *pdev) goto deinit; platform_set_drvdata(pdev, &sport->port); + if (pdata && (pdata->flags & IMXUART_CANWAKE)) + device_init_wakeup(&pdev->dev, 1); + else + device_init_wakeup(&pdev->dev, 0); + return 0; deinit: if (pdata && pdata->exit)