From patchwork Sat Apr 20 15:59:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Baluta X-Patchwork-Id: 10910395 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A31E117EE for ; Sat, 20 Apr 2019 17:17:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82A3228641 for ; Sat, 20 Apr 2019 17:17:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 75DE628BCF; Sat, 20 Apr 2019 17:17:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B02AE28644 for ; Sat, 20 Apr 2019 17:17:55 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id A8007872; Sat, 20 Apr 2019 18:00:09 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A8007872 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1555776059; bh=xBcesweAMR4m/HnJ6x1+/4bLh2wV4pjCJLP7t+esHv4=; h=From:To:Date:References:In-Reply-To:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ZHb7AvCUhFge0qfnk6JnsIkCgRcL4H7AwabSTl6WgCtAu1/vg0t18swGjmFnlrW4X KdL1hS5SrVuMHl9UolZSGhmJbaSsMXvnjbrmPhAWUl1YohjjdyBldKk/PQoGOCfui5 LDBynsnslZVM7LG+lEa7JWanDessq124XaJe8QyM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 1322DF89704; Sat, 20 Apr 2019 17:59:17 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5685CF896E8; Sat, 20 Apr 2019 17:59:13 +0200 (CEST) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00081.outbound.protection.outlook.com [40.107.0.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id E1785F80714 for ; Sat, 20 Apr 2019 17:59:08 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E1785F80714 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="DgNxtboY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=O+DHqJe3MiRmpX9U2CqCgij0+NicnYafvITYpGWCZhU=; b=DgNxtboYRYU8m0oqThvtsDOZ/pMb2tKwodEoG0eNrPy9lftB9AEBYwhy6YLSbdQvpTCMOKYBLQjryY6Mk4+Vb0TM22EoCb7B6ZqJzzIObUYvCW+TD+SRPM30kjZzdAypIkPFLZp0inR7EG/WWamZVzfkmtOjVPfdpv/BgMIU7+A= Received: from VI1PR0402MB3357.eurprd04.prod.outlook.com (52.134.1.18) by VI1PR0402MB2783.eurprd04.prod.outlook.com (10.172.255.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1813.11; Sat, 20 Apr 2019 15:59:04 +0000 Received: from VI1PR0402MB3357.eurprd04.prod.outlook.com ([fe80::c16b:662d:9299:6be6]) by VI1PR0402MB3357.eurprd04.prod.outlook.com ([fe80::c16b:662d:9299:6be6%6]) with mapi id 15.20.1813.017; Sat, 20 Apr 2019 15:59:04 +0000 From: Daniel Baluta To: "broonie@kernel.org" Thread-Topic: [PATCH 1/2] ASoC: fsl: sai: Add support for runtime pm Thread-Index: AQHU95H6a78MC40khEqrtDvohSbOJA== Date: Sat, 20 Apr 2019 15:59:04 +0000 Message-ID: <20190420155846.10027-2-daniel.baluta@nxp.com> References: <20190420155846.10027-1-daniel.baluta@nxp.com> In-Reply-To: <20190420155846.10027-1-daniel.baluta@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VE1PR03CA0042.eurprd03.prod.outlook.com (2603:10a6:803:118::31) To VI1PR0402MB3357.eurprd04.prod.outlook.com (2603:10a6:803:2::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=daniel.baluta@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [212.146.100.6] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: ab641505-7ff8-4560-e205-08d6c5a91ca8 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(4618075)(2017052603328)(7193020); SRVR:VI1PR0402MB2783; x-ms-traffictypediagnostic: VI1PR0402MB2783: x-microsoft-antispam-prvs: x-forefront-prvs: 0013079544 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(396003)(376002)(39860400002)(136003)(366004)(23433003)(199004)(189003)(54906003)(99286004)(11346002)(73956011)(68736007)(7736002)(5640700003)(6116002)(3846002)(6512007)(305945005)(2906002)(2351001)(102836004)(446003)(386003)(6506007)(53936002)(2616005)(76176011)(186003)(486006)(52116002)(26005)(476003)(71200400001)(97736004)(5660300002)(6436002)(66556008)(2501003)(66066001)(14444005)(256004)(44832011)(66946007)(64756008)(36756003)(71190400001)(81156014)(81166006)(8676002)(316002)(66476007)(478600001)(1730700003)(6916009)(1076003)(14454004)(8936002)(86362001)(25786009)(66446008)(7416002)(4326008)(6486002)(50226002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0402MB2783; H:VI1PR0402MB3357.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: BTIREBEISR4tUxV2M9tOUAK5W5RmmFoxWeH0s6a5wirqBEFQnhO2Moz2QHJ7njpsrO43EGmupuAwxXdMJNb2j4toKmrXuXLmkaz+M/c+k4e3zm4oD3MDQxItwiw5eO+TwCaqFljzxLyA9xgpGvJ5hIoOFOQGFtIzehBuJX/+QBFyb/y7J+WQVZqHW56hJmbk3bdwX/jns0yxBs6Cz3bc/HUKc9WKOQ0xWNzgxuoMnFscbeMEQQWm+i2exgTjuF3k68d2Fv/WdKlysUcxkGHChaSGLJbfIGmfoaw8MiAPJ0eJAC/xWDzVyyZKBett2oRXg+kmOpfLpETmg45tB9bbORJicypZojaXT0XSEU/fsV0lecsxclDJNGEPoSUKSOFMIS6J5wzV9XzrtHDQLoM9kZJRF5KAXOe02Iu2+JFBg9M= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ab641505-7ff8-4560-e205-08d6c5a91ca8 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Apr 2019 15:59:04.4071 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB2783 Cc: Daniel Baluta , "alsa-devel@alsa-project.org" , "timur@kernel.org" , "Xiubo.Lee@gmail.com" , "linuxppc-dev@lists.ozlabs.org" , "S.j. Wang" , "tiwai@suse.com" , "lgirdwood@gmail.com" , "nicoleotsuka@gmail.com" , dl-linux-imx , "festevam@gmail.com" , "linux-kernel@vger.kernel.org" Subject: [alsa-devel] [PATCH 1/2] ASoC: fsl: sai: Add support for runtime pm X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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" X-Virus-Scanned: ClamAV using ClamSMTP Basically the same actions as for system PM, so make use of pm_runtime_force_suspend/pm_runtime_force_resume. Signed-off-by: Shengjiu Wang Signed-off-by: Daniel Baluta --- sound/soc/fsl/fsl_sai.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index b563004fb89f..aeeb07b74177 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -898,6 +899,8 @@ static int fsl_sai_probe(struct platform_device *pdev) platform_set_drvdata(pdev, sai); + pm_runtime_enable(&pdev->dev); + ret = devm_snd_soc_register_component(&pdev->dev, &fsl_component, &fsl_sai_dai, 1); if (ret) @@ -917,8 +920,8 @@ static const struct of_device_id fsl_sai_ids[] = { }; MODULE_DEVICE_TABLE(of, fsl_sai_ids); -#ifdef CONFIG_PM_SLEEP -static int fsl_sai_suspend(struct device *dev) +#ifdef CONFIG_PM +static int fsl_sai_runtime_suspend(struct device *dev) { struct fsl_sai *sai = dev_get_drvdata(dev); @@ -928,7 +931,7 @@ static int fsl_sai_suspend(struct device *dev) return 0; } -static int fsl_sai_resume(struct device *dev) +static int fsl_sai_runtime_resume(struct device *dev) { struct fsl_sai *sai = dev_get_drvdata(dev); @@ -940,10 +943,13 @@ static int fsl_sai_resume(struct device *dev) regmap_write(sai->regmap, FSL_SAI_RCSR, 0); return regcache_sync(sai->regmap); } -#endif /* CONFIG_PM_SLEEP */ +#endif /* CONFIG_PM */ static const struct dev_pm_ops fsl_sai_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(fsl_sai_suspend, fsl_sai_resume) + SET_RUNTIME_PM_OPS(fsl_sai_runtime_suspend, + fsl_sai_runtime_resume, NULL) + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, + pm_runtime_force_resume) }; static struct platform_driver fsl_sai_driver = { From patchwork Sat Apr 20 15:59:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Baluta X-Patchwork-Id: 10910391 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 839A91515 for ; Sat, 20 Apr 2019 17:17:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B0E028641 for ; Sat, 20 Apr 2019 17:17:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A07E28668; Sat, 20 Apr 2019 17:17:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1801928641 for ; Sat, 20 Apr 2019 17:17:50 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id A87D8883; Sat, 20 Apr 2019 18:00:55 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A87D8883 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1555776105; bh=jmIFs+FVviZwzfo7Nm1vWcTCjBLwplVkQQh4t1SnN4c=; h=From:To:Date:References:In-Reply-To:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=F68TjUJnx0+/vynySSXJ0IbcrS09Sl0HyzvDBe7CGyqxEQyMtXJrXvUm6/Aya/8kr LOWYBxNV8XzBsTccrexOdq25WZwOKXjxEIRhRpI9kxir1J9Djg48IW4pmUj7vo+oDC 6kjj5ojDL0Bf8vuqWhxR6fs0BGDOJ3gkiW61yS/c= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id A5035F8971E; Sat, 20 Apr 2019 17:59:18 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id D2395F896E4; Sat, 20 Apr 2019 17:59:14 +0200 (CEST) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00081.outbound.protection.outlook.com [40.107.0.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 5C3B7F896E4 for ; Sat, 20 Apr 2019 17:59:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5C3B7F896E4 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="P0CSoMLe" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=m5cEMUO1KurbKmR6e+jJZ/zLIeqiX0xnffzZZ7zOFiI=; b=P0CSoMLe61Oz0BgFOkQem3WyGgo+KWOoe+1XaX51OOUZI0A20OSIe1qjpVh3KUkST2A9sB693els+ClgxogcWbCz3L74kJwvebPZd87pY+nlDL82pRbGNTs3IpFp8em4p/Zh6EQxvrb2cktL4wu9cl23eBF+sIeW4PO7WkFNmO4= Received: from VI1PR0402MB3357.eurprd04.prod.outlook.com (52.134.1.18) by VI1PR0402MB2783.eurprd04.prod.outlook.com (10.172.255.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1813.11; Sat, 20 Apr 2019 15:59:05 +0000 Received: from VI1PR0402MB3357.eurprd04.prod.outlook.com ([fe80::c16b:662d:9299:6be6]) by VI1PR0402MB3357.eurprd04.prod.outlook.com ([fe80::c16b:662d:9299:6be6%6]) with mapi id 15.20.1813.017; Sat, 20 Apr 2019 15:59:05 +0000 From: Daniel Baluta To: "broonie@kernel.org" Thread-Topic: [PATCH 2/2] ASoC: fsl: Move clock operation to PM runtime Thread-Index: AQHU95H6CnqPCJo73E6YBTN1iyGeSw== Date: Sat, 20 Apr 2019 15:59:05 +0000 Message-ID: <20190420155846.10027-3-daniel.baluta@nxp.com> References: <20190420155846.10027-1-daniel.baluta@nxp.com> In-Reply-To: <20190420155846.10027-1-daniel.baluta@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VE1PR03CA0042.eurprd03.prod.outlook.com (2603:10a6:803:118::31) To VI1PR0402MB3357.eurprd04.prod.outlook.com (2603:10a6:803:2::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=daniel.baluta@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [212.146.100.6] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: a4f9df21-848c-48e0-4f42-08d6c5a91d32 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(4618075)(2017052603328)(7193020); SRVR:VI1PR0402MB2783; x-ms-traffictypediagnostic: VI1PR0402MB2783: x-microsoft-antispam-prvs: x-forefront-prvs: 0013079544 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(396003)(376002)(39860400002)(136003)(366004)(199004)(189003)(54906003)(99286004)(11346002)(73956011)(68736007)(7736002)(5640700003)(6116002)(3846002)(6512007)(305945005)(2906002)(2351001)(102836004)(446003)(386003)(6506007)(53936002)(2616005)(76176011)(186003)(486006)(52116002)(26005)(476003)(71200400001)(97736004)(5660300002)(6436002)(66556008)(2501003)(66066001)(14444005)(256004)(44832011)(66946007)(64756008)(36756003)(71190400001)(81156014)(81166006)(8676002)(316002)(66476007)(478600001)(1730700003)(6916009)(1076003)(14454004)(8936002)(86362001)(25786009)(66446008)(7416002)(4326008)(6486002)(50226002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0402MB2783; H:VI1PR0402MB3357.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 1u7SxIlrp+jEl054r9ek0E8BrYr/HzqJP+eG3E1oRbUnv56Fi9JFRN0ZE/oH2UvX7rHkzgjKFCyL/LuaONO4tjUXaLKseBUD6SjHv1a8w3KiWCKzPgY1Y5emgaRJuKLPLc8lHeluu1+obzG6SqD0iuMkzp3cSUiSTgN4csiAP86Apy501Qt89CpDImMrMruZs7SNX4ox7FfVJsWb8j8W4tUt8dyKjut3eWevwrbixdxv6xrBfZZAT/R42uDMTOOYlvDyjePXyvP5hl1v6iypvaLcm96FqLziE4vLMz06tTmhIdHsToU4IWAkWH1eu4m1wdzbmZKSgNwT9vzpqMYVRehG7MRbh4MPqXc72/14zIklKPpdpyZaYSN4koaCGriPDVFJzS5jSqJvoOt3Inacj8ThWCKMQ+dHIrFpGWQpVDI= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a4f9df21-848c-48e0-4f42-08d6c5a91d32 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Apr 2019 15:59:05.2637 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB2783 Cc: Daniel Baluta , "alsa-devel@alsa-project.org" , "timur@kernel.org" , "Xiubo.Lee@gmail.com" , "linuxppc-dev@lists.ozlabs.org" , "S.j. Wang" , "tiwai@suse.com" , "lgirdwood@gmail.com" , "nicoleotsuka@gmail.com" , dl-linux-imx , "festevam@gmail.com" , "linux-kernel@vger.kernel.org" Subject: [alsa-devel] [PATCH 2/2] ASoC: fsl: Move clock operation to PM runtime X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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" X-Virus-Scanned: ClamAV using ClamSMTP From: Shengjiu Wang Turn off/on clocks when device enters suspend/resume. This helps saving power. Signed-off-by: Shengjiu Wang Signed-off-by: Daniel Baluta --- sound/soc/fsl/fsl_sai.c | 54 +++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index aeeb07b74177..a224c07ce31f 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -594,15 +594,8 @@ static int fsl_sai_startup(struct snd_pcm_substream *substream, { struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai); bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; - struct device *dev = &sai->pdev->dev; int ret; - ret = clk_prepare_enable(sai->bus_clk); - if (ret) { - dev_err(dev, "failed to enable bus clock: %d\n", ret); - return ret; - } - regmap_update_bits(sai->regmap, FSL_SAI_xCR3(tx), FSL_SAI_CR3_TRCE, FSL_SAI_CR3_TRCE); @@ -619,8 +612,6 @@ static void fsl_sai_shutdown(struct snd_pcm_substream *substream, bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; regmap_update_bits(sai->regmap, FSL_SAI_xCR3(tx), FSL_SAI_CR3_TRCE, 0); - - clk_disable_unprepare(sai->bus_clk); } static const struct snd_soc_dai_ops fsl_sai_pcm_dai_ops = { @@ -925,6 +916,14 @@ static int fsl_sai_runtime_suspend(struct device *dev) { struct fsl_sai *sai = dev_get_drvdata(dev); + if (sai->mclk_streams & BIT(SNDRV_PCM_STREAM_CAPTURE)) + clk_disable_unprepare(sai->mclk_clk[sai->mclk_id[0]]); + + if (sai->mclk_streams & BIT(SNDRV_PCM_STREAM_PLAYBACK)) + clk_disable_unprepare(sai->mclk_clk[sai->mclk_id[1]]); + + clk_disable_unprepare(sai->bus_clk); + regcache_cache_only(sai->regmap, true); regcache_mark_dirty(sai->regmap); @@ -934,6 +933,25 @@ static int fsl_sai_runtime_suspend(struct device *dev) static int fsl_sai_runtime_resume(struct device *dev) { struct fsl_sai *sai = dev_get_drvdata(dev); + int ret; + + ret = clk_prepare_enable(sai->bus_clk); + if (ret) { + dev_err(dev, "failed to enable bus clock: %d\n", ret); + return ret; + } + + if (sai->mclk_streams & BIT(SNDRV_PCM_STREAM_PLAYBACK)) { + ret = clk_prepare_enable(sai->mclk_clk[sai->mclk_id[1]]); + if (ret) + goto disable_bus_clk; + } + + if (sai->mclk_streams & BIT(SNDRV_PCM_STREAM_CAPTURE)) { + ret = clk_prepare_enable(sai->mclk_clk[sai->mclk_id[0]]); + if (ret) + goto disable_tx_clk; + } regcache_cache_only(sai->regmap, false); regmap_write(sai->regmap, FSL_SAI_TCSR, FSL_SAI_CSR_SR); @@ -941,7 +959,23 @@ static int fsl_sai_runtime_resume(struct device *dev) usleep_range(1000, 2000); regmap_write(sai->regmap, FSL_SAI_TCSR, 0); regmap_write(sai->regmap, FSL_SAI_RCSR, 0); - return regcache_sync(sai->regmap); + + ret = regcache_sync(sai->regmap); + if (ret) + goto disable_rx_clk; + + return 0; + +disable_rx_clk: + if (sai->mclk_streams & BIT(SNDRV_PCM_STREAM_CAPTURE)) + clk_disable_unprepare(sai->mclk_clk[sai->mclk_id[0]]); +disable_tx_clk: + if (sai->mclk_streams & BIT(SNDRV_PCM_STREAM_PLAYBACK)) + clk_disable_unprepare(sai->mclk_clk[sai->mclk_id[1]]); +disable_bus_clk: + clk_disable_unprepare(sai->bus_clk); + + return ret; } #endif /* CONFIG_PM */