Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1745989ybg; Sat, 19 Oct 2019 01:36:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqyiW97dAgGBANt7Rv7yYAkPXnRNlDtjkxzhhRE7m4bolk44I4JU3rsf0FhT90EnEe6S2fJN X-Received: by 2002:a17:906:4748:: with SMTP id j8mr12639071ejs.210.1571474163511; Sat, 19 Oct 2019 01:36:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571474163; cv=none; d=google.com; s=arc-20160816; b=Gpb4LcqHKGwqWcscaCT1kAnnq7MKvdeShZ3Vyuh5vUF2ETL7ETeRY6Aj3hYNIqzMvH uVS65awhA5EtjCmdxR2aNQBXnA8N+KYwMfxc00N7Elz74OhmvSpYrPAF0ERJvg3sPxvP s4YIYuIM1UaOTX/jeht96udgmwO9odI680UEE+EUl42d1yzh1KL8cKWUs9v036pR4meS 5Yy2lz6r7A5LTJfw1TAB805ZMMz8pycWSzzipR7iQQM7VjX+Oa0/qunDBdiezJuekWHV NCTTtAYCKTySAzKM5I6VKyR1BgowxJC9xSBGxCPvjrhfVT8dyQ28Rm3GjW8fYiF2Lo/G LS5g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=iXHXsuk8L55XBylBoCri75zxU6CZ6daSFp0kmrDMW+w=; b=x4SQXchqRsKI/8DITeVqsSrpSScN2woWCMkDjBojx1xfml95mRf8xwOfHaX6q+wzLH I42jBsr05cNd+mrHCdXRF79JUV/FI22F7SiTgmpC0EFoehIcdeBg7HwMzITBY1PO5bqv oMdIUKclkP5+q/zt8Cfe/5BUgd7iLHnujlh71zThcnrFidi5Lir9E/fAr1fy4pCofz3M P60QBF+2EtUHAa00CG1+ZVzopofkRQUNIRfadMRLLicxFIratLKEWSeYhpMmOlRzTWo9 +095FDl9Ts95H5TB3o94CoJKgmQJ5ll/W04/8o92ffeXI0QgCKKcCw5MVzgZBsuyeT/4 G3gA== ARC-Authentication-Results: i=1; mx.google.com; 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 h40si1390956ede.176.2019.10.19.01.35.39; Sat, 19 Oct 2019 01:36:03 -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; 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 S2505268AbfJRPmy (ORCPT + 99 others); Fri, 18 Oct 2019 11:42:54 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:35025 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2505201AbfJRPmp (ORCPT ); Fri, 18 Oct 2019 11:42:45 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPA (Nemesis) id 1MEFrX-1iDXlf06Gj-00ABwm; Fri, 18 Oct 2019 17:42:26 +0200 From: Arnd Bergmann To: Daniel Mack , Haojian Zhuang , Robert Jarzmik Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Linus Walleij , Arnd Bergmann , Mark Brown , alsa-devel@alsa-project.org Subject: [PATCH 18/46] ARM: pxa: corgi: use gpio descriptors for audio Date: Fri, 18 Oct 2019 17:41:33 +0200 Message-Id: <20191018154201.1276638-18-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191018154052.1276506-1-arnd@arndb.de> References: <20191018154052.1276506-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zCP/7/kXz5qtU978M9POI K4kcxA1iPGYq4NV/V90WmPpCWMSBF5BaO5zh3e5g/kc7dAmJytHL0xFbQOhsPIZkHYJTSZ/5y gofshTfkjZrwPiMBm9pptriZ7EWNbW6WHEy/semSfAUGW4GQqXsupl6K4v9x3c9b64c+2wyLr g9Ax+n5CcCDM0fOLODuA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The audio driver should not use a hardwired gpio number from the header. Change it to use a lookup table. Cc: Mark Brown Cc: alsa-devel@alsa-project.org Signed-off-by: Arnd Bergmann --- arch/arm/mach-pxa/corgi.c | 22 ++++++++++- arch/arm/mach-pxa/{include/mach => }/corgi.h | 2 +- arch/arm/mach-pxa/corgi_pm.c | 2 +- sound/soc/pxa/corgi.c | 40 +++++++++++++------- 4 files changed, 50 insertions(+), 16 deletions(-) rename arch/arm/mach-pxa/{include/mach => }/corgi.h (98%) diff --git a/arch/arm/mach-pxa/corgi.c b/arch/arm/mach-pxa/corgi.c index e9743ebbee86..0ff8e8140513 100644 --- a/arch/arm/mach-pxa/corgi.c +++ b/arch/arm/mach-pxa/corgi.c @@ -49,7 +49,7 @@ #include #include #include "udc.h" -#include +#include "corgi.h" #include "sharpsl_pm.h" #include @@ -472,6 +472,25 @@ static struct platform_device corgiled_device = { }, }; +static struct gpiod_lookup_table corgi_audio_gpio_table = { + .dev_id = "corgi-audio", + .table = { + GPIO_LOOKUP("sharp-scoop", + CORGI_GPIO_MUTE_L - CORGI_SCOOP_GPIO_BASE, + "mute-l", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("sharp-scoop", + CORGI_GPIO_MUTE_R - CORGI_SCOOP_GPIO_BASE, + "mute-r", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("sharp-scoop", + CORGI_GPIO_APM_ON - CORGI_SCOOP_GPIO_BASE, + "apm-on", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("sharp-scoop", + CORGI_GPIO_MIC_BIAS - CORGI_SCOOP_GPIO_BASE, + "mic-bias", GPIO_ACTIVE_HIGH), + { }, + }, +}; + /* * Corgi Audio */ @@ -740,6 +759,7 @@ static void __init corgi_init(void) pxa_set_udc_info(&udc_info); gpiod_add_lookup_table(&corgi_mci_gpio_table); + gpiod_add_lookup_table(&corgi_audio_gpio_table); pxa_set_mci_info(&corgi_mci_platform_data); pxa_set_ficp_info(&corgi_ficp_platform_data); pxa_set_i2c_info(NULL); diff --git a/arch/arm/mach-pxa/include/mach/corgi.h b/arch/arm/mach-pxa/corgi.h similarity index 98% rename from arch/arm/mach-pxa/include/mach/corgi.h rename to arch/arm/mach-pxa/corgi.h index b565ca7b8cda..fe2fcf6532b9 100644 --- a/arch/arm/mach-pxa/include/mach/corgi.h +++ b/arch/arm/mach-pxa/corgi.h @@ -9,7 +9,7 @@ #ifndef __ASM_ARCH_CORGI_H #define __ASM_ARCH_CORGI_H 1 -#include "irqs.h" /* PXA_NR_BUILTIN_GPIO */ +#include /* PXA_NR_BUILTIN_GPIO */ /* * Corgi (Non Standard) GPIO Definitions diff --git a/arch/arm/mach-pxa/corgi_pm.c b/arch/arm/mach-pxa/corgi_pm.c index ff1ac9bf37cb..c6ddfc737644 100644 --- a/arch/arm/mach-pxa/corgi_pm.c +++ b/arch/arm/mach-pxa/corgi_pm.c @@ -20,7 +20,7 @@ #include #include -#include +#include "corgi.h" #include #include "sharpsl_pm.h" diff --git a/sound/soc/pxa/corgi.c b/sound/soc/pxa/corgi.c index 47647a1c3124..9db5a3d3606e 100644 --- a/sound/soc/pxa/corgi.c +++ b/sound/soc/pxa/corgi.c @@ -21,7 +21,6 @@ #include #include -#include #include #include "../codecs/wm8731.h" @@ -41,6 +40,8 @@ static int corgi_jack_func; static int corgi_spk_func; +struct gpio_desc *gpiod_mute_l, *gpiod_mute_r, *gpiod_apm_on, *gpiod_mic_bias; + static void corgi_ext_control(struct snd_soc_dapm_context *dapm) { snd_soc_dapm_mutex_lock(dapm); @@ -49,8 +50,8 @@ static void corgi_ext_control(struct snd_soc_dapm_context *dapm) switch (corgi_jack_func) { case CORGI_HP: /* set = unmute headphone */ - gpio_set_value(CORGI_GPIO_MUTE_L, 1); - gpio_set_value(CORGI_GPIO_MUTE_R, 1); + gpiod_set_value(gpiod_mute_l, 1); + gpiod_set_value(gpiod_mute_r, 1); 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"); @@ -58,24 +59,24 @@ static void corgi_ext_control(struct snd_soc_dapm_context *dapm) break; case CORGI_MIC: /* reset = mute headphone */ - gpio_set_value(CORGI_GPIO_MUTE_L, 0); - gpio_set_value(CORGI_GPIO_MUTE_R, 0); + gpiod_set_value(gpiod_mute_l, 0); + gpiod_set_value(gpiod_mute_r, 0); snd_soc_dapm_enable_pin_unlocked(dapm, "Mic Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Line Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headphone Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headset Jack"); break; case CORGI_LINE: - gpio_set_value(CORGI_GPIO_MUTE_L, 0); - gpio_set_value(CORGI_GPIO_MUTE_R, 0); + gpiod_set_value(gpiod_mute_l, 0); + gpiod_set_value(gpiod_mute_r, 0); snd_soc_dapm_disable_pin_unlocked(dapm, "Mic Jack"); snd_soc_dapm_enable_pin_unlocked(dapm, "Line Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headphone Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headset Jack"); break; case CORGI_HEADSET: - gpio_set_value(CORGI_GPIO_MUTE_L, 0); - gpio_set_value(CORGI_GPIO_MUTE_R, 1); + gpiod_set_value(gpiod_mute_l, 0); + gpiod_set_value(gpiod_mute_r, 1); snd_soc_dapm_enable_pin_unlocked(dapm, "Mic Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Line Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headphone Jack"); @@ -108,8 +109,8 @@ static int corgi_startup(struct snd_pcm_substream *substream) static void corgi_shutdown(struct snd_pcm_substream *substream) { /* set = unmute headphone */ - gpio_set_value(CORGI_GPIO_MUTE_L, 1); - gpio_set_value(CORGI_GPIO_MUTE_R, 1); + gpiod_set_value(gpiod_mute_l, 1); + gpiod_set_value(gpiod_mute_r, 1); } static int corgi_hw_params(struct snd_pcm_substream *substream, @@ -199,14 +200,14 @@ static int corgi_set_spk(struct snd_kcontrol *kcontrol, static int corgi_amp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *k, int event) { - gpio_set_value(CORGI_GPIO_APM_ON, SND_SOC_DAPM_EVENT_ON(event)); + gpiod_set_value(gpiod_apm_on, SND_SOC_DAPM_EVENT_ON(event)); return 0; } static int corgi_mic_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *k, int event) { - gpio_set_value(CORGI_GPIO_MIC_BIAS, SND_SOC_DAPM_EVENT_ON(event)); + gpiod_set_value(gpiod_mic_bias, SND_SOC_DAPM_EVENT_ON(event)); return 0; } @@ -293,6 +294,19 @@ static int corgi_probe(struct platform_device *pdev) card->dev = &pdev->dev; + gpiod_mute_l = devm_gpiod_get(&pdev->dev, "mute-l", GPIOD_OUT_HIGH); + if (IS_ERR(gpiod_mute_l)) + return PTR_ERR(gpiod_mute_l); + gpiod_mute_r = devm_gpiod_get(&pdev->dev, "mute-r", GPIOD_OUT_HIGH); + if (IS_ERR(gpiod_mute_r)) + return PTR_ERR(gpiod_mute_r); + gpiod_apm_on = devm_gpiod_get(&pdev->dev, "apm-on", GPIOD_OUT_LOW); + if (IS_ERR(gpiod_apm_on)) + return PTR_ERR(gpiod_apm_on); + gpiod_mic_bias = devm_gpiod_get(&pdev->dev, "mic-bias", GPIOD_OUT_LOW); + if (IS_ERR(gpiod_mic_bias)) + return PTR_ERR(gpiod_mic_bias); + ret = devm_snd_soc_register_card(&pdev->dev, card); if (ret) dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", -- 2.20.0