From patchwork Tue Dec 13 11:28:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 32768 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp57928wrn; Tue, 13 Dec 2022 03:29:25 -0800 (PST) X-Google-Smtp-Source: AA0mqf6gMnTgoi2OybmyI5BP9JhVGBBuKmkyLzwGr6CuELesYCmOW5eSt/4jMnZAJ5grDDvB3iqt X-Received: by 2002:a17:907:789a:b0:7c1:2980:7fd8 with SMTP id ku26-20020a170907789a00b007c129807fd8mr17676922ejc.17.1670930965704; Tue, 13 Dec 2022 03:29:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670930965; cv=none; d=google.com; s=arc-20160816; b=gIhzXdShyxDnVDS689JLiwYnojlissSWhMccky+9orf/VRvyFxQM2m1GIKsKtRdKDD i57hUhG7CbrTWTSvsXfPsp2eIBXZP7SCuSg11ytnBmemLV+Hg2rlgxRHpxp8oFJeIL3P mK2tHX+ngQrf8ALX1XkazTr2Oz9SqQDZZUPVfJj5PG8KHuIYe5ff1hmutnp/Rg0bjvaX IITVf1YVmzZpIayBBS8eszNWFvZUxCBICrhianoEcLA3cDUxYzFd/dm96z7rcpH9eKfW ZfRETZBhO7bA9Qink6BU0xgkyx1slHOmkY5tykOpTtGqMWozPPazq4bcVufE8q6OyBsW y/Vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ghlTf0f+Kkhg6AkhkiAywfXx3QJQjTfKdjwG1YO0lRc=; b=ubW+k1lx4zC+DnPwTNuzJHW/wCEnI+RET8shqB3vsLFL1edAypoe3cVtjjsnnyBW2H U2rRrO5qqVvRT0IOe8/JLWQ7eFwgWtfZYLRnStHh/Z5KiSocOIxUUU/CuRR5WBhwhYbs tl1xkdQY4lQc9NrZjCIfd/j8W2hUMJ92S+K0YRwo7n8+gYoxU++4In4gmY0xDh7gmrAy ErBcZss7R2FEG06iJS1T2CMaTULsKfNQ40ArABH9/z5yiF1eCAgrMprgp0SGd9NTcq7C XQit5/FptTMS+YgrK+hxWke44h2VB0GhinlHN5lqVy132Za/cB39AVz0dclfpR0mvRkb 9r5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=dXhJkT6M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wv13-20020a170907080d00b007a1d4f0e7fcsi7868821ejb.655.2022.12.13.03.29.01; Tue, 13 Dec 2022 03:29:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=dXhJkT6M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235324AbiLMLXs (ORCPT + 99 others); Tue, 13 Dec 2022 06:23:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230061AbiLMLXi (ORCPT ); Tue, 13 Dec 2022 06:23:38 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D37401183B; Tue, 13 Dec 2022 03:23:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1670930616; x=1702466616; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=O6Yhf97L/pahv9g9FCa7RxbB9udp6xC8MQ4GIoD13oM=; b=dXhJkT6MAKRBo1qXGxX6QU+QcVe2H9rAdR6GBSWpw3WXbK3VaC4CHqxN 4qszrpVazdNrZb1BOTPYV9Ks/bMlvGhcemacaNtu2JNQuDBo6b2Qdqrvl 4YThPAP3H2HT3jCG6HD6/Z+hHg5I9ob85xixUb9Hly6qRDPiQ9dwOOlBR RTZKQ045oc3nzh20+CztJgVZsMim4T11UWAhmcUWhbej2lvrbOMHzm9po wRC4YRtu0EAmycbBKpOftVTdx0Aleaua9Ac9wPfhJu4klaPUM3IxNqwWd IuYRfN+YnCtVBc98tdgCyOosZ7FLTw2c7rRenBZ238DrQtXicEOvlxpbO A==; X-IronPort-AV: E=Sophos;i="5.96,241,1665471600"; d="scan'208";a="192862226" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 13 Dec 2022 04:23:36 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Tue, 13 Dec 2022 04:23:35 -0700 Received: from localhost.localdomain (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Tue, 13 Dec 2022 04:23:32 -0700 From: Claudiu Beznea To: , , , , , , , CC: , , , , Claudiu Beznea Subject: [PATCH v3 1/4] ASoC: dt-bindings: microchip: use proper naming syntax Date: Tue, 13 Dec 2022 13:28:48 +0200 Message-ID: <20221213112851.89212-2-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20221213112851.89212-1-claudiu.beznea@microchip.com> References: <20221213112851.89212-1-claudiu.beznea@microchip.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752098108597475838?= X-GMAIL-MSGID: =?utf-8?q?1752098108597475838?= Use the following syntax for Microchip ASoC YAML files: vendor,device.yaml Signed-off-by: Claudiu Beznea Acked-by: Krzysztof Kozlowski --- .../sound/{mchp,i2s-mcc.yaml => microchip,sama7g5-i2smcc.yaml} | 2 +- .../sound/{microchip,pdmc.yaml => microchip,sama7g5-pdmc.yaml} | 2 +- .../sound/{mchp,spdifrx.yaml => microchip,sama7g5-spdifrx.yaml} | 2 +- .../sound/{mchp,spdiftx.yaml => microchip,sama7g5-spdiftx.yaml} | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename Documentation/devicetree/bindings/sound/{mchp,i2s-mcc.yaml => microchip,sama7g5-i2smcc.yaml} (97%) rename Documentation/devicetree/bindings/sound/{microchip,pdmc.yaml => microchip,sama7g5-pdmc.yaml} (97%) rename Documentation/devicetree/bindings/sound/{mchp,spdifrx.yaml => microchip,sama7g5-spdifrx.yaml} (95%) rename Documentation/devicetree/bindings/sound/{mchp,spdiftx.yaml => microchip,sama7g5-spdiftx.yaml} (95%) diff --git a/Documentation/devicetree/bindings/sound/mchp,i2s-mcc.yaml b/Documentation/devicetree/bindings/sound/microchip,sama7g5-i2smcc.yaml similarity index 97% rename from Documentation/devicetree/bindings/sound/mchp,i2s-mcc.yaml rename to Documentation/devicetree/bindings/sound/microchip,sama7g5-i2smcc.yaml index 0481315cb5f2..68423f43ac3a 100644 --- a/Documentation/devicetree/bindings/sound/mchp,i2s-mcc.yaml +++ b/Documentation/devicetree/bindings/sound/microchip,sama7g5-i2smcc.yaml @@ -1,7 +1,7 @@ # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) %YAML 1.2 --- -$id: http://devicetree.org/schemas/sound/mchp,i2s-mcc.yaml# +$id: http://devicetree.org/schemas/sound/microchip,sama7g5-i2smcc.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# title: Microchip I2S Multi-Channel Controller diff --git a/Documentation/devicetree/bindings/sound/microchip,pdmc.yaml b/Documentation/devicetree/bindings/sound/microchip,sama7g5-pdmc.yaml similarity index 97% rename from Documentation/devicetree/bindings/sound/microchip,pdmc.yaml rename to Documentation/devicetree/bindings/sound/microchip,sama7g5-pdmc.yaml index 04414eb4ada9..7cc80dac980c 100644 --- a/Documentation/devicetree/bindings/sound/microchip,pdmc.yaml +++ b/Documentation/devicetree/bindings/sound/microchip,sama7g5-pdmc.yaml @@ -1,7 +1,7 @@ # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) %YAML 1.2 --- -$id: http://devicetree.org/schemas/sound/microchip,pdmc.yaml# +$id: http://devicetree.org/schemas/sound/microchip,sama7g5-pdmc.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# title: Microchip Pulse Density Microphone Controller diff --git a/Documentation/devicetree/bindings/sound/mchp,spdifrx.yaml b/Documentation/devicetree/bindings/sound/microchip,sama7g5-spdifrx.yaml similarity index 95% rename from Documentation/devicetree/bindings/sound/mchp,spdifrx.yaml rename to Documentation/devicetree/bindings/sound/microchip,sama7g5-spdifrx.yaml index 970311143253..5121ea1600ae 100644 --- a/Documentation/devicetree/bindings/sound/mchp,spdifrx.yaml +++ b/Documentation/devicetree/bindings/sound/microchip,sama7g5-spdifrx.yaml @@ -1,7 +1,7 @@ # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) %YAML 1.2 --- -$id: http://devicetree.org/schemas/sound/mchp,spdifrx.yaml# +$id: http://devicetree.org/schemas/sound/microchip,sama7g5-spdifrx.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# title: Microchip S/PDIF Rx Controller Device Tree Bindings diff --git a/Documentation/devicetree/bindings/sound/mchp,spdiftx.yaml b/Documentation/devicetree/bindings/sound/microchip,sama7g5-spdiftx.yaml similarity index 95% rename from Documentation/devicetree/bindings/sound/mchp,spdiftx.yaml rename to Documentation/devicetree/bindings/sound/microchip,sama7g5-spdiftx.yaml index d5c022e49526..d13e76269250 100644 --- a/Documentation/devicetree/bindings/sound/mchp,spdiftx.yaml +++ b/Documentation/devicetree/bindings/sound/microchip,sama7g5-spdiftx.yaml @@ -1,7 +1,7 @@ # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) %YAML 1.2 --- -$id: http://devicetree.org/schemas/sound/mchp,spdiftx.yaml# +$id: http://devicetree.org/schemas/sound/microchip,sama7g5-spdiftx.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# title: Microchip S/PDIF Tx Controller Device Tree Bindings From patchwork Tue Dec 13 11:28:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 32766 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp57690wrn; Tue, 13 Dec 2022 03:28:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf70kDit0n3UifdKQ46dHf0yfOIWoe9Vb2RBGDgAgFvzf/MqqKgvoM74FqYbFK9QPpoQYHC0 X-Received: by 2002:a17:906:dfed:b0:7c1:3f04:efa2 with SMTP id lc13-20020a170906dfed00b007c13f04efa2mr13593741ejc.29.1670930933554; Tue, 13 Dec 2022 03:28:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670930933; cv=none; d=google.com; s=arc-20160816; b=FiEk0Rvgfi1aGlwfs484snUyjQAccM+pKEN5I9gyQMjC77gVBVK/V+RKuTqvqdA3kP WympSiKC5omSkkdf9Vl9nYr7odaHrHzcyd15BuQmlwkw8bC7Ybxu6gENIKYZlc9+Hf+H rwY5CbttGvP67zS1WGFzzEQYbnNqKlAxM0qTKLIGEiKTSkkie4MRezDMu2cuLgRxUYpI 5j7vJNkyO4pLSKmBgBii45KMNUjIXj8ScE2yALqMHLAxbvCOmj95I1/x6lL86gE3PDdr q998na5TGg8yW9Utz9ZTUWPX4kFICHaFBMJ9z4sltuCk0V79ShMrQWKXS1s/XODdgWzB KbBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Ymwlfg+g/R1B/g2LMEfSu800Oe+qA/h93KtekGTD9vg=; b=IB1DRmqg9LRgjnX1btshPWLgK8gru1GLdeisGZHUFER/YUJ+YP+AKA5iGonWGO8wLb vflRBci8BpMqWIL/s8hE4LKIRBPmJrjGfs7CkrbZqBczUTDdLbwV7lQIvr/V2df3rYb+ uub3K6EWdXmvZ+rlxyIE52XeIgroZhaNwoC0+nNxGmhRStu5UCBf5KItId9lipVFXsy0 eLOlqN1htgGCXfuI8k5ayicVXiL/aJdkM4XhQBxAMe14qYEIZLw5gAL2coCzkUMeYCR4 ywZp5xfwh7EOw8fWI+JrVdT4ENhcvm7ZWVqXVqQCgF/fgV44zy1Tp+ewNZLIvyZBOT8I +xNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=Jvf0gRpY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sb21-20020a1709076d9500b007c16fb7f178si5086305ejc.962.2022.12.13.03.28.30; Tue, 13 Dec 2022 03:28:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=Jvf0gRpY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235299AbiLMLYU (ORCPT + 99 others); Tue, 13 Dec 2022 06:24:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235228AbiLMLXl (ORCPT ); Tue, 13 Dec 2022 06:23:41 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C28FB31C; Tue, 13 Dec 2022 03:23:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1670930619; x=1702466619; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Mr8bvoDR3kP1Rf0wpZPD+P1CiMLnicoQSVkgRqx6GS4=; b=Jvf0gRpYMZ291v8vTjNdYvh4fOGByIbHa5heNq5G7KQY12itF7hmImgH cZZN8y0M0waa+4/veW+x0IFQrEsl6A8RFBMAClysAI33nhLIlTK6pkDK6 srcpgPMs15qwlgwWC0xfm9nC4Lq9bVLxkruKRNDB4CXJLnDWzWyyshvNm xSOndCDJHgIzF7438aUWnvlUa2asZMK0/6YgX+raBTWRnVppz9oRGBmQQ 3kELcQi4iodSUc0FnWLBK0Mo60tnAXKGXQ7uwhbwcc9B8IJUaC9afFu4l tfP+DuXjF80dgdRBP4fw2FRbPlzD0UtascO67EzZ3O8UiuIxoPfKqnHWW w==; X-IronPort-AV: E=Sophos;i="5.96,241,1665471600"; d="scan'208";a="192862229" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 13 Dec 2022 04:23:39 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Tue, 13 Dec 2022 04:23:38 -0700 Received: from localhost.localdomain (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Tue, 13 Dec 2022 04:23:35 -0700 From: Claudiu Beznea To: , , , , , , , CC: , , , , Claudiu Beznea Subject: [PATCH v3 2/4] ASoC: mchp-pdmc: use runtime pm for clock power saving Date: Tue, 13 Dec 2022 13:28:49 +0200 Message-ID: <20221213112851.89212-3-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20221213112851.89212-1-claudiu.beznea@microchip.com> References: <20221213112851.89212-1-claudiu.beznea@microchip.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752098074542022545?= X-GMAIL-MSGID: =?utf-8?q?1752098074542022545?= Implement clock power saving taking advantage of runtime PM infrastructure. This simplifies the code and allow using the same infrastructure for suspend to RAM functionalities. Signed-off-by: Claudiu Beznea --- sound/soc/atmel/mchp-pdmc.c | 126 ++++++++++++++++++++++++------------ 1 file changed, 84 insertions(+), 42 deletions(-) diff --git a/sound/soc/atmel/mchp-pdmc.c b/sound/soc/atmel/mchp-pdmc.c index 44aefbd5b62c..f184404e74e5 100644 --- a/sound/soc/atmel/mchp-pdmc.c +++ b/sound/soc/atmel/mchp-pdmc.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -115,7 +116,6 @@ struct mchp_pdmc { int mic_no; int sinc_order; bool audio_filter_en; - u8 gclk_enabled:1; }; static const char *const mchp_pdmc_sinc_filter_order_text[] = { @@ -454,13 +454,6 @@ static int mchp_pdmc_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct mchp_pdmc *dd = snd_soc_dai_get_drvdata(dai); - int ret; - - ret = clk_prepare_enable(dd->pclk); - if (ret) { - dev_err(dd->dev, "failed to enable the peripheral clock: %d\n", ret); - return ret; - } regmap_write(dd->regmap, MCHP_PDMC_CR, MCHP_PDMC_CR_SWRST); @@ -470,14 +463,6 @@ static int mchp_pdmc_startup(struct snd_pcm_substream *substream, return 0; } -static void mchp_pdmc_shutdown(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct mchp_pdmc *dd = snd_soc_dai_get_drvdata(dai); - - clk_disable_unprepare(dd->pclk); -} - static int mchp_pdmc_dai_probe(struct snd_soc_dai *dai) { struct mchp_pdmc *dd = snd_soc_dai_get_drvdata(dai); @@ -594,11 +579,6 @@ static int mchp_pdmc_hw_params(struct snd_pcm_substream *substream, cfgr_val |= MCHP_PDMC_CFGR_BSSEL(i); } - if (dd->gclk_enabled) { - clk_disable_unprepare(dd->gclk); - dd->gclk_enabled = 0; - } - for (osr_start = dd->audio_filter_en ? 64 : 8; osr_start <= 256 && best_diff_rate; osr_start *= 2) { long round_rate; @@ -620,8 +600,12 @@ static int mchp_pdmc_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } + /* CLK is enabled by runtime PM. */ + clk_disable_unprepare(dd->gclk); + /* set the rate */ ret = clk_set_rate(dd->gclk, gclk_rate); + clk_prepare_enable(dd->gclk); if (ret) { dev_err(comp->dev, "unable to set rate %lu to GCLK: %d\n", gclk_rate, ret); @@ -636,9 +620,6 @@ static int mchp_pdmc_hw_params(struct snd_pcm_substream *substream, mr_val |= MCHP_PDMC_MR_CHUNK(dd->addr.maxburst); dev_dbg(comp->dev, "maxburst set to %d\n", dd->addr.maxburst); - clk_prepare_enable(dd->gclk); - dd->gclk_enabled = 1; - snd_soc_component_update_bits(comp, MCHP_PDMC_MR, MCHP_PDMC_MR_OSR_MASK | MCHP_PDMC_MR_SINCORDER_MASK | @@ -650,19 +631,6 @@ static int mchp_pdmc_hw_params(struct snd_pcm_substream *substream, return 0; } -static int mchp_pdmc_hw_free(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct mchp_pdmc *dd = snd_soc_dai_get_drvdata(dai); - - if (dd->gclk_enabled) { - clk_disable_unprepare(dd->gclk); - dd->gclk_enabled = 0; - } - - return 0; -} - static int mchp_pdmc_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { @@ -711,9 +679,7 @@ static int mchp_pdmc_trigger(struct snd_pcm_substream *substream, static const struct snd_soc_dai_ops mchp_pdmc_dai_ops = { .set_fmt = mchp_pdmc_set_fmt, .startup = mchp_pdmc_startup, - .shutdown = mchp_pdmc_shutdown, .hw_params = mchp_pdmc_hw_params, - .hw_free = mchp_pdmc_hw_free, .trigger = mchp_pdmc_trigger, }; @@ -864,6 +830,7 @@ static const struct regmap_config mchp_pdmc_regmap_config = { .readable_reg = mchp_pdmc_readable_reg, .writeable_reg = mchp_pdmc_writeable_reg, .precious_reg = mchp_pdmc_precious_reg, + .cache_type = REGCACHE_FLAT, }; static int mchp_pdmc_dt_init(struct mchp_pdmc *dd) @@ -970,6 +937,49 @@ static struct snd_dmaengine_pcm_config mchp_pdmc_config = { .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config, }; +static int mchp_pdmc_runtime_suspend(struct device *dev) +{ + struct mchp_pdmc *dd = dev_get_drvdata(dev); + + regcache_cache_only(dd->regmap, true); + + clk_disable_unprepare(dd->gclk); + clk_disable_unprepare(dd->pclk); + + return 0; +} + +static int mchp_pdmc_runtime_resume(struct device *dev) +{ + struct mchp_pdmc *dd = dev_get_drvdata(dev); + int ret; + + ret = clk_prepare_enable(dd->pclk); + if (ret) { + dev_err(dd->dev, + "failed to enable the peripheral clock: %d\n", ret); + return ret; + } + ret = clk_prepare_enable(dd->gclk); + if (ret) { + dev_err(dd->dev, + "failed to enable generic clock: %d\n", ret); + goto disable_pclk; + } + + regcache_cache_only(dd->regmap, false); + regcache_mark_dirty(dd->regmap); + ret = regcache_sync(dd->regmap); + if (ret) { + regcache_cache_only(dd->regmap, true); + clk_disable_unprepare(dd->gclk); +disable_pclk: + clk_disable_unprepare(dd->pclk); + } + + return ret; +} + static int mchp_pdmc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -1039,18 +1049,25 @@ static int mchp_pdmc_probe(struct platform_device *pdev) dd->addr.addr = (dma_addr_t)res->start + MCHP_PDMC_RHR; platform_set_drvdata(pdev, dd); + pm_runtime_enable(dd->dev); + if (!pm_runtime_enabled(dd->dev)) { + ret = mchp_pdmc_runtime_resume(dd->dev); + if (ret) + return ret; + } + /* register platform */ ret = devm_snd_dmaengine_pcm_register(dev, &mchp_pdmc_config, 0); if (ret) { dev_err(dev, "could not register platform: %d\n", ret); - return ret; + goto pm_runtime_suspend; } ret = devm_snd_soc_register_component(dev, &mchp_pdmc_dai_component, &mchp_pdmc_dai, 1); if (ret) { dev_err(dev, "could not register CPU DAI: %d\n", ret); - return ret; + goto pm_runtime_suspend; } /* print IP version */ @@ -1059,6 +1076,25 @@ static int mchp_pdmc_probe(struct platform_device *pdev) version & MCHP_PDMC_VER_VERSION); return 0; + +pm_runtime_suspend: + if (!pm_runtime_status_suspended(dd->dev)) + mchp_pdmc_runtime_suspend(dd->dev); + pm_runtime_disable(dd->dev); + + return ret; +} + +static int mchp_pdmc_remove(struct platform_device *pdev) +{ + struct mchp_pdmc *dd = platform_get_drvdata(pdev); + + if (!pm_runtime_status_suspended(dd->dev)) + mchp_pdmc_runtime_suspend(dd->dev); + + pm_runtime_disable(dd->dev); + + return 0; } static const struct of_device_id mchp_pdmc_of_match[] = { @@ -1070,13 +1106,19 @@ static const struct of_device_id mchp_pdmc_of_match[] = { }; MODULE_DEVICE_TABLE(of, mchp_pdmc_of_match); +static const struct dev_pm_ops mchp_pdmc_pm_ops = { + RUNTIME_PM_OPS(mchp_pdmc_runtime_suspend, mchp_pdmc_runtime_resume, + NULL) +}; + static struct platform_driver mchp_pdmc_driver = { .driver = { .name = "mchp-pdmc", .of_match_table = of_match_ptr(mchp_pdmc_of_match), - .pm = &snd_soc_pm_ops, + .pm = pm_ptr(&mchp_pdmc_pm_ops), }, .probe = mchp_pdmc_probe, + .remove = mchp_pdmc_remove, }; module_platform_driver(mchp_pdmc_driver); From patchwork Tue Dec 13 11:28:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 32770 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp58493wrn; Tue, 13 Dec 2022 03:30:38 -0800 (PST) X-Google-Smtp-Source: AA0mqf486FYbOuEvl/1vmrnHCRAD3LXPMPivr9K4vBGfyBkWi/0kfo9zI26VgdjYAUR837Ko9lzG X-Received: by 2002:a05:6402:c2:b0:468:9bc4:1c7 with SMTP id i2-20020a05640200c200b004689bc401c7mr21607542edu.38.1670931038324; Tue, 13 Dec 2022 03:30:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670931038; cv=none; d=google.com; s=arc-20160816; b=fTWn3GyUrxrnG1sPwQ8WnbAHTr7kIr+6D6b3siE8NIGrxV8/MUi7lehHqKCbvNvJ+b /F0cYuDjAVq5pvg+dBLF2QB9/qT346H8cDOJw7yxqUqLfsZvP2C0Cs8wPX0c4fDVQR8+ EIM/HMpLiyhkP4nu5LWiseldpropH6KNEPZlXXMyHt14U1FEe0v1odfkYw+i0tqKPeJ4 0jvEE6bOZwJR3sYGJy/jF1wK+5ZFzYmvb5Tdh8LbJX3CUZts+pMQBVq97wdV6stJDYwP YuNqWDYZiDr01d1wd2LLq+jzxYjlhF+LMhAqDGwzb1p/r6j2aQ3EZRhompomAfgpcdrr chgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uPb+mghbVNFT/AH4t5vOdKM6NTcdUwPcx9VbYtlE5W8=; b=ZQpEqJOllPinBsbBF0LBTJ36zhiV6HhUfBWPtz1MLi3Ijy88QMUeDo3s8C0eNI9sZZ 8cGC2xbNQOxyWBzDX5RNf5J4sPC7sjZCto+meY+eCh/cNxO2gf7H+rrqkgs7uy9QC04H 30R56qlftHWy5KXHCBqrKgW+6pY3yuWWRaEqd+IcNHmwUd6oOgHPPp0bbQEZVYxsjs87 YECX8pVB68akIKIlc0Kmk5gvw2pjiQB7lLxazPFB9XeKOLIVuiF/LhJfOIMad7+xsJkz 8J8abRiCnN3lyLXvc7OdSHkjusNEwUmnd4yOgtZ++Yc87gWgrDQpCHtEHgFrFDPQPP8D vmVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=eJpeLcVo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id du9-20020a17090772c900b007ae377adb6asi8841204ejc.628.2022.12.13.03.30.13; Tue, 13 Dec 2022 03:30:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=eJpeLcVo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235215AbiLMLYX (ORCPT + 99 others); Tue, 13 Dec 2022 06:24:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235309AbiLMLXp (ORCPT ); Tue, 13 Dec 2022 06:23:45 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67BFE13F45; Tue, 13 Dec 2022 03:23:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1670930625; x=1702466625; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=skGTs2WvA6zYDm87dHeVl8kymrVloAz2yV13MCgFbvY=; b=eJpeLcVonPhOGUXaRuQeRcHiIACSDw0Q/GpDLRbvo+4sN94+AI5sIo2p U+WZcvm7A2L4GBtn2YhbrUMXWNa+2sq73iDVvqxuMCNKuC21zAF0tyuhJ 1ZfbBemD4DjCv/QFf72WFUw8f9J7bI9R6ov7mqNr5CFlbkOvfkc7TwCOz +N7Q8p9wuShtuRcWHvOIdjNAPCdM1RhQ52szjJb+WKwWheVxvBJjDKeL/ eIalk/6hwRHtDjmqjKF+Wcyca4Peb6SmsRC98otDBT1I1XmA1Z+/+UEOL ztkQP8wzDrg7a6GghePDoV8+hEpNPr7PTy3WpksN9K7kCsRQEjnjnjzmK A==; X-IronPort-AV: E=Sophos;i="5.96,241,1665471600"; d="scan'208";a="187911755" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 13 Dec 2022 04:23:44 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Tue, 13 Dec 2022 04:23:42 -0700 Received: from localhost.localdomain (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Tue, 13 Dec 2022 04:23:39 -0700 From: Claudiu Beznea To: , , , , , , , CC: , , , , Claudiu Beznea Subject: [PATCH v3 3/4] ASoC: mchp-pdmc: add support for suspend to RAM Date: Tue, 13 Dec 2022 13:28:50 +0200 Message-ID: <20221213112851.89212-4-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20221213112851.89212-1-claudiu.beznea@microchip.com> References: <20221213112851.89212-1-claudiu.beznea@microchip.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752098184442727902?= X-GMAIL-MSGID: =?utf-8?q?1752098184442727902?= Add support for suspend to RAM by re-aranging the lines in switch..case from mchp_pdmc_trigger() and saving/restoring the enabled interrupts. These are necessary as AT91 devices has a special power saving mode (called backup and self-refresh) where most of the SoC parts are powered off and thus we need to reconfigure the PDMC on resume. Signed-off-by: Claudiu Beznea --- sound/soc/atmel/mchp-pdmc.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/sound/soc/atmel/mchp-pdmc.c b/sound/soc/atmel/mchp-pdmc.c index f184404e74e5..cf4084dcbd5e 100644 --- a/sound/soc/atmel/mchp-pdmc.c +++ b/sound/soc/atmel/mchp-pdmc.c @@ -113,6 +113,7 @@ struct mchp_pdmc { struct clk *pclk; struct clk *gclk; u32 pdmcen; + u32 suspend_irq; int mic_no; int sinc_order; bool audio_filter_en; @@ -641,22 +642,27 @@ static int mchp_pdmc_trigger(struct snd_pcm_substream *substream, #endif switch (cmd) { - case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + case SNDRV_PCM_TRIGGER_START: /* Enable overrun and underrun error interrupts */ - regmap_write(dd->regmap, MCHP_PDMC_IER, + regmap_write(dd->regmap, MCHP_PDMC_IER, dd->suspend_irq | MCHP_PDMC_IR_RXOVR | MCHP_PDMC_IR_RXUDR); + dd->suspend_irq = 0; + fallthrough; + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: snd_soc_component_update_bits(cpu, MCHP_PDMC_MR, MCHP_PDMC_MR_PDMCEN_MASK, dd->pdmcen); break; - case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + regmap_read(dd->regmap, MCHP_PDMC_IMR, &dd->suspend_irq); + fallthrough; + case SNDRV_PCM_TRIGGER_STOP: /* Disable overrun and underrun error interrupts */ - regmap_write(dd->regmap, MCHP_PDMC_IDR, + regmap_write(dd->regmap, MCHP_PDMC_IDR, dd->suspend_irq | MCHP_PDMC_IR_RXOVR | MCHP_PDMC_IR_RXUDR); + fallthrough; + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: snd_soc_component_update_bits(cpu, MCHP_PDMC_MR, MCHP_PDMC_MR_PDMCEN_MASK, 0); break; @@ -1107,6 +1113,7 @@ static const struct of_device_id mchp_pdmc_of_match[] = { MODULE_DEVICE_TABLE(of, mchp_pdmc_of_match); static const struct dev_pm_ops mchp_pdmc_pm_ops = { + SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) RUNTIME_PM_OPS(mchp_pdmc_runtime_suspend, mchp_pdmc_runtime_resume, NULL) }; From patchwork Tue Dec 13 11:28:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 32769 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp58496wrn; Tue, 13 Dec 2022 03:30:38 -0800 (PST) X-Google-Smtp-Source: AA0mqf5Br9ldUu0bccI/9c7YssadsSmXjdvxGeP0PpufS6O3kg/fePrPCGcVB7a+piVKktjR5Y1W X-Received: by 2002:a50:eb81:0:b0:46f:a6ea:202 with SMTP id y1-20020a50eb81000000b0046fa6ea0202mr1903175edr.37.1670931038328; Tue, 13 Dec 2022 03:30:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670931038; cv=none; d=google.com; s=arc-20160816; b=FN5zdouECv3k3p0waSaz30IueHtAVohOJQlDkuI0sKgrKYg2J59h7GV9iYAJSXCE1r 2JVSU2o42WviUAJBlovmUv25oapVg2eNNv/dKphNP7smv7Rfp71JB6ZUCldrQ4ojKtZ0 C9Zz9uUmy1NuklZZnajgL26Yn77B4CLBACZ256n1rAl9mtoLyX1JGVuu/fjCPrzF6XHy q5BZ6Lc9Xj2yN2jMvWKPy4wYKZAqtqsL+RCnqPyvRbGL7aeZIO3qdTvP0FFb81E/5ZY8 u7SFi3TjYcdS5ALZQ6b/yONFm/TsHIiyzAGKFoVs7AaVm/E3nunMtMf91eGnCk1AvalP kmPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JQfTsK396DLPhAuSdGWTTzRM+D52T/OtNrP7M1VMPqQ=; b=kJJrrVDdfyzW/DsCwBxDLyglU5C6r216jAxacbWOJGxYrscWsXZ1ZFW260lAbif5kO AcW/c89YQazJgFsTvPuFeFvZvb/9DIKxqy8GVG+WwtitGeS1JOj8iotNz0pEKD6ddY+M T7jUGzrf79mqsxEoCK1lpPm8slKF/w8cuOuraTPztm6gb27DAYHF1m/7X01fuzL+2cE/ ArEjP5RLdxrzUAxZV1G7gSSdD5mdzvr5MyHQVA8yH6rXbfptLaWBkzynPodl3N/HNGUh P/oOHy49I8sMTPAx1TP1lsTRZyQCRJZlsXF3zCuHLl2hcw57toXPnwccEAzsKjBnTe8Z kI7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=f6RJhkpy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji14-20020a170907980e00b007ad69eba328si9759968ejc.539.2022.12.13.03.30.14; Tue, 13 Dec 2022 03:30:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=f6RJhkpy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235315AbiLMLYd (ORCPT + 99 others); Tue, 13 Dec 2022 06:24:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235343AbiLMLXw (ORCPT ); Tue, 13 Dec 2022 06:23:52 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B7CC13F38; Tue, 13 Dec 2022 03:23:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1670930628; x=1702466628; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5xjzRZVtRE1cVlsbZZS0eIcjhBI2JgzIzQmwqEVYM3I=; b=f6RJhkpyAF08NSBjqTdnuVp0NA+nyExxAyi3XrBbq7SwJqqyEkhUtWVe 0X8sMtG3p6JGNy+7iMETbHJ/ySk8XMyDM+jGUMFLysK3igkHb39g/LPnf L1yvSoG+8aIvKyeENOhyugUxIn4x/lyYKblyIdHiN4idroRzMvmmSKp/N 3vtY9rr8Dq8oSduNU6Sf9pch0rTwOIjbt3k7Huup/wzNITQQYHlHaPGlN pcT/4z2DdPNYTwL7nvgGwqAIOuw70gQf0/TAlcYm7vd6q9Q1AKD2bJo5G Kn+ZGN2MBVv3t3DqVFL1ppFUG9/uLn4aYT0pQy9UnOcCutTa8y5TMUCkK w==; X-IronPort-AV: E=Sophos;i="5.96,241,1665471600"; d="scan'208";a="191416487" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 13 Dec 2022 04:23:47 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Tue, 13 Dec 2022 04:23:45 -0700 Received: from localhost.localdomain (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Tue, 13 Dec 2022 04:23:42 -0700 From: Claudiu Beznea To: , , , , , , , CC: , , , , Claudiu Beznea Subject: [PATCH v3 4/4] ASoC: mchp-spdiftx: use FIELD_PREP() where possible Date: Tue, 13 Dec 2022 13:28:51 +0200 Message-ID: <20221213112851.89212-5-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20221213112851.89212-1-claudiu.beznea@microchip.com> References: <20221213112851.89212-1-claudiu.beznea@microchip.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752098184792310069?= X-GMAIL-MSGID: =?utf-8?q?1752098184792310069?= Use FIELD_PREP() in macro definitions. Signed-off-by: Claudiu Beznea --- sound/soc/atmel/mchp-spdiftx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/soc/atmel/mchp-spdiftx.c b/sound/soc/atmel/mchp-spdiftx.c index dc96a6fbf514..20d135c718b0 100644 --- a/sound/soc/atmel/mchp-spdiftx.c +++ b/sound/soc/atmel/mchp-spdiftx.c @@ -6,6 +6,7 @@ // // Author: Codrin Ciubotariu +#include #include #include #include @@ -71,11 +72,11 @@ /* Valid Bits per Sample */ #define SPDIFTX_MR_VBPS_MASK GENMASK(13, 8) -#define SPDIFTX_MR_VBPS(bps) (((bps) << 8) & SPDIFTX_MR_VBPS_MASK) +#define SPDIFTX_MR_VBPS(bps) FIELD_PREP(SPDIFTX_MR_VBPS_MASK, bps) /* Chunk Size */ #define SPDIFTX_MR_CHUNK_MASK GENMASK(19, 16) -#define SPDIFTX_MR_CHUNK(size) (((size) << 16) & SPDIFTX_MR_CHUNK_MASK) +#define SPDIFTX_MR_CHUNK(size) FIELD_PREP(SPDIFTX_MR_CHUNK_MASK, size) /* Validity Bits for Channels 1 and 2 */ #define SPDIFTX_MR_VALID1 BIT(24) @@ -88,8 +89,7 @@ /* Bytes per Sample */ #define SPDIFTX_MR_BPS_MASK GENMASK(29, 28) -#define SPDIFTX_MR_BPS(bytes) \ - ((((bytes) - 1) << 28) & SPDIFTX_MR_BPS_MASK) +#define SPDIFTX_MR_BPS(bytes) FIELD_PREP(SPDIFTX_MR_BPS_MASK, (bytes - 1)) /* * ---- Interrupt Enable/Disable/Mask/Status Register (Write/Read-only) ----