From patchwork Thu Apr 24 06:11:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongsheng Wang X-Patchwork-Id: 342090 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 AAD4614017B for ; Thu, 24 Apr 2014 16:15:02 +1000 (EST) Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1lp0141.outbound.protection.outlook.com [207.46.163.141]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id AEF4F140086 for ; Thu, 24 Apr 2014 16:14:29 +1000 (EST) Received: from DM2PR03CA005.namprd03.prod.outlook.com (10.141.52.153) by DM2PR03MB397.namprd03.prod.outlook.com (10.141.84.139) with Microsoft SMTP Server (TLS) id 15.0.921.12; Thu, 24 Apr 2014 06:14:15 +0000 Received: from BN1BFFO11FD013.protection.gbl (2a01:111:f400:7c10::1:159) by DM2PR03CA005.outlook.office365.com (2a01:111:e400:2414::25) with Microsoft SMTP Server (TLS) id 15.0.929.12 via Frontend Transport; Thu, 24 Apr 2014 06:14:15 +0000 Received: from az84smr01.freescale.net (192.88.158.246) by BN1BFFO11FD013.mail.protection.outlook.com (10.58.144.76) with Microsoft SMTP Server (TLS) id 15.0.929.8 via Frontend Transport; Thu, 24 Apr 2014 06:14:14 +0000 Received: from titan.ap.freescale.net (udp143770uds.ap.freescale.net [10.192.208.233] (may be forged)) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id s3O6E90h028240; Wed, 23 Apr 2014 23:14:11 -0700 From: Dongsheng Wang To: , Subject: [PATCH v2 1/2] powerpc/pm: add api to get suspend state which is STANDBY or MEM Date: Thu, 24 Apr 2014 14:11:48 +0800 Message-ID: <1398319908-30166-1-git-send-email-dongsheng.wang@freescale.com> X-Mailer: git-send-email 1.8.5 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.158.246; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009001)(6009001)(428001)(189002)(199002)(92726001)(36756003)(85852003)(87286001)(92566001)(33646001)(79102001)(74502001)(74662001)(31966008)(80022001)(50986999)(93916002)(87936001)(81542001)(19580395003)(6806004)(80976001)(86362001)(88136002)(46102001)(62966002)(4396001)(89996001)(77156001)(50226001)(47776003)(83072002)(50466002)(81342001)(77982001)(20776003)(83322001)(77096999)(19580405001)(44976005)(48376002)(76482001)(99396002)(2004002)(42866002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR03MB397; H:az84smr01.freescale.net; FPR:E0A674D6.2B149E5D.C0C3325F.48C8D243.2035E; MLV:sfv; PTR:gate-az5.freescale.com; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Forefront-PRVS: 01917B1794 Received-SPF: None (: freescale.com does not designate permitted sender hosts) X-OriginatorOrg: freescale.com 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 or deep sleep, devices can get the system suspend state(STANDBY/MEM) through pm_suspend_state function and to handle different situations. Signed-off-by: Wang Dongsheng --- *v2* Move pm api from fsl platform to powerpc general framework. diff --git a/arch/powerpc/include/asm/pm.h b/arch/powerpc/include/asm/pm.h new file mode 100644 index 0000000..00ddbf1 --- /dev/null +++ b/arch/powerpc/include/asm/pm.h @@ -0,0 +1,26 @@ +/* + * asm/pm.h + * + * Definitions for any platform related flags or structures for + * 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. + */ + +#ifndef _POWERPC_PM_H_ +#define _POWERPC_PM_H_ +#ifdef __KERNEL__ +#include + +extern void set_pm_suspend_state(suspend_state_t state); +extern suspend_state_t pm_suspend_state(void); + +#endif /* __KERNEL__ */ +#endif /* _POWERPC_PM_H_ */ diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile index fcc9a89..2060145 100644 --- a/arch/powerpc/kernel/Makefile +++ b/arch/powerpc/kernel/Makefile @@ -28,7 +28,7 @@ endif obj-y := cputable.o ptrace.o syscalls.o \ irq.o align.o signal_32.o pmc.o vdso.o \ - process.o systbl.o idle.o \ + process.o systbl.o idle.o pm.o \ signal.o sysfs.o cacheinfo.o time.o \ prom.o traps.o setup-common.o \ udbg.o misc.o io.o dma.o \ diff --git a/arch/powerpc/kernel/pm.c b/arch/powerpc/kernel/pm.c new file mode 100644 index 0000000..23d3c94 --- /dev/null +++ b/arch/powerpc/kernel/pm.c @@ -0,0 +1,26 @@ +/* + * PowerPC General Power Management Implementation + * + * Copyright 2014 Freescale Semiconductor, Inc. + * Author: Wang Dongsheng + * + * 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 +#include + +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; +} diff --git a/arch/powerpc/sysdev/fsl_pmc.c b/arch/powerpc/sysdev/fsl_pmc.c index 8cf4aa0..fd777ca 100644 --- a/arch/powerpc/sysdev/fsl_pmc.c +++ b/arch/powerpc/sysdev/fsl_pmc.c @@ -21,6 +21,8 @@ #include #include +#include + struct pmc_regs { __be32 devdisr; __be32 devdisr2; @@ -52,12 +54,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 +78,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; }