From patchwork Thu Aug 17 14:03:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 714732 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 E2BA5C2FC14 for ; Thu, 17 Aug 2023 14:04:51 +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 6439E7F1; Thu, 17 Aug 2023 16:03:59 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6439E7F1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1692281089; bh=dQtYn75+hngMqyzVlrrrJuUf2UaY3wY5yVgVym+UEVw=; 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=kgfx1oSFFJcdCzhiHtwaio3ZZ9B8T1MhPVuSmUzmh720x5eYSnN2eKHzGQ19fb8gJ LhaQVuFalZaRNUoJ4443LjgbjRS8o+wEs+eeXmrKSgEUan1YQM71k4jr9zSqpRDs5Z MAUqG1V9UtWzz3mmOb6GmgR4F60SJSiF6y/ZzqPc= Received: by alsa1.perex.cz (Postfix, from userid 50401) id A884AF80536; Thu, 17 Aug 2023 16:03:38 +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 07F05F801EB; Thu, 17 Aug 2023 16:03:38 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1BBEBF80254; Thu, 17 Aug 2023 16:03:34 +0200 (CEST) Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) (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 40AF1F8016A for ; Thu, 17 Aug 2023 16:03:30 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 40AF1F8016A 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=wRf+w2hV Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2b9b904bb04so123719641fa.1 for ; Thu, 17 Aug 2023 07:03:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692281009; x=1692885809; 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=088USFovIsdoCEmzlnqhLgFZBLMNvUbAonAQf/mwAxw=; b=wRf+w2hVofU/IxEx6VHKnhqF/EYCqFXdyuaJFbKv7U3n8gNC3s046jZuHdCtATWzhp 7U+8q70z10E91FBbXknUsa7BIRqpjTQ5hPd1GCS2pGrZlLyL6pz1pl+l0rFTBKED5yEf qNoaBvGX1VuQAEsKhM1euCnfrtZPVGfaXH0VkOCThH8yZk0p8wRgSyxXILk2cE4F/fBV Y0TbdJSMpiRgUQGkZqjNO1mW4Xh94qm3XAFCZ9ivTmkc6a2u74fEHaQmoR7b2S+YklNA k0jO1unCHxZqyc3/6nFonNc8eBLICRKLTzZbKav5rgosKv6v5VHO6y/pxuFFa9sEED1D xJkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692281009; x=1692885809; 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=088USFovIsdoCEmzlnqhLgFZBLMNvUbAonAQf/mwAxw=; b=N8AnEYFfITV6lAgQdmlmKub7kc3lrNOcwj51uomYRrZJvTVxMu8N+85wn/o6iEPuPE pKn0rfo8IZ8iibizITW4O9la7d82EfZXCxg0wCgONLhzbbF5zX0b8+xXCPTznkP2hds0 V2pIf/BFKnRfLNv4yaP3t7A6LQNWZMXVfKCYlm9/QXi6tN796wzD+QnHMdsGaF1gHX7P iLbWLXZqSPozqmyd26cqPkf04TQB98h0LWsixP0YBRXO7pHw2p9P2mSnVB4Ol+e/hhiI hGtyvni2MNiD41+WDmKtz1vp4/uFqirwGRcgymUVFOXqfavnMRZyG0wj/PQSJpuJ04Jc NivQ== X-Gm-Message-State: AOJu0YzWdGzcHX9LoLQCwJyGl3tQi2zdHn+4Hlp5PuNQkzFnDoq3c7Wp 2ks7SwJG04bl9vbte+Z0E5OSSCYTZIeQRqXldow= X-Google-Smtp-Source: AGHT+IG2Pux8VKOdbP86Oj7Mi6rjgF8/0qq8sb4PVwu1oDpFYcRedBksyLzRLMctv2SUuMjfYx1nQw== X-Received: by 2002:a2e:9c99:0:b0:2b6:e618:b593 with SMTP id x25-20020a2e9c99000000b002b6e618b593mr4368277lji.31.1692281009055; Thu, 17 Aug 2023 07:03:29 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id g3-20020a2eb0c3000000b002b9c3e18095sm4064645ljl.14.2023.08.17.07.03.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Aug 2023 07:03:28 -0700 (PDT) From: Linus Walleij Date: Thu, 17 Aug 2023 16:03:17 +0200 Subject: [PATCH v2 1/5] ASoC: rt5640: Convert to just use GPIO descriptors MIME-Version: 1.0 Message-Id: <20230817-descriptors-asoc-rt-v2-1-02fa2ca3e5b0@linaro.org> References: <20230817-descriptors-asoc-rt-v2-0-02fa2ca3e5b0@linaro.org> In-Reply-To: <20230817-descriptors-asoc-rt-v2-0-02fa2ca3e5b0@linaro.org> To: Oder Chiou , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.3 Message-ID-Hash: YASMSPGU5FENHR5UYOXQSIMNKVDUADEL X-Message-ID-Hash: YASMSPGU5FENHR5UYOXQSIMNKVDUADEL 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: The RT5640 driver is already using GPIO descriptors for some stuff, all that is needed is to convert the remaining LDO1 control line to also use descriptors. Simplify the code using gpiod_get_optional() and drop the special "of" parsing function: these descriptors need not come from device tree and it's optional so hey. Keep some NULL checks around the GPIO operations even though gpiolib is essentially NULL-tolerant, because by checking for whether we have a valid GPIO descriptor or not we can avoid a 400 ms delay which is great. Signed-off-by: Linus Walleij --- sound/soc/codecs/rt5640.c | 55 +++++++++++++---------------------------------- sound/soc/codecs/rt5640.h | 2 +- 2 files changed, 16 insertions(+), 41 deletions(-) diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index eceed8209787..8920726c38e8 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -12,11 +12,10 @@ #include #include #include -#include +#include #include #include #include -#include #include #include #include @@ -2812,8 +2811,8 @@ static int rt5640_suspend(struct snd_soc_component *component) rt5640_reset(component); regcache_cache_only(rt5640->regmap, true); regcache_mark_dirty(rt5640->regmap); - if (gpio_is_valid(rt5640->ldo1_en)) - gpio_set_value_cansleep(rt5640->ldo1_en, 0); + if (rt5640->ldo1_en) + gpiod_set_value_cansleep(rt5640->ldo1_en, 0); return 0; } @@ -2822,8 +2821,8 @@ static int rt5640_resume(struct snd_soc_component *component) { struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); - if (gpio_is_valid(rt5640->ldo1_en)) { - gpio_set_value_cansleep(rt5640->ldo1_en, 1); + if (rt5640->ldo1_en) { + gpiod_set_value_cansleep(rt5640->ldo1_en, 1); msleep(400); } @@ -2986,22 +2985,6 @@ static const struct acpi_device_id rt5640_acpi_match[] = { MODULE_DEVICE_TABLE(acpi, rt5640_acpi_match); #endif -static int rt5640_parse_dt(struct rt5640_priv *rt5640, struct device_node *np) -{ - rt5640->ldo1_en = of_get_named_gpio(np, "realtek,ldo1-en-gpios", 0); - /* - * LDO1_EN is optional (it may be statically tied on the board). - * -ENOENT means that the property doesn't exist, i.e. there is no - * GPIO, so is not an error. Any other error code means the property - * exists, but could not be parsed. - */ - if (!gpio_is_valid(rt5640->ldo1_en) && - (rt5640->ldo1_en != -ENOENT)) - return rt5640->ldo1_en; - - return 0; -} - static int rt5640_i2c_probe(struct i2c_client *i2c) { struct rt5640_priv *rt5640; @@ -3015,12 +2998,16 @@ static int rt5640_i2c_probe(struct i2c_client *i2c) return -ENOMEM; i2c_set_clientdata(i2c, rt5640); - if (i2c->dev.of_node) { - ret = rt5640_parse_dt(rt5640, i2c->dev.of_node); - if (ret) - return ret; - } else - rt5640->ldo1_en = -EINVAL; + rt5640->ldo1_en = devm_gpiod_get_optional(&i2c->dev, + "realtek,ldo1-en", + GPIOD_OUT_HIGH); + if (IS_ERR(rt5640->ldo1_en)) + return PTR_ERR(rt5640->ldo1_en); + + if (rt5640->ldo1_en) { + gpiod_set_consumer_name(rt5640->ldo1_en, "RT5640 LDO1_EN"); + msleep(400); + } rt5640->regmap = devm_regmap_init_i2c(i2c, &rt5640_regmap); if (IS_ERR(rt5640->regmap)) { @@ -3030,18 +3017,6 @@ static int rt5640_i2c_probe(struct i2c_client *i2c) return ret; } - if (gpio_is_valid(rt5640->ldo1_en)) { - ret = devm_gpio_request_one(&i2c->dev, rt5640->ldo1_en, - GPIOF_OUT_INIT_HIGH, - "RT5640 LDO1_EN"); - if (ret < 0) { - dev_err(&i2c->dev, "Failed to request LDO1_EN %d: %d\n", - rt5640->ldo1_en, ret); - return ret; - } - msleep(400); - } - regmap_read(rt5640->regmap, RT5640_VENDOR_ID2, &val); if (val != RT5640_DEVICE_ID) { dev_err(&i2c->dev, diff --git a/sound/soc/codecs/rt5640.h b/sound/soc/codecs/rt5640.h index 9847a1ae01f4..94b9a502f7f9 100644 --- a/sound/soc/codecs/rt5640.h +++ b/sound/soc/codecs/rt5640.h @@ -2138,7 +2138,7 @@ struct rt5640_priv { struct regmap *regmap; struct clk *mclk; - int ldo1_en; /* GPIO for LDO1_EN */ + struct gpio_desc *ldo1_en; /* GPIO for LDO1_EN */ int irq; int jd_gpio_irq; int sysclk; From patchwork Thu Aug 17 14:03:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 714391 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 C1872C2FC14 for ; Thu, 17 Aug 2023 14:05:22 +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 6B0C283A; Thu, 17 Aug 2023 16:04:30 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6B0C283A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1692281120; bh=ExejP8upjmkoti3vwoPjI3X3ePNai2/qpEyeHxxipOk=; 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=GTuhp2OYnLmcHeWRkc4oB+ogejGvPVB1D9j777VJSR6CiLp9qJmkYiMG3MJg5LOxC ldh0WjF3U5f6G2bfUzz46Cr27enfgg07zagR+XC8FQgnwFAAbwqSUgLb23XH45iOxv yHbAYS0sOvNSDha/z36h5EiPnNzZ2NzhQKVEdKMw= Received: by alsa1.perex.cz (Postfix, from userid 50401) id C89B9F80563; Thu, 17 Aug 2023 16:03:41 +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 F17A9F80510; Thu, 17 Aug 2023 16:03:40 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id DDBCDF801EB; Thu, 17 Aug 2023 16:03:34 +0200 (CEST) Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) (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 619FAF8016D for ; Thu, 17 Aug 2023 16:03:32 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 619FAF8016D 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=WE5RtX3/ Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2b9aa1d3029so120073291fa.2 for ; Thu, 17 Aug 2023 07:03:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692281010; x=1692885810; 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=LIqqw/pMNM0WFKKC3NTiQx16fR5msgynp0J7IYgi66w=; b=WE5RtX3/0+0Xk6bnPsgBDBpqvXpMfBzdYTsh3Bjwjj6YyvPHQn9hJjjsmYj9jOE0qF 83dUbq/m4f+LQ8lBdDSPoSS7q/2npkuEtBFwewViWCnZqya7+PBQXmfKmORq9eG2vMYA XWHJmWc1u3KH4/rhE0KIB0lTF0igbfpxY8WtdeWqk0EOUXUqq9iRGDNdLhmTa85+01yY 1ToIHq5D38PhIk+yB0cZRUZyuIX47QqBn0N6LN+Zc1iKn18NQKk24UXHPt5IV1CzAAkS J+FIurca9rOd1aAfOU/0Hm0NvtinD+sSSoiWrtv+lQIFywTFYxzXGzZoVG3oIyJxjk7Q hepA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692281010; x=1692885810; 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=LIqqw/pMNM0WFKKC3NTiQx16fR5msgynp0J7IYgi66w=; b=DscRTs5aR3leE5AiwVDFj36y00majLhEJ0UpBbqET/Pf9HDPBYELISSvnQxniH2NdY hkU93N7XSn63q/OlK8szLK4JOt/F4UxqnpCMnd+7Ln2qLB/GVid2GA//Vb7ANxuTaPhI +UTCJTOdHcpc/yDczdb7hbsA0fkY4+TLUKRQu7Ok/JRHEXZpkR91VWKpZLGYLWrvrrxu viiYwCcfBz8WZkAI9AxvRl5hSk2mBGqEqpgBk/bTLnlYDvlYPiKL1zuTJ7Ggc4easTvq BmXQBPManxg3jiRmbpy8H3QEeAqt5nhjPFiOcn9fdruwxNYTC8HTG6NDUUsDPjqKU0XF nRyw== X-Gm-Message-State: AOJu0YwYi7mR+93yRtPDAUKo0iyXMhfafYpjkyeYWmIvHXUbsuCdvfRQ 961MbivRJ26JvtR/2OyX30OT3qkVCEOi7xivD5k= X-Google-Smtp-Source: AGHT+IFZD78S4HIGKyf6Rs6uW1DQcdJj3K6+vF1CKagH2d7CwoX5ilTAehbT7IjXL7l2L4AU5JpJFg== X-Received: by 2002:a2e:9b0d:0:b0:2b9:ba02:436c with SMTP id u13-20020a2e9b0d000000b002b9ba02436cmr4407547lji.28.1692281010067; Thu, 17 Aug 2023 07:03:30 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id g3-20020a2eb0c3000000b002b9c3e18095sm4064645ljl.14.2023.08.17.07.03.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Aug 2023 07:03:29 -0700 (PDT) From: Linus Walleij Date: Thu, 17 Aug 2023 16:03:18 +0200 Subject: [PATCH v2 2/5] ASoC: rt5665: Convert to use GPIO descriptors MIME-Version: 1.0 Message-Id: <20230817-descriptors-asoc-rt-v2-2-02fa2ca3e5b0@linaro.org> References: <20230817-descriptors-asoc-rt-v2-0-02fa2ca3e5b0@linaro.org> In-Reply-To: <20230817-descriptors-asoc-rt-v2-0-02fa2ca3e5b0@linaro.org> To: Oder Chiou , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.3 Message-ID-Hash: 23R65A5DDU7TKL2WKSFFSHXRC6EGEQZR X-Message-ID-Hash: 23R65A5DDU7TKL2WKSFFSHXRC6EGEQZR 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: The RT5665 driver has some stub support for GPIO descriptors going back to the initial driver commit, where there are two GPIO descriptors for the LDO and headphone detection defined in the device state. Well, let's make use of the descriptor properly. We remove the global GPIO number from the platform data, but it is still possible to create board files using GPIO descriptor tables, if desired. Signed-off-by: Linus Walleij --- include/sound/rt5665.h | 2 -- sound/soc/codecs/rt5665.c | 17 ++++++++--------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/include/sound/rt5665.h b/include/sound/rt5665.h index 3b3d6a19ca49..e865f041929b 100644 --- a/include/sound/rt5665.h +++ b/include/sound/rt5665.h @@ -31,8 +31,6 @@ struct rt5665_platform_data { bool in3_diff; bool in4_diff; - int ldo1_en; /* GPIO for LDO1_EN */ - enum rt5665_dmic1_data_pin dmic1_data_pin; enum rt5665_dmic2_data_pin dmic2_data_pin; enum rt5665_jd_src jd_src; diff --git a/sound/soc/codecs/rt5665.c b/sound/soc/codecs/rt5665.c index 525713c33d71..a39de4a7df00 100644 --- a/sound/soc/codecs/rt5665.c +++ b/sound/soc/codecs/rt5665.c @@ -15,8 +15,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -4659,9 +4658,6 @@ static int rt5665_parse_dt(struct rt5665_priv *rt5665, struct device *dev) of_property_read_u32(dev->of_node, "realtek,jd-src", &rt5665->pdata.jd_src); - rt5665->pdata.ldo1_en = of_get_named_gpio(dev->of_node, - "realtek,ldo1-en-gpios", 0); - return 0; } @@ -4795,10 +4791,13 @@ static int rt5665_i2c_probe(struct i2c_client *i2c) return ret; } - if (gpio_is_valid(rt5665->pdata.ldo1_en)) { - if (devm_gpio_request_one(&i2c->dev, rt5665->pdata.ldo1_en, - GPIOF_OUT_INIT_HIGH, "rt5665")) - dev_err(&i2c->dev, "Fail gpio_request gpio_ldo\n"); + + rt5665->gpiod_ldo1_en = devm_gpiod_get_optional(&i2c->dev, + "realtek,ldo1-en", + GPIOD_OUT_HIGH); + if (IS_ERR(rt5665->gpiod_ldo1_en)) { + dev_err(&i2c->dev, "Failed gpio request ldo1_en\n"); + return PTR_ERR(rt5665->gpiod_ldo1_en); } /* Sleep for 300 ms miniumum */ From patchwork Thu Aug 17 14:03:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 714731 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 4C130C2FC2F for ; Thu, 17 Aug 2023 14:05:39 +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 A2F5084B; Thu, 17 Aug 2023 16:04:46 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A2F5084B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1692281136; bh=6QgTH2VX6miZibcN7DpNPP98RLqAHERJ7G8xczIzQBk=; 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=KFJbFGr7cICLoWkg4zCdy5mQt9SDtYKWHWqyHFFB81wQ3YCGm8fmTDfLK4n1NvKOL uWbeeZFN3EBFfSSH8hAx3lZG5f+l51icCp9d9nSeVWv2kJmSGkDCLggpg0vq4M0wTf 7VVHCmr/diyVHYs9Y026+g1doCEjccx6z/l6khV4= Received: by alsa1.perex.cz (Postfix, from userid 50401) id B4BA8F80578; Thu, 17 Aug 2023 16:03:44 +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 22801F80510; Thu, 17 Aug 2023 16:03:44 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 34D22F80254; Thu, 17 Aug 2023 16:03:36 +0200 (CEST) Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) (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 23997F80027 for ; Thu, 17 Aug 2023 16:03:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 23997F80027 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=EAXiuKU/ Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2b9b904bb04so123720301fa.1 for ; Thu, 17 Aug 2023 07:03:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692281011; x=1692885811; 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=e8CZiR3Xu/7M/67rXheXq6UmPj0XpjwcOmaMWEgamKE=; b=EAXiuKU/5jqRfsfD8D636xmi7FYERS+6fk1Az+reX11zn/mygBydlX7V08cOLeGLJ8 KQrTdrmNrVk/dSjblX9mAcIVxYtM8/pARJnzo4bK/ftUgLMUQWxA5pn6Le806J1V9k5O 2xORBl2Ap5Z80wAKyEq+09suIGM5x/1knxYsUKmQAiTodnsGUqScoUHc4QWuvlfERPhw 1h3LC7GG5wyW/c0ZvUE/HuB+s2VvSEDPGLQSL7wUfcjCErvKIybqYI6TqKIrRxcBdIkr 79KKetuUbh/Aom3rbXE05v7jvmB780m4opR/BVMXk8Av/97i5szMWdfxUqFjQVGjqXEN TWTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692281011; x=1692885811; 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=e8CZiR3Xu/7M/67rXheXq6UmPj0XpjwcOmaMWEgamKE=; b=kjXlKEZJXbkCrP9WWtBq9LICRjshIsO84TZ6pjZTzJ7wRYrCnRABLtzMfI4lo2p0b1 8Q7ChiR9dlugm6++cKMm9llNpMbrT/ltq/OpdVYQ4AYpt8VKqVYueP2QW+5TN+It2w+9 O0+ziPQ5Ly5NrmsnGz5AgR93yG5UMJM8rllS0I9LDpw/P02LOthZ5OJNZyDkc8nSP9B0 L7Z7zf47h/IgOgMJ2lcjDvE1ojn9exi1dw9fhPimi01Xbcf+YEnSZSj9tlQGgy4jgcB7 mP7jxR3PVdxs5EL1c2p73M+hhPRTjPJla75eE8vOZTNsoYRzbqTraahMZIYMsDUINJwB WdHg== X-Gm-Message-State: AOJu0Yxsv4gXVX+AWbNaGLwZ6ccUxRpjG8x0z2GwD+6jDeN6pRXByk7N OcQwWuPLEODsz3o1S2lOjy7SSWtPGtFoEpcTgB4= X-Google-Smtp-Source: AGHT+IH4gg/vR6q4py/1tlJcmjg2VOr2qGwSY69we4f+NfmGIjQ5OxOfgwbAria/spCBKz9bUzEXPA== X-Received: by 2002:a2e:800c:0:b0:2bb:997a:493e with SMTP id j12-20020a2e800c000000b002bb997a493emr3549301ljg.35.1692281010969; Thu, 17 Aug 2023 07:03:30 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id g3-20020a2eb0c3000000b002b9c3e18095sm4064645ljl.14.2023.08.17.07.03.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Aug 2023 07:03:30 -0700 (PDT) From: Linus Walleij Date: Thu, 17 Aug 2023 16:03:19 +0200 Subject: [PATCH v2 3/5] ASoC: rt5668: Convert to use GPIO descriptors MIME-Version: 1.0 Message-Id: <20230817-descriptors-asoc-rt-v2-3-02fa2ca3e5b0@linaro.org> References: <20230817-descriptors-asoc-rt-v2-0-02fa2ca3e5b0@linaro.org> In-Reply-To: <20230817-descriptors-asoc-rt-v2-0-02fa2ca3e5b0@linaro.org> To: Oder Chiou , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.3 Message-ID-Hash: HWK22VRSZ7K77QUGZH5WCJBIJ7DM2Q6H X-Message-ID-Hash: HWK22VRSZ7K77QUGZH5WCJBIJ7DM2Q6H 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: Convert the RT5668 to use GPIO descriptors and drop the legacy GPIO headers. We remove the global GPIO number from the platform data, but it is still possible to create board files using GPIO descriptor tables, if desired. Signed-off-by: Linus Walleij --- include/sound/rt5668.h | 3 --- sound/soc/codecs/rt5668.c | 17 ++++++++--------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/include/sound/rt5668.h b/include/sound/rt5668.h index 182edfbc9e7a..b682418c6cd6 100644 --- a/include/sound/rt5668.h +++ b/include/sound/rt5668.h @@ -25,9 +25,6 @@ enum rt5668_jd_src { }; struct rt5668_platform_data { - - int ldo1_en; /* GPIO for LDO1_EN */ - enum rt5668_dmic1_data_pin dmic1_data_pin; enum rt5668_dmic1_clk_pin dmic1_clk_pin; enum rt5668_jd_src jd_src; diff --git a/sound/soc/codecs/rt5668.c b/sound/soc/codecs/rt5668.c index f04c810fd710..4623b3e62487 100644 --- a/sound/soc/codecs/rt5668.c +++ b/sound/soc/codecs/rt5668.c @@ -15,8 +15,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -43,6 +42,7 @@ static const char *rt5668_supply_names[RT5668_NUM_SUPPLIES] = { struct rt5668_priv { struct snd_soc_component *component; struct rt5668_platform_data pdata; + struct gpio_desc *ldo1_en; struct regmap *regmap; struct snd_soc_jack *hs_jack; struct regulator_bulk_data supplies[RT5668_NUM_SUPPLIES]; @@ -2393,9 +2393,6 @@ static int rt5668_parse_dt(struct rt5668_priv *rt5668, struct device *dev) of_property_read_u32(dev->of_node, "realtek,jd-src", &rt5668->pdata.jd_src); - rt5668->pdata.ldo1_en = of_get_named_gpio(dev->of_node, - "realtek,ldo1-en-gpios", 0); - return 0; } @@ -2497,10 +2494,12 @@ static int rt5668_i2c_probe(struct i2c_client *i2c) return ret; } - if (gpio_is_valid(rt5668->pdata.ldo1_en)) { - if (devm_gpio_request_one(&i2c->dev, rt5668->pdata.ldo1_en, - GPIOF_OUT_INIT_HIGH, "rt5668")) - dev_err(&i2c->dev, "Fail gpio_request gpio_ldo\n"); + rt5668->ldo1_en = devm_gpiod_get_optional(&i2c->dev, + "realtek,ldo1-en", + GPIOD_OUT_HIGH); + if (IS_ERR(rt5668->ldo1_en)) { + dev_err(&i2c->dev, "Fail gpio request ldo1_en\n"); + return PTR_ERR(rt5668->ldo1_en); } /* Sleep for 300 ms miniumum */ From patchwork Thu Aug 17 14:03:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 714389 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 7A3D5C2FC14 for ; Thu, 17 Aug 2023 14:06:27 +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 E0B82828; Thu, 17 Aug 2023 16:05:34 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E0B82828 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1692281185; bh=VclR2Ui/l0qdH/5ar0Z66+iyvxtEuM2+V9yzCgllXgs=; 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=c9Xq+VItdGPyo8ldDAfsem8JZckh21btgCNx5ikVm+Fy1jJhfcl5oDI3LasP7SbsX 30uv30CeU8AOP8Mv5pDtJbF135izpizNcbl6/Jy5WpegGoeolBggdNdMHmQCFE9i2z eSQwdWHpGFtoYD04VPyM7nLj22K0C5BN3RHU5xUs= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5B53AF805BB; Thu, 17 Aug 2023 16:03:54 +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 B9642F805A1; Thu, 17 Aug 2023 16:03:53 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E106EF80567; Thu, 17 Aug 2023 16:03:44 +0200 (CEST) Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) (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 6BB26F8016A for ; Thu, 17 Aug 2023 16:03:34 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6BB26F8016A 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=TV6FCMvT Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2b95d5ee18dso117342081fa.1 for ; Thu, 17 Aug 2023 07:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692281012; x=1692885812; 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=s8QnfXt14InmPur1jaC24sUVlinocDE8jpHSEWJ37+o=; b=TV6FCMvT/LoEqFsobincahfEyqStn0Fuyfn5b5hYbFZazgJ1W6IM9va0mjfgxXgRNM KFxVwj1TawdUco9eenFuTdc2QsFvm8H8JJjb8LAsrNemqAoRN/LTz/ArVsDkBPQouV5V dAjD1U6CLmgytPQuCwo11QMnTcdMgL6wke6WtIJf98Zw1iFq8MsdiwVLVX87SjChjsyl oURNiZrNDyXKkU2oeYC5S+RLAr/IexciJQah2Wib9DJyoqsrlxjWyy3SjIWQrJTptdQf jSNJe8GZ94Mmcm2lzrWmnyxkpKFclCsKozrp7v6ngM5I/GK6ySpZyupxAz3iTGCe7ub9 fMoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692281012; x=1692885812; 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=s8QnfXt14InmPur1jaC24sUVlinocDE8jpHSEWJ37+o=; b=NQL870uECTT2udlhuaJ7IFquBakQ8lytV487Z/2BQOrUHRugvU1vHkhPYHt2Msm7el pZI2a5yjccWxqT3LAJ9RHBtjq6s+FVS6xHGHw1ulkexyya6dCDACdjE8ola31CG8hCJ+ +931OANNiR3pCO2frkB1lJg+0TUgVkaka5svuApk5DyFkg4VQ629EZa1mae3wXrn2Ui9 uknCVLYBgoAkn0SBSthUbTwp3ad/vcQHoJvjuub+luLkpV9upsfFrzh0195Y5GrnF3v1 fOQDIhWL7oN2Cmimi9TgdYkKwumA5YK3AndvgTGTi4Qg7d5j041PPES8/LtggO6TWmKK N1DA== X-Gm-Message-State: AOJu0YwStvIuRJ5op31uxi1AQsjOTK27w+SNHyTLZPKJNNM9+cMss4Gc RhvzLXCTzMc0Is7eOzsG0/1K+gLQWumcV3q/HPs= X-Google-Smtp-Source: AGHT+IF5riaWQT2nv6OvAWzXDDhE1Yh2ZeIyZUsJE/SAjXNz/hCQGKh0HlxKGTYoYC1yTHp2FVoyGg== X-Received: by 2002:a2e:8012:0:b0:2b9:df49:b818 with SMTP id j18-20020a2e8012000000b002b9df49b818mr4043578ljg.53.1692281012072; Thu, 17 Aug 2023 07:03:32 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id g3-20020a2eb0c3000000b002b9c3e18095sm4064645ljl.14.2023.08.17.07.03.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Aug 2023 07:03:31 -0700 (PDT) From: Linus Walleij Date: Thu, 17 Aug 2023 16:03:20 +0200 Subject: [PATCH v2 4/5] ASoC: rt5682: Convert to use GPIO descriptors MIME-Version: 1.0 Message-Id: <20230817-descriptors-asoc-rt-v2-4-02fa2ca3e5b0@linaro.org> References: <20230817-descriptors-asoc-rt-v2-0-02fa2ca3e5b0@linaro.org> In-Reply-To: <20230817-descriptors-asoc-rt-v2-0-02fa2ca3e5b0@linaro.org> To: Oder Chiou , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.3 Message-ID-Hash: 4SKJESOBU6256DYKFIYOX7ZIRXTOV4TK X-Message-ID-Hash: 4SKJESOBU6256DYKFIYOX7ZIRXTOV4TK 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: Convert the RT5682 to use GPIO descriptors and drop the legacy GPIO headers. We remove the global GPIO number from the platform data, but it is still possible to create board files using GPIO descriptor tables, if desired. Make sure to make sure SDW devices can associate with an LDO1 EN descriptor too, if they so desire by putting the lookup into the common code. Signed-off-by: Linus Walleij --- include/sound/rt5682.h | 3 --- sound/soc/codecs/rt5682-i2c.c | 11 ++++------- sound/soc/codecs/rt5682-sdw.c | 5 +++++ sound/soc/codecs/rt5682.c | 20 +++++++++++++++----- sound/soc/codecs/rt5682.h | 3 +++ 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/include/sound/rt5682.h b/include/sound/rt5682.h index 3900a07e3935..4256df721e3a 100644 --- a/include/sound/rt5682.h +++ b/include/sound/rt5682.h @@ -31,9 +31,6 @@ enum rt5682_dai_clks { }; struct rt5682_platform_data { - - int ldo1_en; /* GPIO for LDO1_EN */ - enum rt5682_dmic1_data_pin dmic1_data_pin; enum rt5682_dmic1_clk_pin dmic1_clk_pin; enum rt5682_jd_src jd_src; diff --git a/sound/soc/codecs/rt5682-i2c.c b/sound/soc/codecs/rt5682-i2c.c index fb8ffb5b2ff6..b05b4f73d8aa 100644 --- a/sound/soc/codecs/rt5682-i2c.c +++ b/sound/soc/codecs/rt5682-i2c.c @@ -15,8 +15,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -170,11 +169,9 @@ static int rt5682_i2c_probe(struct i2c_client *i2c) return ret; } - if (gpio_is_valid(rt5682->pdata.ldo1_en)) { - if (devm_gpio_request_one(&i2c->dev, rt5682->pdata.ldo1_en, - GPIOF_OUT_INIT_HIGH, "rt5682")) - dev_err(&i2c->dev, "Fail gpio_request gpio_ldo\n"); - } + ret = rt5682_get_ldo1(rt5682, &i2c->dev); + if (ret) + return ret; /* Sleep for 300 ms miniumum */ usleep_range(300000, 350000); diff --git a/sound/soc/codecs/rt5682-sdw.c b/sound/soc/codecs/rt5682-sdw.c index 65e9c6dc1a54..e67c2e19cb1a 100644 --- a/sound/soc/codecs/rt5682-sdw.c +++ b/sound/soc/codecs/rt5682-sdw.c @@ -320,6 +320,11 @@ static int rt5682_sdw_init(struct device *dev, struct regmap *regmap, return ret; } + + ret = rt5682_get_ldo1(rt5682, dev); + if (ret) + return ret; + regcache_cache_only(rt5682->sdw_regmap, true); regcache_cache_only(rt5682->regmap, true); diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c index 694c581070d9..e3aca9c785a0 100644 --- a/sound/soc/codecs/rt5682.c +++ b/sound/soc/codecs/rt5682.c @@ -15,8 +15,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -3094,9 +3093,6 @@ int rt5682_parse_dt(struct rt5682_priv *rt5682, struct device *dev) device_property_read_u32(dev, "realtek,dmic-delay-ms", &rt5682->pdata.dmic_delay); - rt5682->pdata.ldo1_en = of_get_named_gpio(dev->of_node, - "realtek,ldo1-en-gpios", 0); - if (device_property_read_string_array(dev, "clock-output-names", rt5682->pdata.dai_clk_names, RT5682_DAI_NUM_CLKS) < 0) @@ -3111,6 +3107,20 @@ int rt5682_parse_dt(struct rt5682_priv *rt5682, struct device *dev) } EXPORT_SYMBOL_GPL(rt5682_parse_dt); +int rt5682_get_ldo1(struct rt5682_priv *rt5682, struct device *dev) +{ + rt5682->ldo1_en = devm_gpiod_get_optional(dev, + "realtek,ldo1-en", + GPIOD_OUT_HIGH); + if (IS_ERR(rt5682->ldo1_en)) { + dev_err(dev, "Fail gpio request ldo1_en\n"); + return PTR_ERR(rt5682->ldo1_en); + } + + return 0; +} +EXPORT_SYMBOL_GPL(rt5682_get_ldo1); + void rt5682_calibrate(struct rt5682_priv *rt5682) { int value, count; diff --git a/sound/soc/codecs/rt5682.h b/sound/soc/codecs/rt5682.h index 1a43d595f341..b2d9e87af259 100644 --- a/sound/soc/codecs/rt5682.h +++ b/sound/soc/codecs/rt5682.h @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -1430,6 +1431,7 @@ struct rt5682_priv { struct snd_soc_component *component; struct device *i2c_dev; struct rt5682_platform_data pdata; + struct gpio_desc *ldo1_en; struct regmap *regmap; struct regmap *sdw_regmap; struct snd_soc_jack *hs_jack; @@ -1481,6 +1483,7 @@ int rt5682_register_component(struct device *dev); void rt5682_calibrate(struct rt5682_priv *rt5682); void rt5682_reset(struct rt5682_priv *rt5682); int rt5682_parse_dt(struct rt5682_priv *rt5682, struct device *dev); +int rt5682_get_ldo1(struct rt5682_priv *rt5682, struct device *dev); int rt5682_register_dai_clks(struct rt5682_priv *rt5682); From patchwork Thu Aug 17 14:03:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 714730 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 27339C2FC2F for ; Thu, 17 Aug 2023 14:06:02 +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 6FD3F20C; Thu, 17 Aug 2023 16:05:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6FD3F20C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1692281160; bh=Jza/ELDogTFotgdVJ3d1o1QRv4u31rd3UN8F6vjm3tk=; 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=KknFs+GjLfjYtnA0QgXEmgcbFGLHQCKm8litlB3X2Sg6gtjRyoV/dcZ7fpa296EtF KkfDDGW2P5bXiZhKenobpX66+gN6nSIiYtjT8bRvr8H0R3TsQSubS6nwZtRjACilkI /orCDu9jn/AGeE97cmIFqAyy0DrtJim65cceZpwE= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0AC96F805AB; Thu, 17 Aug 2023 16:03:52 +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 AEA37F8059F; Thu, 17 Aug 2023 16:03:51 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id CF7AEF80510; Thu, 17 Aug 2023 16:03:39 +0200 (CEST) Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) (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 BB8BEF8016D for ; Thu, 17 Aug 2023 16:03:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz BB8BEF8016D 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=oioclo5J Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2b9fa64db41so119412441fa.1 for ; Thu, 17 Aug 2023 07:03:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692281013; x=1692885813; 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=SVRGKrIqK8zdIPLjLE/8ZwUbdMywu2KHkrv9/v0NkSo=; b=oioclo5JM2Z8IQ//cUwFPPQ37qFbQD2VKB4e+vIUFHeDvjfiQwtwWq+AOjZ/raQCf+ z354ZE7/AFnzPICOq6EWUTqvVSc6x2yVVauyV5h+XVXEkvKAosCUJMnksLP6EvPm3xn3 NxZ9q1HxjiEYesrw416DCagvdKhMBPua+iPIithASgflIyKuKgq5mMa4uu+Xsy8R+tHT sboGbYN+DOvBat7iQn8q2qNXzFJJ/dGa4bbWMj1NjGI1XOomH0nynE+a0ROaJskQTA1H NyMWbIgVPJNAFEETbzoFRERS4Oc2pWUsRY3JTQ6Zhs0zW2c4xz+GC8xxejNuZhlfRGdK ZSTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692281013; x=1692885813; 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=SVRGKrIqK8zdIPLjLE/8ZwUbdMywu2KHkrv9/v0NkSo=; b=kzXtdfZtw9RGNseK9Mr32WOmy3euIw6K4GyIuk+OKSC6gsHCzySYt1QcjiQoOiuK1a X1mcZVVM8vxqAIwdLIoMpa3sTtZHGA5/4Im66FyX4hXep0tg9Uf5fJ5TesATwQaql5dZ AtplkMeMX4skPNNDyxiimrXffZu2O+f09GPo9w27T9RY/qXJDGpOIireLvmov4koMc8m ucF+2C3c6xjg7I+aHxKE4V2rG8wZTI/+jIDT0i9Yf/p3MvBpBidB1tSmbbumAd0S2pU6 bAwyd5PuWUZjhGIvxwZXyVT6Xi15GVG+584MApeH/dkmQKKHLE2pRx4+xTyZoGhAcQl8 dumA== X-Gm-Message-State: AOJu0Ywdi4Wk2ez5sxdsw97tf3NP6WR4S4VLZT/dB4EaMxpW/dih3CFG 3HrelCfSgynoztKi/19JmhDppE/OKLGyOerHNuw= X-Google-Smtp-Source: AGHT+IHt8slVZzlqM+67wFP56al0ESEwXNkqY3msrUtb07eUTGraVFPwWUsEKyiz1+fXP8sgs7X0hg== X-Received: by 2002:a05:651c:203:b0:2b9:575e:5298 with SMTP id y3-20020a05651c020300b002b9575e5298mr4236590ljn.13.1692281013057; Thu, 17 Aug 2023 07:03:33 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id g3-20020a2eb0c3000000b002b9c3e18095sm4064645ljl.14.2023.08.17.07.03.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Aug 2023 07:03:32 -0700 (PDT) From: Linus Walleij Date: Thu, 17 Aug 2023 16:03:21 +0200 Subject: [PATCH v2 5/5] ASoC: rt5682s: Convert to use GPIO descriptors MIME-Version: 1.0 Message-Id: <20230817-descriptors-asoc-rt-v2-5-02fa2ca3e5b0@linaro.org> References: <20230817-descriptors-asoc-rt-v2-0-02fa2ca3e5b0@linaro.org> In-Reply-To: <20230817-descriptors-asoc-rt-v2-0-02fa2ca3e5b0@linaro.org> To: Oder Chiou , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.3 Message-ID-Hash: PTEIFYICCTBLK27TJLPVQD6XDIDAIHUU X-Message-ID-Hash: PTEIFYICCTBLK27TJLPVQD6XDIDAIHUU 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: Convert the RT5682S to use GPIO descriptors and drop the legacy GPIO headers. We remove the global GPIO number from the platform data, but it is still possible to create board files using GPIO descriptor tables, if desired. Signed-off-by: Linus Walleij --- include/sound/rt5682s.h | 3 --- sound/soc/codecs/rt5682s.c | 16 +++++++--------- sound/soc/codecs/rt5682s.h | 2 ++ 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/include/sound/rt5682s.h b/include/sound/rt5682s.h index f18d91308b9a..66ca0c75b914 100644 --- a/include/sound/rt5682s.h +++ b/include/sound/rt5682s.h @@ -32,9 +32,6 @@ enum rt5682s_dai_clks { }; struct rt5682s_platform_data { - - int ldo1_en; /* GPIO for LDO1_EN */ - enum rt5682s_dmic1_data_pin dmic1_data_pin; enum rt5682s_dmic1_clk_pin dmic1_clk_pin; enum rt5682s_jd_src jd_src; diff --git a/sound/soc/codecs/rt5682s.c b/sound/soc/codecs/rt5682s.c index c77c675bd5f5..68ac5ea50396 100644 --- a/sound/soc/codecs/rt5682s.c +++ b/sound/soc/codecs/rt5682s.c @@ -15,8 +15,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -2973,9 +2972,6 @@ static int rt5682s_parse_dt(struct rt5682s_priv *rt5682s, struct device *dev) device_property_read_u32(dev, "realtek,amic-delay-ms", &rt5682s->pdata.amic_delay); - rt5682s->pdata.ldo1_en = of_get_named_gpio(dev->of_node, - "realtek,ldo1-en-gpios", 0); - if (device_property_read_string_array(dev, "clock-output-names", rt5682s->pdata.dai_clk_names, RT5682S_DAI_NUM_CLKS) < 0) @@ -3172,10 +3168,12 @@ static int rt5682s_i2c_probe(struct i2c_client *i2c) return ret; } - if (gpio_is_valid(rt5682s->pdata.ldo1_en)) { - if (devm_gpio_request_one(&i2c->dev, rt5682s->pdata.ldo1_en, - GPIOF_OUT_INIT_HIGH, "rt5682s")) - dev_err(&i2c->dev, "Fail gpio_request gpio_ldo\n"); + rt5682s->ldo1_en = devm_gpiod_get_optional(&i2c->dev, + "realtek,ldo1-en", + GPIOD_OUT_HIGH); + if (IS_ERR(rt5682s->ldo1_en)) { + dev_err(&i2c->dev, "Fail gpio request ldo1_en\n"); + return PTR_ERR(rt5682s->ldo1_en); } /* Sleep for 50 ms minimum */ diff --git a/sound/soc/codecs/rt5682s.h b/sound/soc/codecs/rt5682s.h index caa7733b430f..1d79d432d0d8 100644 --- a/sound/soc/codecs/rt5682s.h +++ b/sound/soc/codecs/rt5682s.h @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -1446,6 +1447,7 @@ enum { struct rt5682s_priv { struct snd_soc_component *component; struct rt5682s_platform_data pdata; + struct gpio_desc *ldo1_en; struct regmap *regmap; struct snd_soc_jack *hs_jack; struct regulator_bulk_data supplies[RT5682S_NUM_SUPPLIES];