From patchwork Wed Oct 29 03:21:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alison Wang X-Patchwork-Id: 5183621 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7A837C11AC for ; Wed, 29 Oct 2014 03:25:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6D9A920176 for ; Wed, 29 Oct 2014 03:25:21 +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 3C24B20154 for ; Wed, 29 Oct 2014 03:25:20 +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 1XjJqg-0002y7-5E; Wed, 29 Oct 2014 03:23:02 +0000 Received: from mail-by2on0148.outbound.protection.outlook.com ([207.46.100.148] helo=na01-by2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XjJqd-0002wy-GE for linux-arm-kernel@lists.infradead.org; Wed, 29 Oct 2014 03:23:00 +0000 Received: from BY2PR03CA064.namprd03.prod.outlook.com (10.141.249.37) by BY2PR0301MB0631.namprd03.prod.outlook.com (25.160.63.11) with Microsoft SMTP Server (TLS) id 15.1.11.14; Wed, 29 Oct 2014 03:22:31 +0000 Received: from BN1BFFO11FD041.protection.gbl (2a01:111:f400:7c10::1:192) by BY2PR03CA064.outlook.office365.com (2a01:111:e400:2c5d::37) with Microsoft SMTP Server (TLS) id 15.1.6.9 via Frontend Transport; Wed, 29 Oct 2014 03:22:31 +0000 Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1BFFO11FD041.mail.protection.outlook.com (10.58.144.104) with Microsoft SMTP Server (TLS) id 15.0.1049.20 via Frontend Transport; Wed, 29 Oct 2014 03:22:31 +0000 Received: from titan.ap.freescale.net ([10.192.208.233]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id s9T3MLRV016091; Tue, 28 Oct 2014 20:22:23 -0700 From: Alison Wang To: , , , , , Subject: [PATCH] audio: sai: Add Power Management support Date: Wed, 29 Oct 2014 11:21:36 +0800 Message-ID: <1414552896-20797-1-git-send-email-b18965@freescale.com> X-Mailer: git-send-email 2.1.0.27.g96db324 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)(189002)(199003)(88136002)(2201001)(92566001)(87936001)(84676001)(92726001)(21056001)(93916002)(87286001)(104016003)(97736003)(33646002)(19580395003)(68736004)(19580405001)(4396001)(89996001)(6806004)(85852003)(85306004)(44976005)(50226001)(31966008)(50466002)(48376002)(50986999)(46102003)(26826002)(62966002)(80022003)(102836001)(99396003)(76482002)(104166001)(120916001)(47776003)(106466001)(20776003)(36756003)(95666004)(229853001)(77156001)(64706001)(107046002)(105606002)(42262002); DIR:OUT; SFP:1102; SCL:1; SRVR:BY2PR0301MB0631; H:tx30smr01.am.freescale.net; FPR:; MLV:ovrnspm; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:BY2PR0301MB0631; X-Forefront-PRVS: 03793408BA 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=alison.wang@freescale.com; X-OriginatorOrg: freescale.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141028_202259_628448_6FED71EF X-CRM114-Status: GOOD ( 10.99 ) X-Spam-Score: -0.0 (/) Cc: linux-kernel@vger.kernel.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.5 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 patch adds Power Management support for SAI. Activate regmap cache with REGCACHE_RBTREE, and use regmap cache code to save and restore registers in suspend and resume. The Transmit Control Register (TCSR) and Receive Control Register(RCSR) should be volatile registers. Signed-off-by: Alison Wang --- sound/soc/fsl/fsl_sai.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index 7eeb1dd..c7dd953 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -509,9 +509,11 @@ static bool fsl_sai_readable_reg(struct device *dev, unsigned int reg) static bool fsl_sai_volatile_reg(struct device *dev, unsigned int reg) { switch (reg) { + case FSL_SAI_TCSR: case FSL_SAI_TFR: - case FSL_SAI_RFR: case FSL_SAI_TDR: + case FSL_SAI_RCSR: + case FSL_SAI_RFR: case FSL_SAI_RDR: return true; default: @@ -553,6 +555,7 @@ static const struct regmap_config fsl_sai_regmap_config = { .readable_reg = fsl_sai_readable_reg, .volatile_reg = fsl_sai_volatile_reg, .writeable_reg = fsl_sai_writeable_reg, + .cache_type = REGCACHE_RBTREE, }; static int fsl_sai_probe(struct platform_device *pdev) @@ -668,6 +671,33 @@ static int fsl_sai_probe(struct platform_device *pdev) SND_DMAENGINE_PCM_FLAG_NO_RESIDUE); } +#ifdef CONFIG_PM_SLEEP +static int fsl_sai_suspend(struct device *dev) +{ + struct fsl_sai *sai = dev_get_drvdata(dev); + + regcache_cache_only(sai->regmap, true); + regcache_mark_dirty(sai->regmap); + + return 0; +} + +static int fsl_sai_resume(struct device *dev) +{ + struct fsl_sai *sai = dev_get_drvdata(dev); + + /* Restore all registers */ + regcache_cache_only(sai->regmap, false); + regcache_sync(sai->regmap); + + return 0; +}; +#endif /* CONFIG_PM_SLEEP */ + +static const struct dev_pm_ops fsl_sai_pm = { + SET_SYSTEM_SLEEP_PM_OPS(fsl_sai_suspend, fsl_sai_resume) +}; + static const struct of_device_id fsl_sai_ids[] = { { .compatible = "fsl,vf610-sai", }, { .compatible = "fsl,imx6sx-sai", }, @@ -680,6 +710,7 @@ static struct platform_driver fsl_sai_driver = { .name = "fsl-sai", .owner = THIS_MODULE, .of_match_table = fsl_sai_ids, + .pm = &fsl_sai_pm, }, }; module_platform_driver(fsl_sai_driver);