From patchwork Tue Apr 19 16:37:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 12823469 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 37CA2C433EF for ; Fri, 22 Apr 2022 13:40:46 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 766511746; Fri, 22 Apr 2022 15:39:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 766511746 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1650634844; bh=UmyAEDevE+rFHmIeeKFFlzSBscHHSEtR+AtXVKUZXjI=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=JkQjmaufPMshoR4gJqkkhNOHhs2th36j7i+YGewJ1l01UPo74SW0QySjrEtjXyuj2 DpHHcscOYG0wKr6d5lfcPEyv2bMVRbDLo9EifscLQFgr1hiyL7LGF6asyHoc+4N28W hhXMADPlxMumWf9HPSKeoYCt2/K2Q9JzoWPWCVQY= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 21E4BF805FA; Fri, 22 Apr 2022 15:32:07 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6302BF80121; Tue, 19 Apr 2022 18:41:21 +0200 (CEST) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 52126F80121 for ; Tue, 19 Apr 2022 18:41:15 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 52126F80121 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VBOATLbR" 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 ams.source.kernel.org (Postfix) with ESMTPS id B4DF5B818E6; Tue, 19 Apr 2022 16:41:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23064C385A5; Tue, 19 Apr 2022 16:41:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650386473; bh=UmyAEDevE+rFHmIeeKFFlzSBscHHSEtR+AtXVKUZXjI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VBOATLbRuYChK3MBgRX8mPip9VFQsTd4uM6E3FKAYou3P3IZa9nmev0mrBBoYpVGs Nl+voA7jYEZWdMuLiO7BEMPH+MVsDjnXXGALSLYw1w1AX0WnSQTPUBDuRtK63hpICj 8+5p1J7vvcJkBz7CuQogkh9GDU2SBWlcgjibaorUtjAG4DdHSgFg+dieu5I1H5UTwe yODr+X/HyGXAHTGbi4Lq4APNxVx4sfb3QJu3sbtv29oNO8I1LDZpvn7U0jmcS7bSjQ 9f0xIKo83CR6rz6qWgvk3LUsWMEix8qqKI0I+7fX418R/bEF9m0lgtwSh1l4J0GIYp y51mpx0B4pZoQ== From: Arnd Bergmann To: robert.jarzmik@free.fr, linux-arm-kernel@lists.infradead.org Subject: [PATCH 18/48] ARM: pxa: hx4700: use gpio descriptors for audio Date: Tue, 19 Apr 2022 18:37:40 +0200 Message-Id: <20220419163810.2118169-19-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-Mailman-Approved-At: Fri, 22 Apr 2022 15:31:41 +0200 Cc: Ulf Hansson , linux-usb@vger.kernel.org, Philipp Zabel , "Rafael J. Wysocki" , Viresh Kumar , Sergey Lapin , linux-fbdev@vger.kernel.org, Dominik Brodowski , linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org, linux-mtd@lists.infradead.org, Tomas Cech , linux-clk@vger.kernel.org, linux-leds@vger.kernel.org, linux-rtc@vger.kernel.org, Helge Deller , Marek Vasut , Paul Parsons , Linus Walleij , Arnd Bergmann , linux-pm@vger.kernel.org, linux-input@vger.kernel.org, Haojian Zhuang , Lubomir Rintel , Mark Brown , dri-devel@lists.freedesktop.org, Thomas Bogendoerfer , Stephen Boyd , patches@opensource.cirrus.com, Dmitry Torokhov , linux-mmc@vger.kernel.org, linux-mips@vger.kernel.org, Michael Turquette , alsa-devel@alsa-project.org, Daniel Mack X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Arnd Bergmann The audio driver should not use a hardwired gpio number from the header. Change it to use a lookup table. Cc: Philipp Zabel Cc: Paul Parsons Acked-by: Mark Brown Acked-by: Robert Jarzmik Cc: alsa-devel@alsa-project.org Signed-off-by: Arnd Bergmann --- arch/arm/mach-pxa/hx4700-pcmcia.c | 2 +- arch/arm/mach-pxa/hx4700.c | 16 ++++++++- arch/arm/mach-pxa/{include/mach => }/hx4700.h | 2 +- sound/soc/pxa/hx4700.c | 34 ++++++++----------- 4 files changed, 31 insertions(+), 23 deletions(-) rename arch/arm/mach-pxa/{include/mach => }/hx4700.h (99%) diff --git a/arch/arm/mach-pxa/hx4700-pcmcia.c b/arch/arm/mach-pxa/hx4700-pcmcia.c index e8acbfc9ef6c..e2331dfe427d 100644 --- a/arch/arm/mach-pxa/hx4700-pcmcia.c +++ b/arch/arm/mach-pxa/hx4700-pcmcia.c @@ -10,7 +10,7 @@ #include #include -#include +#include "hx4700.h" #include diff --git a/arch/arm/mach-pxa/hx4700.c b/arch/arm/mach-pxa/hx4700.c index 140a44cb2989..2b7f37172725 100644 --- a/arch/arm/mach-pxa/hx4700.c +++ b/arch/arm/mach-pxa/hx4700.c @@ -41,7 +41,7 @@ #include "pxa27x.h" #include "addr-map.h" -#include +#include "hx4700.h" #include #include @@ -834,6 +834,19 @@ static struct i2c_board_info i2c_board_info[] __initdata = { }, }; +static struct gpiod_lookup_table hx4700_audio_gpio_table = { + .dev_id = "hx4700-audio", + .table = { + GPIO_LOOKUP("gpio-pxa", GPIO75_HX4700_EARPHONE_nDET, + "earphone-ndet", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("gpio-pxa", GPIO92_HX4700_HP_DRIVER, + "hp-driver", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("gpio-pxa", GPIO107_HX4700_SPK_nSD, + "spk-nsd", GPIO_ACTIVE_HIGH), + { }, + }, +}; + static struct platform_device audio = { .name = "hx4700-audio", .id = -1, @@ -895,6 +908,7 @@ static void __init hx4700_init(void) gpiod_add_lookup_table(&bq24022_gpiod_table); gpiod_add_lookup_table(&gpio_vbus_gpiod_table); + gpiod_add_lookup_table(&hx4700_audio_gpio_table); platform_add_devices(devices, ARRAY_SIZE(devices)); pwm_add_table(hx4700_pwm_lookup, ARRAY_SIZE(hx4700_pwm_lookup)); diff --git a/arch/arm/mach-pxa/include/mach/hx4700.h b/arch/arm/mach-pxa/hx4700.h similarity index 99% rename from arch/arm/mach-pxa/include/mach/hx4700.h rename to arch/arm/mach-pxa/hx4700.h index 0c30e6d9c660..ce2db33989e1 100644 --- a/arch/arm/mach-pxa/include/mach/hx4700.h +++ b/arch/arm/mach-pxa/hx4700.h @@ -10,7 +10,7 @@ #include #include -#include "irqs.h" /* PXA_NR_BUILTIN_GPIO */ +#include /* PXA_NR_BUILTIN_GPIO */ #define HX4700_ASIC3_GPIO_BASE PXA_NR_BUILTIN_GPIO #define HX4700_EGPIO_BASE (HX4700_ASIC3_GPIO_BASE + ASIC3_NUM_GPIOS) diff --git a/sound/soc/pxa/hx4700.c b/sound/soc/pxa/hx4700.c index 7334fac758de..e70dc38d9892 100644 --- a/sound/soc/pxa/hx4700.c +++ b/sound/soc/pxa/hx4700.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include @@ -18,10 +18,10 @@ #include #include -#include #include #include "pxa2xx-i2s.h" +static struct gpio_desc *gpiod_hp_driver, *gpiod_spk_nsd; static struct snd_soc_jack hs_jack; /* Headphones jack detection DAPM pin */ @@ -40,9 +40,8 @@ static struct snd_soc_jack_pin hs_jack_pin[] = { /* Headphones jack detection GPIO */ static struct snd_soc_jack_gpio hs_jack_gpio = { - .gpio = GPIO75_HX4700_EARPHONE_nDET, .invert = true, - .name = "hp-gpio", + .name = "earphone-ndet", .report = SND_JACK_HEADPHONE, .debounce_time = 200, }; @@ -81,14 +80,14 @@ static const struct snd_soc_ops hx4700_ops = { static int hx4700_spk_power(struct snd_soc_dapm_widget *w, struct snd_kcontrol *k, int event) { - gpio_set_value(GPIO107_HX4700_SPK_nSD, !!SND_SOC_DAPM_EVENT_ON(event)); + gpiod_set_value(gpiod_spk_nsd, !!SND_SOC_DAPM_EVENT_ON(event)); return 0; } static int hx4700_hp_power(struct snd_soc_dapm_widget *w, struct snd_kcontrol *k, int event) { - gpio_set_value(GPIO92_HX4700_HP_DRIVER, !!SND_SOC_DAPM_EVENT_ON(event)); + gpiod_set_value(gpiod_hp_driver, !!SND_SOC_DAPM_EVENT_ON(event)); return 0; } @@ -162,11 +161,6 @@ static struct snd_soc_card snd_soc_card_hx4700 = { .fully_routed = true, }; -static struct gpio hx4700_audio_gpios[] = { - { GPIO107_HX4700_SPK_nSD, GPIOF_OUT_INIT_HIGH, "SPK_POWER" }, - { GPIO92_HX4700_HP_DRIVER, GPIOF_OUT_INIT_LOW, "EP_POWER" }, -}; - static int hx4700_audio_probe(struct platform_device *pdev) { int ret; @@ -174,26 +168,26 @@ static int hx4700_audio_probe(struct platform_device *pdev) if (!machine_is_h4700()) return -ENODEV; - ret = gpio_request_array(hx4700_audio_gpios, - ARRAY_SIZE(hx4700_audio_gpios)); + gpiod_hp_driver = devm_gpiod_get(&pdev->dev, "hp-driver", GPIOD_OUT_HIGH); + ret = PTR_ERR_OR_ZERO(gpiod_hp_driver); + if (ret) + return ret; + gpiod_spk_nsd = devm_gpiod_get(&pdev->dev, "spk-nsd", GPIOD_OUT_HIGH); + ret = PTR_ERR_OR_ZERO(gpiod_spk_nsd); if (ret) return ret; + hs_jack_gpio.gpiod_dev = &pdev->dev; snd_soc_card_hx4700.dev = &pdev->dev; ret = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_hx4700); - if (ret) - gpio_free_array(hx4700_audio_gpios, - ARRAY_SIZE(hx4700_audio_gpios)); return ret; } static int hx4700_audio_remove(struct platform_device *pdev) { - gpio_set_value(GPIO92_HX4700_HP_DRIVER, 0); - gpio_set_value(GPIO107_HX4700_SPK_nSD, 0); - - gpio_free_array(hx4700_audio_gpios, ARRAY_SIZE(hx4700_audio_gpios)); + gpiod_set_value(gpiod_hp_driver, 0); + gpiod_set_value(gpiod_spk_nsd, 0); return 0; }