From patchwork Tue Sep 23 08:34:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingchang Lu X-Patchwork-Id: 4954521 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1DA779F348 for ; Tue, 23 Sep 2014 09:30:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4C389201FA for ; Tue, 23 Sep 2014 09:30:09 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 065C4201D3 for ; Tue, 23 Sep 2014 09:30:08 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XWMO8-0000oL-9V; Tue, 23 Sep 2014 09:28:00 +0000 Received: from mail-bl2on0139.outbound.protection.outlook.com ([65.55.169.139] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XWMO4-0000eP-WF for linux-arm-kernel@lists.infradead.org; Tue, 23 Sep 2014 09:27:57 +0000 Received: from CO2PR03CA0017.namprd03.prod.outlook.com (10.141.194.144) by BY2PR03MB473.namprd03.prod.outlook.com (10.141.141.143) with Microsoft SMTP Server (TLS) id 15.0.1034.13; Tue, 23 Sep 2014 09:27:32 +0000 Received: from BL2FFO11FD040.protection.gbl (2a01:111:f400:7c09::103) by CO2PR03CA0017.outlook.office365.com (2a01:111:e400:1414::16) with Microsoft SMTP Server (TLS) id 15.0.1034.13 via Frontend Transport; Tue, 23 Sep 2014 09:27:32 +0000 Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11FD040.mail.protection.outlook.com (10.173.161.136) with Microsoft SMTP Server (TLS) id 15.0.1029.15 via Frontend Transport; Tue, 23 Sep 2014 09:27:31 +0000 Received: from rock.ap.freescale.net (rock.ap.freescale.net [10.193.20.106]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id s8N9RQ50015719; Tue, 23 Sep 2014 02:27:27 -0700 From: Jingchang Lu To: Subject: [PATCH] serial: of-serial: add PM suspend/resume support Date: Tue, 23 Sep 2014 16:34:12 +0800 Message-ID: <1411461252-8730-1-git-send-email-jingchang.lu@freescale.com> X-Mailer: git-send-email 1.8.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:CAL; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(199003)(189002)(2351001)(92726001)(106466001)(92566001)(90102001)(26826002)(102836001)(229853001)(50466002)(76482002)(95666004)(97736003)(36756003)(107046002)(50226001)(10300001)(104016003)(4396001)(93916002)(62966002)(21056001)(64706001)(105606002)(79102003)(80022003)(81342003)(83322001)(50986999)(85852003)(74662003)(81542003)(46102003)(77982003)(110136001)(99396002)(77156001)(68736004)(31966008)(44976005)(89996001)(19580405001)(33646002)(83072002)(88136002)(85306004)(20776003)(74502003)(84676001)(86362001)(87936001)(120916001)(19580395003)(6806004)(48376002)(47776003)(104166001)(87286001); DIR:OUT; SFP:1102; SCL:1; SRVR:BY2PR03MB473; H:tx30smr01.am.freescale.net; FPR:; MLV:ovrnspm; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB473; X-Forefront-PRVS: 0343AC1D30 Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=jingchang.lu@freescale.com; X-OriginatorOrg: freescale.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140923_022757_236015_FFC7642C X-CRM114-Status: UNSURE ( 8.57 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) Cc: devicetree@vger.kernel.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Jingchang Lu , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This adds PM suspend/resume support for the of-serial driver to provide power management support on devices attatched to it. Signed-off-by: Jingchang Lu Acked-by: Arnd Bergmann --- drivers/tty/serial/of_serial.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c index 27981e2..8bc2563 100644 --- a/drivers/tty/serial/of_serial.c +++ b/drivers/tty/serial/of_serial.c @@ -240,6 +240,32 @@ static int of_platform_serial_remove(struct platform_device *ofdev) return 0; } +#ifdef CONFIG_PM_SLEEP +static int of_serial_suspend(struct device *dev) +{ + struct of_serial_info *info = dev_get_drvdata(dev); + + serial8250_suspend_port(info->line); + if (info->clk) + clk_disable_unprepare(info->clk); + + return 0; +} + +static int of_serial_resume(struct device *dev) +{ + struct of_serial_info *info = dev_get_drvdata(dev); + + if (info->clk) + clk_prepare_enable(info->clk); + + serial8250_resume_port(info->line); + + return 0; +} +#endif +static SIMPLE_DEV_PM_OPS(of_serial_pm_ops, of_serial_suspend, of_serial_resume); + /* * A few common types, add more as needed. */ @@ -271,6 +297,7 @@ static struct platform_driver of_platform_serial_driver = { .name = "of_serial", .owner = THIS_MODULE, .of_match_table = of_platform_serial_table, + .pm = &of_serial_pm_ops, }, .probe = of_platform_serial_probe, .remove = of_platform_serial_remove,