From patchwork Tue Sep 26 13:25:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13399248 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 20722E7E636 for ; Tue, 26 Sep 2023 13:26:15 +0000 (UTC) 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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7BeT8yumHPle4pqBFlMPbZb6UdWlzoW6ds601zKZfa0=; b=MbmpEVfxR/CEFY 5HeRkWVbxwAtzs4JGiRCSHjdvuB7cmQbfmOhGurhhj+Ouv3fve+rDoEMvjIBiN8dUrBgNWxpjNa+w xFQLRM13YjHXuqoivIw4XlOAUiVnz1ytJMEGq0mkM5c7w3B8eRpj6OG3PdfQHgH1WymuJT4tIy18x gsI9Gsrc5WR1RYr4FOC+dCM3MynYWYEcG47czlXHYipvgCgZJCdbcVA2l59d8XpAEedeDa0E3Zgcp D+mMUKjxTIoWPC/347qN5zcqlIcdOk3OJFTDf84Pv7VB749lCUfuUjnC88BXQqD1pqqvzRCPxQJ6Z dgChyal8MM6rFAKrK92Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ql84R-00GSrG-0q; Tue, 26 Sep 2023 13:25:47 +0000 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ql84K-00GSoe-1E for linux-arm-kernel@lists.infradead.org; Tue, 26 Sep 2023 13:25:41 +0000 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-503012f4e71so12013896e87.0 for ; Tue, 26 Sep 2023 06:25:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695734735; x=1696339535; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=7XQ+0fmcxQn7hNEx2giW0ptNoy4+ucZSflc29tgLhQk=; b=NqSNbnGpOtX/4lIa2NTISlVndIz0JtBFFxu0G6XTufMnOy5jnSPFHpXITh6ZufCdaB ZUKphaZn2PSZVQIJMi2abhBcV4QZbsow8/x3jiLlhnjTQHW7IbM4nK6x7QEbRrCLNT3A ChOsJJV4yIpTwLWCEFuxtZH+410iC3nRe/+cyzkAjUPRvrjoRvrIf3bGenpd/cq/N88c vhd5gcsf9tZqvq4g9DzGz0MCXdueMEtq2jnz/jpR25hzPHGp19Mo4Hls9F61kJ7jvmO5 qNNaO2bTm0ij9m4WNx4SPH/z2q58tWSckPSb68pgLLrQEwK9hbNx9c8PouOub/UBrU0i 70cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695734735; x=1696339535; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7XQ+0fmcxQn7hNEx2giW0ptNoy4+ucZSflc29tgLhQk=; b=JG5KAmAb6QLyNvmdlkx3HEf/E3SzCom41f1EXoOM9ogSQP/hduMGjpLAGxHD8W1SEg 8i9xSKC4Z3n4nB0mk/eW9tbJ7YEIYqysF6WAmw2bIlSW9Iq2fo8QJZEHYY80mWQr7ugq vegPqYwAqksq2bxa4EkW/1WB/rrwbdyX6dVhvZCdwwf0LNJGln5ccpvE47sL/SvM84G7 bW67opKpgLcaj63I2rDfcZ4LkiPH6clOYDArUDvhAuD7TeUgZ07szYYLOWAi2bwoj7Hz gqmrF5sZDT3OUa1iQR7yIxwtfPS1fOpaYusCodW6qtozlP72eGrRuxipeU+CmzxwbP1p 0ZQw== X-Gm-Message-State: AOJu0Yxbs1uOBzIx3u7gS8QSHDBzJBQkrSxgdFs7CAK8j0G12+OjtvdW 0RL2s7r6LxihbVuTYPiotJsIJw== X-Google-Smtp-Source: AGHT+IFPY5U0WllM4x+pCqepZzgVMk893pXwxBLYC4R7FotIFz3M4lxB3pAWd8pzSINV2/2J4ivVlA== X-Received: by 2002:ac2:4c45:0:b0:501:c6d8:6029 with SMTP id o5-20020ac24c45000000b00501c6d86029mr998788lfk.33.1695734735650; Tue, 26 Sep 2023 06:25:35 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id eq25-20020a056512489900b0050307bf2bcdsm2221540lfb.247.2023.09.26.06.25.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 06:25:35 -0700 (PDT) From: Linus Walleij Date: Tue, 26 Sep 2023 15:25:29 +0200 Subject: [PATCH 1/5] ASoC: ti: Convert N810 ASoC to GPIO descriptors MIME-Version: 1.0 Message-Id: <20230926-descriptors-asoc-ti-v1-1-60cf4f8adbc5@linaro.org> References: <20230926-descriptors-asoc-ti-v1-0-60cf4f8adbc5@linaro.org> In-Reply-To: <20230926-descriptors-asoc-ti-v1-0-60cf4f8adbc5@linaro.org> To: Tony Lindgren , Peter Ujfalusi , Jarkko Nikula , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, alsa-devel@alsa-project.org, Linus Walleij X-Mailer: b4 0.12.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230926_062540_427051_EDA7FF79 X-CRM114-Status: GOOD ( 17.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The N810 uses GPIO descriptors pretty much exclusively, but not for ASoC, so let's fix it. Register the pins in a descriptor table in the machine since the ASoC device is not using device tree. Use static locals for the GPIO descriptors because I'm not able to experient with better state storage on any real hardware. Others using the N810 can come afterwards and improve this. Signed-off-by: Linus Walleij --- arch/arm/mach-omap2/board-n8x0.c | 10 ++++++++++ sound/soc/ti/n810.c | 31 +++++++++++++++++-------------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c index 8e3b5068d4ab..31755a378c73 100644 --- a/arch/arm/mach-omap2/board-n8x0.c +++ b/arch/arm/mach-omap2/board-n8x0.c @@ -498,6 +498,15 @@ struct menelaus_platform_data n8x0_menelaus_platform_data = { .late_init = n8x0_menelaus_late_init, }; +static struct gpiod_lookup_table nokia810_asoc_gpio_table = { + .dev_id = "soc-audio", + .table = { + GPIO_LOOKUP("gpio-0-15", 10, "headset", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("gpio-80-111", 21, "speaker", GPIO_ACTIVE_HIGH), + { } + }, +}; + static int __init n8x0_late_initcall(void) { if (!board_caps) @@ -505,6 +514,7 @@ static int __init n8x0_late_initcall(void) n8x0_mmc_init(); n8x0_usb_init(); + gpiod_add_lookup_table(&nokia810_asoc_gpio_table); return 0; } diff --git a/sound/soc/ti/n810.c b/sound/soc/ti/n810.c index ed217b34f846..71a2a90bad2b 100644 --- a/sound/soc/ti/n810.c +++ b/sound/soc/ti/n810.c @@ -15,14 +15,14 @@ #include #include -#include +#include #include #include #include "omap-mcbsp.h" -#define N810_HEADSET_AMP_GPIO 10 -#define N810_SPEAKER_AMP_GPIO 101 +static struct gpio_desc *n810_headset_amp; +static struct gpio_desc *n810_speaker_amp; enum { N810_JACK_DISABLED, @@ -187,9 +187,9 @@ static int n810_spk_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *k, int event) { if (SND_SOC_DAPM_EVENT_ON(event)) - gpio_set_value(N810_SPEAKER_AMP_GPIO, 1); + gpiod_set_value(n810_speaker_amp, 1); else - gpio_set_value(N810_SPEAKER_AMP_GPIO, 0); + gpiod_set_value(n810_speaker_amp, 0); return 0; } @@ -198,9 +198,9 @@ static int n810_jack_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *k, int event) { if (SND_SOC_DAPM_EVENT_ON(event)) - gpio_set_value(N810_HEADSET_AMP_GPIO, 1); + gpiod_set_value(n810_headset_amp, 1); else - gpio_set_value(N810_HEADSET_AMP_GPIO, 0); + gpiod_set_value(n810_headset_amp, 0); return 0; } @@ -327,14 +327,19 @@ static int __init n810_soc_init(void) clk_set_parent(sys_clkout2_src, func96m_clk); clk_set_rate(sys_clkout2, 12000000); - if (WARN_ON((gpio_request(N810_HEADSET_AMP_GPIO, "hs_amp") < 0) || - (gpio_request(N810_SPEAKER_AMP_GPIO, "spk_amp") < 0))) { - err = -EINVAL; + n810_headset_amp = devm_gpiod_get(&n810_snd_device->dev, + "headphone", GPIOD_OUT_LOW); + if (IS_ERR(n810_headset_amp)) { + err = PTR_ERR(n810_headset_amp); goto err4; } - gpio_direction_output(N810_HEADSET_AMP_GPIO, 0); - gpio_direction_output(N810_SPEAKER_AMP_GPIO, 0); + n810_speaker_amp = devm_gpiod_get(&n810_snd_device->dev, + "speaker", GPIOD_OUT_LOW); + if (IS_ERR(n810_speaker_amp)) { + err = PTR_ERR(n810_speaker_amp); + goto err4; + } return 0; err4: @@ -351,8 +356,6 @@ static int __init n810_soc_init(void) static void __exit n810_soc_exit(void) { - gpio_free(N810_SPEAKER_AMP_GPIO); - gpio_free(N810_HEADSET_AMP_GPIO); clk_put(sys_clkout2_src); clk_put(sys_clkout2); clk_put(func96m_clk);