Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp5844691ybn; Sun, 29 Sep 2019 06:58:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqynGCsYNPrUESi+GO5OrHgf5HYL4SzNIhALpGm/ToxjiYr5w4xhaNEi3z8gp7VRwT4v1m+w X-Received: by 2002:a17:906:230c:: with SMTP id l12mr6229943eja.78.1569765537705; Sun, 29 Sep 2019 06:58:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569765537; cv=none; d=google.com; s=arc-20160816; b=kBHipBgW4r7oXgdZYSdVPGl2w2X6p7erf4pVpR4sh2g6ne+BLBA57dyzDSgE7C/7se v17lgMEhyyQC8gxCkUhFjNFpI4+Xkh2rUZ6OFwyvNku9K3E6jXme5EfQrtCOaeiotWGC m1x2DbjIK270uxSUsWFHdh2jyJxEoSvOnGSpkcjPPOb93cusmS1PrB0hQczwYlzG2oXe eJvRtCYE1DEZRWLQuyVNq51ZmbaiW5o4waz+tsiMGfOVLbW97SOn9mzgzFLp22jjeoK5 9pvnj+xeJb7kY7e2UBdKSg/szE+tLGH9pYUQAXFGu0xiV0wPz3KbuYBfEwPMGjjzVGrL xDig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XFwXw2QcqSEUsFCls9KJ50N+nw0Pjs0crLY9ScEW3OE=; b=tkYZBc9zTn7exp7PWp2Qbv6XZA4ARXKxPXTu/ytW2T6XQCf8FmXmKMBtnI11tPysjz CMs9waMWzLRsw5ZPukzn3TNhtKMLmAth86GzEwyL1RFYKIpsgTF1I6r6lG/7bDsA4UJW cAhpgYpBpjUxA9hdwYhhAoxOZBgN/KPxoIo5Rtdu5yjbAy2MhrBp3Ef63VjhI/Mo+zg4 znPdbI5dy6zuiUcUa/gbmNmBVYYaRdbt3NVWVN0IIiBPHqcAN3YcjPtEjaTtAMh5l3qJ Q3E6XR6/G1L3cuhpVh2RfYDk/3fn+7PmqXtEIGr8g6mFvR5Efqg3ttiHAQHLvNA7vQQZ VKyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EZw6+PwJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f33si5369589edb.281.2019.09.29.06.58.33; Sun, 29 Sep 2019 06:58:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EZw6+PwJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729286AbfI2N5k (ORCPT + 99 others); Sun, 29 Sep 2019 09:57:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:37910 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729240AbfI2N5h (ORCPT ); Sun, 29 Sep 2019 09:57:37 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7D21121920; Sun, 29 Sep 2019 13:57:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569765455; bh=NWxVUz+p90O6wni9NhbjPikNGrVOFR+nVmLUqFhIDn8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EZw6+PwJERkyxNSBe2cqexN9gtd108F4BQQBHCKjH4PO/aLxJLc/857DyqDqP8JhV uHCG9bR5sIj9GPytyPK80B4JgUpeyr/xeEG5rZ7FuE4WDW0X+4AsQ7zYQtINM1WPSg o8owceU4RVaINA9AAKcF/9Giz9WWY02uPhwvTjXA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mogens Jensen , Dean Wallace , Hans de Goede , Pierre-Louis Bossart , Mark Brown Subject: [PATCH 4.19 25/63] ASoC: Intel: cht_bsw_max98090_ti: Enable codec clock once and keep it enabled Date: Sun, 29 Sep 2019 15:53:58 +0200 Message-Id: <20190929135036.909328956@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190929135031.382429403@linuxfoundation.org> References: <20190929135031.382429403@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hans de Goede commit 4bcdec39c454c4e8f9512115bdcc3efec1ba5f55 upstream. Users have been seeing sound stability issues with max98090 codecs since: commit 648e921888ad ("clk: x86: Stop marking clocks as CLK_IS_CRITICAL") At first that commit broke sound for Chromebook Swanky and Clapper models, the problem was that the machine-driver has been controlling the wrong clock on those models since support for them was added. This was hidden by clk-pmc-atom.c keeping the actual clk on unconditionally. With the machine-driver controlling the proper clock, sound works again but we are seeing bug reports describing it as: low volume, "sounds like played at 10x speed" and instable. When these issues are hit the following message is seen in dmesg: "max98090 i2c-193C9890:00: PLL unlocked". Attempts have been made to fix this by inserting a delay between enabling the clk and enabling and checking the pll, but this has not helped. It seems that at least on boards which use pmc_plt_clk_0 as clock, if we ever disable the clk, the pll looses its lock and after that we get various issues. This commit fixes this by enabling the clock once at probe time on these boards. In essence this restores the old behavior of clk-pmc-atom.c always keeping the clk on on these boards. Fixes: 648e921888ad ("clk: x86: Stop marking clocks as CLK_IS_CRITICAL") Reported-by: Mogens Jensen Reported-by: Dean Wallace Signed-off-by: Hans de Goede Acked-by: Pierre-Louis Bossart Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- sound/soc/intel/boards/cht_bsw_max98090_ti.c | 47 +++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 6 deletions(-) --- a/sound/soc/intel/boards/cht_bsw_max98090_ti.c +++ b/sound/soc/intel/boards/cht_bsw_max98090_ti.c @@ -42,6 +42,7 @@ struct cht_mc_private { struct clk *mclk; struct snd_soc_jack jack; bool ts3a227e_present; + int quirks; }; static int platform_clock_control(struct snd_soc_dapm_widget *w, @@ -53,6 +54,10 @@ static int platform_clock_control(struct struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card); int ret; + /* See the comment in snd_cht_mc_probe() */ + if (ctx->quirks & QUIRK_PMC_PLT_CLK_0) + return 0; + codec_dai = snd_soc_card_get_codec_dai(card, CHT_CODEC_DAI); if (!codec_dai) { dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n"); @@ -222,6 +227,10 @@ static int cht_codec_init(struct snd_soc "jack detection gpios not added, error %d\n", ret); } + /* See the comment in snd_cht_mc_probe() */ + if (ctx->quirks & QUIRK_PMC_PLT_CLK_0) + return 0; + /* * The firmware might enable the clock at * boot (this information may or may not @@ -420,16 +429,15 @@ static int snd_cht_mc_probe(struct platf int ret_val = 0; struct cht_mc_private *drv; const char *mclk_name; - int quirks = 0; - - dmi_id = dmi_first_match(cht_max98090_quirk_table); - if (dmi_id) - quirks = (unsigned long)dmi_id->driver_data; drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); if (!drv) return -ENOMEM; + dmi_id = dmi_first_match(cht_max98090_quirk_table); + if (dmi_id) + drv->quirks = (unsigned long)dmi_id->driver_data; + drv->ts3a227e_present = acpi_dev_found("104C227E"); if (!drv->ts3a227e_present) { /* no need probe TI jack detection chip */ @@ -446,7 +454,7 @@ static int snd_cht_mc_probe(struct platf snd_soc_card_cht.dev = &pdev->dev; snd_soc_card_set_drvdata(&snd_soc_card_cht, drv); - if (quirks & QUIRK_PMC_PLT_CLK_0) + if (drv->quirks & QUIRK_PMC_PLT_CLK_0) mclk_name = "pmc_plt_clk_0"; else mclk_name = "pmc_plt_clk_3"; @@ -459,6 +467,21 @@ static int snd_cht_mc_probe(struct platf return PTR_ERR(drv->mclk); } + /* + * Boards which have the MAX98090's clk connected to clk_0 do not seem + * to like it if we muck with the clock. If we disable the clock when + * it is unused we get "max98090 i2c-193C9890:00: PLL unlocked" errors + * and the PLL never seems to lock again. + * So for these boards we enable it here once and leave it at that. + */ + if (drv->quirks & QUIRK_PMC_PLT_CLK_0) { + ret_val = clk_prepare_enable(drv->mclk); + if (ret_val < 0) { + dev_err(&pdev->dev, "MCLK enable error: %d\n", ret_val); + return ret_val; + } + } + ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_cht); if (ret_val) { dev_err(&pdev->dev, @@ -469,11 +492,23 @@ static int snd_cht_mc_probe(struct platf return ret_val; } +static int snd_cht_mc_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev); + struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card); + + if (ctx->quirks & QUIRK_PMC_PLT_CLK_0) + clk_disable_unprepare(ctx->mclk); + + return 0; +} + static struct platform_driver snd_cht_mc_driver = { .driver = { .name = "cht-bsw-max98090", }, .probe = snd_cht_mc_probe, + .remove = snd_cht_mc_remove, }; module_platform_driver(snd_cht_mc_driver)