From patchwork Mon Jul 6 09:50:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zidan Wang X-Patchwork-Id: 6721401 Return-Path: X-Original-To: patchwork-alsa-devel@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 AACB3C05AC for ; Mon, 6 Jul 2015 09:49:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C238A2070B for ; Mon, 6 Jul 2015 09:49:51 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id E32C720602 for ; Mon, 6 Jul 2015 09:49:49 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 68361260671; Mon, 6 Jul 2015 11:49:44 +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, NO_DNS_FOR_FROM,UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id B8B51260568; Mon, 6 Jul 2015 11:49:15 +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 D51AE2605D6; Mon, 6 Jul 2015 11:49:14 +0200 (CEST) Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1on0131.outbound.protection.outlook.com [157.56.110.131]) by alsa0.perex.cz (Postfix) with ESMTP id 8C4BF260568 for ; Mon, 6 Jul 2015 11:49:05 +0200 (CEST) Received: from DM2PR03CA0045.namprd03.prod.outlook.com (10.141.96.44) by CY1PR0301MB1258.namprd03.prod.outlook.com (10.161.212.156) with Microsoft SMTP Server (TLS) id 15.1.207.19; Mon, 6 Jul 2015 09:49:03 +0000 Received: from BN1BFFO11FD020.protection.gbl (2a01:111:f400:7c10::1:178) by DM2PR03CA0045.outlook.office365.com (2a01:111:e400:2428::44) with Microsoft SMTP Server (TLS) id 15.1.207.19 via Frontend Transport; Mon, 6 Jul 2015 09:49:03 +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 BN1BFFO11FD020.mail.protection.outlook.com (10.58.144.83) with Microsoft SMTP Server (TLS) id 15.1.201.10 via Frontend Transport; Mon, 6 Jul 2015 09:49:02 +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 t669mrYS019060; Mon, 6 Jul 2015 02:48:59 -0700 From: Zidan Wang To: Date: Mon, 6 Jul 2015 17:50:35 +0800 Message-ID: X-Mailer: git-send-email 1.9.1 In-Reply-To: References: X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD020; 1:a4TYQPIYErbYyStZghc1ALSkMcz6NKcAfULCsi7/RXZwv4EYK3lwqEybFVsdAJvcj7c7WylFf6ZdI4CNVA1cWg99koSCDhZNp9VlnJqTbBBcTp49tL/vK9uO1cqFkThmznsTloEgla2+rAUSa5XKhfzEAS0t/y17S1Jy5AxeEQ/1d+MZunxCQ8GcNihXin6t9qAnFyk/6OAb+LTkK8x6CYoEwGFH+DVynEkpA8voIecvRyV+ZwkPlR342GOiQY+XqxRmfPcKw+FRrq81Y1eNfEnRrAEvjChB5VPtWf/huXUltCCkVTlRqGORSmh+ozQfWKGBxRKXwIv4F7qcYVXYwH0Y/Y6mvV9HwLxsXFiPQLoDxgRu2E4r6HKBrgYEK1fv X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(1060300003)(2980300002)(339900001)(189002)(199003)(50226001)(76176999)(77096005)(47776003)(50986999)(4290100001)(92566002)(36756003)(2950100001)(62966003)(77156002)(19580405001)(19580395003)(105606002)(104016003)(106466001)(110436001)(87936001)(33646002)(6806004)(107886002)(46102003)(5001960100002)(86362001)(2351001)(229853001)(85426001)(110136002)(50466002)(118296001)(48376002)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR0301MB1258; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1258; 2:RNdJm3LpgwjSmtLRDO1TcBVuOWNbLaur+QgmKdvPSz7n6kJmIo5uACgMtYXwBYNE; 3:IuiZ0nnxiUn1pk6LVfif6uESZkBf3dBYgm5vuuBUtphvaJmtSwqjctv+v+QSwgbRcfDUzRDnFV10mGt8F/AkyooAW5PcPIOYBz4m22CIcEbCH/vXPqi9+UzzwwUgw3A0+vLcEBINzSScvdQoqiGW0h1HSqRrWkotwCX4lpR5BbPZEtzKs81O8ZMCuwDZ0aamfUrYlPRDO1bBMOyQQfvC+orwAbi83YY8/+ZvPMonn/U=; 25:ch3sqeTms/459doYe8KrkmEAEz5xdJ8wZp9R3T7G69k9bx4cIt8V5dbqrbFc+oH4DFlS7WZtMEjulEnlhbXUmmHcSOU6BBk82aENdK0YD+mstzCkY7ww6e8kULV+xHMU2osyfxM83aGVNhqKe9o528NvysSmC8E7vMP6nqwjOFR3fDJ6IOWugsG8knJqvzlZDIW4NdGAqKj86o1KPqV6gJBxQuAU7HAgRXyehvt+Ofsx7ryqYieY8V46+N1QYnnPvwgThocwCVJ4YXJ/WMXJ/Q==; 20:eC+AK+uv/NVlEEV7kOIlHHSCa57q6s+Z9FnhdkKVRdNi/x5Z8CbgeATJ4A7OapxQK0GIUUfZ4lk7Bs6QPobtryIkmwYo/PgqCZU2qR5+w+O85PL6btYQjLJ0jMpNE48uRO1fnwattLdIYMoH/WDgBbJ1HApwkbzBZCVFcU3B0p6dilbwHvrxMHbhbY1VSaoadhPyiwsDvPSi+QV4qD4GOVNvcN9PpE34mXxOpQfrcM7yUdBs3s61ZzFjCPQAlglDbDSkRO9gi2CCaSc3jFTEHPloXvHBC9TOy/cal0Nkc7mQ4VuRs8rGx00ogm55CUjdy5ZOkWoadw9I8lymYt5OGyYF+mDwFGugd3bZFAgpvgY= X-Microsoft-Antispam: UriScan:;BCL:1;PCL:0;RULEID:;SRVR:CY1PR0301MB1258; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:1; PCL:0; RULEID:(601004)(5005006)(1201001)(3002001); SRVR:CY1PR0301MB1258; BCL:1; PCL:0; RULEID:; SRVR:CY1PR0301MB1258; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1258; 4:naqVonoXLoTdi+vmoyhDTR43r2FixWEHRx4mwTVkgtBnq4btAQ7M4APXfkh6qe92ZwYldSi538pTrqOJZ7WfaHc2q2cMHtg3u8aDn6NjXi2kAIq+hK6tI8n/1EwJiAJTrih6duBsgNCYxV2B7q15kx51Uu1COgGluL8RWZEklz8BF+RjS4BWVzc9KestfPj3GlxzUFWf2UB054k6pcb1JXZnoyIEx3wIGmoXJROA0SyaMu/ij2LtvAQIPTyVWUm1zPbD2udSTe1PpMewAwKlDV+3qw/6uCIuPVMimSKKZb7noaPsb6LbzDSqjgd7i57G X-Forefront-PRVS: 06290ECA9D X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB1258; 23:tu4nA+HAEMalSr7MK4mU9O1ttXnKm/FPbPLydMo?= =?us-ascii?Q?b2m+d5VVlwv+R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=?us-ascii?Q?eFIrCmZOAztwia3v8ub+nVsepvSEX6I33IHVYLh1UleM48pdXnr1e2FsGiXA?= =?us-ascii?Q?95n7+VLGUtQ23C8eBujgfB/bJ?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1258; 5:viQ+vie2lGQaaEsBOkk7vgypgVO2tMY/cNjGu4MCcUiBvY8XjjCKMTDKl/Ibqmf1N7kBUwkOZyVr8twob+u/iNa7TTqElliAhy7XZe1ZQllyG/E50rLJuBtUtTAdcKgy/eAnGdy/DjuedkqO46Z27Q==; 24:xXDgFPtgN0d4du0dvRq2tRfxCVQgqeJIqOhNQB6Or0zLGOiQiwXaATXcEJlr5mgit5l1rpRqiZ3MzGBVRAHRCWNnH7N8HpTRS6IMOMl4KQA=; 20:IGAZXZCZcMwCG1oYhS3WAenX9zZGzHtO54ahnL/0BafsX18gG1zG0sgGuZby1O8RYTWeavAx9V6qcM5oSKn24w== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2015 09:49:02.4865 (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: CY1PR0301MB1258 Cc: alsa-devel@alsa-project.org, Zidan Wang , tiwai@suse.de, linux-kernel@vger.kernel.org, lgirdwood@gmail.com, nicoleotsuka@gmail.com, broonie@kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [alsa-devel] [PATCH 2/3] ASoC: fsl_spdif: 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, SAI needs to save all the values of registers before the system suspend and restore them after the system resume. Signed-off-by: Zidan Wang --- sound/soc/fsl/fsl_spdif.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c index 8e93221..caf20d1 100644 --- a/sound/soc/fsl/fsl_spdif.c +++ b/sound/soc/fsl/fsl_spdif.c @@ -300,6 +300,8 @@ static int spdif_softreset(struct fsl_spdif_priv *spdif_priv) struct regmap *regmap = spdif_priv->regmap; u32 val, cycle = 1000; + regcache_cache_bypass(regmap, true); + regmap_write(regmap, REG_SPDIF_SCR, SCR_SOFT_RESET); /* @@ -310,6 +312,10 @@ static int spdif_softreset(struct fsl_spdif_priv *spdif_priv) regmap_read(regmap, REG_SPDIF_SCR, &val); } while ((val & SCR_SOFT_RESET) && cycle--); + regcache_cache_bypass(regmap, false); + regcache_mark_dirty(regmap); + regcache_sync(regmap); + if (cycle) return 0; else @@ -1013,6 +1019,26 @@ static bool fsl_spdif_readable_reg(struct device *dev, unsigned int reg) } } +static bool fsl_spdif_volatile_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case REG_SPDIF_SIS: + case REG_SPDIF_SRL: + case REG_SPDIF_SRR: + case REG_SPDIF_SRCSH: + case REG_SPDIF_SRCSL: + case REG_SPDIF_SRU: + case REG_SPDIF_SRQ: + case REG_SPDIF_STL: + case REG_SPDIF_STR: + case REG_SPDIF_SRFM: + return true; + default: + return false; + } + +} + static bool fsl_spdif_writeable_reg(struct device *dev, unsigned int reg) { switch (reg) { @@ -1039,7 +1065,9 @@ static const struct regmap_config fsl_spdif_regmap_config = { .max_register = REG_SPDIF_STC, .readable_reg = fsl_spdif_readable_reg, + .volatile_reg = fsl_spdif_volatile_reg, .writeable_reg = fsl_spdif_writeable_reg, + .cache_type = REGCACHE_RBTREE, }; static u32 fsl_spdif_txclk_caldiv(struct fsl_spdif_priv *spdif_priv, @@ -1262,6 +1290,30 @@ static int fsl_spdif_probe(struct platform_device *pdev) return ret; } +#ifdef CONFIG_PM_SLEEP +static int fsl_spdif_suspend(struct device *dev) +{ + struct fsl_spdif_priv *spdif_priv = dev_get_drvdata(dev); + + regcache_cache_only(spdif_priv->regmap, true); + regcache_mark_dirty(spdif_priv->regmap); + + return 0; +} + +static int fsl_spdif_resume(struct device *dev) +{ + struct fsl_spdif_priv *spdif_priv = dev_get_drvdata(dev); + + regcache_cache_only(spdif_priv->regmap, false); + return regcache_sync(spdif_priv->regmap); +} +#endif /* CONFIG_PM_SLEEP */ + +static const struct dev_pm_ops fsl_spdif_pm = { + SET_SYSTEM_SLEEP_PM_OPS(fsl_spdif_suspend, fsl_spdif_resume) +}; + static const struct of_device_id fsl_spdif_dt_ids[] = { { .compatible = "fsl,imx35-spdif", }, { .compatible = "fsl,vf610-spdif", }, @@ -1273,6 +1325,7 @@ static struct platform_driver fsl_spdif_driver = { .driver = { .name = "fsl-spdif-dai", .of_match_table = fsl_spdif_dt_ids, + .pm = &fsl_spdif_pm, }, .probe = fsl_spdif_probe, };