From patchwork Tue Nov 11 07:09:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingchang Lu X-Patchwork-Id: 5271121 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 920C39F387 for ; Tue, 11 Nov 2014 08:03:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8F81320142 for ; Tue, 11 Nov 2014 08:03:55 +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 42AF7200EC for ; Tue, 11 Nov 2014 08:03:54 +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 1Xo6OE-0005Hc-3X; Tue, 11 Nov 2014 08:01:26 +0000 Received: from mail-bn1bbn0103.outbound.protection.outlook.com ([157.56.111.103] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xo6OA-0005G0-QG for linux-arm-kernel@lists.infradead.org; Tue, 11 Nov 2014 08:01:24 +0000 Received: from CY1PR0301MB1241.namprd03.prod.outlook.com (25.161.212.151) by CY1PR0301MB0681.namprd03.prod.outlook.com (25.160.158.151) with Microsoft SMTP Server (TLS) id 15.1.11.14; Tue, 11 Nov 2014 08:00:59 +0000 Received: from BY2PR03CA074.namprd03.prod.outlook.com (10.141.249.47) by CY1PR0301MB1241.namprd03.prod.outlook.com (25.161.212.151) with Microsoft SMTP Server (TLS) id 15.1.11.14; Tue, 11 Nov 2014 08:00:58 +0000 Received: from BL2FFO11FD047.protection.gbl (2a01:111:f400:7c09::190) by BY2PR03CA074.outlook.office365.com (2a01:111:e400:2c5d::47) with Microsoft SMTP Server (TLS) id 15.1.16.15 via Frontend Transport; Tue, 11 Nov 2014 08:00:57 +0000 Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11FD047.mail.protection.outlook.com (10.173.161.209) with Microsoft SMTP Server (TLS) id 15.1.6.13 via Frontend Transport; Tue, 11 Nov 2014 08:00:57 +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 sAB80oUZ015341; Tue, 11 Nov 2014 01:00:51 -0700 From: Jingchang Lu To: Subject: [RESEND] serial: of-serial: add PM suspend/resume support Date: Tue, 11 Nov 2014 15:09:05 +0800 Message-ID: <1415689745-28572-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:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(199003)(189002)(50466002)(106466001)(31966008)(2351001)(105606002)(48376002)(107046002)(229853001)(93916002)(62966003)(102836001)(95666004)(77156002)(46102003)(92726001)(64706001)(86362001)(92566001)(36756003)(120916001)(20776003)(47776003)(99396003)(87286001)(84676001)(89996001)(97736003)(50986999)(68736004)(110136001)(44976005)(19580395003)(21056001)(88136002)(6806004)(19580405001)(4396001)(50226001)(104016003)(104166001)(33646002)(87936001); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR0301MB1241; H:tx30smr01.am.freescale.net; FPR:; MLV:sfv; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: UriScan:;UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1241; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA: BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1241; X-Forefront-PRVS: 0392679D18 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-Exchange-Antispam-Report-CFA: BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1241; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB0681; X-OriginatorOrg: freescale.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141111_000123_123146_DD26892C X-CRM114-Status: GOOD ( 11.42 ) X-Spam-Score: -0.0 (/) Cc: f.fainelli@gmail.com, peter@hurleysoftware.com, arnd@arndb.de, Jingchang Lu , linux-serial@vger.kernel.org, josephl@nvidia.com, 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=-3.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham 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 suspend/resume support for the of-serial driver to provide power management support on devices attatched. The handling may vary since not every of_serial device is an 8250 port. Currently only 8250 port handling is added in the suspend/resume function based on the type switch. Signed-off-by: Jingchang Lu Acked-by: Arnd Bergmann Tested-by: Joseph Lo Reviewed-by: Peter Hurley Tested-by: Florina Fainelli --- This patch merges the two pervious accepted patches into one to make things clearly: commit 2dea53bf57783f243c892e99c10c6921e956aa7e serial: of-serial: add PM suspend/resume support commit 513e438581020334e0345561adeeeaefa36701be serial: of-serial: fix up PM ops on no_console_suspend and port type The first has a bug that causes a hardware hang on register access if no_console_suspend command line option used, also lack of disnguishing the port type. Then there is the second one. The first has entered 3.18-rc but the second not, and both have entered linux-next tree, so please drop them first to apply this one. Thanks. drivers/tty/serial/of_serial.c | 66 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c index e60b59f..f66d814 100644 --- a/drivers/tty/serial/of_serial.c +++ b/drivers/tty/serial/of_serial.c @@ -9,6 +9,7 @@ * 2 of the License, or (at your option) any later version. * */ +#include #include #include #include @@ -251,6 +252,70 @@ static int of_platform_serial_remove(struct platform_device *ofdev) return 0; } +#ifdef CONFIG_PM_SLEEP +#ifdef CONFIG_SERIAL_8250 +static void of_serial_suspend_8250(struct of_serial_info *info) +{ + struct uart_8250_port *port8250 = serial8250_get_port(info->line); + struct uart_port *port = &port8250->port; + + serial8250_suspend_port(info->line); + if (info->clk && (!uart_console(port) || console_suspend_enabled)) + clk_disable_unprepare(info->clk); +} + +static void of_serial_resume_8250(struct of_serial_info *info) +{ + struct uart_8250_port *port8250 = serial8250_get_port(info->line); + struct uart_port *port = &port8250->port; + + if (info->clk && (!uart_console(port) || console_suspend_enabled)) + clk_prepare_enable(info->clk); + + serial8250_resume_port(info->line); +} +#else +static inline void of_serial_suspend_8250(struct of_serial_info *info) +{ +} + +static inline void of_serial_resume_8250(struct of_serial_info *info) +{ +} +#endif + +static int of_serial_suspend(struct device *dev) +{ + struct of_serial_info *info = dev_get_drvdata(dev); + + switch (info->type) { + case PORT_8250 ... PORT_MAX_8250: + of_serial_suspend_8250(info); + break; + default: + break; + } + + return 0; +} + +static int of_serial_resume(struct device *dev) +{ + struct of_serial_info *info = dev_get_drvdata(dev); + + switch (info->type) { + case PORT_8250 ... PORT_MAX_8250: + of_serial_resume_8250(info); + break; + default: + break; + } + + 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. */ @@ -282,6 +347,7 @@ static struct platform_driver of_platform_serial_driver = { .driver = { .name = "of_serial", .of_match_table = of_platform_serial_table, + .pm = &of_serial_pm_ops, }, .probe = of_platform_serial_probe, .remove = of_platform_serial_remove,