From patchwork Mon Apr 14 02:24:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongsheng Wang X-Patchwork-Id: 338807 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id BD4091402BA for ; Mon, 14 Apr 2014 12:27:10 +1000 (EST) Received: from ch1outboundpool.messaging.microsoft.com (ch1ehsobe004.messaging.microsoft.com [216.32.181.184]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3DF641400B5 for ; Mon, 14 Apr 2014 12:26:39 +1000 (EST) Received: from mail77-ch1-R.bigfish.com (10.43.68.237) by CH1EHSOBE014.bigfish.com (10.43.70.64) with Microsoft SMTP Server id 14.1.225.22; Mon, 14 Apr 2014 02:26:00 +0000 Received: from mail77-ch1 (localhost [127.0.0.1]) by mail77-ch1-R.bigfish.com (Postfix) with ESMTP id 6D472E01BE for ; Mon, 14 Apr 2014 02:26:00 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 6 X-BigFish: VS6(zzc8kzz1f42h2148h1ee6h1de0h1fdah2073h2146h1202h1e76h2189h1d1ah1d2ah21bch1fc6h208chzz1de098h8275bh1de097hz2dh2a8h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1b2fh2222h224fh1fb3h1d0ch1d2eh1d3fh1dc1h1dfeh1dffh1e23h1fe8h1ff5h2218h2216h226dh22d0h24afh2327h2336h2438h2461h2487h24d7h2516h2545h255eh25cch25f6h2605h268bh26d3h10bek1155h) Received: from mail77-ch1 (localhost.localdomain [127.0.0.1]) by mail77-ch1 (MessageSwitch) id 1397442358138022_8715; Mon, 14 Apr 2014 02:25:58 +0000 (UTC) Received: from CH1EHSMHS017.bigfish.com (snatpool1.int.messaging.microsoft.com [10.43.68.242]) by mail77-ch1.bigfish.com (Postfix) with ESMTP id 1202D18008D; Mon, 14 Apr 2014 02:25:58 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CH1EHSMHS017.bigfish.com (10.43.70.17) with Microsoft SMTP Server (TLS) id 14.16.227.3; Mon, 14 Apr 2014 02:25:58 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server (TLS) id 14.3.174.2; Mon, 14 Apr 2014 02:26:30 +0000 Received: from titan.am.freescale.net (udp143770uds.ap.freescale.net [10.192.208.233] (may be forged)) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id s3E2QRxN010945; Sun, 13 Apr 2014 19:26:28 -0700 From: Dongsheng Wang To: Subject: [PATCH 1/2] powerpc/mpc85xx: add two functions to get suspend state which is standby or mem Date: Mon, 14 Apr 2014 10:24:09 +0800 Message-ID: <1397442250-14886-1-git-send-email-dongsheng.wang@freescale.com> X-Mailer: git-send-email 1.8.5 MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% X-FOPE-CONNECTOR: Id%0$Dn%FREESCALE.MAIL.ONMICROSOFT.COM$RO%1$TLS%0$FQDN%$TlsDn% Cc: linuxppc-dev@lists.ozlabs.org, chenhui.zhao@freescale.com, jason.jin@freescale.com, Wang Dongsheng X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Wang Dongsheng Add set_pm_suspend_state & pm_suspend_state functions to set/get suspend state. When system going to sleep, devices can get the system suspend state(STANDBY/MEM) through pm_suspend_state function and handle different situations. Signed-off-by: Wang Dongsheng diff --git a/arch/powerpc/platforms/85xx/common.c b/arch/powerpc/platforms/85xx/common.c index b564b5e..3853d43 100644 --- a/arch/powerpc/platforms/85xx/common.c +++ b/arch/powerpc/platforms/85xx/common.c @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -47,6 +48,19 @@ int __init mpc85xx_common_publish_devices(void) { return of_platform_bus_probe(NULL, mpc85xx_common_ids, NULL); } + +static suspend_state_t pm_state; + +void set_pm_suspend_state(suspend_state_t state) +{ + pm_state = state; +} + +suspend_state_t pm_suspend_state(void) +{ + return pm_state; +} + #ifdef CONFIG_CPM2 static void cpm2_cascade(unsigned int irq, struct irq_desc *desc) { diff --git a/arch/powerpc/sysdev/fsl_pmc.c b/arch/powerpc/sysdev/fsl_pmc.c index 8cf4aa0..0b34c00 100644 --- a/arch/powerpc/sysdev/fsl_pmc.c +++ b/arch/powerpc/sysdev/fsl_pmc.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -52,12 +53,20 @@ static int pmc_suspend_valid(suspend_state_t state) { if (state != PM_SUSPEND_STANDBY) return 0; + + set_pm_suspend_state(state); return 1; } +static void pmc_suspend_end(void) +{ + set_pm_suspend_state(PM_SUSPEND_ON); +} + static const struct platform_suspend_ops pmc_suspend_ops = { .valid = pmc_suspend_valid, .enter = pmc_suspend_enter, + .end = pmc_suspend_end, }; static int pmc_probe(struct platform_device *ofdev) @@ -68,6 +77,7 @@ static int pmc_probe(struct platform_device *ofdev) pmc_dev = &ofdev->dev; suspend_set_ops(&pmc_suspend_ops); + set_pm_suspend_state(PM_SUSPEND_ON); return 0; } diff --git a/include/linux/fsl/fsl_pm.h b/include/linux/fsl/fsl_pm.h new file mode 100644 index 0000000..705ea52 --- /dev/null +++ b/include/linux/fsl/fsl_pm.h @@ -0,0 +1,25 @@ +/* + * include/linux/fsl/fsl_pm.h + * + * Definitions for any platform related flags or structures for Freescale + * Power Management. + * + * Author: Wang Dongsheng + * + * Copyright 2014 Freescale Semiconductor, Inc + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include + +#ifdef CONFIG_FSL_SOC_BOOKE +extern void set_pm_suspend_state(suspend_state_t state); +extern suspend_state_t pm_suspend_state(void); +#else +static inline void set_pm_suspend_state(suspend_state_t state) { } +static inline suspend_state_t pm_suspend_state(void) { } +#endif