From patchwork Tue Apr 19 16:37:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 563353 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp3442958map; Tue, 19 Apr 2022 10:02:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHvG1Rp3xf7UZMOX2xd7nPPh88OQsYMsXZ7zCvj+s6cuHis30NW4HSNBn61T8RXaewdiAz X-Received: by 2002:a05:6870:5487:b0:e6:10f4:ec50 with SMTP id f7-20020a056870548700b000e610f4ec50mr2841728oan.18.1650387729984; Tue, 19 Apr 2022 10:02:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650387729; cv=none; d=google.com; s=arc-20160816; b=XwbdIioDseZpMNBfPAtORwcpuwm8+IKIqjXhWDA32XUi92BW/q9b6BBIYWyUo5EhnO PfzRRT+AkE0ITpUU7mDjwLn0UjsvGlQFWMPBdBOJ9+N5FPHRqRKB8pa+3MnQ9UTFM7o1 X/i0RTOnl16qtSTubosuKHECRqDvFTmRaHUy951gf6OCASR+ceOsthgfy+0U/mBMMAaE MPbdUdipKEnnnqu6RMOCn54JOkAsr2Zo010OywXJx9FAq18WgzpAWPbvPifQz2TX6Bm8 1zKPf45L08UE5FnsHzS9SCemE7V1emIhrVmPsgXVDoin0ZYZvBBLd8hrwH+tQW431ROw bQEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dkim-signature; bh=R2Qeh6gI8F7LBdIOE0a1/cLlAgM/fwO7ig2DbIdT5rI=; b=n2Q2UJ6RU58uvnPT+yoKLaJGzwx0p7mXcp2FQWSJ+cJHJ7mGHiASvqa1jwWiYCyFQo I+lt5mR/gShxQn2rgGmFuTWAXgrcbqaCUnY10Gv2raZ80Jp4MyOQtsVvs/Rvvx+R4Dm1 xeF840oA0hYiPKKN9pfljkEvHNdjCnjVIrhyZuJ+TCjQUfPb1KfECRlY1Kp2vH1i+ONL akSAd5CA+wjZIPhm7p/hR/8hbUD+4RQAkctdhvTeVRFCgeMuCLJTTM1X3uv8EAhKOqyy YkfSo0MKSnOoJN8NBiV9PcfhNfS3aMrXvxGVoezKiq5IbgFMFmgrXigRHu4KEbT7LQYo leaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=dp9k0mAe; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b="KP5D3/+g"; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id nl17-20020a056871459100b000da716e62absi6549600oab.308.2022.04.19.10.02.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 10:02:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=dp9k0mAe; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b="KP5D3/+g"; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=R2Qeh6gI8F7LBdIOE0a1/cLlAgM/fwO7ig2DbIdT5rI=; b=dp9k0mAelgRnIL xAxNQr9AknXGm//CTvX7LJ8ueBLnsdaZL3yvEDWMABenVj/J7WunVnx76AE8e1kT4syrdrN6+eHhu WzFUB888RcuCp5cA++xwnneTZP2Y3X2UMEuWXbPJrK9omjrZvkXY7sf2VOjgGyMDR4QrxlAeVXl+c 6PO11aZj2onH6Yj9/B650/jQUKGy7O3KDQ2GlaKhFP7B04/uhDJ6BCHitVen71jbwi4EzI0/XQrZ3 DB676Zjgr5RhySw661tHHRBnGKJsiw2+ljFoJS4XWg874ngmJW25yFDAjxwgnDn2jj0BYFfMPr1cT 2NF44appUqqMOFhEpALw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ngrEn-00570V-B0; Tue, 19 Apr 2022 17:02:01 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ngquw-004x3z-Aq; Tue, 19 Apr 2022 16:41:32 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DA72061841; Tue, 19 Apr 2022 16:41:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 035C7C385AE; Tue, 19 Apr 2022 16:41:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650386489; bh=CV2DfOuzXf7kUPil8tZ7gZo9izvbbtgmXRdVGoTTjS0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KP5D3/+gEbUNQwq4+2Dg5ZiO0/4UD7UBYxqQ+Yhzyb8rcMpQy8IwFnD3vc7nRThh9 0S/UDwriRgtkpACByKJG0x9h6S5YK9TudrYKnkr6NhsX4J5fKn6ygewSDktxKDpnIv tCIuO2FwqWl//65PEBymVPwNOmkUQYMSZ9p1GIJ8MV0q3d+ZIUxvSSsZsxbivMXbmX rBvFb4Uy8VNcVIp7gUj0ZEUm+nWs62XeJSEZiKgu2W6BY2wI3KzjhVsDVg/3FFR+Sz R7ffATntjCQqbOT5/L1YIUTX+OZ6M/ixyUEcIRbi2l9O7ozPWfqM11qZUjM90rXQq0 vHB3D8vED3y3w== From: Arnd Bergmann To: robert.jarzmik@free.fr, linux-arm-kernel@lists.infradead.org Cc: Arnd Bergmann , Daniel Mack , Haojian Zhuang , Marek Vasut , Philipp Zabel , Lubomir Rintel , Paul Parsons , Tomas Cech , Sergey Lapin , Thomas Bogendoerfer , Michael Turquette , Stephen Boyd , "Rafael J. Wysocki" , Viresh Kumar , Dmitry Torokhov , Ulf Hansson , Dominik Brodowski , Helge Deller , Mark Brown , Linus Walleij , linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-ide@vger.kernel.org, linux-clk@vger.kernel.org, linux-pm@vger.kernel.org, linux-input@vger.kernel.org, patches@opensource.cirrus.com, linux-leds@vger.kernel.org, linux-mmc@vger.kernel.org, linux-mtd@lists.infradead.org, linux-rtc@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, alsa-devel@alsa-project.org Subject: [PATCH 20/48] ARM: pxa: spitz: use gpio descriptors for audio Date: Tue, 19 Apr 2022 18:37:42 +0200 Message-Id: <20220419163810.2118169-21-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220419163810.2118169-1-arnd@kernel.org> References: <20220419163810.2118169-1-arnd@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220419_094130_522023_A7B4888C X-CRM114-Status: GOOD ( 22.07 ) X-Spam-Score: -5.4 (-----) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Arnd Bergmann The audio driver should not use a hardwired gpio number from the header. Change it to use a lookup table. Acked-by: Mark Brown Cc: alsa-devel@alsa-project.org Signed-off-by: Arnd Bergmann --- arch/arm/mach-pxa/spitz.c | 33 ++++++++++- arch/arm/mach-pxa/{include/mach => [...] Content analysis details: (-5.4 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [139.178.84.217 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.2 DKIMWL_WL_HIGH DKIMwl.org - High trust sender X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org From: Arnd Bergmann The audio driver should not use a hardwired gpio number from the header. Change it to use a lookup table. Acked-by: Mark Brown Cc: alsa-devel@alsa-project.org Signed-off-by: Arnd Bergmann Reviewed-by: Linus Walleij --- arch/arm/mach-pxa/spitz.c | 33 ++++++++++- arch/arm/mach-pxa/{include/mach => }/spitz.h | 2 +- arch/arm/mach-pxa/spitz_pm.c | 2 +- sound/soc/pxa/spitz.c | 58 ++++++++------------ 4 files changed, 57 insertions(+), 38 deletions(-) rename arch/arm/mach-pxa/{include/mach => }/spitz.h (99%) diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c index a648e7094e84..cd8f00945373 100644 --- a/arch/arm/mach-pxa/spitz.c +++ b/arch/arm/mach-pxa/spitz.c @@ -44,7 +44,7 @@ #include #include #include -#include +#include "spitz.h" #include "sharpsl_pm.h" #include @@ -962,11 +962,42 @@ static void __init spitz_i2c_init(void) static inline void spitz_i2c_init(void) {} #endif +static struct gpiod_lookup_table spitz_audio_gpio_table = { + .dev_id = "spitz-audio", + .table = { + GPIO_LOOKUP("sharp-scoop.0", SPITZ_GPIO_MUTE_L - SPITZ_SCP_GPIO_BASE, + "mute-l", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("sharp-scoop.0", SPITZ_GPIO_MUTE_R - SPITZ_SCP_GPIO_BASE, + "mute-r", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("sharp-scoop.1", SPITZ_GPIO_MIC_BIAS - SPITZ_SCP2_GPIO_BASE, + "mic", GPIO_ACTIVE_HIGH), + { }, + }, +}; + +static struct gpiod_lookup_table akita_audio_gpio_table = { + .dev_id = "spitz-audio", + .table = { + GPIO_LOOKUP("sharp-scoop.0", SPITZ_GPIO_MUTE_L - SPITZ_SCP_GPIO_BASE, + "mute-l", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("sharp-scoop.0", SPITZ_GPIO_MUTE_R - SPITZ_SCP_GPIO_BASE, + "mute-r", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("i2c-max7310", AKITA_GPIO_MIC_BIAS - AKITA_IOEXP_GPIO_BASE, + "mic", GPIO_ACTIVE_HIGH), + { }, + }, +}; + /****************************************************************************** * Audio devices ******************************************************************************/ static inline void spitz_audio_init(void) { + if (machine_is_akita()) + gpiod_add_lookup_table(&akita_audio_gpio_table); + else + gpiod_add_lookup_table(&spitz_audio_gpio_table); + platform_device_register_simple("spitz-audio", -1, NULL, 0); } diff --git a/arch/arm/mach-pxa/include/mach/spitz.h b/arch/arm/mach-pxa/spitz.h similarity index 99% rename from arch/arm/mach-pxa/include/mach/spitz.h rename to arch/arm/mach-pxa/spitz.h index 04828d8918aa..f97e3ebd762d 100644 --- a/arch/arm/mach-pxa/include/mach/spitz.h +++ b/arch/arm/mach-pxa/spitz.h @@ -11,7 +11,7 @@ #define __ASM_ARCH_SPITZ_H 1 #endif -#include "irqs.h" /* PXA_NR_BUILTIN_GPIO, PXA_GPIO_TO_IRQ */ +#include /* PXA_NR_BUILTIN_GPIO, PXA_GPIO_TO_IRQ */ #include /* Spitz/Akita GPIOs */ diff --git a/arch/arm/mach-pxa/spitz_pm.c b/arch/arm/mach-pxa/spitz_pm.c index 201dabe883b6..6689b67f9ce5 100644 --- a/arch/arm/mach-pxa/spitz_pm.c +++ b/arch/arm/mach-pxa/spitz_pm.c @@ -19,7 +19,7 @@ #include #include -#include +#include "spitz.h" #include "pxa27x.h" #include "sharpsl_pm.h" diff --git a/sound/soc/pxa/spitz.c b/sound/soc/pxa/spitz.c index 7c1384a869ca..44303b6eb228 100644 --- a/sound/soc/pxa/spitz.c +++ b/sound/soc/pxa/spitz.c @@ -14,13 +14,12 @@ #include #include #include -#include +#include #include #include #include #include -#include #include "../codecs/wm8750.h" #include "pxa2xx-i2s.h" @@ -37,7 +36,7 @@ static int spitz_jack_func; static int spitz_spk_func; -static int spitz_mic_gpio; +static struct gpio_desc *gpiod_mic, *gpiod_mute_l, *gpiod_mute_r; static void spitz_ext_control(struct snd_soc_dapm_context *dapm) { @@ -56,8 +55,8 @@ static void spitz_ext_control(struct snd_soc_dapm_context *dapm) snd_soc_dapm_disable_pin_unlocked(dapm, "Mic Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Line Jack"); snd_soc_dapm_enable_pin_unlocked(dapm, "Headphone Jack"); - gpio_set_value(SPITZ_GPIO_MUTE_L, 1); - gpio_set_value(SPITZ_GPIO_MUTE_R, 1); + gpiod_set_value(gpiod_mute_l, 1); + gpiod_set_value(gpiod_mute_r, 1); break; case SPITZ_MIC: /* enable mic jack and bias, mute hp */ @@ -65,8 +64,8 @@ static void spitz_ext_control(struct snd_soc_dapm_context *dapm) snd_soc_dapm_disable_pin_unlocked(dapm, "Headset Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Line Jack"); snd_soc_dapm_enable_pin_unlocked(dapm, "Mic Jack"); - gpio_set_value(SPITZ_GPIO_MUTE_L, 0); - gpio_set_value(SPITZ_GPIO_MUTE_R, 0); + gpiod_set_value(gpiod_mute_l, 0); + gpiod_set_value(gpiod_mute_r, 0); break; case SPITZ_LINE: /* enable line jack, disable mic bias and mute hp */ @@ -74,8 +73,8 @@ static void spitz_ext_control(struct snd_soc_dapm_context *dapm) snd_soc_dapm_disable_pin_unlocked(dapm, "Headset Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Mic Jack"); snd_soc_dapm_enable_pin_unlocked(dapm, "Line Jack"); - gpio_set_value(SPITZ_GPIO_MUTE_L, 0); - gpio_set_value(SPITZ_GPIO_MUTE_R, 0); + gpiod_set_value(gpiod_mute_l, 0); + gpiod_set_value(gpiod_mute_r, 0); break; case SPITZ_HEADSET: /* enable and unmute headset jack enable mic bias, mute L hp */ @@ -83,8 +82,8 @@ static void spitz_ext_control(struct snd_soc_dapm_context *dapm) snd_soc_dapm_enable_pin_unlocked(dapm, "Mic Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Line Jack"); snd_soc_dapm_enable_pin_unlocked(dapm, "Headset Jack"); - gpio_set_value(SPITZ_GPIO_MUTE_L, 0); - gpio_set_value(SPITZ_GPIO_MUTE_R, 1); + gpiod_set_value(gpiod_mute_l, 0); + gpiod_set_value(gpiod_mute_r, 1); break; case SPITZ_HP_OFF: @@ -93,8 +92,8 @@ static void spitz_ext_control(struct snd_soc_dapm_context *dapm) snd_soc_dapm_disable_pin_unlocked(dapm, "Headset Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Mic Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Line Jack"); - gpio_set_value(SPITZ_GPIO_MUTE_L, 0); - gpio_set_value(SPITZ_GPIO_MUTE_R, 0); + gpiod_set_value(gpiod_mute_l, 0); + gpiod_set_value(gpiod_mute_r, 0); break; } @@ -199,7 +198,7 @@ static int spitz_set_spk(struct snd_kcontrol *kcontrol, static int spitz_mic_bias(struct snd_soc_dapm_widget *w, struct snd_kcontrol *k, int event) { - gpio_set_value_cansleep(spitz_mic_gpio, SND_SOC_DAPM_EVENT_ON(event)); + gpiod_set_value_cansleep(gpiod_mic, SND_SOC_DAPM_EVENT_ON(event)); return 0; } @@ -287,39 +286,28 @@ static int spitz_probe(struct platform_device *pdev) struct snd_soc_card *card = &snd_soc_spitz; int ret; - if (machine_is_akita()) - spitz_mic_gpio = AKITA_GPIO_MIC_BIAS; - else - spitz_mic_gpio = SPITZ_GPIO_MIC_BIAS; - - ret = gpio_request(spitz_mic_gpio, "MIC GPIO"); - if (ret) - goto err1; - - ret = gpio_direction_output(spitz_mic_gpio, 0); - if (ret) - goto err2; + gpiod_mic = devm_gpiod_get(&pdev->dev, "mic", GPIOD_OUT_LOW); + if (IS_ERR(gpiod_mic)) + return PTR_ERR(gpiod_mic); + gpiod_mute_l = devm_gpiod_get(&pdev->dev, "mute-l", GPIOD_OUT_LOW); + if (IS_ERR(gpiod_mute_l)) + return PTR_ERR(gpiod_mute_l); + gpiod_mute_r = devm_gpiod_get(&pdev->dev, "mute-r", GPIOD_OUT_LOW); + if (IS_ERR(gpiod_mute_r)) + return PTR_ERR(gpiod_mute_r); card->dev = &pdev->dev; ret = devm_snd_soc_register_card(&pdev->dev, card); - if (ret) { + if (ret) dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", ret); - goto err2; - } - - return 0; -err2: - gpio_free(spitz_mic_gpio); -err1: return ret; } static int spitz_remove(struct platform_device *pdev) { - gpio_free(spitz_mic_gpio); return 0; }