From patchwork Mon Sep 14 09:03:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alison Wang X-Patchwork-Id: 7174071 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 89D67BEEC1 for ; Mon, 14 Sep 2015 09:11:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9E747205EE for ; Mon, 14 Sep 2015 09:11:34 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C3796205E2 for ; Mon, 14 Sep 2015 09:11:33 +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 1ZbPli-0006NQ-Ud; Mon, 14 Sep 2015 09:09:46 +0000 Received: from mail-bn1on0112.outbound.protection.outlook.com ([157.56.110.112] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZbPlb-00061m-Kq for linux-arm-kernel@lists.infradead.org; Mon, 14 Sep 2015 09:09:40 +0000 Received: from BN3PR0301CA0018.namprd03.prod.outlook.com (10.160.180.156) by CY1PR0301MB1308.namprd03.prod.outlook.com (10.161.212.18) with Microsoft SMTP Server (TLS) id 15.1.262.15; Mon, 14 Sep 2015 09:09:17 +0000 Received: from BN1AFFO11FD052.protection.gbl (2a01:111:f400:7c10::193) by BN3PR0301CA0018.outlook.office365.com (2a01:111:e400:4000::28) with Microsoft SMTP Server (TLS) id 15.1.268.17 via Frontend Transport; Mon, 14 Sep 2015 09:09:16 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; freescale.mail.onmicrosoft.com; dmarc=none action=none header.from=freescale.com; Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BN1AFFO11FD052.mail.protection.outlook.com (10.58.53.67) with Microsoft SMTP Server (TLS) id 15.1.262.18 via Frontend Transport; Mon, 14 Sep 2015 09:09:16 +0000 Received: from titan.ap.freescale.net ([10.192.208.233]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t8E99CZF000487; Mon, 14 Sep 2015 02:09:13 -0700 From: Alison Wang To: , , , , , , Subject: [PATCH v2] audio: sai: Add Power Management support Date: Mon, 14 Sep 2015 17:03:24 +0800 Message-ID: <1442221404-35240-1-git-send-email-b18965@freescale.com> X-Mailer: git-send-email 2.1.0.27.g96db324 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD052; 1:DlFwHS4GeJc0bunxqq6h0Vwu2ed9NeCTrtGSAC4o/ZYLRx2HXplX5iGUj3MiWcdnlTcfjtwjPSlPFK72pG+iPSYlRVHwDJj3ra3x+biQXe7pP3XHtalO5wCNAwVws6nx4Z4sP/BNKAOrp5X6N5ZJNQgBHMPCPqkYcSbXhy870LF20UURLeYZSX2CmUXdF+JvTyHmBlXJFkcf0tDotpGVuhF5BwQlnbLv32+wdG4p0p2RtRG21hz+e8lEiz3douUgsTSKfXBexHHfWL0CoX/6wjFsRI91CAfdvb5RnJoqUFJAGqsLJ7jWTZovzqZXeebF4b2FaUqm5ipjdcDFHoE8AnP5i3aFEvNB7YOYHSxaOTnD9WaXfWe/5nD+NNlw43cBkD/b/prjnqXpxUCKzjLBkg== X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(33646002)(107886002)(189998001)(5003940100001)(85426001)(81156007)(5001830100001)(97736004)(4001540100001)(5001860100001)(50226001)(5001770100001)(6806004)(69596002)(19580405001)(19580395003)(87936001)(47776003)(77156002)(64706001)(62966003)(92566002)(48376002)(68736005)(106466001)(104016003)(77096005)(5001960100002)(50986999)(229853001)(105606002)(46102003)(5007970100001)(11100500001)(50466002)(36756003)(2201001)(4001430100001)(2101003)(42262002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR0301MB1308; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1308; 2:ELNCCPz4+DLVqeG7oESAqSZMPp9JVKtPs5Z7HZ5uPzuYAD86a5ZThBc6R7wuu4YcDQCR5MHBuNLY5Uq6wzZz5ZFbQePMobbevoTpHBQ7NQ4H06D2+MtvD4B8NYl4eOQtg90RNvCj2qHP13DdZiWmuIt7yIZ4ZN3U0y4JRY93zUI=; 3:RjFdnR6V7RCy9yiA6UfiVvK3aoHQaJT1v25oxMcc2UqMani6y82e41vJRR+32KlFyeGwWrDKTxL5X7xBd5YYL7AQ+23FgU6UXvu0kr+SDFDbjnCLytx11O2+ntYCpZurQJqgRYcQlXI1GCwuiw9fVEV0B/p+2uZU0D/+EvtmDAkkyQwm1heQwx9Qjv6Hoh/lqEKxo9CgiWEILO27+iYD+08IMequxqMvlxCBp27Hxnc=; 25:ar2/F0OoQAOHXwtrc4IsYbfRVMtnniAk4z4CqZN87dDSLjBVdHCwtQjaMrRWAG6oE+ZIcAjMkaw38SJHPeuzU9UIhcc14V5TmIedsyGbwyJ/awb6D7B5D67/g7USCJtVqQvLIK+4eDhkkCaQEe4swJrvb+sGVQvC8G2TLNOmdn7wFbuspw/rHe/gXsi6UuQJ1QKz+JoOfn3SQ9ZpKBh/a6dQnTEO+TrRaPK+Gt5lwMQ3oP8N0Aj3206yLzw4rktHVkHCJUCaGYeFY1csiapBZg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1308; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1308; 20:3tu1vF/XUoki2hAxm6UF1qns8ZPmknPC+F3re3xGoAzOo2kuCmSXaHRi94UDU0gP0KbUQxRJa73eG4aEsW7Gt2neWbBouS9VM+1tJjqTr6Gqb5KmHUr4XCZ77kSBUe5ssLzmOgvbq2gwaBX2JjyseSOFDu14uCnijeffqbC2fyIM8Fuab07pxrq5JGE1RY40Ryr6tuihzmBuzpcB9SXkFJe3HkZUK2Vs4RiBBkKWQBk42fz1DvY8/7wXfc2SIb24fXzVxx1C6b2Fk0kdvjgPo02W63Xmbb4uJhNXNfOx83WsInLgRC2OjfgLBUKVxN7S56i79s8rESYizVaa/EmyM9d8+VTdzrFwdmuRLZ7ZCqU=; 4:j3WoqSkYaTd+AzGD781pyE0jCy/2N3LH6w0f1oADI6/acru6qSdctACaZDQZxULtIE3bmH3QpcSou7usNpoGykF1Xyd0B0C54FS8ZscY+y5cejE8Df/+N/aDu8Q+xh0pJ+6k7Jnpw9bU4e+UZvZbmfV1ktfs9FemT3lQ5f/poTKaW4UtT/PDnXL5TVO8PaGW09C521js0ZduCGyuB9uGlNeiQ7aZo+9LH0gqPcKOZk9m94p6DQSD+FTsWG/QbrwRe0k/OPO41VEMlWZrdTzsUB4DEZ4vRatc/MDO1aDFySqjs1wAV/TT+ih/JhSfWCtI X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(8121501046)(3002001); SRVR:CY1PR0301MB1308; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0301MB1308; X-Forefront-PRVS: 0699FCD394 X-Microsoft-Exchange-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GozGyWMcld5VSVjIvTOT1d1QPtr9?= =?us-ascii?Q?cTYkoc4mSXztVRFoqm/F+OmDvGBOXTzQaNz/CBo6NItUY9usZ1ogLcBQG2rJ?= =?us-ascii?Q?dA45lM1Yhs2vuG7Lbgr8WfRWdyBSgDBj+JNIcmxeGwV069w/EeF6xnStBA6+?= =?us-ascii?Q?KPFIFXg2kfUvODv+ZDIEgDfwJsswdy6V3XrwABIwSVtQuhRP5jhs4PM6xr7R?= =?us-ascii?Q?KyjZPi25ny43YIa/6i/urUvUE46/YM7VgWQl/j4maxv0jilZPVeTaYOfEFd1?= =?us-ascii?Q?zwDu4O8XF/fui1JCsrhG6Vt9JcILMIVQA0lZfXvEPQQyCFHimNGhHN9R6khf?= =?us-ascii?Q?BVYK4ozoJNsq3qxbWyk0F8l/icrjQ8bjSLkBi1UDVYJVB34oST1DPmCcUflx?= =?us-ascii?Q?g8OFVF2W2jHR/IvvYzkJO1Ry4JuCwk8qlH1LZKPKk?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1308; 5:8wyAJVfpjllHXDBQJ6Si8CPTWNly/pAg6quE84x0V+HePi5uQKw53r73Lr7PcwEc7csoLZ3eq2AWb023uT0Im6z0ScPtOQq4CqUNWd1MvI4b/nKkklWrvemvPcIizLrI6iPiqzd9I54jzML02wdRjw==; 24:qbl+aSg6K9wElxYrgSRgVgSyreCvM/zINsy7ZHEjr5D45x1fJMZP/L3Xtfnk1XQjCtaZEsRVASwZMm4B6rkrkv32md+gdQLsSfpg86s9YPs=; 20:UBcmOyU4AqhdKutkvX84ldy/vlBWAtZ71CehYcG2hwkODkfyofdL434PA2y6V0wOzt0Fy2nn4TFDG5XKOwalMw== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2015 09:09:16.9231 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB1308 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150914_020939_996011_E5193AEC X-CRM114-Status: GOOD ( 18.17 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alison Wang Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, T_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_FLAT, 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 --- Changes since v1: - Use REGCACHE_FLAT instead of REGCACHE_RBTREE. - Use SIMPLE_DEV_PM_OPS to simplify the code. sound/soc/fsl/fsl_sai.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index a18fd92..030f71e 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -637,9 +637,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: @@ -681,6 +683,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_FLAT, }; static int fsl_sai_probe(struct platform_device *pdev) @@ -796,6 +799,31 @@ static int fsl_sai_probe(struct platform_device *pdev) return devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0); } +#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 SIMPLE_DEV_PM_OPS(fsl_sai_pm, fsl_sai_suspend, fsl_sai_resume); + static const struct of_device_id fsl_sai_ids[] = { { .compatible = "fsl,vf610-sai", }, { .compatible = "fsl,imx6sx-sai", }, @@ -807,6 +835,7 @@ static struct platform_driver fsl_sai_driver = { .driver = { .name = "fsl-sai", .of_match_table = fsl_sai_ids, + .pm = &fsl_sai_pm, }, }; module_platform_driver(fsl_sai_driver);