From patchwork Wed Jul 8 07:22:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zidan Wang X-Patchwork-Id: 6740881 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C432E9F38C for ; Wed, 8 Jul 2015 07:23:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D4A8C206F7 for ; Wed, 8 Jul 2015 07:23:09 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 537A0206DF for ; Wed, 8 Jul 2015 07:23:08 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 7973D2657E0; Wed, 8 Jul 2015 09:23:05 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 94F33265777; Wed, 8 Jul 2015 09:22:07 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id A5414265777; Wed, 8 Jul 2015 09:22:06 +0200 (CEST) Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1bon0135.outbound.protection.outlook.com [157.56.111.135]) by alsa0.perex.cz (Postfix) with ESMTP id BD477264F39 for ; Wed, 8 Jul 2015 09:21:35 +0200 (CEST) Received: from DM2PR03CA0027.namprd03.prod.outlook.com (10.141.96.26) by DM2PR0301MB1264.namprd03.prod.outlook.com (10.160.220.11) with Microsoft SMTP Server (TLS) id 15.1.213.14; Wed, 8 Jul 2015 07:21:22 +0000 Received: from BN1AFFO11FD005.protection.gbl (2a01:111:f400:7c10::185) by DM2PR03CA0027.outlook.office365.com (2a01:111:e400:2428::26) with Microsoft SMTP Server (TLS) id 15.1.207.19 via Frontend Transport; Wed, 8 Jul 2015 07:21:22 +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; 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 BN1AFFO11FD005.mail.protection.outlook.com (10.58.52.65) with Microsoft SMTP Server (TLS) id 15.1.201.10 via Frontend Transport; Wed, 8 Jul 2015 07:21:18 +0000 Received: from b50113.ap.freescale.net (b50113.ap.freescale.net [10.192.241.89]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t687L1gB031432; Wed, 8 Jul 2015 00:21:16 -0700 From: Zidan Wang To: Date: Wed, 8 Jul 2015 15:22:29 +0800 Message-ID: <32243d772f82eb67e4a561b842be9661d730f0b1.1436339869.git.zidan.wang@freescale.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD005; 1:eNLTDfyAzXcJyJVXFeYJ+UKwT6Bw5wizvOhIrxi0LLwCEctP24V+QfnQrjIAh0KOF4/iYxeqCtnavs6vUoMYVy1FLC+FB808izc6JlUcgoWf/m6j1Nz4NtadkBd/LHMeX7pr1p5ekaL++ceIwwRPAhKx4VI/+IhZ9hCG+nK0gyAtYrsRi1k9lnxWEMar2Wv0BBpO1Kexs2b/BWnFt91QSiRHeG/QLGec51xbGnX+lWAN4TVSv1rB4emFih1sFT/swRhlljmAxURsL3jWgibObZGy69LvwEY3xyUNhO6k6/r34+VHptD4bOuwJvEODZBrFcub/JMTbyNC3dN4u3uZvYMHPYwXSibptxUturY+CIU= X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(1060300003)(339900001)(199003)(189002)(5001960100002)(6806004)(107886002)(118296001)(85426001)(46102003)(19580395003)(87936001)(19580405001)(48376002)(47776003)(5003940100001)(86362001)(76176999)(92566002)(4290100001)(50986999)(36756003)(105606002)(50226001)(229853001)(62966003)(77156002)(2351001)(33646002)(104016003)(110436001)(77096005)(2950100001)(106466001)(110136002)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:DM2PR0301MB1264; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:sfv; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB1264; 2:YilWfEhdTfujpVNL/hk6ohVIKDAE+tktj/OVzKfCqkV7gzo2bboPZQFKoRhqXk70; 3:u9fZcvfVaQFBTcpDJYu1k4YYBdAXtO1X9jcpX0aLoLqeg3U0CosIA7y/lDvCRtV5gyv9sW7xDCF161IvIbRcPCubSaMS6VjWbkYqX1wXu7ZFjf7SkPi4/gYaWYNRocNsOR1pd7hITlLC+CMbAFyZK74R6rTYej1a3b4ArBq9rfexb5aJ5Xu/o9oDnaqv5PJubuROA+niMAATiM+wWR/OoLieT3Au6KnnsnmjFdGCJW0=; 25:WkDVvGCdQsl6Br4iN1huT1zhJ2tyTYk27qM8H3A1x2n2V0JHadErta2ht1tLooIAz3IoSba3DuJ4lvB32qaAW/H1ZJQIWHDsIn1bePNSk4Qaks8HO0/JnHwCUrxp5eP7n5s5YXLi+HC4GimS/cGb1eEtgNzRT1LvI6WeK9O0mueYwcpLBkQZf2IL+nuDmzDsPD82ftO1/2OSUIpnAhT27JqLfmhpO/AboDWP19uqDHUvSX3g4Kp5dRG8Hh26JJ1yeuLnfgfpLCv3CI8RYPgXiQ==; 20:Go4zZCBDgAU28DRhzf8tMgRK0YKk+cRR+dfc5vbtTH5nKMkEfnHYR4eI0yATirAbOi5FAzhWJcJgCzfplZFlyxyh/CQ4e7REzYQoxsl2yjiMLprzD+A0nPL5O/0c3dpLFfGzXt8ZXzUvmKECR+sJb58LwqHZ39tvwkybadVZQEMY5wpwFeO8S2UU1ljLcZf+EmrTuZ+b8b9jvgthJM7JVbxFHcdyVg1HlUXr8lkoa9j6BTrDH7ZOkEtdJIKtilzoNe1IpQfEInNryRrEWfXDi8F4AnDDl00+0MmHhVpatfprzXH1OyiY3UuZ613Kxkny5oHGNhJN2PqYu07oYpiYxPmwaWeaPy7zH0gg17VxBLI= X-Microsoft-Antispam: UriScan:;BCL:1;PCL:0;RULEID:;SRVR:DM2PR0301MB1264; DM2PR0301MB1264: X-MS-Exchange-Organization-RulesExecuted X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:1; PCL:0; RULEID:(601004)(1201001)(5005006)(3002001); SRVR:DM2PR0301MB1264; BCL:1; PCL:0; RULEID:; SRVR:DM2PR0301MB1264; X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB1264; 4:hS1FdOzFM+LQ0kvaDPdKr/Eio4vVtEIsYMJSBsWtPCqn+GkLXY3bCgNtRoZ2gVlOU6FX1bpxTzRGcQFeEUXUwfh6V9OqC9+N34Vj5fOMrewBe5auKdwPPxNgpjQ6SOjlIFlqlaccLbE0hQzDLFOp8yqRHM9aBSkoVxHu2mXft+nnHdWRauUDCOAVAqy1ACet3+FPJs0/gNjqWZS0pleOGiL04AR8McqO38xRpeSB+0VItmY0zytTwE+xJxC9psyQIxz66Vm+MwJgXiiAcPNISPAHe7d6WJPD2UPyT/JqwUS4cDXHc+RVtpOU4ujLvafP X-Forefront-PRVS: 0631F0BC3D X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR0301MB1264; 23:u/WF9jS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?hWb+Hvr+Ewn8Gpieoqw16xB3TTssT8Av3lZmaxu5z2Xm1SjhscdCCTEflIpS?= =?us-ascii?Q?nLi9F+wN02vTZEkLhEEve1LvH9qZNdfaFvPYa8wRuGtjjO7GPOIweq9nUyoX?= =?us-ascii?Q?21MVJIQm20eFdK6mqiPC6ELK3?= X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB1264; 5:7nVCdVRKIf2gyfe33WgUPdZzeq1nDaf34C2p6+BdgHqoYYikxyTkAhVF/+6shZOf5WhIDEImiycVEnHe644t/G46RBFYSUkKb4RYrfEQGKPzZkKkQMn8lGav4ADPtizDeqlUXW6FopcnLF0yPWuvHw==; 24:NuQIy3sSTI/7/ixWQT/5JlyNygncACWM/LgMzWjh6ZYhUAnasETlHB/LHd/bL0JRmzf4RMaEth59pNIR/FoS5/fMjNuymmoRQNza03eF/Gk=; 20:eHK/fc99UFCsnCvFhj226iwa4KGI5UhQdBSPGn0L1Sf5SYAK/TcPjOdj03nVcx6q3m62rvzPI2yUOgH3forGAQ== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2015 07:21:18.7643 (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: DM2PR0301MB1264 Cc: alsa-devel@alsa-project.org, Zidan Wang , tiwai@suse.de, nicoleotsuka@gmail.com, broonie@kernel.org Subject: [alsa-devel] [PATCH v2 3/4] ASoC: fsl_ssi: Add driver suspend and resume to support MEGA Fast X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP For i.MX6 SoloX, there is a mode of the SoC to shutdown all power source of modules during system suspend and resume procedure. Thus, SSI needs to save all the values of registers before the system suspend and restore them after the system resume. The register SFCSR is volatile, but some bits in it need to be recovered after suspend/resume. Signed-off-by: Zidan Wang --- sound/soc/fsl/fsl_ssi.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index c7647e0..6d8536d 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -111,12 +111,60 @@ struct fsl_ssi_rxtx_reg_val { struct fsl_ssi_reg_val rx; struct fsl_ssi_reg_val tx; }; + +static bool fsl_ssi_readable_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case CCSR_SSI_SACCEN: + case CCSR_SSI_SACCDIS: + return false; + default: + return true; + } +} + +static bool fsl_ssi_volatile_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case CCSR_SSI_STX0: + case CCSR_SSI_STX1: + case CCSR_SSI_SRX0: + case CCSR_SSI_SRX1: + case CCSR_SSI_SISR: + case CCSR_SSI_SFCSR: + case CCSR_SSI_SACADD: + case CCSR_SSI_SACDAT: + case CCSR_SSI_SATAG: + case CCSR_SSI_SACCST: + return true; + default: + return false; + } + +} + +static bool fsl_ssi_writeable_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case CCSR_SSI_SRX0: + case CCSR_SSI_SRX1: + case CCSR_SSI_SACCST: + return false; + default: + return true; + } +} + static const struct regmap_config fsl_ssi_regconfig = { .max_register = CCSR_SSI_SACCDIS, .reg_bits = 32, .val_bits = 32, .reg_stride = 4, .val_format_endian = REGMAP_ENDIAN_NATIVE, + .readable_reg = fsl_ssi_readable_reg, + .volatile_reg = fsl_ssi_volatile_reg, + .writeable_reg = fsl_ssi_writeable_reg, + .cache_type = REGCACHE_RBTREE, }; struct fsl_ssi_soc_data { @@ -176,6 +224,9 @@ struct fsl_ssi_private { unsigned int baudclk_streams; unsigned int bitclk_freq; + /*regcache for SFCSR*/ + u32 regcache_sfcsr; + /* DMA params */ struct snd_dmaengine_dai_dma_data dma_params_tx; struct snd_dmaengine_dai_dma_data dma_params_rx; @@ -1461,10 +1512,46 @@ static int fsl_ssi_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM_SLEEP +static int fsl_ssi_suspend(struct device *dev) +{ + struct fsl_ssi_private *ssi_private = dev_get_drvdata(dev); + struct regmap *regs = ssi_private->regs; + + regmap_read(regs, CCSR_SSI_SFCSR, + &ssi_private->regcache_sfcsr); + + regcache_cache_only(regs, true); + regcache_mark_dirty(regs); + + return 0; +} + +static int fsl_ssi_resume(struct device *dev) +{ + struct fsl_ssi_private *ssi_private = dev_get_drvdata(dev); + struct regmap *regs = ssi_private->regs; + + regcache_cache_only(regs, false); + + regmap_update_bits(regs, CCSR_SSI_SFCSR, + CCSR_SSI_SFCSR_RFWM1_MASK | CCSR_SSI_SFCSR_TFWM1_MASK | + CCSR_SSI_SFCSR_RFWM0_MASK | CCSR_SSI_SFCSR_TFWM0_MASK, + ssi_private->regcache_sfcsr); + + return regcache_sync(regs); +} +#endif /* CONFIG_PM_SLEEP */ + +static const struct dev_pm_ops fsl_ssi_pm = { + SET_SYSTEM_SLEEP_PM_OPS(fsl_ssi_suspend, fsl_ssi_resume) +}; + static struct platform_driver fsl_ssi_driver = { .driver = { .name = "fsl-ssi-dai", .of_match_table = fsl_ssi_ids, + .pm = &fsl_ssi_pm, }, .probe = fsl_ssi_probe, .remove = fsl_ssi_remove,