Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp174917iob; Mon, 2 May 2022 16:18:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKgb66tgcs8t77gym9d82erDWo2407GNmKqQuILC955SVs0RHS/p2BKFO1SLt61/H9kbEY X-Received: by 2002:a63:38e:0:b0:3ab:ada6:a219 with SMTP id 136-20020a63038e000000b003abada6a219mr11761443pgd.140.1651533495433; Mon, 02 May 2022 16:18:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651533495; cv=none; d=google.com; s=arc-20160816; b=FcqJHiNNyFqmDhCcZDO/Q3fhomt1OJWKwnpYydBFCMzwUDWzzhWcbowhBSE2yipqJD 9sBZjN5DUZGaTSfWt5c5/q+CiDdd4LjbhdSeE+uHBkLUugashU1ZioDYos6sug1NYDOo w7k9zVrD5DDXXTrklvn6G0nnGI5wVzaVUG4f/azuNByosG2DntzUCVqfn15n4QEVvsUJ 9J5NRQgbt/H+KCEPzpHcvkJsFxSopH6fsKrDcB6/Y2kmNhm0URdROmDQIZQtLqhAHrd2 VxLCVI5q/zEKk+AMzad+IzQ4O3GrA6DZGGQI9bVLqpDIpKqYxKxNanJPtkUjXUjoEpM9 i2Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=1dTh5s/88RaBqifajHaW2aB+dQC/Zyk4BWxOMPVOd5A=; b=uzjF5UMbzu4LVBTlltronDjYpt1ZnF5zdWiCEKO6sL+mgDUEkAOoCk5MJkc6Fvce8N 6gR99wwwgxCmYOHIpMFBBZZU0jVXVRmCwIgREPQltPK0NMg4hWWFLA3xSvtPcwOIyzUy i1cZNplaN8I0pNdGm0V6j9J0HmZDZKxJ1wfmAqofi8WvKrkpidHtfSkzKeLHbKySGJIe 5FSiS8MSVRB0eel13IdRIM6Sgm62dux1Jzk8aiEBnHa+gRSjp8Z3h8oRULeDA1uCgsfN NwBLT+X4mdsMJw1TIHG9iiWmbXaHmNF/lY7DocmvOIxoZcSclZPHEoNGGEVpU69xsxgn XNlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ftc66P1K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id y7-20020a17090322c700b00156bc537059si16079949plg.17.2022.05.02.16.18.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 16:18:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ftc66P1K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3442530F5D; Mon, 2 May 2022 16:17:54 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383546AbiEBHLl (ORCPT + 99 others); Mon, 2 May 2022 03:11:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354251AbiEBHLk (ORCPT ); Mon, 2 May 2022 03:11:40 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A0FE38DBC; Mon, 2 May 2022 00:08:12 -0700 (PDT) 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 1714DB81147; Mon, 2 May 2022 07:08:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBB14C385B4; Mon, 2 May 2022 07:08:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651475289; bh=X5DDZ5cu8Ec0v5TpZDEASVCpiKVJTD3WHl3xILny+5s=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Ftc66P1KRLtIxbphpeXSRKGK+ku85pG3xcLnI/ILm+zDUqAWSpZi/jH68+mJyw4e4 qrSk4knKQzczwh6juw3h25W1EEaFoJp13UogCVeUFApS4IlTRxkiRu31rw+h42AEEo yVvI3NHLHqZRZMWf/GwdXrO0fkciYsoEJY1TJDzJqiHn5YRljNyBweeocP1TAdMDIW SjWUyPk2BlfHWlnvCbBf3F73MPSMg+TT/ecnNgdjKm4f099yYZrBX2f5FXLl9T5/YR SvkcpkVzscWXQHMTAsjSEd0WcjGhlhqUMXSf9/gRaXtg84BSH7Y053ojFgR2kKR7NX cyQX12I4WnqMQ== Received: by mail-yb1-f182.google.com with SMTP id m128so24603743ybm.5; Mon, 02 May 2022 00:08:09 -0700 (PDT) X-Gm-Message-State: AOAM533YXgNgVBCaIk7s9X4l2uGaKY7PX9fESMeQGr95OIWvy9Hgok5G skFANhKVeVZqhSpAEiicidyCvsqdenyuPV2U89E= X-Received: by 2002:a25:31c2:0:b0:641:660f:230f with SMTP id x185-20020a2531c2000000b00641660f230fmr9381815ybx.472.1651475288728; Mon, 02 May 2022 00:08:08 -0700 (PDT) MIME-Version: 1.0 References: <20220419163810.2118169-1-arnd@kernel.org> <20220419163810.2118169-19-arnd@kernel.org> In-Reply-To: From: Arnd Bergmann Date: Mon, 2 May 2022 09:07:52 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 18/48] ARM: pxa: hx4700: use gpio descriptors for audio To: Linus Walleij Cc: Robert Jarzmik , Linux ARM , 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 , Linux Kernel Mailing List , "open list:BROADCOM NVRAM DRIVER" , IDE-ML , linux-clk , Linux PM list , "open list:HID CORE LAYER" , patches@opensource.cirrus.com, linux-leds@vger.kernel.org, linux-mmc , linux-mtd , linux-rtc@vger.kernel.org, USB list , Linux Fbdev development list , dri-devel , ALSA Development Mailing List Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, May 1, 2022 at 11:41 PM Linus Walleij wrote: > > (...) > > +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), > > This looks wrong. The n in nDET in the end of the name of the GPIO line > means active low does it not? > > What I usually do when I see this is to properly set it to > GPIO_ACTIVE_LOW in the descriptor table, then invert the logic > where it's getting used. > > Also rename to earphone-det instead of -ndet Thanks for taking a look! I changed it now, but I don't know if I got the correct number of inversions in the end. How does this look? Arnd commit 9d452c9cbee59fc58c940b5f7ae5a40579aab0d2 Author: Arnd Bergmann Date: Wed Sep 11 14:27:13 2019 +0200 ARM: pxa: hx4700: use gpio descriptors for audio 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 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..2ae06edf413c 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-det", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio-pxa", GPIO92_HX4700_HP_DRIVER, + "hp-driver", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("gpio-pxa", GPIO107_HX4700_SPK_nSD, + "spk-sd", GPIO_ACTIVE_LOW), + { }, + }, +}; + 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..a0734b742322 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_sd; static struct snd_soc_jack hs_jack; /* Headphones jack detection DAPM pin */ @@ -40,9 +40,7 @@ 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-det", .report = SND_JACK_HEADPHONE, .debounce_time = 200, }; @@ -81,14 +79,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_sd, !!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 +160,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 +167,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_sd = devm_gpiod_get(&pdev->dev, "spk-sd", GPIOD_OUT_LOW); + ret = PTR_ERR_OR_ZERO(gpiod_spk_sd); 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_sd, 0); return 0; }