From patchwork Wed Feb 22 11:39:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chancel Liu X-Patchwork-Id: 13149038 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D28B2C61DA4 for ; Wed, 22 Feb 2023 11:42:22 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 6ED78EC0; Wed, 22 Feb 2023 12:41:30 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6ED78EC0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1677066140; bh=WRcZP8TDXSmWSgac+1ln+Ko0r5VNqftPTqy29hM22qw=; h=From:To:Subject:Date:In-Reply-To:References:CC:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=h08RksNpzarOzkj0B87Czp8nn1Xaihkodm8Lm5kUCLjmwePjXGCcN2nm7nu9MJlCP iCObKjr+vfQFuE/2f7oCRyeCTKxtMSMsGTIVwIsNh6Zt9Ku+GviWWAMqOauvJFJhuC U40EnNdJY5+jV2HEvWIcSlxS901IDac4F7m6s16g= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 79ED2F80544; Wed, 22 Feb 2023 12:40:26 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 702A0F804FC; Wed, 22 Feb 2023 12:40:22 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2061d.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e1a::61d]) (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 BF66BF804FC for ; Wed, 22 Feb 2023 12:40:20 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz BF66BF804FC Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=nxp.com header.i=@nxp.com header.a=rsa-sha256 header.s=selector2 header.b=jMzIg925 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b5LdaaEr4tKFLLvgfDNi2bHGslgUfZum87olRM6wOfGw05GjPCbriIsm722ZCMJUCU7TG6BrRa0TLO8dLhK72BQwWIihC8ea7C9O57FTpI+oDPzcufUJeTBCIsL0wkDChX6H/21n3rbHzzUwrE2h0JmIwAsdKg2BH417jPAZsv/z28oeHUqHVweUKH9bt41pR/Pdemhvbq9JfvIZsbabbzUUnjF+V4r1iC5BW/vyP0gyXfPZFQtmqDXbApX6iYUODzQ3+CC6uLdyPpr0WA9+Zo6zEMyWZqN7rGkyXd5kfTHIrLEbeOC3+BRFWtzM4b+MTnNg7Vm1NzzbNWMxi+pYIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=H492h3zy+zQgFK4gbKLUlUZchyTJd7Y7VmAgomkPmho=; b=cTCwY72yTXWPrJLi+E2j/aAsSXa3+mZ7f9HNSBUvSIoDpXN4H5JysgkSf51FerAd8nOGlb1IcLBaP8X97Zc8jIo8P/V+g6UlFFtOiNhGddhoY5ZT1zSJLt6WCWEic3ILXzarvL7GzLXFe1LKLNWrsGRhyXGJjqbiWUp1timwrsjDx0Q3+LcfeBZGXn4QGCUXqQXfdXkyENLNT55wsAT/P64eCObOCH4d8mhvT1DlUQW1LR6QA7o7iZ9JpQsFLQzZDJxu1TKuJB4yypA9UBOARkoyDB+oPIOQRAr+pKDzBMqdIa5gQBvNivfwJRZipt0mmpBaTsvcrjrDeqs9BNMNxA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H492h3zy+zQgFK4gbKLUlUZchyTJd7Y7VmAgomkPmho=; b=jMzIg9259ks2Gl5wDTU89K4UhrUYXmMqHghs3JWk2aWXc6COK9t5Pfykl67o0RO8xPA1xwXFFzDa81lUddVkDg2lrLgijotBbDKn3pY1ax+T4QV/RotVVrZtsNYwxUDGHujLINyQ1R8q1nc/uSq6NGlzMGQ35nQN8vCnD9eoEgI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB4222.eurprd04.prod.outlook.com (2603:10a6:803:46::19) by PAXPR04MB8653.eurprd04.prod.outlook.com (2603:10a6:102:21c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.18; Wed, 22 Feb 2023 11:40:17 +0000 Received: from VI1PR04MB4222.eurprd04.prod.outlook.com ([fe80::8562:affc:e0c:c610]) by VI1PR04MB4222.eurprd04.prod.outlook.com ([fe80::8562:affc:e0c:c610%7]) with mapi id 15.20.6134.019; Wed, 22 Feb 2023 11:40:17 +0000 From: Chancel Liu To: lgirdwood@gmail.com, broonie@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, perex@perex.cz, tiwai@suse.com, ckeepax@opensource.cirrus.com, patches@opensource.cirrus.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 4/4] ASoC: wm8524: Delay some time to follow power up sequency Date: Wed, 22 Feb 2023 19:39:45 +0800 Message-Id: <20230222113945.3390672-4-chancel.liu@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230222113945.3390672-1-chancel.liu@nxp.com> References: <20230222113945.3390672-1-chancel.liu@nxp.com> X-ClientProxiedBy: SI2PR01CA0033.apcprd01.prod.exchangelabs.com (2603:1096:4:192::23) To VI1PR04MB4222.eurprd04.prod.outlook.com (2603:10a6:803:46::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB4222:EE_|PAXPR04MB8653:EE_ X-MS-Office365-Filtering-Correlation-Id: f3413fb6-69d0-416d-95a1-08db14c9921f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JYGOqS/TqkefrFnIgjIQq35lgPYF8yP3QtnP/6tV5jraXljyqCyVh/TYm+rVpC1/79kg2DB41NDObYR9UCyZDr9lKvw6iht0ED5WTi5UmA2Rm8p6jpknVjfgqQSA2amFuC0tUh+8f5Sd4hj4UaAmjP4wOApCrQP3Cvk2SqbqXUy9MhJSQK+KddQROsuoQ7xKlagHqAbldx6VnaldECw3cj2HZsUWgWpEQ2dU0eCWKcdCs1RhCFfQv3LM9MBU3GOdlyRWkkZPo9PIIug9dBUCpl8daDGszLtREOwt0ZvwpCxXmPq2uj6DIddgzfy0wL1CCeETTkNwGiGpe9yyj0Ao+0qSE1VHAYaLFt4IRuYh+ITcNnYwzuJd7vSZ2Gk8VNmhfpnnvDVPmIsVLKS/S/ve8OKMEeOtMgS6iEyBMsF+x1OhmPOJn4znScRtOXcUEyFK9Lmum8W//eyQgzCXhJnFs8HDJZt4BKBLMajPuqEfhfIw457EH3uvR2giMR2WDF8fcn9+9xGz1qarymm/O2HUxfvP8dGz51FpdE/0krISAjIJMiKAKxQ+qkf4zNy2hQ86rDV/wBiLWKrrUpmkMo6gC4R4Sst9PlQPcModPSRQ0S1zLVLSDZ97BWCsPysKqJLbkG0VhHJwQjmZhem8VwKJvnMMmNNHx7cE6qbGToSJYQG+P8tEcyVE3MYDoI3+eLn0 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB4222.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(136003)(346002)(396003)(39860400002)(366004)(376002)(451199018)(478600001)(86362001)(38100700002)(38350700002)(2906002)(44832011)(921005)(316002)(41300700001)(36756003)(7416002)(5660300002)(8936002)(83380400001)(4326008)(66476007)(66946007)(8676002)(66556008)(966005)(186003)(26005)(6486002)(1076003)(6506007)(6512007)(2616005)(6666004)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2Ia/wQRpp6kWkccXPVI4IWDRGP+WGzaEqWmP7GcRvQ1Iz6UFMC0bATYZfXsj1QXJs14WFpGwklHtlPZ6AtRV3cDuJ4WqjFR6dEufUY8rghRm4sYZ3nBskGBq7wDZFuq2M0zrslEWNzcnCCpwAMbgND26oJ+aHopIx85PIUJiQrKHtfAa8Q/cORDllR7m68e2jYOv8+Vh7Gx/ywgWlvKkW5v7XX/ctextwhrF8ssL8MWVPJqAjhaJoYmzhPLFWnnVQi4sU3h4gwu69Xewht5CkpccZcb7P3RSZ9e1sT8oCqQNkre7wt4uJYWYg4zX7Zu5Wg1wXxGbH47Y56U+76trq5TgWh+QGFwKwAz9qeW9JYZStGVlBKmnJhi2v1/e/Nf2LJUHGGdtVfWSScJp6j8olVnR778zQrYu5GtFd+E7Ybhq2nE84da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ZDQBVinZk0Yn3KurRTG3on2Fi65YzawAAblAzCrAnbXQl2byvgHPmGr2uX/nwnGNXJFI29fZTpNQxXHp X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f3413fb6-69d0-416d-95a1-08db14c9921f X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB4222.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2023 11:40:17.7613 (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-CrossTenant-UserPrincipalName: NuMNIp2xjQKVdZZjxMHBB9bvggRyh8cO0/S9oyQ197VQ23wpz/5hArDdJG0sAmjNtysW6HpI+m32r9ycmDSWYg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8653 Message-ID-Hash: EGPOZTXELBZVND2PN7N2GBZQG6TWUD37 X-Message-ID-Hash: EGPOZTXELBZVND2PN7N2GBZQG6TWUD37 X-MailFrom: chancel.liu@nxp.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Chancel Liu X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The recommended power sequence needs to be followed to ensure the best performance. After MCLK, BCLK and MUTE=1 are ready, this device has to wait some time before ready to output audio. Otherwise the beginning data may be lost. For more details about the timing constraints, please refer to WTN0302 on https://www.cirrus.com/products/wm8524/ Signed-off-by: Chancel Liu --- sound/soc/codecs/wm8524.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/sound/soc/codecs/wm8524.c b/sound/soc/codecs/wm8524.c index 8f2130e05b32..f61967b66c3b 100644 --- a/sound/soc/codecs/wm8524.c +++ b/sound/soc/codecs/wm8524.c @@ -21,6 +21,7 @@ #include #include +#define WM8524_POWER_UP_DELAY_MS 100 #define WM8524_NUM_RATES 7 /* codec private data */ @@ -29,6 +30,7 @@ struct wm8524_priv { unsigned int sysclk; unsigned int rate_constraint_list[WM8524_NUM_RATES]; struct snd_pcm_hw_constraint_list rate_constraint; + unsigned int power_up_delay; }; @@ -157,6 +159,28 @@ static int wm8524_mute_stream(struct snd_soc_dai *dai, int mute, int stream) return 0; } +static int wm8524_trigger(struct snd_pcm_substream *substream, int cmd, + struct snd_soc_dai *dai) +{ + struct wm8524_priv *wm8524 = snd_soc_dai_get_drvdata(dai); + + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + mdelay(wm8524->power_up_delay); + break; + case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + break; + default: + return -EINVAL; + } + + return 0; +}; + #define WM8524_RATES SNDRV_PCM_RATE_8000_192000 #define WM8524_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\ @@ -169,6 +193,7 @@ static const struct snd_soc_dai_ops wm8524_dai_ops = { .set_sysclk = wm8524_set_dai_sysclk, .set_fmt = wm8524_set_fmt, .mute_stream = wm8524_mute_stream, + .trigger = wm8524_trigger, }; static struct snd_soc_dai_driver wm8524_dai = { @@ -213,6 +238,7 @@ MODULE_DEVICE_TABLE(of, wm8524_of_match); static int wm8524_codec_probe(struct platform_device *pdev) { + struct device_node *np = pdev->dev.of_node; struct wm8524_priv *wm8524; int ret; @@ -230,6 +256,9 @@ static int wm8524_codec_probe(struct platform_device *pdev) return ret; } + wm8524->power_up_delay = WM8524_POWER_UP_DELAY_MS; + of_property_read_u32(np, "wlf,power-up-delay-ms", &wm8524->power_up_delay); + ret = devm_snd_soc_register_component(&pdev->dev, &soc_component_dev_wm8524, &wm8524_dai, 1); if (ret < 0)