Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1594195pxb; Mon, 12 Apr 2021 01:46:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUoGA59E827RGC9fFVIaIfiX6LCMLCw0Ib1HSahWYSG7hGErn1iFQRLVQ9g+gkcxJX4KBV X-Received: by 2002:a17:90a:e7cc:: with SMTP id kb12mr27358333pjb.31.1618217161433; Mon, 12 Apr 2021 01:46:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618217161; cv=none; d=google.com; s=arc-20160816; b=hCnARno1EkF/l9y/mOeXFCXOZ8oV0+8NhXfsFr2D5v5aNqqlT6bWle1XQF58DnuZ4Y G7n8hccrYALfnomjH9kHxunwuSK7BAFPfLba1q2gqwJzLSnR6RYeB+7LP1pyVxzJEn+t SVeFl1kI4mv3iUI2qvsHIXzqc0LzA5zCjdRX7UCbmfwYeAEZlMyHI6nZDsflfVi0eAuO 1+tjIgB1s4WBvXNWoBjJK+r8/GVthckCwUemASt0xr8UBVxHpoAkXJ9YZBtRty8O56Ut D84Y6bsHUqzhzZjhiflfWCAEvW7JkNdEg8vT3EGb2zwdrq9+B8C5cewiWlOygjdp042V kENA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Se04UyNLWNyjT/zA/POwGYFxREk24XpkEsl/3tCd5l0=; b=u1s5BorImZLtPrad+sO2uEcmVw5ZH0W4a12fDFpp6G/mwAwK2xq/LczGAL7gR82r3f tGlUzyPUKHzMdqR4mZ9si0j3QQp3FkATQaYvMUOrpfvQqDz32kpcKdxTgAqk2GQI+wZi 9L4Vcpq8nuaCDGLC1vDkILBHAJFzwcLOPz4Kavf2JuG19KWOBR/CTfteNHlsIxCFhfOs 360KxVdlBJqVfihJG5YYg04PjU3mgNV5ijkn31IVuv3iNq62Wqc4qvePM2idPu3LyYQB h2nKIP1mc+L+PRj8oLBkop7w3h/K//RJtADXmURlophHoRWBBYGtlokwLF/lOUBa0v2u +zww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2gsvMiuN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t2si13140230pgg.529.2021.04.12.01.45.49; Mon, 12 Apr 2021 01:46:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2gsvMiuN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237734AbhDLIpE (ORCPT + 99 others); Mon, 12 Apr 2021 04:45:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:36412 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237665AbhDLIoW (ORCPT ); Mon, 12 Apr 2021 04:44:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5EE396109E; Mon, 12 Apr 2021 08:44:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618217045; bh=K7l++CqPG8padr7r6Czqcp9HTLlK7tgJKEVOsOkTFWA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2gsvMiuNqOq68bxGmOFF+mc/M3v+4ef0+YS/lBs/hfsdiLsm/yh0MvbXaDJriztqB zxxh4fm+V3SfJ0BW7im0t4MzCGDVxCWOK6gqROhzr+2FhIBjw1gpsOm69I5nEk5EQK vxGRCxZAjAgEjS4vSDRwkmdTyo4xZAbCryaI3LQo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shengjiu Wang , Charles Keepax , Mark Brown , Sasha Levin Subject: [PATCH 4.19 32/66] ASoC: wm8960: Fix wrong bclk and lrclk with pll enabled for some chips Date: Mon, 12 Apr 2021 10:40:38 +0200 Message-Id: <20210412083959.164654649@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412083958.129944265@linuxfoundation.org> References: <20210412083958.129944265@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Shengjiu Wang [ Upstream commit 16b82e75c15a7dbd564ea3654f3feb61df9e1e6f ] The input MCLK is 12.288MHz, the desired output sysclk is 11.2896MHz and sample rate is 44100Hz, with the configuration pllprescale=2, postscale=sysclkdiv=1, some chip may have wrong bclk and lrclk output with pll enabled in master mode, but with the configuration pllprescale=1, postscale=2, the output clock is correct. >From Datasheet, the PLL performs best when f2 is between 90MHz and 100MHz when the desired sysclk output is 11.2896MHz or 12.288MHz, so sysclkdiv = 2 (f2/8) is the best choice. So search available sysclk_divs from 2 to 1 other than from 1 to 2. Fixes: 84fdc00d519f ("ASoC: codec: wm9860: Refactor PLL out freq search") Signed-off-by: Shengjiu Wang Acked-by: Charles Keepax Link: https://lore.kernel.org/r/1616150926-22892-1-git-send-email-shengjiu.wang@nxp.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/codecs/wm8960.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c index c4c00297ada6..88e869d16714 100644 --- a/sound/soc/codecs/wm8960.c +++ b/sound/soc/codecs/wm8960.c @@ -710,7 +710,13 @@ int wm8960_configure_pll(struct snd_soc_component *component, int freq_in, best_freq_out = -EINVAL; *sysclk_idx = *dac_idx = *bclk_idx = -1; - for (i = 0; i < ARRAY_SIZE(sysclk_divs); ++i) { + /* + * From Datasheet, the PLL performs best when f2 is between + * 90MHz and 100MHz, the desired sysclk output is 11.2896MHz + * or 12.288MHz, then sysclkdiv = 2 is the best choice. + * So search sysclk_divs from 2 to 1 other than from 1 to 2. + */ + for (i = ARRAY_SIZE(sysclk_divs) - 1; i >= 0; --i) { if (sysclk_divs[i] == -1) continue; for (j = 0; j < ARRAY_SIZE(dac_divs); ++j) { -- 2.30.2