From patchwork Tue Sep 19 13:45:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 112984 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp4936932qgf; Tue, 19 Sep 2017 06:46:28 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBywirhuVXFipbX/i/fyOImETg1EeJlaLfx/8dlOFHktOjvMqtdDSbfCa1tBAz96Qd3I9UG X-Received: by 10.223.196.228 with SMTP id o33mr1497011wrf.253.1505828788510; Tue, 19 Sep 2017 06:46:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505828788; cv=none; d=google.com; s=arc-20160816; b=OIOVd+vvAxgs6A7KI2FDl5a+vB/YnSI/W8/2a8Q7kaJ6y4SWtKRYRb/i3RtX/boKya mOeUyBQ+QCoOzAlbYDtbkN3mPYcP4Gb8FD8vFtI3+lcI6hLJzfxF+TuEXLT1tbZYUwpJ iw++Ml27SFeXgRsJxb1vVkXlQfWHTY1bZLTAgx7ZZghNCGtJ7df2V94rpsZpbwrwd2R3 ynsOUg9YjnNIzxCPQ6SOGPnZVhWtlqUBhSqtzIcKt36OcFpUc0JVW7Q+ujNCVM2r0mHt TxcqWD8luF4WNIVYgLDzdbQQmLIFle6E6h+jdP/hH9pBspYkdr0Rv1GPu/tCorpu7S1x lbiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:date:message-id:in-reply-to:to:from :dkim-signature:delivered-to:arc-authentication-results; bh=UbAtqOnd/JJCl7Ntkw/YlZg9mBgfek43aCtAzmaX9FY=; b=Qtmojsl6ECnKJD5HnSYcYL6jCYtF42s3QrfkNWLgvIz4RFZpBeCxGw/bAKONiLDKpj tKfWbmgcT/9qi556ABoZ/S6GusXbFpiKBCLIo48x33mNgr0fren0AVS6xn4yTwJOnlVx rhPsPhLVr1Wj5A2vjZdZ2bqhdLHWqY/fbxONYiBprULhKeFKxVmF8v4ZMLg7Z05PLyTx BGprJQ6N97HeQiZh1CsXw7J4Dmu3s6eV+BGTMqAUtt37PHFpfXV4Ke8vceqZqrnpYb/M S2jHCZugKP0Ax5Wry+R8jM9E+7h/A0QmHs/fMVW03tyvzUW7nUEE96K32+YC6wtH3nD7 GpCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=LA1j+M1W; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id p43si7923994wrc.165.2017.09.19.06.46.28; Tue, 19 Sep 2017 06:46:28 -0700 (PDT) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=LA1j+M1W; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 80F74267387; Tue, 19 Sep 2017 15:45:46 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id D60D2266D18; Tue, 19 Sep 2017 15:45:45 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, SPF_NEUTRAL autolearn=disabled version=3.4.0 Received: from heliosphere.sirena.org.uk (heliosphere.sirena.org.uk [172.104.155.198]) by alsa0.perex.cz (Postfix) with ESMTP id F1D3B266D18 for ; Tue, 19 Sep 2017 15:45:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=6bcsDUqu4ycInQIv/M9wgdLuvFcwe6Fbhfn5EGq5jsM=; b=LA1j+M1WYwUb OUwD56TbGhIKomqc19D5qRPK1SKBANx9GaSTcDzj4uWRGHqC97MUj8GoyuJ80WLSHq/FBahf1bNcX z4xbSA4kNPROptzZeglwdC1TMW1gx3cOaTa3NGrIJSigKffEFbsv01v8+dkmNkiTiMn5jdSEBJY0X 9XTW0=; Received: from debutante.sirena.org.uk ([2001:470:1f1d:6b5::3] helo=debutante) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1duIqK-0001Mn-0F; Tue, 19 Sep 2017 13:45:40 +0000 Received: from broonie by debutante with local (Exim 4.89) (envelope-from ) id 1duIqJ-00084A-BY; Tue, 19 Sep 2017 14:45:39 +0100 From: Mark Brown To: Pierre-Louis Bossart In-Reply-To: <20170908051309.19028-4-pierre-louis.bossart@linux.intel.com> Message-Id: Date: Tue, 19 Sep 2017 14:45:39 +0100 Cc: alsa-devel@alsa-project.org, tiwai@suse.de, liam.r.girdwood@linux.intel.com, vinod.koul@intel.com, broonie@kernel.org, jarkko.nikula@linux.intel.com, andriy.shevchenko@linux.intel.com Subject: [alsa-devel] Applied "ASoC: Intel: cht_bsw_max98090: add support for Baytrail" to the asoc tree X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org The patch ASoC: Intel: cht_bsw_max98090: add support for Baytrail has been applied to the asoc tree at git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark >From 299bad365b900223cded22a6f66dbb3763da4235 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Fri, 8 Sep 2017 00:13:05 -0500 Subject: [PATCH] ASoC: Intel: cht_bsw_max98090: add support for Baytrail Distributions such as Fedora, Ubuntu and Gallium don't currently have a means to support Baytrail Chromebooks and other platforms with the same build [1][2] due to incompatible platform drivers. Add MCLK management to reuse this machine driver for Baytrail platforms and solve this coexistence problem at last. UCM files are provided at [3] and will eventually be submitted to the new repo. The legacy byt-max98090 machine driver is still maintained but can only be used when the other Atom/DPCM driver is not compiled in, or when users don't want to configure extra mixers required by the Atom/sst driver. Tested on Lenovo 100s Baytrail Chromebook w/ Mr. Chromebox BOOT_STUB firmware and Acer R11 Cherrytrail Chromebook [1] https://bugzilla.redhat.com/show_bug.cgi?id=1335196 [2] http://mailman.alsa-project.org/pipermail/alsa-devel/2016-August/ 111641.html [3] https://github.com/plbossart/UCM/tree/master/byt-max98090 Signed-off-by: Pierre-Louis Bossart Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/boards/cht_bsw_max98090_ti.c | 78 ++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) -- 2.14.1 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/sound/soc/intel/boards/cht_bsw_max98090_ti.c b/sound/soc/intel/boards/cht_bsw_max98090_ti.c index 20755ecc7f9e..442a81bf17b4 100644 --- a/sound/soc/intel/boards/cht_bsw_max98090_ti.c +++ b/sound/soc/intel/boards/cht_bsw_max98090_ti.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -35,15 +36,60 @@ #define CHT_CODEC_DAI "HiFi" struct cht_mc_private { + struct clk *mclk; struct snd_soc_jack jack; bool ts3a227e_present; }; +static inline struct snd_soc_dai *cht_get_codec_dai(struct snd_soc_card *card) +{ + struct snd_soc_pcm_runtime *rtd; + + list_for_each_entry(rtd, &card->rtd_list, list) { + if (!strncmp(rtd->codec_dai->name, CHT_CODEC_DAI, + strlen(CHT_CODEC_DAI))) + return rtd->codec_dai; + } + return NULL; +} + +static int platform_clock_control(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *k, int event) +{ + struct snd_soc_dapm_context *dapm = w->dapm; + struct snd_soc_card *card = dapm->card; + struct snd_soc_dai *codec_dai; + struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card); + int ret; + + codec_dai = cht_get_codec_dai(card); + if (!codec_dai) { + dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n"); + return -EIO; + } + + if (SND_SOC_DAPM_EVENT_ON(event)) { + ret = clk_prepare_enable(ctx->mclk); + if (ret < 0) { + dev_err(card->dev, + "could not configure MCLK state"); + return ret; + } + } else { + clk_disable_unprepare(ctx->mclk); + } + + return 0; +} + static const struct snd_soc_dapm_widget cht_dapm_widgets[] = { SND_SOC_DAPM_HP("Headphone", NULL), SND_SOC_DAPM_MIC("Headset Mic", NULL), SND_SOC_DAPM_MIC("Int Mic", NULL), SND_SOC_DAPM_SPK("Ext Spk", NULL), + SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0, + platform_clock_control, SND_SOC_DAPM_PRE_PMU | + SND_SOC_DAPM_POST_PMD), }; static const struct snd_soc_dapm_route cht_audio_map[] = { @@ -60,6 +106,10 @@ static const struct snd_soc_dapm_route cht_audio_map[] = { {"codec_in0", NULL, "ssp2 Rx" }, {"codec_in1", NULL, "ssp2 Rx" }, {"ssp2 Rx", NULL, "HiFi Capture"}, + {"Headphone", NULL, "Platform Clock"}, + {"Headset Mic", NULL, "Platform Clock"}, + {"Int Mic", NULL, "Platform Clock"}, + {"Ext Spk", NULL, "Platform Clock"}, }; static const struct snd_kcontrol_new cht_mc_controls[] = { @@ -141,6 +191,25 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) if (ctx->ts3a227e_present) snd_soc_jack_notifier_register(jack, &cht_jack_nb); + /* + * The firmware might enable the clock at + * boot (this information may or may not + * be reflected in the enable clock register). + * To change the rate we must disable the clock + * first to cover these cases. Due to common + * clock framework restrictions that do not allow + * to disable a clock that has not been enabled, + * we need to enable the clock first. + */ + ret = clk_prepare_enable(ctx->mclk); + if (!ret) + clk_disable_unprepare(ctx->mclk); + + ret = clk_set_rate(ctx->mclk, CHT_PLAT_CLK_3_HZ); + + if (ret) + dev_err(runtime->dev, "unable to set MCLK rate\n"); + return ret; } @@ -294,6 +363,15 @@ static int snd_cht_mc_probe(struct platform_device *pdev) /* register the soc card */ snd_soc_card_cht.dev = &pdev->dev; snd_soc_card_set_drvdata(&snd_soc_card_cht, drv); + + drv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3"); + if (IS_ERR(drv->mclk)) { + dev_err(&pdev->dev, + "Failed to get MCLK from pmc_plt_clk_3: %ld\n", + PTR_ERR(drv->mclk)); + return PTR_ERR(drv->mclk); + } + ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_cht); if (ret_val) { dev_err(&pdev->dev,