From patchwork Tue Mar 27 12:02:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vignesh Raghavendra X-Patchwork-Id: 10309773 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 F0C556037D for ; Tue, 27 Mar 2018 12:02:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C64752845E for ; Tue, 27 Mar 2018 12:02:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB03329D1E; Tue, 27 Mar 2018 12:02:07 +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 0FA192845E for ; Tue, 27 Mar 2018 12:02:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751205AbeC0MCE (ORCPT ); Tue, 27 Mar 2018 08:02:04 -0400 Received: from fllnx210.ext.ti.com ([198.47.19.17]:58252 "EHLO fllnx210.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750898AbeC0MCD (ORCPT ); Tue, 27 Mar 2018 08:02:03 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id w2RC1unj010468; Tue, 27 Mar 2018 07:01:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1522152116; bh=vtA1BwZSUl3sAWQkdNiAb1t40STXPtrGKQmAUOGAwLs=; h=From:To:CC:Subject:Date; b=xeoxAHHr/K290oDBJy/64wFoX7d5Wsgo8hJY4zebBMS9Bu3TgkV0zfDXHxlttB2Vq breGq1725d1yQlnHkJrRoMZ1J5Zgu1y2gGpk6fC4BEgmOcfWfN+2J5v9IrdyEc0wHM sjPU3FuuqHrA/au5nQDhQKxkbMEsMb+nk9lt4VK0= Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w2RC1uGC002047; Tue, 27 Mar 2018 07:01:56 -0500 Received: from DFLE115.ent.ti.com (10.64.6.36) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Tue, 27 Mar 2018 07:01:56 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Tue, 27 Mar 2018 07:01:56 -0500 Received: from a0132425.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w2RC1r14005919; Tue, 27 Mar 2018 07:01:54 -0500 From: Vignesh R To: Greg Kroah-Hartman CC: Jiri Slaby , Tony Lindgren , Vignesh R , , , Subject: [PATCH] serial: 8250: omap: Provide ability to enable/disable UART as wakeup source Date: Tue, 27 Mar 2018 17:32:17 +0530 Message-ID: <20180327120217.4749-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 Signed-off-by: Vignesh R Tested-by: Tony Lindgren --- 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)