Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795056714; b=CFArIWSOca2lR5iUjyzXvLKSm1bUzX3WxEiidjOH5jPeGF48r2I833bOlRnn7bhH2OvY nhmCT+MdG/hOewnxEqzZybDof11oOSwGLnvVGtDC2AApKF/TQsv0QaVmEf6AjrPVB7M5n VLpcVw6ecQXaSTwfcQygFvuYPkYbbOn8Y1toOFFD79ayd1meE1+GLR4MIbh/FJnKzbqus CoP3FeUJ+EDTfaRqKZMRkPbSO8kNllKph5QHnszIc/JNOLJAVRb34t8LByiy03V2kq0MG QwIA7DSll1R5opOlIvONg6LCowoGVrbLdDASoQG5TL2FCFDK8PG1aaZLW+ofPZnm3ig== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795056714; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=xO1Eo/BgoxkUXCZLJMiAbLIooF2vPwd+TwZm33fF/1Q=; b=n0t4tgTD+iocUxuAN6idDUXeHkvZBWS2ulqAaNMSu1teiFJ1HyAABv3ckEWkZZhdzFHH xvdK/zz71+XqvbqaqAwEu5bkdRX8cdZsnYdqNVNA8HeGBvdE9fIBWH4iDTj73VC9Cheeb CGrfieLWPD+wUQZC83eYycqsbK9B1ktAVsj8ydaadzaOUFDERpeaQWHbWN+VLARqZpq2U 75xrCKw+uQCD0tUI8xexYAHapzCSu+nU4v3/wokPM2m5suSSlRfpBm6yltEvnPbAuLkv/ vu+1jI6A/NsZ918Rz4xHinkYpqPME1Iwcw+IN2sGDnhFB9+PHN5KPjqKOE8te7bEiJw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=fk21t6YP; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 069AB606A32C; Thu, 19 Nov 2026 02:51:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=fk21t6YP Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B2B61F000C4; Thu, 19 Nov 2026 02:51:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795056713; bh=xO1Eo/BgoxkUXCZLJMiAbLIooF2vPwd+TwZm33fF/1Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fk21t6YPdy0yA0elxBV+pQcajDwjnbx1pEbBeRbXMpWHXSG/M4mU/E3oJKsbIjmq4 QltQkpZzJkF6jhuy8VI3uXZhIOFthbnw5L6N9PkeY0vxY32Zco46ssaY2tYfjQqtr7 fp9LLSlQjL6RoJzYjDtv16FjeHgnwxg7nIt55mIs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Marek Szyprowski , Charles Keepax , Sylwester Nawrocki , Mark Brown , Sasha Levin Subject: [PATCH 5.15 2087/2214] ASoC: wm8994: dont lose the AIF clock ratio when staying at 32kHz SYSCLK Date: Wed, 18 Nov 2026 16:02:43 +0100 Message-ID: <20261118150134.117340955@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150009.797899913@linuxfoundation.org> References: <20261118150009.797899913@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Marek Szyprowski [ Upstream commit 693574504051a19383640cfb99524a6b69e4624f ] When SYSCLK drops below 50kHz, the AIFnCLK rate ratio is saved and temporarily lowered to 128fs for accessory detection, then restored once SYSCLK gets fast enough again. The ratio is however saved again on each clock reconfiguration done while SYSCLK is still slow, which overwrites the original ratio with the 128fs one. This happens on the Exynos4412 Trats2 board, which set MCLK2 as SYSCLK twice during the card probe and then configure FLL1 while still running from MCLK2. Once SYSCLK is switched to FLL1, the 128fs ratio is "restored", so AIF1 is left configured for 48kHz at 128fs while being clocked at 256fs. If any digital path is powered up before a stream reconfigures the AIF, the codec raises FIFO error interrupts every 10ms, flooding the kernel log: wm8994-codec wm8994-codec: FIFO error Save the original ratio only when entering the low SYSCLK mode. While at it, move the code duplicated in _wm8994_set_fll() and wm8994_set_dai_sysclk() to a common helper. Fixes: 6730049a4763 ("ASoC: wm8994: Lower AIFnCLK divisor when dropping to 32kHz") Signed-off-by: Marek Szyprowski Reviewed-by: Charles Keepax Reviewed-by: Sylwester Nawrocki Link: https://patch.msgid.link/20261021101750.3297770-3-m.szyprowski@samsung.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/codecs/wm8994.c | 94 +++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 54 deletions(-) diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c index 0c121fc4b750d..01809e8b0dbd9 100644 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c @@ -2210,6 +2210,44 @@ static int wm8994_get_fll_config(struct wm8994 *control, struct fll_div *fll, return 0; } +/* + * If SYSCLK is less than 50kHz adjust AIFnCLK dividers for detection, + * restoring the original ones once SYSCLK is fast enough again. + */ +static void wm8994_update_aif_clk_rate(struct snd_soc_component *component) +{ + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); + + if (max(wm8994->aifclk[0], wm8994->aifclk[1]) < 50000) { + /* Don't overwrite the saved dividers with the 128fs ones */ + if (!wm8994->aifdiv[0]) { + dev_dbg(component->dev, "Configuring AIFs for 128fs\n"); + + wm8994->aifdiv[0] = snd_soc_component_read(component, + WM8994_AIF1_RATE) + & WM8994_AIF1CLK_RATE_MASK; + wm8994->aifdiv[1] = snd_soc_component_read(component, + WM8994_AIF2_RATE) + & WM8994_AIF1CLK_RATE_MASK; + } + + snd_soc_component_update_bits(component, WM8994_AIF1_RATE, + WM8994_AIF1CLK_RATE_MASK, 0x1); + snd_soc_component_update_bits(component, WM8994_AIF2_RATE, + WM8994_AIF2CLK_RATE_MASK, 0x1); + } else if (wm8994->aifdiv[0]) { + snd_soc_component_update_bits(component, WM8994_AIF1_RATE, + WM8994_AIF1CLK_RATE_MASK, + wm8994->aifdiv[0]); + snd_soc_component_update_bits(component, WM8994_AIF2_RATE, + WM8994_AIF2CLK_RATE_MASK, + wm8994->aifdiv[1]); + + wm8994->aifdiv[0] = 0; + wm8994->aifdiv[1] = 0; + } +} + static int _wm8994_set_fll(struct snd_soc_component *component, int id, int src, unsigned int freq_in, unsigned int freq_out) { @@ -2444,33 +2482,7 @@ static int _wm8994_set_fll(struct snd_soc_component *component, int id, int src, configure_clock(component); - /* - * If SYSCLK will be less than 50kHz adjust AIFnCLK dividers - * for detection. - */ - if (max(wm8994->aifclk[0], wm8994->aifclk[1]) < 50000) { - dev_dbg(component->dev, "Configuring AIFs for 128fs\n"); - - wm8994->aifdiv[0] = snd_soc_component_read(component, WM8994_AIF1_RATE) - & WM8994_AIF1CLK_RATE_MASK; - wm8994->aifdiv[1] = snd_soc_component_read(component, WM8994_AIF2_RATE) - & WM8994_AIF1CLK_RATE_MASK; - - snd_soc_component_update_bits(component, WM8994_AIF1_RATE, - WM8994_AIF1CLK_RATE_MASK, 0x1); - snd_soc_component_update_bits(component, WM8994_AIF2_RATE, - WM8994_AIF2CLK_RATE_MASK, 0x1); - } else if (wm8994->aifdiv[0]) { - snd_soc_component_update_bits(component, WM8994_AIF1_RATE, - WM8994_AIF1CLK_RATE_MASK, - wm8994->aifdiv[0]); - snd_soc_component_update_bits(component, WM8994_AIF2_RATE, - WM8994_AIF2CLK_RATE_MASK, - wm8994->aifdiv[1]); - - wm8994->aifdiv[0] = 0; - wm8994->aifdiv[1] = 0; - } + wm8994_update_aif_clk_rate(component); return 0; } @@ -2588,33 +2600,7 @@ static int wm8994_set_dai_sysclk(struct snd_soc_dai *dai, configure_clock(component); - /* - * If SYSCLK will be less than 50kHz adjust AIFnCLK dividers - * for detection. - */ - if (max(wm8994->aifclk[0], wm8994->aifclk[1]) < 50000) { - dev_dbg(component->dev, "Configuring AIFs for 128fs\n"); - - wm8994->aifdiv[0] = snd_soc_component_read(component, WM8994_AIF1_RATE) - & WM8994_AIF1CLK_RATE_MASK; - wm8994->aifdiv[1] = snd_soc_component_read(component, WM8994_AIF2_RATE) - & WM8994_AIF1CLK_RATE_MASK; - - snd_soc_component_update_bits(component, WM8994_AIF1_RATE, - WM8994_AIF1CLK_RATE_MASK, 0x1); - snd_soc_component_update_bits(component, WM8994_AIF2_RATE, - WM8994_AIF2CLK_RATE_MASK, 0x1); - } else if (wm8994->aifdiv[0]) { - snd_soc_component_update_bits(component, WM8994_AIF1_RATE, - WM8994_AIF1CLK_RATE_MASK, - wm8994->aifdiv[0]); - snd_soc_component_update_bits(component, WM8994_AIF2_RATE, - WM8994_AIF2CLK_RATE_MASK, - wm8994->aifdiv[1]); - - wm8994->aifdiv[0] = 0; - wm8994->aifdiv[1] = 0; - } + wm8994_update_aif_clk_rate(component); return 0; } -- 2.53.0