From patchwork Tue Aug 8 13:48:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 9888331 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 9D44E60384 for ; Tue, 8 Aug 2017 13:50:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F2A9288BC for ; Tue, 8 Aug 2017 13:50:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8404928915; Tue, 8 Aug 2017 13:50:45 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 19AD2288BC for ; Tue, 8 Aug 2017 13:50:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=0X8IgQhd4ITFXgijGzmHrBvRWyjNTHvildsDFR71664=; b=OL2rR+IeIP1qLZUSN4PsQkxdXR rbLxKswr7kQW6qnamib352ejCxJarsVMyrjOeSuR5RR84jU+OAuqCNeFwi9yWUK7qayz0s52FaaK9 +iYwV84y9h5K5SO5Wp/tLc3oX8JRIlV1FtYKpVy5AmjNMgeTzwd7W/fgt07CH5I0Nqd8r+nXnEgdM jfXehnUf7Rnp00em713q7LubgKAarDFeiqRPuQvIit/t3+lBB701pTHHN3YK3jOTPtgmWY//5s4NL AZOJCN4JcNMtJDdC8ASPJXLwkHBEue8UBCI0nWS9uDTbkNSUojFdwJ7Pg20OvZwIDNDmLUz1HDhSr Shv3mqGQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1df4u9-00083v-4q; Tue, 08 Aug 2017 13:50:41 +0000 Received: from conuserg-09.nifty.com ([210.131.2.76]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1df4to-0006ay-Ef for linux-arm-kernel@lists.infradead.org; Tue, 08 Aug 2017 13:50:22 +0000 Received: from localhost.localdomain (pw126245200194.16.panda-world.ne.jp [126.245.200.194]) (authenticated) by conuserg-09.nifty.com with ESMTP id v78DnDnu010873; Tue, 8 Aug 2017 22:49:17 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com v78DnDnu010873 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1502200157; bh=xdPYMkMtaSewvzrB0y6L1L44gKdUsJ1mnpYecjdJ9iM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xGK7CCxUNdHopNLhO8rs1d8y45UNagLpdo6kU0UiiedvOHg5xn+f2f4P56yBBgrhr a3nN2mjCQk2B9ytMTiqWV+NZ1D1EkahSDYePfuDqekBo9Wz1ZMu33xhNEsK+DaP27L TjO17qA39V+NNPRQ3SlH5YaqI/+dbNk+7QS6snOad5m5VgWMd9DnAB87V72EcQyHsd 794tmmH1gVoa8KbAJCUkzCY7VZzC5LkFLuX9k+uNbzI+8s6tVO+ivotHAbjYshqVPF mmzY0LcvFliUlCg5P+zcY90lt4HBlAgDo5ZgDzDRAGwo/A+yenAYPn55qDQemmPJYx 1FR7/nVqMFtSQ== X-Nifty-SrcIP: [126.245.200.194] From: Masahiro Yamada To: linux-serial@vger.kernel.org Subject: [PATCH 3/3] serial: 8250_uniphier: add suspend/resume support Date: Tue, 8 Aug 2017 22:48:43 +0900 Message-Id: <1502200123-2558-4-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502200123-2558-1-git-send-email-yamada.masahiro@socionext.com> References: <1502200123-2558-1-git-send-email-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170808_065020_868753_0FD1C367 X-CRM114-Status: UNSURE ( 9.55 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Masahiro Yamada , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Jassi Brar , Masami Hiramatsu , Jiri Slaby , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add suspend/resume support for UniPhier serial driver. Signed-off-by: Masahiro Yamada --- drivers/tty/serial/8250/8250_uniphier.c | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/tty/serial/8250/8250_uniphier.c b/drivers/tty/serial/8250/8250_uniphier.c index 97a45b798fcd..8a10b10e27aa 100644 --- a/drivers/tty/serial/8250/8250_uniphier.c +++ b/drivers/tty/serial/8250/8250_uniphier.c @@ -281,6 +281,40 @@ static int uniphier_uart_remove(struct platform_device *pdev) return 0; } +static int __maybe_unused uniphier_uart_suspend(struct device *dev) +{ + struct uniphier8250_priv *priv = dev_get_drvdata(dev); + struct uart_8250_port *up = serial8250_get_port(priv->line); + + serial8250_suspend_port(priv->line); + + if (!uart_console(&up->port) || console_suspend_enabled) + clk_disable_unprepare(priv->clk); + + return 0; +} + +static int __maybe_unused uniphier_uart_resume(struct device *dev) +{ + struct uniphier8250_priv *priv = dev_get_drvdata(dev); + struct uart_8250_port *up = serial8250_get_port(priv->line); + int ret; + + if (!uart_console(&up->port) || console_suspend_enabled) { + ret = clk_prepare_enable(priv->clk); + if (ret) + return ret; + } + + serial8250_resume_port(priv->line); + + return 0; +} + +static const struct dev_pm_ops uniphier_uart_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(uniphier_uart_suspend, uniphier_uart_resume) +}; + static const struct of_device_id uniphier_uart_match[] = { { .compatible = "socionext,uniphier-uart" }, { /* sentinel */ } @@ -293,6 +327,7 @@ static struct platform_driver uniphier_uart_platform_driver = { .driver = { .name = "uniphier-uart", .of_match_table = uniphier_uart_match, + .pm = &uniphier_uart_pm_ops, }, }; module_platform_driver(uniphier_uart_platform_driver);