From patchwork Sun Oct 7 07:27:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Christophe PLAGNIOL-VILLARD X-Patchwork-Id: 1560831 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 71F7E3FC1A for ; Sun, 7 Oct 2012 08:08:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752012Ab2JGII1 (ORCPT ); Sun, 7 Oct 2012 04:08:27 -0400 Received: from 16.mo1.mail-out.ovh.net ([178.33.104.224]:44911 "EHLO mo1.mail-out.ovh.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751971Ab2JGIIS (ORCPT ); Sun, 7 Oct 2012 04:08:18 -0400 X-Greylist: delayed 2301 seconds by postgrey-1.27 at vger.kernel.org; Sun, 07 Oct 2012 04:08:17 EDT Received: from mail625.ha.ovh.net (b7.ovh.net [213.186.33.57]) by mo1.mail-out.ovh.net (Postfix) with SMTP id 637C4FFB051 for ; Sun, 7 Oct 2012 09:39:09 +0200 (CEST) Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 7 Oct 2012 09:29:54 +0200 Received: from ns32433.ovh.net (HELO localhost) (plagnioj%jcrosoft.com@213.251.161.87) by ns0.ovh.net with SMTP; 7 Oct 2012 09:29:52 +0200 From: Jean-Christophe PLAGNIOL-VILLARD To: linux-arm-kernel@lists.infradead.org Cc: Jean-Christophe PLAGNIOL-VILLARD , Nicolas Ferre , linux-pm@vger.kernel.org, linux-serial@vger.kernel.org X-Ovh-Mailout: 178.32.228.1 (mo1.mail-out.ovh.net) Subject: [PATCH 3/6] tty: atmel_serial: switch pm ops Date: Sun, 7 Oct 2012 09:27:17 +0200 Message-Id: <1349594840-11374-3-git-send-email-plagnioj@jcrosoft.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1349594840-11374-1-git-send-email-plagnioj@jcrosoft.com> References: <20121006161429.GD12462@game.jcrosoft.org> <1349594840-11374-1-git-send-email-plagnioj@jcrosoft.com> X-Ovh-Tracer-Id: 3418232118546050045 X-Ovh-Remote: 213.251.161.87 (ns32433.ovh.net) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-OVH-SPAMSTATE: OK X-OVH-SPAMSCORE: -100 X-OVH-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeehuddrudduucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfhrhhomheplfgvrghnqdevhhhrihhsthhophhhvgcurffntefipffkqffnqdggkffnnfettfffuceophhlrghgnhhiohhjsehjtghrohhsohhfthdrtghomheqnecujfgurhephffvufffkffojghfsedttdertdertddt X-Spam-Check: DONE|U 0.5/N X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeehuddrudduucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfhrhhomheplfgvrghnqdevhhhrihhsthhophhhvgcurffntefipffkqffnqdggkffnnfettfffuceophhlrghgnhhiohhjsehjtghrohhsohhfthdrtghomheqnecujfgurhephffvufffkffojghfsedttdertdertddt Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org so we can detect when we enter in slow_clock mode and drop at91_suspend_entering_slow_clock Cc: Nicolas Ferre Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD Cc: linux-pm@vger.kernel.org Cc: linux-serial@vger.kernel.org --- drivers/tty/serial/atmel_serial.c | 52 +++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index 3d7e1ee..7a51a0c 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c @@ -1720,20 +1720,10 @@ static struct uart_driver atmel_uart = { }; #ifdef CONFIG_PM -static bool atmel_serial_clk_will_stop(void) +static int atmel_serial_suspend(struct device *dev, int slow_clock) { -#ifdef CONFIG_ARCH_AT91 - return at91_suspend_entering_slow_clock(); -#else - return false; -#endif -} - -static int atmel_serial_suspend(struct platform_device *pdev, - pm_message_t state) -{ - struct uart_port *port = platform_get_drvdata(pdev); - struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); + struct atmel_uart_port *atmel_port = dev_get_drvdata(dev); + struct uart_port *port = &atmel_port->uart; if (atmel_is_console_port(port) && console_suspend_enabled) { /* Drain the TX shifter */ @@ -1742,30 +1732,43 @@ static int atmel_serial_suspend(struct platform_device *pdev, } /* we can not wake up if we're running on slow clock */ - atmel_port->may_wakeup = device_may_wakeup(&pdev->dev); - if (atmel_serial_clk_will_stop()) - device_set_wakeup_enable(&pdev->dev, 0); + atmel_port->may_wakeup = device_may_wakeup(dev); + if (slow_clock) + device_set_wakeup_enable(dev, 0); uart_suspend_port(&atmel_uart, port); return 0; } -static int atmel_serial_resume(struct platform_device *pdev) +static int atmel_serial_suspend_standby(struct device *dev) { - struct uart_port *port = platform_get_drvdata(pdev); - struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); + return atmel_serial_suspend(dev, 0); +} + +static int atmel_serial_suspend_mem(struct device *dev) +{ + return atmel_serial_suspend(dev, 1); +} + +static int atmel_serial_resume(struct device *dev) +{ + struct atmel_uart_port *atmel_port = dev_get_drvdata(dev); + struct uart_port *port = &atmel_port->uart; uart_resume_port(&atmel_uart, port); - device_set_wakeup_enable(&pdev->dev, atmel_port->may_wakeup); + device_set_wakeup_enable(dev, atmel_port->may_wakeup); return 0; } -#else -#define atmel_serial_suspend NULL -#define atmel_serial_resume NULL #endif +static struct dev_pm_ops atmel_serial_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(atmel_serial_suspend_standby, atmel_serial_resume) + SET_SYSTEM_SLEEP_STANDBY_MEM_PM_OPS(atmel_serial_suspend_standby, + atmel_serial_suspend_mem) +}; + static int __devinit atmel_serial_probe(struct platform_device *pdev) { struct atmel_uart_port *port; @@ -1877,11 +1880,10 @@ static int __devexit atmel_serial_remove(struct platform_device *pdev) static struct platform_driver atmel_serial_driver = { .probe = atmel_serial_probe, .remove = __devexit_p(atmel_serial_remove), - .suspend = atmel_serial_suspend, - .resume = atmel_serial_resume, .driver = { .name = "atmel_usart", .owner = THIS_MODULE, + .pm = &atmel_serial_pm_ops, .of_match_table = of_match_ptr(atmel_serial_dt_ids), }, };