From patchwork Fri Aug 7 06:21:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zidan Wang X-Patchwork-Id: 6965131 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 C0D179F358 for ; Fri, 7 Aug 2015 06:22:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C4DE220634 for ; Fri, 7 Aug 2015 06:22:07 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 786DE2064B for ; Fri, 7 Aug 2015 06:22:06 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id AD510261504; Fri, 7 Aug 2015 08:22:05 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, NO_DNS_FOR_FROM, RCVD_IN_DNSWL_LOW, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 06CE42606C3; Fri, 7 Aug 2015 08:20:47 +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 88F482612D7; Fri, 7 Aug 2015 08:20:45 +0200 (CEST) Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1bbn0101.outbound.protection.outlook.com [157.56.111.101]) by alsa0.perex.cz (Postfix) with ESMTP id 8F01E2604C5 for ; Fri, 7 Aug 2015 08:20:07 +0200 (CEST) Received: from BN3PR0301CA0067.namprd03.prod.outlook.com (10.160.152.163) by BN3PR0301MB1251.namprd03.prod.outlook.com (10.161.207.27) with Microsoft SMTP Server (TLS) id 15.1.225.19; Fri, 7 Aug 2015 06:20:05 +0000 Received: from BN1AFFO11FD021.protection.gbl (2a01:111:f400:7c10::160) by BN3PR0301CA0067.outlook.office365.com (2a01:111:e400:401e::35) with Microsoft SMTP Server (TLS) id 15.1.225.19 via Frontend Transport; Fri, 7 Aug 2015 06:20:05 +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 BN1AFFO11FD021.mail.protection.outlook.com (10.58.52.81) with Microsoft SMTP Server (TLS) id 15.1.243.9 via Frontend Transport; Fri, 7 Aug 2015 06:20:04 +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 t776JeIm029536; Thu, 6 Aug 2015 23:20:01 -0700 From: Zidan Wang To: Date: Fri, 7 Aug 2015 14:21:08 +0800 Message-ID: <410baabbc6d51a2a5bc2f0496368764214a2abc6.1438928296.git.zidan.wang@freescale.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <6fa4e6ebf1f34f5d637324c9f62e68b03037568c.1438928296.git.zidan.wang@freescale.com> References: <6fa4e6ebf1f34f5d637324c9f62e68b03037568c.1438928296.git.zidan.wang@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD021; 1:p+DJJVldSb/i/mNELZxGRd0Yj6b8JAc/XeFV54R79WKcTvdmfvHOViEVSvQmRgk1z9aAtrxatHkFSMDVR1m95QsNde2rdl6KMl+YbWfl1F38wAj5KNzd/noAhjSpL61L/zwFyjVR+7UsJQu+gsv9Vg2IcE/trbb1xpFPiGar0IxS81gQh28GBs4cb3R4kz/VA+yY01WWVDdSfdgzV4mNvS2jfwBJwVJbQ9i1NCsYNu6ufJQANSWeGwKewlPq5rTQ11BRhvJKPaZkCKb3xrcFVHRBaJQ6sS7nufEtcRrY89e7hkeRlz+9ZR4+m4ysNsr+JyXfYVk1aO/4W2FcyF1t4M3iFD0kDnmS1Q21RgpkLxA= 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)(81156007)(19580405001)(69596002)(87936001)(85426001)(86362001)(48376002)(50466002)(5001960100002)(19580395003)(33646002)(6806004)(105606002)(106466001)(46102003)(5001860100001)(110136002)(2950100001)(5001830100001)(107886002)(4001540100001)(97736004)(4290100001)(92566002)(77096005)(50986999)(68736005)(5003940100001)(47776003)(2351001)(64706001)(36756003)(118296001)(62966003)(229853001)(110436001)(104016003)(50226001)(77156002)(76176999)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:BN3PR0301MB1251; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BN3PR0301MB1251; 2:8X2D9gBpr59JlPJ4Yc6ot5OMHJjNDhiDaN9TmC2cHXPYw57s8fg7gorB4MvV+6ludUyofv5MsMxYVFJ+YuMdkAz5Zp0X9o7ZR4GFvYgTluhaXb0vT+sVb6fsTDj8XoKmBrBbaCLSKojP5j9VcFsCQoOwl7bqQzu1jnJn5FvGj0U=; 3:Ggt5Q3a+FHfeSjaJokxQAlB3A8z8EgcLIk2LgwqJG1FI3t16ws4zmYYRqezBTPkEjPClZZordYhrfgaxzI7oRPMQLJnItlFyirF7ksbC1OhlZ7d38bd/8UfG6a8G+2PxkClSV4o12W6fw8XIvztDwW5P6fM8MewS5fgDM0S9TIHHYgRF6CL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gmb3zPI+fbYYm/Et4CZp1K 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:BN3PR0301MB1251; BCL:1; PCL:0; RULEID:; SRVR:BN3PR0301MB1251; X-Forefront-PRVS: 066153096A X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR0301MB1251; 23:JuhSnVvUVf/JCOpHyV/ufLgNrju8CP0OMy1PO02?= =?us-ascii?Q?sTBT3fOVyKcAjLv15cNRdv2D0CwKJleb/BlJsSBeBwOh2zMAhxrBHItlNa6M?= =?us-ascii?Q?V8aGT2D6l9Nq3ty2dlsqjI4DISVAQulwU9yiddfMF8sp+WecA6P4Z3XNkyIO?= =?us-ascii?Q?QhDyohHfd8op17QwveRk7EP/xF2O0u/Bx2QZXn27QFa8aM/9CnJZcR8kR1nh?= =?us-ascii?Q?XoOkkAH9jtK68iSJ35Hb5mZn9Dzae8XDUlgBkXsuo/zRgdoDD8VhjkaKEoWy?= =?us-ascii?Q?wA0cmEAKnWjXldeiiU9deaKTzLmGJh+tcJ96bQx35Q6Bndjbz8G74lEWauDh?= =?us-ascii?Q?epbOTwcniQCmsSAjsLb9/HfCADzh4ceR/vA+8Lo9xS6IsuLkNoRebcTYOheh?= =?us-ascii?Q?WDqe6jKT9SWltJYm9Lasd8PTw4sshPHeDwKe56I+4ob/oboZ5GSDtFIpk3C2?= =?us-ascii?Q?1WHTu7vP8tvBWGF2pse0r9iWaIQ/wHedf25bfOdzqLlsm6TXTZOtx1Ad/lvw?= =?us-ascii?Q?gfGz0977ZeF4GNWSglXxDF6/yFGknUWNZPEdE2VmojLJN1ggHej9fXhrtffP?= =?us-ascii?Q?bFCLgKDB43/kWqNZSimCErwI9SQBj2bPeZ4aSIvBCCzu20skK+XdS3dYKlOI?= =?us-ascii?Q?nopuLY1q0SKCTrPe/qVyXRh6JO0qsbYlthks8uU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nfmZa+zzoK2QRdb6/S7vXBYqoc0L+SaxRdwqFQ== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2015 06:20:04.6780 (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: BN3PR0301MB1251 Cc: alsa-devel@alsa-project.org, timur@tabi.org, Zidan Wang , Xiubo.Lee@gmail.com, tiwai@suse.com, lgirdwood@gmail.com, broonie@kernel.org Subject: [alsa-devel] [PATCH v3 4/4] ASoC: fsl_esai: 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, ESAI 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_esai.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c index 8c2ddc1..521e8cb 100644 --- a/sound/soc/fsl/fsl_esai.c +++ b/sound/soc/fsl/fsl_esai.c @@ -652,6 +652,24 @@ static const struct snd_soc_component_driver fsl_esai_component = { .name = "fsl-esai", }; +static const struct reg_default fsl_esai_reg_defaults[] = { + {0x8, 0x00000000}, + {0x10, 0x00000000}, + {0x18, 0x00000000}, + {0x98, 0x00000000}, + {0xd0, 0x00000000}, + {0xd4, 0x00000000}, + {0xd8, 0x00000000}, + {0xdc, 0x00000000}, + {0xe0, 0x00000000}, + {0xe4, 0x0000ffff}, + {0xe8, 0x0000ffff}, + {0xec, 0x0000ffff}, + {0xf0, 0x0000ffff}, + {0xf8, 0x00000000}, + {0xfc, 0x00000000}, +}; + static bool fsl_esai_readable_reg(struct device *dev, unsigned int reg) { switch (reg) { @@ -684,6 +702,31 @@ static bool fsl_esai_readable_reg(struct device *dev, unsigned int reg) } } +static bool fsl_esai_volatile_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case REG_ESAI_ETDR: + case REG_ESAI_ERDR: + case REG_ESAI_ESR: + case REG_ESAI_TFSR: + case REG_ESAI_RFSR: + case REG_ESAI_TX0: + case REG_ESAI_TX1: + case REG_ESAI_TX2: + case REG_ESAI_TX3: + case REG_ESAI_TX4: + case REG_ESAI_TX5: + case REG_ESAI_RX0: + case REG_ESAI_RX1: + case REG_ESAI_RX2: + case REG_ESAI_RX3: + case REG_ESAI_SAISR: + return true; + default: + return false; + } +} + static bool fsl_esai_writeable_reg(struct device *dev, unsigned int reg) { switch (reg) { @@ -721,8 +764,12 @@ static const struct regmap_config fsl_esai_regmap_config = { .val_bits = 32, .max_register = REG_ESAI_PCRC, + .reg_defaults = fsl_esai_reg_defaults, + .num_reg_defaults = ARRAY_SIZE(fsl_esai_reg_defaults), .readable_reg = fsl_esai_readable_reg, + .volatile_reg = fsl_esai_volatile_reg, .writeable_reg = fsl_esai_writeable_reg, + .cache_type = REGCACHE_RBTREE, }; static int fsl_esai_probe(struct platform_device *pdev) @@ -853,10 +900,51 @@ static const struct of_device_id fsl_esai_dt_ids[] = { }; MODULE_DEVICE_TABLE(of, fsl_esai_dt_ids); +#if CONFIG_PM_SLEEP +static int fsl_esai_suspend(struct device *dev) +{ + struct fsl_esai *esai = dev_get_drvdata(dev); + + regcache_cache_only(esai->regmap, true); + regcache_mark_dirty(esai->regmap); + + return 0; +} + +static int fsl_esai_resume(struct device *dev) +{ + struct fsl_esai *esai = dev_get_drvdata(dev); + int ret; + + regcache_cache_only(esai->regmap, false); + + /* FIFO reset for safety */ + regmap_update_bits(esai->regmap, REG_ESAI_TFCR, + ESAI_xFCR_xFR, ESAI_xFCR_xFR); + regmap_update_bits(esai->regmap, REG_ESAI_RFCR, + ESAI_xFCR_xFR, ESAI_xFCR_xFR); + + ret = regcache_sync(esai->regmap); + if (ret) + return ret; + + /* FIFO reset done */ + regmap_update_bits(esai->regmap, REG_ESAI_TFCR, ESAI_xFCR_xFR, 0); + regmap_update_bits(esai->regmap, REG_ESAI_RFCR, ESAI_xFCR_xFR, 0); + + return 0; +} +#endif /* CONFIG_PM_SLEEP */ + +static const struct dev_pm_ops fsl_esai_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(fsl_esai_suspend, fsl_esai_resume) +}; + static struct platform_driver fsl_esai_driver = { .probe = fsl_esai_probe, .driver = { .name = "fsl-esai-dai", + .pm = &fsl_esai_pm_ops, .of_match_table = fsl_esai_dt_ids, }, };