From patchwork Fri Dec 8 10:09:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13485185 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 C26C0C10DCE for ; Fri, 8 Dec 2023 10:10:09 +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=9GC1/FTwZACwGHtEqo90Cv+doCB1J+0thKpusNkVP4I=; b=xvGg9vcEdBNhUb 4m+nBZ/QYlnQIQLvCiC/Lr+ixwdTRTzjp3a22eDhuJGIysW4zh76FJHqwgbxT8VhRnQapjzOU+Gmx OxWazi/Ky5y8s2Mrr0DvKrTBSyJ262F/DNUgoCHum6Bp9lvixwGU8A6znVXgbU1dMXAvZAZIkbLYz EqjtuwramtmQ9dLcu3naNXWiI8A47jsoMLTCmzjPFTlcxOozwBxzWPlWO5O416iyxfgGOPiuJLKqO LdCDdk5INMBL5cplRyly4cZpZ98YNuCHTl3x276V4m1RXlMoZlujJkD6LgT0ODKhWNW4ItpJHF4o/ xjfh7irfMDtYh60/S4vg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rBXnj-00FCeh-2K; Fri, 08 Dec 2023 10:09:43 +0000 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rBXne-00FCc6-1Z for linux-arm-kernel@lists.infradead.org; Fri, 08 Dec 2023 10:09:40 +0000 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-50c0f6b1015so2072478e87.3 for ; Fri, 08 Dec 2023 02:09:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702030174; x=1702634974; 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=4fbMNx8K6X721K26Lgmb1xI9uac4P9/tY0MeUYoh8EA=; b=d10la6IrbTXrfi26+aNjQYabjCQNcenguG61xUSRf7fjLoAFXMC/VGNrilTn9ZcTL5 iCKYPKibJBwRTJiTGC2fYb57ydfRjo5VASxO0xup0hP8BjIamq0hj127l+c5aFNF07d5 dgHkk3Z+AByZsDDMuTSjgO1iZHtXNjhOGP/VL2hvD/dBsMXTaNi40aO8sEAS9J4iZTGI WhsuwThx7H8uNTrKM2NKdScCY+GC1cyNGzhpqW2pAonH2TKL2LAJVSkc+lgkuy4/QxPZ d94lIVcPHzZ9VK/+EUMQOuDrTFFuVFNvjxTHni22zDh4sdFj9znFh4chzXptZgf+57Hh Aggw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702030174; x=1702634974; 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=4fbMNx8K6X721K26Lgmb1xI9uac4P9/tY0MeUYoh8EA=; b=RlKbsg2CxyCYGBj4EwijGJ5NEhNNZpjGB8+QAWRxpHxGtrbFaU04T+RIklGZdkpYS9 GHsYsVa2UxR43ccU5HGt6IgyRgTJjOfOUBc8WCDoER7gEPbAOQFmFtWV5UB+RAowkZsq UzJwGXW9c4c3x2HArmFUgVuC4ObfgwzUru4LpdjY1vZ4LfvCyhvZtJ8qYPPUm/WoeWiV GYMWpxWaAwF0HQVvTloOlr1omKFqS2OXu1d8CIVqRecHAwuog2WGLiAZlRrSKv34TiSQ eazBdDC22uqNZtPfKCFD8lU6RA5s79mJoEYeEY9YmSKs2ytZ3iu5a7++f9fg/3CQ1FQe mbeA== X-Gm-Message-State: AOJu0YxPddQnqV9i6EgUbYxuUeViXV6TsnmNKVxQgOFYVbuoXnB8nrQ1 XFvnQ7R8lJz3pG24Db88RnpyHQ== X-Google-Smtp-Source: AGHT+IG5hKLIPrlVDQ94uVi4SqUyllHlGOKufWNCNqV7C79hn/3+s2YqaskB1j5yvCcg+N6xWM87dA== X-Received: by 2002:a05:6512:3e03:b0:50b:e229:23b0 with SMTP id i3-20020a0565123e0300b0050be22923b0mr3135826lfv.94.1702030174566; Fri, 08 Dec 2023 02:09:34 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id m4-20020a194344000000b0050bfd7d8873sm174295lfj.254.2023.12.08.02.09.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 02:09:33 -0800 (PST) From: Linus Walleij Date: Fri, 08 Dec 2023 11:09:25 +0100 Subject: [PATCH 1/5] ASoC: wm0010: Convert to GPIO descriptors MIME-Version: 1.0 Message-Id: <20231208-descriptors-sound-wlf-v1-1-c4dab6f521ec@linaro.org> References: <20231208-descriptors-sound-wlf-v1-0-c4dab6f521ec@linaro.org> In-Reply-To: <20231208-descriptors-sound-wlf-v1-0-c4dab6f521ec@linaro.org> To: Krzysztof Kozlowski , Alim Akhtar , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown Cc: patches@opensource.cirrus.com, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-sound@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231208_020938_527611_3C73E14A X-CRM114-Status: GOOD ( 21.24 ) 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 This converts the WM0010 codec to use GPIO descriptors. It's a pretty straight-forward conversion also switching over the single in-tree user in the S3C Cragganmore module for S3C 6410. Signed-off-by: Linus Walleij Reviewed-by: Charles Keepax Acked-by: Krzysztof Kozlowski --- arch/arm/mach-s3c/mach-crag6410-module.c | 16 +++++++++--- include/sound/wm0010.h | 6 ----- sound/soc/codecs/wm0010.c | 44 ++++++++------------------------ 3 files changed, 23 insertions(+), 43 deletions(-) diff --git a/arch/arm/mach-s3c/mach-crag6410-module.c b/arch/arm/mach-s3c/mach-crag6410-module.c index 8fce1e815ee8..a9a713641047 100644 --- a/arch/arm/mach-s3c/mach-crag6410-module.c +++ b/arch/arm/mach-s3c/mach-crag6410-module.c @@ -32,9 +32,18 @@ #include "crag6410.h" +static struct gpiod_lookup_table wm0010_gpiod_table = { + .dev_id = "spi0.0", /* SPI device name */ + .table = { + /* Active high for Glenfarclas Rev 2 */ + GPIO_LOOKUP("GPION", 6, + "reset", GPIO_ACTIVE_HIGH), + { }, + }, +}; + static struct wm0010_pdata wm0010_pdata = { - .gpio_reset = S3C64XX_GPN(6), - .reset_active_high = 1, /* Active high for Glenfarclas Rev 2 */ + /* Intentionally left blank */ }; static struct spi_board_info wm1253_devs[] = { @@ -337,7 +346,8 @@ static const struct { { .id = 0x21, .rev = 0xff, .name = "1275-EV1 Mortlach" }, { .id = 0x25, .rev = 0xff, .name = "1274-EV1 Glencadam" }, { .id = 0x31, .rev = 0xff, .name = "1253-EV1 Tomatin", - .spi_devs = wm1253_devs, .num_spi_devs = ARRAY_SIZE(wm1253_devs) }, + .spi_devs = wm1253_devs, .num_spi_devs = ARRAY_SIZE(wm1253_devs), + .gpiod_table = &wm0010_gpiod_table }, { .id = 0x32, .rev = 0xff, .name = "XXXX-EV1 Caol Illa" }, { .id = 0x33, .rev = 0xff, .name = "XXXX-EV1 Oban" }, { .id = 0x34, .rev = 0xff, .name = "WM0010-6320-CS42 Balblair", diff --git a/include/sound/wm0010.h b/include/sound/wm0010.h index 13b473935ca1..14ff9056c5d0 100644 --- a/include/sound/wm0010.h +++ b/include/sound/wm0010.h @@ -11,12 +11,6 @@ #define WM0010_PDATA_H struct wm0010_pdata { - int gpio_reset; - - /* Set if there is an inverter between the GPIO controlling - * the reset signal and the device. - */ - int reset_active_high; int irq_flags; }; diff --git a/sound/soc/codecs/wm0010.c b/sound/soc/codecs/wm0010.c index 1d4259433f47..8f862729a2ca 100644 --- a/sound/soc/codecs/wm0010.c +++ b/sound/soc/codecs/wm0010.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include #include @@ -94,8 +94,7 @@ struct wm0010_priv { struct wm0010_pdata pdata; - int gpio_reset; - int gpio_reset_value; + struct gpio_desc *reset; struct regulator_bulk_data core_supplies[2]; struct regulator *dbvdd; @@ -174,8 +173,7 @@ static void wm0010_halt(struct snd_soc_component *component) case WM0010_STAGE2: case WM0010_FIRMWARE: /* Remember to put chip back into reset */ - gpio_set_value_cansleep(wm0010->gpio_reset, - wm0010->gpio_reset_value); + gpiod_set_value_cansleep(wm0010->reset, 1); /* Disable the regulators */ regulator_disable(wm0010->dbvdd); regulator_bulk_disable(ARRAY_SIZE(wm0010->core_supplies), @@ -610,7 +608,7 @@ static int wm0010_boot(struct snd_soc_component *component) } /* Release reset */ - gpio_set_value_cansleep(wm0010->gpio_reset, !wm0010->gpio_reset_value); + gpiod_set_value_cansleep(wm0010->reset, 0); spin_lock_irqsave(&wm0010->irq_lock, flags); wm0010->state = WM0010_OUT_OF_RESET; spin_unlock_irqrestore(&wm0010->irq_lock, flags); @@ -863,7 +861,6 @@ static int wm0010_probe(struct snd_soc_component *component) static int wm0010_spi_probe(struct spi_device *spi) { - unsigned long gpio_flags; int ret; int trigger; int irq; @@ -903,31 +900,11 @@ static int wm0010_spi_probe(struct spi_device *spi) return ret; } - if (wm0010->pdata.gpio_reset) { - wm0010->gpio_reset = wm0010->pdata.gpio_reset; - - if (wm0010->pdata.reset_active_high) - wm0010->gpio_reset_value = 1; - else - wm0010->gpio_reset_value = 0; - - if (wm0010->gpio_reset_value) - gpio_flags = GPIOF_OUT_INIT_HIGH; - else - gpio_flags = GPIOF_OUT_INIT_LOW; - - ret = devm_gpio_request_one(wm0010->dev, wm0010->gpio_reset, - gpio_flags, "wm0010 reset"); - if (ret < 0) { - dev_err(wm0010->dev, - "Failed to request GPIO for DSP reset: %d\n", - ret); - return ret; - } - } else { - dev_err(wm0010->dev, "No reset GPIO configured\n"); - return -EINVAL; - } + wm0010->reset = devm_gpiod_get(wm0010->dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(wm0010->reset)) + return dev_err_probe(wm0010->dev, PTR_ERR(wm0010->reset), + "could not get RESET GPIO\n"); + gpiod_set_consumer_name(wm0010->reset, "wm0010 reset"); wm0010->state = WM0010_POWER_OFF; @@ -972,8 +949,7 @@ static void wm0010_spi_remove(struct spi_device *spi) { struct wm0010_priv *wm0010 = spi_get_drvdata(spi); - gpio_set_value_cansleep(wm0010->gpio_reset, - wm0010->gpio_reset_value); + gpiod_set_value_cansleep(wm0010->reset, 1); irq_set_irq_wake(wm0010->irq, 0);