Message ID | 20221024220015.1759428-3-nfraprado@collabora.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp712955wru; Mon, 24 Oct 2022 17:02:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5U7LP9j6PPjHJUU1dVRdjIs2lLNo2/yb1oSCDsl0NdbV6Aid39g1ZcESdjeuG0S5DsUjGW X-Received: by 2002:a17:907:8a1c:b0:78d:ef44:7759 with SMTP id sc28-20020a1709078a1c00b0078def447759mr30710051ejc.441.1666656132970; Mon, 24 Oct 2022 17:02:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666656132; cv=none; d=google.com; s=arc-20160816; b=FxGd7UG3/X9LZ3reolFut10Y4+2hLoUcVdjYDv9Azhfa1W2ObumthoWY+L8tqSs8c/ gVgyU8cSqZwZ+TAjG04qc++AyJxjP4b3+Lk9mFkjRN5xel5/4H0P1uncHV8KAJ6QxoJG NyG5xL7b713sYTG0fO4l+0nb7fc0/QW2eS5eCpUWMxEH/1Ui6Gs9jXFcCuFqvWUhkqP1 1hox/7WMP2zlaaul1rz6QfSY8WvdsKeen4D5V7KQ+a5IY96+31XcZ5op+U5U4k7xtuwi L3oNawm8ziiqR1rwLnKnKCpCTsvqWcPRtdxooqbv6kBYXTw0New0onqIq3YFoXFvVkEp vbuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=p4xo0nWzBLoUrzYOHPdNngMrs8Cn8O6FaIxWrUUvCIc=; b=GBQmqJoRcuJVOSKtXYmY1pAJvWB2BihUc1g5xJtIFfmW7M+6xN3pmGRgu3+ZU99/Du /tx9l300wXyjxLe9tdeawv+tIE0OPKx5516ZXrL8Kejj13kv2SGB7FJhbx5KqucGQ9fM Xgqnlmq1NlzDSPCkoTPR0WXFv5OW/Jdbe6petCqe6KKN83h9mNcg6PiK6pJQNcB/pbf2 8icnQct/5f7Zi+7Nx6tJN5VV3b+XokyPJV4NaQwpmr1zXeOmxczwJ4M6V5QrpHjXDoMt F71SjPX47uCTHzxsY2TYYxTJelhXdEHV8EWGNQbnh8uPIuiNmRKIf6HmL5jcpOe425jS QNFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=hN3evVtj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gy12-20020a170906f24c00b0077f92be81adsi1089750ejb.212.2022.10.24.17.01.48; Mon, 24 Oct 2022 17:02:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=hN3evVtj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229714AbiJXXlu (ORCPT <rfc822;pwkd43@gmail.com> + 99 others); Mon, 24 Oct 2022 19:41:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230199AbiJXXl3 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 24 Oct 2022 19:41:29 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6A3D29F13D; Mon, 24 Oct 2022 15:00:29 -0700 (PDT) Received: from notapiano.myfiosgateway.com (unknown [194.36.25.51]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: nfraprado) by madras.collabora.co.uk (Postfix) with ESMTPSA id 6002A66026E6; Mon, 24 Oct 2022 23:00:25 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1666648827; bh=zH2yLaAyOCI8HWlnuIsMKt/wbk7W63NEAC2PrYHIQu4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hN3evVtjPXxYFgB91bDh1SQXIwQjNmNjTD5fUwYDtrR4pu3rNv3JwNveKdsTVHyp3 OCy+7bWb3wX07X4CFPH7gGcCL4rrSECV8UlZ4ko3si3GUMdPmuj6L084wCC5AlpP96 GHvxYvjMDleeoMN2Ay37cIOH14ngJukjKFHjqS96Ftm70UOjxG3y0aCmfMc0wugHFh 6GB0dI+/qqekdcQqGfiESiworEzu7X36uWPsLRr1YbS5KihfwA/rWpJt53ZASINSrl arQMfpSXATYqIhh/ncTeVb3bPythieLhBbc+tUEE5BzKLOtXgnLcGqoarhPdgiN++S LpES3IS0bGotg== From: =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= <nfraprado@collabora.com> To: Mark Brown <broonie@kernel.org> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, kernel@collabora.com, =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= <nfraprado@collabora.com>, Derek Fang <derek.fang@realtek.com>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Liam Girdwood <lgirdwood@gmail.com>, Rob Herring <robh+dt@kernel.org>, alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/4] ASoC: dt-bindings: realtek,rt5682s: Add AVDD and MICVDD supplies Date: Mon, 24 Oct 2022 18:00:13 -0400 Message-Id: <20221024220015.1759428-3-nfraprado@collabora.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024220015.1759428-1-nfraprado@collabora.com> References: <20221024220015.1759428-1-nfraprado@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747615621299806606?= X-GMAIL-MSGID: =?utf-8?q?1747615621299806606?= |
Series |
Add missing dt-binding properties to rt5682(s)
|
|
Commit Message
Nícolas F. R. A. Prado
Oct. 24, 2022, 10 p.m. UTC
The rt5682s codec can have two supplies: AVDD and MICVDD. They are
already used by sc7180-trogdor-kingoftown.dtsi, so document them in the
binding.
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
Changes in v2:
- Added mention that property is already used in a DT to the commit
message
Documentation/devicetree/bindings/sound/realtek,rt5682s.yaml | 4 ++++
1 file changed, 4 insertions(+)
Comments
Il 25/10/22 00:00, Nícolas F. R. A. Prado ha scritto: > The rt5682s codec can have two supplies: AVDD and MICVDD. They are > already used by sc7180-trogdor-kingoftown.dtsi, so document them in the > binding. > > Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> > I also don't like these uppercase supply names... I wonder if it's worth changing the driver to get "avdd" *or* "AVDD" (so, if "avdd" fails -> backwards compat)... ...this way, we can change the devicetree to use the lowercase names without breaking abi. Of course, this commit would need to be changed to document only the lowercase supply names. Driver-wise, we have a rt5682s_supply_names array... we could do something like: static const char *rt5682s_supply_names_legacy[RT5682S_NUM_SUPPLIES] = { [RT5682S_SUPPLY_AVDD] = "AVDD", [RT5682S_SUPPLY_MICVDD] = "MICVDD", }; static const char *rt5682s_supply_names[RT5682S_NUM_SUPPLIES] = { [RT5682S_SUPPLY_AVDD] = "avdd", [RT5682S_SUPPLY_MICVDD] = "micvdd", }; for (...) assign_supply_names; ret = devm_regulator_bulk_get(...); if (ret) { for (...) assign_legacy_supply_names; ret = devm_regulator_bulk_get(...) if (ret) return ret; } What do you think? Cheers, Angelo
On 24/10/2022 18:00, Nícolas F. R. A. Prado wrote: > The rt5682s codec can have two supplies: AVDD and MICVDD. They are > already used by sc7180-trogdor-kingoftown.dtsi, so document them in the > binding. > > Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> > > --- > > Changes in v2: > - Added mention that property is already used in a DT to the commit > message You already got an ack for it. Don't ignore it. Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Best regards, Krzysztof
On Mon, Oct 24, 2022 at 3:01 PM Nícolas F. R. A. Prado <nfraprado@collabora.com> wrote: > > The rt5682s codec can have two supplies: AVDD and MICVDD. They are The actual chip also has LDO1_IN (for digital core and charge pump) and DBVDD (for I/O). However in the Chromebook designs these two and AVDD are all provided from the same power rail, through separate filter banks. Neither does the datasheet specify the ordering of AVDD, DBVDD, and LDO1_IN for power sequencing, just that three should be toggled together. Should we model these? Or wait until some design actually splits these? ChenYu > already used by sc7180-trogdor-kingoftown.dtsi, so document them in the > binding. > > Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> > > --- > > Changes in v2: > - Added mention that property is already used in a DT to the commit > message > > Documentation/devicetree/bindings/sound/realtek,rt5682s.yaml | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/Documentation/devicetree/bindings/sound/realtek,rt5682s.yaml b/Documentation/devicetree/bindings/sound/realtek,rt5682s.yaml > index 1c0b06d82369..ac1dea5b4450 100644 > --- a/Documentation/devicetree/bindings/sound/realtek,rt5682s.yaml > +++ b/Documentation/devicetree/bindings/sound/realtek,rt5682s.yaml > @@ -90,6 +90,10 @@ properties: > "#sound-dai-cells": > const: 1 > > + AVDD-supply: true > + > + MICVDD-supply: true > + > additionalProperties: false > > required: > -- > 2.38.1 >
On Tue, Oct 25, 2022 at 01:12:49PM -0700, Chen-Yu Tsai wrote: > On Mon, Oct 24, 2022 at 3:01 PM Nícolas F. R. A. Prado > > The rt5682s codec can have two supplies: AVDD and MICVDD. They are > Neither does the datasheet specify the ordering of AVDD, DBVDD, and > LDO1_IN for power sequencing, just that three should be toggled together. > Should we model these? Or wait until some design actually splits these? Yes, the driver for a chip should be a driver for the chip not for some specific board.
On Tue, Oct 25, 2022 at 12:06:23PM +0200, AngeloGioacchino Del Regno wrote: > Il 25/10/22 00:00, Nícolas F. R. A. Prado ha scritto: > > The rt5682s codec can have two supplies: AVDD and MICVDD. They are > > already used by sc7180-trogdor-kingoftown.dtsi, so document them in the > > binding. > > > > Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> > > > > I also don't like these uppercase supply names... I wonder if it's worth changing > the driver to get "avdd" *or* "AVDD" (so, if "avdd" fails -> backwards compat)... > > ...this way, we can change the devicetree to use the lowercase names without > breaking abi. > > Of course, this commit would need to be changed to document only the lowercase > supply names. > > Driver-wise, we have a rt5682s_supply_names array... we could do something like: > > static const char *rt5682s_supply_names_legacy[RT5682S_NUM_SUPPLIES] = { > [RT5682S_SUPPLY_AVDD] = "AVDD", > [RT5682S_SUPPLY_MICVDD] = "MICVDD", > }; > > static const char *rt5682s_supply_names[RT5682S_NUM_SUPPLIES] = { > [RT5682S_SUPPLY_AVDD] = "avdd", > [RT5682S_SUPPLY_MICVDD] = "micvdd", > }; > > for (...) assign_supply_names; > ret = devm_regulator_bulk_get(...); > > if (ret) { > for (...) assign_legacy_supply_names; > ret = devm_regulator_bulk_get(...) > if (ret) > return ret; > } > > What do you think? No one seems opposed to it, so I'll add that to the next version. Thanks, Nícolas
On Tue, Oct 25, 2022 at 01:12:49PM -0700, Chen-Yu Tsai wrote: > On Mon, Oct 24, 2022 at 3:01 PM Nícolas F. R. A. Prado > <nfraprado@collabora.com> wrote: > > > > The rt5682s codec can have two supplies: AVDD and MICVDD. They are > > The actual chip also has LDO1_IN (for digital core and charge pump) > and DBVDD (for I/O). However in the Chromebook designs these two > and AVDD are all provided from the same power rail, through separate > filter banks. What about rt5682 (no s), does that chip also have these same supplies? Also, since you already gave the purpose of these other supplies, could you also tell the purpose of AVDD, MICVDD and (for rt5682) VBAT? That way I could add some description for them in the binding. Thanks, Nícolas > > Neither does the datasheet specify the ordering of AVDD, DBVDD, and > LDO1_IN for power sequencing, just that three should be toggled together. > > Should we model these? Or wait until some design actually splits these? [..]
On Thu, Oct 27, 2022 at 10:36:27AM -0400, Nícolas F. R. A. Prado wrote: > Also, since you already gave the purpose of these other supplies, could you also > tell the purpose of AVDD, MICVDD and (for rt5682) VBAT? That way I could add > some description for them in the binding. Those are all very conventional names - analog, microphone and battery supplies.
On Thu, Oct 27, 2022 at 7:36 AM Nícolas F. R. A. Prado <nfraprado@collabora.com> wrote: > > On Tue, Oct 25, 2022 at 01:12:49PM -0700, Chen-Yu Tsai wrote: > > On Mon, Oct 24, 2022 at 3:01 PM Nícolas F. R. A. Prado > > <nfraprado@collabora.com> wrote: > > > > > > The rt5682s codec can have two supplies: AVDD and MICVDD. They are > > > > The actual chip also has LDO1_IN (for digital core and charge pump) > > and DBVDD (for I/O). However in the Chromebook designs these two > > and AVDD are all provided from the same power rail, through separate > > filter banks. > > What about rt5682 (no s), does that chip also have these same supplies? > > Also, since you already gave the purpose of these other supplies, could you also > tell the purpose of AVDD, MICVDD and (for rt5682) VBAT? That way I could add > some description for them in the binding. As Mark mentioned in his reply, these are quite standard names. AVDD is for the analog bits. MICVDD is for the microphone bias. VBAT is called battery power in the datasheet. The block diagram shows it going through an internal controllable LDO whose output then powers MICVDD. This could be used in designs that don't include a suitable external supply for MICVDD. If MICVDD is provided, then one would turn the internal LDO off. So either VBAT or MICVDD has to be provided. ChenYu > Thanks, > Nícolas > > > > > Neither does the datasheet specify the ordering of AVDD, DBVDD, and > > LDO1_IN for power sequencing, just that three should be toggled together. > > > > Should we model these? Or wait until some design actually splits these? > [..]
On Thu, Oct 27, 2022 at 10:48 AM Chen-Yu Tsai <wenst@chromium.org> wrote: > > On Thu, Oct 27, 2022 at 7:36 AM Nícolas F. R. A. Prado > <nfraprado@collabora.com> wrote: > > > > On Tue, Oct 25, 2022 at 01:12:49PM -0700, Chen-Yu Tsai wrote: > > > On Mon, Oct 24, 2022 at 3:01 PM Nícolas F. R. A. Prado > > > <nfraprado@collabora.com> wrote: > > > > > > > > The rt5682s codec can have two supplies: AVDD and MICVDD. They are > > > > > > The actual chip also has LDO1_IN (for digital core and charge pump) > > > and DBVDD (for I/O). However in the Chromebook designs these two > > > and AVDD are all provided from the same power rail, through separate > > > filter banks. > > > > What about rt5682 (no s), does that chip also have these same supplies? (Missed this question) The RT5682 has the same supplies, plus the VBAT one. ChenYu > > Also, since you already gave the purpose of these other supplies, could you also > > tell the purpose of AVDD, MICVDD and (for rt5682) VBAT? That way I could add > > some description for them in the binding. > > As Mark mentioned in his reply, these are quite standard names. > > AVDD is for the analog bits. MICVDD is for the microphone bias. > VBAT is called battery power in the datasheet. The block diagram > shows it going through an internal controllable LDO whose output > then powers MICVDD. This could be used in designs that don't > include a suitable external supply for MICVDD. If MICVDD is provided, > then one would turn the internal LDO off. > > So either VBAT or MICVDD has to be provided. > > ChenYu > > > Thanks, > > Nícolas > > > > > > > > Neither does the datasheet specify the ordering of AVDD, DBVDD, and > > > LDO1_IN for power sequencing, just that three should be toggled together. > > > > > > Should we model these? Or wait until some design actually splits these? > > [..]
On Thu, Oct 27, 2022 at 11:11:08AM -0700, Chen-Yu Tsai wrote: > On Thu, Oct 27, 2022 at 10:48 AM Chen-Yu Tsai <wenst@chromium.org> wrote: > > > > On Thu, Oct 27, 2022 at 7:36 AM Nícolas F. R. A. Prado > > <nfraprado@collabora.com> wrote: > > > > > > On Tue, Oct 25, 2022 at 01:12:49PM -0700, Chen-Yu Tsai wrote: > > > > On Mon, Oct 24, 2022 at 3:01 PM Nícolas F. R. A. Prado > > > > <nfraprado@collabora.com> wrote: > > > > > > > > > > The rt5682s codec can have two supplies: AVDD and MICVDD. They are > > > > > > > > The actual chip also has LDO1_IN (for digital core and charge pump) > > > > and DBVDD (for I/O). However in the Chromebook designs these two > > > > and AVDD are all provided from the same power rail, through separate > > > > filter banks. > > > > > > What about rt5682 (no s), does that chip also have these same supplies? > > (Missed this question) > > The RT5682 has the same supplies, plus the VBAT one. > > ChenYu > > > > Also, since you already gave the purpose of these other supplies, could you also > > > tell the purpose of AVDD, MICVDD and (for rt5682) VBAT? That way I could add > > > some description for them in the binding. > > > > As Mark mentioned in his reply, these are quite standard names. > > > > AVDD is for the analog bits. MICVDD is for the microphone bias. > > VBAT is called battery power in the datasheet. The block diagram > > shows it going through an internal controllable LDO whose output > > then powers MICVDD. This could be used in designs that don't > > include a suitable external supply for MICVDD. If MICVDD is provided, > > then one would turn the internal LDO off. > > > > So either VBAT or MICVDD has to be provided. So if I get this right we should be making the following supplies required: AVDD VBAT or MICVDD (on rt5682s there's no VBAT so just MICVDD) And for LDO1_ON and DBVDD what would be the best way to model? Should we make them required in the binding as well and add them pointing to the same regulator from AVDD in the chromebook DT or just leave them as optional? Thanks, Nícolas > > > > ChenYu > > > > > Thanks, > > > Nícolas > > > > > > > > > > > Neither does the datasheet specify the ordering of AVDD, DBVDD, and > > > > LDO1_IN for power sequencing, just that three should be toggled together. > > > > > > > > Should we model these? Or wait until some design actually splits these? > > > [..]
On Thu, Oct 27, 2022 at 12:20 PM Nícolas F. R. A. Prado <nfraprado@collabora.com> wrote: > > On Thu, Oct 27, 2022 at 11:11:08AM -0700, Chen-Yu Tsai wrote: > > On Thu, Oct 27, 2022 at 10:48 AM Chen-Yu Tsai <wenst@chromium.org> wrote: > > > > > > On Thu, Oct 27, 2022 at 7:36 AM Nícolas F. R. A. Prado > > > <nfraprado@collabora.com> wrote: > > > > > > > > On Tue, Oct 25, 2022 at 01:12:49PM -0700, Chen-Yu Tsai wrote: > > > > > On Mon, Oct 24, 2022 at 3:01 PM Nícolas F. R. A. Prado > > > > > <nfraprado@collabora.com> wrote: > > > > > > > > > > > > The rt5682s codec can have two supplies: AVDD and MICVDD. They are > > > > > > > > > > The actual chip also has LDO1_IN (for digital core and charge pump) > > > > > and DBVDD (for I/O). However in the Chromebook designs these two > > > > > and AVDD are all provided from the same power rail, through separate > > > > > filter banks. > > > > > > > > What about rt5682 (no s), does that chip also have these same supplies? > > > > (Missed this question) > > > > The RT5682 has the same supplies, plus the VBAT one. > > > > ChenYu > > > > > > Also, since you already gave the purpose of these other supplies, could you also > > > > tell the purpose of AVDD, MICVDD and (for rt5682) VBAT? That way I could add > > > > some description for them in the binding. > > > > > > As Mark mentioned in his reply, these are quite standard names. > > > > > > AVDD is for the analog bits. MICVDD is for the microphone bias. > > > VBAT is called battery power in the datasheet. The block diagram > > > shows it going through an internal controllable LDO whose output > > > then powers MICVDD. This could be used in designs that don't > > > include a suitable external supply for MICVDD. If MICVDD is provided, > > > then one would turn the internal LDO off. > > > > > > So either VBAT or MICVDD has to be provided. > > So if I get this right we should be making the following supplies required: > AVDD > VBAT or MICVDD (on rt5682s there's no VBAT so just MICVDD) That's right. > And for LDO1_ON and DBVDD what would be the best way to model? Should we make > them required in the binding as well and add them pointing to the same regulator > from AVDD in the chromebook DT or just leave them as optional? They should be required. And we then describe them to match the board. ChenYu > Thanks, > Nícolas > > > > > > > ChenYu > > > > > > > Thanks, > > > > Nícolas > > > > > > > > > > > > > > Neither does the datasheet specify the ordering of AVDD, DBVDD, and > > > > > LDO1_IN for power sequencing, just that three should be toggled together. > > > > > > > > > > Should we model these? Or wait until some design actually splits these? > > > > [..]
On Tue, Oct 25, 2022 at 12:06:23PM +0200, AngeloGioacchino Del Regno wrote: > Il 25/10/22 00:00, Nícolas F. R. A. Prado ha scritto: > > The rt5682s codec can have two supplies: AVDD and MICVDD. They are > > already used by sc7180-trogdor-kingoftown.dtsi, so document them in the > > binding. > > > > Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> > > > > I also don't like these uppercase supply names... I wonder if it's worth changing > the driver to get "avdd" *or* "AVDD" (so, if "avdd" fails -> backwards compat)... > > ...this way, we can change the devicetree to use the lowercase names without > breaking abi. > > Of course, this commit would need to be changed to document only the lowercase > supply names. > > Driver-wise, we have a rt5682s_supply_names array... we could do something like: > > static const char *rt5682s_supply_names_legacy[RT5682S_NUM_SUPPLIES] = { > [RT5682S_SUPPLY_AVDD] = "AVDD", > [RT5682S_SUPPLY_MICVDD] = "MICVDD", > }; > > static const char *rt5682s_supply_names[RT5682S_NUM_SUPPLIES] = { > [RT5682S_SUPPLY_AVDD] = "avdd", > [RT5682S_SUPPLY_MICVDD] = "micvdd", > }; > > for (...) assign_supply_names; > ret = devm_regulator_bulk_get(...); > > if (ret) { > for (...) assign_legacy_supply_names; > ret = devm_regulator_bulk_get(...) > if (ret) > return ret; > } > > What do you think? Hi, I took a stab at this, but the resulting code wasn't as elegant. The default behavior of the regulator core when a regulator is missing is to just print a warning and give a dummy regulator in its place. A way around this is the "optional" variant, but it doesn't have a bulk version (in fact seems like it was added and then removed a few years back, but I haven't dug out the reason). So the result was a code block that wasn't nearly as neat as your draft above and it didn't seem worth it to add this complexity just to gain the usage of lowercase properties, which is why in the end I decided to not include this in the series I just sent [1]. I've included the patch below. If you do think there's a more reasonable approach or if having the lowercase supplies is worth it, let me know. Thanks, Nícolas [1] https://lore.kernel.org/all/20221028205540.3197304-1-nfraprado@collabora.com From 8de4a86f10ba2e13458afe63fe658df685b21b45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?= <nfraprado@collabora.com> Date: Thu, 27 Oct 2022 16:10:22 -0400 Subject: [PATCH] ASoC: rt5682s: Handle lowercase supply name and fallback if needed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Supply names provided by devicetree are conventionally lowercase. In order to be able to use lowercase names without breaking existing setups, detect if any of the older names are used and if so fallback to them. Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> --- sound/soc/codecs/rt5682s.c | 40 ++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/sound/soc/codecs/rt5682s.c b/sound/soc/codecs/rt5682s.c index 466a37f3500c..3cefa016be77 100644 --- a/sound/soc/codecs/rt5682s.c +++ b/sound/soc/codecs/rt5682s.c @@ -41,11 +41,16 @@ static const struct rt5682s_platform_data i2s_default_platform_data = { .dai_clk_names[RT5682S_DAI_BCLK_IDX] = "rt5682-dai-bclk", }; -static const char *rt5682s_supply_names[RT5682S_NUM_SUPPLIES] = { +static const char *rt5682s_legacy_supply_names[RT5682S_NUM_SUPPLIES] = { [RT5682S_SUPPLY_AVDD] = "AVDD", [RT5682S_SUPPLY_MICVDD] = "MICVDD", }; +static const char *rt5682s_supply_names[RT5682S_NUM_SUPPLIES] = { + [RT5682S_SUPPLY_AVDD] = "avdd", + [RT5682S_SUPPLY_MICVDD] = "micvdd", +}; + static const struct reg_sequence patch_list[] = { {RT5682S_I2C_CTRL, 0x0007}, {RT5682S_DIG_IN_CTRL_1, 0x0000}, @@ -3090,7 +3095,9 @@ static int rt5682s_i2c_probe(struct i2c_client *i2c) struct rt5682s_platform_data *pdata = dev_get_platdata(&i2c->dev); struct rt5682s_priv *rt5682s; int i, ret; + struct regulator *reg; unsigned int val; + bool using_legacy_supply_names = false; rt5682s = devm_kzalloc(&i2c->dev, sizeof(struct rt5682s_priv), GFP_KERNEL); if (!rt5682s) @@ -3112,14 +3119,31 @@ static int rt5682s_i2c_probe(struct i2c_client *i2c) return ret; } - for (i = 0; i < ARRAY_SIZE(rt5682s->supplies); i++) - rt5682s->supplies[i].supply = rt5682s_supply_names[i]; + for (i = 0; i < ARRAY_SIZE(rt5682s_supply_names); i++) { + reg = devm_regulator_get_optional(&i2c->dev, rt5682s_supply_names[i]); + if (IS_ERR(reg)) { + if (PTR_ERR(reg) == -ENODEV) { + using_legacy_supply_names = true; + break; + } else { + dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret); + return PTR_ERR(reg); + } + } - ret = devm_regulator_bulk_get(&i2c->dev, - ARRAY_SIZE(rt5682s->supplies), rt5682s->supplies); - if (ret) { - dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret); - return ret; + rt5682s->supplies[i].consumer = reg; + } + + if (using_legacy_supply_names) { + for (i = 0; i < ARRAY_SIZE(rt5682s->supplies); i++) + rt5682s->supplies[i].supply = rt5682s_legacy_supply_names[i]; + + ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(rt5682s->supplies), + rt5682s->supplies); + if (ret) { + dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret); + return ret; + } } ret = devm_add_action_or_reset(&i2c->dev, rt5682s_i2c_disable_regulators, rt5682s); -- 2.38.1
diff --git a/Documentation/devicetree/bindings/sound/realtek,rt5682s.yaml b/Documentation/devicetree/bindings/sound/realtek,rt5682s.yaml index 1c0b06d82369..ac1dea5b4450 100644 --- a/Documentation/devicetree/bindings/sound/realtek,rt5682s.yaml +++ b/Documentation/devicetree/bindings/sound/realtek,rt5682s.yaml @@ -90,6 +90,10 @@ properties: "#sound-dai-cells": const: 1 + AVDD-supply: true + + MICVDD-supply: true + additionalProperties: false required: