From patchwork Tue Jul 10 18:16:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 141643 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4202906ljj; Tue, 10 Jul 2018 11:17:33 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcVbTOherXK7tL0kYEMaIRUiZUflKu9XrcCUEzyO7QG22uGER3Hg89TLYj5uFwyEd/lZNMP X-Received: by 2002:a1c:d543:: with SMTP id m64-v6mr14513605wmg.12.1531246653299; Tue, 10 Jul 2018 11:17:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531246653; cv=none; d=google.com; s=arc-20160816; b=Sk3eLBtGxOP2P+g4gBaUTcFGC5dYCDIZj/Tq38XmExnWdhThf+L4YPAa9BRWlZkNuc PvovSna45KBqAQ3bv11//qMgVTHTkw7EeRQqLAHw+XoVsUuG9GfUjqHP9eKk5v6oGm/G 7MOBeqz0UOIsM4LFGCdHoOHKQ/1KZIJ3jf7MJDDYl+77VHDysEOG6gSMXyxLv7oo+trf qx1hpEuc3u58LzXcO+t55R6K9DeCIinSIX+bgzl9Bw48Ja8xawa+6W5LTJ3oz1X95v67 9TqSdFpHTJar78Qk8BsxFrWCQ6Zr43tN8kTZj8GU0P2MwmCXkwWHiSFLYBuPZCKtaVfy 2ZXQ== 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=F18kUZEs4Y6iJeyZ5PZKS8Pelm6SWgKI86VSl9cLang=; b=k+VytLlagR5Zz7mbSX/9KpvCygQCa3K9twuIQP1uW5oJnMj0WiOD0+wXS1zj/sCmBg KrwoqxHgqAaCdXwEWLntlAq6ZvhaOp1zLUKt8CBkPn3/cjEo0mClArx8b+f9oOBeID1B e6uX7tHdRazZJ2B3GfeTwWassNTi6M41zNH8Nw9e/K8as5ehH2AFp9tHXukjXlnJnm1b f+ChiD83hZ48antq1m5VdMxEjNfubMuKAM4hNdFBKnz2FCrlE8bTH5DaLedzkJSeh0dF Xv6lz7beCua+GPPqR/TgtPKaqtMEEwtaJzLirVnuoOh3hs+5l58dWjPD4AJE9Ftz2FIY xrlA== 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=FHmJT6WQ; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id k7-v6si16025963wro.76.2018.07.10.11.17.33; Tue, 10 Jul 2018 11:17:33 -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=FHmJT6WQ; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 8F8DF26773C; Tue, 10 Jul 2018 20:16:56 +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 0356226771B; Tue, 10 Jul 2018 20:16:49 +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.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_PASS 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 C8B74267713 for ; Tue, 10 Jul 2018 20:16:46 +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=8Iztht1dhEmnAPz0wBY776fH5z7m5dNCf8AvYffC0Mo=; b=FHmJT6WQ5L7c mmgsF1BV9YBdcjp4LeUBwyDFg04HFyf27YXSwEQDSjtzfyD438W3vvBbRHdg0nnbu7Lvjx+IK+R7u +eJ066qIx2q9EjPjTR57lBXfcZZGPf6GKh57smjAT+wSwegmHChfc7nYoxAVuD9QB5aSNj6xB60Kp mNYtw=; 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 1fcxBp-00029S-FE; Tue, 10 Jul 2018 18:16:41 +0000 Received: from broonie by debutante with local (Exim 4.91) (envelope-from ) id 1fcxBo-0001kX-WE; Tue, 10 Jul 2018 19:16:41 +0100 From: Mark Brown To: Hans de Goede In-Reply-To: <20180701183107.4896-1-hdegoede@redhat.com> Message-Id: Date: Tue, 10 Jul 2018 19:16:40 +0100 Cc: Oder Chiou , alsa-devel@alsa-project.org, Pierre-Louis Bossart , Liam Girdwood , Mark Brown , Carlo Caione , Bard Liao Subject: [alsa-devel] Applied "ASoC: Intel: bytcr_rt5651: Add support for externar amplifier enable GPIO" 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: bytcr_rt5651: Add support for externar amplifier enable GPIO has been applied to the asoc tree at https://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 5f6fb23d2e114506ddb8437a3e65f4a20d081013 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 1 Jul 2018 20:36:31 +0200 Subject: [PATCH] ASoC: Intel: bytcr_rt5651: Add support for externar amplifier enable GPIO The rt5651 does not have a built-in speaker amplifier, so it is often used together with an external amplifier. On Cherry Trail boards this external amplifier's enable pin is driven through a GPIO, which is given as the first GPIO in the ACPI resources of the codec fwnode. This commit adds support to the bytcr_rt5651 for this GPIO, fixing the speaker not working on CHT devices with a rt5651 codec. Cc: Carlo Caione Signed-off-by: Hans de Goede Acked-by: Pierre-Louis Bossart Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 65 +++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 3 deletions(-) -- 2.18.0.rc2 _______________________________________________ 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/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index d920725ce603..5301205496be 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include #include #include @@ -86,6 +88,7 @@ enum { struct byt_rt5651_private { struct clk *mclk; + struct gpio_desc *ext_amp_gpio; struct snd_soc_jack jack; }; @@ -208,6 +211,20 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w, return 0; } +static int rt5651_ext_amp_power_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_card *card = w->dapm->card; + struct byt_rt5651_private *priv = snd_soc_card_get_drvdata(card); + + if (SND_SOC_DAPM_EVENT_ON(event)) + gpiod_set_value_cansleep(priv->ext_amp_gpio, 1); + else + gpiod_set_value_cansleep(priv->ext_amp_gpio, 0); + + return 0; +} + static const struct snd_soc_dapm_widget byt_rt5651_widgets[] = { SND_SOC_DAPM_HP("Headphone", NULL), SND_SOC_DAPM_MIC("Headset Mic", NULL), @@ -217,7 +234,9 @@ static const struct snd_soc_dapm_widget byt_rt5651_widgets[] = { SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0, platform_clock_control, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), - + SND_SOC_DAPM_SUPPLY("Ext Amp Power", SND_SOC_NOPM, 0, 0, + rt5651_ext_amp_power_event, + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), }; static const struct snd_soc_dapm_route byt_rt5651_audio_map[] = { @@ -225,6 +244,7 @@ static const struct snd_soc_dapm_route byt_rt5651_audio_map[] = { {"Headset Mic", NULL, "Platform Clock"}, {"Internal Mic", NULL, "Platform Clock"}, {"Speaker", NULL, "Platform Clock"}, + {"Speaker", NULL, "Ext Amp Power"}, {"Line In", NULL, "Platform Clock"}, {"Headset Mic", NULL, "micbias1"}, /* lowercase for rt5651 */ @@ -678,6 +698,18 @@ static const struct x86_cpu_id baytrail_cpu_ids[] = { {} }; +static const struct x86_cpu_id cherrytrail_cpu_ids[] = { + { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_AIRMONT }, /* Braswell */ + {} +}; + +static const struct acpi_gpio_params ext_amp_enable_gpios = { 0, 0, false }; + +static const struct acpi_gpio_mapping byt_rt5651_gpios[] = { + { "ext-amp-enable-gpios", &ext_amp_enable_gpios, 1 }, + { }, +}; + struct acpi_chan_package { /* ACPICA seems to require 64 bit integers */ u64 aif_value; /* 1: AIF1, 2: AIF2 */ u64 mclock_value; /* usually 25MHz (0x17d7940), ignored */ @@ -793,9 +825,36 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) /* Must be called before register_card, also see declaration comment. */ ret_val = byt_rt5651_add_codec_device_props(codec_dev); - put_device(codec_dev); - if (ret_val) + if (ret_val) { + put_device(codec_dev); return ret_val; + } + + /* Cherry Trail devices use an external amplifier enable gpio */ + if (x86_match_cpu(cherrytrail_cpu_ids)) { + devm_acpi_dev_add_driver_gpios(codec_dev, byt_rt5651_gpios); + priv->ext_amp_gpio = devm_fwnode_get_index_gpiod_from_child( + &pdev->dev, "ext-amp-enable", 0, + codec_dev->fwnode, + GPIOD_OUT_LOW, "speaker-amp"); + if (IS_ERR(priv->ext_amp_gpio)) { + ret_val = PTR_ERR(priv->ext_amp_gpio); + switch (ret_val) { + case -ENOENT: + priv->ext_amp_gpio = NULL; + break; + default: + dev_err(&pdev->dev, "Failed to get ext-amp-enable GPIO: %d\n", + ret_val); + /* fall through */ + case -EPROBE_DEFER: + put_device(codec_dev); + return ret_val; + } + } + } + + put_device(codec_dev); log_quirks(&pdev->dev);