From patchwork Fri Aug 25 08:12:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 716897 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 447AFC3DA66 for ; Fri, 25 Aug 2023 08:14:36 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 5960D1E3; Fri, 25 Aug 2023 10:13:44 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5960D1E3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1692951274; bh=ZPOVoWflkn5ze/RL1vfcrWv4KndgatLnq+lpS515m1M=; h=From:Date:Subject:References:In-Reply-To:To:Cc:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=onY12nRVoHiLCFWEr1boywbHJKI3XPq2Ti3h1TcP2Y+uG4Z2tvslpLxrTKjhqW8xD BWeQdotgFfFW83iyq8g3jq4wpQGZzM9fPwdX6242zjGyo5KV2IOdvzH0C22xqimCCI N7ahEO1EmKzU/JeB64N5siOzcEoRzX7GPNPUwHCw= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0E855F8056F; Fri, 25 Aug 2023 10:12:36 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 17EF3F80579; Fri, 25 Aug 2023 10:12:36 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2A61DF8055C; Fri, 25 Aug 2023 10:12:30 +0200 (CEST) Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id AC363F800F5 for ; Fri, 25 Aug 2023 10:12:17 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz AC363F800F5 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=ZXicqbRu Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-5007abb15e9so963760e87.0 for ; Fri, 25 Aug 2023 01:12:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692951135; x=1693555935; 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=NBbRRSYAQA5xmq25ubQ8kHHlKCIWtZeRLr/sb85xuNU=; b=ZXicqbRubMjwCeZSDp32zGvSe2Cg8/FKjVonc3OsBRO2krXO9cvadTN+LEo+huL3zn OIhuzcmuZ3+DNGfyUWUCnuHFZT6ri6Nm07495TVslpIaSQ+NwKVr6zekLYT0PZSblQrs wagBfLfbz5NQpkh7nX06Io3lM54ZJt2f6MhCztCKdKx86JpxnpZlXLGy1+BQ1Im+EdaN AGZG/AsNNs0dYj56gsC/jkl6aRqlgLHWJ1hpp1h+Mfw6U8oU3wtq7mCeGrhqhOULtwHX 1BxTwnLpJ71GxdGgkFs12MOHXaxOu6FTOzDbnJZI20sPRMcQu5+jN9t8fL8hzsj5adyJ pXTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692951135; x=1693555935; 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=NBbRRSYAQA5xmq25ubQ8kHHlKCIWtZeRLr/sb85xuNU=; b=T47fWjilBVdH/VNdKUI9O85Q923sdN1q9e4mUXNoIBFx5usx3PqCB2kL7S1z/keWgd rOLhw6DdI/DjqNGTwDRCJ//6X12oKFcxedM22lGxFVMkJZ/0QuGSfz0cfq0/72Ljl1TZ IxScAwzjCp+JZyeW3XadpKeDX/we0luCKVCASZxk9+bfOFFMAh3Qlz8CHyqJ7jmcIReL iAbGJ111H+gLeIwerGt7y4oIsNgJslLR5WoFrHwuRWE1gZIv91fYeFNMz4+pps0nl3r3 og7yxqxfYu4+Wh24zta+MoHmLZ6EZMtbY/n7+captunA4rz66X3LQTBwQfAiWqKyJC4r Gccg== X-Gm-Message-State: AOJu0YwBiYLT+4YYcenGsnFQcYPB+psNvKc/CVc/9x/+JbekfG80XkPu 4+EZ0IEtq8+eNAlMDbcAr/oGNA== X-Google-Smtp-Source: AGHT+IEPLIDpD1w1RF98YcjynCIXKHZQox8F22rws/cF0RMIh/cKJbjBBRiwjVgcU5sTSiS7K0f0rA== X-Received: by 2002:a05:6512:615:b0:4fd:c923:db59 with SMTP id b21-20020a056512061500b004fdc923db59mr11392637lfe.15.1692951135669; Fri, 25 Aug 2023 01:12:15 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id q28-20020ac2511c000000b004fe1a35fd15sm195559lfb.140.2023.08.25.01.12.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Aug 2023 01:12:15 -0700 (PDT) From: Linus Walleij Date: Fri, 25 Aug 2023 10:12:13 +0200 Subject: [PATCH 3/7] ASoC: max98373: Convert to use GPIO descriptors MIME-Version: 1.0 Message-Id: <20230825-descriptors-asoc-max-v1-3-b212292b2f08@linaro.org> References: <20230825-descriptors-asoc-max-v1-0-b212292b2f08@linaro.org> In-Reply-To: <20230825-descriptors-asoc-max-v1-0-b212292b2f08@linaro.org> To: Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.3 Message-ID-Hash: RTWVNJ5GMUDYOJPMKVV3NEPTTKJTKNY4 X-Message-ID-Hash: RTWVNJ5GMUDYOJPMKVV3NEPTTKJTKNY4 X-MailFrom: linus.walleij@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Instead of relying on legacy interfaces, convert the driver to use GPIO descriptors. This is a straight-forward conversion, we support also sdw devices providing GPIO descriptor tables if they so desire. Signed-off-by: Linus Walleij --- sound/soc/codecs/max98373-i2c.c | 17 ----------------- sound/soc/codecs/max98373.c | 35 +++++++++++++++++++---------------- sound/soc/codecs/max98373.h | 2 +- 3 files changed, 20 insertions(+), 34 deletions(-) diff --git a/sound/soc/codecs/max98373-i2c.c b/sound/soc/codecs/max98373-i2c.c index 0fa5ceca62a2..e7ec7875c4a9 100644 --- a/sound/soc/codecs/max98373-i2c.c +++ b/sound/soc/codecs/max98373-i2c.c @@ -3,12 +3,10 @@ #include #include -#include #include #include #include #include -#include #include #include #include @@ -560,21 +558,6 @@ static int max98373_i2c_probe(struct i2c_client *i2c) /* voltage/current slot & gpio configuration */ max98373_slot_config(&i2c->dev, max98373); - /* Power on device */ - if (gpio_is_valid(max98373->reset_gpio)) { - ret = devm_gpio_request(&i2c->dev, max98373->reset_gpio, - "MAX98373_RESET"); - if (ret) { - dev_err(&i2c->dev, "%s: Failed to request gpio %d\n", - __func__, max98373->reset_gpio); - return -EINVAL; - } - gpio_direction_output(max98373->reset_gpio, 0); - msleep(50); - gpio_direction_output(max98373->reset_gpio, 1); - msleep(20); - } - /* Check Revision ID */ ret = regmap_read(max98373->regmap, MAX98373_R21FF_REV_ID, ®); diff --git a/sound/soc/codecs/max98373.c b/sound/soc/codecs/max98373.c index fde055c6c894..33eb4576da23 100644 --- a/sound/soc/codecs/max98373.c +++ b/sound/soc/codecs/max98373.c @@ -12,9 +12,8 @@ #include #include #include -#include +#include #include -#include #include #include "max98373.h" @@ -478,20 +477,24 @@ void max98373_slot_config(struct device *dev, max98373->i_slot = value & 0xF; else max98373->i_slot = 1; - if (dev->of_node) { - max98373->reset_gpio = of_get_named_gpio(dev->of_node, - "maxim,reset-gpio", 0); - if (!gpio_is_valid(max98373->reset_gpio)) { - dev_err(dev, "Looking up %s property in node %s failed %d\n", - "maxim,reset-gpio", dev->of_node->full_name, - max98373->reset_gpio); - } else { - dev_dbg(dev, "maxim,reset-gpio=%d", - max98373->reset_gpio); - } - } else { - /* this makes reset_gpio as invalid */ - max98373->reset_gpio = -1; + + /* This will assert RESET */ + max98373->reset = devm_gpiod_get_optional(dev, + "maxim,reset", + GPIOD_OUT_HIGH); + if (IS_ERR(max98373->reset)) { + dev_err(dev, "error %ld looking up RESET GPIO line\n", + PTR_ERR(max98373->reset)); + return; + } + + /* Cycle reset */ + if (max98373->reset) { + gpiod_set_consumer_name(max98373->reset ,"MAX98373_RESET"); + gpiod_direction_output(max98373->reset, 1); + msleep(50); + gpiod_direction_output(max98373->reset, 0); + msleep(20); } if (!device_property_read_u32(dev, "maxim,spkfb-slot-no", &value)) diff --git a/sound/soc/codecs/max98373.h b/sound/soc/codecs/max98373.h index e1810b3b1620..af3b62217497 100644 --- a/sound/soc/codecs/max98373.h +++ b/sound/soc/codecs/max98373.h @@ -213,7 +213,7 @@ struct max98373_cache { struct max98373_priv { struct regmap *regmap; - int reset_gpio; + struct gpio_desc *reset; unsigned int v_slot; unsigned int i_slot; unsigned int spkfb_slot;