From patchwork Thu Jul 19 16:57:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 142361 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1961308ljj; Thu, 19 Jul 2018 09:57:40 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcsygi+UEVqdLKdL9WtezqXd/C+8b0hLuoMfOGl9bacz0XsDLr0LC3KDFkSVDbtpEN+jfEI X-Received: by 2002:a5d:6a03:: with SMTP id m3-v6mr2179583wru.192.1532019460342; Thu, 19 Jul 2018 09:57:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532019460; cv=none; d=google.com; s=arc-20160816; b=qBvkOfAqjbeW1nHK/yIa4jA9ZmaoLPvRb6IVUOq0VraNGNBbfOh2LcY8gw4CR7kYcN NMIziKzrf8LgibcWodpeaW/iEqbU+PlKu0TugbJa28xR5pcXwTOOqIYP5Ktqt+tDMf6P ntGRi99v7Gk+yW5gqn2kdHGy7Bwsa1v6h+MlUPAKStUSEKmQj+SIUfVWyBEg3EDojxAO 9M0GhPSE8EbfEqIlnHycS3zPzFpyUaPNLklesdxskUCwQYNwYyiDJHvmuwwElvtzyfeD pEbi1wX7XH75rLPT9jFWAlIq+qDI3hWlI1EV/4bD10v4D6p3ugXUy8zkoSem2Jl3cuwg eBng== 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=Ybx6EveE0RN5/+NAuakJlA96tZ1nHJZuhdiClnAK5zQ=; b=KoCQE3xXBG0bgDeaqNa7kBDcZ2KTiw8uHI3jhzqDYfQaTRzp/7v6Q3AbZkOp+KjGyt OpiBWSFpjpbRsgg9RKkk+DTbhJMvpOKCFzM9sMGsxKcruzAhsk/TRml0PbC1By2BnI5l Mi1WxNhYzEh0LFncMUwYg+LEnjGgwOLAzlZT79K6bD8PEBtxe/mGQxNIXqi85WaJXKmx o8uccRCxRMnGPH0ggwXDNNalsO8ZsaJPFPI1jNvBfWaEAXGEv/qymo80sZlB+YSI9uwS tw63r7BJwTZur3LpZtHHOuYb83Avk4KwSqjulMcZjjhOGsO5SQ878/VEGHXXk51kSZxk FbBQ== 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=TGaejxRP; 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 p5-v6si5402547wre.361.2018.07.19.09.57.40; Thu, 19 Jul 2018 09:57:40 -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=TGaejxRP; 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 A21B0267711; Thu, 19 Jul 2018 18:57:17 +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 1326926775E; Thu, 19 Jul 2018 18:57:15 +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 14628267749 for ; Thu, 19 Jul 2018 18:57:13 +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=n/oClRXfHfdfZ113e2R6DAFcU2e+yqs0MLaX4XmCjNw=; b=TGaejxRPU5jX 52T4YwnZ8PoeWtGeymHqMZYGXtn4lhEKqrkHKzSRGbN2Z57ZZgkpd7oYQ6plnn0b8alVx9IeYrPJE /uBFrVJTZEeZa/1pPtJ8WFFafPXGKlcJIJDQIHfxOxArGnrZfncfUaKKCHfUUkgmF3HvaW9CZ/fge XcCSw=; 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 1fgCEm-0007J1-C6; Thu, 19 Jul 2018 16:57:08 +0000 Received: from broonie by debutante with local (Exim 4.91) (envelope-from ) id 1fgCEl-0005Rr-UD; Thu, 19 Jul 2018 17:57:07 +0100 From: Mark Brown To: Hans de Goede In-Reply-To: <20180718205542.12364-3-hdegoede@redhat.com> Message-Id: Date: Thu, 19 Jul 2018 17:57:07 +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: Fix using the wrong GPIO for the ext-amp on some boards" 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: Fix using the wrong GPIO for the ext-amp on some boards 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 0a3badd141f78535315cca9ff5062a7ebf414281 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Wed, 18 Jul 2018 22:55:38 +0200 Subject: [PATCH] ASoC: Intel: bytcr_rt5651: Fix using the wrong GPIO for the ext-amp on some boards Some boards have I2cSerialBusV2, GpioIo, GpioInt as ACPI resources, other boards may have I2cSerialBusV2, GpioInt, GpioIo instead. We want the GpioIo one for the ext-amp-enable-gpio. So far we've been assuming that the GpioIo one always comes first, this commit adds code to detect which one comes first and to add the right gpio-mapping. This fixes sound not working on the Vios LTH17 laptop. Signed-off-by: Hans de Goede Acked-by: Pierre-Louis Bossart Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 69 +++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 4 deletions(-) -- 2.18.0 _______________________________________________ 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 b687043c8425..601e47c33ba8 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -747,13 +747,74 @@ static const struct x86_cpu_id cherrytrail_cpu_ids[] = { {} }; -static const struct acpi_gpio_params ext_amp_enable_gpios = { 0, 0, false }; +static const struct acpi_gpio_params first_gpio = { 0, 0, false }; +static const struct acpi_gpio_params second_gpio = { 1, 0, false }; -static const struct acpi_gpio_mapping byt_rt5651_gpios[] = { - { "ext-amp-enable-gpios", &ext_amp_enable_gpios, 1 }, +static const struct acpi_gpio_mapping byt_rt5651_amp_en_first[] = { + { "ext-amp-enable-gpios", &first_gpio, 1 }, { }, }; +static const struct acpi_gpio_mapping byt_rt5651_amp_en_second[] = { + { "ext-amp-enable-gpios", &second_gpio, 1 }, + { }, +}; + +/* + * Some boards have I2cSerialBusV2, GpioIo, GpioInt as ACPI resources, other + * boards may have I2cSerialBusV2, GpioInt, GpioIo instead. We want the + * GpioIo one for the ext-amp-enable-gpio and both count for the index in + * acpi_gpio_params index. So we have 2 different mappings and the code + * below figures out which one to use. + */ +struct byt_rt5651_acpi_resource_data { + int gpio_count; + int gpio_int_idx; +}; + +static int snd_byt_rt5651_acpi_resource(struct acpi_resource *ares, void *arg) +{ + struct byt_rt5651_acpi_resource_data *data = arg; + + if (ares->type != ACPI_RESOURCE_TYPE_GPIO) + return 0; + + if (ares->data.gpio.connection_type == ACPI_RESOURCE_GPIO_TYPE_INT) + data->gpio_int_idx = data->gpio_count; + + data->gpio_count++; + return 0; +} + +static void snd_byt_rt5651_mc_add_amp_en_gpio_mapping(struct device *codec) +{ + struct byt_rt5651_acpi_resource_data data = { 0, -1 }; + LIST_HEAD(resources); + int ret; + + ret = acpi_dev_get_resources(ACPI_COMPANION(codec), &resources, + snd_byt_rt5651_acpi_resource, &data); + if (ret < 0) { + dev_warn(codec, "Failed to get ACPI resources, not adding external amplifier GPIO mapping\n"); + return; + } + + /* All info we need is gathered during the walk */ + acpi_dev_free_resource_list(&resources); + + switch (data.gpio_int_idx) { + case 0: + devm_acpi_dev_add_driver_gpios(codec, byt_rt5651_amp_en_second); + break; + case 1: + devm_acpi_dev_add_driver_gpios(codec, byt_rt5651_amp_en_first); + break; + default: + dev_warn(codec, "Unknown GpioInt index %d, not adding external amplifier GPIO mapping\n", + data.gpio_int_idx); + } +} + 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 */ @@ -876,7 +937,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) /* 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); + snd_byt_rt5651_mc_add_amp_en_gpio_mapping(codec_dev); priv->ext_amp_gpio = devm_fwnode_get_index_gpiod_from_child( &pdev->dev, "ext-amp-enable", 0, codec_dev->fwnode,