From patchwork Mon Apr 22 19:02:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Baluta X-Patchwork-Id: 10911527 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 BB234161F for ; Mon, 22 Apr 2019 19:04:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACE0F286B0 for ; Mon, 22 Apr 2019 19:04:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A04EF287A6; Mon, 22 Apr 2019 19:04:25 +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 E8A67286B0 for ; Mon, 22 Apr 2019 19:04:24 +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 BF6F0862; Mon, 22 Apr 2019 21:03:32 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BF6F0862 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1555959862; bh=SX2f267Ejkk0To+U5Mu4Pgk424TAb0ePpfKuPB921CQ=; h=From:To:Date:References:In-Reply-To:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=oOAYR51e7tJzUg0kpEKq5iInTLKRx/hqgjViyFcJT9JeR8pC9TdIVx/Q+h14cAQxV vQ8+Pkx3NyBWp3U9xwPtuZIjwUHs1EAKCHZ1CyWtjqiLoujlvTgeqS5NlnIY79QIOL +4IsQlf75KEm1p6tf7Z6/qEVQI5Os5TASTyu9e8c= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 24B90F896E6; Mon, 22 Apr 2019 21:02:43 +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 B6F34F896E6; Mon, 22 Apr 2019 21:02:35 +0200 (CEST) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140089.outbound.protection.outlook.com [40.107.14.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C3FDDF80730 for ; Mon, 22 Apr 2019 21:02:31 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C3FDDF80730 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="a7HLeJqe" 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=K+RN83TExktH1D3DkBWK6UmuXPpvxogMg1Wv5ShCbrs=; b=a7HLeJqeWXNEnTaMMkVr2b+rMZYfcSQ6tgR/XGoIBnJKpMthuBKpbKLaPmKIBSg5UF+JlX2eZ4sLM4A+k8+K2TlD5aZN36lgtok46xWKsnHRsxFNdATOvs3AECZY/DkQtoH5cAwcfZkZaNUOzdGH8W8qOMxPyAFtcZdyXomb/00= Received: from VI1PR0402MB3357.eurprd04.prod.outlook.com (52.134.1.18) by VI1PR0402MB2815.eurprd04.prod.outlook.com (10.172.255.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1813.14; Mon, 22 Apr 2019 19:02:28 +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; Mon, 22 Apr 2019 19:02:28 +0000 From: Daniel Baluta To: "broonie@kernel.org" Thread-Topic: [PATCH v3 1/3] ASoC: fsl_sai: Update is_slave_mode with correct value Thread-Index: AQHU+T3ucLYQo18Ixk+PfyeYLkOx6w== Date: Mon, 22 Apr 2019 19:02:28 +0000 Message-ID: <20190422190213.30726-2-daniel.baluta@nxp.com> References: <20190422190213.30726-1-daniel.baluta@nxp.com> In-Reply-To: <20190422190213.30726-1-daniel.baluta@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR06CA0114.eurprd06.prod.outlook.com (2603:10a6:803:8c::43) 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: 872b39ab-a166-4476-b324-08d6c755105d 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:VI1PR0402MB2815; x-ms-traffictypediagnostic: VI1PR0402MB2815: x-microsoft-antispam-prvs: x-forefront-prvs: 00159D1518 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(376002)(366004)(396003)(346002)(39860400002)(199004)(189003)(2906002)(6512007)(53936002)(7736002)(305945005)(316002)(386003)(6506007)(99286004)(102836004)(52116002)(186003)(76176011)(8936002)(54906003)(50226002)(26005)(25786009)(4326008)(66066001)(8676002)(36756003)(6116002)(3846002)(6916009)(2501003)(81166006)(1730700003)(81156014)(68736007)(2351001)(5640700003)(14454004)(478600001)(71190400001)(64756008)(6486002)(66446008)(5660300002)(66556008)(97736004)(2616005)(476003)(44832011)(446003)(256004)(11346002)(86362001)(66476007)(73956011)(66946007)(6436002)(7416002)(486006)(1076003)(71200400001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0402MB2815; 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: tfDIJ2Eu85Z6S6ewrO56aZNo9taPM9byJhbV9ohGxzDECd0FaqJ2u/i/sLBZZoF+NF83g1AD+Yulpom1fXBmOdFf7CeS1RfS5RAQb5yGJdewaLvqQSk4q7ae5RCptpo2oHaDErZLF/V9+p0wZs/p4dvzFzcn/k+L1eraQA3kR6ScTayh+dY7fLe8suFMccPz/riTF6OsHzpLziKVf3dg2o9NJlWs6k16Oy2x1D65Ix1Weoaq9xNboJXW9IEYZWcvosxTeAuiItwP1D+HhN/P7yF0DvOW8dKLQXi+Epk+SDEoAM5iR5kcZDfmQTPkij26Av0mTKDxEqtuU5Aft9uNlUs1pe4MeqtUWuLM/6WUnHhhVF6g69OFGisW3NPSvu123u0fLF/D+npBWVorxvg4ky2IpPO5CWOl3vkEnaXZ1WE= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 872b39ab-a166-4476-b324-08d6c755105d X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Apr 2019 19:02:28.4290 (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: VI1PR0402MB2815 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" , dl-linux-imx , "festevam@gmail.com" , "linux-kernel@vger.kernel.org" Subject: [alsa-devel] [PATCH v3 1/3] ASoC: fsl_sai: Update is_slave_mode with correct value 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 is_slave_mode defaults to false because sai structure that contains it is kzalloc'ed. Anyhow, if we decide to set the following configuration SAI slave -> SAI master, is_slave_mode will remain set on true altough SAI being master it should be set to false. Fix this by updating is_slave_mode for each call of fsl_sai_set_dai_fmt. Signed-off-by: Daniel Baluta Acked-by: Nicolin Chen --- sound/soc/fsl/fsl_sai.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index b563004fb89f..d9df98975cf8 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -268,12 +268,14 @@ static int fsl_sai_set_dai_fmt_tr(struct snd_soc_dai *cpu_dai, case SND_SOC_DAIFMT_CBS_CFS: val_cr2 |= FSL_SAI_CR2_BCD_MSTR; val_cr4 |= FSL_SAI_CR4_FSD_MSTR; + sai->is_slave_mode = false; break; case SND_SOC_DAIFMT_CBM_CFM: sai->is_slave_mode = true; break; case SND_SOC_DAIFMT_CBS_CFM: val_cr2 |= FSL_SAI_CR2_BCD_MSTR; + sai->is_slave_mode = false; break; case SND_SOC_DAIFMT_CBM_CFS: val_cr4 |= FSL_SAI_CR4_FSD_MSTR; From patchwork Mon Apr 22 19:02:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Baluta X-Patchwork-Id: 10911541 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 D43E6161F for ; Mon, 22 Apr 2019 19:05:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C2E6926242 for ; Mon, 22 Apr 2019 19:05:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B36AD26E98; Mon, 22 Apr 2019 19:05:11 +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 DAB3326242 for ; Mon, 22 Apr 2019 19:05:10 +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 0336D86D; Mon, 22 Apr 2019 21:04:19 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0336D86D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1555959909; bh=dypVj1G0HSnNq31lH3ccvclQza0PuvtLW97Ikts3vIs=; h=From:To:Date:References:In-Reply-To:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=AUUDa5659WL+zaBFqxnLqQK5hd0qeVG/u/3o1ZxcEMiz170vhMx6eDLawFCgqq1hL fsHTi4k1fmFPSSE/KaHbv+Dk3LqLV9pe17DdEYmVfj9RZH9GfS5Mhqm/uPgRH6g2yZ 60fT/mU1mzV6O8yMn9SZzPUydfmzKa7GvEadD/vk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id BD899F896EE; Mon, 22 Apr 2019 21:02:44 +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 95152F896ED; Mon, 22 Apr 2019 21:02:37 +0200 (CEST) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140089.outbound.protection.outlook.com [40.107.14.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 166FDF896CC for ; Mon, 22 Apr 2019 21:02:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 166FDF896CC Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="xZl6YJ2k" 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=VQbr348hdlIG/WVBXd/HDcYL46Fa8R9qVum0dfFFreY=; b=xZl6YJ2kHkEq2MtqExQyEi0w3z/8iUpIrbEiSO/BhEjfYJjbb7X7djb0EsKQChnCNYndpxAUG6JTeQn2WwFYnNJSxRSej82WXz/GPFMY+45pqjoXPF0Z0noifhVXqmudAzAZBzzoD9SLRJ+96c4hQm89Ee63jt9SL/fAjNwsqf4= Received: from VI1PR0402MB3357.eurprd04.prod.outlook.com (52.134.1.18) by VI1PR0402MB2815.eurprd04.prod.outlook.com (10.172.255.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1813.14; Mon, 22 Apr 2019 19:02:29 +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; Mon, 22 Apr 2019 19:02:29 +0000 From: Daniel Baluta To: "broonie@kernel.org" Thread-Topic: [PATCH v3 2/3] ASoC: fsl_sai: Add support for runtime pm Thread-Index: AQHU+T3uWSULvj9plkCDwcPDgnoZEg== Date: Mon, 22 Apr 2019 19:02:29 +0000 Message-ID: <20190422190213.30726-3-daniel.baluta@nxp.com> References: <20190422190213.30726-1-daniel.baluta@nxp.com> In-Reply-To: <20190422190213.30726-1-daniel.baluta@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR06CA0114.eurprd06.prod.outlook.com (2603:10a6:803:8c::43) 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: 0187b151-05a0-4986-c90c-08d6c75510f5 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:VI1PR0402MB2815; x-ms-traffictypediagnostic: VI1PR0402MB2815: x-microsoft-antispam-prvs: x-forefront-prvs: 00159D1518 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(376002)(366004)(396003)(346002)(39860400002)(199004)(189003)(23433003)(2906002)(6512007)(53936002)(7736002)(305945005)(316002)(386003)(6506007)(99286004)(102836004)(52116002)(186003)(76176011)(8936002)(54906003)(50226002)(26005)(25786009)(4326008)(66066001)(8676002)(36756003)(6116002)(3846002)(6916009)(2501003)(81166006)(1730700003)(81156014)(68736007)(2351001)(5640700003)(14454004)(478600001)(71190400001)(64756008)(6486002)(66446008)(5660300002)(66556008)(97736004)(2616005)(476003)(44832011)(446003)(256004)(11346002)(14444005)(86362001)(66476007)(73956011)(66946007)(6436002)(7416002)(486006)(1076003)(71200400001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0402MB2815; 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: c//cS5hQENOnB1zgnbTDManeGLR7tSIxJSNrx+tdYIH5v5J1fk4TwqaVeVw8a+hACrxN+h0UJPEkMsy75lxfbLp3YScUV/kRyRc5vy3xQCw4/RV5G8Ag94qL/iX45WxB29Cazrpsn0XxTcBMRRh8qmObVvCvAsnQxYYe4bbgudXnPmVZ43VqJzGY1sOY6xJkFXbHVN4loyG9rI5aYUSKr5HXTdj10N0zbi4Cg34wBgnL1FS4ejOFpzB3MFPigOo5edp42AHaTpvlKZLj+rKqQaD0Vet5hCFuIhpo0q6uNBtii71Edh0tR3m8R3l7LGJLCPu/x4gbSV1YNJbdlMy4TZdOtXsCgdz26eXYdQ/lAaV1j3gv7T/pOiroOs8Uu5irsRsvkSLVfkzNb01Ibi7egPE2w8T4VIEtRSS6MWQBQYs= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0187b151-05a0-4986-c90c-08d6c75510f5 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Apr 2019 19:02:29.4467 (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: VI1PR0402MB2815 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" , dl-linux-imx , "festevam@gmail.com" , "linux-kernel@vger.kernel.org" Subject: [alsa-devel] [PATCH v3 2/3] 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 | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index d9df98975cf8..8623b7f882b9 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 @@ -900,6 +901,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) @@ -911,6 +914,11 @@ static int fsl_sai_probe(struct platform_device *pdev) return devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0); } +static int fsl_sai_remove(struct platform_device *pdev) +{ + pm_runtime_disable(&pdev->dev); +} + static const struct of_device_id fsl_sai_ids[] = { { .compatible = "fsl,vf610-sai", }, { .compatible = "fsl,imx6sx-sai", }, @@ -919,8 +927,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); @@ -930,7 +938,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); @@ -942,14 +950,18 @@ 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 = { .probe = fsl_sai_probe, + .remove = fsl_sai_remove, .driver = { .name = "fsl-sai", .pm = &fsl_sai_pm_ops, From patchwork Mon Apr 22 19:02:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Baluta X-Patchwork-Id: 10911551 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 F1F09922 for ; Mon, 22 Apr 2019 19:05:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E449D287AF for ; Mon, 22 Apr 2019 19:05:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D8232287C3; Mon, 22 Apr 2019 19:05:47 +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 1903F287AF for ; Mon, 22 Apr 2019 19:05:47 +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 4793A869; Mon, 22 Apr 2019 21:04:55 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4793A869 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1555959945; bh=B0VQITpJI/5IzGLv1LMYOAv3/yhjjcaA7IUuHYqfJkU=; h=From:To:Date:References:In-Reply-To:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=CsTchXVw0Qz2twKEqDT26JmxnUot+c9hMQfrHs1PI7VrQmCoXyNaAgun7Xmtsjv6f R2eiYChTOgQgGMErfKvUGdoqwmw98yRThi447tnu3j4Y+Qt45M5vL+UaaDVglmyd7h wAJ5EFmUYxBgYFojQTFR0B+rOKXjbG7L+vsFiOPA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id A58A3F89722; Mon, 22 Apr 2019 21:02:46 +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 A564DF896ED; Mon, 22 Apr 2019 21:02:41 +0200 (CEST) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140089.outbound.protection.outlook.com [40.107.14.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 66477F896DF for ; Mon, 22 Apr 2019 21:02:34 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 66477F896DF Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="smiKPVvS" 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=bEX3x3e0ljlPC40jBK3AsnHXWxgmFWIH2s0yE3NhOR0=; b=smiKPVvS/axkGOg8ejIj8yYNWf0lvhdXXTzmsj+4Oc6wmCEhv0HD3ThQzLA6GYhLmZNsgYmxW+25rCPoyQuKRfBkvp70gBj+vgCSSwh/IXgn93WcUpLzEVY9D/NHEUBW5jTqlxPvHziglCVMB4j8REGhluahj5B/gYPAkl13g0g= Received: from VI1PR0402MB3357.eurprd04.prod.outlook.com (52.134.1.18) by VI1PR0402MB2815.eurprd04.prod.outlook.com (10.172.255.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1813.14; Mon, 22 Apr 2019 19:02:30 +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; Mon, 22 Apr 2019 19:02:30 +0000 From: Daniel Baluta To: "broonie@kernel.org" Thread-Topic: [PATCH v3 3/3] ASoC: fsl_sai: Move clock operation to PM runtime Thread-Index: AQHU+T3vEZlYZN+pPk2qp55sbp9cMQ== Date: Mon, 22 Apr 2019 19:02:30 +0000 Message-ID: <20190422190213.30726-4-daniel.baluta@nxp.com> References: <20190422190213.30726-1-daniel.baluta@nxp.com> In-Reply-To: <20190422190213.30726-1-daniel.baluta@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR06CA0114.eurprd06.prod.outlook.com (2603:10a6:803:8c::43) 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: 5a377046-f2ed-4a72-ee3c-08d6c7551185 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:VI1PR0402MB2815; x-ms-traffictypediagnostic: VI1PR0402MB2815: x-microsoft-antispam-prvs: x-forefront-prvs: 00159D1518 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(376002)(366004)(396003)(346002)(39860400002)(199004)(189003)(2906002)(6512007)(53936002)(7736002)(305945005)(316002)(386003)(6506007)(99286004)(102836004)(52116002)(186003)(76176011)(8936002)(54906003)(50226002)(26005)(25786009)(4326008)(66066001)(8676002)(36756003)(6116002)(3846002)(6916009)(2501003)(81166006)(1730700003)(81156014)(68736007)(2351001)(5640700003)(14454004)(478600001)(71190400001)(64756008)(6486002)(66446008)(5660300002)(66556008)(97736004)(2616005)(476003)(44832011)(446003)(256004)(11346002)(14444005)(86362001)(66476007)(73956011)(66946007)(6436002)(7416002)(486006)(1076003)(71200400001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0402MB2815; 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: GPI0IkzsfgKqLo9zlJdd2hWl11iTlaWWXQVLvEKGHogqStj9qwEQxRvNxOux3Ozsc9rJicUbjtcx/DaHaLH4I8r28T68qFmgspj6h+U45tBC00x4xW5tdFvXL0atLNwTvwGaRd5Gbv0lp5emXjnYkZxRaFcyZ/+Q7W7+3h0aZxzJRvw6qSAM0JHLb1HyutXeevDVB1u7Eq2FplXRM0i5B5O5jR1otdVykd5S+k72tDkJfrZEu/I9euO5gTaRiGwVkJmTn29qY7CEonUIu/xr+iF74GvUQmz3bpCJqH6D9lxkHNYBCG14iUAkbdjdwHlDgxo6xmJq6mNAqsBOhv4PPauuqkwechVSMFjm84GTzr5UtAYv4UU88Bh1c++oHD/I63cIEizXMLOaA1+xOT8jcSCCnOBenLBn5aFgnBtBWSI= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5a377046-f2ed-4a72-ee3c-08d6c7551185 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Apr 2019 19:02:30.3444 (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: VI1PR0402MB2815 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" , dl-linux-imx , "festevam@gmail.com" , "linux-kernel@vger.kernel.org" Subject: [alsa-devel] [PATCH v3 3/3] ASoC: fsl_sai: 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 can help saving power. As a further optimization, we turn off/on mclk only when SAI is in master mode because otherwise mclk is externally provided. 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 8623b7f882b9..7fd1a81ec1aa 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -596,15 +596,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); @@ -621,8 +614,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 = { @@ -932,6 +923,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); @@ -941,6 +940,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); @@ -948,7 +966,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 */