From patchwork Mon Apr 2 12:20:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vignesh Raghavendra X-Patchwork-Id: 10319637 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 7683060247 for ; Mon, 2 Apr 2018 12:20:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55CAE28A1C for ; Mon, 2 Apr 2018 12:20:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E9A128A48; Mon, 2 Apr 2018 12:20:02 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D54228A1C for ; Mon, 2 Apr 2018 12:19:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751242AbeDBMT4 (ORCPT ); Mon, 2 Apr 2018 08:19:56 -0400 Received: from lelnx193.ext.ti.com ([198.47.27.77]:41102 "EHLO lelnx193.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750927AbeDBMTz (ORCPT ); Mon, 2 Apr 2018 08:19:55 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id w32CJoHU017362; Mon, 2 Apr 2018 07:19:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1522671590; bh=l9m3Xi85k+ud6v67AL5xJBFgo3lhbENc2zdA/oN8XGs=; h=From:To:CC:Subject:Date; b=Pnu2m7hwR5rb0+V52LyH2UfVvYkQsvdCylqx0gG9SCyCeoabXatdPdX9AaZsL4gbN ByTt0VKMr3Gm67ZFVyl1li6CNB9n0RZorKPDYFVDXBKdlpuK+h4rpc4kmJo8zn5T4x VgjyoGlyYG7DHKmNU92V0e+L8xqpCWaFBCTv2+lE= Received: from DFLE113.ent.ti.com (dfle113.ent.ti.com [10.64.6.34]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w32CJo8W024370; Mon, 2 Apr 2018 07:19:50 -0500 Received: from DFLE108.ent.ti.com (10.64.6.29) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Mon, 2 Apr 2018 07:19:50 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Mon, 2 Apr 2018 07:19:50 -0500 Received: from a0132425.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w32CJlm8009663; Mon, 2 Apr 2018 07:19:48 -0500 From: Vignesh R To: Greg Kroah-Hartman CC: Jiri Slaby , Tony Lindgren , Vignesh R , , , Subject: [PATCH v2] serial: 8250: omap: Provide ability to enable/disable UART as wakeup source Date: Mon, 2 Apr 2018 17:50:37 +0530 Message-ID: <20180402122037.2710-1-vigneshr@ti.com> X-Mailer: git-send-email 2.16.2 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Enable/Clear module level UART wakeup in UART_OMAP_WER register based on return value of device_may_wakeup() in .suspend(). This allows userspace to use sysfs to control the ability of UART to wakeup the system from deep sleep state. Register is restored back in .startup() call that happens as part of resume sequence. With this patch, userspace can control UART wakeup capability via sysfs: To enable wakeup capability: echo enabled > /sys/class/tty/ttyXX/device/power/wakeup For disabling wakeup capability: echo disabled > /sys/class/tty/ttyXX/device/power/wakeup Note that the UART wakeup events configured in the 8250 hardware only work for idle modes that do not cut off power for the UART. For deeper idle states, dedicated padconf wakeirqs must be used. Or in some cases the UART RX pin can be remuxed to GPIO input if the GPIO block stays powered. Signed-off-by: Vignesh R Tested-by: Tony Lindgren --- v2: update commit log. drivers/tty/serial/8250/8250_omap.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c index 624b501fd253..6aaa84355fd1 100644 --- a/drivers/tty/serial/8250/8250_omap.c +++ b/drivers/tty/serial/8250/8250_omap.c @@ -1310,8 +1310,17 @@ static void omap8250_complete(struct device *dev) static int omap8250_suspend(struct device *dev) { struct omap8250_priv *priv = dev_get_drvdata(dev); + struct uart_8250_port *up = serial8250_get_port(priv->line); serial8250_suspend_port(priv->line); + + pm_runtime_get_sync(dev); + if (!device_may_wakeup(dev)) + priv->wer = 0; + serial_out(up, UART_OMAP_WER, priv->wer); + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + flush_work(&priv->qos_work); return 0; } @@ -1403,6 +1412,8 @@ static int omap8250_runtime_suspend(struct device *dev) /* Restore to UART mode after reset (for wakeup) */ omap8250_update_mdr1(up, priv); + /* Restore wakeup enable register */ + serial_out(up, UART_OMAP_WER, priv->wer); } if (up->dma && up->dma->rxchan)