* [PATCH v3 00/12] qrb4210-rb2: add wsa audio playback and capture support @ 2025-05-22 17:40 Alexey Klimov 2025-05-22 17:40 ` [PATCH v3 01/12] ASoC: dt-bindings: qcom: Add SM6115 LPASS rxmacro and vamacro codecs Alexey Klimov ` (12 more replies) 0 siblings, 13 replies; 43+ messages in thread From: Alexey Klimov @ 2025-05-22 17:40 UTC (permalink / raw) To: Srinivas Kandagatla, Mark Brown, linux-sound Cc: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio, Srinivas Kandagatla, Konrad Dybcio Rebased, updated, re-tested. This implements the playback support via the following path: RX1 from DSP is connected to rxmacro which communicates with wcd codec using soundwire. This goes into AUX input of wcd. Wcd codec outputs analog audio into wsa8815 amplifier. Capturing works through vamacro using one onboard DMIC which is directly connected to vamacro codec. Changes since v2: -- dropped [PATCH v2 08/14] dt-bindings: arm: qcom-soc: extend pattern matching to support qcom,wsa881x and replaced with new one; -- dropped [PATCH v2 14/14] ASoC: qcom: sm8250: force single channel via RX_1 output for qrb4210 -- reordered as suggested by Krzysztof; -- updates to wsa881x-common.h registers descriptions and corresponding updates to wsa881x-common.c (Konrad); -- sorted subnodes in DT alphabetically as suggested by Konrad; -- wsa881x bindings updates (as suggested by Krzysztof); -- ASoC: dt-bindings: qcom: Add SM6115 LPASS rxmacro and vamacro codecs is still present; -- added "qcom,wsa8810" compatible to wsa881x-i2c.c; -- wsa881x is still present in wsa881x_probe_common(); Second version: https://lore.kernel.org/linux-arm-msm/20241212004727.2903846-1-alexey.klimov@linaro.org/ First version: https://lore.kernel.org/linux-sound/20241101053154.497550-1-alexey.klimov@linaro.org/ --- Alexey Klimov (12): ASoC: dt-bindings: qcom: Add SM6115 LPASS rxmacro and vamacro codecs dt-bindings: arm: qcom-soc: ignore "wsa" from being selected as SoC component ASoC: dt-bindings: qcom,wsa881x: extend description to analog mode ASoC: codecs: lpass-rx-macro: add sm6115 compatible ASoC: codecs: wsa881x: split into common and soundwire drivers ASoC: codecs: add wsa881x-i2c amplifier codec driver arm64: dts: qcom: sm6115: add LPASS devices arm64: dts: qcom: sm4250: add description of soundwire and dmic pins arm64: dts: qcom: qrb4210-rb2: add wcd937x codec support arm64: dts: qcom: qrb4210-rb2: enable wsa881x amplifier arm64: dts: qcom: qrb4210-rb2: add WSA audio playback support arm64: dts: qcom: qrb4210-rb2: add VA capture support .../devicetree/bindings/arm/qcom-soc.yaml | 2 +- .../bindings/sound/qcom,lpass-rx-macro.yaml | 19 + .../bindings/sound/qcom,lpass-va-macro.yaml | 22 +- .../devicetree/bindings/sound/qcom,wsa881x.yaml | 66 +- arch/arm64/boot/dts/qcom/qrb4210-rb2.dts | 113 ++ arch/arm64/boot/dts/qcom/sm4250.dtsi | 62 + arch/arm64/boot/dts/qcom/sm6115.dtsi | 132 ++ sound/soc/codecs/Kconfig | 15 + sound/soc/codecs/Makefile | 4 + sound/soc/codecs/lpass-rx-macro.c | 4 +- sound/soc/codecs/wsa881x-common.c | 193 +++ sound/soc/codecs/wsa881x-common.h | 478 +++++++ sound/soc/codecs/wsa881x-i2c.c | 1353 ++++++++++++++++++++ sound/soc/codecs/wsa881x.c | 493 +------ 14 files changed, 2459 insertions(+), 497 deletions(-) --- base-commit: 7bac2c97af4078d7a627500c9bcdd5b033f97718 change-id: 20250522-rb2_audio_v3-ffa12dcc6148 Best regards, -- Alexey Klimov <alexey.klimov@linaro.org> ^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v3 01/12] ASoC: dt-bindings: qcom: Add SM6115 LPASS rxmacro and vamacro codecs 2025-05-22 17:40 [PATCH v3 00/12] qrb4210-rb2: add wsa audio playback and capture support Alexey Klimov @ 2025-05-22 17:40 ` Alexey Klimov 2025-05-22 17:49 ` Krzysztof Kozlowski 2025-05-22 17:40 ` [PATCH v3 02/12] dt-bindings: arm: qcom-soc: ignore "wsa" from being selected as SoC component Alexey Klimov ` (11 subsequent siblings) 12 siblings, 1 reply; 43+ messages in thread From: Alexey Klimov @ 2025-05-22 17:40 UTC (permalink / raw) To: Srinivas Kandagatla, Mark Brown, linux-sound Cc: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio Document compatibles for Qualcomm SM6115 SoC digital RX and VA (voice activation) macro codecs and their clocks. Cc: Srinivas Kandagatla <srini@kernel.org> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> --- .../bindings/sound/qcom,lpass-rx-macro.yaml | 19 +++++++++++++++++++ .../bindings/sound/qcom,lpass-va-macro.yaml | 22 ++++++++++++++++------ 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/qcom,lpass-rx-macro.yaml b/Documentation/devicetree/bindings/sound/qcom,lpass-rx-macro.yaml index 92f95eb74b1928fde11ad86ab6344f274bdf7790..697c5591ae7cb82633ff0159fb31d08b57c11b97 100644 --- a/Documentation/devicetree/bindings/sound/qcom,lpass-rx-macro.yaml +++ b/Documentation/devicetree/bindings/sound/qcom,lpass-rx-macro.yaml @@ -14,6 +14,7 @@ properties: oneOf: - enum: - qcom,sc7280-lpass-rx-macro + - qcom,sm6115-lpass-rx-macro - qcom,sm8250-lpass-rx-macro - qcom,sm8450-lpass-rx-macro - qcom,sm8550-lpass-rx-macro @@ -80,6 +81,24 @@ allOf: - const: npl - const: fsgen + - if: + properties: + compatible: + contains: + enum: + - qcom,sm6115-lpass-rx-macro + then: + properties: + clocks: + minItems: 4 + maxItems: 4 + clock-names: + items: + - const: mclk + - const: npl + - const: dcodec + - const: fsgen + - if: properties: compatible: diff --git a/Documentation/devicetree/bindings/sound/qcom,lpass-va-macro.yaml b/Documentation/devicetree/bindings/sound/qcom,lpass-va-macro.yaml index f41deaa6f4df57c8186acf4cd7bb99e38dbf89f0..a70c0f36389269756b724889c335c1b0bae157d2 100644 --- a/Documentation/devicetree/bindings/sound/qcom,lpass-va-macro.yaml +++ b/Documentation/devicetree/bindings/sound/qcom,lpass-va-macro.yaml @@ -14,10 +14,15 @@ properties: oneOf: - enum: - qcom,sc7280-lpass-va-macro + - qcom,sm6115-lpass-va-macro - qcom,sm8250-lpass-va-macro - qcom,sm8450-lpass-va-macro - qcom,sm8550-lpass-va-macro - qcom,sc8280xp-lpass-va-macro + - items: + - enum: + - qcom,sm6115-lpass-va-macro + - const: qcom,sm8450-lpass-va-macro - items: - enum: - qcom,sm8650-lpass-va-macro @@ -109,14 +114,19 @@ allOf: then: properties: clocks: - minItems: 4 + minItems: 3 maxItems: 4 clock-names: - items: - - const: mclk - - const: macro - - const: dcodec - - const: npl + oneOf: + - items: + - const: mclk + - const: macro + - const: dcodec + - const: npl + - items: + - const: mclk + - const: dcodec + - const: npl - if: properties: -- 2.47.2 ^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH v3 01/12] ASoC: dt-bindings: qcom: Add SM6115 LPASS rxmacro and vamacro codecs 2025-05-22 17:40 ` [PATCH v3 01/12] ASoC: dt-bindings: qcom: Add SM6115 LPASS rxmacro and vamacro codecs Alexey Klimov @ 2025-05-22 17:49 ` Krzysztof Kozlowski 0 siblings, 0 replies; 43+ messages in thread From: Krzysztof Kozlowski @ 2025-05-22 17:49 UTC (permalink / raw) To: Alexey Klimov, Srinivas Kandagatla, Mark Brown, linux-sound Cc: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio On 22/05/2025 19:40, Alexey Klimov wrote: > Document compatibles for Qualcomm SM6115 SoC digital RX and > VA (voice activation) macro codecs and their clocks. > > Cc: Srinivas Kandagatla <srini@kernel.org> > Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> > --- > .../bindings/sound/qcom,lpass-rx-macro.yaml | 19 +++++++++++++++++++ > .../bindings/sound/qcom,lpass-va-macro.yaml | 22 ++++++++++++++++------ > 2 files changed, 35 insertions(+), 6 deletions(-) > You did not respond to my comments, I don't see any changelog. I also do not understand the changes done later > diff --git a/Documentation/devicetree/bindings/sound/qcom,lpass-rx-macro.yaml b/Documentation/devicetree/bindings/sound/qcom,lpass-rx-macro.yaml > index 92f95eb74b1928fde11ad86ab6344f274bdf7790..697c5591ae7cb82633ff0159fb31d08b57c11b97 100644 > --- a/Documentation/devicetree/bindings/sound/qcom,lpass-rx-macro.yaml > +++ b/Documentation/devicetree/bindings/sound/qcom,lpass-rx-macro.yaml > @@ -14,6 +14,7 @@ properties: > oneOf: > - enum: > - qcom,sc7280-lpass-rx-macro > + - qcom,sm6115-lpass-rx-macro > - qcom,sm8250-lpass-rx-macro > - qcom,sm8450-lpass-rx-macro > - qcom,sm8550-lpass-rx-macro > @@ -80,6 +81,24 @@ allOf: > - const: npl > - const: fsgen > > + - if: > + properties: > + compatible: > + contains: > + enum: > + - qcom,sm6115-lpass-rx-macro > + then: > + properties: > + clocks: > + minItems: 4 > + maxItems: 4 > + clock-names: > + items: > + - const: mclk > + - const: npl > + - const: dcodec > + - const: fsgen > + > - if: > properties: > compatible: > diff --git a/Documentation/devicetree/bindings/sound/qcom,lpass-va-macro.yaml b/Documentation/devicetree/bindings/sound/qcom,lpass-va-macro.yaml > index f41deaa6f4df57c8186acf4cd7bb99e38dbf89f0..a70c0f36389269756b724889c335c1b0bae157d2 100644 > --- a/Documentation/devicetree/bindings/sound/qcom,lpass-va-macro.yaml > +++ b/Documentation/devicetree/bindings/sound/qcom,lpass-va-macro.yaml > @@ -14,10 +14,15 @@ properties: > oneOf: > - enum: > - qcom,sc7280-lpass-va-macro > + - qcom,sm6115-lpass-va-macro > - qcom,sm8250-lpass-va-macro > - qcom,sm8450-lpass-va-macro > - qcom,sm8550-lpass-va-macro > - qcom,sc8280xp-lpass-va-macro > + - items: > + - enum: > + - qcom,sm6115-lpass-va-macro > + - const: qcom,sm8450-lpass-va-macro > - items: > - enum: > - qcom,sm8650-lpass-va-macro > @@ -109,14 +114,19 @@ allOf: > then: > properties: > clocks: > - minItems: 4 > + minItems: 3 Why? Nothing in commit msg explains why existing devices changed. Best regards, Krzysztof ^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v3 02/12] dt-bindings: arm: qcom-soc: ignore "wsa" from being selected as SoC component 2025-05-22 17:40 [PATCH v3 00/12] qrb4210-rb2: add wsa audio playback and capture support Alexey Klimov 2025-05-22 17:40 ` [PATCH v3 01/12] ASoC: dt-bindings: qcom: Add SM6115 LPASS rxmacro and vamacro codecs Alexey Klimov @ 2025-05-22 17:40 ` Alexey Klimov 2025-05-23 8:12 ` Krzysztof Kozlowski 2025-05-22 17:40 ` [PATCH v3 03/12] ASoC: dt-bindings: qcom,wsa881x: extend description to analog mode Alexey Klimov ` (10 subsequent siblings) 12 siblings, 1 reply; 43+ messages in thread From: Alexey Klimov @ 2025-05-22 17:40 UTC (permalink / raw) To: Srinivas Kandagatla, Mark Brown, linux-sound Cc: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio The pattern matching incorrectly selects "wsa" because of "sa" substring and evaluates it as a SoC component or block. Wsa88xx are family of amplifiers and should not be evaluated here. Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> --- Documentation/devicetree/bindings/arm/qcom-soc.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/arm/qcom-soc.yaml b/Documentation/devicetree/bindings/arm/qcom-soc.yaml index a77d68dcad4e52e4fee43729ac8dc1caf957262e..99521813a04ca416fe90454a811c4a13143efce3 100644 --- a/Documentation/devicetree/bindings/arm/qcom-soc.yaml +++ b/Documentation/devicetree/bindings/arm/qcom-soc.yaml @@ -23,7 +23,7 @@ description: | select: properties: compatible: - pattern: "^qcom,.*(apq|ipq|mdm|msm|qcm|qcs|q[dr]u|sa|sar|sc|sd[amx]|sm|x1[ep])[0-9]+.*$" + pattern: "^qcom,(?!.*wsa)(apq|ipq|mdm|msm|qcm|qcs|q[dr]u|sa|sar|sc|sd[amx]|smx1[ep])[0-9]+.*$" required: - compatible -- 2.47.2 ^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH v3 02/12] dt-bindings: arm: qcom-soc: ignore "wsa" from being selected as SoC component 2025-05-22 17:40 ` [PATCH v3 02/12] dt-bindings: arm: qcom-soc: ignore "wsa" from being selected as SoC component Alexey Klimov @ 2025-05-23 8:12 ` Krzysztof Kozlowski 2025-05-28 14:37 ` Alexey Klimov 0 siblings, 1 reply; 43+ messages in thread From: Krzysztof Kozlowski @ 2025-05-23 8:12 UTC (permalink / raw) To: Alexey Klimov Cc: Srinivas Kandagatla, Mark Brown, linux-sound, Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio On Thu, May 22, 2025 at 06:40:52PM GMT, Alexey Klimov wrote: > The pattern matching incorrectly selects "wsa" because of "sa" substring > and evaluates it as a SoC component or block. > > Wsa88xx are family of amplifiers and should not be evaluated here. > > Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> > --- > Documentation/devicetree/bindings/arm/qcom-soc.yaml | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/Documentation/devicetree/bindings/arm/qcom-soc.yaml b/Documentation/devicetree/bindings/arm/qcom-soc.yaml > index a77d68dcad4e52e4fee43729ac8dc1caf957262e..99521813a04ca416fe90454a811c4a13143efce3 100644 > --- a/Documentation/devicetree/bindings/arm/qcom-soc.yaml > +++ b/Documentation/devicetree/bindings/arm/qcom-soc.yaml > @@ -23,7 +23,7 @@ description: | > select: > properties: > compatible: > - pattern: "^qcom,.*(apq|ipq|mdm|msm|qcm|qcs|q[dr]u|sa|sar|sc|sd[amx]|sm|x1[ep])[0-9]+.*$" > + pattern: "^qcom,(?!.*wsa)(apq|ipq|mdm|msm|qcm|qcs|q[dr]u|sa|sar|sc|sd[amx]|smx1[ep])[0-9]+.*$" Why dropping front .*? Are you sure this matches what we want - so incorrect compatibles? To me it breaks the entire point of this select, so I am sure you did not test whether it still works. To remind: this is to select incorrect compatibles. (?!wsa) Because qcom,x-wsa8845 should be matched and cause warnings. And probably we are getting past the point of readability, so could you try: compatible: anyOf: - pattern: "^qcom,.*(apq|ipq|mdm|msm|qcm|qcs|q[dr]u|sar|sc|sd[amx]|sm|x1[ep])[0-9]+.*$" - pattern: "^qcom,.*(?!wsa)sa[0-9]+.*$" > required: > - compatible > > > -- > 2.47.2 > ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v3 02/12] dt-bindings: arm: qcom-soc: ignore "wsa" from being selected as SoC component 2025-05-23 8:12 ` Krzysztof Kozlowski @ 2025-05-28 14:37 ` Alexey Klimov 2025-05-28 16:58 ` Konrad Dybcio 2025-05-29 6:38 ` Krzysztof Kozlowski 0 siblings, 2 replies; 43+ messages in thread From: Alexey Klimov @ 2025-05-28 14:37 UTC (permalink / raw) To: Krzysztof Kozlowski Cc: Srinivas Kandagatla, Mark Brown, linux-sound, Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio On Fri May 23, 2025 at 9:12 AM BST, Krzysztof Kozlowski wrote: > On Thu, May 22, 2025 at 06:40:52PM GMT, Alexey Klimov wrote: >> The pattern matching incorrectly selects "wsa" because of "sa" substring >> and evaluates it as a SoC component or block. >> >> Wsa88xx are family of amplifiers and should not be evaluated here. >> >> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> >> --- >> Documentation/devicetree/bindings/arm/qcom-soc.yaml | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/Documentation/devicetree/bindings/arm/qcom-soc.yaml b/Documentation/devicetree/bindings/arm/qcom-soc.yaml >> index a77d68dcad4e52e4fee43729ac8dc1caf957262e..99521813a04ca416fe90454a811c4a13143efce3 100644 >> --- a/Documentation/devicetree/bindings/arm/qcom-soc.yaml >> +++ b/Documentation/devicetree/bindings/arm/qcom-soc.yaml >> @@ -23,7 +23,7 @@ description: | >> select: >> properties: >> compatible: >> - pattern: "^qcom,.*(apq|ipq|mdm|msm|qcm|qcs|q[dr]u|sa|sar|sc|sd[amx]|sm|x1[ep])[0-9]+.*$" >> + pattern: "^qcom,(?!.*wsa)(apq|ipq|mdm|msm|qcm|qcs|q[dr]u|sa|sar|sc|sd[amx]|smx1[ep])[0-9]+.*$" > > Why dropping front .*? Are you sure this matches what we want - so > incorrect compatibles? To me it breaks the entire point of this select, > so I am sure you did not test whether it still works. To remind: this is > to select incorrect compatibles. Thanks, great point. I tested it with regular dtbs checks with different dtb files but I didn't check if it selects incorrect compatibles. > (?!wsa) > Because qcom,x-wsa8845 should be matched and cause warnings. This is now confusing. I thought that the main job for the pattern above is to avoid selecting wsa88xx amplifiers in the first place. Or, if I can quote yourself: "What is WSA8815 that it should be here?" If said wsa8845 with incorrect or correct should be selected by that pattern then why not just leave that pattern as it is then? I am lost. > And probably we are getting past the point of readability, so could you > try: > > compatible: > anyOf: > - pattern: "^qcom,.*(apq|ipq|mdm|msm|qcm|qcs|q[dr]u|sar|sc|sd[amx]|sm|x1[ep])[0-9]+.*$" > - pattern: "^qcom,.*(?!wsa)sa[0-9]+.*$" Thanks, that one is much better for readability. I'll test that one then. Best regards, Alexey ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v3 02/12] dt-bindings: arm: qcom-soc: ignore "wsa" from being selected as SoC component 2025-05-28 14:37 ` Alexey Klimov @ 2025-05-28 16:58 ` Konrad Dybcio 2025-05-29 6:58 ` Krzysztof Kozlowski 2025-05-29 6:38 ` Krzysztof Kozlowski 1 sibling, 1 reply; 43+ messages in thread From: Konrad Dybcio @ 2025-05-28 16:58 UTC (permalink / raw) To: Alexey Klimov, Krzysztof Kozlowski Cc: Srinivas Kandagatla, Mark Brown, linux-sound, Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio On 5/28/25 4:37 PM, Alexey Klimov wrote: > On Fri May 23, 2025 at 9:12 AM BST, Krzysztof Kozlowski wrote: >> On Thu, May 22, 2025 at 06:40:52PM GMT, Alexey Klimov wrote: >>> The pattern matching incorrectly selects "wsa" because of "sa" substring >>> and evaluates it as a SoC component or block. >>> >>> Wsa88xx are family of amplifiers and should not be evaluated here. >>> >>> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> >>> --- >>> Documentation/devicetree/bindings/arm/qcom-soc.yaml | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/Documentation/devicetree/bindings/arm/qcom-soc.yaml b/Documentation/devicetree/bindings/arm/qcom-soc.yaml >>> index a77d68dcad4e52e4fee43729ac8dc1caf957262e..99521813a04ca416fe90454a811c4a13143efce3 100644 >>> --- a/Documentation/devicetree/bindings/arm/qcom-soc.yaml >>> +++ b/Documentation/devicetree/bindings/arm/qcom-soc.yaml >>> @@ -23,7 +23,7 @@ description: | >>> select: >>> properties: >>> compatible: >>> - pattern: "^qcom,.*(apq|ipq|mdm|msm|qcm|qcs|q[dr]u|sa|sar|sc|sd[amx]|sm|x1[ep])[0-9]+.*$" >>> + pattern: "^qcom,(?!.*wsa)(apq|ipq|mdm|msm|qcm|qcs|q[dr]u|sa|sar|sc|sd[amx]|smx1[ep])[0-9]+.*$" >> >> Why dropping front .*? Are you sure this matches what we want - so >> incorrect compatibles? To me it breaks the entire point of this select, >> so I am sure you did not test whether it still works. To remind: this is >> to select incorrect compatibles. > > Thanks, great point. I tested it with regular dtbs checks with different > dtb files but I didn't check if it selects incorrect compatibles. Maybe we can introduce a '-' before or after the socname, to also officially disallow using other connecting characters Konrad ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v3 02/12] dt-bindings: arm: qcom-soc: ignore "wsa" from being selected as SoC component 2025-05-28 16:58 ` Konrad Dybcio @ 2025-05-29 6:58 ` Krzysztof Kozlowski 2025-05-29 16:34 ` Konrad Dybcio 0 siblings, 1 reply; 43+ messages in thread From: Krzysztof Kozlowski @ 2025-05-29 6:58 UTC (permalink / raw) To: Konrad Dybcio, Alexey Klimov, Krzysztof Kozlowski Cc: Srinivas Kandagatla, Mark Brown, linux-sound, Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio On 28/05/2025 18:58, Konrad Dybcio wrote: > On 5/28/25 4:37 PM, Alexey Klimov wrote: >> On Fri May 23, 2025 at 9:12 AM BST, Krzysztof Kozlowski wrote: >>> On Thu, May 22, 2025 at 06:40:52PM GMT, Alexey Klimov wrote: >>>> The pattern matching incorrectly selects "wsa" because of "sa" substring >>>> and evaluates it as a SoC component or block. >>>> >>>> Wsa88xx are family of amplifiers and should not be evaluated here. >>>> >>>> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> >>>> --- >>>> Documentation/devicetree/bindings/arm/qcom-soc.yaml | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/Documentation/devicetree/bindings/arm/qcom-soc.yaml b/Documentation/devicetree/bindings/arm/qcom-soc.yaml >>>> index a77d68dcad4e52e4fee43729ac8dc1caf957262e..99521813a04ca416fe90454a811c4a13143efce3 100644 >>>> --- a/Documentation/devicetree/bindings/arm/qcom-soc.yaml >>>> +++ b/Documentation/devicetree/bindings/arm/qcom-soc.yaml >>>> @@ -23,7 +23,7 @@ description: | >>>> select: >>>> properties: >>>> compatible: >>>> - pattern: "^qcom,.*(apq|ipq|mdm|msm|qcm|qcs|q[dr]u|sa|sar|sc|sd[amx]|sm|x1[ep])[0-9]+.*$" >>>> + pattern: "^qcom,(?!.*wsa)(apq|ipq|mdm|msm|qcm|qcs|q[dr]u|sa|sar|sc|sd[amx]|smx1[ep])[0-9]+.*$" >>> >>> Why dropping front .*? Are you sure this matches what we want - so >>> incorrect compatibles? To me it breaks the entire point of this select, >>> so I am sure you did not test whether it still works. To remind: this is >>> to select incorrect compatibles. >> >> Thanks, great point. I tested it with regular dtbs checks with different >> dtb files but I didn't check if it selects incorrect compatibles. > > Maybe we can introduce a '-' before or after the socname, to also officially > disallow using other connecting characters It is already there. Best regards, Krzysztof ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v3 02/12] dt-bindings: arm: qcom-soc: ignore "wsa" from being selected as SoC component 2025-05-29 6:58 ` Krzysztof Kozlowski @ 2025-05-29 16:34 ` Konrad Dybcio 2025-05-29 16:58 ` Krzysztof Kozlowski 0 siblings, 1 reply; 43+ messages in thread From: Konrad Dybcio @ 2025-05-29 16:34 UTC (permalink / raw) To: Krzysztof Kozlowski, Alexey Klimov, Krzysztof Kozlowski Cc: Srinivas Kandagatla, Mark Brown, linux-sound, Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio On 5/29/25 8:58 AM, Krzysztof Kozlowski wrote: > On 28/05/2025 18:58, Konrad Dybcio wrote: >> On 5/28/25 4:37 PM, Alexey Klimov wrote: >>> On Fri May 23, 2025 at 9:12 AM BST, Krzysztof Kozlowski wrote: >>>> On Thu, May 22, 2025 at 06:40:52PM GMT, Alexey Klimov wrote: >>>>> The pattern matching incorrectly selects "wsa" because of "sa" substring >>>>> and evaluates it as a SoC component or block. >>>>> >>>>> Wsa88xx are family of amplifiers and should not be evaluated here. >>>>> >>>>> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> >>>>> --- >>>>> Documentation/devicetree/bindings/arm/qcom-soc.yaml | 2 +- >>>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>>> >>>>> diff --git a/Documentation/devicetree/bindings/arm/qcom-soc.yaml b/Documentation/devicetree/bindings/arm/qcom-soc.yaml >>>>> index a77d68dcad4e52e4fee43729ac8dc1caf957262e..99521813a04ca416fe90454a811c4a13143efce3 100644 >>>>> --- a/Documentation/devicetree/bindings/arm/qcom-soc.yaml >>>>> +++ b/Documentation/devicetree/bindings/arm/qcom-soc.yaml >>>>> @@ -23,7 +23,7 @@ description: | >>>>> select: >>>>> properties: >>>>> compatible: >>>>> - pattern: "^qcom,.*(apq|ipq|mdm|msm|qcm|qcs|q[dr]u|sa|sar|sc|sd[amx]|sm|x1[ep])[0-9]+.*$" >>>>> + pattern: "^qcom,(?!.*wsa)(apq|ipq|mdm|msm|qcm|qcs|q[dr]u|sa|sar|sc|sd[amx]|smx1[ep])[0-9]+.*$" >>>> >>>> Why dropping front .*? Are you sure this matches what we want - so >>>> incorrect compatibles? To me it breaks the entire point of this select, >>>> so I am sure you did not test whether it still works. To remind: this is >>>> to select incorrect compatibles. >>> >>> Thanks, great point. I tested it with regular dtbs checks with different >>> dtb files but I didn't check if it selects incorrect compatibles. >> >> Maybe we can introduce a '-' before or after the socname, to also officially >> disallow using other connecting characters > > It is already there. Pardon, but I don't see it, only in the 0-9 group Konrad ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v3 02/12] dt-bindings: arm: qcom-soc: ignore "wsa" from being selected as SoC component 2025-05-29 16:34 ` Konrad Dybcio @ 2025-05-29 16:58 ` Krzysztof Kozlowski 2025-05-29 17:12 ` Konrad Dybcio 0 siblings, 1 reply; 43+ messages in thread From: Krzysztof Kozlowski @ 2025-05-29 16:58 UTC (permalink / raw) To: Konrad Dybcio, Krzysztof Kozlowski, Alexey Klimov Cc: Srinivas Kandagatla, Mark Brown, linux-sound, Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio On 29/05/2025 18:34, Konrad Dybcio wrote: > On 5/29/25 8:58 AM, Krzysztof Kozlowski wrote: >> On 28/05/2025 18:58, Konrad Dybcio wrote: >>> On 5/28/25 4:37 PM, Alexey Klimov wrote: >>>> On Fri May 23, 2025 at 9:12 AM BST, Krzysztof Kozlowski wrote: >>>>> On Thu, May 22, 2025 at 06:40:52PM GMT, Alexey Klimov wrote: >>>>>> The pattern matching incorrectly selects "wsa" because of "sa" substring >>>>>> and evaluates it as a SoC component or block. >>>>>> >>>>>> Wsa88xx are family of amplifiers and should not be evaluated here. >>>>>> >>>>>> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> >>>>>> --- >>>>>> Documentation/devicetree/bindings/arm/qcom-soc.yaml | 2 +- >>>>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>>>> >>>>>> diff --git a/Documentation/devicetree/bindings/arm/qcom-soc.yaml b/Documentation/devicetree/bindings/arm/qcom-soc.yaml >>>>>> index a77d68dcad4e52e4fee43729ac8dc1caf957262e..99521813a04ca416fe90454a811c4a13143efce3 100644 >>>>>> --- a/Documentation/devicetree/bindings/arm/qcom-soc.yaml >>>>>> +++ b/Documentation/devicetree/bindings/arm/qcom-soc.yaml >>>>>> @@ -23,7 +23,7 @@ description: | >>>>>> select: >>>>>> properties: >>>>>> compatible: >>>>>> - pattern: "^qcom,.*(apq|ipq|mdm|msm|qcm|qcs|q[dr]u|sa|sar|sc|sd[amx]|sm|x1[ep])[0-9]+.*$" >>>>>> + pattern: "^qcom,(?!.*wsa)(apq|ipq|mdm|msm|qcm|qcs|q[dr]u|sa|sar|sc|sd[amx]|smx1[ep])[0-9]+.*$" >>>>> >>>>> Why dropping front .*? Are you sure this matches what we want - so >>>>> incorrect compatibles? To me it breaks the entire point of this select, >>>>> so I am sure you did not test whether it still works. To remind: this is >>>>> to select incorrect compatibles. >>>> >>>> Thanks, great point. I tested it with regular dtbs checks with different >>>> dtb files but I didn't check if it selects incorrect compatibles. >>> >>> Maybe we can introduce a '-' before or after the socname, to also officially >>> disallow using other connecting characters >> >> It is already there. > > Pardon, but I don't see it, only in the 0-9 group Then maybe we talk about different things? Because the one to fulfill your request - to officially disallow using other characters, which is part of the goal of this binding - is here: "^qcom,(apq| <snip> |sc|sd[amx]|sm|x1[ep])[0-9]+(pro)?-.*$ -----------^ That's the hyphen after soc name. Best regards, Krzysztof ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v3 02/12] dt-bindings: arm: qcom-soc: ignore "wsa" from being selected as SoC component 2025-05-29 16:58 ` Krzysztof Kozlowski @ 2025-05-29 17:12 ` Konrad Dybcio 0 siblings, 0 replies; 43+ messages in thread From: Konrad Dybcio @ 2025-05-29 17:12 UTC (permalink / raw) To: Krzysztof Kozlowski, Konrad Dybcio, Krzysztof Kozlowski, Alexey Klimov Cc: Srinivas Kandagatla, Mark Brown, linux-sound, Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio On 5/29/25 6:58 PM, Krzysztof Kozlowski wrote: > On 29/05/2025 18:34, Konrad Dybcio wrote: >> On 5/29/25 8:58 AM, Krzysztof Kozlowski wrote: >>> On 28/05/2025 18:58, Konrad Dybcio wrote: >>>> On 5/28/25 4:37 PM, Alexey Klimov wrote: >>>>> On Fri May 23, 2025 at 9:12 AM BST, Krzysztof Kozlowski wrote: >>>>>> On Thu, May 22, 2025 at 06:40:52PM GMT, Alexey Klimov wrote: >>>>>>> The pattern matching incorrectly selects "wsa" because of "sa" substring >>>>>>> and evaluates it as a SoC component or block. >>>>>>> >>>>>>> Wsa88xx are family of amplifiers and should not be evaluated here. >>>>>>> >>>>>>> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> >>>>>>> --- >>>>>>> Documentation/devicetree/bindings/arm/qcom-soc.yaml | 2 +- >>>>>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>>>>> >>>>>>> diff --git a/Documentation/devicetree/bindings/arm/qcom-soc.yaml b/Documentation/devicetree/bindings/arm/qcom-soc.yaml >>>>>>> index a77d68dcad4e52e4fee43729ac8dc1caf957262e..99521813a04ca416fe90454a811c4a13143efce3 100644 >>>>>>> --- a/Documentation/devicetree/bindings/arm/qcom-soc.yaml >>>>>>> +++ b/Documentation/devicetree/bindings/arm/qcom-soc.yaml >>>>>>> @@ -23,7 +23,7 @@ description: | >>>>>>> select: >>>>>>> properties: >>>>>>> compatible: >>>>>>> - pattern: "^qcom,.*(apq|ipq|mdm|msm|qcm|qcs|q[dr]u|sa|sar|sc|sd[amx]|sm|x1[ep])[0-9]+.*$" >>>>>>> + pattern: "^qcom,(?!.*wsa)(apq|ipq|mdm|msm|qcm|qcs|q[dr]u|sa|sar|sc|sd[amx]|smx1[ep])[0-9]+.*$" >>>>>> >>>>>> Why dropping front .*? Are you sure this matches what we want - so >>>>>> incorrect compatibles? To me it breaks the entire point of this select, >>>>>> so I am sure you did not test whether it still works. To remind: this is >>>>>> to select incorrect compatibles. >>>>> >>>>> Thanks, great point. I tested it with regular dtbs checks with different >>>>> dtb files but I didn't check if it selects incorrect compatibles. >>>> >>>> Maybe we can introduce a '-' before or after the socname, to also officially >>>> disallow using other connecting characters >>> >>> It is already there. >> >> Pardon, but I don't see it, only in the 0-9 group > > Then maybe we talk about different things? Because the one to fulfill > your request - to officially disallow using other characters, which is > part of the goal of this binding - is here: > > "^qcom,(apq| <snip> |sc|sd[amx]|sm|x1[ep])[0-9]+(pro)?-.*$ > -----------^ > > That's the hyphen after soc name. Aaaah ok it simply wasn't in the email context Konrad ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v3 02/12] dt-bindings: arm: qcom-soc: ignore "wsa" from being selected as SoC component 2025-05-28 14:37 ` Alexey Klimov 2025-05-28 16:58 ` Konrad Dybcio @ 2025-05-29 6:38 ` Krzysztof Kozlowski 1 sibling, 0 replies; 43+ messages in thread From: Krzysztof Kozlowski @ 2025-05-29 6:38 UTC (permalink / raw) To: Alexey Klimov Cc: Srinivas Kandagatla, Mark Brown, linux-sound, Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio On 28/05/2025 16:37, Alexey Klimov wrote: > On Fri May 23, 2025 at 9:12 AM BST, Krzysztof Kozlowski wrote: >> On Thu, May 22, 2025 at 06:40:52PM GMT, Alexey Klimov wrote: >>> The pattern matching incorrectly selects "wsa" because of "sa" substring >>> and evaluates it as a SoC component or block. >>> >>> Wsa88xx are family of amplifiers and should not be evaluated here. >>> >>> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> >>> --- >>> Documentation/devicetree/bindings/arm/qcom-soc.yaml | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/Documentation/devicetree/bindings/arm/qcom-soc.yaml b/Documentation/devicetree/bindings/arm/qcom-soc.yaml >>> index a77d68dcad4e52e4fee43729ac8dc1caf957262e..99521813a04ca416fe90454a811c4a13143efce3 100644 >>> --- a/Documentation/devicetree/bindings/arm/qcom-soc.yaml >>> +++ b/Documentation/devicetree/bindings/arm/qcom-soc.yaml >>> @@ -23,7 +23,7 @@ description: | >>> select: >>> properties: >>> compatible: >>> - pattern: "^qcom,.*(apq|ipq|mdm|msm|qcm|qcs|q[dr]u|sa|sar|sc|sd[amx]|sm|x1[ep])[0-9]+.*$" >>> + pattern: "^qcom,(?!.*wsa)(apq|ipq|mdm|msm|qcm|qcs|q[dr]u|sa|sar|sc|sd[amx]|smx1[ep])[0-9]+.*$" >> >> Why dropping front .*? Are you sure this matches what we want - so >> incorrect compatibles? To me it breaks the entire point of this select, >> so I am sure you did not test whether it still works. To remind: this is >> to select incorrect compatibles. > > Thanks, great point. I tested it with regular dtbs checks with different > dtb files but I didn't check if it selects incorrect compatibles. > > >> (?!wsa) >> Because qcom,x-wsa8845 should be matched and cause warnings. > > This is now confusing. I thought that the main job for the pattern above > is to avoid selecting wsa88xx amplifiers in the first place. Or, if I can > quote yourself: "What is WSA8815 that it should be here?" > > If said wsa8845 with incorrect or correct should be selected by that pattern > then why not just leave that pattern as it is then? I am lost. I guess I wanted to catch x-wsa8845 as well, but now never mind. It is not a soc so does not really matter for this file. > >> And probably we are getting past the point of readability, so could you >> try: >> >> compatible: >> anyOf: >> - pattern: "^qcom,.*(apq|ipq|mdm|msm|qcm|qcs|q[dr]u|sar|sc|sd[amx]|sm|x1[ep])[0-9]+.*$" >> - pattern: "^qcom,.*(?!wsa)sa[0-9]+.*$" Here should be: s/wsa/w/ Best regards, Krzysztof ^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v3 03/12] ASoC: dt-bindings: qcom,wsa881x: extend description to analog mode 2025-05-22 17:40 [PATCH v3 00/12] qrb4210-rb2: add wsa audio playback and capture support Alexey Klimov 2025-05-22 17:40 ` [PATCH v3 01/12] ASoC: dt-bindings: qcom: Add SM6115 LPASS rxmacro and vamacro codecs Alexey Klimov 2025-05-22 17:40 ` [PATCH v3 02/12] dt-bindings: arm: qcom-soc: ignore "wsa" from being selected as SoC component Alexey Klimov @ 2025-05-22 17:40 ` Alexey Klimov 2025-05-22 17:45 ` Krzysztof Kozlowski 2025-05-22 17:40 ` [PATCH v3 04/12] ASoC: codecs: lpass-rx-macro: add sm6115 compatible Alexey Klimov ` (9 subsequent siblings) 12 siblings, 1 reply; 43+ messages in thread From: Alexey Klimov @ 2025-05-22 17:40 UTC (permalink / raw) To: Srinivas Kandagatla, Mark Brown, linux-sound Cc: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio WSA881X also supports analog mode when device is configured via i2c only. Document it, add properties, new compatibles and example. Cc: Srinivas Kandagatla <srini@kernel.org> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> --- .../devicetree/bindings/sound/qcom,wsa881x.yaml | 66 +++++++++++++++++++--- 1 file changed, 58 insertions(+), 8 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/qcom,wsa881x.yaml b/Documentation/devicetree/bindings/sound/qcom,wsa881x.yaml index ac03672ebf6de1df862ce282f955ac91bdd9167d..a33e2754ec6159dbcaf5b6fcacf89eb2a6056899 100644 --- a/Documentation/devicetree/bindings/sound/qcom,wsa881x.yaml +++ b/Documentation/devicetree/bindings/sound/qcom,wsa881x.yaml @@ -12,15 +12,17 @@ maintainers: description: | WSA8810 is a class-D smart speaker amplifier and WSA8815 is a high-output power class-D smart speaker amplifier. - Their primary operating mode uses a SoundWire digital audio - interface. This binding is for SoundWire interface. - -allOf: - - $ref: dai-common.yaml# + This family of amplifiers support two operating modes: + SoundWire digital audio interface which is a primary mode + and analog mode when device is configured via i2c only. + This binding describes both modes. properties: compatible: - const: sdw10217201000 + enum: + - qcom,wsa8810 + - qcom,wsa8815 + - sdw10217201000 reg: maxItems: 1 @@ -35,17 +37,51 @@ properties: '#sound-dai-cells': const: 0 + clocks: + maxItems: 1 + + mclk-gpios: + description: GPIO spec for control signal to the clock gating circuit + maxItems: 1 + required: - compatible - reg - powerdown-gpios - - "#thermal-sensor-cells" - - "#sound-dai-cells" + - '#thermal-sensor-cells' + - '#sound-dai-cells' + +allOf: + - $ref: dai-common.yaml# + - if: + properties: + compatible: + contains: + enum: + - qcom,wsa8810 + - qcom,wsa8815 + then: + properties: + reg: + description: + In case of analog mode this should be I2C address of the digital + part of the device. The I2C address of analog part of an amplifier + is expected to be located at the fixed offset. + maxItems: 1 + items: + minimum: 0x0e + maximum: 0x0f + required: + - clocks + - mclk-gpios unevaluatedProperties: false examples: - | + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/sound/qcom,q6afe.h> + soundwire@c2d0000 { #address-cells = <2>; #size-cells = <0>; @@ -68,4 +104,18 @@ examples: }; }; + i2c { + #address-cells = <1>; + #size-cells = <0>; + + amplifier@e { + compatible = "qcom,wsa8810"; + reg = <0x0e>; + clocks = <&q6afecc LPASS_CLK_ID_MCLK_3 LPASS_CLK_ATTRIBUTE_COUPLE_NO>; + powerdown-gpios = <&lpass_tlmm 16 GPIO_ACTIVE_LOW>; + mclk-gpios = <&lpass_tlmm 18 GPIO_ACTIVE_HIGH>; + #sound-dai-cells = <0>; + #thermal-sensor-cells = <0>; + }; + }; ... -- 2.47.2 ^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH v3 03/12] ASoC: dt-bindings: qcom,wsa881x: extend description to analog mode 2025-05-22 17:40 ` [PATCH v3 03/12] ASoC: dt-bindings: qcom,wsa881x: extend description to analog mode Alexey Klimov @ 2025-05-22 17:45 ` Krzysztof Kozlowski 2025-05-27 20:34 ` Alexey Klimov 0 siblings, 1 reply; 43+ messages in thread From: Krzysztof Kozlowski @ 2025-05-22 17:45 UTC (permalink / raw) To: Alexey Klimov, Srinivas Kandagatla, Mark Brown, linux-sound Cc: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio On 22/05/2025 19:40, Alexey Klimov wrote: > WSA881X also supports analog mode when device is configured via i2c > only. Document it, add properties, new compatibles and example. > > Cc: Srinivas Kandagatla <srini@kernel.org> > Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> > --- > .../devicetree/bindings/sound/qcom,wsa881x.yaml | 66 +++++++++++++++++++--- > 1 file changed, 58 insertions(+), 8 deletions(-) > > diff --git a/Documentation/devicetree/bindings/sound/qcom,wsa881x.yaml b/Documentation/devicetree/bindings/sound/qcom,wsa881x.yaml > index ac03672ebf6de1df862ce282f955ac91bdd9167d..a33e2754ec6159dbcaf5b6fcacf89eb2a6056899 100644 > --- a/Documentation/devicetree/bindings/sound/qcom,wsa881x.yaml > +++ b/Documentation/devicetree/bindings/sound/qcom,wsa881x.yaml > @@ -12,15 +12,17 @@ maintainers: > description: | > WSA8810 is a class-D smart speaker amplifier and WSA8815 > is a high-output power class-D smart speaker amplifier. > - Their primary operating mode uses a SoundWire digital audio > - interface. This binding is for SoundWire interface. > - > -allOf: > - - $ref: dai-common.yaml# > + This family of amplifiers support two operating modes: > + SoundWire digital audio interface which is a primary mode > + and analog mode when device is configured via i2c only. > + This binding describes both modes. > > properties: > compatible: > - const: sdw10217201000 > + enum: > + - qcom,wsa8810 > + - qcom,wsa8815 > + - sdw10217201000 You never responded to my comments, never implemented them. Same problem as before. Best regards, Krzysztof ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v3 03/12] ASoC: dt-bindings: qcom,wsa881x: extend description to analog mode 2025-05-22 17:45 ` Krzysztof Kozlowski @ 2025-05-27 20:34 ` Alexey Klimov 2025-05-28 5:58 ` Krzysztof Kozlowski 0 siblings, 1 reply; 43+ messages in thread From: Alexey Klimov @ 2025-05-27 20:34 UTC (permalink / raw) To: Krzysztof Kozlowski Cc: Srinivas Kandagatla, Mark Brown, linux-sound, Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio On Thu May 22, 2025 at 6:45 PM BST, Krzysztof Kozlowski wrote: > On 22/05/2025 19:40, Alexey Klimov wrote: >> WSA881X also supports analog mode when device is configured via i2c >> only. Document it, add properties, new compatibles and example. >> >> Cc: Srinivas Kandagatla <srini@kernel.org> >> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> >> --- >> .../devicetree/bindings/sound/qcom,wsa881x.yaml | 66 +++++++++++++++++++--- >> 1 file changed, 58 insertions(+), 8 deletions(-) >> >> diff --git a/Documentation/devicetree/bindings/sound/qcom,wsa881x.yaml b/Documentation/devicetree/bindings/sound/qcom,wsa881x.yaml >> index ac03672ebf6de1df862ce282f955ac91bdd9167d..a33e2754ec6159dbcaf5b6fcacf89eb2a6056899 100644 >> --- a/Documentation/devicetree/bindings/sound/qcom,wsa881x.yaml >> +++ b/Documentation/devicetree/bindings/sound/qcom,wsa881x.yaml >> @@ -12,15 +12,17 @@ maintainers: >> description: | >> WSA8810 is a class-D smart speaker amplifier and WSA8815 >> is a high-output power class-D smart speaker amplifier. >> - Their primary operating mode uses a SoundWire digital audio >> - interface. This binding is for SoundWire interface. >> - >> -allOf: >> - - $ref: dai-common.yaml# >> + This family of amplifiers support two operating modes: >> + SoundWire digital audio interface which is a primary mode >> + and analog mode when device is configured via i2c only. >> + This binding describes both modes. >> >> properties: >> compatible: >> - const: sdw10217201000 >> + enum: >> + - qcom,wsa8810 >> + - qcom,wsa8815 >> + - sdw10217201000 > > You never responded to my comments, never implemented them. Same problem > as before. You don't respond to emails sometimes and, while I want to move this forward, I am not taking any chances replying to few months old thread, so if it okay I'll respond here. Sorry for doing this. Previous comment: >You implement only one compatible, so does it mean they are compatible? >If so, make them compatible. There are two compatibles in wsa881x-i2c.c. By looking at downstream sources and current code I think there is no diff between wsa8810 and wsa8815 and it is handled by reading hw registers if needed. So I am thinking that maybe it makes sense to reduce it to "qcom,wsa881x". Previous comment: >Do not repeat property name as description. Say something useful. "GPIO >spec for" is redundant, it cannot be anything else, so basically your >description saod "mclk" which is the same as in property name. >Usually clocks are not GPIOs, so description could explain that. Should the "GPIO spec for control signal to the clock gating circuit" be changed to "control signal to the clock gating circuit"? Previous comment: >That's not a valid syntax. Either enum or const. >This was never tested. >Why are you repeating the if? These parts are no longer present. Also i2c0 was changed to i2c in the example. Best regards, Alexey ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v3 03/12] ASoC: dt-bindings: qcom,wsa881x: extend description to analog mode 2025-05-27 20:34 ` Alexey Klimov @ 2025-05-28 5:58 ` Krzysztof Kozlowski 0 siblings, 0 replies; 43+ messages in thread From: Krzysztof Kozlowski @ 2025-05-28 5:58 UTC (permalink / raw) To: Alexey Klimov, Krzysztof Kozlowski Cc: Srinivas Kandagatla, Mark Brown, linux-sound, Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio On 27/05/2025 22:34, Alexey Klimov wrote: > On Thu May 22, 2025 at 6:45 PM BST, Krzysztof Kozlowski wrote: >> On 22/05/2025 19:40, Alexey Klimov wrote: >>> WSA881X also supports analog mode when device is configured via i2c >>> only. Document it, add properties, new compatibles and example. >>> >>> Cc: Srinivas Kandagatla <srini@kernel.org> >>> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> >>> --- >>> .../devicetree/bindings/sound/qcom,wsa881x.yaml | 66 +++++++++++++++++++--- >>> 1 file changed, 58 insertions(+), 8 deletions(-) >>> >>> diff --git a/Documentation/devicetree/bindings/sound/qcom,wsa881x.yaml b/Documentation/devicetree/bindings/sound/qcom,wsa881x.yaml >>> index ac03672ebf6de1df862ce282f955ac91bdd9167d..a33e2754ec6159dbcaf5b6fcacf89eb2a6056899 100644 >>> --- a/Documentation/devicetree/bindings/sound/qcom,wsa881x.yaml >>> +++ b/Documentation/devicetree/bindings/sound/qcom,wsa881x.yaml >>> @@ -12,15 +12,17 @@ maintainers: >>> description: | >>> WSA8810 is a class-D smart speaker amplifier and WSA8815 >>> is a high-output power class-D smart speaker amplifier. >>> - Their primary operating mode uses a SoundWire digital audio >>> - interface. This binding is for SoundWire interface. >>> - >>> -allOf: >>> - - $ref: dai-common.yaml# >>> + This family of amplifiers support two operating modes: >>> + SoundWire digital audio interface which is a primary mode >>> + and analog mode when device is configured via i2c only. >>> + This binding describes both modes. >>> >>> properties: >>> compatible: >>> - const: sdw10217201000 >>> + enum: >>> + - qcom,wsa8810 >>> + - qcom,wsa8815 >>> + - sdw10217201000 >> >> You never responded to my comments, never implemented them. Same problem >> as before. > > You don't respond to emails sometimes and, while I want to move this forward, > I am not taking any chances replying to few months old thread, so if it okay > I'll respond here. Sorry for doing this. > > Previous comment: > >> You implement only one compatible, so does it mean they are compatible? >> If so, make them compatible. > > There are two compatibles in wsa881x-i2c.c. > By looking at downstream sources and current code I think there is no diff > between wsa8810 and wsa8815 and it is handled by reading hw registers if > needed. So I am thinking that maybe it makes sense to reduce it to > "qcom,wsa881x". No, you need specific compatibles. That's the standard DT rule. Compatibility is expressed with list and fallback (see example-schema or any other qcom binding, really 95% of them have fallbacks). WSA usually have version registers so even if there are differences, they are fully detectable, thus one more argument for compatibility. > > Previous comment: >> Do not repeat property name as description. Say something useful. "GPIO >> spec for" is redundant, it cannot be anything else, so basically your >> description saod "mclk" which is the same as in property name. > >> Usually clocks are not GPIOs, so description could explain that. > > Should the "GPIO spec for control signal to the clock gating circuit" be > changed to "control signal to the clock gating circuit"? I don't see previous code, cannot even reference it via reply-to link/header. That way of communication is not effective. Best regards, Krzysztof ^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v3 04/12] ASoC: codecs: lpass-rx-macro: add sm6115 compatible 2025-05-22 17:40 [PATCH v3 00/12] qrb4210-rb2: add wsa audio playback and capture support Alexey Klimov ` (2 preceding siblings ...) 2025-05-22 17:40 ` [PATCH v3 03/12] ASoC: dt-bindings: qcom,wsa881x: extend description to analog mode Alexey Klimov @ 2025-05-22 17:40 ` Alexey Klimov 2025-05-22 17:49 ` Krzysztof Kozlowski 2025-05-22 17:40 ` [PATCH v3 05/12] ASoC: codecs: wsa881x: split into common and soundwire drivers Alexey Klimov ` (8 subsequent siblings) 12 siblings, 1 reply; 43+ messages in thread From: Alexey Klimov @ 2025-05-22 17:40 UTC (permalink / raw) To: Srinivas Kandagatla, Mark Brown, linux-sound Cc: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio, Srinivas Kandagatla Add rxmacro compatible for sm6115. Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> --- sound/soc/codecs/lpass-rx-macro.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c index 45a6b83808b277344f17d35a70cd1e3bb89cbaea..3ce7ad758df9fb0b7845a1dfef46cdf0ecf3b8c8 100644 --- a/sound/soc/codecs/lpass-rx-macro.c +++ b/sound/soc/codecs/lpass-rx-macro.c @@ -3946,7 +3946,9 @@ static const struct of_device_id rx_macro_dt_match[] = { { .compatible = "qcom,sc7280-lpass-rx-macro", .data = (void *)LPASS_MACRO_FLAG_HAS_NPL_CLOCK, - + }, { + .compatible = "qcom,sm6115-lpass-rx-macro", + .data = (void *)LPASS_MACRO_FLAG_HAS_NPL_CLOCK, }, { .compatible = "qcom,sm8250-lpass-rx-macro", .data = (void *)LPASS_MACRO_FLAG_HAS_NPL_CLOCK, -- 2.47.2 ^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH v3 04/12] ASoC: codecs: lpass-rx-macro: add sm6115 compatible 2025-05-22 17:40 ` [PATCH v3 04/12] ASoC: codecs: lpass-rx-macro: add sm6115 compatible Alexey Klimov @ 2025-05-22 17:49 ` Krzysztof Kozlowski 2025-05-27 16:42 ` Alexey Klimov 0 siblings, 1 reply; 43+ messages in thread From: Krzysztof Kozlowski @ 2025-05-22 17:49 UTC (permalink / raw) To: Alexey Klimov, Srinivas Kandagatla, Mark Brown, linux-sound Cc: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio On 22/05/2025 19:40, Alexey Klimov wrote: > Add rxmacro compatible for sm6115. > > Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> > Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> > --- > sound/soc/codecs/lpass-rx-macro.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c > index 45a6b83808b277344f17d35a70cd1e3bb89cbaea..3ce7ad758df9fb0b7845a1dfef46cdf0ecf3b8c8 100644 > --- a/sound/soc/codecs/lpass-rx-macro.c > +++ b/sound/soc/codecs/lpass-rx-macro.c > @@ -3946,7 +3946,9 @@ static const struct of_device_id rx_macro_dt_match[] = { > { > .compatible = "qcom,sc7280-lpass-rx-macro", > .data = (void *)LPASS_MACRO_FLAG_HAS_NPL_CLOCK, > - > + }, { > + .compatible = "qcom,sm6115-lpass-rx-macro", > + .data = (void *)LPASS_MACRO_FLAG_HAS_NPL_CLOCK, > }, { > .compatible = "qcom,sm8250-lpass-rx-macro", > .data = (void *)LPASS_MACRO_FLAG_HAS_NPL_CLOCK, So devices are compatible, thus why do we need this change? Best regards, Krzysztof ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v3 04/12] ASoC: codecs: lpass-rx-macro: add sm6115 compatible 2025-05-22 17:49 ` Krzysztof Kozlowski @ 2025-05-27 16:42 ` Alexey Klimov 0 siblings, 0 replies; 43+ messages in thread From: Alexey Klimov @ 2025-05-27 16:42 UTC (permalink / raw) To: Krzysztof Kozlowski, Srinivas Kandagatla, Mark Brown, linux-sound Cc: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio On Thu May 22, 2025 at 6:49 PM BST, Krzysztof Kozlowski wrote: > On 22/05/2025 19:40, Alexey Klimov wrote: >> Add rxmacro compatible for sm6115. >> >> Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> >> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> >> --- >> sound/soc/codecs/lpass-rx-macro.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c >> index 45a6b83808b277344f17d35a70cd1e3bb89cbaea..3ce7ad758df9fb0b7845a1dfef46cdf0ecf3b8c8 100644 >> --- a/sound/soc/codecs/lpass-rx-macro.c >> +++ b/sound/soc/codecs/lpass-rx-macro.c >> @@ -3946,7 +3946,9 @@ static const struct of_device_id rx_macro_dt_match[] = { >> { >> .compatible = "qcom,sc7280-lpass-rx-macro", >> .data = (void *)LPASS_MACRO_FLAG_HAS_NPL_CLOCK, >> - >> + }, { >> + .compatible = "qcom,sm6115-lpass-rx-macro", >> + .data = (void *)LPASS_MACRO_FLAG_HAS_NPL_CLOCK, >> }, { >> .compatible = "qcom,sm8250-lpass-rx-macro", >> .data = (void *)LPASS_MACRO_FLAG_HAS_NPL_CLOCK, > > So devices are compatible, thus why do we need this change? Ok, I'll link it to sm8250-lpass-rx-macro I guess. Thanks. Best regards, Alexey ^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v3 05/12] ASoC: codecs: wsa881x: split into common and soundwire drivers 2025-05-22 17:40 [PATCH v3 00/12] qrb4210-rb2: add wsa audio playback and capture support Alexey Klimov ` (3 preceding siblings ...) 2025-05-22 17:40 ` [PATCH v3 04/12] ASoC: codecs: lpass-rx-macro: add sm6115 compatible Alexey Klimov @ 2025-05-22 17:40 ` Alexey Klimov 2025-05-29 10:05 ` Srinivas Kandagatla 2025-05-22 17:40 ` [PATCH v3 06/12] ASoC: codecs: add wsa881x-i2c amplifier codec driver Alexey Klimov ` (7 subsequent siblings) 12 siblings, 1 reply; 43+ messages in thread From: Alexey Klimov @ 2025-05-22 17:40 UTC (permalink / raw) To: Srinivas Kandagatla, Mark Brown, linux-sound Cc: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio This is required in order to introduce wsa881x driver that works in analog mode and is configurable via i2c only. Functional changes, if any, are kept to be minimal and common parts or parts that can be shared are moved into wsa881x-common helper driver. The regmap config structure now contains 0x3000 offset as required by soundwire spec. While at this, also fix the typo in WSA881X_ADC_EN_SEL_IBIAS register name and rename wsa881x_set_sdw_stream() to wsa881x_set_stream() and update registers description in the header and use the new defines in wsa881x_init_common() and in wsa881x_digital_mute(). Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Cc: Srinivas Kandagatla <srini@kernel.org> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> --- sound/soc/codecs/Kconfig | 4 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/wsa881x-common.c | 193 +++++++++++++++ sound/soc/codecs/wsa881x-common.h | 458 +++++++++++++++++++++++++++++++++++ sound/soc/codecs/wsa881x.c | 493 +------------------------------------- 5 files changed, 669 insertions(+), 481 deletions(-) diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 8fe795504dbb5c91881e9de10f676c9d151b42d3..ba6e4504b5e9951203bd61fae894e86e9d40048e 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -2543,10 +2543,14 @@ config SND_SOC_WM9713 select REGMAP_AC97 select AC97_BUS_COMPAT if AC97_BUS_NEW +config SND_SOC_WSA881X_COMMON + tristate + config SND_SOC_WSA881X tristate "WSA881X Codec" depends on SOUNDWIRE select REGMAP_SOUNDWIRE + select SND_SOC_WSA881X_COMMON help This enables support for Qualcomm WSA8810/WSA8815 Class-D Smart Speaker Amplifier. diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index c92824713df0690998b76d43fcbe7c6e93dd5dd2..212d419cfe3c0fbd5d4e475e5d81c69ef930b3e1 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -406,6 +406,7 @@ snd-soc-wm9712-y := wm9712.o snd-soc-wm9713-y := wm9713.o snd-soc-wm-hubs-y := wm_hubs.o snd-soc-wsa881x-y := wsa881x.o +snd-soc-wsa881x-common-y := wsa881x-common.o snd-soc-wsa883x-y := wsa883x.o snd-soc-wsa884x-y := wsa884x.o snd-soc-zl38060-y := zl38060.o @@ -835,6 +836,7 @@ obj-$(CONFIG_SND_SOC_WM9713) += snd-soc-wm9713.o obj-$(CONFIG_SND_SOC_WM_ADSP) += snd-soc-wm-adsp.o obj-$(CONFIG_SND_SOC_WM_HUBS) += snd-soc-wm-hubs.o obj-$(CONFIG_SND_SOC_WSA881X) += snd-soc-wsa881x.o +obj-$(CONFIG_SND_SOC_WSA881X_COMMON) += snd-soc-wsa881x-common.o obj-$(CONFIG_SND_SOC_WSA883X) += snd-soc-wsa883x.o obj-$(CONFIG_SND_SOC_WSA884X) += snd-soc-wsa884x.o obj-$(CONFIG_SND_SOC_ZL38060) += snd-soc-zl38060.o diff --git a/sound/soc/codecs/wsa881x-common.c b/sound/soc/codecs/wsa881x-common.c new file mode 100644 index 0000000000000000000000000000000000000000..fbc431bd059544505647688db0d09e407589e330 --- /dev/null +++ b/sound/soc/codecs/wsa881x-common.c @@ -0,0 +1,193 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2024 Linaro Ltd + */ + +#include <linux/gpio/consumer.h> +#include <linux/module.h> +#include <linux/regmap.h> +#include <sound/soc.h> + +#include "wsa881x-common.h" + +int wsa881x_set_stream(struct snd_soc_dai *dai, void *stream, int direction) +{ +#if IS_ENABLED(CONFIG_SND_SOC_WSA881X) + struct wsa881x_priv *wsa881x = dev_get_drvdata(dai->dev); + + wsa881x->sruntime = stream; +#endif + return 0; +} +EXPORT_SYMBOL_GPL(wsa881x_set_stream); + +int wsa881x_digital_mute(struct snd_soc_dai *dai, int mute, int stream) +{ + struct snd_soc_component *component = dai->component; + + return snd_soc_component_update_bits(component, + WSA881X_SPKR_DRV_EN, + WSA881X_SPKR_DRV_EN_CLASS_PA_MASK, + mute ? + WSA881X_SPKR_DRV_EN_CLASS_PA_DIS : + WSA881X_SPKR_DRV_EN_CLASS_PA_EN); +} +EXPORT_SYMBOL_GPL(wsa881x_digital_mute); + +void wsa881x_init_common(struct wsa881x_priv *wsa881x) +{ + struct regmap *rm = wsa881x->regmap; + unsigned int val = 0; + + /* Bring out of analog reset */ + regmap_update_bits(rm, WSA881X_CDC_RST_CTL, + WSA881X_CDC_RST_CTL_ANA_RST, + WSA881X_CDC_RST_CTL_ANA_RST); + + /* Bring out of digital reset */ + regmap_update_bits(rm, WSA881X_CDC_RST_CTL, + WSA881X_CDC_RST_CTL_DIG_RST, + WSA881X_CDC_RST_CTL_DIG_RST); + regmap_update_bits(rm, WSA881X_CLOCK_CONFIG, + WSA881X_CLOCK_SCLK_SDM_DEM_DIV2_EN, + WSA881X_CLOCK_SCLK_SDM_DEM_DIV2_EN); + regmap_update_bits(rm, WSA881X_SPKR_OCP_CTL, + WSA881X_SPKR_OCP_CTL_RDAC_CLK_DIV2_MASK, + FIELD_PREP(WSA881X_SPKR_OCP_CTL_RDAC_CLK_DIV2_MASK, + WSA881X_SPKR_OCP_CTL_RDAC_CLK_DIV2)); + regmap_update_bits(rm, WSA881X_SPKR_MISC_CTL1, + WSA881X_SPKR_MISC_CTL1_DTIME_MASK, + FIELD_PREP(WSA881X_SPKR_MISC_CTL1_DTIME_MASK, + WSA881X_SPKR_MISC_CTL1_40NS)); + regmap_update_bits(rm, WSA881X_SPKR_MISC_CTL1, + WSA881X_SPKR_MISC_CTL1_SLEW_RATE_MASK, + FIELD_PREP(WSA881X_SPKR_MISC_CTL1_SLEW_RATE_MASK, + WSA881X_SPKR_MISC_CTL1_60NS)); + regmap_update_bits(rm, WSA881X_SPKR_BIAS_INT, + WSA881X_SPKR_BIAS_INT_FULL_MASK, + 0x0); + regmap_update_bits(rm, WSA881X_SPKR_PA_INT, + WSA881X_SPKR_PA_INT_COMP_CURR_MASK, + FIELD_PREP(WSA881X_SPKR_PA_INT_COMP_CURR_MASK, + WSA881X_SPKR_PA_INT_COMP_CURR_2UA0)); + regmap_update_bits(rm, WSA881X_SPKR_PA_INT, + WSA881X_SPKR_PA_INT_LDO_CURR_MASK, + FIELD_PREP(WSA881X_SPKR_PA_INT_LDO_CURR_MASK, + WSA881X_SPKR_PA_INT_LDO_CURR_5UA0)); + regmap_update_bits(rm, WSA881X_BOOST_LOOP_STABILITY, + WSA881X_BOOST_LOOP_STAB_COMP_RES_MASK, + FIELD_PREP(WSA881X_BOOST_LOOP_STAB_COMP_RES_MASK, + WSA881X_BOOST_LOOP_STAB_COMP_RES_400K)); + regmap_update_bits(rm, WSA881X_BOOST_MISC2_CTL, + WSA881X_BOOST_MISC2_CTL_FULL_MASK, + WSA881X_BOOST_MISC2_CTL_RST); + regmap_update_bits(rm, WSA881X_BOOST_START_CTL, + WSA881X_BOOST_START_CTL_FAST_TRAN_MASK, + WSA881X_BOOST_START_CTL_FAST_TRAN_EN); + regmap_update_bits(rm, WSA881X_BOOST_START_CTL, + WSA881X_BOOST_START_CTL_PULSE_SKIP_MASK, + FIELD_PREP(WSA881X_BOOST_START_CTL_PULSE_SKIP_MASK, + WSA881X_BOOST_START_CTL_PULSE_SKIP_50MA)); + regmap_update_bits(rm, WSA881X_BOOST_SLOPE_COMP_ISENSE_FB, + WSA881X_BOOST_SLOPE_ERR_CURR_MASK, + FIELD_PREP(WSA881X_BOOST_SLOPE_ERR_CURR_MASK, + WSA881X_BOOST_SLOPE_ERR_CURR_11UA)); + regmap_update_bits(rm, WSA881X_BOOST_SLOPE_COMP_ISENSE_FB, + WSA881X_BOOST_SLOPE_ISENSE_FB_MASK, + FIELD_PREP(WSA881X_BOOST_SLOPE_ISENSE_FB_MASK, + WSA881X_BOOST_SLOPE_ISENSE_FB_03)); + + regmap_read(rm, WSA881X_OTP_REG_0, &val); + if (val) + regmap_update_bits(rm, + WSA881X_BOOST_PRESET_OUT1, + WSA881X_BOOST_PRESET_OUT1_1ST_LVL_MASK, + FIELD_PREP(WSA881X_BOOST_PRESET_OUT1_1ST_LVL_MASK, + WSA881X_BOOST_PRESET_OUT1_5V5)); + + regmap_update_bits(rm, WSA881X_BOOST_PRESET_OUT2, + WSA881X_BOOST_PRESET_OUT2_3RD_LVL_MASK, + FIELD_PREP(WSA881X_BOOST_PRESET_OUT2_3RD_LVL_MASK, + WSA881X_BOOST_PRESET_OUT2_9V)); + regmap_update_bits(rm, WSA881X_SPKR_DRV_EN, + WSA881X_SPKR_DRV_EN_INT_LDO_VOUT_MASK, + FIELD_PREP(WSA881X_SPKR_DRV_EN_INT_LDO_VOUT_MASK, + WSA881X_SPKR_DRV_EN_INT_LDO_VOUT_5V5)); + regmap_update_bits(rm, WSA881X_BOOST_CURRENT_LIMIT, + WSA881X_BOOST_CURRENT_LIMIT_SET_MASK, + FIELD_PREP(WSA881X_BOOST_CURRENT_LIMIT_SET_MASK, + WSA881X_BOOST_CURRENT_LIMIT_SET_4A)); + regmap_update_bits(rm, WSA881X_SPKR_OCP_CTL, + WSA881X_SPKR_OCP_CTL_CURR_LIMIT_MASK, + FIELD_PREP(WSA881X_SPKR_OCP_CTL_CURR_LIMIT_MASK, + WSA881X_SPKR_OCP_CTL_CURR_LIMIT_5A)); + regmap_update_bits(rm, WSA881X_SPKR_OCP_CTL, + WSA881X_SPKR_OCP_CTL_GLITCH_FLT_MASK, + FIELD_PREP(WSA881X_SPKR_OCP_CTL_GLITCH_FLT_MASK, + WSA881X_SPKR_OCP_CTL_GLITCH_FLT_128NS)); + regmap_update_bits(rm, WSA881X_OTP_REG_28, + WSA881X_OTP_REG_28_ISENSE_CAL_MASK, + FIELD_PREP(WSA881X_OTP_REG_28_ISENSE_CAL_MASK, + WSA881X_OTP_REG_28_ISENSE_CAL_RST_VAL)); + regmap_update_bits(rm, WSA881X_BONGO_RESRV_REG1, + WSA881X_BONGO_RESRV_REG1_TEMP_CMP_MASK, + WSA881X_BONGO_RESRV_REG1_TEMP_CMP_EN); + regmap_update_bits(rm, WSA881X_BONGO_RESRV_REG1, + WSA881X_BONGO_RESRV_REG1_ISENSE_MASK, + FIELD_PREP(WSA881X_BONGO_RESRV_REG1_ISENSE_MASK, + WSA881X_BONGO_RESRV_REG1_ISENSE_RST_VAL)); + regmap_update_bits(rm, WSA881X_BONGO_RESRV_REG1, + WSA881X_BONGO_RESRV_REG1_ATEST_MASK, + WSA881X_BONGO_RESRV_REG1_ATEST_DIS); + regmap_update_bits(rm, WSA881X_BONGO_RESRV_REG2, + WSA881X_BONGO_RESRV_REG2_FULL_MASK, + WSA881X_BONGO_RESRV_REG2_RST_VAL); +} +EXPORT_SYMBOL_GPL(wsa881x_init_common); + +int wsa881x_probe_common(struct wsa881x_priv **wsa881x, struct device *dev) +{ + struct wsa881x_priv *wsa; + + wsa = devm_kzalloc(dev, sizeof(*wsa), GFP_KERNEL); + if (!wsa) + return -ENOMEM; + + wsa->dev = dev; + wsa->sd_n = devm_gpiod_get_optional(dev, "powerdown", + GPIOD_FLAGS_BIT_NONEXCLUSIVE); + if (IS_ERR(wsa->sd_n)) + return dev_err_probe(dev, PTR_ERR(wsa->sd_n), + "Shutdown Control GPIO not found\n"); + /* + * Backwards compatibility work-around. + * + * The SD_N GPIO is active low, however upstream DTS used always active + * high. Changing the flag in driver and DTS will break backwards + * compatibility, so add a simple value inversion to work with both old + * and new DTS. + * + * This won't work properly with DTS using the flags properly in cases: + * 1. Old DTS with proper ACTIVE_LOW, however such case was broken + * before as the driver required the active high. + * 2. New DTS with proper ACTIVE_HIGH (intended), which is rare case + * (not existing upstream) but possible. This is the price of + * backwards compatibility, therefore this hack should be removed at + * some point. + */ + wsa->sd_n_val = gpiod_is_active_low(wsa->sd_n); + if (!wsa->sd_n_val) + dev_warn(dev, + "Using ACTIVE_HIGH for shutdown GPIO. Your DTB might be outdated or you use unsupported configuration for the GPIO.\n"); + + dev_set_drvdata(dev, wsa); + gpiod_direction_output(wsa->sd_n, !wsa->sd_n_val); + + *wsa881x = wsa; + + return 0; +} +EXPORT_SYMBOL_GPL(wsa881x_probe_common); + +MODULE_DESCRIPTION("WSA881x codec helper driver"); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/codecs/wsa881x-common.h b/sound/soc/codecs/wsa881x-common.h new file mode 100644 index 0000000000000000000000000000000000000000..ab4ee5848b10fe6ca4160b7ff634e7e06b6e41e6 --- /dev/null +++ b/sound/soc/codecs/wsa881x-common.h @@ -0,0 +1,458 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __WSA881x_COMMON_H__ +#define __WSA881x_COMMON_H__ + +#include <linux/soundwire/sdw.h> +#include <sound/soc.h> + +#define WSA881X_MAX_SWR_PORTS 4 + +#define WSA881X_DIGITAL_BASE 0x0000 +#define WSA881X_ANALOG_BASE 0x0100 + +/* Digital register address space */ +#define WSA881X_CHIP_ID0 (WSA881X_DIGITAL_BASE + 0x0000) +#define WSA881X_CHIP_ID1 (WSA881X_DIGITAL_BASE + 0x0001) +#define WSA881X_CHIP_ID2 (WSA881X_DIGITAL_BASE + 0x0002) +#define WSA881X_CHIP_ID3 (WSA881X_DIGITAL_BASE + 0x0003) +#define WSA881X_BUS_ID (WSA881X_DIGITAL_BASE + 0x0004) +#define WSA881X_CDC_RST_CTL (WSA881X_DIGITAL_BASE + 0x0005) +#define WSA881X_CDC_RST_CTL_ANA_RST BIT(1) +#define WSA881X_CDC_RST_CTL_DIG_RST BIT(0) +#define WSA881X_CDC_TOP_CLK_CTL (WSA881X_DIGITAL_BASE + 0x0006) +#define WSA881X_CDC_ANA_CLK_CTL (WSA881X_DIGITAL_BASE + 0x0007) +#define WSA881X_CDC_DIG_CLK_CTL (WSA881X_DIGITAL_BASE + 0x0008) +#define WSA881X_CLOCK_CONFIG (WSA881X_DIGITAL_BASE + 0x0009) +#define WSA881X_CLOCK_SCLK_SDM_DEM_DIV2_EN BIT(4) +#define WSA881X_ANA_CTL (WSA881X_DIGITAL_BASE + 0x000A) +#define WSA881X_SWR_RESET_EN (WSA881X_DIGITAL_BASE + 0x000B) +#define WSA881X_RESET_CTL (WSA881X_DIGITAL_BASE + 0x000C) +#define WSA881X_TADC_VALUE_CTL (WSA881X_DIGITAL_BASE + 0x000F) +#define WSA881X_TEMP_DETECT_CTL (WSA881X_DIGITAL_BASE + 0x0010) +#define WSA881X_TEMP_MSB (WSA881X_DIGITAL_BASE + 0x0011) +#define WSA881X_TEMP_LSB (WSA881X_DIGITAL_BASE + 0x0012) +#define WSA881X_TEMP_CONFIG0 (WSA881X_DIGITAL_BASE + 0x0013) +#define WSA881X_TEMP_CONFIG1 (WSA881X_DIGITAL_BASE + 0x0014) +#define WSA881X_CDC_CLIP_CTL (WSA881X_DIGITAL_BASE + 0x0015) +#define WSA881X_SDM_PDM9_LSB (WSA881X_DIGITAL_BASE + 0x0016) +#define WSA881X_SDM_PDM9_MSB (WSA881X_DIGITAL_BASE + 0x0017) +#define WSA881X_CDC_RX_CTL (WSA881X_DIGITAL_BASE + 0x0018) +#define WSA881X_DEM_BYPASS_DATA0 (WSA881X_DIGITAL_BASE + 0x0019) +#define WSA881X_DEM_BYPASS_DATA1 (WSA881X_DIGITAL_BASE + 0x001A) +#define WSA881X_DEM_BYPASS_DATA2 (WSA881X_DIGITAL_BASE + 0x001B) +#define WSA881X_DEM_BYPASS_DATA3 (WSA881X_DIGITAL_BASE + 0x001C) +#define WSA881X_OTP_CTRL0 (WSA881X_DIGITAL_BASE + 0x001D) +#define WSA881X_OTP_CTRL1 (WSA881X_DIGITAL_BASE + 0x001E) +#define WSA881X_HDRIVE_CTL_GROUP1 (WSA881X_DIGITAL_BASE + 0x001F) +#define WSA881X_INTR_MODE (WSA881X_DIGITAL_BASE + 0x0020) +#define WSA881X_INTR_MASK (WSA881X_DIGITAL_BASE + 0x0021) +#define WSA881X_INTR_STATUS (WSA881X_DIGITAL_BASE + 0x0022) +#define WSA881X_INTR_CLEAR (WSA881X_DIGITAL_BASE + 0x0023) +#define WSA881X_INTR_LEVEL (WSA881X_DIGITAL_BASE + 0x0024) +#define WSA881X_INTR_SET (WSA881X_DIGITAL_BASE + 0x0025) +#define WSA881X_INTR_TEST (WSA881X_DIGITAL_BASE + 0x0026) +#define WSA881X_PDM_TEST_MODE (WSA881X_DIGITAL_BASE + 0x0030) +#define WSA881X_ATE_TEST_MODE (WSA881X_DIGITAL_BASE + 0x0031) +#define WSA881X_PIN_CTL_MODE (WSA881X_DIGITAL_BASE + 0x0032) +#define WSA881X_PIN_CTL_OE (WSA881X_DIGITAL_BASE + 0x0033) +#define WSA881X_PIN_WDATA_IOPAD (WSA881X_DIGITAL_BASE + 0x0034) +#define WSA881X_PIN_STATUS (WSA881X_DIGITAL_BASE + 0x0035) +#define WSA881X_DIG_DEBUG_MODE (WSA881X_DIGITAL_BASE + 0x0037) +#define WSA881X_DIG_DEBUG_SEL (WSA881X_DIGITAL_BASE + 0x0038) +#define WSA881X_DIG_DEBUG_EN (WSA881X_DIGITAL_BASE + 0x0039) +#define WSA881X_SWR_HM_TEST1 (WSA881X_DIGITAL_BASE + 0x003B) +#define WSA881X_SWR_HM_TEST2 (WSA881X_DIGITAL_BASE + 0x003C) +#define WSA881X_TEMP_DETECT_DBG_CTL (WSA881X_DIGITAL_BASE + 0x003D) +#define WSA881X_TEMP_DEBUG_MSB (WSA881X_DIGITAL_BASE + 0x003E) +#define WSA881X_TEMP_DEBUG_LSB (WSA881X_DIGITAL_BASE + 0x003F) +#define WSA881X_SAMPLE_EDGE_SEL (WSA881X_DIGITAL_BASE + 0x0044) +#define WSA881X_IOPAD_CTL (WSA881X_DIGITAL_BASE + 0x0045) +#define WSA881X_SPARE_0 (WSA881X_DIGITAL_BASE + 0x0050) +#define WSA881X_SPARE_1 (WSA881X_DIGITAL_BASE + 0x0051) +#define WSA881X_SPARE_2 (WSA881X_DIGITAL_BASE + 0x0052) +#define WSA881X_OTP_REG_0 (WSA881X_DIGITAL_BASE + 0x0080) +#define WSA881X_OTP_REG_1 (WSA881X_DIGITAL_BASE + 0x0081) +#define WSA881X_OTP_REG_2 (WSA881X_DIGITAL_BASE + 0x0082) +#define WSA881X_OTP_REG_3 (WSA881X_DIGITAL_BASE + 0x0083) +#define WSA881X_OTP_REG_4 (WSA881X_DIGITAL_BASE + 0x0084) +#define WSA881X_OTP_REG_5 (WSA881X_DIGITAL_BASE + 0x0085) +#define WSA881X_OTP_REG_6 (WSA881X_DIGITAL_BASE + 0x0086) +#define WSA881X_OTP_REG_7 (WSA881X_DIGITAL_BASE + 0x0087) +#define WSA881X_OTP_REG_8 (WSA881X_DIGITAL_BASE + 0x0088) +#define WSA881X_OTP_REG_9 (WSA881X_DIGITAL_BASE + 0x0089) +#define WSA881X_OTP_REG_10 (WSA881X_DIGITAL_BASE + 0x008A) +#define WSA881X_OTP_REG_11 (WSA881X_DIGITAL_BASE + 0x008B) +#define WSA881X_OTP_REG_12 (WSA881X_DIGITAL_BASE + 0x008C) +#define WSA881X_OTP_REG_13 (WSA881X_DIGITAL_BASE + 0x008D) +#define WSA881X_OTP_REG_14 (WSA881X_DIGITAL_BASE + 0x008E) +#define WSA881X_OTP_REG_15 (WSA881X_DIGITAL_BASE + 0x008F) +#define WSA881X_OTP_REG_16 (WSA881X_DIGITAL_BASE + 0x0090) +#define WSA881X_OTP_REG_17 (WSA881X_DIGITAL_BASE + 0x0091) +#define WSA881X_OTP_REG_18 (WSA881X_DIGITAL_BASE + 0x0092) +#define WSA881X_OTP_REG_19 (WSA881X_DIGITAL_BASE + 0x0093) +#define WSA881X_OTP_REG_20 (WSA881X_DIGITAL_BASE + 0x0094) +#define WSA881X_OTP_REG_21 (WSA881X_DIGITAL_BASE + 0x0095) +#define WSA881X_OTP_REG_22 (WSA881X_DIGITAL_BASE + 0x0096) +#define WSA881X_OTP_REG_23 (WSA881X_DIGITAL_BASE + 0x0097) +#define WSA881X_OTP_REG_24 (WSA881X_DIGITAL_BASE + 0x0098) +#define WSA881X_OTP_REG_25 (WSA881X_DIGITAL_BASE + 0x0099) +#define WSA881X_OTP_REG_26 (WSA881X_DIGITAL_BASE + 0x009A) +#define WSA881X_OTP_REG_27 (WSA881X_DIGITAL_BASE + 0x009B) +#define WSA881X_OTP_REG_28 (WSA881X_DIGITAL_BASE + 0x009C) +#define WSA881X_OTP_REG_28_ISENSE_CAL_MASK GENMASK(5, 0) +#define WSA881X_OTP_REG_28_ISENSE_CAL_RST_VAL (0x3A) +#define WSA881X_OTP_REG_29 (WSA881X_DIGITAL_BASE + 0x009D) +#define WSA881X_OTP_REG_30 (WSA881X_DIGITAL_BASE + 0x009E) +#define WSA881X_OTP_REG_31 (WSA881X_DIGITAL_BASE + 0x009F) +#define WSA881X_OTP_REG_63 (WSA881X_DIGITAL_BASE + 0x00BF) + +/* Analog Register address space */ +#define WSA881X_BIAS_REF_CTRL (WSA881X_ANALOG_BASE + 0x0000) +#define WSA881X_BIAS_TEST (WSA881X_ANALOG_BASE + 0x0001) +#define WSA881X_BIAS_BIAS (WSA881X_ANALOG_BASE + 0x0002) +#define WSA881X_TEMP_OP (WSA881X_ANALOG_BASE + 0x0003) +#define WSA881X_TEMP_IREF_CTRL (WSA881X_ANALOG_BASE + 0x0004) +#define WSA881X_TEMP_ISENS_CTRL (WSA881X_ANALOG_BASE + 0x0005) +#define WSA881X_TEMP_CLK_CTRL (WSA881X_ANALOG_BASE + 0x0006) +#define WSA881X_TEMP_TEST (WSA881X_ANALOG_BASE + 0x0007) +#define WSA881X_TEMP_BIAS (WSA881X_ANALOG_BASE + 0x0008) +#define WSA881X_TEMP_ADC_CTRL (WSA881X_ANALOG_BASE + 0x0009) +#define WSA881X_TEMP_DOUT_MSB (WSA881X_ANALOG_BASE + 0x000A) +#define WSA881X_TEMP_DOUT_LSB (WSA881X_ANALOG_BASE + 0x000B) +#define WSA881X_ADC_EN_MODU_V (WSA881X_ANALOG_BASE + 0x0010) +#define WSA881X_ADC_EN_MODU_I (WSA881X_ANALOG_BASE + 0x0011) +#define WSA881X_ADC_EN_DET_TEST_V (WSA881X_ANALOG_BASE + 0x0012) +#define WSA881X_ADC_EN_DET_TEST_I (WSA881X_ANALOG_BASE + 0x0013) +#define WSA881X_ADC_SEL_IBIAS (WSA881X_ANALOG_BASE + 0x0014) +#define WSA881X_ADC_EN_SEL_IBIAS (WSA881X_ANALOG_BASE + 0x0015) +#define WSA881X_SPKR_DRV_EN (WSA881X_ANALOG_BASE + 0x001A) +#define WSA881X_SPKR_DRV_EN_CLASS_PA_MASK BIT(7) +#define WSA881X_SPKR_DRV_EN_CLASS_PA_DIS 0 +#define WSA881X_SPKR_DRV_EN_CLASS_PA_EN BIT(7) +#define WSA881X_SPKR_DRV_EN_INT_LDO_VOUT_MASK BIT(3) +#define WSA881X_SPKR_DRV_EN_INT_LDO_VOUT_5V 0 +#define WSA881X_SPKR_DRV_EN_INT_LDO_VOUT_5V5 1 +#define WSA881X_SPKR_DRV_GAIN (WSA881X_ANALOG_BASE + 0x001B) +#define WSA881X_PA_GAIN_SEL_MASK BIT(3) +#define WSA881X_PA_GAIN_SEL_REG BIT(3) +#define WSA881X_PA_GAIN_SEL_DRE 0 +#define WSA881X_SPKR_PAG_GAIN_MASK GENMASK(7, 4) +#define WSA881X_SPKR_DAC_CTL (WSA881X_ANALOG_BASE + 0x001C) +#define WSA881X_SPKR_DRV_DBG (WSA881X_ANALOG_BASE + 0x001D) +#define WSA881X_SPKR_PWRSTG_DBG (WSA881X_ANALOG_BASE + 0x001E) +#define WSA881X_SPKR_OCP_CTL (WSA881X_ANALOG_BASE + 0x001F) +#define WSA881X_SPKR_OCP_MASK GENMASK(7, 6) +#define WSA881X_SPKR_OCP_CTL_CURR_LIMIT_MASK GENMASK(5, 4) +#define WSA881X_SPKR_OCP_CTL_GLITCH_FLT_MASK GENMASK(3, 2) +#define WSA881X_SPKR_OCP_CTL_CURR_LIMIT_5A (BIT(1) | BIT(0)) +#define WSA881X_SPKR_OCP_CTL_GLITCH_FLT_128NS 0 +#define WSA881X_SPKR_OCP_CTL_RDAC_CLK_DIV2_MASK BIT(1) +#define WSA881X_SPKR_OCP_CTL_RDAC_CLK_DIV2 1 +#define WSA881X_SPKR_OCP_EN BIT(7) +#define WSA881X_SPKR_OCP_HOLD BIT(6) +#define WSA881X_SPKR_CLIP_CTL (WSA881X_ANALOG_BASE + 0x0020) +#define WSA881X_SPKR_BBM_CTL (WSA881X_ANALOG_BASE + 0x0021) +#define WSA881X_SPKR_MISC_CTL1 (WSA881X_ANALOG_BASE + 0x0022) +#define WSA881X_SPKR_MISC_CTL1_DTIME_MASK GENMASK(7, 6) +#define WSA881X_SPKR_MISC_CTL1_SLEW_RATE_MASK GENMASK(2, 1) +#define WSA881X_SPKR_MISC_CTL1_60NS (BIT(1) | BIT(0)) +#define WSA881X_SPKR_MISC_CTL1_40NS BIT(1) +#define WSA881X_SPKR_MISC_CTL2 (WSA881X_ANALOG_BASE + 0x0023) +#define WSA881X_SPKR_BIAS_INT (WSA881X_ANALOG_BASE + 0x0024) +#define WSA881X_SPKR_BIAS_INT_FULL_MASK ((u8)~0U) +#define WSA881X_SPKR_PA_INT (WSA881X_ANALOG_BASE + 0x0025) +#define WSA881X_SPKR_PA_INT_COMP_CURR_MASK GENMASK(7, 4) +#define WSA881X_SPKR_PA_INT_LDO_CURR_MASK GENMASK(3, 1) +#define WSA881X_SPKR_PA_INT_COMP_CURR_2UA0 BIT(2) +#define WSA881X_SPKR_PA_INT_LDO_CURR_5UA0 (BIT(2) | BIT(1) | BIT(0)) +#define WSA881X_SPKR_BIAS_CAL (WSA881X_ANALOG_BASE + 0x0026) +#define WSA881X_SPKR_BIAS_PSRR (WSA881X_ANALOG_BASE + 0x0027) +#define WSA881X_SPKR_STATUS1 (WSA881X_ANALOG_BASE + 0x0028) +#define WSA881X_SPKR_STATUS2 (WSA881X_ANALOG_BASE + 0x0029) +#define WSA881X_BOOST_EN_CTL (WSA881X_ANALOG_BASE + 0x002A) +#define WSA881X_BOOST_EN_MASK BIT(7) +#define WSA881X_BOOST_EN BIT(7) +#define WSA881X_BOOST_CURRENT_LIMIT (WSA881X_ANALOG_BASE + 0x002B) +#define WSA881X_BOOST_CURRENT_LIMIT_SET_MASK GENMASK(3, 0) +#define WSA881X_BOOST_CURRENT_LIMIT_SET_4A BIT(3) +#define WSA881X_BOOST_PS_CTL (WSA881X_ANALOG_BASE + 0x002C) +#define WSA881X_BOOST_PRESET_OUT1 (WSA881X_ANALOG_BASE + 0x002D) +#define WSA881X_BOOST_PRESET_OUT1_1ST_LVL_MASK GENMASK(7, 4) +#define WSA881X_BOOST_PRESET_OUT1_5V5 (BIT(2) | BIT(1) | BIT(0)) +#define WSA881X_BOOST_PRESET_OUT2 (WSA881X_ANALOG_BASE + 0x002E) +#define WSA881X_BOOST_PRESET_OUT2_3RD_LVL_MASK GENMASK(7, 4) +#define WSA881X_BOOST_PRESET_OUT2_9V (BIT(1) | BIT(0)) +#define WSA881X_BOOST_FORCE_OUT (WSA881X_ANALOG_BASE + 0x002F) +#define WSA881X_BOOST_LDO_PROG (WSA881X_ANALOG_BASE + 0x0030) +#define WSA881X_BOOST_SLOPE_COMP_ISENSE_FB (WSA881X_ANALOG_BASE + 0x0031) +#define WSA881X_BOOST_SLOPE_ERR_CURR_MASK GENMASK(3, 2) +#define WSA881X_BOOST_SLOPE_ISENSE_FB_MASK GENMASK(1, 0) +#define WSA881X_BOOST_SLOPE_ERR_CURR_11UA BIT(0) +#define WSA881X_BOOST_SLOPE_ISENSE_FB_03 0 +#define WSA881X_BOOST_RON_CTL (WSA881X_ANALOG_BASE + 0x0032) +#define WSA881X_BOOST_LOOP_STABILITY (WSA881X_ANALOG_BASE + 0x0033) +#define WSA881X_BOOST_LOOP_STAB_COMP_RES_MASK GENMASK(1, 0) +#define WSA881X_BOOST_LOOP_STAB_COMP_RES_400K (BIT(1) | BIT(0)) +#define WSA881X_BOOST_ZX_CTL (WSA881X_ANALOG_BASE + 0x0034) +#define WSA881X_BOOST_START_CTL (WSA881X_ANALOG_BASE + 0x0035) +#define WSA881X_BOOST_START_CTL_FAST_TRAN_MASK BIT(7) +#define WSA881X_BOOST_START_CTL_PULSE_SKIP_MASK GENMASK(1, 0) +#define WSA881X_BOOST_START_CTL_FAST_TRAN_EN BIT(7) +#define WSA881X_BOOST_START_CTL_PULSE_SKIP_50MA 0 +#define WSA881X_BOOST_MISC1_CTL (WSA881X_ANALOG_BASE + 0x0036) +#define WSA881X_BOOST_MISC2_CTL (WSA881X_ANALOG_BASE + 0x0037) +#define WSA881X_BOOST_MISC2_CTL_FULL_MASK ((u8)~0U) +#define WSA881X_BOOST_MISC2_CTL_RST (BIT(4) | BIT(2)) +#define WSA881X_BOOST_MISC3_CTL (WSA881X_ANALOG_BASE + 0x0038) +#define WSA881X_BOOST_ATEST_CTL (WSA881X_ANALOG_BASE + 0x0039) +#define WSA881X_SPKR_PROT_FE_GAIN (WSA881X_ANALOG_BASE + 0x003A) +#define WSA881X_SPKR_PROT_FE_CM_LDO_SET (WSA881X_ANALOG_BASE + 0x003B) +#define WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET1 (WSA881X_ANALOG_BASE + 0x003C) +#define WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET2 (WSA881X_ANALOG_BASE + 0x003D) +#define WSA881X_SPKR_PROT_ATEST1 (WSA881X_ANALOG_BASE + 0x003E) +#define WSA881X_SPKR_PROT_ATEST2 (WSA881X_ANALOG_BASE + 0x003F) +#define WSA881X_SPKR_PROT_FE_VSENSE_VCM (WSA881X_ANALOG_BASE + 0x0040) +#define WSA881X_SPKR_PROT_FE_VSENSE_BIAS_SET1 (WSA881X_ANALOG_BASE + 0x0041) +#define WSA881X_BONGO_RESRV_REG1 (WSA881X_ANALOG_BASE + 0x0042) +#define WSA881X_BONGO_RESRV_REG1_TEMP_CMP_MASK BIT(7) +#define WSA881X_BONGO_RESRV_REG1_ISENSE_MASK GENMASK(6, 1) +#define WSA881X_BONGO_RESRV_REG1_ATEST_MASK BIT(0) +#define WSA881X_BONGO_RESRV_REG1_TEMP_CMP_EN BIT(7) +#define WSA881X_BONGO_RESRV_REG1_ISENSE_RST_VAL (BIT(4) | BIT(3) | BIT(0)) +#define WSA881X_BONGO_RESRV_REG1_ATEST_DIS 0 +#define WSA881X_BONGO_RESRV_REG2 (WSA881X_ANALOG_BASE + 0x0043) +#define WSA881X_BONGO_RESRV_REG2_FULL_MASK ((u8)~0U) +#define WSA881X_BONGO_RESRV_REG2_RST_VAL (0x5) +#define WSA881X_SPKR_PROT_SAR (WSA881X_ANALOG_BASE + 0x0044) +#define WSA881X_SPKR_STATUS3 (WSA881X_ANALOG_BASE + 0x0045) + +/* + * Private data Structure for wsa881x. All parameters related to + * WSA881X codec needs to be defined here. + */ +struct wsa881x_priv { + struct regmap *regmap; + struct device *dev; + +#if IS_ENABLED(CONFIG_SND_SOC_WSA881X) + /* Soundwire interface */ + struct sdw_slave *slave; + struct sdw_stream_config sconfig; + struct sdw_stream_runtime *sruntime; + struct sdw_port_config port_config[WSA881X_MAX_SWR_PORTS]; + int active_ports; + bool port_prepared[WSA881X_MAX_SWR_PORTS]; + bool port_enable[WSA881X_MAX_SWR_PORTS]; +#endif + + struct gpio_desc *sd_n; + /* + * Logical state for SD_N GPIO: high for shutdown, low for enable. + * For backwards compatibility. + */ + unsigned int sd_n_val; +}; + +void wsa881x_init_common(struct wsa881x_priv *wsa881x); +int wsa881x_probe_common(struct wsa881x_priv **wsa881x, struct device *dev); +int wsa881x_digital_mute(struct snd_soc_dai *dai, int mute, int stream); +int wsa881x_set_stream(struct snd_soc_dai *dai, void *stream, int direction); + +static inline bool wsa881x_readable_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case WSA881X_CHIP_ID0: + case WSA881X_CHIP_ID1: + case WSA881X_CHIP_ID2: + case WSA881X_CHIP_ID3: + case WSA881X_BUS_ID: + case WSA881X_CDC_RST_CTL: + case WSA881X_CDC_TOP_CLK_CTL: + case WSA881X_CDC_ANA_CLK_CTL: + case WSA881X_CDC_DIG_CLK_CTL: + case WSA881X_CLOCK_CONFIG: + case WSA881X_ANA_CTL: + case WSA881X_SWR_RESET_EN: + case WSA881X_RESET_CTL: + case WSA881X_TADC_VALUE_CTL: + case WSA881X_TEMP_DETECT_CTL: + case WSA881X_TEMP_MSB: + case WSA881X_TEMP_LSB: + case WSA881X_TEMP_CONFIG0: + case WSA881X_TEMP_CONFIG1: + case WSA881X_CDC_CLIP_CTL: + case WSA881X_SDM_PDM9_LSB: + case WSA881X_SDM_PDM9_MSB: + case WSA881X_CDC_RX_CTL: + case WSA881X_DEM_BYPASS_DATA0: + case WSA881X_DEM_BYPASS_DATA1: + case WSA881X_DEM_BYPASS_DATA2: + case WSA881X_DEM_BYPASS_DATA3: + case WSA881X_OTP_CTRL0: + case WSA881X_OTP_CTRL1: + case WSA881X_HDRIVE_CTL_GROUP1: + case WSA881X_INTR_MODE: + case WSA881X_INTR_MASK: + case WSA881X_INTR_STATUS: + case WSA881X_INTR_CLEAR: + case WSA881X_INTR_LEVEL: + case WSA881X_INTR_SET: + case WSA881X_INTR_TEST: + case WSA881X_PDM_TEST_MODE: + case WSA881X_ATE_TEST_MODE: + case WSA881X_PIN_CTL_MODE: + case WSA881X_PIN_CTL_OE: + case WSA881X_PIN_WDATA_IOPAD: + case WSA881X_PIN_STATUS: + case WSA881X_DIG_DEBUG_MODE: + case WSA881X_DIG_DEBUG_SEL: + case WSA881X_DIG_DEBUG_EN: + case WSA881X_SWR_HM_TEST1: + case WSA881X_SWR_HM_TEST2: + case WSA881X_TEMP_DETECT_DBG_CTL: + case WSA881X_TEMP_DEBUG_MSB: + case WSA881X_TEMP_DEBUG_LSB: + case WSA881X_SAMPLE_EDGE_SEL: + case WSA881X_IOPAD_CTL: + case WSA881X_SPARE_0: + case WSA881X_SPARE_1: + case WSA881X_SPARE_2: + case WSA881X_OTP_REG_0: + case WSA881X_OTP_REG_1: + case WSA881X_OTP_REG_2: + case WSA881X_OTP_REG_3: + case WSA881X_OTP_REG_4: + case WSA881X_OTP_REG_5: + case WSA881X_OTP_REG_6: + case WSA881X_OTP_REG_7: + case WSA881X_OTP_REG_8: + case WSA881X_OTP_REG_9: + case WSA881X_OTP_REG_10: + case WSA881X_OTP_REG_11: + case WSA881X_OTP_REG_12: + case WSA881X_OTP_REG_13: + case WSA881X_OTP_REG_14: + case WSA881X_OTP_REG_15: + case WSA881X_OTP_REG_16: + case WSA881X_OTP_REG_17: + case WSA881X_OTP_REG_18: + case WSA881X_OTP_REG_19: + case WSA881X_OTP_REG_20: + case WSA881X_OTP_REG_21: + case WSA881X_OTP_REG_22: + case WSA881X_OTP_REG_23: + case WSA881X_OTP_REG_24: + case WSA881X_OTP_REG_25: + case WSA881X_OTP_REG_26: + case WSA881X_OTP_REG_27: + case WSA881X_OTP_REG_28: + case WSA881X_OTP_REG_29: + case WSA881X_OTP_REG_30: + case WSA881X_OTP_REG_31: + case WSA881X_OTP_REG_63: + case WSA881X_BIAS_REF_CTRL: + case WSA881X_BIAS_TEST: + case WSA881X_BIAS_BIAS: + case WSA881X_TEMP_OP: + case WSA881X_TEMP_IREF_CTRL: + case WSA881X_TEMP_ISENS_CTRL: + case WSA881X_TEMP_CLK_CTRL: + case WSA881X_TEMP_TEST: + case WSA881X_TEMP_BIAS: + case WSA881X_TEMP_ADC_CTRL: + case WSA881X_TEMP_DOUT_MSB: + case WSA881X_TEMP_DOUT_LSB: + case WSA881X_ADC_EN_MODU_V: + case WSA881X_ADC_EN_MODU_I: + case WSA881X_ADC_EN_DET_TEST_V: + case WSA881X_ADC_EN_DET_TEST_I: + case WSA881X_ADC_SEL_IBIAS: + case WSA881X_ADC_EN_SEL_IBIAS: + case WSA881X_SPKR_DRV_EN: + case WSA881X_SPKR_DRV_GAIN: + case WSA881X_SPKR_DAC_CTL: + case WSA881X_SPKR_DRV_DBG: + case WSA881X_SPKR_PWRSTG_DBG: + case WSA881X_SPKR_OCP_CTL: + case WSA881X_SPKR_CLIP_CTL: + case WSA881X_SPKR_BBM_CTL: + case WSA881X_SPKR_MISC_CTL1: + case WSA881X_SPKR_MISC_CTL2: + case WSA881X_SPKR_BIAS_INT: + case WSA881X_SPKR_PA_INT: + case WSA881X_SPKR_BIAS_CAL: + case WSA881X_SPKR_BIAS_PSRR: + case WSA881X_SPKR_STATUS1: + case WSA881X_SPKR_STATUS2: + case WSA881X_BOOST_EN_CTL: + case WSA881X_BOOST_CURRENT_LIMIT: + case WSA881X_BOOST_PS_CTL: + case WSA881X_BOOST_PRESET_OUT1: + case WSA881X_BOOST_PRESET_OUT2: + case WSA881X_BOOST_FORCE_OUT: + case WSA881X_BOOST_LDO_PROG: + case WSA881X_BOOST_SLOPE_COMP_ISENSE_FB: + case WSA881X_BOOST_RON_CTL: + case WSA881X_BOOST_LOOP_STABILITY: + case WSA881X_BOOST_ZX_CTL: + case WSA881X_BOOST_START_CTL: + case WSA881X_BOOST_MISC1_CTL: + case WSA881X_BOOST_MISC2_CTL: + case WSA881X_BOOST_MISC3_CTL: + case WSA881X_BOOST_ATEST_CTL: + case WSA881X_SPKR_PROT_FE_GAIN: + case WSA881X_SPKR_PROT_FE_CM_LDO_SET: + case WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET1: + case WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET2: + case WSA881X_SPKR_PROT_ATEST1: + case WSA881X_SPKR_PROT_ATEST2: + case WSA881X_SPKR_PROT_FE_VSENSE_VCM: + case WSA881X_SPKR_PROT_FE_VSENSE_BIAS_SET1: + case WSA881X_BONGO_RESRV_REG1: + case WSA881X_BONGO_RESRV_REG2: + case WSA881X_SPKR_PROT_SAR: + case WSA881X_SPKR_STATUS3: + return true; + default: + return false; + } +} + +static inline bool wsa881x_volatile_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case WSA881X_CHIP_ID0: + case WSA881X_CHIP_ID1: + case WSA881X_CHIP_ID2: + case WSA881X_CHIP_ID3: + case WSA881X_BUS_ID: + case WSA881X_TEMP_MSB: + case WSA881X_TEMP_LSB: + case WSA881X_SDM_PDM9_LSB: + case WSA881X_SDM_PDM9_MSB: + case WSA881X_OTP_CTRL1: + case WSA881X_INTR_STATUS: + case WSA881X_ATE_TEST_MODE: + case WSA881X_PIN_STATUS: + case WSA881X_SWR_HM_TEST2: + case WSA881X_SPKR_STATUS1: + case WSA881X_SPKR_STATUS2: + case WSA881X_SPKR_STATUS3: + case WSA881X_OTP_REG_0: + case WSA881X_OTP_REG_1: + case WSA881X_OTP_REG_2: + case WSA881X_OTP_REG_3: + case WSA881X_OTP_REG_4: + case WSA881X_OTP_REG_5: + case WSA881X_OTP_REG_31: + case WSA881X_TEMP_DOUT_MSB: + case WSA881X_TEMP_DOUT_LSB: + case WSA881X_TEMP_OP: + case WSA881X_SPKR_PROT_SAR: + return true; + default: + return false; + } +} + +#endif /* __WSA881x_COMMON_H__ */ diff --git a/sound/soc/codecs/wsa881x.c b/sound/soc/codecs/wsa881x.c index 6627d2da372206eff879f8f3bd5fae9ddc0757d7..3fecc16590a1b0415d944684924f3d41ba3dabd2 100644 --- a/sound/soc/codecs/wsa881x.c +++ b/sound/soc/codecs/wsa881x.c @@ -15,172 +15,7 @@ #include <sound/soc.h> #include <sound/tlv.h> -#define WSA881X_DIGITAL_BASE 0x3000 -#define WSA881X_ANALOG_BASE 0x3100 - -/* Digital register address space */ -#define WSA881X_CHIP_ID0 (WSA881X_DIGITAL_BASE + 0x0000) -#define WSA881X_CHIP_ID1 (WSA881X_DIGITAL_BASE + 0x0001) -#define WSA881X_CHIP_ID2 (WSA881X_DIGITAL_BASE + 0x0002) -#define WSA881X_CHIP_ID3 (WSA881X_DIGITAL_BASE + 0x0003) -#define WSA881X_BUS_ID (WSA881X_DIGITAL_BASE + 0x0004) -#define WSA881X_CDC_RST_CTL (WSA881X_DIGITAL_BASE + 0x0005) -#define WSA881X_CDC_TOP_CLK_CTL (WSA881X_DIGITAL_BASE + 0x0006) -#define WSA881X_CDC_ANA_CLK_CTL (WSA881X_DIGITAL_BASE + 0x0007) -#define WSA881X_CDC_DIG_CLK_CTL (WSA881X_DIGITAL_BASE + 0x0008) -#define WSA881X_CLOCK_CONFIG (WSA881X_DIGITAL_BASE + 0x0009) -#define WSA881X_ANA_CTL (WSA881X_DIGITAL_BASE + 0x000A) -#define WSA881X_SWR_RESET_EN (WSA881X_DIGITAL_BASE + 0x000B) -#define WSA881X_RESET_CTL (WSA881X_DIGITAL_BASE + 0x000C) -#define WSA881X_TADC_VALUE_CTL (WSA881X_DIGITAL_BASE + 0x000F) -#define WSA881X_TEMP_DETECT_CTL (WSA881X_DIGITAL_BASE + 0x0010) -#define WSA881X_TEMP_MSB (WSA881X_DIGITAL_BASE + 0x0011) -#define WSA881X_TEMP_LSB (WSA881X_DIGITAL_BASE + 0x0012) -#define WSA881X_TEMP_CONFIG0 (WSA881X_DIGITAL_BASE + 0x0013) -#define WSA881X_TEMP_CONFIG1 (WSA881X_DIGITAL_BASE + 0x0014) -#define WSA881X_CDC_CLIP_CTL (WSA881X_DIGITAL_BASE + 0x0015) -#define WSA881X_SDM_PDM9_LSB (WSA881X_DIGITAL_BASE + 0x0016) -#define WSA881X_SDM_PDM9_MSB (WSA881X_DIGITAL_BASE + 0x0017) -#define WSA881X_CDC_RX_CTL (WSA881X_DIGITAL_BASE + 0x0018) -#define WSA881X_DEM_BYPASS_DATA0 (WSA881X_DIGITAL_BASE + 0x0019) -#define WSA881X_DEM_BYPASS_DATA1 (WSA881X_DIGITAL_BASE + 0x001A) -#define WSA881X_DEM_BYPASS_DATA2 (WSA881X_DIGITAL_BASE + 0x001B) -#define WSA881X_DEM_BYPASS_DATA3 (WSA881X_DIGITAL_BASE + 0x001C) -#define WSA881X_OTP_CTRL0 (WSA881X_DIGITAL_BASE + 0x001D) -#define WSA881X_OTP_CTRL1 (WSA881X_DIGITAL_BASE + 0x001E) -#define WSA881X_HDRIVE_CTL_GROUP1 (WSA881X_DIGITAL_BASE + 0x001F) -#define WSA881X_INTR_MODE (WSA881X_DIGITAL_BASE + 0x0020) -#define WSA881X_INTR_MASK (WSA881X_DIGITAL_BASE + 0x0021) -#define WSA881X_INTR_STATUS (WSA881X_DIGITAL_BASE + 0x0022) -#define WSA881X_INTR_CLEAR (WSA881X_DIGITAL_BASE + 0x0023) -#define WSA881X_INTR_LEVEL (WSA881X_DIGITAL_BASE + 0x0024) -#define WSA881X_INTR_SET (WSA881X_DIGITAL_BASE + 0x0025) -#define WSA881X_INTR_TEST (WSA881X_DIGITAL_BASE + 0x0026) -#define WSA881X_PDM_TEST_MODE (WSA881X_DIGITAL_BASE + 0x0030) -#define WSA881X_ATE_TEST_MODE (WSA881X_DIGITAL_BASE + 0x0031) -#define WSA881X_PIN_CTL_MODE (WSA881X_DIGITAL_BASE + 0x0032) -#define WSA881X_PIN_CTL_OE (WSA881X_DIGITAL_BASE + 0x0033) -#define WSA881X_PIN_WDATA_IOPAD (WSA881X_DIGITAL_BASE + 0x0034) -#define WSA881X_PIN_STATUS (WSA881X_DIGITAL_BASE + 0x0035) -#define WSA881X_DIG_DEBUG_MODE (WSA881X_DIGITAL_BASE + 0x0037) -#define WSA881X_DIG_DEBUG_SEL (WSA881X_DIGITAL_BASE + 0x0038) -#define WSA881X_DIG_DEBUG_EN (WSA881X_DIGITAL_BASE + 0x0039) -#define WSA881X_SWR_HM_TEST1 (WSA881X_DIGITAL_BASE + 0x003B) -#define WSA881X_SWR_HM_TEST2 (WSA881X_DIGITAL_BASE + 0x003C) -#define WSA881X_TEMP_DETECT_DBG_CTL (WSA881X_DIGITAL_BASE + 0x003D) -#define WSA881X_TEMP_DEBUG_MSB (WSA881X_DIGITAL_BASE + 0x003E) -#define WSA881X_TEMP_DEBUG_LSB (WSA881X_DIGITAL_BASE + 0x003F) -#define WSA881X_SAMPLE_EDGE_SEL (WSA881X_DIGITAL_BASE + 0x0044) -#define WSA881X_IOPAD_CTL (WSA881X_DIGITAL_BASE + 0x0045) -#define WSA881X_SPARE_0 (WSA881X_DIGITAL_BASE + 0x0050) -#define WSA881X_SPARE_1 (WSA881X_DIGITAL_BASE + 0x0051) -#define WSA881X_SPARE_2 (WSA881X_DIGITAL_BASE + 0x0052) -#define WSA881X_OTP_REG_0 (WSA881X_DIGITAL_BASE + 0x0080) -#define WSA881X_OTP_REG_1 (WSA881X_DIGITAL_BASE + 0x0081) -#define WSA881X_OTP_REG_2 (WSA881X_DIGITAL_BASE + 0x0082) -#define WSA881X_OTP_REG_3 (WSA881X_DIGITAL_BASE + 0x0083) -#define WSA881X_OTP_REG_4 (WSA881X_DIGITAL_BASE + 0x0084) -#define WSA881X_OTP_REG_5 (WSA881X_DIGITAL_BASE + 0x0085) -#define WSA881X_OTP_REG_6 (WSA881X_DIGITAL_BASE + 0x0086) -#define WSA881X_OTP_REG_7 (WSA881X_DIGITAL_BASE + 0x0087) -#define WSA881X_OTP_REG_8 (WSA881X_DIGITAL_BASE + 0x0088) -#define WSA881X_OTP_REG_9 (WSA881X_DIGITAL_BASE + 0x0089) -#define WSA881X_OTP_REG_10 (WSA881X_DIGITAL_BASE + 0x008A) -#define WSA881X_OTP_REG_11 (WSA881X_DIGITAL_BASE + 0x008B) -#define WSA881X_OTP_REG_12 (WSA881X_DIGITAL_BASE + 0x008C) -#define WSA881X_OTP_REG_13 (WSA881X_DIGITAL_BASE + 0x008D) -#define WSA881X_OTP_REG_14 (WSA881X_DIGITAL_BASE + 0x008E) -#define WSA881X_OTP_REG_15 (WSA881X_DIGITAL_BASE + 0x008F) -#define WSA881X_OTP_REG_16 (WSA881X_DIGITAL_BASE + 0x0090) -#define WSA881X_OTP_REG_17 (WSA881X_DIGITAL_BASE + 0x0091) -#define WSA881X_OTP_REG_18 (WSA881X_DIGITAL_BASE + 0x0092) -#define WSA881X_OTP_REG_19 (WSA881X_DIGITAL_BASE + 0x0093) -#define WSA881X_OTP_REG_20 (WSA881X_DIGITAL_BASE + 0x0094) -#define WSA881X_OTP_REG_21 (WSA881X_DIGITAL_BASE + 0x0095) -#define WSA881X_OTP_REG_22 (WSA881X_DIGITAL_BASE + 0x0096) -#define WSA881X_OTP_REG_23 (WSA881X_DIGITAL_BASE + 0x0097) -#define WSA881X_OTP_REG_24 (WSA881X_DIGITAL_BASE + 0x0098) -#define WSA881X_OTP_REG_25 (WSA881X_DIGITAL_BASE + 0x0099) -#define WSA881X_OTP_REG_26 (WSA881X_DIGITAL_BASE + 0x009A) -#define WSA881X_OTP_REG_27 (WSA881X_DIGITAL_BASE + 0x009B) -#define WSA881X_OTP_REG_28 (WSA881X_DIGITAL_BASE + 0x009C) -#define WSA881X_OTP_REG_29 (WSA881X_DIGITAL_BASE + 0x009D) -#define WSA881X_OTP_REG_30 (WSA881X_DIGITAL_BASE + 0x009E) -#define WSA881X_OTP_REG_31 (WSA881X_DIGITAL_BASE + 0x009F) -#define WSA881X_OTP_REG_63 (WSA881X_DIGITAL_BASE + 0x00BF) - -/* Analog Register address space */ -#define WSA881X_BIAS_REF_CTRL (WSA881X_ANALOG_BASE + 0x0000) -#define WSA881X_BIAS_TEST (WSA881X_ANALOG_BASE + 0x0001) -#define WSA881X_BIAS_BIAS (WSA881X_ANALOG_BASE + 0x0002) -#define WSA881X_TEMP_OP (WSA881X_ANALOG_BASE + 0x0003) -#define WSA881X_TEMP_IREF_CTRL (WSA881X_ANALOG_BASE + 0x0004) -#define WSA881X_TEMP_ISENS_CTRL (WSA881X_ANALOG_BASE + 0x0005) -#define WSA881X_TEMP_CLK_CTRL (WSA881X_ANALOG_BASE + 0x0006) -#define WSA881X_TEMP_TEST (WSA881X_ANALOG_BASE + 0x0007) -#define WSA881X_TEMP_BIAS (WSA881X_ANALOG_BASE + 0x0008) -#define WSA881X_TEMP_ADC_CTRL (WSA881X_ANALOG_BASE + 0x0009) -#define WSA881X_TEMP_DOUT_MSB (WSA881X_ANALOG_BASE + 0x000A) -#define WSA881X_TEMP_DOUT_LSB (WSA881X_ANALOG_BASE + 0x000B) -#define WSA881X_ADC_EN_MODU_V (WSA881X_ANALOG_BASE + 0x0010) -#define WSA881X_ADC_EN_MODU_I (WSA881X_ANALOG_BASE + 0x0011) -#define WSA881X_ADC_EN_DET_TEST_V (WSA881X_ANALOG_BASE + 0x0012) -#define WSA881X_ADC_EN_DET_TEST_I (WSA881X_ANALOG_BASE + 0x0013) -#define WSA881X_ADC_SEL_IBIAS (WSA881X_ANALOG_BASE + 0x0014) -#define WSA881X_ADC_EN_SEL_IBAIS (WSA881X_ANALOG_BASE + 0x0015) -#define WSA881X_SPKR_DRV_EN (WSA881X_ANALOG_BASE + 0x001A) -#define WSA881X_SPKR_DRV_GAIN (WSA881X_ANALOG_BASE + 0x001B) -#define WSA881X_PA_GAIN_SEL_MASK BIT(3) -#define WSA881X_PA_GAIN_SEL_REG BIT(3) -#define WSA881X_PA_GAIN_SEL_DRE 0 -#define WSA881X_SPKR_PAG_GAIN_MASK GENMASK(7, 4) -#define WSA881X_SPKR_DAC_CTL (WSA881X_ANALOG_BASE + 0x001C) -#define WSA881X_SPKR_DRV_DBG (WSA881X_ANALOG_BASE + 0x001D) -#define WSA881X_SPKR_PWRSTG_DBG (WSA881X_ANALOG_BASE + 0x001E) -#define WSA881X_SPKR_OCP_CTL (WSA881X_ANALOG_BASE + 0x001F) -#define WSA881X_SPKR_OCP_MASK GENMASK(7, 6) -#define WSA881X_SPKR_OCP_EN BIT(7) -#define WSA881X_SPKR_OCP_HOLD BIT(6) -#define WSA881X_SPKR_CLIP_CTL (WSA881X_ANALOG_BASE + 0x0020) -#define WSA881X_SPKR_BBM_CTL (WSA881X_ANALOG_BASE + 0x0021) -#define WSA881X_SPKR_MISC_CTL1 (WSA881X_ANALOG_BASE + 0x0022) -#define WSA881X_SPKR_MISC_CTL2 (WSA881X_ANALOG_BASE + 0x0023) -#define WSA881X_SPKR_BIAS_INT (WSA881X_ANALOG_BASE + 0x0024) -#define WSA881X_SPKR_PA_INT (WSA881X_ANALOG_BASE + 0x0025) -#define WSA881X_SPKR_BIAS_CAL (WSA881X_ANALOG_BASE + 0x0026) -#define WSA881X_SPKR_BIAS_PSRR (WSA881X_ANALOG_BASE + 0x0027) -#define WSA881X_SPKR_STATUS1 (WSA881X_ANALOG_BASE + 0x0028) -#define WSA881X_SPKR_STATUS2 (WSA881X_ANALOG_BASE + 0x0029) -#define WSA881X_BOOST_EN_CTL (WSA881X_ANALOG_BASE + 0x002A) -#define WSA881X_BOOST_EN_MASK BIT(7) -#define WSA881X_BOOST_EN BIT(7) -#define WSA881X_BOOST_CURRENT_LIMIT (WSA881X_ANALOG_BASE + 0x002B) -#define WSA881X_BOOST_PS_CTL (WSA881X_ANALOG_BASE + 0x002C) -#define WSA881X_BOOST_PRESET_OUT1 (WSA881X_ANALOG_BASE + 0x002D) -#define WSA881X_BOOST_PRESET_OUT2 (WSA881X_ANALOG_BASE + 0x002E) -#define WSA881X_BOOST_FORCE_OUT (WSA881X_ANALOG_BASE + 0x002F) -#define WSA881X_BOOST_LDO_PROG (WSA881X_ANALOG_BASE + 0x0030) -#define WSA881X_BOOST_SLOPE_COMP_ISENSE_FB (WSA881X_ANALOG_BASE + 0x0031) -#define WSA881X_BOOST_RON_CTL (WSA881X_ANALOG_BASE + 0x0032) -#define WSA881X_BOOST_LOOP_STABILITY (WSA881X_ANALOG_BASE + 0x0033) -#define WSA881X_BOOST_ZX_CTL (WSA881X_ANALOG_BASE + 0x0034) -#define WSA881X_BOOST_START_CTL (WSA881X_ANALOG_BASE + 0x0035) -#define WSA881X_BOOST_MISC1_CTL (WSA881X_ANALOG_BASE + 0x0036) -#define WSA881X_BOOST_MISC2_CTL (WSA881X_ANALOG_BASE + 0x0037) -#define WSA881X_BOOST_MISC3_CTL (WSA881X_ANALOG_BASE + 0x0038) -#define WSA881X_BOOST_ATEST_CTL (WSA881X_ANALOG_BASE + 0x0039) -#define WSA881X_SPKR_PROT_FE_GAIN (WSA881X_ANALOG_BASE + 0x003A) -#define WSA881X_SPKR_PROT_FE_CM_LDO_SET (WSA881X_ANALOG_BASE + 0x003B) -#define WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET1 (WSA881X_ANALOG_BASE + 0x003C) -#define WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET2 (WSA881X_ANALOG_BASE + 0x003D) -#define WSA881X_SPKR_PROT_ATEST1 (WSA881X_ANALOG_BASE + 0x003E) -#define WSA881X_SPKR_PROT_ATEST2 (WSA881X_ANALOG_BASE + 0x003F) -#define WSA881X_SPKR_PROT_FE_VSENSE_VCM (WSA881X_ANALOG_BASE + 0x0040) -#define WSA881X_SPKR_PROT_FE_VSENSE_BIAS_SET1 (WSA881X_ANALOG_BASE + 0x0041) -#define WSA881X_BONGO_RESRV_REG1 (WSA881X_ANALOG_BASE + 0x0042) -#define WSA881X_BONGO_RESRV_REG2 (WSA881X_ANALOG_BASE + 0x0043) -#define WSA881X_SPKR_PROT_SAR (WSA881X_ANALOG_BASE + 0x0044) -#define WSA881X_SPKR_STATUS3 (WSA881X_ANALOG_BASE + 0x0045) +#include "wsa881x-common.h" #define SWRS_SCP_FRAME_CTRL_BANK(m) (0x60 + 0x10 * (m)) #define SWRS_SCP_HOST_CLK_DIV2_CTL_BANK(m) (0xE0 + 0x10 * (m)) @@ -191,7 +26,6 @@ #define SWR_SLV_RD_BUF_LEN 8 #define SWR_SLV_WR_BUF_LEN 32 #define SWR_SLV_MAX_DEVICES 2 -#define WSA881X_MAX_SWR_PORTS 4 #define WSA881X_VERSION_ENTRY_SIZE 27 #define WSA881X_OCP_CTL_TIMER_SEC 2 #define WSA881X_OCP_CTL_TEMP_CELSIUS 25 @@ -300,7 +134,7 @@ static struct reg_default wsa881x_defaults[] = { { WSA881X_ADC_EN_MODU_I, 0x00 }, { WSA881X_ADC_EN_DET_TEST_V, 0x00 }, { WSA881X_ADC_EN_DET_TEST_I, 0x00 }, - { WSA881X_ADC_EN_SEL_IBAIS, 0x10 }, + { WSA881X_ADC_EN_SEL_IBIAS, 0x10 }, { WSA881X_SPKR_DRV_EN, 0x74 }, { WSA881X_SPKR_DRV_DBG, 0x15 }, { WSA881X_SPKR_PWRSTG_DBG, 0x00 }, @@ -434,204 +268,8 @@ static const struct sdw_port_config wsa881x_pconfig[WSA881X_MAX_SWR_PORTS] = { }, }; -static bool wsa881x_readable_register(struct device *dev, unsigned int reg) -{ - switch (reg) { - case WSA881X_CHIP_ID0: - case WSA881X_CHIP_ID1: - case WSA881X_CHIP_ID2: - case WSA881X_CHIP_ID3: - case WSA881X_BUS_ID: - case WSA881X_CDC_RST_CTL: - case WSA881X_CDC_TOP_CLK_CTL: - case WSA881X_CDC_ANA_CLK_CTL: - case WSA881X_CDC_DIG_CLK_CTL: - case WSA881X_CLOCK_CONFIG: - case WSA881X_ANA_CTL: - case WSA881X_SWR_RESET_EN: - case WSA881X_RESET_CTL: - case WSA881X_TADC_VALUE_CTL: - case WSA881X_TEMP_DETECT_CTL: - case WSA881X_TEMP_MSB: - case WSA881X_TEMP_LSB: - case WSA881X_TEMP_CONFIG0: - case WSA881X_TEMP_CONFIG1: - case WSA881X_CDC_CLIP_CTL: - case WSA881X_SDM_PDM9_LSB: - case WSA881X_SDM_PDM9_MSB: - case WSA881X_CDC_RX_CTL: - case WSA881X_DEM_BYPASS_DATA0: - case WSA881X_DEM_BYPASS_DATA1: - case WSA881X_DEM_BYPASS_DATA2: - case WSA881X_DEM_BYPASS_DATA3: - case WSA881X_OTP_CTRL0: - case WSA881X_OTP_CTRL1: - case WSA881X_HDRIVE_CTL_GROUP1: - case WSA881X_INTR_MODE: - case WSA881X_INTR_MASK: - case WSA881X_INTR_STATUS: - case WSA881X_INTR_CLEAR: - case WSA881X_INTR_LEVEL: - case WSA881X_INTR_SET: - case WSA881X_INTR_TEST: - case WSA881X_PDM_TEST_MODE: - case WSA881X_ATE_TEST_MODE: - case WSA881X_PIN_CTL_MODE: - case WSA881X_PIN_CTL_OE: - case WSA881X_PIN_WDATA_IOPAD: - case WSA881X_PIN_STATUS: - case WSA881X_DIG_DEBUG_MODE: - case WSA881X_DIG_DEBUG_SEL: - case WSA881X_DIG_DEBUG_EN: - case WSA881X_SWR_HM_TEST1: - case WSA881X_SWR_HM_TEST2: - case WSA881X_TEMP_DETECT_DBG_CTL: - case WSA881X_TEMP_DEBUG_MSB: - case WSA881X_TEMP_DEBUG_LSB: - case WSA881X_SAMPLE_EDGE_SEL: - case WSA881X_IOPAD_CTL: - case WSA881X_SPARE_0: - case WSA881X_SPARE_1: - case WSA881X_SPARE_2: - case WSA881X_OTP_REG_0: - case WSA881X_OTP_REG_1: - case WSA881X_OTP_REG_2: - case WSA881X_OTP_REG_3: - case WSA881X_OTP_REG_4: - case WSA881X_OTP_REG_5: - case WSA881X_OTP_REG_6: - case WSA881X_OTP_REG_7: - case WSA881X_OTP_REG_8: - case WSA881X_OTP_REG_9: - case WSA881X_OTP_REG_10: - case WSA881X_OTP_REG_11: - case WSA881X_OTP_REG_12: - case WSA881X_OTP_REG_13: - case WSA881X_OTP_REG_14: - case WSA881X_OTP_REG_15: - case WSA881X_OTP_REG_16: - case WSA881X_OTP_REG_17: - case WSA881X_OTP_REG_18: - case WSA881X_OTP_REG_19: - case WSA881X_OTP_REG_20: - case WSA881X_OTP_REG_21: - case WSA881X_OTP_REG_22: - case WSA881X_OTP_REG_23: - case WSA881X_OTP_REG_24: - case WSA881X_OTP_REG_25: - case WSA881X_OTP_REG_26: - case WSA881X_OTP_REG_27: - case WSA881X_OTP_REG_28: - case WSA881X_OTP_REG_29: - case WSA881X_OTP_REG_30: - case WSA881X_OTP_REG_31: - case WSA881X_OTP_REG_63: - case WSA881X_BIAS_REF_CTRL: - case WSA881X_BIAS_TEST: - case WSA881X_BIAS_BIAS: - case WSA881X_TEMP_OP: - case WSA881X_TEMP_IREF_CTRL: - case WSA881X_TEMP_ISENS_CTRL: - case WSA881X_TEMP_CLK_CTRL: - case WSA881X_TEMP_TEST: - case WSA881X_TEMP_BIAS: - case WSA881X_TEMP_ADC_CTRL: - case WSA881X_TEMP_DOUT_MSB: - case WSA881X_TEMP_DOUT_LSB: - case WSA881X_ADC_EN_MODU_V: - case WSA881X_ADC_EN_MODU_I: - case WSA881X_ADC_EN_DET_TEST_V: - case WSA881X_ADC_EN_DET_TEST_I: - case WSA881X_ADC_SEL_IBIAS: - case WSA881X_ADC_EN_SEL_IBAIS: - case WSA881X_SPKR_DRV_EN: - case WSA881X_SPKR_DRV_GAIN: - case WSA881X_SPKR_DAC_CTL: - case WSA881X_SPKR_DRV_DBG: - case WSA881X_SPKR_PWRSTG_DBG: - case WSA881X_SPKR_OCP_CTL: - case WSA881X_SPKR_CLIP_CTL: - case WSA881X_SPKR_BBM_CTL: - case WSA881X_SPKR_MISC_CTL1: - case WSA881X_SPKR_MISC_CTL2: - case WSA881X_SPKR_BIAS_INT: - case WSA881X_SPKR_PA_INT: - case WSA881X_SPKR_BIAS_CAL: - case WSA881X_SPKR_BIAS_PSRR: - case WSA881X_SPKR_STATUS1: - case WSA881X_SPKR_STATUS2: - case WSA881X_BOOST_EN_CTL: - case WSA881X_BOOST_CURRENT_LIMIT: - case WSA881X_BOOST_PS_CTL: - case WSA881X_BOOST_PRESET_OUT1: - case WSA881X_BOOST_PRESET_OUT2: - case WSA881X_BOOST_FORCE_OUT: - case WSA881X_BOOST_LDO_PROG: - case WSA881X_BOOST_SLOPE_COMP_ISENSE_FB: - case WSA881X_BOOST_RON_CTL: - case WSA881X_BOOST_LOOP_STABILITY: - case WSA881X_BOOST_ZX_CTL: - case WSA881X_BOOST_START_CTL: - case WSA881X_BOOST_MISC1_CTL: - case WSA881X_BOOST_MISC2_CTL: - case WSA881X_BOOST_MISC3_CTL: - case WSA881X_BOOST_ATEST_CTL: - case WSA881X_SPKR_PROT_FE_GAIN: - case WSA881X_SPKR_PROT_FE_CM_LDO_SET: - case WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET1: - case WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET2: - case WSA881X_SPKR_PROT_ATEST1: - case WSA881X_SPKR_PROT_ATEST2: - case WSA881X_SPKR_PROT_FE_VSENSE_VCM: - case WSA881X_SPKR_PROT_FE_VSENSE_BIAS_SET1: - case WSA881X_BONGO_RESRV_REG1: - case WSA881X_BONGO_RESRV_REG2: - case WSA881X_SPKR_PROT_SAR: - case WSA881X_SPKR_STATUS3: - return true; - default: - return false; - } -} - -static bool wsa881x_volatile_register(struct device *dev, unsigned int reg) -{ - switch (reg) { - case WSA881X_CHIP_ID0: - case WSA881X_CHIP_ID1: - case WSA881X_CHIP_ID2: - case WSA881X_CHIP_ID3: - case WSA881X_BUS_ID: - case WSA881X_TEMP_MSB: - case WSA881X_TEMP_LSB: - case WSA881X_SDM_PDM9_LSB: - case WSA881X_SDM_PDM9_MSB: - case WSA881X_OTP_CTRL1: - case WSA881X_INTR_STATUS: - case WSA881X_ATE_TEST_MODE: - case WSA881X_PIN_STATUS: - case WSA881X_SWR_HM_TEST2: - case WSA881X_SPKR_STATUS1: - case WSA881X_SPKR_STATUS2: - case WSA881X_SPKR_STATUS3: - case WSA881X_OTP_REG_0: - case WSA881X_OTP_REG_1: - case WSA881X_OTP_REG_2: - case WSA881X_OTP_REG_3: - case WSA881X_OTP_REG_4: - case WSA881X_OTP_REG_5: - case WSA881X_OTP_REG_31: - case WSA881X_TEMP_DOUT_MSB: - case WSA881X_TEMP_DOUT_LSB: - case WSA881X_TEMP_OP: - case WSA881X_SPKR_PROT_SAR: - return true; - default: - return false; - } -} - static const struct regmap_config wsa881x_regmap_config = { + .reg_base = 0x3000, .reg_bits = 32, .val_bits = 8, .cache_type = REGCACHE_MAPLE, @@ -660,70 +298,15 @@ enum { G_0DB, }; -/* - * Private data Structure for wsa881x. All parameters related to - * WSA881X codec needs to be defined here. - */ -struct wsa881x_priv { - struct regmap *regmap; - struct device *dev; - struct sdw_slave *slave; - struct sdw_stream_config sconfig; - struct sdw_stream_runtime *sruntime; - struct sdw_port_config port_config[WSA881X_MAX_SWR_PORTS]; - struct gpio_desc *sd_n; - /* - * Logical state for SD_N GPIO: high for shutdown, low for enable. - * For backwards compatibility. - */ - unsigned int sd_n_val; - int active_ports; - bool port_prepared[WSA881X_MAX_SWR_PORTS]; - bool port_enable[WSA881X_MAX_SWR_PORTS]; -}; - static void wsa881x_init(struct wsa881x_priv *wsa881x) { - struct regmap *rm = wsa881x->regmap; - unsigned int val = 0; - regmap_register_patch(wsa881x->regmap, wsa881x_rev_2_0, ARRAY_SIZE(wsa881x_rev_2_0)); /* Enable software reset output from soundwire slave */ - regmap_update_bits(rm, WSA881X_SWR_RESET_EN, 0x07, 0x07); - - /* Bring out of analog reset */ - regmap_update_bits(rm, WSA881X_CDC_RST_CTL, 0x02, 0x02); - - /* Bring out of digital reset */ - regmap_update_bits(rm, WSA881X_CDC_RST_CTL, 0x01, 0x01); - regmap_update_bits(rm, WSA881X_CLOCK_CONFIG, 0x10, 0x10); - regmap_update_bits(rm, WSA881X_SPKR_OCP_CTL, 0x02, 0x02); - regmap_update_bits(rm, WSA881X_SPKR_MISC_CTL1, 0xC0, 0x80); - regmap_update_bits(rm, WSA881X_SPKR_MISC_CTL1, 0x06, 0x06); - regmap_update_bits(rm, WSA881X_SPKR_BIAS_INT, 0xFF, 0x00); - regmap_update_bits(rm, WSA881X_SPKR_PA_INT, 0xF0, 0x40); - regmap_update_bits(rm, WSA881X_SPKR_PA_INT, 0x0E, 0x0E); - regmap_update_bits(rm, WSA881X_BOOST_LOOP_STABILITY, 0x03, 0x03); - regmap_update_bits(rm, WSA881X_BOOST_MISC2_CTL, 0xFF, 0x14); - regmap_update_bits(rm, WSA881X_BOOST_START_CTL, 0x80, 0x80); - regmap_update_bits(rm, WSA881X_BOOST_START_CTL, 0x03, 0x00); - regmap_update_bits(rm, WSA881X_BOOST_SLOPE_COMP_ISENSE_FB, 0x0C, 0x04); - regmap_update_bits(rm, WSA881X_BOOST_SLOPE_COMP_ISENSE_FB, 0x03, 0x00); - - regmap_read(rm, WSA881X_OTP_REG_0, &val); - if (val) - regmap_update_bits(rm, WSA881X_BOOST_PRESET_OUT1, 0xF0, 0x70); - - regmap_update_bits(rm, WSA881X_BOOST_PRESET_OUT2, 0xF0, 0x30); - regmap_update_bits(rm, WSA881X_SPKR_DRV_EN, 0x08, 0x08); - regmap_update_bits(rm, WSA881X_BOOST_CURRENT_LIMIT, 0x0F, 0x08); - regmap_update_bits(rm, WSA881X_SPKR_OCP_CTL, 0x30, 0x30); - regmap_update_bits(rm, WSA881X_SPKR_OCP_CTL, 0x0C, 0x00); - regmap_update_bits(rm, WSA881X_OTP_REG_28, 0x3F, 0x3A); - regmap_update_bits(rm, WSA881X_BONGO_RESRV_REG1, 0xFF, 0xB2); - regmap_update_bits(rm, WSA881X_BONGO_RESRV_REG2, 0xFF, 0x05); + regmap_update_bits(wsa881x->regmap, WSA881X_SWR_RESET_EN, 0x07, 0x07); + + wsa881x_init_common(wsa881x); } static int wsa881x_component_probe(struct snd_soc_component *comp) @@ -932,7 +515,7 @@ static int wsa881x_spkr_pa_event(struct snd_soc_dapm_widget *w, if (wsa881x->port_prepared[WSA881X_PORT_VISENSE]) { wsa881x_visense_txfe_ctrl(comp, true); snd_soc_component_update_bits(comp, - WSA881X_ADC_EN_SEL_IBAIS, + WSA881X_ADC_EN_SEL_IBIAS, 0x07, 0x01); wsa881x_visense_adc_ctrl(comp, true); } @@ -1003,35 +586,11 @@ static int wsa881x_hw_free(struct snd_pcm_substream *substream, return 0; } -static int wsa881x_set_sdw_stream(struct snd_soc_dai *dai, - void *stream, int direction) -{ - struct wsa881x_priv *wsa881x = dev_get_drvdata(dai->dev); - - wsa881x->sruntime = stream; - - return 0; -} - -static int wsa881x_digital_mute(struct snd_soc_dai *dai, int mute, int stream) -{ - struct wsa881x_priv *wsa881x = dev_get_drvdata(dai->dev); - - if (mute) - regmap_update_bits(wsa881x->regmap, WSA881X_SPKR_DRV_EN, 0x80, - 0x00); - else - regmap_update_bits(wsa881x->regmap, WSA881X_SPKR_DRV_EN, 0x80, - 0x80); - - return 0; -} - static const struct snd_soc_dai_ops wsa881x_dai_ops = { .hw_params = wsa881x_hw_params, .hw_free = wsa881x_hw_free, .mute_stream = wsa881x_digital_mute, - .set_stream = wsa881x_set_sdw_stream, + .set_stream = wsa881x_set_stream, }; static struct snd_soc_dai_driver wsa881x_dais[] = { @@ -1108,40 +667,13 @@ static int wsa881x_probe(struct sdw_slave *pdev, { struct wsa881x_priv *wsa881x; struct device *dev = &pdev->dev; + int ret; - wsa881x = devm_kzalloc(dev, sizeof(*wsa881x), GFP_KERNEL); - if (!wsa881x) - return -ENOMEM; - - wsa881x->sd_n = devm_gpiod_get_optional(dev, "powerdown", - GPIOD_FLAGS_BIT_NONEXCLUSIVE); - if (IS_ERR(wsa881x->sd_n)) - return dev_err_probe(dev, PTR_ERR(wsa881x->sd_n), - "Shutdown Control GPIO not found\n"); - - /* - * Backwards compatibility work-around. - * - * The SD_N GPIO is active low, however upstream DTS used always active - * high. Changing the flag in driver and DTS will break backwards - * compatibility, so add a simple value inversion to work with both old - * and new DTS. - * - * This won't work properly with DTS using the flags properly in cases: - * 1. Old DTS with proper ACTIVE_LOW, however such case was broken - * before as the driver required the active high. - * 2. New DTS with proper ACTIVE_HIGH (intended), which is rare case - * (not existing upstream) but possible. This is the price of - * backwards compatibility, therefore this hack should be removed at - * some point. - */ - wsa881x->sd_n_val = gpiod_is_active_low(wsa881x->sd_n); - if (!wsa881x->sd_n_val) - dev_warn(dev, "Using ACTIVE_HIGH for shutdown GPIO. Your DTB might be outdated or you use unsupported configuration for the GPIO."); + ret = wsa881x_probe_common(&wsa881x, dev); + if (ret) + return ret; - dev_set_drvdata(dev, wsa881x); wsa881x->slave = pdev; - wsa881x->dev = dev; wsa881x->sconfig.ch_count = 1; wsa881x->sconfig.bps = 1; wsa881x->sconfig.frame_rate = 48000; @@ -1151,7 +683,6 @@ static int wsa881x_probe(struct sdw_slave *pdev, pdev->prop.sink_dpn_prop = wsa_sink_dpn_prop; pdev->prop.scp_int1_mask = SDW_SCP_INT1_BUS_CLASH | SDW_SCP_INT1_PARITY; pdev->prop.clk_stop_mode1 = true; - gpiod_direction_output(wsa881x->sd_n, !wsa881x->sd_n_val); wsa881x->regmap = devm_regmap_init_sdw(pdev, &wsa881x_regmap_config); if (IS_ERR(wsa881x->regmap)) -- 2.47.2 ^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH v3 05/12] ASoC: codecs: wsa881x: split into common and soundwire drivers 2025-05-22 17:40 ` [PATCH v3 05/12] ASoC: codecs: wsa881x: split into common and soundwire drivers Alexey Klimov @ 2025-05-29 10:05 ` Srinivas Kandagatla 0 siblings, 0 replies; 43+ messages in thread From: Srinivas Kandagatla @ 2025-05-29 10:05 UTC (permalink / raw) To: Alexey Klimov, Srinivas Kandagatla, Mark Brown, linux-sound Cc: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio On 5/22/25 6:40 PM, Alexey Klimov wrote: > This is required in order to introduce wsa881x driver that works > in analog mode and is configurable via i2c only. > Functional changes, if any, are kept to be minimal and common > parts or parts that can be shared are moved into wsa881x-common > helper driver. > The regmap config structure now contains 0x3000 offset as required > by soundwire spec. > > While at this, also fix the typo in WSA881X_ADC_EN_SEL_IBIAS > register name and rename wsa881x_set_sdw_stream() to > wsa881x_set_stream() and update registers description in the > header and use the new defines in wsa881x_init_common() and > in wsa881x_digital_mute(). > > Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> > Cc: Srinivas Kandagatla <srini@kernel.org> > Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> > --- > sound/soc/codecs/Kconfig | 4 + > sound/soc/codecs/Makefile | 2 + > sound/soc/codecs/wsa881x-common.c | 193 +++++++++++++++ > sound/soc/codecs/wsa881x-common.h | 458 +++++++++++++++++++++++++++++++++++ > sound/soc/codecs/wsa881x.c | 493 +------------------------------------- How about we have something like wsa881x.c wsa881x-sdw.c wsa881x-i2c.c ? > 5 files changed, 669 insertions(+), 481 deletions(-) > > diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig > index 8fe795504dbb5c91881e9de10f676c9d151b42d3..ba6e4504b5e9951203bd61fae894e86e9d40048e 100644 > --- a/sound/soc/codecs/Kconfig > +++ b/sound/soc/codecs/Kconfig > @@ -2543,10 +2543,14 @@ config SND_SOC_WM9713 > select REGMAP_AC97 > select AC97_BUS_COMPAT if AC97_BUS_NEW > > +config SND_SOC_WSA881X_COMMON > + tristate > + > config SND_SOC_WSA881X > tristate "WSA881X Codec" > depends on SOUNDWIRE > select REGMAP_SOUNDWIRE > + select SND_SOC_WSA881X_COMMON > help > This enables support for Qualcomm WSA8810/WSA8815 Class-D > Smart Speaker Amplifier. > diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile > index c92824713df0690998b76d43fcbe7c6e93dd5dd2..212d419cfe3c0fbd5d4e475e5d81c69ef930b3e1 100644 > --- a/sound/soc/codecs/Makefile > +++ b/sound/soc/codecs/Makefile > @@ -406,6 +406,7 @@ snd-soc-wm9712-y := wm9712.o > snd-soc-wm9713-y := wm9713.o > snd-soc-wm-hubs-y := wm_hubs.o > snd-soc-wsa881x-y := wsa881x.o > +snd-soc-wsa881x-common-y := wsa881x-common.o > snd-soc-wsa883x-y := wsa883x.o > snd-soc-wsa884x-y := wsa884x.o > snd-soc-zl38060-y := zl38060.o > @@ -835,6 +836,7 @@ obj-$(CONFIG_SND_SOC_WM9713) += snd-soc-wm9713.o > obj-$(CONFIG_SND_SOC_WM_ADSP) += snd-soc-wm-adsp.o > obj-$(CONFIG_SND_SOC_WM_HUBS) += snd-soc-wm-hubs.o > obj-$(CONFIG_SND_SOC_WSA881X) += snd-soc-wsa881x.o > +obj-$(CONFIG_SND_SOC_WSA881X_COMMON) += snd-soc-wsa881x-common.o > obj-$(CONFIG_SND_SOC_WSA883X) += snd-soc-wsa883x.o > obj-$(CONFIG_SND_SOC_WSA884X) += snd-soc-wsa884x.o > obj-$(CONFIG_SND_SOC_ZL38060) += snd-soc-zl38060.o > diff --git a/sound/soc/codecs/wsa881x-common.c b/sound/soc/codecs/wsa881x-common.c > new file mode 100644 > index 0000000000000000000000000000000000000000..fbc431bd059544505647688db0d09e407589e330 > --- /dev/null > +++ b/sound/soc/codecs/wsa881x-common.c > @@ -0,0 +1,193 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Copyright (C) 2024 Linaro Ltd > + */ > + > +#include <linux/gpio/consumer.h> > +#include <linux/module.h> > +#include <linux/regmap.h> > +#include <sound/soc.h> > + > +#include "wsa881x-common.h" > + > +int wsa881x_set_stream(struct snd_soc_dai *dai, void *stream, int direction) > +{ > +#if IS_ENABLED(CONFIG_SND_SOC_WSA881X) > + struct wsa881x_priv *wsa881x = dev_get_drvdata(dai->dev); > + > + wsa881x->sruntime = stream; > +#endif > + return 0; > +} > +EXPORT_SYMBOL_GPL(wsa881x_set_stream); > + > +int wsa881x_digital_mute(struct snd_soc_dai *dai, int mute, int stream) > +{ > + struct snd_soc_component *component = dai->component; > + > + return snd_soc_component_update_bits(component, > + WSA881X_SPKR_DRV_EN, > + WSA881X_SPKR_DRV_EN_CLASS_PA_MASK, > + mute ? > + WSA881X_SPKR_DRV_EN_CLASS_PA_DIS : > + WSA881X_SPKR_DRV_EN_CLASS_PA_EN); > +} > +EXPORT_SYMBOL_GPL(wsa881x_digital_mute); > + > +void wsa881x_init_common(struct wsa881x_priv *wsa881x) > +{ > + struct regmap *rm = wsa881x->regmap; > + unsigned int val = 0; > + > + /* Bring out of analog reset */ > + regmap_update_bits(rm, WSA881X_CDC_RST_CTL, > + WSA881X_CDC_RST_CTL_ANA_RST, > + WSA881X_CDC_RST_CTL_ANA_RST); > + > + /* Bring out of digital reset */ > + regmap_update_bits(rm, WSA881X_CDC_RST_CTL, > + WSA881X_CDC_RST_CTL_DIG_RST, > + WSA881X_CDC_RST_CTL_DIG_RST); > + regmap_update_bits(rm, WSA881X_CLOCK_CONFIG, > + WSA881X_CLOCK_SCLK_SDM_DEM_DIV2_EN, > + WSA881X_CLOCK_SCLK_SDM_DEM_DIV2_EN); > + regmap_update_bits(rm, WSA881X_SPKR_OCP_CTL, > + WSA881X_SPKR_OCP_CTL_RDAC_CLK_DIV2_MASK, > + FIELD_PREP(WSA881X_SPKR_OCP_CTL_RDAC_CLK_DIV2_MASK, > + WSA881X_SPKR_OCP_CTL_RDAC_CLK_DIV2)); > + regmap_update_bits(rm, WSA881X_SPKR_MISC_CTL1, > + WSA881X_SPKR_MISC_CTL1_DTIME_MASK, > + FIELD_PREP(WSA881X_SPKR_MISC_CTL1_DTIME_MASK, > + WSA881X_SPKR_MISC_CTL1_40NS)); > + regmap_update_bits(rm, WSA881X_SPKR_MISC_CTL1, > + WSA881X_SPKR_MISC_CTL1_SLEW_RATE_MASK, > + FIELD_PREP(WSA881X_SPKR_MISC_CTL1_SLEW_RATE_MASK, > + WSA881X_SPKR_MISC_CTL1_60NS)); > + regmap_update_bits(rm, WSA881X_SPKR_BIAS_INT, > + WSA881X_SPKR_BIAS_INT_FULL_MASK, > + 0x0); > + regmap_update_bits(rm, WSA881X_SPKR_PA_INT, > + WSA881X_SPKR_PA_INT_COMP_CURR_MASK, > + FIELD_PREP(WSA881X_SPKR_PA_INT_COMP_CURR_MASK, > + WSA881X_SPKR_PA_INT_COMP_CURR_2UA0)); > + regmap_update_bits(rm, WSA881X_SPKR_PA_INT, > + WSA881X_SPKR_PA_INT_LDO_CURR_MASK, > + FIELD_PREP(WSA881X_SPKR_PA_INT_LDO_CURR_MASK, > + WSA881X_SPKR_PA_INT_LDO_CURR_5UA0)); > + regmap_update_bits(rm, WSA881X_BOOST_LOOP_STABILITY, > + WSA881X_BOOST_LOOP_STAB_COMP_RES_MASK, > + FIELD_PREP(WSA881X_BOOST_LOOP_STAB_COMP_RES_MASK, > + WSA881X_BOOST_LOOP_STAB_COMP_RES_400K)); > + regmap_update_bits(rm, WSA881X_BOOST_MISC2_CTL, > + WSA881X_BOOST_MISC2_CTL_FULL_MASK, > + WSA881X_BOOST_MISC2_CTL_RST); > + regmap_update_bits(rm, WSA881X_BOOST_START_CTL, > + WSA881X_BOOST_START_CTL_FAST_TRAN_MASK, > + WSA881X_BOOST_START_CTL_FAST_TRAN_EN); > + regmap_update_bits(rm, WSA881X_BOOST_START_CTL, > + WSA881X_BOOST_START_CTL_PULSE_SKIP_MASK, > + FIELD_PREP(WSA881X_BOOST_START_CTL_PULSE_SKIP_MASK, > + WSA881X_BOOST_START_CTL_PULSE_SKIP_50MA)); > + regmap_update_bits(rm, WSA881X_BOOST_SLOPE_COMP_ISENSE_FB, > + WSA881X_BOOST_SLOPE_ERR_CURR_MASK, > + FIELD_PREP(WSA881X_BOOST_SLOPE_ERR_CURR_MASK, > + WSA881X_BOOST_SLOPE_ERR_CURR_11UA)); > + regmap_update_bits(rm, WSA881X_BOOST_SLOPE_COMP_ISENSE_FB, > + WSA881X_BOOST_SLOPE_ISENSE_FB_MASK, > + FIELD_PREP(WSA881X_BOOST_SLOPE_ISENSE_FB_MASK, > + WSA881X_BOOST_SLOPE_ISENSE_FB_03)); > + > + regmap_read(rm, WSA881X_OTP_REG_0, &val); > + if (val) > + regmap_update_bits(rm, > + WSA881X_BOOST_PRESET_OUT1, > + WSA881X_BOOST_PRESET_OUT1_1ST_LVL_MASK, > + FIELD_PREP(WSA881X_BOOST_PRESET_OUT1_1ST_LVL_MASK, > + WSA881X_BOOST_PRESET_OUT1_5V5)); > + > + regmap_update_bits(rm, WSA881X_BOOST_PRESET_OUT2, > + WSA881X_BOOST_PRESET_OUT2_3RD_LVL_MASK, > + FIELD_PREP(WSA881X_BOOST_PRESET_OUT2_3RD_LVL_MASK, > + WSA881X_BOOST_PRESET_OUT2_9V)); > + regmap_update_bits(rm, WSA881X_SPKR_DRV_EN, > + WSA881X_SPKR_DRV_EN_INT_LDO_VOUT_MASK, > + FIELD_PREP(WSA881X_SPKR_DRV_EN_INT_LDO_VOUT_MASK, > + WSA881X_SPKR_DRV_EN_INT_LDO_VOUT_5V5)); > + regmap_update_bits(rm, WSA881X_BOOST_CURRENT_LIMIT, > + WSA881X_BOOST_CURRENT_LIMIT_SET_MASK, > + FIELD_PREP(WSA881X_BOOST_CURRENT_LIMIT_SET_MASK, > + WSA881X_BOOST_CURRENT_LIMIT_SET_4A)); > + regmap_update_bits(rm, WSA881X_SPKR_OCP_CTL, > + WSA881X_SPKR_OCP_CTL_CURR_LIMIT_MASK, > + FIELD_PREP(WSA881X_SPKR_OCP_CTL_CURR_LIMIT_MASK, > + WSA881X_SPKR_OCP_CTL_CURR_LIMIT_5A)); > + regmap_update_bits(rm, WSA881X_SPKR_OCP_CTL, > + WSA881X_SPKR_OCP_CTL_GLITCH_FLT_MASK, > + FIELD_PREP(WSA881X_SPKR_OCP_CTL_GLITCH_FLT_MASK, > + WSA881X_SPKR_OCP_CTL_GLITCH_FLT_128NS)); > + regmap_update_bits(rm, WSA881X_OTP_REG_28, > + WSA881X_OTP_REG_28_ISENSE_CAL_MASK, > + FIELD_PREP(WSA881X_OTP_REG_28_ISENSE_CAL_MASK, > + WSA881X_OTP_REG_28_ISENSE_CAL_RST_VAL)); > + regmap_update_bits(rm, WSA881X_BONGO_RESRV_REG1, > + WSA881X_BONGO_RESRV_REG1_TEMP_CMP_MASK, > + WSA881X_BONGO_RESRV_REG1_TEMP_CMP_EN); > + regmap_update_bits(rm, WSA881X_BONGO_RESRV_REG1, > + WSA881X_BONGO_RESRV_REG1_ISENSE_MASK, > + FIELD_PREP(WSA881X_BONGO_RESRV_REG1_ISENSE_MASK, > + WSA881X_BONGO_RESRV_REG1_ISENSE_RST_VAL)); > + regmap_update_bits(rm, WSA881X_BONGO_RESRV_REG1, > + WSA881X_BONGO_RESRV_REG1_ATEST_MASK, > + WSA881X_BONGO_RESRV_REG1_ATEST_DIS); > + regmap_update_bits(rm, WSA881X_BONGO_RESRV_REG2, > + WSA881X_BONGO_RESRV_REG2_FULL_MASK, > + WSA881X_BONGO_RESRV_REG2_RST_VAL); > +} > +EXPORT_SYMBOL_GPL(wsa881x_init_common); > + > +int wsa881x_probe_common(struct wsa881x_priv **wsa881x, struct device *dev) > +{ > + struct wsa881x_priv *wsa; > + > + wsa = devm_kzalloc(dev, sizeof(*wsa), GFP_KERNEL); > + if (!wsa) > + return -ENOMEM; > + > + wsa->dev = dev; > + wsa->sd_n = devm_gpiod_get_optional(dev, "powerdown", > + GPIOD_FLAGS_BIT_NONEXCLUSIVE); > + if (IS_ERR(wsa->sd_n)) > + return dev_err_probe(dev, PTR_ERR(wsa->sd_n), > + "Shutdown Control GPIO not found\n"); > + /* > + * Backwards compatibility work-around. > + * > + * The SD_N GPIO is active low, however upstream DTS used always active > + * high. Changing the flag in driver and DTS will break backwards > + * compatibility, so add a simple value inversion to work with both old > + * and new DTS. > + * > + * This won't work properly with DTS using the flags properly in cases: > + * 1. Old DTS with proper ACTIVE_LOW, however such case was broken > + * before as the driver required the active high. > + * 2. New DTS with proper ACTIVE_HIGH (intended), which is rare case > + * (not existing upstream) but possible. This is the price of > + * backwards compatibility, therefore this hack should be removed at > + * some point. > + */ > + wsa->sd_n_val = gpiod_is_active_low(wsa->sd_n); > + if (!wsa->sd_n_val) > + dev_warn(dev, > + "Using ACTIVE_HIGH for shutdown GPIO. Your DTB might be outdated or you use unsupported configuration for the GPIO.\n"); > + > + dev_set_drvdata(dev, wsa); > + gpiod_direction_output(wsa->sd_n, !wsa->sd_n_val); > + > + *wsa881x = wsa; > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(wsa881x_probe_common); > + > +MODULE_DESCRIPTION("WSA881x codec helper driver"); > +MODULE_LICENSE("GPL"); > diff --git a/sound/soc/codecs/wsa881x-common.h b/sound/soc/codecs/wsa881x-common.h > new file mode 100644 > index 0000000000000000000000000000000000000000..ab4ee5848b10fe6ca4160b7ff634e7e06b6e41e6 > --- /dev/null > +++ b/sound/soc/codecs/wsa881x-common.h > @@ -0,0 +1,458 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +#ifndef __WSA881x_COMMON_H__ > +#define __WSA881x_COMMON_H__ > + > +#include <linux/soundwire/sdw.h> > +#include <sound/soc.h> > + > +#define WSA881X_MAX_SWR_PORTS 4 > + > +#define WSA881X_DIGITAL_BASE 0x0000 > +#define WSA881X_ANALOG_BASE 0x0100 > + > +/* Digital register address space */ > +#define WSA881X_CHIP_ID0 (WSA881X_DIGITAL_BASE + 0x0000) > +#define WSA881X_CHIP_ID1 (WSA881X_DIGITAL_BASE + 0x0001) > +#define WSA881X_CHIP_ID2 (WSA881X_DIGITAL_BASE + 0x0002) > +#define WSA881X_CHIP_ID3 (WSA881X_DIGITAL_BASE + 0x0003) > +#define WSA881X_BUS_ID (WSA881X_DIGITAL_BASE + 0x0004) > +#define WSA881X_CDC_RST_CTL (WSA881X_DIGITAL_BASE + 0x0005) > +#define WSA881X_CDC_RST_CTL_ANA_RST BIT(1) > +#define WSA881X_CDC_RST_CTL_DIG_RST BIT(0) > +#define WSA881X_CDC_TOP_CLK_CTL (WSA881X_DIGITAL_BASE + 0x0006) > +#define WSA881X_CDC_ANA_CLK_CTL (WSA881X_DIGITAL_BASE + 0x0007) > +#define WSA881X_CDC_DIG_CLK_CTL (WSA881X_DIGITAL_BASE + 0x0008) > +#define WSA881X_CLOCK_CONFIG (WSA881X_DIGITAL_BASE + 0x0009) > +#define WSA881X_CLOCK_SCLK_SDM_DEM_DIV2_EN BIT(4) > +#define WSA881X_ANA_CTL (WSA881X_DIGITAL_BASE + 0x000A) > +#define WSA881X_SWR_RESET_EN (WSA881X_DIGITAL_BASE + 0x000B) > +#define WSA881X_RESET_CTL (WSA881X_DIGITAL_BASE + 0x000C) > +#define WSA881X_TADC_VALUE_CTL (WSA881X_DIGITAL_BASE + 0x000F) > +#define WSA881X_TEMP_DETECT_CTL (WSA881X_DIGITAL_BASE + 0x0010) > +#define WSA881X_TEMP_MSB (WSA881X_DIGITAL_BASE + 0x0011) > +#define WSA881X_TEMP_LSB (WSA881X_DIGITAL_BASE + 0x0012) > +#define WSA881X_TEMP_CONFIG0 (WSA881X_DIGITAL_BASE + 0x0013) > +#define WSA881X_TEMP_CONFIG1 (WSA881X_DIGITAL_BASE + 0x0014) > +#define WSA881X_CDC_CLIP_CTL (WSA881X_DIGITAL_BASE + 0x0015) > +#define WSA881X_SDM_PDM9_LSB (WSA881X_DIGITAL_BASE + 0x0016) > +#define WSA881X_SDM_PDM9_MSB (WSA881X_DIGITAL_BASE + 0x0017) > +#define WSA881X_CDC_RX_CTL (WSA881X_DIGITAL_BASE + 0x0018) > +#define WSA881X_DEM_BYPASS_DATA0 (WSA881X_DIGITAL_BASE + 0x0019) > +#define WSA881X_DEM_BYPASS_DATA1 (WSA881X_DIGITAL_BASE + 0x001A) > +#define WSA881X_DEM_BYPASS_DATA2 (WSA881X_DIGITAL_BASE + 0x001B) > +#define WSA881X_DEM_BYPASS_DATA3 (WSA881X_DIGITAL_BASE + 0x001C) > +#define WSA881X_OTP_CTRL0 (WSA881X_DIGITAL_BASE + 0x001D) > +#define WSA881X_OTP_CTRL1 (WSA881X_DIGITAL_BASE + 0x001E) > +#define WSA881X_HDRIVE_CTL_GROUP1 (WSA881X_DIGITAL_BASE + 0x001F) > +#define WSA881X_INTR_MODE (WSA881X_DIGITAL_BASE + 0x0020) > +#define WSA881X_INTR_MASK (WSA881X_DIGITAL_BASE + 0x0021) > +#define WSA881X_INTR_STATUS (WSA881X_DIGITAL_BASE + 0x0022) > +#define WSA881X_INTR_CLEAR (WSA881X_DIGITAL_BASE + 0x0023) > +#define WSA881X_INTR_LEVEL (WSA881X_DIGITAL_BASE + 0x0024) > +#define WSA881X_INTR_SET (WSA881X_DIGITAL_BASE + 0x0025) > +#define WSA881X_INTR_TEST (WSA881X_DIGITAL_BASE + 0x0026) > +#define WSA881X_PDM_TEST_MODE (WSA881X_DIGITAL_BASE + 0x0030) > +#define WSA881X_ATE_TEST_MODE (WSA881X_DIGITAL_BASE + 0x0031) > +#define WSA881X_PIN_CTL_MODE (WSA881X_DIGITAL_BASE + 0x0032) > +#define WSA881X_PIN_CTL_OE (WSA881X_DIGITAL_BASE + 0x0033) > +#define WSA881X_PIN_WDATA_IOPAD (WSA881X_DIGITAL_BASE + 0x0034) > +#define WSA881X_PIN_STATUS (WSA881X_DIGITAL_BASE + 0x0035) > +#define WSA881X_DIG_DEBUG_MODE (WSA881X_DIGITAL_BASE + 0x0037) > +#define WSA881X_DIG_DEBUG_SEL (WSA881X_DIGITAL_BASE + 0x0038) > +#define WSA881X_DIG_DEBUG_EN (WSA881X_DIGITAL_BASE + 0x0039) > +#define WSA881X_SWR_HM_TEST1 (WSA881X_DIGITAL_BASE + 0x003B) > +#define WSA881X_SWR_HM_TEST2 (WSA881X_DIGITAL_BASE + 0x003C) > +#define WSA881X_TEMP_DETECT_DBG_CTL (WSA881X_DIGITAL_BASE + 0x003D) > +#define WSA881X_TEMP_DEBUG_MSB (WSA881X_DIGITAL_BASE + 0x003E) > +#define WSA881X_TEMP_DEBUG_LSB (WSA881X_DIGITAL_BASE + 0x003F) > +#define WSA881X_SAMPLE_EDGE_SEL (WSA881X_DIGITAL_BASE + 0x0044) > +#define WSA881X_IOPAD_CTL (WSA881X_DIGITAL_BASE + 0x0045) > +#define WSA881X_SPARE_0 (WSA881X_DIGITAL_BASE + 0x0050) > +#define WSA881X_SPARE_1 (WSA881X_DIGITAL_BASE + 0x0051) > +#define WSA881X_SPARE_2 (WSA881X_DIGITAL_BASE + 0x0052) > +#define WSA881X_OTP_REG_0 (WSA881X_DIGITAL_BASE + 0x0080) > +#define WSA881X_OTP_REG_1 (WSA881X_DIGITAL_BASE + 0x0081) > +#define WSA881X_OTP_REG_2 (WSA881X_DIGITAL_BASE + 0x0082) > +#define WSA881X_OTP_REG_3 (WSA881X_DIGITAL_BASE + 0x0083) > +#define WSA881X_OTP_REG_4 (WSA881X_DIGITAL_BASE + 0x0084) > +#define WSA881X_OTP_REG_5 (WSA881X_DIGITAL_BASE + 0x0085) > +#define WSA881X_OTP_REG_6 (WSA881X_DIGITAL_BASE + 0x0086) > +#define WSA881X_OTP_REG_7 (WSA881X_DIGITAL_BASE + 0x0087) > +#define WSA881X_OTP_REG_8 (WSA881X_DIGITAL_BASE + 0x0088) > +#define WSA881X_OTP_REG_9 (WSA881X_DIGITAL_BASE + 0x0089) > +#define WSA881X_OTP_REG_10 (WSA881X_DIGITAL_BASE + 0x008A) > +#define WSA881X_OTP_REG_11 (WSA881X_DIGITAL_BASE + 0x008B) > +#define WSA881X_OTP_REG_12 (WSA881X_DIGITAL_BASE + 0x008C) > +#define WSA881X_OTP_REG_13 (WSA881X_DIGITAL_BASE + 0x008D) > +#define WSA881X_OTP_REG_14 (WSA881X_DIGITAL_BASE + 0x008E) > +#define WSA881X_OTP_REG_15 (WSA881X_DIGITAL_BASE + 0x008F) > +#define WSA881X_OTP_REG_16 (WSA881X_DIGITAL_BASE + 0x0090) > +#define WSA881X_OTP_REG_17 (WSA881X_DIGITAL_BASE + 0x0091) > +#define WSA881X_OTP_REG_18 (WSA881X_DIGITAL_BASE + 0x0092) > +#define WSA881X_OTP_REG_19 (WSA881X_DIGITAL_BASE + 0x0093) > +#define WSA881X_OTP_REG_20 (WSA881X_DIGITAL_BASE + 0x0094) > +#define WSA881X_OTP_REG_21 (WSA881X_DIGITAL_BASE + 0x0095) > +#define WSA881X_OTP_REG_22 (WSA881X_DIGITAL_BASE + 0x0096) > +#define WSA881X_OTP_REG_23 (WSA881X_DIGITAL_BASE + 0x0097) > +#define WSA881X_OTP_REG_24 (WSA881X_DIGITAL_BASE + 0x0098) > +#define WSA881X_OTP_REG_25 (WSA881X_DIGITAL_BASE + 0x0099) > +#define WSA881X_OTP_REG_26 (WSA881X_DIGITAL_BASE + 0x009A) > +#define WSA881X_OTP_REG_27 (WSA881X_DIGITAL_BASE + 0x009B) > +#define WSA881X_OTP_REG_28 (WSA881X_DIGITAL_BASE + 0x009C) > +#define WSA881X_OTP_REG_28_ISENSE_CAL_MASK GENMASK(5, 0) > +#define WSA881X_OTP_REG_28_ISENSE_CAL_RST_VAL (0x3A) > +#define WSA881X_OTP_REG_29 (WSA881X_DIGITAL_BASE + 0x009D) > +#define WSA881X_OTP_REG_30 (WSA881X_DIGITAL_BASE + 0x009E) > +#define WSA881X_OTP_REG_31 (WSA881X_DIGITAL_BASE + 0x009F) > +#define WSA881X_OTP_REG_63 (WSA881X_DIGITAL_BASE + 0x00BF) > + > +/* Analog Register address space */ > +#define WSA881X_BIAS_REF_CTRL (WSA881X_ANALOG_BASE + 0x0000) > +#define WSA881X_BIAS_TEST (WSA881X_ANALOG_BASE + 0x0001) > +#define WSA881X_BIAS_BIAS (WSA881X_ANALOG_BASE + 0x0002) > +#define WSA881X_TEMP_OP (WSA881X_ANALOG_BASE + 0x0003) > +#define WSA881X_TEMP_IREF_CTRL (WSA881X_ANALOG_BASE + 0x0004) > +#define WSA881X_TEMP_ISENS_CTRL (WSA881X_ANALOG_BASE + 0x0005) > +#define WSA881X_TEMP_CLK_CTRL (WSA881X_ANALOG_BASE + 0x0006) > +#define WSA881X_TEMP_TEST (WSA881X_ANALOG_BASE + 0x0007) > +#define WSA881X_TEMP_BIAS (WSA881X_ANALOG_BASE + 0x0008) > +#define WSA881X_TEMP_ADC_CTRL (WSA881X_ANALOG_BASE + 0x0009) > +#define WSA881X_TEMP_DOUT_MSB (WSA881X_ANALOG_BASE + 0x000A) > +#define WSA881X_TEMP_DOUT_LSB (WSA881X_ANALOG_BASE + 0x000B) > +#define WSA881X_ADC_EN_MODU_V (WSA881X_ANALOG_BASE + 0x0010) > +#define WSA881X_ADC_EN_MODU_I (WSA881X_ANALOG_BASE + 0x0011) > +#define WSA881X_ADC_EN_DET_TEST_V (WSA881X_ANALOG_BASE + 0x0012) > +#define WSA881X_ADC_EN_DET_TEST_I (WSA881X_ANALOG_BASE + 0x0013) > +#define WSA881X_ADC_SEL_IBIAS (WSA881X_ANALOG_BASE + 0x0014) > +#define WSA881X_ADC_EN_SEL_IBIAS (WSA881X_ANALOG_BASE + 0x0015) > +#define WSA881X_SPKR_DRV_EN (WSA881X_ANALOG_BASE + 0x001A) > +#define WSA881X_SPKR_DRV_EN_CLASS_PA_MASK BIT(7) > +#define WSA881X_SPKR_DRV_EN_CLASS_PA_DIS 0 > +#define WSA881X_SPKR_DRV_EN_CLASS_PA_EN BIT(7) > +#define WSA881X_SPKR_DRV_EN_INT_LDO_VOUT_MASK BIT(3) > +#define WSA881X_SPKR_DRV_EN_INT_LDO_VOUT_5V 0 > +#define WSA881X_SPKR_DRV_EN_INT_LDO_VOUT_5V5 1 > +#define WSA881X_SPKR_DRV_GAIN (WSA881X_ANALOG_BASE + 0x001B) > +#define WSA881X_PA_GAIN_SEL_MASK BIT(3) > +#define WSA881X_PA_GAIN_SEL_REG BIT(3) > +#define WSA881X_PA_GAIN_SEL_DRE 0 > +#define WSA881X_SPKR_PAG_GAIN_MASK GENMASK(7, 4) > +#define WSA881X_SPKR_DAC_CTL (WSA881X_ANALOG_BASE + 0x001C) > +#define WSA881X_SPKR_DRV_DBG (WSA881X_ANALOG_BASE + 0x001D) > +#define WSA881X_SPKR_PWRSTG_DBG (WSA881X_ANALOG_BASE + 0x001E) > +#define WSA881X_SPKR_OCP_CTL (WSA881X_ANALOG_BASE + 0x001F) > +#define WSA881X_SPKR_OCP_MASK GENMASK(7, 6) > +#define WSA881X_SPKR_OCP_CTL_CURR_LIMIT_MASK GENMASK(5, 4) > +#define WSA881X_SPKR_OCP_CTL_GLITCH_FLT_MASK GENMASK(3, 2) > +#define WSA881X_SPKR_OCP_CTL_CURR_LIMIT_5A (BIT(1) | BIT(0)) > +#define WSA881X_SPKR_OCP_CTL_GLITCH_FLT_128NS 0 > +#define WSA881X_SPKR_OCP_CTL_RDAC_CLK_DIV2_MASK BIT(1) > +#define WSA881X_SPKR_OCP_CTL_RDAC_CLK_DIV2 1 > +#define WSA881X_SPKR_OCP_EN BIT(7) > +#define WSA881X_SPKR_OCP_HOLD BIT(6) > +#define WSA881X_SPKR_CLIP_CTL (WSA881X_ANALOG_BASE + 0x0020) > +#define WSA881X_SPKR_BBM_CTL (WSA881X_ANALOG_BASE + 0x0021) > +#define WSA881X_SPKR_MISC_CTL1 (WSA881X_ANALOG_BASE + 0x0022) > +#define WSA881X_SPKR_MISC_CTL1_DTIME_MASK GENMASK(7, 6) > +#define WSA881X_SPKR_MISC_CTL1_SLEW_RATE_MASK GENMASK(2, 1) > +#define WSA881X_SPKR_MISC_CTL1_60NS (BIT(1) | BIT(0)) > +#define WSA881X_SPKR_MISC_CTL1_40NS BIT(1) > +#define WSA881X_SPKR_MISC_CTL2 (WSA881X_ANALOG_BASE + 0x0023) > +#define WSA881X_SPKR_BIAS_INT (WSA881X_ANALOG_BASE + 0x0024) > +#define WSA881X_SPKR_BIAS_INT_FULL_MASK ((u8)~0U) > +#define WSA881X_SPKR_PA_INT (WSA881X_ANALOG_BASE + 0x0025) > +#define WSA881X_SPKR_PA_INT_COMP_CURR_MASK GENMASK(7, 4) > +#define WSA881X_SPKR_PA_INT_LDO_CURR_MASK GENMASK(3, 1) > +#define WSA881X_SPKR_PA_INT_COMP_CURR_2UA0 BIT(2) > +#define WSA881X_SPKR_PA_INT_LDO_CURR_5UA0 (BIT(2) | BIT(1) | BIT(0)) > +#define WSA881X_SPKR_BIAS_CAL (WSA881X_ANALOG_BASE + 0x0026) > +#define WSA881X_SPKR_BIAS_PSRR (WSA881X_ANALOG_BASE + 0x0027) > +#define WSA881X_SPKR_STATUS1 (WSA881X_ANALOG_BASE + 0x0028) > +#define WSA881X_SPKR_STATUS2 (WSA881X_ANALOG_BASE + 0x0029) > +#define WSA881X_BOOST_EN_CTL (WSA881X_ANALOG_BASE + 0x002A) > +#define WSA881X_BOOST_EN_MASK BIT(7) > +#define WSA881X_BOOST_EN BIT(7) > +#define WSA881X_BOOST_CURRENT_LIMIT (WSA881X_ANALOG_BASE + 0x002B) > +#define WSA881X_BOOST_CURRENT_LIMIT_SET_MASK GENMASK(3, 0) > +#define WSA881X_BOOST_CURRENT_LIMIT_SET_4A BIT(3) > +#define WSA881X_BOOST_PS_CTL (WSA881X_ANALOG_BASE + 0x002C) > +#define WSA881X_BOOST_PRESET_OUT1 (WSA881X_ANALOG_BASE + 0x002D) > +#define WSA881X_BOOST_PRESET_OUT1_1ST_LVL_MASK GENMASK(7, 4) > +#define WSA881X_BOOST_PRESET_OUT1_5V5 (BIT(2) | BIT(1) | BIT(0)) > +#define WSA881X_BOOST_PRESET_OUT2 (WSA881X_ANALOG_BASE + 0x002E) > +#define WSA881X_BOOST_PRESET_OUT2_3RD_LVL_MASK GENMASK(7, 4) > +#define WSA881X_BOOST_PRESET_OUT2_9V (BIT(1) | BIT(0)) > +#define WSA881X_BOOST_FORCE_OUT (WSA881X_ANALOG_BASE + 0x002F) > +#define WSA881X_BOOST_LDO_PROG (WSA881X_ANALOG_BASE + 0x0030) > +#define WSA881X_BOOST_SLOPE_COMP_ISENSE_FB (WSA881X_ANALOG_BASE + 0x0031) > +#define WSA881X_BOOST_SLOPE_ERR_CURR_MASK GENMASK(3, 2) > +#define WSA881X_BOOST_SLOPE_ISENSE_FB_MASK GENMASK(1, 0) > +#define WSA881X_BOOST_SLOPE_ERR_CURR_11UA BIT(0) > +#define WSA881X_BOOST_SLOPE_ISENSE_FB_03 0 > +#define WSA881X_BOOST_RON_CTL (WSA881X_ANALOG_BASE + 0x0032) > +#define WSA881X_BOOST_LOOP_STABILITY (WSA881X_ANALOG_BASE + 0x0033) > +#define WSA881X_BOOST_LOOP_STAB_COMP_RES_MASK GENMASK(1, 0) > +#define WSA881X_BOOST_LOOP_STAB_COMP_RES_400K (BIT(1) | BIT(0)) > +#define WSA881X_BOOST_ZX_CTL (WSA881X_ANALOG_BASE + 0x0034) > +#define WSA881X_BOOST_START_CTL (WSA881X_ANALOG_BASE + 0x0035) > +#define WSA881X_BOOST_START_CTL_FAST_TRAN_MASK BIT(7) > +#define WSA881X_BOOST_START_CTL_PULSE_SKIP_MASK GENMASK(1, 0) > +#define WSA881X_BOOST_START_CTL_FAST_TRAN_EN BIT(7) > +#define WSA881X_BOOST_START_CTL_PULSE_SKIP_50MA 0 > +#define WSA881X_BOOST_MISC1_CTL (WSA881X_ANALOG_BASE + 0x0036) > +#define WSA881X_BOOST_MISC2_CTL (WSA881X_ANALOG_BASE + 0x0037) > +#define WSA881X_BOOST_MISC2_CTL_FULL_MASK ((u8)~0U) > +#define WSA881X_BOOST_MISC2_CTL_RST (BIT(4) | BIT(2)) > +#define WSA881X_BOOST_MISC3_CTL (WSA881X_ANALOG_BASE + 0x0038) > +#define WSA881X_BOOST_ATEST_CTL (WSA881X_ANALOG_BASE + 0x0039) > +#define WSA881X_SPKR_PROT_FE_GAIN (WSA881X_ANALOG_BASE + 0x003A) > +#define WSA881X_SPKR_PROT_FE_CM_LDO_SET (WSA881X_ANALOG_BASE + 0x003B) > +#define WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET1 (WSA881X_ANALOG_BASE + 0x003C) > +#define WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET2 (WSA881X_ANALOG_BASE + 0x003D) > +#define WSA881X_SPKR_PROT_ATEST1 (WSA881X_ANALOG_BASE + 0x003E) > +#define WSA881X_SPKR_PROT_ATEST2 (WSA881X_ANALOG_BASE + 0x003F) > +#define WSA881X_SPKR_PROT_FE_VSENSE_VCM (WSA881X_ANALOG_BASE + 0x0040) > +#define WSA881X_SPKR_PROT_FE_VSENSE_BIAS_SET1 (WSA881X_ANALOG_BASE + 0x0041) > +#define WSA881X_BONGO_RESRV_REG1 (WSA881X_ANALOG_BASE + 0x0042) > +#define WSA881X_BONGO_RESRV_REG1_TEMP_CMP_MASK BIT(7) > +#define WSA881X_BONGO_RESRV_REG1_ISENSE_MASK GENMASK(6, 1) > +#define WSA881X_BONGO_RESRV_REG1_ATEST_MASK BIT(0) > +#define WSA881X_BONGO_RESRV_REG1_TEMP_CMP_EN BIT(7) > +#define WSA881X_BONGO_RESRV_REG1_ISENSE_RST_VAL (BIT(4) | BIT(3) | BIT(0)) > +#define WSA881X_BONGO_RESRV_REG1_ATEST_DIS 0 > +#define WSA881X_BONGO_RESRV_REG2 (WSA881X_ANALOG_BASE + 0x0043) > +#define WSA881X_BONGO_RESRV_REG2_FULL_MASK ((u8)~0U) > +#define WSA881X_BONGO_RESRV_REG2_RST_VAL (0x5) > +#define WSA881X_SPKR_PROT_SAR (WSA881X_ANALOG_BASE + 0x0044) > +#define WSA881X_SPKR_STATUS3 (WSA881X_ANALOG_BASE + 0x0045) > + > +/* > + * Private data Structure for wsa881x. All parameters related to > + * WSA881X codec needs to be defined here. > + */ > +struct wsa881x_priv { > + struct regmap *regmap; > + struct device *dev; > + > +#if IS_ENABLED(CONFIG_SND_SOC_WSA881X) > + /* Soundwire interface */ > + struct sdw_slave *slave; > + struct sdw_stream_config sconfig; > + struct sdw_stream_runtime *sruntime; > + struct sdw_port_config port_config[WSA881X_MAX_SWR_PORTS]; > + int active_ports; > + bool port_prepared[WSA881X_MAX_SWR_PORTS]; > + bool port_enable[WSA881X_MAX_SWR_PORTS]; > +#endif > + > + struct gpio_desc *sd_n; > + /* > + * Logical state for SD_N GPIO: high for shutdown, low for enable. > + * For backwards compatibility. > + */ > + unsigned int sd_n_val; > +}; > + > +void wsa881x_init_common(struct wsa881x_priv *wsa881x); > +int wsa881x_probe_common(struct wsa881x_priv **wsa881x, struct device *dev); > +int wsa881x_digital_mute(struct snd_soc_dai *dai, int mute, int stream); > +int wsa881x_set_stream(struct snd_soc_dai *dai, void *stream, int direction); > + > +static inline bool wsa881x_readable_register(struct device *dev, unsigned int reg) > +{ > + switch (reg) { > + case WSA881X_CHIP_ID0: > + case WSA881X_CHIP_ID1: > + case WSA881X_CHIP_ID2: > + case WSA881X_CHIP_ID3: > + case WSA881X_BUS_ID: > + case WSA881X_CDC_RST_CTL: > + case WSA881X_CDC_TOP_CLK_CTL: > + case WSA881X_CDC_ANA_CLK_CTL: > + case WSA881X_CDC_DIG_CLK_CTL: > + case WSA881X_CLOCK_CONFIG: > + case WSA881X_ANA_CTL: > + case WSA881X_SWR_RESET_EN: > + case WSA881X_RESET_CTL: > + case WSA881X_TADC_VALUE_CTL: > + case WSA881X_TEMP_DETECT_CTL: > + case WSA881X_TEMP_MSB: > + case WSA881X_TEMP_LSB: > + case WSA881X_TEMP_CONFIG0: > + case WSA881X_TEMP_CONFIG1: > + case WSA881X_CDC_CLIP_CTL: > + case WSA881X_SDM_PDM9_LSB: > + case WSA881X_SDM_PDM9_MSB: > + case WSA881X_CDC_RX_CTL: > + case WSA881X_DEM_BYPASS_DATA0: > + case WSA881X_DEM_BYPASS_DATA1: > + case WSA881X_DEM_BYPASS_DATA2: > + case WSA881X_DEM_BYPASS_DATA3: > + case WSA881X_OTP_CTRL0: > + case WSA881X_OTP_CTRL1: > + case WSA881X_HDRIVE_CTL_GROUP1: > + case WSA881X_INTR_MODE: > + case WSA881X_INTR_MASK: > + case WSA881X_INTR_STATUS: > + case WSA881X_INTR_CLEAR: > + case WSA881X_INTR_LEVEL: > + case WSA881X_INTR_SET: > + case WSA881X_INTR_TEST: > + case WSA881X_PDM_TEST_MODE: > + case WSA881X_ATE_TEST_MODE: > + case WSA881X_PIN_CTL_MODE: > + case WSA881X_PIN_CTL_OE: > + case WSA881X_PIN_WDATA_IOPAD: > + case WSA881X_PIN_STATUS: > + case WSA881X_DIG_DEBUG_MODE: > + case WSA881X_DIG_DEBUG_SEL: > + case WSA881X_DIG_DEBUG_EN: > + case WSA881X_SWR_HM_TEST1: > + case WSA881X_SWR_HM_TEST2: > + case WSA881X_TEMP_DETECT_DBG_CTL: > + case WSA881X_TEMP_DEBUG_MSB: > + case WSA881X_TEMP_DEBUG_LSB: > + case WSA881X_SAMPLE_EDGE_SEL: > + case WSA881X_IOPAD_CTL: > + case WSA881X_SPARE_0: > + case WSA881X_SPARE_1: > + case WSA881X_SPARE_2: > + case WSA881X_OTP_REG_0: > + case WSA881X_OTP_REG_1: > + case WSA881X_OTP_REG_2: > + case WSA881X_OTP_REG_3: > + case WSA881X_OTP_REG_4: > + case WSA881X_OTP_REG_5: > + case WSA881X_OTP_REG_6: > + case WSA881X_OTP_REG_7: > + case WSA881X_OTP_REG_8: > + case WSA881X_OTP_REG_9: > + case WSA881X_OTP_REG_10: > + case WSA881X_OTP_REG_11: > + case WSA881X_OTP_REG_12: > + case WSA881X_OTP_REG_13: > + case WSA881X_OTP_REG_14: > + case WSA881X_OTP_REG_15: > + case WSA881X_OTP_REG_16: > + case WSA881X_OTP_REG_17: > + case WSA881X_OTP_REG_18: > + case WSA881X_OTP_REG_19: > + case WSA881X_OTP_REG_20: > + case WSA881X_OTP_REG_21: > + case WSA881X_OTP_REG_22: > + case WSA881X_OTP_REG_23: > + case WSA881X_OTP_REG_24: > + case WSA881X_OTP_REG_25: > + case WSA881X_OTP_REG_26: > + case WSA881X_OTP_REG_27: > + case WSA881X_OTP_REG_28: > + case WSA881X_OTP_REG_29: > + case WSA881X_OTP_REG_30: > + case WSA881X_OTP_REG_31: > + case WSA881X_OTP_REG_63: > + case WSA881X_BIAS_REF_CTRL: > + case WSA881X_BIAS_TEST: > + case WSA881X_BIAS_BIAS: > + case WSA881X_TEMP_OP: > + case WSA881X_TEMP_IREF_CTRL: > + case WSA881X_TEMP_ISENS_CTRL: > + case WSA881X_TEMP_CLK_CTRL: > + case WSA881X_TEMP_TEST: > + case WSA881X_TEMP_BIAS: > + case WSA881X_TEMP_ADC_CTRL: > + case WSA881X_TEMP_DOUT_MSB: > + case WSA881X_TEMP_DOUT_LSB: > + case WSA881X_ADC_EN_MODU_V: > + case WSA881X_ADC_EN_MODU_I: > + case WSA881X_ADC_EN_DET_TEST_V: > + case WSA881X_ADC_EN_DET_TEST_I: > + case WSA881X_ADC_SEL_IBIAS: > + case WSA881X_ADC_EN_SEL_IBIAS: > + case WSA881X_SPKR_DRV_EN: > + case WSA881X_SPKR_DRV_GAIN: > + case WSA881X_SPKR_DAC_CTL: > + case WSA881X_SPKR_DRV_DBG: > + case WSA881X_SPKR_PWRSTG_DBG: > + case WSA881X_SPKR_OCP_CTL: > + case WSA881X_SPKR_CLIP_CTL: > + case WSA881X_SPKR_BBM_CTL: > + case WSA881X_SPKR_MISC_CTL1: > + case WSA881X_SPKR_MISC_CTL2: > + case WSA881X_SPKR_BIAS_INT: > + case WSA881X_SPKR_PA_INT: > + case WSA881X_SPKR_BIAS_CAL: > + case WSA881X_SPKR_BIAS_PSRR: > + case WSA881X_SPKR_STATUS1: > + case WSA881X_SPKR_STATUS2: > + case WSA881X_BOOST_EN_CTL: > + case WSA881X_BOOST_CURRENT_LIMIT: > + case WSA881X_BOOST_PS_CTL: > + case WSA881X_BOOST_PRESET_OUT1: > + case WSA881X_BOOST_PRESET_OUT2: > + case WSA881X_BOOST_FORCE_OUT: > + case WSA881X_BOOST_LDO_PROG: > + case WSA881X_BOOST_SLOPE_COMP_ISENSE_FB: > + case WSA881X_BOOST_RON_CTL: > + case WSA881X_BOOST_LOOP_STABILITY: > + case WSA881X_BOOST_ZX_CTL: > + case WSA881X_BOOST_START_CTL: > + case WSA881X_BOOST_MISC1_CTL: > + case WSA881X_BOOST_MISC2_CTL: > + case WSA881X_BOOST_MISC3_CTL: > + case WSA881X_BOOST_ATEST_CTL: > + case WSA881X_SPKR_PROT_FE_GAIN: > + case WSA881X_SPKR_PROT_FE_CM_LDO_SET: > + case WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET1: > + case WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET2: > + case WSA881X_SPKR_PROT_ATEST1: > + case WSA881X_SPKR_PROT_ATEST2: > + case WSA881X_SPKR_PROT_FE_VSENSE_VCM: > + case WSA881X_SPKR_PROT_FE_VSENSE_BIAS_SET1: > + case WSA881X_BONGO_RESRV_REG1: > + case WSA881X_BONGO_RESRV_REG2: > + case WSA881X_SPKR_PROT_SAR: > + case WSA881X_SPKR_STATUS3: > + return true; > + default: > + return false; > + } > +} > + > +static inline bool wsa881x_volatile_register(struct device *dev, unsigned int reg) > +{ > + switch (reg) { > + case WSA881X_CHIP_ID0: > + case WSA881X_CHIP_ID1: > + case WSA881X_CHIP_ID2: > + case WSA881X_CHIP_ID3: > + case WSA881X_BUS_ID: > + case WSA881X_TEMP_MSB: > + case WSA881X_TEMP_LSB: > + case WSA881X_SDM_PDM9_LSB: > + case WSA881X_SDM_PDM9_MSB: > + case WSA881X_OTP_CTRL1: > + case WSA881X_INTR_STATUS: > + case WSA881X_ATE_TEST_MODE: > + case WSA881X_PIN_STATUS: > + case WSA881X_SWR_HM_TEST2: > + case WSA881X_SPKR_STATUS1: > + case WSA881X_SPKR_STATUS2: > + case WSA881X_SPKR_STATUS3: > + case WSA881X_OTP_REG_0: > + case WSA881X_OTP_REG_1: > + case WSA881X_OTP_REG_2: > + case WSA881X_OTP_REG_3: > + case WSA881X_OTP_REG_4: > + case WSA881X_OTP_REG_5: > + case WSA881X_OTP_REG_31: > + case WSA881X_TEMP_DOUT_MSB: > + case WSA881X_TEMP_DOUT_LSB: > + case WSA881X_TEMP_OP: > + case WSA881X_SPKR_PROT_SAR: > + return true; > + default: > + return false; > + } > +} > + > +#endif /* __WSA881x_COMMON_H__ */ > diff --git a/sound/soc/codecs/wsa881x.c b/sound/soc/codecs/wsa881x.c > index 6627d2da372206eff879f8f3bd5fae9ddc0757d7..3fecc16590a1b0415d944684924f3d41ba3dabd2 100644 > --- a/sound/soc/codecs/wsa881x.c > +++ b/sound/soc/codecs/wsa881x.c > @@ -15,172 +15,7 @@ > #include <sound/soc.h> > #include <sound/tlv.h> > > -#define WSA881X_DIGITAL_BASE 0x3000 > -#define WSA881X_ANALOG_BASE 0x3100 > - > -/* Digital register address space */ > -#define WSA881X_CHIP_ID0 (WSA881X_DIGITAL_BASE + 0x0000) > -#define WSA881X_CHIP_ID1 (WSA881X_DIGITAL_BASE + 0x0001) > -#define WSA881X_CHIP_ID2 (WSA881X_DIGITAL_BASE + 0x0002) > -#define WSA881X_CHIP_ID3 (WSA881X_DIGITAL_BASE + 0x0003) > -#define WSA881X_BUS_ID (WSA881X_DIGITAL_BASE + 0x0004) > -#define WSA881X_CDC_RST_CTL (WSA881X_DIGITAL_BASE + 0x0005) > -#define WSA881X_CDC_TOP_CLK_CTL (WSA881X_DIGITAL_BASE + 0x0006) > -#define WSA881X_CDC_ANA_CLK_CTL (WSA881X_DIGITAL_BASE + 0x0007) > -#define WSA881X_CDC_DIG_CLK_CTL (WSA881X_DIGITAL_BASE + 0x0008) > -#define WSA881X_CLOCK_CONFIG (WSA881X_DIGITAL_BASE + 0x0009) > -#define WSA881X_ANA_CTL (WSA881X_DIGITAL_BASE + 0x000A) > -#define WSA881X_SWR_RESET_EN (WSA881X_DIGITAL_BASE + 0x000B) > -#define WSA881X_RESET_CTL (WSA881X_DIGITAL_BASE + 0x000C) > -#define WSA881X_TADC_VALUE_CTL (WSA881X_DIGITAL_BASE + 0x000F) > -#define WSA881X_TEMP_DETECT_CTL (WSA881X_DIGITAL_BASE + 0x0010) > -#define WSA881X_TEMP_MSB (WSA881X_DIGITAL_BASE + 0x0011) > -#define WSA881X_TEMP_LSB (WSA881X_DIGITAL_BASE + 0x0012) > -#define WSA881X_TEMP_CONFIG0 (WSA881X_DIGITAL_BASE + 0x0013) > -#define WSA881X_TEMP_CONFIG1 (WSA881X_DIGITAL_BASE + 0x0014) > -#define WSA881X_CDC_CLIP_CTL (WSA881X_DIGITAL_BASE + 0x0015) > -#define WSA881X_SDM_PDM9_LSB (WSA881X_DIGITAL_BASE + 0x0016) > -#define WSA881X_SDM_PDM9_MSB (WSA881X_DIGITAL_BASE + 0x0017) > -#define WSA881X_CDC_RX_CTL (WSA881X_DIGITAL_BASE + 0x0018) > -#define WSA881X_DEM_BYPASS_DATA0 (WSA881X_DIGITAL_BASE + 0x0019) > -#define WSA881X_DEM_BYPASS_DATA1 (WSA881X_DIGITAL_BASE + 0x001A) > -#define WSA881X_DEM_BYPASS_DATA2 (WSA881X_DIGITAL_BASE + 0x001B) > -#define WSA881X_DEM_BYPASS_DATA3 (WSA881X_DIGITAL_BASE + 0x001C) > -#define WSA881X_OTP_CTRL0 (WSA881X_DIGITAL_BASE + 0x001D) > -#define WSA881X_OTP_CTRL1 (WSA881X_DIGITAL_BASE + 0x001E) > -#define WSA881X_HDRIVE_CTL_GROUP1 (WSA881X_DIGITAL_BASE + 0x001F) > -#define WSA881X_INTR_MODE (WSA881X_DIGITAL_BASE + 0x0020) > -#define WSA881X_INTR_MASK (WSA881X_DIGITAL_BASE + 0x0021) > -#define WSA881X_INTR_STATUS (WSA881X_DIGITAL_BASE + 0x0022) > -#define WSA881X_INTR_CLEAR (WSA881X_DIGITAL_BASE + 0x0023) > -#define WSA881X_INTR_LEVEL (WSA881X_DIGITAL_BASE + 0x0024) > -#define WSA881X_INTR_SET (WSA881X_DIGITAL_BASE + 0x0025) > -#define WSA881X_INTR_TEST (WSA881X_DIGITAL_BASE + 0x0026) > -#define WSA881X_PDM_TEST_MODE (WSA881X_DIGITAL_BASE + 0x0030) > -#define WSA881X_ATE_TEST_MODE (WSA881X_DIGITAL_BASE + 0x0031) > -#define WSA881X_PIN_CTL_MODE (WSA881X_DIGITAL_BASE + 0x0032) > -#define WSA881X_PIN_CTL_OE (WSA881X_DIGITAL_BASE + 0x0033) > -#define WSA881X_PIN_WDATA_IOPAD (WSA881X_DIGITAL_BASE + 0x0034) > -#define WSA881X_PIN_STATUS (WSA881X_DIGITAL_BASE + 0x0035) > -#define WSA881X_DIG_DEBUG_MODE (WSA881X_DIGITAL_BASE + 0x0037) > -#define WSA881X_DIG_DEBUG_SEL (WSA881X_DIGITAL_BASE + 0x0038) > -#define WSA881X_DIG_DEBUG_EN (WSA881X_DIGITAL_BASE + 0x0039) > -#define WSA881X_SWR_HM_TEST1 (WSA881X_DIGITAL_BASE + 0x003B) > -#define WSA881X_SWR_HM_TEST2 (WSA881X_DIGITAL_BASE + 0x003C) > -#define WSA881X_TEMP_DETECT_DBG_CTL (WSA881X_DIGITAL_BASE + 0x003D) > -#define WSA881X_TEMP_DEBUG_MSB (WSA881X_DIGITAL_BASE + 0x003E) > -#define WSA881X_TEMP_DEBUG_LSB (WSA881X_DIGITAL_BASE + 0x003F) > -#define WSA881X_SAMPLE_EDGE_SEL (WSA881X_DIGITAL_BASE + 0x0044) > -#define WSA881X_IOPAD_CTL (WSA881X_DIGITAL_BASE + 0x0045) > -#define WSA881X_SPARE_0 (WSA881X_DIGITAL_BASE + 0x0050) > -#define WSA881X_SPARE_1 (WSA881X_DIGITAL_BASE + 0x0051) > -#define WSA881X_SPARE_2 (WSA881X_DIGITAL_BASE + 0x0052) > -#define WSA881X_OTP_REG_0 (WSA881X_DIGITAL_BASE + 0x0080) > -#define WSA881X_OTP_REG_1 (WSA881X_DIGITAL_BASE + 0x0081) > -#define WSA881X_OTP_REG_2 (WSA881X_DIGITAL_BASE + 0x0082) > -#define WSA881X_OTP_REG_3 (WSA881X_DIGITAL_BASE + 0x0083) > -#define WSA881X_OTP_REG_4 (WSA881X_DIGITAL_BASE + 0x0084) > -#define WSA881X_OTP_REG_5 (WSA881X_DIGITAL_BASE + 0x0085) > -#define WSA881X_OTP_REG_6 (WSA881X_DIGITAL_BASE + 0x0086) > -#define WSA881X_OTP_REG_7 (WSA881X_DIGITAL_BASE + 0x0087) > -#define WSA881X_OTP_REG_8 (WSA881X_DIGITAL_BASE + 0x0088) > -#define WSA881X_OTP_REG_9 (WSA881X_DIGITAL_BASE + 0x0089) > -#define WSA881X_OTP_REG_10 (WSA881X_DIGITAL_BASE + 0x008A) > -#define WSA881X_OTP_REG_11 (WSA881X_DIGITAL_BASE + 0x008B) > -#define WSA881X_OTP_REG_12 (WSA881X_DIGITAL_BASE + 0x008C) > -#define WSA881X_OTP_REG_13 (WSA881X_DIGITAL_BASE + 0x008D) > -#define WSA881X_OTP_REG_14 (WSA881X_DIGITAL_BASE + 0x008E) > -#define WSA881X_OTP_REG_15 (WSA881X_DIGITAL_BASE + 0x008F) > -#define WSA881X_OTP_REG_16 (WSA881X_DIGITAL_BASE + 0x0090) > -#define WSA881X_OTP_REG_17 (WSA881X_DIGITAL_BASE + 0x0091) > -#define WSA881X_OTP_REG_18 (WSA881X_DIGITAL_BASE + 0x0092) > -#define WSA881X_OTP_REG_19 (WSA881X_DIGITAL_BASE + 0x0093) > -#define WSA881X_OTP_REG_20 (WSA881X_DIGITAL_BASE + 0x0094) > -#define WSA881X_OTP_REG_21 (WSA881X_DIGITAL_BASE + 0x0095) > -#define WSA881X_OTP_REG_22 (WSA881X_DIGITAL_BASE + 0x0096) > -#define WSA881X_OTP_REG_23 (WSA881X_DIGITAL_BASE + 0x0097) > -#define WSA881X_OTP_REG_24 (WSA881X_DIGITAL_BASE + 0x0098) > -#define WSA881X_OTP_REG_25 (WSA881X_DIGITAL_BASE + 0x0099) > -#define WSA881X_OTP_REG_26 (WSA881X_DIGITAL_BASE + 0x009A) > -#define WSA881X_OTP_REG_27 (WSA881X_DIGITAL_BASE + 0x009B) > -#define WSA881X_OTP_REG_28 (WSA881X_DIGITAL_BASE + 0x009C) > -#define WSA881X_OTP_REG_29 (WSA881X_DIGITAL_BASE + 0x009D) > -#define WSA881X_OTP_REG_30 (WSA881X_DIGITAL_BASE + 0x009E) > -#define WSA881X_OTP_REG_31 (WSA881X_DIGITAL_BASE + 0x009F) > -#define WSA881X_OTP_REG_63 (WSA881X_DIGITAL_BASE + 0x00BF) > - > -/* Analog Register address space */ > -#define WSA881X_BIAS_REF_CTRL (WSA881X_ANALOG_BASE + 0x0000) > -#define WSA881X_BIAS_TEST (WSA881X_ANALOG_BASE + 0x0001) > -#define WSA881X_BIAS_BIAS (WSA881X_ANALOG_BASE + 0x0002) > -#define WSA881X_TEMP_OP (WSA881X_ANALOG_BASE + 0x0003) > -#define WSA881X_TEMP_IREF_CTRL (WSA881X_ANALOG_BASE + 0x0004) > -#define WSA881X_TEMP_ISENS_CTRL (WSA881X_ANALOG_BASE + 0x0005) > -#define WSA881X_TEMP_CLK_CTRL (WSA881X_ANALOG_BASE + 0x0006) > -#define WSA881X_TEMP_TEST (WSA881X_ANALOG_BASE + 0x0007) > -#define WSA881X_TEMP_BIAS (WSA881X_ANALOG_BASE + 0x0008) > -#define WSA881X_TEMP_ADC_CTRL (WSA881X_ANALOG_BASE + 0x0009) > -#define WSA881X_TEMP_DOUT_MSB (WSA881X_ANALOG_BASE + 0x000A) > -#define WSA881X_TEMP_DOUT_LSB (WSA881X_ANALOG_BASE + 0x000B) > -#define WSA881X_ADC_EN_MODU_V (WSA881X_ANALOG_BASE + 0x0010) > -#define WSA881X_ADC_EN_MODU_I (WSA881X_ANALOG_BASE + 0x0011) > -#define WSA881X_ADC_EN_DET_TEST_V (WSA881X_ANALOG_BASE + 0x0012) > -#define WSA881X_ADC_EN_DET_TEST_I (WSA881X_ANALOG_BASE + 0x0013) > -#define WSA881X_ADC_SEL_IBIAS (WSA881X_ANALOG_BASE + 0x0014) > -#define WSA881X_ADC_EN_SEL_IBAIS (WSA881X_ANALOG_BASE + 0x0015) > -#define WSA881X_SPKR_DRV_EN (WSA881X_ANALOG_BASE + 0x001A) > -#define WSA881X_SPKR_DRV_GAIN (WSA881X_ANALOG_BASE + 0x001B) > -#define WSA881X_PA_GAIN_SEL_MASK BIT(3) > -#define WSA881X_PA_GAIN_SEL_REG BIT(3) > -#define WSA881X_PA_GAIN_SEL_DRE 0 > -#define WSA881X_SPKR_PAG_GAIN_MASK GENMASK(7, 4) > -#define WSA881X_SPKR_DAC_CTL (WSA881X_ANALOG_BASE + 0x001C) > -#define WSA881X_SPKR_DRV_DBG (WSA881X_ANALOG_BASE + 0x001D) > -#define WSA881X_SPKR_PWRSTG_DBG (WSA881X_ANALOG_BASE + 0x001E) > -#define WSA881X_SPKR_OCP_CTL (WSA881X_ANALOG_BASE + 0x001F) > -#define WSA881X_SPKR_OCP_MASK GENMASK(7, 6) > -#define WSA881X_SPKR_OCP_EN BIT(7) > -#define WSA881X_SPKR_OCP_HOLD BIT(6) > -#define WSA881X_SPKR_CLIP_CTL (WSA881X_ANALOG_BASE + 0x0020) > -#define WSA881X_SPKR_BBM_CTL (WSA881X_ANALOG_BASE + 0x0021) > -#define WSA881X_SPKR_MISC_CTL1 (WSA881X_ANALOG_BASE + 0x0022) > -#define WSA881X_SPKR_MISC_CTL2 (WSA881X_ANALOG_BASE + 0x0023) > -#define WSA881X_SPKR_BIAS_INT (WSA881X_ANALOG_BASE + 0x0024) > -#define WSA881X_SPKR_PA_INT (WSA881X_ANALOG_BASE + 0x0025) > -#define WSA881X_SPKR_BIAS_CAL (WSA881X_ANALOG_BASE + 0x0026) > -#define WSA881X_SPKR_BIAS_PSRR (WSA881X_ANALOG_BASE + 0x0027) > -#define WSA881X_SPKR_STATUS1 (WSA881X_ANALOG_BASE + 0x0028) > -#define WSA881X_SPKR_STATUS2 (WSA881X_ANALOG_BASE + 0x0029) > -#define WSA881X_BOOST_EN_CTL (WSA881X_ANALOG_BASE + 0x002A) > -#define WSA881X_BOOST_EN_MASK BIT(7) > -#define WSA881X_BOOST_EN BIT(7) > -#define WSA881X_BOOST_CURRENT_LIMIT (WSA881X_ANALOG_BASE + 0x002B) > -#define WSA881X_BOOST_PS_CTL (WSA881X_ANALOG_BASE + 0x002C) > -#define WSA881X_BOOST_PRESET_OUT1 (WSA881X_ANALOG_BASE + 0x002D) > -#define WSA881X_BOOST_PRESET_OUT2 (WSA881X_ANALOG_BASE + 0x002E) > -#define WSA881X_BOOST_FORCE_OUT (WSA881X_ANALOG_BASE + 0x002F) > -#define WSA881X_BOOST_LDO_PROG (WSA881X_ANALOG_BASE + 0x0030) > -#define WSA881X_BOOST_SLOPE_COMP_ISENSE_FB (WSA881X_ANALOG_BASE + 0x0031) > -#define WSA881X_BOOST_RON_CTL (WSA881X_ANALOG_BASE + 0x0032) > -#define WSA881X_BOOST_LOOP_STABILITY (WSA881X_ANALOG_BASE + 0x0033) > -#define WSA881X_BOOST_ZX_CTL (WSA881X_ANALOG_BASE + 0x0034) > -#define WSA881X_BOOST_START_CTL (WSA881X_ANALOG_BASE + 0x0035) > -#define WSA881X_BOOST_MISC1_CTL (WSA881X_ANALOG_BASE + 0x0036) > -#define WSA881X_BOOST_MISC2_CTL (WSA881X_ANALOG_BASE + 0x0037) > -#define WSA881X_BOOST_MISC3_CTL (WSA881X_ANALOG_BASE + 0x0038) > -#define WSA881X_BOOST_ATEST_CTL (WSA881X_ANALOG_BASE + 0x0039) > -#define WSA881X_SPKR_PROT_FE_GAIN (WSA881X_ANALOG_BASE + 0x003A) > -#define WSA881X_SPKR_PROT_FE_CM_LDO_SET (WSA881X_ANALOG_BASE + 0x003B) > -#define WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET1 (WSA881X_ANALOG_BASE + 0x003C) > -#define WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET2 (WSA881X_ANALOG_BASE + 0x003D) > -#define WSA881X_SPKR_PROT_ATEST1 (WSA881X_ANALOG_BASE + 0x003E) > -#define WSA881X_SPKR_PROT_ATEST2 (WSA881X_ANALOG_BASE + 0x003F) > -#define WSA881X_SPKR_PROT_FE_VSENSE_VCM (WSA881X_ANALOG_BASE + 0x0040) > -#define WSA881X_SPKR_PROT_FE_VSENSE_BIAS_SET1 (WSA881X_ANALOG_BASE + 0x0041) > -#define WSA881X_BONGO_RESRV_REG1 (WSA881X_ANALOG_BASE + 0x0042) > -#define WSA881X_BONGO_RESRV_REG2 (WSA881X_ANALOG_BASE + 0x0043) > -#define WSA881X_SPKR_PROT_SAR (WSA881X_ANALOG_BASE + 0x0044) > -#define WSA881X_SPKR_STATUS3 (WSA881X_ANALOG_BASE + 0x0045) > +#include "wsa881x-common.h" > > #define SWRS_SCP_FRAME_CTRL_BANK(m) (0x60 + 0x10 * (m)) > #define SWRS_SCP_HOST_CLK_DIV2_CTL_BANK(m) (0xE0 + 0x10 * (m)) > @@ -191,7 +26,6 @@ > #define SWR_SLV_RD_BUF_LEN 8 > #define SWR_SLV_WR_BUF_LEN 32 > #define SWR_SLV_MAX_DEVICES 2 > -#define WSA881X_MAX_SWR_PORTS 4 > #define WSA881X_VERSION_ENTRY_SIZE 27 > #define WSA881X_OCP_CTL_TIMER_SEC 2 > #define WSA881X_OCP_CTL_TEMP_CELSIUS 25 > @@ -300,7 +134,7 @@ static struct reg_default wsa881x_defaults[] = { > { WSA881X_ADC_EN_MODU_I, 0x00 }, > { WSA881X_ADC_EN_DET_TEST_V, 0x00 }, > { WSA881X_ADC_EN_DET_TEST_I, 0x00 }, > - { WSA881X_ADC_EN_SEL_IBAIS, 0x10 }, > + { WSA881X_ADC_EN_SEL_IBIAS, 0x10 }, > { WSA881X_SPKR_DRV_EN, 0x74 }, > { WSA881X_SPKR_DRV_DBG, 0x15 }, > { WSA881X_SPKR_PWRSTG_DBG, 0x00 }, > @@ -434,204 +268,8 @@ static const struct sdw_port_config wsa881x_pconfig[WSA881X_MAX_SWR_PORTS] = { > }, > }; > > -static bool wsa881x_readable_register(struct device *dev, unsigned int reg) > -{ > - switch (reg) { > - case WSA881X_CHIP_ID0: > - case WSA881X_CHIP_ID1: > - case WSA881X_CHIP_ID2: > - case WSA881X_CHIP_ID3: > - case WSA881X_BUS_ID: > - case WSA881X_CDC_RST_CTL: > - case WSA881X_CDC_TOP_CLK_CTL: > - case WSA881X_CDC_ANA_CLK_CTL: > - case WSA881X_CDC_DIG_CLK_CTL: > - case WSA881X_CLOCK_CONFIG: > - case WSA881X_ANA_CTL: > - case WSA881X_SWR_RESET_EN: > - case WSA881X_RESET_CTL: > - case WSA881X_TADC_VALUE_CTL: > - case WSA881X_TEMP_DETECT_CTL: > - case WSA881X_TEMP_MSB: > - case WSA881X_TEMP_LSB: > - case WSA881X_TEMP_CONFIG0: > - case WSA881X_TEMP_CONFIG1: > - case WSA881X_CDC_CLIP_CTL: > - case WSA881X_SDM_PDM9_LSB: > - case WSA881X_SDM_PDM9_MSB: > - case WSA881X_CDC_RX_CTL: > - case WSA881X_DEM_BYPASS_DATA0: > - case WSA881X_DEM_BYPASS_DATA1: > - case WSA881X_DEM_BYPASS_DATA2: > - case WSA881X_DEM_BYPASS_DATA3: > - case WSA881X_OTP_CTRL0: > - case WSA881X_OTP_CTRL1: > - case WSA881X_HDRIVE_CTL_GROUP1: > - case WSA881X_INTR_MODE: > - case WSA881X_INTR_MASK: > - case WSA881X_INTR_STATUS: > - case WSA881X_INTR_CLEAR: > - case WSA881X_INTR_LEVEL: > - case WSA881X_INTR_SET: > - case WSA881X_INTR_TEST: > - case WSA881X_PDM_TEST_MODE: > - case WSA881X_ATE_TEST_MODE: > - case WSA881X_PIN_CTL_MODE: > - case WSA881X_PIN_CTL_OE: > - case WSA881X_PIN_WDATA_IOPAD: > - case WSA881X_PIN_STATUS: > - case WSA881X_DIG_DEBUG_MODE: > - case WSA881X_DIG_DEBUG_SEL: > - case WSA881X_DIG_DEBUG_EN: > - case WSA881X_SWR_HM_TEST1: > - case WSA881X_SWR_HM_TEST2: > - case WSA881X_TEMP_DETECT_DBG_CTL: > - case WSA881X_TEMP_DEBUG_MSB: > - case WSA881X_TEMP_DEBUG_LSB: > - case WSA881X_SAMPLE_EDGE_SEL: > - case WSA881X_IOPAD_CTL: > - case WSA881X_SPARE_0: > - case WSA881X_SPARE_1: > - case WSA881X_SPARE_2: > - case WSA881X_OTP_REG_0: > - case WSA881X_OTP_REG_1: > - case WSA881X_OTP_REG_2: > - case WSA881X_OTP_REG_3: > - case WSA881X_OTP_REG_4: > - case WSA881X_OTP_REG_5: > - case WSA881X_OTP_REG_6: > - case WSA881X_OTP_REG_7: > - case WSA881X_OTP_REG_8: > - case WSA881X_OTP_REG_9: > - case WSA881X_OTP_REG_10: > - case WSA881X_OTP_REG_11: > - case WSA881X_OTP_REG_12: > - case WSA881X_OTP_REG_13: > - case WSA881X_OTP_REG_14: > - case WSA881X_OTP_REG_15: > - case WSA881X_OTP_REG_16: > - case WSA881X_OTP_REG_17: > - case WSA881X_OTP_REG_18: > - case WSA881X_OTP_REG_19: > - case WSA881X_OTP_REG_20: > - case WSA881X_OTP_REG_21: > - case WSA881X_OTP_REG_22: > - case WSA881X_OTP_REG_23: > - case WSA881X_OTP_REG_24: > - case WSA881X_OTP_REG_25: > - case WSA881X_OTP_REG_26: > - case WSA881X_OTP_REG_27: > - case WSA881X_OTP_REG_28: > - case WSA881X_OTP_REG_29: > - case WSA881X_OTP_REG_30: > - case WSA881X_OTP_REG_31: > - case WSA881X_OTP_REG_63: > - case WSA881X_BIAS_REF_CTRL: > - case WSA881X_BIAS_TEST: > - case WSA881X_BIAS_BIAS: > - case WSA881X_TEMP_OP: > - case WSA881X_TEMP_IREF_CTRL: > - case WSA881X_TEMP_ISENS_CTRL: > - case WSA881X_TEMP_CLK_CTRL: > - case WSA881X_TEMP_TEST: > - case WSA881X_TEMP_BIAS: > - case WSA881X_TEMP_ADC_CTRL: > - case WSA881X_TEMP_DOUT_MSB: > - case WSA881X_TEMP_DOUT_LSB: > - case WSA881X_ADC_EN_MODU_V: > - case WSA881X_ADC_EN_MODU_I: > - case WSA881X_ADC_EN_DET_TEST_V: > - case WSA881X_ADC_EN_DET_TEST_I: > - case WSA881X_ADC_SEL_IBIAS: > - case WSA881X_ADC_EN_SEL_IBAIS: > - case WSA881X_SPKR_DRV_EN: > - case WSA881X_SPKR_DRV_GAIN: > - case WSA881X_SPKR_DAC_CTL: > - case WSA881X_SPKR_DRV_DBG: > - case WSA881X_SPKR_PWRSTG_DBG: > - case WSA881X_SPKR_OCP_CTL: > - case WSA881X_SPKR_CLIP_CTL: > - case WSA881X_SPKR_BBM_CTL: > - case WSA881X_SPKR_MISC_CTL1: > - case WSA881X_SPKR_MISC_CTL2: > - case WSA881X_SPKR_BIAS_INT: > - case WSA881X_SPKR_PA_INT: > - case WSA881X_SPKR_BIAS_CAL: > - case WSA881X_SPKR_BIAS_PSRR: > - case WSA881X_SPKR_STATUS1: > - case WSA881X_SPKR_STATUS2: > - case WSA881X_BOOST_EN_CTL: > - case WSA881X_BOOST_CURRENT_LIMIT: > - case WSA881X_BOOST_PS_CTL: > - case WSA881X_BOOST_PRESET_OUT1: > - case WSA881X_BOOST_PRESET_OUT2: > - case WSA881X_BOOST_FORCE_OUT: > - case WSA881X_BOOST_LDO_PROG: > - case WSA881X_BOOST_SLOPE_COMP_ISENSE_FB: > - case WSA881X_BOOST_RON_CTL: > - case WSA881X_BOOST_LOOP_STABILITY: > - case WSA881X_BOOST_ZX_CTL: > - case WSA881X_BOOST_START_CTL: > - case WSA881X_BOOST_MISC1_CTL: > - case WSA881X_BOOST_MISC2_CTL: > - case WSA881X_BOOST_MISC3_CTL: > - case WSA881X_BOOST_ATEST_CTL: > - case WSA881X_SPKR_PROT_FE_GAIN: > - case WSA881X_SPKR_PROT_FE_CM_LDO_SET: > - case WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET1: > - case WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET2: > - case WSA881X_SPKR_PROT_ATEST1: > - case WSA881X_SPKR_PROT_ATEST2: > - case WSA881X_SPKR_PROT_FE_VSENSE_VCM: > - case WSA881X_SPKR_PROT_FE_VSENSE_BIAS_SET1: > - case WSA881X_BONGO_RESRV_REG1: > - case WSA881X_BONGO_RESRV_REG2: > - case WSA881X_SPKR_PROT_SAR: > - case WSA881X_SPKR_STATUS3: > - return true; > - default: > - return false; > - } > -} > - > -static bool wsa881x_volatile_register(struct device *dev, unsigned int reg) > -{ > - switch (reg) { > - case WSA881X_CHIP_ID0: > - case WSA881X_CHIP_ID1: > - case WSA881X_CHIP_ID2: > - case WSA881X_CHIP_ID3: > - case WSA881X_BUS_ID: > - case WSA881X_TEMP_MSB: > - case WSA881X_TEMP_LSB: > - case WSA881X_SDM_PDM9_LSB: > - case WSA881X_SDM_PDM9_MSB: > - case WSA881X_OTP_CTRL1: > - case WSA881X_INTR_STATUS: > - case WSA881X_ATE_TEST_MODE: > - case WSA881X_PIN_STATUS: > - case WSA881X_SWR_HM_TEST2: > - case WSA881X_SPKR_STATUS1: > - case WSA881X_SPKR_STATUS2: > - case WSA881X_SPKR_STATUS3: > - case WSA881X_OTP_REG_0: > - case WSA881X_OTP_REG_1: > - case WSA881X_OTP_REG_2: > - case WSA881X_OTP_REG_3: > - case WSA881X_OTP_REG_4: > - case WSA881X_OTP_REG_5: > - case WSA881X_OTP_REG_31: > - case WSA881X_TEMP_DOUT_MSB: > - case WSA881X_TEMP_DOUT_LSB: > - case WSA881X_TEMP_OP: > - case WSA881X_SPKR_PROT_SAR: > - return true; > - default: > - return false; > - } > -} > - > static const struct regmap_config wsa881x_regmap_config = { > + .reg_base = 0x3000, > .reg_bits = 32, > .val_bits = 8, > .cache_type = REGCACHE_MAPLE, > @@ -660,70 +298,15 @@ enum { > G_0DB, > }; > > -/* > - * Private data Structure for wsa881x. All parameters related to > - * WSA881X codec needs to be defined here. > - */ > -struct wsa881x_priv { > - struct regmap *regmap; > - struct device *dev; > - struct sdw_slave *slave; > - struct sdw_stream_config sconfig; > - struct sdw_stream_runtime *sruntime; > - struct sdw_port_config port_config[WSA881X_MAX_SWR_PORTS]; > - struct gpio_desc *sd_n; > - /* > - * Logical state for SD_N GPIO: high for shutdown, low for enable. > - * For backwards compatibility. > - */ > - unsigned int sd_n_val; > - int active_ports; > - bool port_prepared[WSA881X_MAX_SWR_PORTS]; > - bool port_enable[WSA881X_MAX_SWR_PORTS]; > -}; > - > static void wsa881x_init(struct wsa881x_priv *wsa881x) > { > - struct regmap *rm = wsa881x->regmap; > - unsigned int val = 0; > - > regmap_register_patch(wsa881x->regmap, wsa881x_rev_2_0, > ARRAY_SIZE(wsa881x_rev_2_0)); > > /* Enable software reset output from soundwire slave */ > - regmap_update_bits(rm, WSA881X_SWR_RESET_EN, 0x07, 0x07); > - > - /* Bring out of analog reset */ > - regmap_update_bits(rm, WSA881X_CDC_RST_CTL, 0x02, 0x02); > - > - /* Bring out of digital reset */ > - regmap_update_bits(rm, WSA881X_CDC_RST_CTL, 0x01, 0x01); > - regmap_update_bits(rm, WSA881X_CLOCK_CONFIG, 0x10, 0x10); > - regmap_update_bits(rm, WSA881X_SPKR_OCP_CTL, 0x02, 0x02); > - regmap_update_bits(rm, WSA881X_SPKR_MISC_CTL1, 0xC0, 0x80); > - regmap_update_bits(rm, WSA881X_SPKR_MISC_CTL1, 0x06, 0x06); > - regmap_update_bits(rm, WSA881X_SPKR_BIAS_INT, 0xFF, 0x00); > - regmap_update_bits(rm, WSA881X_SPKR_PA_INT, 0xF0, 0x40); > - regmap_update_bits(rm, WSA881X_SPKR_PA_INT, 0x0E, 0x0E); > - regmap_update_bits(rm, WSA881X_BOOST_LOOP_STABILITY, 0x03, 0x03); > - regmap_update_bits(rm, WSA881X_BOOST_MISC2_CTL, 0xFF, 0x14); > - regmap_update_bits(rm, WSA881X_BOOST_START_CTL, 0x80, 0x80); > - regmap_update_bits(rm, WSA881X_BOOST_START_CTL, 0x03, 0x00); > - regmap_update_bits(rm, WSA881X_BOOST_SLOPE_COMP_ISENSE_FB, 0x0C, 0x04); > - regmap_update_bits(rm, WSA881X_BOOST_SLOPE_COMP_ISENSE_FB, 0x03, 0x00); > - > - regmap_read(rm, WSA881X_OTP_REG_0, &val); > - if (val) > - regmap_update_bits(rm, WSA881X_BOOST_PRESET_OUT1, 0xF0, 0x70); > - > - regmap_update_bits(rm, WSA881X_BOOST_PRESET_OUT2, 0xF0, 0x30); > - regmap_update_bits(rm, WSA881X_SPKR_DRV_EN, 0x08, 0x08); > - regmap_update_bits(rm, WSA881X_BOOST_CURRENT_LIMIT, 0x0F, 0x08); > - regmap_update_bits(rm, WSA881X_SPKR_OCP_CTL, 0x30, 0x30); > - regmap_update_bits(rm, WSA881X_SPKR_OCP_CTL, 0x0C, 0x00); > - regmap_update_bits(rm, WSA881X_OTP_REG_28, 0x3F, 0x3A); > - regmap_update_bits(rm, WSA881X_BONGO_RESRV_REG1, 0xFF, 0xB2); > - regmap_update_bits(rm, WSA881X_BONGO_RESRV_REG2, 0xFF, 0x05); > + regmap_update_bits(wsa881x->regmap, WSA881X_SWR_RESET_EN, 0x07, 0x07); > + > + wsa881x_init_common(wsa881x); > } > > static int wsa881x_component_probe(struct snd_soc_component *comp) > @@ -932,7 +515,7 @@ static int wsa881x_spkr_pa_event(struct snd_soc_dapm_widget *w, > if (wsa881x->port_prepared[WSA881X_PORT_VISENSE]) { > wsa881x_visense_txfe_ctrl(comp, true); > snd_soc_component_update_bits(comp, > - WSA881X_ADC_EN_SEL_IBAIS, > + WSA881X_ADC_EN_SEL_IBIAS, > 0x07, 0x01); > wsa881x_visense_adc_ctrl(comp, true); > } > @@ -1003,35 +586,11 @@ static int wsa881x_hw_free(struct snd_pcm_substream *substream, > return 0; > } > > -static int wsa881x_set_sdw_stream(struct snd_soc_dai *dai, > - void *stream, int direction) > -{ > - struct wsa881x_priv *wsa881x = dev_get_drvdata(dai->dev); > - > - wsa881x->sruntime = stream; > - > - return 0; > -} > - > -static int wsa881x_digital_mute(struct snd_soc_dai *dai, int mute, int stream) > -{ > - struct wsa881x_priv *wsa881x = dev_get_drvdata(dai->dev); > - > - if (mute) > - regmap_update_bits(wsa881x->regmap, WSA881X_SPKR_DRV_EN, 0x80, > - 0x00); > - else > - regmap_update_bits(wsa881x->regmap, WSA881X_SPKR_DRV_EN, 0x80, > - 0x80); > - > - return 0; > -} > - > static const struct snd_soc_dai_ops wsa881x_dai_ops = { > .hw_params = wsa881x_hw_params, > .hw_free = wsa881x_hw_free, > .mute_stream = wsa881x_digital_mute, > - .set_stream = wsa881x_set_sdw_stream, > + .set_stream = wsa881x_set_stream, > }; > > static struct snd_soc_dai_driver wsa881x_dais[] = { > @@ -1108,40 +667,13 @@ static int wsa881x_probe(struct sdw_slave *pdev, > { > struct wsa881x_priv *wsa881x; > struct device *dev = &pdev->dev; > + int ret; > > - wsa881x = devm_kzalloc(dev, sizeof(*wsa881x), GFP_KERNEL); > - if (!wsa881x) > - return -ENOMEM; > - > - wsa881x->sd_n = devm_gpiod_get_optional(dev, "powerdown", > - GPIOD_FLAGS_BIT_NONEXCLUSIVE); > - if (IS_ERR(wsa881x->sd_n)) > - return dev_err_probe(dev, PTR_ERR(wsa881x->sd_n), > - "Shutdown Control GPIO not found\n"); > - > - /* > - * Backwards compatibility work-around. > - * > - * The SD_N GPIO is active low, however upstream DTS used always active > - * high. Changing the flag in driver and DTS will break backwards > - * compatibility, so add a simple value inversion to work with both old > - * and new DTS. > - * > - * This won't work properly with DTS using the flags properly in cases: > - * 1. Old DTS with proper ACTIVE_LOW, however such case was broken > - * before as the driver required the active high. > - * 2. New DTS with proper ACTIVE_HIGH (intended), which is rare case > - * (not existing upstream) but possible. This is the price of > - * backwards compatibility, therefore this hack should be removed at > - * some point. > - */ > - wsa881x->sd_n_val = gpiod_is_active_low(wsa881x->sd_n); > - if (!wsa881x->sd_n_val) > - dev_warn(dev, "Using ACTIVE_HIGH for shutdown GPIO. Your DTB might be outdated or you use unsupported configuration for the GPIO."); > + ret = wsa881x_probe_common(&wsa881x, dev); > + if (ret) > + return ret; > > - dev_set_drvdata(dev, wsa881x); > wsa881x->slave = pdev; > - wsa881x->dev = dev; > wsa881x->sconfig.ch_count = 1; > wsa881x->sconfig.bps = 1; > wsa881x->sconfig.frame_rate = 48000; > @@ -1151,7 +683,6 @@ static int wsa881x_probe(struct sdw_slave *pdev, > pdev->prop.sink_dpn_prop = wsa_sink_dpn_prop; > pdev->prop.scp_int1_mask = SDW_SCP_INT1_BUS_CLASH | SDW_SCP_INT1_PARITY; > pdev->prop.clk_stop_mode1 = true; > - gpiod_direction_output(wsa881x->sd_n, !wsa881x->sd_n_val); > > wsa881x->regmap = devm_regmap_init_sdw(pdev, &wsa881x_regmap_config); > if (IS_ERR(wsa881x->regmap)) > ^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v3 06/12] ASoC: codecs: add wsa881x-i2c amplifier codec driver 2025-05-22 17:40 [PATCH v3 00/12] qrb4210-rb2: add wsa audio playback and capture support Alexey Klimov ` (4 preceding siblings ...) 2025-05-22 17:40 ` [PATCH v3 05/12] ASoC: codecs: wsa881x: split into common and soundwire drivers Alexey Klimov @ 2025-05-22 17:40 ` Alexey Klimov 2025-05-23 12:59 ` kernel test robot 2025-05-29 10:05 ` Srinivas Kandagatla 2025-05-22 17:40 ` [PATCH v3 07/12] arm64: dts: qcom: sm6115: add LPASS devices Alexey Klimov ` (6 subsequent siblings) 12 siblings, 2 replies; 43+ messages in thread From: Alexey Klimov @ 2025-05-22 17:40 UTC (permalink / raw) To: Srinivas Kandagatla, Mark Brown, linux-sound Cc: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio Add support to analog mode of WSA8810/WSA8815 Class-D Smart Speaker family of amplifiers. Such amplifiers are primarily interfaced with SoundWire but they also support analog mode which is configurable by setting one of the pins to high/low. In such case the WSA881X amplifier is configurable only using i2c. To have stereo two WSA881X amplifiers are required but mono configurations are also possible. Cc: Srinivas Kandagatla <srini@kernel.org> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> --- sound/soc/codecs/Kconfig | 11 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/wsa881x-common.h | 20 + sound/soc/codecs/wsa881x-i2c.c | 1353 +++++++++++++++++++++++++++++++++++++ 4 files changed, 1386 insertions(+) diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index ba6e4504b5e9951203bd61fae894e86e9d40048e..9fef16003e2b7bb650c9a6bbcfd5d2f58626a5ae 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -357,6 +357,7 @@ config SND_SOC_ALL_CODECS imply SND_SOC_WM9712 imply SND_SOC_WM9713 imply SND_SOC_WSA881X + imply SND_SOC_WSA881X_I2C imply SND_SOC_WSA883X imply SND_SOC_WSA884X imply SND_SOC_ZL38060 @@ -2555,6 +2556,16 @@ config SND_SOC_WSA881X This enables support for Qualcomm WSA8810/WSA8815 Class-D Smart Speaker Amplifier. +config SND_SOC_WSA881X_I2C + tristate "WSA881X Codec - Analog mode" + depends on I2C + select REGMAP_I2C + select SND_SOC_WSA881X_COMMON + help + This enables support for Qualcomm WSA8810/WSA8815 Class-D Smart + Speaker Amplifier that works in analog mode and configurable + via I2C. + config SND_SOC_WSA883X tristate "WSA883X Codec" depends on SOUNDWIRE diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 212d419cfe3c0fbd5d4e475e5d81c69ef930b3e1..7f2ec25a279087078d9480c1b14506e70c80d552 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -407,6 +407,7 @@ snd-soc-wm9713-y := wm9713.o snd-soc-wm-hubs-y := wm_hubs.o snd-soc-wsa881x-y := wsa881x.o snd-soc-wsa881x-common-y := wsa881x-common.o +snd-soc-wsa881x-i2c-y := wsa881x-i2c.o snd-soc-wsa883x-y := wsa883x.o snd-soc-wsa884x-y := wsa884x.o snd-soc-zl38060-y := zl38060.o @@ -837,6 +838,7 @@ obj-$(CONFIG_SND_SOC_WM_ADSP) += snd-soc-wm-adsp.o obj-$(CONFIG_SND_SOC_WM_HUBS) += snd-soc-wm-hubs.o obj-$(CONFIG_SND_SOC_WSA881X) += snd-soc-wsa881x.o obj-$(CONFIG_SND_SOC_WSA881X_COMMON) += snd-soc-wsa881x-common.o +obj-$(CONFIG_SND_SOC_WSA881X_I2C) += snd-soc-wsa881x-i2c.o obj-$(CONFIG_SND_SOC_WSA883X) += snd-soc-wsa883x.o obj-$(CONFIG_SND_SOC_WSA884X) += snd-soc-wsa884x.o obj-$(CONFIG_SND_SOC_ZL38060) += snd-soc-zl38060.o diff --git a/sound/soc/codecs/wsa881x-common.h b/sound/soc/codecs/wsa881x-common.h index ab4ee5848b10fe6ca4160b7ff634e7e06b6e41e6..a3322ad1a6eac220244a29c0540ea5dbe3118106 100644 --- a/sound/soc/codecs/wsa881x-common.h +++ b/sound/soc/codecs/wsa881x-common.h @@ -2,6 +2,7 @@ #ifndef __WSA881x_COMMON_H__ #define __WSA881x_COMMON_H__ +#include <linux/i2c.h> #include <linux/soundwire/sdw.h> #include <sound/soc.h> @@ -245,6 +246,25 @@ struct wsa881x_priv { bool port_enable[WSA881X_MAX_SWR_PORTS]; #endif +#if IS_ENABLED(CONFIG_SND_SOC_WSA881X_I2C) + /* i2c interace for analog mode */ + struct regmap *regmap_analog; + /* + * First client is for the digital part, + * the second one is for analog part + */ + struct i2c_client *client[2]; + struct i2c_msg xfer_msg[2]; + struct snd_soc_component *component; + struct snd_soc_dai_driver *dai_driver; + const struct snd_soc_component_driver *driver; + struct gpio_desc *mclk_pin; + struct clk *wsa_mclk; + bool regmap_flag; + bool boost_enable; + int spk_pa_gain; + int version; +#endif struct gpio_desc *sd_n; /* * Logical state for SD_N GPIO: high for shutdown, low for enable. diff --git a/sound/soc/codecs/wsa881x-i2c.c b/sound/soc/codecs/wsa881x-i2c.c new file mode 100644 index 0000000000000000000000000000000000000000..5fa3940c65877e480aecb53acdfad5fd6ff905bd --- /dev/null +++ b/sound/soc/codecs/wsa881x-i2c.c @@ -0,0 +1,1353 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2015-2016, 2018-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2025, Linaro Limited + */ + +#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/device.h> +#include <linux/gpio.h> +#include <linux/i2c.h> +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/platform_device.h> +#include <linux/printk.h> +#include <linux/pm_runtime.h> +#include <linux/regmap.h> +#include <linux/slab.h> +#include <sound/pcm.h> +#include <sound/pcm_params.h> +#include <sound/soc.h> +#include <sound/soc-dapm.h> +#include "wsa881x-common.h" + +#define I2C_ANALOG_OFFSET 0x36 +#define SPK_GAIN_12DB 4 + +#define WSA881X_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\ + SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\ + SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000 |\ + SNDRV_PCM_RATE_384000) +/* Fractional Rates */ +#define WSA881X_FRAC_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_88200 |\ + SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800) + +#define WSA881X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\ + SNDRV_PCM_FMTBIT_S24_LE |\ + SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE) + +#define WSA881X_I2C_DRV_NAME "wsa881x_i2c_codec" + +#define DIGITAL 0 +#define ANALOG 1 + +enum { + WSA881X_1_X = 0, + WSA881X_2_0, +}; + +#define WSA881X_IS_2_0(ver) ((ver == WSA881X_2_0) ? 1 : 0) + +struct reg_default wsa881x_ana_reg_defaults[] = { + {WSA881X_CHIP_ID0, 0x00}, + {WSA881X_CHIP_ID1, 0x00}, + {WSA881X_CHIP_ID2, 0x00}, + {WSA881X_CHIP_ID3, 0x02}, + {WSA881X_BUS_ID, 0x00}, + {WSA881X_CDC_RST_CTL, 0x00}, + {WSA881X_CDC_TOP_CLK_CTL, 0x03}, + {WSA881X_CDC_ANA_CLK_CTL, 0x00}, + {WSA881X_CDC_DIG_CLK_CTL, 0x00}, + {WSA881X_CLOCK_CONFIG, 0x00}, + {WSA881X_ANA_CTL, 0x08}, + {WSA881X_SWR_RESET_EN, 0x00}, + {WSA881X_TEMP_DETECT_CTL, 0x01}, + {WSA881X_TEMP_MSB, 0x00}, + {WSA881X_TEMP_LSB, 0x00}, + {WSA881X_TEMP_CONFIG0, 0x00}, + {WSA881X_TEMP_CONFIG1, 0x00}, + {WSA881X_CDC_CLIP_CTL, 0x03}, + {WSA881X_SDM_PDM9_LSB, 0x00}, + {WSA881X_SDM_PDM9_MSB, 0x00}, + {WSA881X_CDC_RX_CTL, 0x7E}, + {WSA881X_DEM_BYPASS_DATA0, 0x00}, + {WSA881X_DEM_BYPASS_DATA1, 0x00}, + {WSA881X_DEM_BYPASS_DATA2, 0x00}, + {WSA881X_DEM_BYPASS_DATA3, 0x00}, + {WSA881X_OTP_CTRL0, 0x00}, + {WSA881X_OTP_CTRL1, 0x00}, + {WSA881X_HDRIVE_CTL_GROUP1, 0x00}, + {WSA881X_INTR_MODE, 0x00}, + {WSA881X_INTR_MASK, 0x1F}, + {WSA881X_INTR_STATUS, 0x00}, + {WSA881X_INTR_CLEAR, 0x00}, + {WSA881X_INTR_LEVEL, 0x00}, + {WSA881X_INTR_SET, 0x00}, + {WSA881X_INTR_TEST, 0x00}, + {WSA881X_PDM_TEST_MODE, 0x00}, + {WSA881X_ATE_TEST_MODE, 0x00}, + {WSA881X_PIN_CTL_MODE, 0x00}, + {WSA881X_PIN_CTL_OE, 0x00}, + {WSA881X_PIN_WDATA_IOPAD, 0x00}, + {WSA881X_PIN_STATUS, 0x00}, + {WSA881X_DIG_DEBUG_MODE, 0x00}, + {WSA881X_DIG_DEBUG_SEL, 0x00}, + {WSA881X_DIG_DEBUG_EN, 0x00}, + {WSA881X_SWR_HM_TEST1, 0x08}, + {WSA881X_SWR_HM_TEST2, 0x00}, + {WSA881X_TEMP_DETECT_DBG_CTL, 0x00}, + {WSA881X_TEMP_DEBUG_MSB, 0x00}, + {WSA881X_TEMP_DEBUG_LSB, 0x00}, + {WSA881X_SAMPLE_EDGE_SEL, 0x0C}, + {WSA881X_SPARE_0, 0x00}, + {WSA881X_SPARE_1, 0x00}, + {WSA881X_SPARE_2, 0x00}, + {WSA881X_OTP_REG_0, 0x01}, + {WSA881X_OTP_REG_1, 0xFF}, + {WSA881X_OTP_REG_2, 0xC0}, + {WSA881X_OTP_REG_3, 0xFF}, + {WSA881X_OTP_REG_4, 0xC0}, + {WSA881X_OTP_REG_5, 0xFF}, + {WSA881X_OTP_REG_6, 0xFF}, + {WSA881X_OTP_REG_7, 0xFF}, + {WSA881X_OTP_REG_8, 0xFF}, + {WSA881X_OTP_REG_9, 0xFF}, + {WSA881X_OTP_REG_10, 0xFF}, + {WSA881X_OTP_REG_11, 0xFF}, + {WSA881X_OTP_REG_12, 0xFF}, + {WSA881X_OTP_REG_13, 0xFF}, + {WSA881X_OTP_REG_14, 0xFF}, + {WSA881X_OTP_REG_15, 0xFF}, + {WSA881X_OTP_REG_16, 0xFF}, + {WSA881X_OTP_REG_17, 0xFF}, + {WSA881X_OTP_REG_18, 0xFF}, + {WSA881X_OTP_REG_19, 0xFF}, + {WSA881X_OTP_REG_20, 0xFF}, + {WSA881X_OTP_REG_21, 0xFF}, + {WSA881X_OTP_REG_22, 0xFF}, + {WSA881X_OTP_REG_23, 0xFF}, + {WSA881X_OTP_REG_24, 0x03}, + {WSA881X_OTP_REG_25, 0x01}, + {WSA881X_OTP_REG_26, 0x03}, + {WSA881X_OTP_REG_27, 0x11}, + {WSA881X_OTP_REG_28, 0xFF}, + {WSA881X_OTP_REG_29, 0xFF}, + {WSA881X_OTP_REG_30, 0xFF}, + {WSA881X_OTP_REG_31, 0xFF}, + {WSA881X_OTP_REG_63, 0x40}, + /* WSA881x Analog registers */ + {WSA881X_BIAS_REF_CTRL, 0x6C}, + {WSA881X_BIAS_TEST, 0x16}, + {WSA881X_BIAS_BIAS, 0xF0}, + {WSA881X_TEMP_OP, 0x00}, + {WSA881X_TEMP_IREF_CTRL, 0x56}, + {WSA881X_TEMP_ISENS_CTRL, 0x47}, + {WSA881X_TEMP_CLK_CTRL, 0x87}, + {WSA881X_TEMP_TEST, 0x00}, + {WSA881X_TEMP_BIAS, 0x51}, + {WSA881X_TEMP_ADC_CTRL, 0x00}, + {WSA881X_TEMP_DOUT_MSB, 0x00}, + {WSA881X_TEMP_DOUT_LSB, 0x00}, + {WSA881X_ADC_EN_MODU_V, 0x00}, + {WSA881X_ADC_EN_MODU_I, 0x00}, + {WSA881X_ADC_EN_DET_TEST_V, 0x00}, + {WSA881X_ADC_EN_DET_TEST_I, 0x00}, + {WSA881X_ADC_SEL_IBIAS, 0x25}, + {WSA881X_ADC_EN_SEL_IBIAS, 0x10}, + {WSA881X_SPKR_DRV_EN, 0x74}, + {WSA881X_SPKR_DRV_GAIN, 0x01}, + {WSA881X_SPKR_DAC_CTL, 0x40}, + {WSA881X_SPKR_DRV_DBG, 0x15}, + {WSA881X_SPKR_PWRSTG_DBG, 0x00}, + {WSA881X_SPKR_OCP_CTL, 0xD4}, + {WSA881X_SPKR_CLIP_CTL, 0x90}, + {WSA881X_SPKR_BBM_CTL, 0x00}, + {WSA881X_SPKR_MISC_CTL1, 0x80}, + {WSA881X_SPKR_MISC_CTL2, 0x00}, + {WSA881X_SPKR_BIAS_INT, 0x56}, + {WSA881X_SPKR_PA_INT, 0x54}, + {WSA881X_SPKR_BIAS_CAL, 0xAC}, + {WSA881X_SPKR_BIAS_PSRR, 0x54}, + {WSA881X_SPKR_STATUS1, 0x00}, + {WSA881X_SPKR_STATUS2, 0x00}, + {WSA881X_BOOST_EN_CTL, 0x18}, + {WSA881X_BOOST_CURRENT_LIMIT, 0x7A}, + {WSA881X_BOOST_PS_CTL, 0xC0}, + {WSA881X_BOOST_PRESET_OUT1, 0x77}, + {WSA881X_BOOST_PRESET_OUT2, 0x70}, + {WSA881X_BOOST_FORCE_OUT, 0x0E}, + {WSA881X_BOOST_LDO_PROG, 0x16}, + {WSA881X_BOOST_SLOPE_COMP_ISENSE_FB, 0x71}, + {WSA881X_BOOST_RON_CTL, 0x0F}, + {WSA881X_BOOST_LOOP_STABILITY, 0xAD}, + {WSA881X_BOOST_ZX_CTL, 0x34}, + {WSA881X_BOOST_START_CTL, 0x23}, + {WSA881X_BOOST_MISC1_CTL, 0x80}, + {WSA881X_BOOST_MISC2_CTL, 0x00}, + {WSA881X_BOOST_MISC3_CTL, 0x00}, + {WSA881X_BOOST_ATEST_CTL, 0x00}, + {WSA881X_SPKR_PROT_FE_GAIN, 0x46}, + {WSA881X_SPKR_PROT_FE_CM_LDO_SET, 0x3B}, + {WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET1, 0x8D}, + {WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET2, 0x8D}, + {WSA881X_SPKR_PROT_ATEST1, 0x01}, + {WSA881X_SPKR_PROT_ATEST2, 0x00}, + {WSA881X_SPKR_PROT_FE_VSENSE_VCM, 0x8D}, + {WSA881X_SPKR_PROT_FE_VSENSE_BIAS_SET1, 0x4D}, + {WSA881X_BONGO_RESRV_REG1, 0x00}, + {WSA881X_BONGO_RESRV_REG2, 0x00}, + {WSA881X_SPKR_PROT_SAR, 0x00}, + {WSA881X_SPKR_STATUS3, 0x00}, +}; + +const struct reg_default wsa881x_ana_reg_defaults_0[] = { + {WSA881X_CHIP_ID0, 0x00}, + {WSA881X_CHIP_ID1, 0x00}, + {WSA881X_CHIP_ID2, 0x00}, + {WSA881X_CHIP_ID3, 0x02}, + {WSA881X_BUS_ID, 0x00}, + {WSA881X_CDC_RST_CTL, 0x00}, + {WSA881X_CDC_TOP_CLK_CTL, 0x03}, + {WSA881X_CDC_ANA_CLK_CTL, 0x00}, + {WSA881X_CDC_DIG_CLK_CTL, 0x00}, + {WSA881X_CLOCK_CONFIG, 0x00}, + {WSA881X_ANA_CTL, 0x08}, + {WSA881X_SWR_RESET_EN, 0x00}, + {WSA881X_TEMP_DETECT_CTL, 0x01}, + {WSA881X_TEMP_MSB, 0x00}, + {WSA881X_TEMP_LSB, 0x00}, + {WSA881X_TEMP_CONFIG0, 0x00}, + {WSA881X_TEMP_CONFIG1, 0x00}, + {WSA881X_CDC_CLIP_CTL, 0x03}, + {WSA881X_SDM_PDM9_LSB, 0x00}, + {WSA881X_SDM_PDM9_MSB, 0x00}, + {WSA881X_CDC_RX_CTL, 0x7E}, + {WSA881X_DEM_BYPASS_DATA0, 0x00}, + {WSA881X_DEM_BYPASS_DATA1, 0x00}, + {WSA881X_DEM_BYPASS_DATA2, 0x00}, + {WSA881X_DEM_BYPASS_DATA3, 0x00}, + {WSA881X_OTP_CTRL0, 0x00}, + {WSA881X_OTP_CTRL1, 0x00}, + {WSA881X_HDRIVE_CTL_GROUP1, 0x00}, + {WSA881X_INTR_MODE, 0x00}, + {WSA881X_INTR_MASK, 0x1F}, + {WSA881X_INTR_STATUS, 0x00}, + {WSA881X_INTR_CLEAR, 0x00}, + {WSA881X_INTR_LEVEL, 0x00}, + {WSA881X_INTR_SET, 0x00}, + {WSA881X_INTR_TEST, 0x00}, + {WSA881X_PDM_TEST_MODE, 0x00}, + {WSA881X_ATE_TEST_MODE, 0x00}, + {WSA881X_PIN_CTL_MODE, 0x00}, + {WSA881X_PIN_CTL_OE, 0x00}, + {WSA881X_PIN_WDATA_IOPAD, 0x00}, + {WSA881X_PIN_STATUS, 0x00}, + {WSA881X_DIG_DEBUG_MODE, 0x00}, + {WSA881X_DIG_DEBUG_SEL, 0x00}, + {WSA881X_DIG_DEBUG_EN, 0x00}, + {WSA881X_SWR_HM_TEST1, 0x08}, + {WSA881X_SWR_HM_TEST2, 0x00}, + {WSA881X_TEMP_DETECT_DBG_CTL, 0x00}, + {WSA881X_TEMP_DEBUG_MSB, 0x00}, + {WSA881X_TEMP_DEBUG_LSB, 0x00}, + {WSA881X_SAMPLE_EDGE_SEL, 0x0C}, + {WSA881X_SPARE_0, 0x00}, + {WSA881X_SPARE_1, 0x00}, + {WSA881X_SPARE_2, 0x00}, + {WSA881X_OTP_REG_0, 0x01}, + {WSA881X_OTP_REG_1, 0xFF}, + {WSA881X_OTP_REG_2, 0xC0}, + {WSA881X_OTP_REG_3, 0xFF}, + {WSA881X_OTP_REG_4, 0xC0}, + {WSA881X_OTP_REG_5, 0xFF}, + {WSA881X_OTP_REG_6, 0xFF}, + {WSA881X_OTP_REG_7, 0xFF}, + {WSA881X_OTP_REG_8, 0xFF}, + {WSA881X_OTP_REG_9, 0xFF}, + {WSA881X_OTP_REG_10, 0xFF}, + {WSA881X_OTP_REG_11, 0xFF}, + {WSA881X_OTP_REG_12, 0xFF}, + {WSA881X_OTP_REG_13, 0xFF}, + {WSA881X_OTP_REG_14, 0xFF}, + {WSA881X_OTP_REG_15, 0xFF}, + {WSA881X_OTP_REG_16, 0xFF}, + {WSA881X_OTP_REG_17, 0xFF}, + {WSA881X_OTP_REG_18, 0xFF}, + {WSA881X_OTP_REG_19, 0xFF}, + {WSA881X_OTP_REG_20, 0xFF}, + {WSA881X_OTP_REG_21, 0xFF}, + {WSA881X_OTP_REG_22, 0xFF}, + {WSA881X_OTP_REG_23, 0xFF}, + {WSA881X_OTP_REG_24, 0x03}, + {WSA881X_OTP_REG_25, 0x01}, + {WSA881X_OTP_REG_26, 0x03}, + {WSA881X_OTP_REG_27, 0x11}, + {WSA881X_OTP_REG_28, 0xFF}, + {WSA881X_OTP_REG_29, 0xFF}, + {WSA881X_OTP_REG_30, 0xFF}, + {WSA881X_OTP_REG_31, 0xFF}, + {WSA881X_OTP_REG_63, 0x40}, +}; + +const struct reg_default wsa881x_ana_reg_defaults_1[] = { + {WSA881X_BIAS_REF_CTRL - WSA881X_ANALOG_BASE, 0x6C}, + {WSA881X_BIAS_TEST - WSA881X_ANALOG_BASE, 0x16}, + {WSA881X_BIAS_BIAS - WSA881X_ANALOG_BASE, 0xF0}, + {WSA881X_TEMP_OP - WSA881X_ANALOG_BASE, 0x00}, + {WSA881X_TEMP_IREF_CTRL - WSA881X_ANALOG_BASE, 0x56}, + {WSA881X_TEMP_ISENS_CTRL - WSA881X_ANALOG_BASE, 0x47}, + {WSA881X_TEMP_CLK_CTRL - WSA881X_ANALOG_BASE, 0x87}, + {WSA881X_TEMP_TEST - WSA881X_ANALOG_BASE, 0x00}, + {WSA881X_TEMP_BIAS - WSA881X_ANALOG_BASE, 0x51}, + {WSA881X_TEMP_ADC_CTRL - WSA881X_ANALOG_BASE, 0x00}, + {WSA881X_TEMP_DOUT_MSB - WSA881X_ANALOG_BASE, 0x00}, + {WSA881X_TEMP_DOUT_LSB - WSA881X_ANALOG_BASE, 0x00}, + {WSA881X_ADC_EN_MODU_V - WSA881X_ANALOG_BASE, 0x00}, + {WSA881X_ADC_EN_MODU_I - WSA881X_ANALOG_BASE, 0x00}, + {WSA881X_ADC_EN_DET_TEST_V - WSA881X_ANALOG_BASE, 0x00}, + {WSA881X_ADC_EN_DET_TEST_I - WSA881X_ANALOG_BASE, 0x00}, + {WSA881X_ADC_SEL_IBIAS - WSA881X_ANALOG_BASE, 0x25}, + {WSA881X_ADC_EN_SEL_IBIAS - WSA881X_ANALOG_BASE, 0x10}, + {WSA881X_SPKR_DRV_EN - WSA881X_ANALOG_BASE, 0x74}, + {WSA881X_SPKR_DRV_GAIN - WSA881X_ANALOG_BASE, 0x01}, + {WSA881X_SPKR_DAC_CTL - WSA881X_ANALOG_BASE, 0x40}, + {WSA881X_SPKR_DRV_DBG - WSA881X_ANALOG_BASE, 0x15}, + {WSA881X_SPKR_PWRSTG_DBG - WSA881X_ANALOG_BASE, 0x00}, + {WSA881X_SPKR_OCP_CTL - WSA881X_ANALOG_BASE, 0xD4}, + {WSA881X_SPKR_CLIP_CTL - WSA881X_ANALOG_BASE, 0x90}, + {WSA881X_SPKR_BBM_CTL - WSA881X_ANALOG_BASE, 0x00}, + {WSA881X_SPKR_MISC_CTL1 - WSA881X_ANALOG_BASE, 0x80}, + {WSA881X_SPKR_MISC_CTL2 - WSA881X_ANALOG_BASE, 0x00}, + {WSA881X_SPKR_BIAS_INT - WSA881X_ANALOG_BASE, 0x56}, + {WSA881X_SPKR_PA_INT - WSA881X_ANALOG_BASE, 0x54}, + {WSA881X_SPKR_BIAS_CAL - WSA881X_ANALOG_BASE, 0xAC}, + {WSA881X_SPKR_BIAS_PSRR - WSA881X_ANALOG_BASE, 0x54}, + {WSA881X_SPKR_STATUS1 - WSA881X_ANALOG_BASE, 0x00}, + {WSA881X_SPKR_STATUS2 - WSA881X_ANALOG_BASE, 0x00}, + {WSA881X_BOOST_EN_CTL - WSA881X_ANALOG_BASE, 0x18}, + {WSA881X_BOOST_CURRENT_LIMIT - WSA881X_ANALOG_BASE, 0x7A}, + {WSA881X_BOOST_PS_CTL - WSA881X_ANALOG_BASE, 0xC0}, + {WSA881X_BOOST_PRESET_OUT1 - WSA881X_ANALOG_BASE, 0x77}, + {WSA881X_BOOST_PRESET_OUT2 - WSA881X_ANALOG_BASE, 0x70}, + {WSA881X_BOOST_FORCE_OUT - WSA881X_ANALOG_BASE, 0x0E}, + {WSA881X_BOOST_LDO_PROG - WSA881X_ANALOG_BASE, 0x16}, + {WSA881X_BOOST_SLOPE_COMP_ISENSE_FB - WSA881X_ANALOG_BASE, 0x71}, + {WSA881X_BOOST_RON_CTL - WSA881X_ANALOG_BASE, 0x0F}, + {WSA881X_BOOST_LOOP_STABILITY - WSA881X_ANALOG_BASE, 0xAD}, + {WSA881X_BOOST_ZX_CTL - WSA881X_ANALOG_BASE, 0x34}, + {WSA881X_BOOST_START_CTL - WSA881X_ANALOG_BASE, 0x23}, + {WSA881X_BOOST_MISC1_CTL - WSA881X_ANALOG_BASE, 0x80}, + {WSA881X_BOOST_MISC2_CTL - WSA881X_ANALOG_BASE, 0x00}, + {WSA881X_BOOST_MISC3_CTL - WSA881X_ANALOG_BASE, 0x00}, + {WSA881X_BOOST_ATEST_CTL - WSA881X_ANALOG_BASE, 0x00}, + {WSA881X_SPKR_PROT_FE_GAIN - WSA881X_ANALOG_BASE, 0x46}, + {WSA881X_SPKR_PROT_FE_CM_LDO_SET - WSA881X_ANALOG_BASE, 0x3B}, + {WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET1 - WSA881X_ANALOG_BASE, 0x8D}, + {WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET2 - WSA881X_ANALOG_BASE, 0x8D}, + {WSA881X_SPKR_PROT_ATEST1 - WSA881X_ANALOG_BASE, 0x01}, + {WSA881X_SPKR_PROT_ATEST2 - WSA881X_ANALOG_BASE, 0x00}, + {WSA881X_SPKR_PROT_FE_VSENSE_VCM - WSA881X_ANALOG_BASE, 0x8D}, + {WSA881X_SPKR_PROT_FE_VSENSE_BIAS_SET1 - WSA881X_ANALOG_BASE, 0x4D}, + {WSA881X_BONGO_RESRV_REG1 - WSA881X_ANALOG_BASE, 0x00}, + {WSA881X_BONGO_RESRV_REG2 - WSA881X_ANALOG_BASE, 0x00}, + {WSA881X_SPKR_PROT_SAR - WSA881X_ANALOG_BASE, 0x00}, + {WSA881X_SPKR_STATUS3 - WSA881X_ANALOG_BASE, 0x00}, +}; + +static const struct reg_sequence wsa881x_rev_2_0_dig[] = { + {WSA881X_RESET_CTL, 0x00}, + {WSA881X_TADC_VALUE_CTL, 0x01}, + {WSA881X_INTR_MASK, 0x1B}, + {WSA881X_IOPAD_CTL, 0x00}, + {WSA881X_OTP_REG_28, 0x3F}, + {WSA881X_OTP_REG_29, 0x3F}, + {WSA881X_OTP_REG_30, 0x01}, + {WSA881X_OTP_REG_31, 0x01}, +}; + +static const struct reg_sequence wsa881x_rev_2_0_ana[] = { + {WSA881X_TEMP_ADC_CTRL, 0x03}, + {WSA881X_ADC_SEL_IBIAS, 0x45}, + {WSA881X_SPKR_DRV_GAIN, 0xC1}, + {WSA881X_SPKR_DAC_CTL, 0x42}, + {WSA881X_SPKR_BBM_CTL, 0x02}, + {WSA881X_SPKR_MISC_CTL1, 0x40}, + {WSA881X_SPKR_MISC_CTL2, 0x07}, + {WSA881X_SPKR_BIAS_INT, 0x5F}, + {WSA881X_SPKR_BIAS_PSRR, 0x44}, + {WSA881X_BOOST_PS_CTL, 0xA0}, + {WSA881X_BOOST_PRESET_OUT1, 0xB7}, + {WSA881X_BOOST_LOOP_STABILITY, 0x8D}, + {WSA881X_SPKR_PROT_ATEST2, 0x02}, + {WSA881X_BONGO_RESRV_REG1, 0x5E}, + {WSA881X_BONGO_RESRV_REG2, 0x07}, +}; + +static const struct reg_default wsa881x_rev_2_0_regmap_ana[] = { + {WSA881X_TEMP_ADC_CTRL - WSA881X_ANALOG_BASE, 0x03}, + {WSA881X_ADC_SEL_IBIAS - WSA881X_ANALOG_BASE, 0x45}, + {WSA881X_SPKR_DRV_GAIN - WSA881X_ANALOG_BASE, 0xC1}, + {WSA881X_SPKR_DAC_CTL - WSA881X_ANALOG_BASE, 0x42}, + {WSA881X_SPKR_BBM_CTL - WSA881X_ANALOG_BASE, 0x02}, + {WSA881X_SPKR_MISC_CTL1 - WSA881X_ANALOG_BASE, 0x40}, + {WSA881X_SPKR_MISC_CTL2 - WSA881X_ANALOG_BASE, 0x07}, + {WSA881X_SPKR_BIAS_INT - WSA881X_ANALOG_BASE, 0x5F}, + {WSA881X_SPKR_BIAS_PSRR - WSA881X_ANALOG_BASE, 0x44}, + {WSA881X_BOOST_PS_CTL - WSA881X_ANALOG_BASE, 0xA0}, + {WSA881X_BOOST_PRESET_OUT1 - WSA881X_ANALOG_BASE, 0xB7}, + {WSA881X_BOOST_LOOP_STABILITY - WSA881X_ANALOG_BASE, 0x8D}, + {WSA881X_SPKR_PROT_ATEST2 - WSA881X_ANALOG_BASE, 0x02}, + {WSA881X_BONGO_RESRV_REG1 - WSA881X_ANALOG_BASE, 0x5E}, + {WSA881X_BONGO_RESRV_REG2 - WSA881X_ANALOG_BASE, 0x07}, +}; + +/** + * wsa881x_update_reg_defaults_2_0 - update default values of regs for v2.0 + * + * wsa881x v2.0 has different default values for certain analog and digital + * registers compared to v1.x. Therefore, update the values of these registers + * with the values from tables defined above for v2.0. + */ +static void wsa881x_update_reg_defaults_2_0(void) +{ + int i, j; + + for (i = 0; i < ARRAY_SIZE(wsa881x_rev_2_0_dig); i++) { + for (j = 0; j < ARRAY_SIZE(wsa881x_ana_reg_defaults); j++) + if (wsa881x_ana_reg_defaults[j].reg == + wsa881x_rev_2_0_dig[i].reg) + wsa881x_ana_reg_defaults[j].def = + wsa881x_rev_2_0_dig[i].def; + } + for (i = 0; i < ARRAY_SIZE(wsa881x_rev_2_0_ana); i++) { + for (j = 0; j < ARRAY_SIZE(wsa881x_ana_reg_defaults); j++) + if (wsa881x_ana_reg_defaults[j].reg == + wsa881x_rev_2_0_ana[i].reg) + wsa881x_ana_reg_defaults[j].def = + wsa881x_rev_2_0_ana[i].def; + } +} + +/** + * wsa881x_update_regmap_2_0 - update regmap framework with new tables + * @regmap: pointer to wsa881x regmap structure + * @flag: indicates digital or analog wsa881x slave + * + * wsa881x v2.0 has some new registers for both analog and digital slaves. + * Update the regmap framework with all the new registers. + */ +static void wsa881x_update_regmap_2_0(struct regmap *regmap, int flag) +{ + u16 ret; + + switch (flag) { + case DIGITAL: + ret = regmap_register_patch(regmap, wsa881x_rev_2_0_dig, + ARRAY_SIZE(wsa881x_rev_2_0_dig)); + break; + case ANALOG: + ret = regmap_register_patch(regmap, wsa881x_rev_2_0_ana, + ARRAY_SIZE(wsa881x_rev_2_0_ana)); + break; + default: + pr_debug("%s: unknown version", __func__); + ret = -EINVAL; + break; + } + if (ret) + pr_err("%s: failed to update regmap defaults ret=%d\n", + __func__, ret); +} + +const struct regmap_config wsa881x_ana_regmap_config[] = { + { + .reg_bits = 8, + .val_bits = 8, + .cache_type = REGCACHE_NONE, + .reg_defaults = wsa881x_ana_reg_defaults_0, + .num_reg_defaults = ARRAY_SIZE(wsa881x_ana_reg_defaults_0), + .max_register = WSA881X_SPKR_STATUS3, + .volatile_reg = wsa881x_volatile_register, + .readable_reg = wsa881x_readable_register, + .reg_format_endian = REGMAP_ENDIAN_NATIVE, + .val_format_endian = REGMAP_ENDIAN_NATIVE, + }, + { + .reg_bits = 8, + .val_bits = 8, + .cache_type = REGCACHE_NONE, + .reg_defaults = wsa881x_ana_reg_defaults_1, + .num_reg_defaults = ARRAY_SIZE(wsa881x_ana_reg_defaults_1), + .max_register = WSA881X_SPKR_STATUS3, + .volatile_reg = wsa881x_volatile_register, + .readable_reg = wsa881x_readable_register, + .reg_format_endian = REGMAP_ENDIAN_NATIVE, + .val_format_endian = REGMAP_ENDIAN_NATIVE, + } +}; + +static const struct i2c_device_id wsa881x_i2c_id[]; + +static const int delay_array_msec[] = {10, 20, 30, 40, 50}; + +static const char * const wsa881x_spk_pa_gain_text[] = { +"POS_13P5_DB", "POS_12_DB", "POS_10P5_DB", "POS_9_DB", "POS_7P5_DB", +"POS_6_DB", "POS_4P5_DB", "POS_3_DB", "POS_1P5_DB", "POS_0_DB"}; + +static const struct soc_enum wsa881x_spk_pa_gain_enum[] = { + SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(wsa881x_spk_pa_gain_text), + wsa881x_spk_pa_gain_text), +}; + +static int wsa881x_spk_pa_gain_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wsa881x_priv *wsa881x = + snd_soc_component_get_drvdata(component); + + ucontrol->value.integer.value[0] = wsa881x->spk_pa_gain; + return 0; +} + +static int wsa881x_spk_pa_gain_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wsa881x_priv *wsa881x = + snd_soc_component_get_drvdata(component); + + if (ucontrol->value.integer.value[0] < 0 || + ucontrol->value.integer.value[0] > 0xC) { + dev_err(component->dev, "unsupported gain val %ld\n", + ucontrol->value.integer.value[0]); + return -EINVAL; + } + wsa881x->spk_pa_gain = ucontrol->value.integer.value[0]; + return 0; +} + +/* Helpers to figure out which regmap or client contains the register */ +static struct regmap *find_regmap(struct wsa881x_priv *wsa881x, u16 reg) +{ + if (reg >= WSA881X_ANALOG_BASE) + return wsa881x->regmap_analog; + else + return wsa881x->regmap; +} + +static int find_client_index(u16 reg) +{ + return reg >= WSA881X_ANALOG_BASE ? ANALOG : DIGITAL; +} + +static int wsa881x_i2c_write_device(struct wsa881x_priv *wsa881x, + unsigned int reg, unsigned int val) +{ + struct regmap *wsa881x_regmap; + struct i2c_msg *msg; + int bytes = 1; + int ret, i, index; + u8 reg_addr = 0; + u8 data[2]; + + if (wsa881x->regmap_flag) { + wsa881x_regmap = find_regmap(wsa881x, reg); + ret = regmap_write(wsa881x_regmap, reg, val); + for (i = 0; ret && i < ARRAY_SIZE(delay_array_msec); i++) { + dev_err_ratelimited(wsa881x->dev, + "failed writing reg=%x-retry(%d)\n", + reg, i); + /* retry after delay of increasing order */ + msleep(delay_array_msec[i]); + ret = regmap_write(wsa881x_regmap, reg, val); + } + if (ret) + dev_err_ratelimited(wsa881x->dev, + "failed writing reg=%x ret=%d\n", + reg, ret); + else + dev_dbg(wsa881x->dev, "wrote reg=%x val=%x\n", + reg, val); + } else { + index = find_client_index(reg); + reg_addr = (u8)reg; + msg = &wsa881x->xfer_msg[0]; + msg->addr = wsa881x->client[index]->addr; + msg->len = bytes + 1; + msg->flags = 0; + data[0] = reg; + data[1] = (u8)val; + msg->buf = data; + + ret = i2c_transfer(wsa881x->client[index]->adapter, + wsa881x->xfer_msg, 1); + /* Try again if the write fails */ + if (ret != 1) { + pr_err("write failed\n"); + ret = i2c_transfer(wsa881x->client[index]->adapter, + wsa881x->xfer_msg, 1); + if (ret != 1) { + dev_err_ratelimited(wsa881x->dev, + "failed i2c transfer\n"); + return ret; + } + } + dev_dbg(wsa881x->dev, "wrote reg=%x val=%x\n", reg, data[1]); + } + return ret; +} + +static int wsa881x_i2c_read_device(struct wsa881x_priv *wsa881x, + unsigned int reg) +{ + struct regmap *wsa881x_regmap; + struct i2c_msg *msg; + unsigned int val; + int ret, i, index; + u8 reg_addr = 0; + u8 dest[5] = {0}; + + if (wsa881x->regmap_flag) { + wsa881x_regmap = find_regmap(wsa881x, reg); + if (!wsa881x_regmap) { + dev_err_ratelimited(wsa881x->dev, + "invalid register to read\n"); + return -EINVAL; + } + ret = regmap_read(wsa881x_regmap, reg, &val); + for (i = 0; ret && i < ARRAY_SIZE(delay_array_msec); i++) { + dev_err_ratelimited(wsa881x->dev, + "failed to read reg=%x-retry(%d)\n", + reg, i); + /* retry after delay of increasing order */ + msleep(delay_array_msec[i]); + ret = regmap_read(wsa881x_regmap, reg, &val); + } + if (ret) { + dev_err_ratelimited(wsa881x->dev, + "failed to read reg=%x ret=%d\n", + reg, ret); + return ret; + } + dev_dbg(wsa881x->dev, "read success, reg=%x val=%x\n", + reg, val); + } else { + index = find_client_index(reg); + reg_addr = (u8)reg; + msg = &wsa881x->xfer_msg[0]; + msg->addr = wsa881x->client[index]->addr; + msg->len = 1; + msg->flags = 0; + msg->buf = ®_addr; + + msg = &wsa881x->xfer_msg[1]; + msg->addr = wsa881x->client[index]->addr; + msg->len = 1; + msg->flags = I2C_M_RD; + msg->buf = dest; + + ret = i2c_transfer(wsa881x->client[index]->adapter, + wsa881x->xfer_msg, 2); + /* Try again if read fails first time */ + if (ret != 2) { + ret = i2c_transfer(wsa881x->client[index]->adapter, + wsa881x->xfer_msg, 2); + if (ret != 2) { + dev_err_ratelimited(wsa881x->dev, + "failed to read reg=%d\n", + reg); + return ret; + } + } + val = dest[0]; + } + return val; +} + +static unsigned int wsa881x_i2c_read(struct snd_soc_component *component, + unsigned int reg) +{ + struct wsa881x_priv *wsa881x; + int retval; + + wsa881x = snd_soc_component_get_drvdata(component); + + retval = wsa881x_i2c_read_device(wsa881x, reg); + + return retval >= 0 ? retval : 0; +} + +static int wsa881x_i2c_write(struct snd_soc_component *component, + unsigned int reg, unsigned int val) +{ + struct wsa881x_priv *wsa881x; + + wsa881x = snd_soc_component_get_drvdata(component); + + return wsa881x_i2c_write_device(wsa881x, reg, val); +} + +static int wsa881x_boost_ctrl(struct snd_soc_component *component, bool enable) +{ + struct wsa881x_priv *wsa881x = + snd_soc_component_get_drvdata(component); + + if (enable) { + if (!WSA881X_IS_2_0(wsa881x->version)) { + snd_soc_component_update_bits(component, + WSA881X_ANA_CTL, 0x01, 0x01); + snd_soc_component_update_bits(component, + WSA881X_ANA_CTL, 0x04, 0x04); + snd_soc_component_update_bits(component, + WSA881X_BOOST_PS_CTL, + 0x40, 0x00); + snd_soc_component_update_bits(component, + WSA881X_BOOST_PRESET_OUT1, + 0xF0, 0xB0); + snd_soc_component_update_bits(component, + WSA881X_BOOST_ZX_CTL, + 0x20, 0x00); + snd_soc_component_update_bits(component, + WSA881X_BOOST_EN_CTL, + 0x80, 0x80); + } else { + snd_soc_component_update_bits(component, + WSA881X_BOOST_LOOP_STABILITY, + 0x03, 0x03); + snd_soc_component_update_bits(component, + WSA881X_BOOST_MISC2_CTL, + 0xFF, 0x14); + snd_soc_component_update_bits(component, + WSA881X_BOOST_START_CTL, + 0x80, 0x80); + snd_soc_component_update_bits(component, + WSA881X_BOOST_START_CTL, + 0x03, 0x00); + snd_soc_component_update_bits(component, + WSA881X_BOOST_SLOPE_COMP_ISENSE_FB, + 0x0C, 0x04); + snd_soc_component_update_bits(component, + WSA881X_BOOST_SLOPE_COMP_ISENSE_FB, + 0x03, 0x00); + if (snd_soc_component_read(component, WSA881X_OTP_REG_0)) + snd_soc_component_update_bits(component, + WSA881X_BOOST_PRESET_OUT1, + 0xF0, 0x70); + else + snd_soc_component_update_bits(component, + WSA881X_BOOST_PRESET_OUT1, + 0xF0, 0xB0); + snd_soc_component_update_bits(component, + WSA881X_ANA_CTL, 0x03, 0x01); + snd_soc_component_update_bits(component, + WSA881X_SPKR_DRV_EN, + 0x08, 0x08); + snd_soc_component_update_bits(component, + WSA881X_ANA_CTL, 0x04, 0x04); + snd_soc_component_update_bits(component, + WSA881X_BOOST_CURRENT_LIMIT, + 0x0F, 0x08); + snd_soc_component_update_bits(component, + WSA881X_BOOST_EN_CTL, + 0x80, 0x80); + } + /* For WSA8810, start-up time is 1500us as per qcrg sequence */ + usleep_range(1500, 1510); + } else { + /* ENSURE: Class-D amp is shutdown. CLK is still on */ + snd_soc_component_update_bits(component, WSA881X_BOOST_EN_CTL, + 0x80, 0x00); + /* boost settle time is 1500us as per qcrg sequence */ + usleep_range(1500, 1510); + } + return 0; +} + +static void wsa881x_bandgap_ctrl(struct snd_soc_component *component, + bool enable) +{ + if (enable) { + snd_soc_component_update_bits(component, WSA881X_TEMP_OP, + 0x08, 0x08); + /* 400usec sleep is needed as per HW requirement */ + usleep_range(400, 410); + snd_soc_component_update_bits(component, WSA881X_TEMP_OP, + 0x04, 0x04); + } else { + snd_soc_component_update_bits(component, WSA881X_TEMP_OP, + 0x04, 0x00); + snd_soc_component_update_bits(component, WSA881X_TEMP_OP, + 0x08, 0x00); + } +} + +static void wsa881x_clk_ctrl(struct snd_soc_component *component, bool enable) +{ + struct wsa881x_priv *wsa881x = + snd_soc_component_get_drvdata(component); + + if (enable) { + snd_soc_component_write(component, + WSA881X_CDC_RST_CTL, 0x02); + snd_soc_component_write(component, + WSA881X_CDC_RST_CTL, 0x03); + snd_soc_component_write(component, + WSA881X_CLOCK_CONFIG, 0x01); + + snd_soc_component_write(component, + WSA881X_CDC_DIG_CLK_CTL, 0x01); + snd_soc_component_write(component, + WSA881X_CDC_ANA_CLK_CTL, 0x01); + } else { + snd_soc_component_write(component, + WSA881X_CDC_ANA_CLK_CTL, 0x00); + snd_soc_component_write(component, + WSA881X_CDC_DIG_CLK_CTL, 0x00); + if (WSA881X_IS_2_0(wsa881x->version)) + snd_soc_component_update_bits(component, + WSA881X_CDC_TOP_CLK_CTL, 0x01, 0x00); + } +} + +static int wsa881x_rdac_ctrl(struct snd_soc_component *component, bool enable) +{ + struct wsa881x_priv *wsa881x = + snd_soc_component_get_drvdata(component); + + if (enable) { + snd_soc_component_update_bits(component, + WSA881X_ANA_CTL, 0x08, 0x00); + snd_soc_component_update_bits(component, + WSA881X_SPKR_DRV_GAIN, 0x08, 0x08); + snd_soc_component_update_bits(component, + WSA881X_SPKR_DAC_CTL, 0x20, 0x20); + snd_soc_component_update_bits(component, + WSA881X_SPKR_DAC_CTL, 0x20, 0x00); + snd_soc_component_update_bits(component, + WSA881X_SPKR_DAC_CTL, 0x40, 0x40); + snd_soc_component_update_bits(component, + WSA881X_SPKR_DAC_CTL, 0x80, 0x80); + if (WSA881X_IS_2_0(wsa881x->version)) { + snd_soc_component_update_bits(component, + WSA881X_SPKR_BIAS_CAL, 0x01, 0x01); + snd_soc_component_update_bits(component, + WSA881X_SPKR_OCP_CTL, 0x30, 0x30); + snd_soc_component_update_bits(component, + WSA881X_SPKR_OCP_CTL, 0x0C, 0x00); + } + snd_soc_component_update_bits(component, + WSA881X_SPKR_DRV_GAIN, 0xF0, 0x40); + snd_soc_component_update_bits(component, + WSA881X_SPKR_MISC_CTL1, 0x01, 0x01); + } else { + /* Ensure class-D amp is off */ + snd_soc_component_update_bits(component, + WSA881X_SPKR_DAC_CTL, 0x80, 0x00); + } + return 0; +} + +static int wsa881x_spkr_pa_ctrl(struct snd_soc_component *component, + bool enable) +{ + struct wsa881x_priv *wsa881x = + snd_soc_component_get_drvdata(component); + + if (enable) { + /* + * Ensure: Boost is enabled and stable, Analog input is up + * and outputting silence + */ + if (!WSA881X_IS_2_0(wsa881x->version)) { + snd_soc_component_update_bits(component, + WSA881X_ADC_EN_DET_TEST_I, + 0xFF, 0x01); + snd_soc_component_update_bits(component, + WSA881X_ADC_EN_MODU_V, + 0x02, 0x02); + snd_soc_component_update_bits(component, + WSA881X_ADC_EN_DET_TEST_V, + 0xFF, 0x10); + snd_soc_component_update_bits(component, + WSA881X_SPKR_PWRSTG_DBG, + 0xA0, 0xA0); + snd_soc_component_update_bits(component, + WSA881X_SPKR_DRV_EN, + 0x80, 0x80); + usleep_range(700, 710); + snd_soc_component_update_bits(component, + WSA881X_SPKR_PWRSTG_DBG, + 0x00, 0x00); + snd_soc_component_update_bits(component, + WSA881X_ADC_EN_DET_TEST_V, + 0xFF, 0x00); + snd_soc_component_update_bits(component, + WSA881X_ADC_EN_MODU_V, + 0x02, 0x00); + snd_soc_component_update_bits(component, + WSA881X_ADC_EN_DET_TEST_I, + 0xFF, 0x00); + } else + snd_soc_component_update_bits(component, + WSA881X_SPKR_DRV_EN, 0x80, 0x80); + /* add 1000us delay as per qcrg */ + usleep_range(1000, 1010); + snd_soc_component_update_bits(component, + WSA881X_SPKR_DRV_EN, 0x01, 0x01); + if (WSA881X_IS_2_0(wsa881x->version)) + snd_soc_component_update_bits(component, + WSA881X_SPKR_BIAS_CAL, + 0x01, 0x00); + usleep_range(1000, 1010); + snd_soc_component_update_bits(component, + WSA881X_SPKR_DRV_GAIN, + 0xF0, (wsa881x->spk_pa_gain << 4)); + } else { + /* + * Ensure: Boost is still on, Stream from Analog input and + * Speaker Protection has been stopped and input is at 0V + */ + if (WSA881X_IS_2_0(wsa881x->version)) { + snd_soc_component_update_bits(component, + WSA881X_SPKR_BIAS_CAL, + 0x01, 0x01); + usleep_range(1000, 1010); + snd_soc_component_update_bits(component, + WSA881X_SPKR_BIAS_CAL, + 0x01, 0x00); + msleep(20); + snd_soc_component_update_bits(component, + WSA881X_ANA_CTL, 0x03, 0x00); + usleep_range(200, 210); + } + snd_soc_component_update_bits(component, + WSA881X_SPKR_DRV_EN, 0x80, 0x00); + } + return 0; +} + +static int wsa881x_get_boost(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wsa881x_priv *wsa881x = + snd_soc_component_get_drvdata(component); + + ucontrol->value.integer.value[0] = wsa881x->boost_enable; + return 0; +} + +static int wsa881x_set_boost(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wsa881x_priv *wsa881x = + snd_soc_component_get_drvdata(component); + int value = ucontrol->value.integer.value[0]; + + wsa881x->boost_enable = value; + return 0; +} + +static const struct snd_kcontrol_new wsa881x_snd_controls[] = { + SOC_SINGLE_EXT("BOOST Switch", SND_SOC_NOPM, 0, 1, 0, + wsa881x_get_boost, wsa881x_set_boost), + + SOC_ENUM_EXT("WSA_SPK PA Gain", wsa881x_spk_pa_gain_enum[0], + wsa881x_spk_pa_gain_get, wsa881x_spk_pa_gain_put), +}; + +static const char * const rdac_text[] = { + "ZERO", "Switch", +}; + +static const struct soc_enum rdac_enum = + SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(rdac_text), rdac_text); + +static const struct snd_kcontrol_new rdac_mux[] = { + SOC_DAPM_ENUM("RDAC", rdac_enum) +}; + +static int wsa881x_rdac_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct wsa881x_priv *wsa881x = + snd_soc_component_get_drvdata(component); + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + wsa881x_clk_ctrl(component, true); + snd_soc_component_update_bits(component, WSA881X_SPKR_DAC_CTL, + 0x02, 0x02); + if (!WSA881X_IS_2_0(wsa881x->version)) + snd_soc_component_update_bits(component, + WSA881X_BIAS_REF_CTRL, + 0x0F, 0x08); + wsa881x_bandgap_ctrl(component, true); + if (!WSA881X_IS_2_0(wsa881x->version)) + snd_soc_component_update_bits(component, + WSA881X_SPKR_BBM_CTL, + 0x02, 0x02); + snd_soc_component_update_bits(component, WSA881X_SPKR_MISC_CTL1, + 0xC0, 0x80); + snd_soc_component_update_bits(component, WSA881X_SPKR_MISC_CTL1, + 0x06, 0x06); + if (!WSA881X_IS_2_0(wsa881x->version)) { + snd_soc_component_update_bits(component, + WSA881X_SPKR_MISC_CTL2, + 0x04, 0x04); + snd_soc_component_update_bits(component, + WSA881X_SPKR_BIAS_INT, + 0x09, 0x09); + } + snd_soc_component_update_bits(component, WSA881X_SPKR_PA_INT, + 0xF0, 0x20); + if (WSA881X_IS_2_0(wsa881x->version)) + snd_soc_component_update_bits(component, + WSA881X_SPKR_PA_INT, + 0x0E, 0x0E); + if (wsa881x->boost_enable) + wsa881x_boost_ctrl(component, true); + break; + case SND_SOC_DAPM_POST_PMU: + wsa881x_rdac_ctrl(component, true); + break; + case SND_SOC_DAPM_PRE_PMD: + wsa881x_rdac_ctrl(component, false); + break; + case SND_SOC_DAPM_POST_PMD: + if (wsa881x->boost_enable) + wsa881x_boost_ctrl(component, false); + wsa881x_clk_ctrl(component, false); + wsa881x_bandgap_ctrl(component, false); + + break; + default: + dev_err(component->dev, "invalid event:%d\n", event); + return -EINVAL; + } + return 0; +} + +static int wsa881x_spkr_pa_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + snd_soc_component_update_bits(component, WSA881X_SPKR_OCP_CTL, + 0xC0, 0x80); + break; + case SND_SOC_DAPM_POST_PMU: + wsa881x_spkr_pa_ctrl(component, true); + break; + case SND_SOC_DAPM_PRE_PMD: + wsa881x_spkr_pa_ctrl(component, false); + break; + case SND_SOC_DAPM_POST_PMD: + snd_soc_component_update_bits(component, WSA881X_SPKR_OCP_CTL, + 0xC0, 0xC0); + break; + default: + dev_err(component->dev, "invalid event:%d\n", event); + return -EINVAL; + } + return 0; +} + +static const struct snd_soc_dapm_widget wsa881x_dapm_widgets[] = { + SND_SOC_DAPM_INPUT("WSA_IN"), + + SND_SOC_DAPM_DAC_E("RDAC Analog", NULL, SND_SOC_NOPM, 0, 0, + wsa881x_rdac_event, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), + + SND_SOC_DAPM_MUX("WSA_RDAC", SND_SOC_NOPM, 0, 0, + rdac_mux), + + SND_SOC_DAPM_PGA_S("WSA_SPKR PGA", 1, SND_SOC_NOPM, 0, 0, + wsa881x_spkr_pa_event, + SND_SOC_DAPM_PRE_PMU | + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD | + SND_SOC_DAPM_POST_PMD), + + SND_SOC_DAPM_OUTPUT("WSA_SPKR"), +}; + +static const struct snd_soc_dapm_route wsa881x_audio_map[] = { + {"WSA_RDAC", "Switch", "WSA_IN"}, + {"RDAC Analog", NULL, "WSA_RDAC"}, + {"WSA_SPKR PGA", NULL, "RDAC Analog"}, + {"WSA_SPKR", NULL, "WSA_SPKR PGA"}, +}; + +static int wsa881x_probe(struct snd_soc_component *component) +{ + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component); + + wsa881x->component = component; + wsa881x->spk_pa_gain = SPK_GAIN_12DB; + + return 0; +} + +static const struct snd_soc_dai_ops wsa881x_dai_ops = { + .set_stream = wsa881x_set_stream, + .mute_stream = wsa881x_digital_mute, + .mute_unmute_on_trigger = false, +}; + +static const struct snd_soc_component_driver soc_codec_dev_wsa881x = { + .probe = wsa881x_probe, + .read = wsa881x_i2c_read, + .write = wsa881x_i2c_write, + .controls = wsa881x_snd_controls, + .num_controls = ARRAY_SIZE(wsa881x_snd_controls), + .dapm_widgets = wsa881x_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wsa881x_dapm_widgets), + .dapm_routes = wsa881x_audio_map, + .num_dapm_routes = ARRAY_SIZE(wsa881x_audio_map), +}; + +static const struct snd_soc_dai_driver wsa_dai[] = { + { + .name = "wsa_rx0", + .id = 0, + .playback = { + .stream_name = "", + .rates = WSA881X_RATES | WSA881X_FRAC_RATES, + .formats = WSA881X_FORMATS, + .rate_max = 384000, + .rate_min = 8000, + .channels_min = 1, + .channels_max = 1, + }, + .ops = &wsa881x_dai_ops, + }, +}; + +static int check_wsa881x_presence(struct wsa881x_priv *wsa881x) +{ + struct i2c_client *client = wsa881x->client[DIGITAL]; + int ret; + + ret = wsa881x_i2c_read_device(wsa881x, WSA881X_CDC_RST_CTL); + if (ret < 0) { + dev_err(&client->dev, "failed to read from addr=%x\n", + client->addr); + return ret; + } + + ret = wsa881x_i2c_write_device(wsa881x, WSA881X_CDC_RST_CTL, 0x01); + if (ret < 0) { + dev_err(&client->dev, "failed write addr=%x reg:0x5 val:0x1\n", + client->addr); + return ret; + } + + /* allow 20ms before trigger next write to verify wsa881x presence */ + msleep(20); + ret = wsa881x_i2c_write_device(wsa881x, WSA881X_CDC_RST_CTL, 0x00); + if (ret < 0) { + dev_err(&client->dev, "failed write addr=%x reg:0x5 val:0x0\n", + client->addr); + return ret; + } + return ret; +} + +static int wsa881x_i2c_probe(struct i2c_client *client) +{ + struct device *dev = &client->dev; + struct wsa881x_priv *wsa881x; + int leftright; + int ret; + + ret = wsa881x_probe_common(&wsa881x, dev); + if (ret) + return ret; + + wsa881x->mclk_pin = devm_gpiod_get(dev, "mclk", + GPIOD_FLAGS_BIT_NONEXCLUSIVE); + if (IS_ERR(wsa881x->mclk_pin)) + dev_err_probe(dev, PTR_ERR(wsa881x->mclk_pin), + "MCLK GPIO not found\n"); + + wsa881x->wsa_mclk = devm_clk_get_enabled(&client->dev, NULL); + if (IS_ERR(wsa881x->wsa_mclk)) + return dev_err_probe(dev, PTR_ERR(wsa881x->wsa_mclk), + "failed to get mclk\n"); + gpiod_direction_output(wsa881x->mclk_pin, 1); + clk_set_rate(wsa881x->wsa_mclk, 9600000); + + wsa881x->client[DIGITAL] = client; + ret = check_wsa881x_presence(wsa881x); + if (ret < 0) { + dev_err(&client->dev, + "failed to ping wsa with addr:%x, ret = %d\n", + client->addr, ret); + return -ENODEV; + } + + wsa881x->regmap = devm_regmap_init_i2c(client, + &wsa881x_ana_regmap_config[DIGITAL]); + if (IS_ERR(wsa881x->regmap)) { + dev_err(dev, "digital regmap init failed %d\n", ret); + return PTR_ERR(wsa881x->regmap); + } + regcache_cache_bypass(wsa881x->regmap, true); + + wsa881x_init_common(wsa881x); + + wsa881x->version = wsa881x_i2c_read_device(wsa881x, WSA881X_CHIP_ID1); + if (wsa881x->version == WSA881X_2_0) { + wsa881x_update_reg_defaults_2_0(); + wsa881x_update_regmap_2_0(wsa881x->regmap, DIGITAL); + } + + /* + * If we reached this point, then device is present and we're good to + * go to initialise analog part of the amplifier + */ + wsa881x->client[ANALOG] = devm_i2c_new_dummy_device(&client->dev, + client->adapter, + client->addr + I2C_ANALOG_OFFSET); + if (IS_ERR(wsa881x->client[ANALOG])) { + dev_err(dev, + "failed to register i2c device for analog part\n"); + return PTR_ERR(wsa881x->client[ANALOG]); + } + + wsa881x->regmap_analog = devm_regmap_init_i2c(wsa881x->client[ANALOG], + &wsa881x_ana_regmap_config[ANALOG]); + if (IS_ERR(wsa881x->regmap_analog)) { + dev_err(dev, "analog regmap init failed %d\n", ret); + return PTR_ERR(wsa881x->regmap_analog); + } + regcache_cache_bypass(wsa881x->regmap_analog, true); + + wsa881x->client[ANALOG]->dev.platform_data = wsa881x; + i2c_set_clientdata(wsa881x->client[ANALOG], wsa881x); + wsa881x->regmap_flag = true; + + if (wsa881x->version == WSA881X_2_0) + wsa881x_update_regmap_2_0(wsa881x->regmap_analog, ANALOG); + /* finished initialising analog part */ + + leftright = wsa881x_i2c_read_device(wsa881x, WSA881X_BUS_ID) & 0x1; + + wsa881x->driver = devm_kmemdup(dev, &soc_codec_dev_wsa881x, + sizeof(*wsa881x->driver), GFP_KERNEL); + if (!wsa881x->driver) + return -ENOMEM; + + wsa881x->dai_driver = devm_kmemdup(dev, wsa_dai, + sizeof(struct snd_soc_dai_driver), + GFP_KERNEL); + if (!wsa881x->dai_driver) + return -ENOMEM; + + wsa881x->driver->name = devm_kasprintf(dev, GFP_KERNEL, "wsa-codec%d", + leftright); + if (!wsa881x->driver->name) + return -ENOMEM; + + wsa881x->dai_driver->name = devm_kasprintf(dev, GFP_KERNEL, + "wsa_rx%d", leftright); + if (!wsa881x->dai_driver->name) + return -ENOMEM; + + wsa881x->dai_driver->playback.stream_name = devm_kasprintf(dev, + GFP_KERNEL, "WSA881X_AIF%d Playback", + leftright); + if (!wsa881x->dai_driver->playback.stream_name) + return -ENOMEM; + + pm_runtime_set_autosuspend_delay(dev, 3000); + pm_runtime_use_autosuspend(dev); + pm_runtime_mark_last_busy(dev); + pm_runtime_set_active(dev); + pm_runtime_enable(dev); + + return devm_snd_soc_register_component(dev, + wsa881x->driver, + wsa881x->dai_driver, + ARRAY_SIZE(wsa_dai)); +} + +static int __maybe_unused wsa881x_i2c_suspend(struct device *dev) +{ + struct wsa881x_priv *wsa881x = dev_get_drvdata(dev); + + clk_disable_unprepare(wsa881x->wsa_mclk); + + gpiod_direction_output(wsa881x->sd_n, wsa881x->sd_n_val); + + return 0; +} + +static int __maybe_unused wsa881x_i2c_resume(struct device *dev) +{ + struct wsa881x_priv *wsa881x = dev_get_drvdata(dev); + int ret; + + gpiod_direction_output(wsa881x->sd_n, !wsa881x->sd_n_val); + + gpiod_direction_output(wsa881x->mclk_pin, 1); + ret = clk_prepare_enable(wsa881x->wsa_mclk); + if (ret) { + dev_err(wsa881x->dev, "mclk enable failed\n"); + return ret; + } + + wsa881x_init_common(wsa881x); + + return 0; +} + +static const struct dev_pm_ops wsa881x_i2c_pm_ops = { + SET_RUNTIME_PM_OPS(wsa881x_i2c_suspend, wsa881x_i2c_resume, NULL) + SET_SYSTEM_SLEEP_PM_OPS(wsa881x_i2c_suspend, wsa881x_i2c_resume) +}; + +static const struct i2c_device_id wsa881x_i2c_id[] = { + {"qcom,wsa8810"}, + {"qcom,wsa8815"}, + {} +}; + +MODULE_DEVICE_TABLE(i2c, wsa881x_i2c_id); + +static const struct of_device_id wsa881x_i2c_driver_table[] = { + {.compatible = "qcom,wsa8810"}, + {.compatible = "qcom,wsa8815"}, + {} +}; +MODULE_DEVICE_TABLE(of, wsa881x_i2c_driver_table); + +static struct i2c_driver wsa881x_i2c_driver = { + .driver = { + .name = "wsa881x-i2c-codec", + .pm = &wsa881x_i2c_pm_ops, + .of_match_table = wsa881x_i2c_driver_table, + }, + .id_table = wsa881x_i2c_id, + .probe = wsa881x_i2c_probe, +}; + +module_i2c_driver(wsa881x_i2c_driver); +MODULE_DESCRIPTION("WSA881x Codec driver for Analog mode"); +MODULE_LICENSE("GPL"); -- 2.47.2 ^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH v3 06/12] ASoC: codecs: add wsa881x-i2c amplifier codec driver 2025-05-22 17:40 ` [PATCH v3 06/12] ASoC: codecs: add wsa881x-i2c amplifier codec driver Alexey Klimov @ 2025-05-23 12:59 ` kernel test robot 2025-05-29 10:05 ` Srinivas Kandagatla 1 sibling, 0 replies; 43+ messages in thread From: kernel test robot @ 2025-05-23 12:59 UTC (permalink / raw) To: Alexey Klimov, Srinivas Kandagatla, Mark Brown, linux-sound Cc: llvm, oe-kbuild-all, Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio Hi Alexey, kernel test robot noticed the following build errors: [auto build test ERROR on 7bac2c97af4078d7a627500c9bcdd5b033f97718] url: https://github.com/intel-lab-lkp/linux/commits/Alexey-Klimov/ASoC-dt-bindings-qcom-Add-SM6115-LPASS-rxmacro-and-vamacro-codecs/20250523-014432 base: 7bac2c97af4078d7a627500c9bcdd5b033f97718 patch link: https://lore.kernel.org/r/20250522-rb2_audio_v3-v3-6-9eeb08cab9dc%40linaro.org patch subject: [PATCH v3 06/12] ASoC: codecs: add wsa881x-i2c amplifier codec driver config: x86_64-buildonly-randconfig-004-20250523 (https://download.01.org/0day-ci/archive/20250523/202505232000.eTkDhRzd-lkp@intel.com/config) compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250523/202505232000.eTkDhRzd-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202505232000.eTkDhRzd-lkp@intel.com/ All error/warnings (new ones prefixed by >>): >> sound/soc/codecs/wsa881x-i2c.c:555:5: warning: variable 'reg_addr' set but not used [-Wunused-but-set-variable] 555 | u8 reg_addr = 0; | ^ >> sound/soc/codecs/wsa881x-i2c.c:1263:24: error: cannot assign to non-static data member 'driver' with const-qualified type 'const struct snd_soc_component_driver *' 1263 | wsa881x->driver->name = devm_kasprintf(dev, GFP_KERNEL, "wsa-codec%d", | ~~~~~~~~~~~~~~~~~~~~~ ^ sound/soc/codecs/wsa881x-common.h:260:41: note: non-static data member 'driver' declared const here 260 | const struct snd_soc_component_driver *driver; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ 1 warning and 1 error generated. vim +1263 sound/soc/codecs/wsa881x-i2c.c 1171 1172 static int wsa881x_i2c_probe(struct i2c_client *client) 1173 { 1174 struct device *dev = &client->dev; 1175 struct wsa881x_priv *wsa881x; 1176 int leftright; 1177 int ret; 1178 1179 ret = wsa881x_probe_common(&wsa881x, dev); 1180 if (ret) 1181 return ret; 1182 1183 wsa881x->mclk_pin = devm_gpiod_get(dev, "mclk", 1184 GPIOD_FLAGS_BIT_NONEXCLUSIVE); 1185 if (IS_ERR(wsa881x->mclk_pin)) 1186 dev_err_probe(dev, PTR_ERR(wsa881x->mclk_pin), 1187 "MCLK GPIO not found\n"); 1188 1189 wsa881x->wsa_mclk = devm_clk_get_enabled(&client->dev, NULL); 1190 if (IS_ERR(wsa881x->wsa_mclk)) 1191 return dev_err_probe(dev, PTR_ERR(wsa881x->wsa_mclk), 1192 "failed to get mclk\n"); 1193 gpiod_direction_output(wsa881x->mclk_pin, 1); 1194 clk_set_rate(wsa881x->wsa_mclk, 9600000); 1195 1196 wsa881x->client[DIGITAL] = client; 1197 ret = check_wsa881x_presence(wsa881x); 1198 if (ret < 0) { 1199 dev_err(&client->dev, 1200 "failed to ping wsa with addr:%x, ret = %d\n", 1201 client->addr, ret); 1202 return -ENODEV; 1203 } 1204 1205 wsa881x->regmap = devm_regmap_init_i2c(client, 1206 &wsa881x_ana_regmap_config[DIGITAL]); 1207 if (IS_ERR(wsa881x->regmap)) { 1208 dev_err(dev, "digital regmap init failed %d\n", ret); 1209 return PTR_ERR(wsa881x->regmap); 1210 } 1211 regcache_cache_bypass(wsa881x->regmap, true); 1212 1213 wsa881x_init_common(wsa881x); 1214 1215 wsa881x->version = wsa881x_i2c_read_device(wsa881x, WSA881X_CHIP_ID1); 1216 if (wsa881x->version == WSA881X_2_0) { 1217 wsa881x_update_reg_defaults_2_0(); 1218 wsa881x_update_regmap_2_0(wsa881x->regmap, DIGITAL); 1219 } 1220 1221 /* 1222 * If we reached this point, then device is present and we're good to 1223 * go to initialise analog part of the amplifier 1224 */ 1225 wsa881x->client[ANALOG] = devm_i2c_new_dummy_device(&client->dev, 1226 client->adapter, 1227 client->addr + I2C_ANALOG_OFFSET); 1228 if (IS_ERR(wsa881x->client[ANALOG])) { 1229 dev_err(dev, 1230 "failed to register i2c device for analog part\n"); 1231 return PTR_ERR(wsa881x->client[ANALOG]); 1232 } 1233 1234 wsa881x->regmap_analog = devm_regmap_init_i2c(wsa881x->client[ANALOG], 1235 &wsa881x_ana_regmap_config[ANALOG]); 1236 if (IS_ERR(wsa881x->regmap_analog)) { 1237 dev_err(dev, "analog regmap init failed %d\n", ret); 1238 return PTR_ERR(wsa881x->regmap_analog); 1239 } 1240 regcache_cache_bypass(wsa881x->regmap_analog, true); 1241 1242 wsa881x->client[ANALOG]->dev.platform_data = wsa881x; 1243 i2c_set_clientdata(wsa881x->client[ANALOG], wsa881x); 1244 wsa881x->regmap_flag = true; 1245 1246 if (wsa881x->version == WSA881X_2_0) 1247 wsa881x_update_regmap_2_0(wsa881x->regmap_analog, ANALOG); 1248 /* finished initialising analog part */ 1249 1250 leftright = wsa881x_i2c_read_device(wsa881x, WSA881X_BUS_ID) & 0x1; 1251 1252 wsa881x->driver = devm_kmemdup(dev, &soc_codec_dev_wsa881x, 1253 sizeof(*wsa881x->driver), GFP_KERNEL); 1254 if (!wsa881x->driver) 1255 return -ENOMEM; 1256 1257 wsa881x->dai_driver = devm_kmemdup(dev, wsa_dai, 1258 sizeof(struct snd_soc_dai_driver), 1259 GFP_KERNEL); 1260 if (!wsa881x->dai_driver) 1261 return -ENOMEM; 1262 > 1263 wsa881x->driver->name = devm_kasprintf(dev, GFP_KERNEL, "wsa-codec%d", 1264 leftright); 1265 if (!wsa881x->driver->name) 1266 return -ENOMEM; 1267 1268 wsa881x->dai_driver->name = devm_kasprintf(dev, GFP_KERNEL, 1269 "wsa_rx%d", leftright); 1270 if (!wsa881x->dai_driver->name) 1271 return -ENOMEM; 1272 1273 wsa881x->dai_driver->playback.stream_name = devm_kasprintf(dev, 1274 GFP_KERNEL, "WSA881X_AIF%d Playback", 1275 leftright); 1276 if (!wsa881x->dai_driver->playback.stream_name) 1277 return -ENOMEM; 1278 1279 pm_runtime_set_autosuspend_delay(dev, 3000); 1280 pm_runtime_use_autosuspend(dev); 1281 pm_runtime_mark_last_busy(dev); 1282 pm_runtime_set_active(dev); 1283 pm_runtime_enable(dev); 1284 1285 return devm_snd_soc_register_component(dev, 1286 wsa881x->driver, 1287 wsa881x->dai_driver, 1288 ARRAY_SIZE(wsa_dai)); 1289 } 1290 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v3 06/12] ASoC: codecs: add wsa881x-i2c amplifier codec driver 2025-05-22 17:40 ` [PATCH v3 06/12] ASoC: codecs: add wsa881x-i2c amplifier codec driver Alexey Klimov 2025-05-23 12:59 ` kernel test robot @ 2025-05-29 10:05 ` Srinivas Kandagatla 1 sibling, 0 replies; 43+ messages in thread From: Srinivas Kandagatla @ 2025-05-29 10:05 UTC (permalink / raw) To: Alexey Klimov, Srinivas Kandagatla, Mark Brown, linux-sound Cc: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio On 5/22/25 6:40 PM, Alexey Klimov wrote: > Add support to analog mode of WSA8810/WSA8815 Class-D Smart Speaker > family of amplifiers. Such amplifiers are primarily interfaced with > SoundWire but they also support analog mode which is configurable by > setting one of the pins to high/low. In such case the WSA881X amplifier > is configurable only using i2c. > > To have stereo two WSA881X amplifiers are required but mono > configurations are also possible. > > Cc: Srinivas Kandagatla <srini@kernel.org> > Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> > --- > sound/soc/codecs/Kconfig | 11 + > sound/soc/codecs/Makefile | 2 + > sound/soc/codecs/wsa881x-common.h | 20 + > sound/soc/codecs/wsa881x-i2c.c | 1353 +++++++++++++++++++++++++++++++++++++ > 4 files changed, 1386 insertions(+) > > diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig > index ba6e4504b5e9951203bd61fae894e86e9d40048e..9fef16003e2b7bb650c9a6bbcfd5d2f58626a5ae 100644 > --- a/sound/soc/codecs/Kconfig > +++ b/sound/soc/codecs/Kconfig > @@ -357,6 +357,7 @@ config SND_SOC_ALL_CODECS > imply SND_SOC_WM9712 > imply SND_SOC_WM9713 > imply SND_SOC_WSA881X > + imply SND_SOC_WSA881X_I2C > imply SND_SOC_WSA883X > imply SND_SOC_WSA884X > imply SND_SOC_ZL38060 > @@ -2555,6 +2556,16 @@ config SND_SOC_WSA881X > This enables support for Qualcomm WSA8810/WSA8815 Class-D > Smart Speaker Amplifier. > > +config SND_SOC_WSA881X_I2C > + tristate "WSA881X Codec - Analog mode" > + depends on I2C > + select REGMAP_I2C > + select SND_SOC_WSA881X_COMMON > + help > + This enables support for Qualcomm WSA8810/WSA8815 Class-D Smart > + Speaker Amplifier that works in analog mode and configurable > + via I2C. > + > config SND_SOC_WSA883X > tristate "WSA883X Codec" > depends on SOUNDWIRE > diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile > index 212d419cfe3c0fbd5d4e475e5d81c69ef930b3e1..7f2ec25a279087078d9480c1b14506e70c80d552 100644 > --- a/sound/soc/codecs/Makefile > +++ b/sound/soc/codecs/Makefile > @@ -407,6 +407,7 @@ snd-soc-wm9713-y := wm9713.o > snd-soc-wm-hubs-y := wm_hubs.o > snd-soc-wsa881x-y := wsa881x.o > snd-soc-wsa881x-common-y := wsa881x-common.o > +snd-soc-wsa881x-i2c-y := wsa881x-i2c.o > snd-soc-wsa883x-y := wsa883x.o > snd-soc-wsa884x-y := wsa884x.o > snd-soc-zl38060-y := zl38060.o > @@ -837,6 +838,7 @@ obj-$(CONFIG_SND_SOC_WM_ADSP) += snd-soc-wm-adsp.o > obj-$(CONFIG_SND_SOC_WM_HUBS) += snd-soc-wm-hubs.o > obj-$(CONFIG_SND_SOC_WSA881X) += snd-soc-wsa881x.o > obj-$(CONFIG_SND_SOC_WSA881X_COMMON) += snd-soc-wsa881x-common.o > +obj-$(CONFIG_SND_SOC_WSA881X_I2C) += snd-soc-wsa881x-i2c.o > obj-$(CONFIG_SND_SOC_WSA883X) += snd-soc-wsa883x.o > obj-$(CONFIG_SND_SOC_WSA884X) += snd-soc-wsa884x.o > obj-$(CONFIG_SND_SOC_ZL38060) += snd-soc-zl38060.o > diff --git a/sound/soc/codecs/wsa881x-common.h b/sound/soc/codecs/wsa881x-common.h > index ab4ee5848b10fe6ca4160b7ff634e7e06b6e41e6..a3322ad1a6eac220244a29c0540ea5dbe3118106 100644 > --- a/sound/soc/codecs/wsa881x-common.h > +++ b/sound/soc/codecs/wsa881x-common.h > @@ -2,6 +2,7 @@ > #ifndef __WSA881x_COMMON_H__ > #define __WSA881x_COMMON_H__ > > +#include <linux/i2c.h> > #include <linux/soundwire/sdw.h> > #include <sound/soc.h> > > @@ -245,6 +246,25 @@ struct wsa881x_priv { > bool port_enable[WSA881X_MAX_SWR_PORTS]; > #endif > > +#if IS_ENABLED(CONFIG_SND_SOC_WSA881X_I2C) > + /* i2c interace for analog mode */ > + struct regmap *regmap_analog; > + /* > + * First client is for the digital part, > + * the second one is for analog part > + */ > + struct i2c_client *client[2]; > + struct i2c_msg xfer_msg[2]; > + struct snd_soc_component *component; > + struct snd_soc_dai_driver *dai_driver; > + const struct snd_soc_component_driver *driver; > + struct gpio_desc *mclk_pin; > + struct clk *wsa_mclk; > + bool regmap_flag; > + bool boost_enable; > + int spk_pa_gain; > + int version; > +#endif > struct gpio_desc *sd_n; > /* > * Logical state for SD_N GPIO: high for shutdown, low for enable. > diff --git a/sound/soc/codecs/wsa881x-i2c.c b/sound/soc/codecs/wsa881x-i2c.c > new file mode 100644 > index 0000000000000000000000000000000000000000..5fa3940c65877e480aecb53acdfad5fd6ff905bd > --- /dev/null > +++ b/sound/soc/codecs/wsa881x-i2c.c > @@ -0,0 +1,1353 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Copyright (c) 2015-2016, 2018-2020, The Linux Foundation. All rights reserved. > + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. > + * Copyright (c) 2025, Linaro Limited > + */ > + > +#include <linux/clk.h> > +#include <linux/delay.h> > +#include <linux/device.h> > +#include <linux/gpio.h> > +#include <linux/i2c.h> > +#include <linux/init.h> > +#include <linux/kernel.h> > +#include <linux/platform_device.h> > +#include <linux/printk.h> > +#include <linux/pm_runtime.h> > +#include <linux/regmap.h> > +#include <linux/slab.h> > +#include <sound/pcm.h> > +#include <sound/pcm_params.h> > +#include <sound/soc.h> > +#include <sound/soc-dapm.h> > +#include "wsa881x-common.h" > + > +#define I2C_ANALOG_OFFSET 0x36 > +#define SPK_GAIN_12DB 4 > + > +#define WSA881X_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\ > + SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\ > + SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000 |\ > + SNDRV_PCM_RATE_384000) > +/* Fractional Rates */ > +#define WSA881X_FRAC_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_88200 |\ > + SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800) > + > +#define WSA881X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\ > + SNDRV_PCM_FMTBIT_S24_LE |\ > + SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE) > + > +#define WSA881X_I2C_DRV_NAME "wsa881x_i2c_codec" > + > +#define DIGITAL 0 > +#define ANALOG 1 > + > +enum { > + WSA881X_1_X = 0, > + WSA881X_2_0, > +}; > + > +#define WSA881X_IS_2_0(ver) ((ver == WSA881X_2_0) ? 1 : 0) > + > +struct reg_default wsa881x_ana_reg_defaults[] = { This does not make sense. All the regmaps should be same, it should not change with the change in interface from SWD to I2C. Could you calrify this before we start reviewing rest of the driver. --srini > + {WSA881X_CHIP_ID0, 0x00}, > + {WSA881X_CHIP_ID1, 0x00}, > + {WSA881X_CHIP_ID2, 0x00}, > + {WSA881X_CHIP_ID3, 0x02}, > + {WSA881X_BUS_ID, 0x00}, > + {WSA881X_CDC_RST_CTL, 0x00}, > + {WSA881X_CDC_TOP_CLK_CTL, 0x03}, > + {WSA881X_CDC_ANA_CLK_CTL, 0x00}, > + {WSA881X_CDC_DIG_CLK_CTL, 0x00}, > + {WSA881X_CLOCK_CONFIG, 0x00}, > + {WSA881X_ANA_CTL, 0x08}, > + {WSA881X_SWR_RESET_EN, 0x00}, > + {WSA881X_TEMP_DETECT_CTL, 0x01}, > + {WSA881X_TEMP_MSB, 0x00}, > + {WSA881X_TEMP_LSB, 0x00}, > + {WSA881X_TEMP_CONFIG0, 0x00}, > + {WSA881X_TEMP_CONFIG1, 0x00}, > + {WSA881X_CDC_CLIP_CTL, 0x03}, > + {WSA881X_SDM_PDM9_LSB, 0x00}, > + {WSA881X_SDM_PDM9_MSB, 0x00}, > + {WSA881X_CDC_RX_CTL, 0x7E}, > + {WSA881X_DEM_BYPASS_DATA0, 0x00}, > + {WSA881X_DEM_BYPASS_DATA1, 0x00}, > + {WSA881X_DEM_BYPASS_DATA2, 0x00}, > + {WSA881X_DEM_BYPASS_DATA3, 0x00}, > + {WSA881X_OTP_CTRL0, 0x00}, > + {WSA881X_OTP_CTRL1, 0x00}, > + {WSA881X_HDRIVE_CTL_GROUP1, 0x00}, > + {WSA881X_INTR_MODE, 0x00}, > + {WSA881X_INTR_MASK, 0x1F}, > + {WSA881X_INTR_STATUS, 0x00}, > + {WSA881X_INTR_CLEAR, 0x00}, > + {WSA881X_INTR_LEVEL, 0x00}, > + {WSA881X_INTR_SET, 0x00}, > + {WSA881X_INTR_TEST, 0x00}, > + {WSA881X_PDM_TEST_MODE, 0x00}, > + {WSA881X_ATE_TEST_MODE, 0x00}, > + {WSA881X_PIN_CTL_MODE, 0x00}, > + {WSA881X_PIN_CTL_OE, 0x00}, > + {WSA881X_PIN_WDATA_IOPAD, 0x00}, > + {WSA881X_PIN_STATUS, 0x00}, > + {WSA881X_DIG_DEBUG_MODE, 0x00}, > + {WSA881X_DIG_DEBUG_SEL, 0x00}, > + {WSA881X_DIG_DEBUG_EN, 0x00}, > + {WSA881X_SWR_HM_TEST1, 0x08}, > + {WSA881X_SWR_HM_TEST2, 0x00}, > + {WSA881X_TEMP_DETECT_DBG_CTL, 0x00}, > + {WSA881X_TEMP_DEBUG_MSB, 0x00}, > + {WSA881X_TEMP_DEBUG_LSB, 0x00}, > + {WSA881X_SAMPLE_EDGE_SEL, 0x0C}, > + {WSA881X_SPARE_0, 0x00}, > + {WSA881X_SPARE_1, 0x00}, > + {WSA881X_SPARE_2, 0x00}, > + {WSA881X_OTP_REG_0, 0x01}, > + {WSA881X_OTP_REG_1, 0xFF}, > + {WSA881X_OTP_REG_2, 0xC0}, > + {WSA881X_OTP_REG_3, 0xFF}, > + {WSA881X_OTP_REG_4, 0xC0}, > + {WSA881X_OTP_REG_5, 0xFF}, > + {WSA881X_OTP_REG_6, 0xFF}, > + {WSA881X_OTP_REG_7, 0xFF}, > + {WSA881X_OTP_REG_8, 0xFF}, > + {WSA881X_OTP_REG_9, 0xFF}, > + {WSA881X_OTP_REG_10, 0xFF}, > + {WSA881X_OTP_REG_11, 0xFF}, > + {WSA881X_OTP_REG_12, 0xFF}, > + {WSA881X_OTP_REG_13, 0xFF}, > + {WSA881X_OTP_REG_14, 0xFF}, > + {WSA881X_OTP_REG_15, 0xFF}, > + {WSA881X_OTP_REG_16, 0xFF}, > + {WSA881X_OTP_REG_17, 0xFF}, > + {WSA881X_OTP_REG_18, 0xFF}, > + {WSA881X_OTP_REG_19, 0xFF}, > + {WSA881X_OTP_REG_20, 0xFF}, > + {WSA881X_OTP_REG_21, 0xFF}, > + {WSA881X_OTP_REG_22, 0xFF}, > + {WSA881X_OTP_REG_23, 0xFF}, > + {WSA881X_OTP_REG_24, 0x03}, > + {WSA881X_OTP_REG_25, 0x01}, > + {WSA881X_OTP_REG_26, 0x03}, > + {WSA881X_OTP_REG_27, 0x11}, > + {WSA881X_OTP_REG_28, 0xFF}, > + {WSA881X_OTP_REG_29, 0xFF}, > + {WSA881X_OTP_REG_30, 0xFF}, > + {WSA881X_OTP_REG_31, 0xFF}, > + {WSA881X_OTP_REG_63, 0x40}, > + /* WSA881x Analog registers */ > + {WSA881X_BIAS_REF_CTRL, 0x6C}, > + {WSA881X_BIAS_TEST, 0x16}, > + {WSA881X_BIAS_BIAS, 0xF0}, > + {WSA881X_TEMP_OP, 0x00}, > + {WSA881X_TEMP_IREF_CTRL, 0x56}, > + {WSA881X_TEMP_ISENS_CTRL, 0x47}, > + {WSA881X_TEMP_CLK_CTRL, 0x87}, > + {WSA881X_TEMP_TEST, 0x00}, > + {WSA881X_TEMP_BIAS, 0x51}, > + {WSA881X_TEMP_ADC_CTRL, 0x00}, > + {WSA881X_TEMP_DOUT_MSB, 0x00}, > + {WSA881X_TEMP_DOUT_LSB, 0x00}, > + {WSA881X_ADC_EN_MODU_V, 0x00}, > + {WSA881X_ADC_EN_MODU_I, 0x00}, > + {WSA881X_ADC_EN_DET_TEST_V, 0x00}, > + {WSA881X_ADC_EN_DET_TEST_I, 0x00}, > + {WSA881X_ADC_SEL_IBIAS, 0x25}, > + {WSA881X_ADC_EN_SEL_IBIAS, 0x10}, > + {WSA881X_SPKR_DRV_EN, 0x74}, > + {WSA881X_SPKR_DRV_GAIN, 0x01}, > + {WSA881X_SPKR_DAC_CTL, 0x40}, > + {WSA881X_SPKR_DRV_DBG, 0x15}, > + {WSA881X_SPKR_PWRSTG_DBG, 0x00}, > + {WSA881X_SPKR_OCP_CTL, 0xD4}, > + {WSA881X_SPKR_CLIP_CTL, 0x90}, > + {WSA881X_SPKR_BBM_CTL, 0x00}, > + {WSA881X_SPKR_MISC_CTL1, 0x80}, > + {WSA881X_SPKR_MISC_CTL2, 0x00}, > + {WSA881X_SPKR_BIAS_INT, 0x56}, > + {WSA881X_SPKR_PA_INT, 0x54}, > + {WSA881X_SPKR_BIAS_CAL, 0xAC}, > + {WSA881X_SPKR_BIAS_PSRR, 0x54}, > + {WSA881X_SPKR_STATUS1, 0x00}, > + {WSA881X_SPKR_STATUS2, 0x00}, > + {WSA881X_BOOST_EN_CTL, 0x18}, > + {WSA881X_BOOST_CURRENT_LIMIT, 0x7A}, > + {WSA881X_BOOST_PS_CTL, 0xC0}, > + {WSA881X_BOOST_PRESET_OUT1, 0x77}, > + {WSA881X_BOOST_PRESET_OUT2, 0x70}, > + {WSA881X_BOOST_FORCE_OUT, 0x0E}, > + {WSA881X_BOOST_LDO_PROG, 0x16}, > + {WSA881X_BOOST_SLOPE_COMP_ISENSE_FB, 0x71}, > + {WSA881X_BOOST_RON_CTL, 0x0F}, > + {WSA881X_BOOST_LOOP_STABILITY, 0xAD}, > + {WSA881X_BOOST_ZX_CTL, 0x34}, > + {WSA881X_BOOST_START_CTL, 0x23}, > + {WSA881X_BOOST_MISC1_CTL, 0x80}, > + {WSA881X_BOOST_MISC2_CTL, 0x00}, > + {WSA881X_BOOST_MISC3_CTL, 0x00}, > + {WSA881X_BOOST_ATEST_CTL, 0x00}, > + {WSA881X_SPKR_PROT_FE_GAIN, 0x46}, > + {WSA881X_SPKR_PROT_FE_CM_LDO_SET, 0x3B}, > + {WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET1, 0x8D}, > + {WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET2, 0x8D}, > + {WSA881X_SPKR_PROT_ATEST1, 0x01}, > + {WSA881X_SPKR_PROT_ATEST2, 0x00}, > + {WSA881X_SPKR_PROT_FE_VSENSE_VCM, 0x8D}, > + {WSA881X_SPKR_PROT_FE_VSENSE_BIAS_SET1, 0x4D}, > + {WSA881X_BONGO_RESRV_REG1, 0x00}, > + {WSA881X_BONGO_RESRV_REG2, 0x00}, > + {WSA881X_SPKR_PROT_SAR, 0x00}, > + {WSA881X_SPKR_STATUS3, 0x00}, > +}; > + > +const struct reg_default wsa881x_ana_reg_defaults_0[] = { > + {WSA881X_CHIP_ID0, 0x00}, > + {WSA881X_CHIP_ID1, 0x00}, > + {WSA881X_CHIP_ID2, 0x00}, > + {WSA881X_CHIP_ID3, 0x02}, > + {WSA881X_BUS_ID, 0x00}, > + {WSA881X_CDC_RST_CTL, 0x00}, > + {WSA881X_CDC_TOP_CLK_CTL, 0x03}, > + {WSA881X_CDC_ANA_CLK_CTL, 0x00}, > + {WSA881X_CDC_DIG_CLK_CTL, 0x00}, > + {WSA881X_CLOCK_CONFIG, 0x00}, > + {WSA881X_ANA_CTL, 0x08}, > + {WSA881X_SWR_RESET_EN, 0x00}, > + {WSA881X_TEMP_DETECT_CTL, 0x01}, > + {WSA881X_TEMP_MSB, 0x00}, > + {WSA881X_TEMP_LSB, 0x00}, > + {WSA881X_TEMP_CONFIG0, 0x00}, > + {WSA881X_TEMP_CONFIG1, 0x00}, > + {WSA881X_CDC_CLIP_CTL, 0x03}, > + {WSA881X_SDM_PDM9_LSB, 0x00}, > + {WSA881X_SDM_PDM9_MSB, 0x00}, > + {WSA881X_CDC_RX_CTL, 0x7E}, > + {WSA881X_DEM_BYPASS_DATA0, 0x00}, > + {WSA881X_DEM_BYPASS_DATA1, 0x00}, > + {WSA881X_DEM_BYPASS_DATA2, 0x00}, > + {WSA881X_DEM_BYPASS_DATA3, 0x00}, > + {WSA881X_OTP_CTRL0, 0x00}, > + {WSA881X_OTP_CTRL1, 0x00}, > + {WSA881X_HDRIVE_CTL_GROUP1, 0x00}, > + {WSA881X_INTR_MODE, 0x00}, > + {WSA881X_INTR_MASK, 0x1F}, > + {WSA881X_INTR_STATUS, 0x00}, > + {WSA881X_INTR_CLEAR, 0x00}, > + {WSA881X_INTR_LEVEL, 0x00}, > + {WSA881X_INTR_SET, 0x00}, > + {WSA881X_INTR_TEST, 0x00}, > + {WSA881X_PDM_TEST_MODE, 0x00}, > + {WSA881X_ATE_TEST_MODE, 0x00}, > + {WSA881X_PIN_CTL_MODE, 0x00}, > + {WSA881X_PIN_CTL_OE, 0x00}, > + {WSA881X_PIN_WDATA_IOPAD, 0x00}, > + {WSA881X_PIN_STATUS, 0x00}, > + {WSA881X_DIG_DEBUG_MODE, 0x00}, > + {WSA881X_DIG_DEBUG_SEL, 0x00}, > + {WSA881X_DIG_DEBUG_EN, 0x00}, > + {WSA881X_SWR_HM_TEST1, 0x08}, > + {WSA881X_SWR_HM_TEST2, 0x00}, > + {WSA881X_TEMP_DETECT_DBG_CTL, 0x00}, > + {WSA881X_TEMP_DEBUG_MSB, 0x00}, > + {WSA881X_TEMP_DEBUG_LSB, 0x00}, > + {WSA881X_SAMPLE_EDGE_SEL, 0x0C}, > + {WSA881X_SPARE_0, 0x00}, > + {WSA881X_SPARE_1, 0x00}, > + {WSA881X_SPARE_2, 0x00}, > + {WSA881X_OTP_REG_0, 0x01}, > + {WSA881X_OTP_REG_1, 0xFF}, > + {WSA881X_OTP_REG_2, 0xC0}, > + {WSA881X_OTP_REG_3, 0xFF}, > + {WSA881X_OTP_REG_4, 0xC0}, > + {WSA881X_OTP_REG_5, 0xFF}, > + {WSA881X_OTP_REG_6, 0xFF}, > + {WSA881X_OTP_REG_7, 0xFF}, > + {WSA881X_OTP_REG_8, 0xFF}, > + {WSA881X_OTP_REG_9, 0xFF}, > + {WSA881X_OTP_REG_10, 0xFF}, > + {WSA881X_OTP_REG_11, 0xFF}, > + {WSA881X_OTP_REG_12, 0xFF}, > + {WSA881X_OTP_REG_13, 0xFF}, > + {WSA881X_OTP_REG_14, 0xFF}, > + {WSA881X_OTP_REG_15, 0xFF}, > + {WSA881X_OTP_REG_16, 0xFF}, > + {WSA881X_OTP_REG_17, 0xFF}, > + {WSA881X_OTP_REG_18, 0xFF}, > + {WSA881X_OTP_REG_19, 0xFF}, > + {WSA881X_OTP_REG_20, 0xFF}, > + {WSA881X_OTP_REG_21, 0xFF}, > + {WSA881X_OTP_REG_22, 0xFF}, > + {WSA881X_OTP_REG_23, 0xFF}, > + {WSA881X_OTP_REG_24, 0x03}, > + {WSA881X_OTP_REG_25, 0x01}, > + {WSA881X_OTP_REG_26, 0x03}, > + {WSA881X_OTP_REG_27, 0x11}, > + {WSA881X_OTP_REG_28, 0xFF}, > + {WSA881X_OTP_REG_29, 0xFF}, > + {WSA881X_OTP_REG_30, 0xFF}, > + {WSA881X_OTP_REG_31, 0xFF}, > + {WSA881X_OTP_REG_63, 0x40}, > +}; > + > +const struct reg_default wsa881x_ana_reg_defaults_1[] = { > + {WSA881X_BIAS_REF_CTRL - WSA881X_ANALOG_BASE, 0x6C}, > + {WSA881X_BIAS_TEST - WSA881X_ANALOG_BASE, 0x16}, > + {WSA881X_BIAS_BIAS - WSA881X_ANALOG_BASE, 0xF0}, > + {WSA881X_TEMP_OP - WSA881X_ANALOG_BASE, 0x00}, > + {WSA881X_TEMP_IREF_CTRL - WSA881X_ANALOG_BASE, 0x56}, > + {WSA881X_TEMP_ISENS_CTRL - WSA881X_ANALOG_BASE, 0x47}, > + {WSA881X_TEMP_CLK_CTRL - WSA881X_ANALOG_BASE, 0x87}, > + {WSA881X_TEMP_TEST - WSA881X_ANALOG_BASE, 0x00}, > + {WSA881X_TEMP_BIAS - WSA881X_ANALOG_BASE, 0x51}, > + {WSA881X_TEMP_ADC_CTRL - WSA881X_ANALOG_BASE, 0x00}, > + {WSA881X_TEMP_DOUT_MSB - WSA881X_ANALOG_BASE, 0x00}, > + {WSA881X_TEMP_DOUT_LSB - WSA881X_ANALOG_BASE, 0x00}, > + {WSA881X_ADC_EN_MODU_V - WSA881X_ANALOG_BASE, 0x00}, > + {WSA881X_ADC_EN_MODU_I - WSA881X_ANALOG_BASE, 0x00}, > + {WSA881X_ADC_EN_DET_TEST_V - WSA881X_ANALOG_BASE, 0x00}, > + {WSA881X_ADC_EN_DET_TEST_I - WSA881X_ANALOG_BASE, 0x00}, > + {WSA881X_ADC_SEL_IBIAS - WSA881X_ANALOG_BASE, 0x25}, > + {WSA881X_ADC_EN_SEL_IBIAS - WSA881X_ANALOG_BASE, 0x10}, > + {WSA881X_SPKR_DRV_EN - WSA881X_ANALOG_BASE, 0x74}, > + {WSA881X_SPKR_DRV_GAIN - WSA881X_ANALOG_BASE, 0x01}, > + {WSA881X_SPKR_DAC_CTL - WSA881X_ANALOG_BASE, 0x40}, > + {WSA881X_SPKR_DRV_DBG - WSA881X_ANALOG_BASE, 0x15}, > + {WSA881X_SPKR_PWRSTG_DBG - WSA881X_ANALOG_BASE, 0x00}, > + {WSA881X_SPKR_OCP_CTL - WSA881X_ANALOG_BASE, 0xD4}, > + {WSA881X_SPKR_CLIP_CTL - WSA881X_ANALOG_BASE, 0x90}, > + {WSA881X_SPKR_BBM_CTL - WSA881X_ANALOG_BASE, 0x00}, > + {WSA881X_SPKR_MISC_CTL1 - WSA881X_ANALOG_BASE, 0x80}, > + {WSA881X_SPKR_MISC_CTL2 - WSA881X_ANALOG_BASE, 0x00}, > + {WSA881X_SPKR_BIAS_INT - WSA881X_ANALOG_BASE, 0x56}, > + {WSA881X_SPKR_PA_INT - WSA881X_ANALOG_BASE, 0x54}, > + {WSA881X_SPKR_BIAS_CAL - WSA881X_ANALOG_BASE, 0xAC}, > + {WSA881X_SPKR_BIAS_PSRR - WSA881X_ANALOG_BASE, 0x54}, > + {WSA881X_SPKR_STATUS1 - WSA881X_ANALOG_BASE, 0x00}, > + {WSA881X_SPKR_STATUS2 - WSA881X_ANALOG_BASE, 0x00}, > + {WSA881X_BOOST_EN_CTL - WSA881X_ANALOG_BASE, 0x18}, > + {WSA881X_BOOST_CURRENT_LIMIT - WSA881X_ANALOG_BASE, 0x7A}, > + {WSA881X_BOOST_PS_CTL - WSA881X_ANALOG_BASE, 0xC0}, > + {WSA881X_BOOST_PRESET_OUT1 - WSA881X_ANALOG_BASE, 0x77}, > + {WSA881X_BOOST_PRESET_OUT2 - WSA881X_ANALOG_BASE, 0x70}, > + {WSA881X_BOOST_FORCE_OUT - WSA881X_ANALOG_BASE, 0x0E}, > + {WSA881X_BOOST_LDO_PROG - WSA881X_ANALOG_BASE, 0x16}, > + {WSA881X_BOOST_SLOPE_COMP_ISENSE_FB - WSA881X_ANALOG_BASE, 0x71}, > + {WSA881X_BOOST_RON_CTL - WSA881X_ANALOG_BASE, 0x0F}, > + {WSA881X_BOOST_LOOP_STABILITY - WSA881X_ANALOG_BASE, 0xAD}, > + {WSA881X_BOOST_ZX_CTL - WSA881X_ANALOG_BASE, 0x34}, > + {WSA881X_BOOST_START_CTL - WSA881X_ANALOG_BASE, 0x23}, > + {WSA881X_BOOST_MISC1_CTL - WSA881X_ANALOG_BASE, 0x80}, > + {WSA881X_BOOST_MISC2_CTL - WSA881X_ANALOG_BASE, 0x00}, > + {WSA881X_BOOST_MISC3_CTL - WSA881X_ANALOG_BASE, 0x00}, > + {WSA881X_BOOST_ATEST_CTL - WSA881X_ANALOG_BASE, 0x00}, > + {WSA881X_SPKR_PROT_FE_GAIN - WSA881X_ANALOG_BASE, 0x46}, > + {WSA881X_SPKR_PROT_FE_CM_LDO_SET - WSA881X_ANALOG_BASE, 0x3B}, > + {WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET1 - WSA881X_ANALOG_BASE, 0x8D}, > + {WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET2 - WSA881X_ANALOG_BASE, 0x8D}, > + {WSA881X_SPKR_PROT_ATEST1 - WSA881X_ANALOG_BASE, 0x01}, > + {WSA881X_SPKR_PROT_ATEST2 - WSA881X_ANALOG_BASE, 0x00}, > + {WSA881X_SPKR_PROT_FE_VSENSE_VCM - WSA881X_ANALOG_BASE, 0x8D}, > + {WSA881X_SPKR_PROT_FE_VSENSE_BIAS_SET1 - WSA881X_ANALOG_BASE, 0x4D}, > + {WSA881X_BONGO_RESRV_REG1 - WSA881X_ANALOG_BASE, 0x00}, > + {WSA881X_BONGO_RESRV_REG2 - WSA881X_ANALOG_BASE, 0x00}, > + {WSA881X_SPKR_PROT_SAR - WSA881X_ANALOG_BASE, 0x00}, > + {WSA881X_SPKR_STATUS3 - WSA881X_ANALOG_BASE, 0x00}, > +}; > + > +static const struct reg_sequence wsa881x_rev_2_0_dig[] = { > + {WSA881X_RESET_CTL, 0x00}, > + {WSA881X_TADC_VALUE_CTL, 0x01}, > + {WSA881X_INTR_MASK, 0x1B}, > + {WSA881X_IOPAD_CTL, 0x00}, > + {WSA881X_OTP_REG_28, 0x3F}, > + {WSA881X_OTP_REG_29, 0x3F}, > + {WSA881X_OTP_REG_30, 0x01}, > + {WSA881X_OTP_REG_31, 0x01}, > +}; > + > +static const struct reg_sequence wsa881x_rev_2_0_ana[] = { > + {WSA881X_TEMP_ADC_CTRL, 0x03}, > + {WSA881X_ADC_SEL_IBIAS, 0x45}, > + {WSA881X_SPKR_DRV_GAIN, 0xC1}, > + {WSA881X_SPKR_DAC_CTL, 0x42}, > + {WSA881X_SPKR_BBM_CTL, 0x02}, > + {WSA881X_SPKR_MISC_CTL1, 0x40}, > + {WSA881X_SPKR_MISC_CTL2, 0x07}, > + {WSA881X_SPKR_BIAS_INT, 0x5F}, > + {WSA881X_SPKR_BIAS_PSRR, 0x44}, > + {WSA881X_BOOST_PS_CTL, 0xA0}, > + {WSA881X_BOOST_PRESET_OUT1, 0xB7}, > + {WSA881X_BOOST_LOOP_STABILITY, 0x8D}, > + {WSA881X_SPKR_PROT_ATEST2, 0x02}, > + {WSA881X_BONGO_RESRV_REG1, 0x5E}, > + {WSA881X_BONGO_RESRV_REG2, 0x07}, > +}; > + > +static const struct reg_default wsa881x_rev_2_0_regmap_ana[] = { > + {WSA881X_TEMP_ADC_CTRL - WSA881X_ANALOG_BASE, 0x03}, > + {WSA881X_ADC_SEL_IBIAS - WSA881X_ANALOG_BASE, 0x45}, > + {WSA881X_SPKR_DRV_GAIN - WSA881X_ANALOG_BASE, 0xC1}, > + {WSA881X_SPKR_DAC_CTL - WSA881X_ANALOG_BASE, 0x42}, > + {WSA881X_SPKR_BBM_CTL - WSA881X_ANALOG_BASE, 0x02}, > + {WSA881X_SPKR_MISC_CTL1 - WSA881X_ANALOG_BASE, 0x40}, > + {WSA881X_SPKR_MISC_CTL2 - WSA881X_ANALOG_BASE, 0x07}, > + {WSA881X_SPKR_BIAS_INT - WSA881X_ANALOG_BASE, 0x5F}, > + {WSA881X_SPKR_BIAS_PSRR - WSA881X_ANALOG_BASE, 0x44}, > + {WSA881X_BOOST_PS_CTL - WSA881X_ANALOG_BASE, 0xA0}, > + {WSA881X_BOOST_PRESET_OUT1 - WSA881X_ANALOG_BASE, 0xB7}, > + {WSA881X_BOOST_LOOP_STABILITY - WSA881X_ANALOG_BASE, 0x8D}, > + {WSA881X_SPKR_PROT_ATEST2 - WSA881X_ANALOG_BASE, 0x02}, > + {WSA881X_BONGO_RESRV_REG1 - WSA881X_ANALOG_BASE, 0x5E}, > + {WSA881X_BONGO_RESRV_REG2 - WSA881X_ANALOG_BASE, 0x07}, > +}; > + > +/** > + * wsa881x_update_reg_defaults_2_0 - update default values of regs for v2.0 > + * > + * wsa881x v2.0 has different default values for certain analog and digital > + * registers compared to v1.x. Therefore, update the values of these registers > + * with the values from tables defined above for v2.0. > + */ > +static void wsa881x_update_reg_defaults_2_0(void) > +{ > + int i, j; > + > + for (i = 0; i < ARRAY_SIZE(wsa881x_rev_2_0_dig); i++) { > + for (j = 0; j < ARRAY_SIZE(wsa881x_ana_reg_defaults); j++) > + if (wsa881x_ana_reg_defaults[j].reg == > + wsa881x_rev_2_0_dig[i].reg) > + wsa881x_ana_reg_defaults[j].def = > + wsa881x_rev_2_0_dig[i].def; > + } > + for (i = 0; i < ARRAY_SIZE(wsa881x_rev_2_0_ana); i++) { > + for (j = 0; j < ARRAY_SIZE(wsa881x_ana_reg_defaults); j++) > + if (wsa881x_ana_reg_defaults[j].reg == > + wsa881x_rev_2_0_ana[i].reg) > + wsa881x_ana_reg_defaults[j].def = > + wsa881x_rev_2_0_ana[i].def; > + } > +} > + > +/** > + * wsa881x_update_regmap_2_0 - update regmap framework with new tables > + * @regmap: pointer to wsa881x regmap structure > + * @flag: indicates digital or analog wsa881x slave > + * > + * wsa881x v2.0 has some new registers for both analog and digital slaves. > + * Update the regmap framework with all the new registers. > + */ > +static void wsa881x_update_regmap_2_0(struct regmap *regmap, int flag) > +{ > + u16 ret; > + > + switch (flag) { > + case DIGITAL: > + ret = regmap_register_patch(regmap, wsa881x_rev_2_0_dig, > + ARRAY_SIZE(wsa881x_rev_2_0_dig)); > + break; > + case ANALOG: > + ret = regmap_register_patch(regmap, wsa881x_rev_2_0_ana, > + ARRAY_SIZE(wsa881x_rev_2_0_ana)); > + break; > + default: > + pr_debug("%s: unknown version", __func__); > + ret = -EINVAL; > + break; > + } > + if (ret) > + pr_err("%s: failed to update regmap defaults ret=%d\n", > + __func__, ret); > +} > + > +const struct regmap_config wsa881x_ana_regmap_config[] = { > + { > + .reg_bits = 8, > + .val_bits = 8, > + .cache_type = REGCACHE_NONE, > + .reg_defaults = wsa881x_ana_reg_defaults_0, > + .num_reg_defaults = ARRAY_SIZE(wsa881x_ana_reg_defaults_0), > + .max_register = WSA881X_SPKR_STATUS3, > + .volatile_reg = wsa881x_volatile_register, > + .readable_reg = wsa881x_readable_register, > + .reg_format_endian = REGMAP_ENDIAN_NATIVE, > + .val_format_endian = REGMAP_ENDIAN_NATIVE, > + }, > + { > + .reg_bits = 8, > + .val_bits = 8, > + .cache_type = REGCACHE_NONE, > + .reg_defaults = wsa881x_ana_reg_defaults_1, > + .num_reg_defaults = ARRAY_SIZE(wsa881x_ana_reg_defaults_1), > + .max_register = WSA881X_SPKR_STATUS3, > + .volatile_reg = wsa881x_volatile_register, > + .readable_reg = wsa881x_readable_register, > + .reg_format_endian = REGMAP_ENDIAN_NATIVE, > + .val_format_endian = REGMAP_ENDIAN_NATIVE, > + } > +}; > + > +static const struct i2c_device_id wsa881x_i2c_id[]; > + > +static const int delay_array_msec[] = {10, 20, 30, 40, 50}; > + > +static const char * const wsa881x_spk_pa_gain_text[] = { > +"POS_13P5_DB", "POS_12_DB", "POS_10P5_DB", "POS_9_DB", "POS_7P5_DB", > +"POS_6_DB", "POS_4P5_DB", "POS_3_DB", "POS_1P5_DB", "POS_0_DB"}; > + > +static const struct soc_enum wsa881x_spk_pa_gain_enum[] = { > + SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(wsa881x_spk_pa_gain_text), > + wsa881x_spk_pa_gain_text), > +}; > + > +static int wsa881x_spk_pa_gain_get(struct snd_kcontrol *kcontrol, > + struct snd_ctl_elem_value *ucontrol) > +{ > + struct snd_soc_component *component = > + snd_soc_kcontrol_component(kcontrol); > + struct wsa881x_priv *wsa881x = > + snd_soc_component_get_drvdata(component); > + > + ucontrol->value.integer.value[0] = wsa881x->spk_pa_gain; > + return 0; > +} > + > +static int wsa881x_spk_pa_gain_put(struct snd_kcontrol *kcontrol, > + struct snd_ctl_elem_value *ucontrol) > +{ > + struct snd_soc_component *component = > + snd_soc_kcontrol_component(kcontrol); > + struct wsa881x_priv *wsa881x = > + snd_soc_component_get_drvdata(component); > + > + if (ucontrol->value.integer.value[0] < 0 || > + ucontrol->value.integer.value[0] > 0xC) { > + dev_err(component->dev, "unsupported gain val %ld\n", > + ucontrol->value.integer.value[0]); > + return -EINVAL; > + } > + wsa881x->spk_pa_gain = ucontrol->value.integer.value[0]; > + return 0; > +} > + > +/* Helpers to figure out which regmap or client contains the register */ > +static struct regmap *find_regmap(struct wsa881x_priv *wsa881x, u16 reg) > +{ > + if (reg >= WSA881X_ANALOG_BASE) > + return wsa881x->regmap_analog; > + else > + return wsa881x->regmap; > +} > + > +static int find_client_index(u16 reg) > +{ > + return reg >= WSA881X_ANALOG_BASE ? ANALOG : DIGITAL; > +} > + > +static int wsa881x_i2c_write_device(struct wsa881x_priv *wsa881x, > + unsigned int reg, unsigned int val) > +{ > + struct regmap *wsa881x_regmap; > + struct i2c_msg *msg; > + int bytes = 1; > + int ret, i, index; > + u8 reg_addr = 0; > + u8 data[2]; > + > + if (wsa881x->regmap_flag) { > + wsa881x_regmap = find_regmap(wsa881x, reg); > + ret = regmap_write(wsa881x_regmap, reg, val); > + for (i = 0; ret && i < ARRAY_SIZE(delay_array_msec); i++) { > + dev_err_ratelimited(wsa881x->dev, > + "failed writing reg=%x-retry(%d)\n", > + reg, i); > + /* retry after delay of increasing order */ > + msleep(delay_array_msec[i]); > + ret = regmap_write(wsa881x_regmap, reg, val); > + } > + if (ret) > + dev_err_ratelimited(wsa881x->dev, > + "failed writing reg=%x ret=%d\n", > + reg, ret); > + else > + dev_dbg(wsa881x->dev, "wrote reg=%x val=%x\n", > + reg, val); > + } else { > + index = find_client_index(reg); > + reg_addr = (u8)reg; > + msg = &wsa881x->xfer_msg[0]; > + msg->addr = wsa881x->client[index]->addr; > + msg->len = bytes + 1; > + msg->flags = 0; > + data[0] = reg; > + data[1] = (u8)val; > + msg->buf = data; > + > + ret = i2c_transfer(wsa881x->client[index]->adapter, > + wsa881x->xfer_msg, 1); > + /* Try again if the write fails */ > + if (ret != 1) { > + pr_err("write failed\n"); > + ret = i2c_transfer(wsa881x->client[index]->adapter, > + wsa881x->xfer_msg, 1); > + if (ret != 1) { > + dev_err_ratelimited(wsa881x->dev, > + "failed i2c transfer\n"); > + return ret; > + } > + } > + dev_dbg(wsa881x->dev, "wrote reg=%x val=%x\n", reg, data[1]); > + } > + return ret; > +} > + > +static int wsa881x_i2c_read_device(struct wsa881x_priv *wsa881x, > + unsigned int reg) > +{ > + struct regmap *wsa881x_regmap; > + struct i2c_msg *msg; > + unsigned int val; > + int ret, i, index; > + u8 reg_addr = 0; > + u8 dest[5] = {0}; > + > + if (wsa881x->regmap_flag) { > + wsa881x_regmap = find_regmap(wsa881x, reg); > + if (!wsa881x_regmap) { > + dev_err_ratelimited(wsa881x->dev, > + "invalid register to read\n"); > + return -EINVAL; > + } > + ret = regmap_read(wsa881x_regmap, reg, &val); > + for (i = 0; ret && i < ARRAY_SIZE(delay_array_msec); i++) { > + dev_err_ratelimited(wsa881x->dev, > + "failed to read reg=%x-retry(%d)\n", > + reg, i); > + /* retry after delay of increasing order */ > + msleep(delay_array_msec[i]); > + ret = regmap_read(wsa881x_regmap, reg, &val); > + } > + if (ret) { > + dev_err_ratelimited(wsa881x->dev, > + "failed to read reg=%x ret=%d\n", > + reg, ret); > + return ret; > + } > + dev_dbg(wsa881x->dev, "read success, reg=%x val=%x\n", > + reg, val); > + } else { > + index = find_client_index(reg); > + reg_addr = (u8)reg; > + msg = &wsa881x->xfer_msg[0]; > + msg->addr = wsa881x->client[index]->addr; > + msg->len = 1; > + msg->flags = 0; > + msg->buf = ®_addr; > + > + msg = &wsa881x->xfer_msg[1]; > + msg->addr = wsa881x->client[index]->addr; > + msg->len = 1; > + msg->flags = I2C_M_RD; > + msg->buf = dest; > + > + ret = i2c_transfer(wsa881x->client[index]->adapter, > + wsa881x->xfer_msg, 2); > + /* Try again if read fails first time */ > + if (ret != 2) { > + ret = i2c_transfer(wsa881x->client[index]->adapter, > + wsa881x->xfer_msg, 2); > + if (ret != 2) { > + dev_err_ratelimited(wsa881x->dev, > + "failed to read reg=%d\n", > + reg); > + return ret; > + } > + } > + val = dest[0]; > + } > + return val; > +} > + > +static unsigned int wsa881x_i2c_read(struct snd_soc_component *component, > + unsigned int reg) > +{ > + struct wsa881x_priv *wsa881x; > + int retval; > + > + wsa881x = snd_soc_component_get_drvdata(component); > + > + retval = wsa881x_i2c_read_device(wsa881x, reg); > + > + return retval >= 0 ? retval : 0; > +} > + > +static int wsa881x_i2c_write(struct snd_soc_component *component, > + unsigned int reg, unsigned int val) > +{ > + struct wsa881x_priv *wsa881x; > + > + wsa881x = snd_soc_component_get_drvdata(component); > + > + return wsa881x_i2c_write_device(wsa881x, reg, val); > +} > + > +static int wsa881x_boost_ctrl(struct snd_soc_component *component, bool enable) > +{ > + struct wsa881x_priv *wsa881x = > + snd_soc_component_get_drvdata(component); > + > + if (enable) { > + if (!WSA881X_IS_2_0(wsa881x->version)) { > + snd_soc_component_update_bits(component, > + WSA881X_ANA_CTL, 0x01, 0x01); > + snd_soc_component_update_bits(component, > + WSA881X_ANA_CTL, 0x04, 0x04); > + snd_soc_component_update_bits(component, > + WSA881X_BOOST_PS_CTL, > + 0x40, 0x00); > + snd_soc_component_update_bits(component, > + WSA881X_BOOST_PRESET_OUT1, > + 0xF0, 0xB0); > + snd_soc_component_update_bits(component, > + WSA881X_BOOST_ZX_CTL, > + 0x20, 0x00); > + snd_soc_component_update_bits(component, > + WSA881X_BOOST_EN_CTL, > + 0x80, 0x80); > + } else { > + snd_soc_component_update_bits(component, > + WSA881X_BOOST_LOOP_STABILITY, > + 0x03, 0x03); > + snd_soc_component_update_bits(component, > + WSA881X_BOOST_MISC2_CTL, > + 0xFF, 0x14); > + snd_soc_component_update_bits(component, > + WSA881X_BOOST_START_CTL, > + 0x80, 0x80); > + snd_soc_component_update_bits(component, > + WSA881X_BOOST_START_CTL, > + 0x03, 0x00); > + snd_soc_component_update_bits(component, > + WSA881X_BOOST_SLOPE_COMP_ISENSE_FB, > + 0x0C, 0x04); > + snd_soc_component_update_bits(component, > + WSA881X_BOOST_SLOPE_COMP_ISENSE_FB, > + 0x03, 0x00); > + if (snd_soc_component_read(component, WSA881X_OTP_REG_0)) > + snd_soc_component_update_bits(component, > + WSA881X_BOOST_PRESET_OUT1, > + 0xF0, 0x70); > + else > + snd_soc_component_update_bits(component, > + WSA881X_BOOST_PRESET_OUT1, > + 0xF0, 0xB0); > + snd_soc_component_update_bits(component, > + WSA881X_ANA_CTL, 0x03, 0x01); > + snd_soc_component_update_bits(component, > + WSA881X_SPKR_DRV_EN, > + 0x08, 0x08); > + snd_soc_component_update_bits(component, > + WSA881X_ANA_CTL, 0x04, 0x04); > + snd_soc_component_update_bits(component, > + WSA881X_BOOST_CURRENT_LIMIT, > + 0x0F, 0x08); > + snd_soc_component_update_bits(component, > + WSA881X_BOOST_EN_CTL, > + 0x80, 0x80); > + } > + /* For WSA8810, start-up time is 1500us as per qcrg sequence */ > + usleep_range(1500, 1510); > + } else { > + /* ENSURE: Class-D amp is shutdown. CLK is still on */ > + snd_soc_component_update_bits(component, WSA881X_BOOST_EN_CTL, > + 0x80, 0x00); > + /* boost settle time is 1500us as per qcrg sequence */ > + usleep_range(1500, 1510); > + } > + return 0; > +} > + > +static void wsa881x_bandgap_ctrl(struct snd_soc_component *component, > + bool enable) > +{ > + if (enable) { > + snd_soc_component_update_bits(component, WSA881X_TEMP_OP, > + 0x08, 0x08); > + /* 400usec sleep is needed as per HW requirement */ > + usleep_range(400, 410); > + snd_soc_component_update_bits(component, WSA881X_TEMP_OP, > + 0x04, 0x04); > + } else { > + snd_soc_component_update_bits(component, WSA881X_TEMP_OP, > + 0x04, 0x00); > + snd_soc_component_update_bits(component, WSA881X_TEMP_OP, > + 0x08, 0x00); > + } > +} > + > +static void wsa881x_clk_ctrl(struct snd_soc_component *component, bool enable) > +{ > + struct wsa881x_priv *wsa881x = > + snd_soc_component_get_drvdata(component); > + > + if (enable) { > + snd_soc_component_write(component, > + WSA881X_CDC_RST_CTL, 0x02); > + snd_soc_component_write(component, > + WSA881X_CDC_RST_CTL, 0x03); > + snd_soc_component_write(component, > + WSA881X_CLOCK_CONFIG, 0x01); > + > + snd_soc_component_write(component, > + WSA881X_CDC_DIG_CLK_CTL, 0x01); > + snd_soc_component_write(component, > + WSA881X_CDC_ANA_CLK_CTL, 0x01); > + } else { > + snd_soc_component_write(component, > + WSA881X_CDC_ANA_CLK_CTL, 0x00); > + snd_soc_component_write(component, > + WSA881X_CDC_DIG_CLK_CTL, 0x00); > + if (WSA881X_IS_2_0(wsa881x->version)) > + snd_soc_component_update_bits(component, > + WSA881X_CDC_TOP_CLK_CTL, 0x01, 0x00); > + } > +} > + > +static int wsa881x_rdac_ctrl(struct snd_soc_component *component, bool enable) > +{ > + struct wsa881x_priv *wsa881x = > + snd_soc_component_get_drvdata(component); > + > + if (enable) { > + snd_soc_component_update_bits(component, > + WSA881X_ANA_CTL, 0x08, 0x00); > + snd_soc_component_update_bits(component, > + WSA881X_SPKR_DRV_GAIN, 0x08, 0x08); > + snd_soc_component_update_bits(component, > + WSA881X_SPKR_DAC_CTL, 0x20, 0x20); > + snd_soc_component_update_bits(component, > + WSA881X_SPKR_DAC_CTL, 0x20, 0x00); > + snd_soc_component_update_bits(component, > + WSA881X_SPKR_DAC_CTL, 0x40, 0x40); > + snd_soc_component_update_bits(component, > + WSA881X_SPKR_DAC_CTL, 0x80, 0x80); > + if (WSA881X_IS_2_0(wsa881x->version)) { > + snd_soc_component_update_bits(component, > + WSA881X_SPKR_BIAS_CAL, 0x01, 0x01); > + snd_soc_component_update_bits(component, > + WSA881X_SPKR_OCP_CTL, 0x30, 0x30); > + snd_soc_component_update_bits(component, > + WSA881X_SPKR_OCP_CTL, 0x0C, 0x00); > + } > + snd_soc_component_update_bits(component, > + WSA881X_SPKR_DRV_GAIN, 0xF0, 0x40); > + snd_soc_component_update_bits(component, > + WSA881X_SPKR_MISC_CTL1, 0x01, 0x01); > + } else { > + /* Ensure class-D amp is off */ > + snd_soc_component_update_bits(component, > + WSA881X_SPKR_DAC_CTL, 0x80, 0x00); > + } > + return 0; > +} > + > +static int wsa881x_spkr_pa_ctrl(struct snd_soc_component *component, > + bool enable) > +{ > + struct wsa881x_priv *wsa881x = > + snd_soc_component_get_drvdata(component); > + > + if (enable) { > + /* > + * Ensure: Boost is enabled and stable, Analog input is up > + * and outputting silence > + */ > + if (!WSA881X_IS_2_0(wsa881x->version)) { > + snd_soc_component_update_bits(component, > + WSA881X_ADC_EN_DET_TEST_I, > + 0xFF, 0x01); > + snd_soc_component_update_bits(component, > + WSA881X_ADC_EN_MODU_V, > + 0x02, 0x02); > + snd_soc_component_update_bits(component, > + WSA881X_ADC_EN_DET_TEST_V, > + 0xFF, 0x10); > + snd_soc_component_update_bits(component, > + WSA881X_SPKR_PWRSTG_DBG, > + 0xA0, 0xA0); > + snd_soc_component_update_bits(component, > + WSA881X_SPKR_DRV_EN, > + 0x80, 0x80); > + usleep_range(700, 710); > + snd_soc_component_update_bits(component, > + WSA881X_SPKR_PWRSTG_DBG, > + 0x00, 0x00); > + snd_soc_component_update_bits(component, > + WSA881X_ADC_EN_DET_TEST_V, > + 0xFF, 0x00); > + snd_soc_component_update_bits(component, > + WSA881X_ADC_EN_MODU_V, > + 0x02, 0x00); > + snd_soc_component_update_bits(component, > + WSA881X_ADC_EN_DET_TEST_I, > + 0xFF, 0x00); > + } else > + snd_soc_component_update_bits(component, > + WSA881X_SPKR_DRV_EN, 0x80, 0x80); > + /* add 1000us delay as per qcrg */ > + usleep_range(1000, 1010); > + snd_soc_component_update_bits(component, > + WSA881X_SPKR_DRV_EN, 0x01, 0x01); > + if (WSA881X_IS_2_0(wsa881x->version)) > + snd_soc_component_update_bits(component, > + WSA881X_SPKR_BIAS_CAL, > + 0x01, 0x00); > + usleep_range(1000, 1010); > + snd_soc_component_update_bits(component, > + WSA881X_SPKR_DRV_GAIN, > + 0xF0, (wsa881x->spk_pa_gain << 4)); > + } else { > + /* > + * Ensure: Boost is still on, Stream from Analog input and > + * Speaker Protection has been stopped and input is at 0V > + */ > + if (WSA881X_IS_2_0(wsa881x->version)) { > + snd_soc_component_update_bits(component, > + WSA881X_SPKR_BIAS_CAL, > + 0x01, 0x01); > + usleep_range(1000, 1010); > + snd_soc_component_update_bits(component, > + WSA881X_SPKR_BIAS_CAL, > + 0x01, 0x00); > + msleep(20); > + snd_soc_component_update_bits(component, > + WSA881X_ANA_CTL, 0x03, 0x00); > + usleep_range(200, 210); > + } > + snd_soc_component_update_bits(component, > + WSA881X_SPKR_DRV_EN, 0x80, 0x00); > + } > + return 0; > +} > + > +static int wsa881x_get_boost(struct snd_kcontrol *kcontrol, > + struct snd_ctl_elem_value *ucontrol) > +{ > + > + struct snd_soc_component *component = > + snd_soc_kcontrol_component(kcontrol); > + struct wsa881x_priv *wsa881x = > + snd_soc_component_get_drvdata(component); > + > + ucontrol->value.integer.value[0] = wsa881x->boost_enable; > + return 0; > +} > + > +static int wsa881x_set_boost(struct snd_kcontrol *kcontrol, > + struct snd_ctl_elem_value *ucontrol) > +{ > + struct snd_soc_component *component = > + snd_soc_kcontrol_component(kcontrol); > + struct wsa881x_priv *wsa881x = > + snd_soc_component_get_drvdata(component); > + int value = ucontrol->value.integer.value[0]; > + > + wsa881x->boost_enable = value; > + return 0; > +} > + > +static const struct snd_kcontrol_new wsa881x_snd_controls[] = { > + SOC_SINGLE_EXT("BOOST Switch", SND_SOC_NOPM, 0, 1, 0, > + wsa881x_get_boost, wsa881x_set_boost), > + > + SOC_ENUM_EXT("WSA_SPK PA Gain", wsa881x_spk_pa_gain_enum[0], > + wsa881x_spk_pa_gain_get, wsa881x_spk_pa_gain_put), > +}; > + > +static const char * const rdac_text[] = { > + "ZERO", "Switch", > +}; > + > +static const struct soc_enum rdac_enum = > + SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(rdac_text), rdac_text); > + > +static const struct snd_kcontrol_new rdac_mux[] = { > + SOC_DAPM_ENUM("RDAC", rdac_enum) > +}; > + > +static int wsa881x_rdac_event(struct snd_soc_dapm_widget *w, > + struct snd_kcontrol *kcontrol, int event) > +{ > + struct snd_soc_component *component = > + snd_soc_dapm_to_component(w->dapm); > + struct wsa881x_priv *wsa881x = > + snd_soc_component_get_drvdata(component); > + > + switch (event) { > + case SND_SOC_DAPM_PRE_PMU: > + wsa881x_clk_ctrl(component, true); > + snd_soc_component_update_bits(component, WSA881X_SPKR_DAC_CTL, > + 0x02, 0x02); > + if (!WSA881X_IS_2_0(wsa881x->version)) > + snd_soc_component_update_bits(component, > + WSA881X_BIAS_REF_CTRL, > + 0x0F, 0x08); > + wsa881x_bandgap_ctrl(component, true); > + if (!WSA881X_IS_2_0(wsa881x->version)) > + snd_soc_component_update_bits(component, > + WSA881X_SPKR_BBM_CTL, > + 0x02, 0x02); > + snd_soc_component_update_bits(component, WSA881X_SPKR_MISC_CTL1, > + 0xC0, 0x80); > + snd_soc_component_update_bits(component, WSA881X_SPKR_MISC_CTL1, > + 0x06, 0x06); > + if (!WSA881X_IS_2_0(wsa881x->version)) { > + snd_soc_component_update_bits(component, > + WSA881X_SPKR_MISC_CTL2, > + 0x04, 0x04); > + snd_soc_component_update_bits(component, > + WSA881X_SPKR_BIAS_INT, > + 0x09, 0x09); > + } > + snd_soc_component_update_bits(component, WSA881X_SPKR_PA_INT, > + 0xF0, 0x20); > + if (WSA881X_IS_2_0(wsa881x->version)) > + snd_soc_component_update_bits(component, > + WSA881X_SPKR_PA_INT, > + 0x0E, 0x0E); > + if (wsa881x->boost_enable) > + wsa881x_boost_ctrl(component, true); > + break; > + case SND_SOC_DAPM_POST_PMU: > + wsa881x_rdac_ctrl(component, true); > + break; > + case SND_SOC_DAPM_PRE_PMD: > + wsa881x_rdac_ctrl(component, false); > + break; > + case SND_SOC_DAPM_POST_PMD: > + if (wsa881x->boost_enable) > + wsa881x_boost_ctrl(component, false); > + wsa881x_clk_ctrl(component, false); > + wsa881x_bandgap_ctrl(component, false); > + > + break; > + default: > + dev_err(component->dev, "invalid event:%d\n", event); > + return -EINVAL; > + } > + return 0; > +} > + > +static int wsa881x_spkr_pa_event(struct snd_soc_dapm_widget *w, > + struct snd_kcontrol *kcontrol, int event) > +{ > + struct snd_soc_component *component = > + snd_soc_dapm_to_component(w->dapm); > + > + switch (event) { > + case SND_SOC_DAPM_PRE_PMU: > + snd_soc_component_update_bits(component, WSA881X_SPKR_OCP_CTL, > + 0xC0, 0x80); > + break; > + case SND_SOC_DAPM_POST_PMU: > + wsa881x_spkr_pa_ctrl(component, true); > + break; > + case SND_SOC_DAPM_PRE_PMD: > + wsa881x_spkr_pa_ctrl(component, false); > + break; > + case SND_SOC_DAPM_POST_PMD: > + snd_soc_component_update_bits(component, WSA881X_SPKR_OCP_CTL, > + 0xC0, 0xC0); > + break; > + default: > + dev_err(component->dev, "invalid event:%d\n", event); > + return -EINVAL; > + } > + return 0; > +} > + > +static const struct snd_soc_dapm_widget wsa881x_dapm_widgets[] = { > + SND_SOC_DAPM_INPUT("WSA_IN"), > + > + SND_SOC_DAPM_DAC_E("RDAC Analog", NULL, SND_SOC_NOPM, 0, 0, > + wsa881x_rdac_event, > + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | > + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), > + > + SND_SOC_DAPM_MUX("WSA_RDAC", SND_SOC_NOPM, 0, 0, > + rdac_mux), > + > + SND_SOC_DAPM_PGA_S("WSA_SPKR PGA", 1, SND_SOC_NOPM, 0, 0, > + wsa881x_spkr_pa_event, > + SND_SOC_DAPM_PRE_PMU | > + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD | > + SND_SOC_DAPM_POST_PMD), > + > + SND_SOC_DAPM_OUTPUT("WSA_SPKR"), > +}; > + > +static const struct snd_soc_dapm_route wsa881x_audio_map[] = { > + {"WSA_RDAC", "Switch", "WSA_IN"}, > + {"RDAC Analog", NULL, "WSA_RDAC"}, > + {"WSA_SPKR PGA", NULL, "RDAC Analog"}, > + {"WSA_SPKR", NULL, "WSA_SPKR PGA"}, > +}; > + > +static int wsa881x_probe(struct snd_soc_component *component) > +{ > + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component); > + > + wsa881x->component = component; > + wsa881x->spk_pa_gain = SPK_GAIN_12DB; > + > + return 0; > +} > + > +static const struct snd_soc_dai_ops wsa881x_dai_ops = { > + .set_stream = wsa881x_set_stream, > + .mute_stream = wsa881x_digital_mute, > + .mute_unmute_on_trigger = false, > +}; > + > +static const struct snd_soc_component_driver soc_codec_dev_wsa881x = { > + .probe = wsa881x_probe, > + .read = wsa881x_i2c_read, > + .write = wsa881x_i2c_write, > + .controls = wsa881x_snd_controls, > + .num_controls = ARRAY_SIZE(wsa881x_snd_controls), > + .dapm_widgets = wsa881x_dapm_widgets, > + .num_dapm_widgets = ARRAY_SIZE(wsa881x_dapm_widgets), > + .dapm_routes = wsa881x_audio_map, > + .num_dapm_routes = ARRAY_SIZE(wsa881x_audio_map), > +}; > + > +static const struct snd_soc_dai_driver wsa_dai[] = { > + { > + .name = "wsa_rx0", > + .id = 0, > + .playback = { > + .stream_name = "", > + .rates = WSA881X_RATES | WSA881X_FRAC_RATES, > + .formats = WSA881X_FORMATS, > + .rate_max = 384000, > + .rate_min = 8000, > + .channels_min = 1, > + .channels_max = 1, > + }, > + .ops = &wsa881x_dai_ops, > + }, > +}; > + > +static int check_wsa881x_presence(struct wsa881x_priv *wsa881x) > +{ > + struct i2c_client *client = wsa881x->client[DIGITAL]; > + int ret; > + > + ret = wsa881x_i2c_read_device(wsa881x, WSA881X_CDC_RST_CTL); > + if (ret < 0) { > + dev_err(&client->dev, "failed to read from addr=%x\n", > + client->addr); > + return ret; > + } > + > + ret = wsa881x_i2c_write_device(wsa881x, WSA881X_CDC_RST_CTL, 0x01); > + if (ret < 0) { > + dev_err(&client->dev, "failed write addr=%x reg:0x5 val:0x1\n", > + client->addr); > + return ret; > + } > + > + /* allow 20ms before trigger next write to verify wsa881x presence */ > + msleep(20); > + ret = wsa881x_i2c_write_device(wsa881x, WSA881X_CDC_RST_CTL, 0x00); > + if (ret < 0) { > + dev_err(&client->dev, "failed write addr=%x reg:0x5 val:0x0\n", > + client->addr); > + return ret; > + } > + return ret; > +} > + > +static int wsa881x_i2c_probe(struct i2c_client *client) > +{ > + struct device *dev = &client->dev; > + struct wsa881x_priv *wsa881x; > + int leftright; > + int ret; > + > + ret = wsa881x_probe_common(&wsa881x, dev); > + if (ret) > + return ret; > + > + wsa881x->mclk_pin = devm_gpiod_get(dev, "mclk", > + GPIOD_FLAGS_BIT_NONEXCLUSIVE); > + if (IS_ERR(wsa881x->mclk_pin)) > + dev_err_probe(dev, PTR_ERR(wsa881x->mclk_pin), > + "MCLK GPIO not found\n"); > + > + wsa881x->wsa_mclk = devm_clk_get_enabled(&client->dev, NULL); > + if (IS_ERR(wsa881x->wsa_mclk)) > + return dev_err_probe(dev, PTR_ERR(wsa881x->wsa_mclk), > + "failed to get mclk\n"); > + gpiod_direction_output(wsa881x->mclk_pin, 1); > + clk_set_rate(wsa881x->wsa_mclk, 9600000); > + > + wsa881x->client[DIGITAL] = client; > + ret = check_wsa881x_presence(wsa881x); > + if (ret < 0) { > + dev_err(&client->dev, > + "failed to ping wsa with addr:%x, ret = %d\n", > + client->addr, ret); > + return -ENODEV; > + } > + > + wsa881x->regmap = devm_regmap_init_i2c(client, > + &wsa881x_ana_regmap_config[DIGITAL]); > + if (IS_ERR(wsa881x->regmap)) { > + dev_err(dev, "digital regmap init failed %d\n", ret); > + return PTR_ERR(wsa881x->regmap); > + } > + regcache_cache_bypass(wsa881x->regmap, true); > + > + wsa881x_init_common(wsa881x); > + > + wsa881x->version = wsa881x_i2c_read_device(wsa881x, WSA881X_CHIP_ID1); > + if (wsa881x->version == WSA881X_2_0) { > + wsa881x_update_reg_defaults_2_0(); > + wsa881x_update_regmap_2_0(wsa881x->regmap, DIGITAL); > + } > + > + /* > + * If we reached this point, then device is present and we're good to > + * go to initialise analog part of the amplifier > + */ > + wsa881x->client[ANALOG] = devm_i2c_new_dummy_device(&client->dev, > + client->adapter, > + client->addr + I2C_ANALOG_OFFSET); > + if (IS_ERR(wsa881x->client[ANALOG])) { > + dev_err(dev, > + "failed to register i2c device for analog part\n"); > + return PTR_ERR(wsa881x->client[ANALOG]); > + } > + > + wsa881x->regmap_analog = devm_regmap_init_i2c(wsa881x->client[ANALOG], > + &wsa881x_ana_regmap_config[ANALOG]); > + if (IS_ERR(wsa881x->regmap_analog)) { > + dev_err(dev, "analog regmap init failed %d\n", ret); > + return PTR_ERR(wsa881x->regmap_analog); > + } > + regcache_cache_bypass(wsa881x->regmap_analog, true); > + > + wsa881x->client[ANALOG]->dev.platform_data = wsa881x; > + i2c_set_clientdata(wsa881x->client[ANALOG], wsa881x); > + wsa881x->regmap_flag = true; > + > + if (wsa881x->version == WSA881X_2_0) > + wsa881x_update_regmap_2_0(wsa881x->regmap_analog, ANALOG); > + /* finished initialising analog part */ > + > + leftright = wsa881x_i2c_read_device(wsa881x, WSA881X_BUS_ID) & 0x1; > + > + wsa881x->driver = devm_kmemdup(dev, &soc_codec_dev_wsa881x, > + sizeof(*wsa881x->driver), GFP_KERNEL); > + if (!wsa881x->driver) > + return -ENOMEM; > + > + wsa881x->dai_driver = devm_kmemdup(dev, wsa_dai, > + sizeof(struct snd_soc_dai_driver), > + GFP_KERNEL); > + if (!wsa881x->dai_driver) > + return -ENOMEM; > + > + wsa881x->driver->name = devm_kasprintf(dev, GFP_KERNEL, "wsa-codec%d", > + leftright); > + if (!wsa881x->driver->name) > + return -ENOMEM; > + > + wsa881x->dai_driver->name = devm_kasprintf(dev, GFP_KERNEL, > + "wsa_rx%d", leftright); > + if (!wsa881x->dai_driver->name) > + return -ENOMEM; > + > + wsa881x->dai_driver->playback.stream_name = devm_kasprintf(dev, > + GFP_KERNEL, "WSA881X_AIF%d Playback", > + leftright); > + if (!wsa881x->dai_driver->playback.stream_name) > + return -ENOMEM; > + > + pm_runtime_set_autosuspend_delay(dev, 3000); > + pm_runtime_use_autosuspend(dev); > + pm_runtime_mark_last_busy(dev); > + pm_runtime_set_active(dev); > + pm_runtime_enable(dev); > + > + return devm_snd_soc_register_component(dev, > + wsa881x->driver, > + wsa881x->dai_driver, > + ARRAY_SIZE(wsa_dai)); > +} > + > +static int __maybe_unused wsa881x_i2c_suspend(struct device *dev) > +{ > + struct wsa881x_priv *wsa881x = dev_get_drvdata(dev); > + > + clk_disable_unprepare(wsa881x->wsa_mclk); > + > + gpiod_direction_output(wsa881x->sd_n, wsa881x->sd_n_val); > + > + return 0; > +} > + > +static int __maybe_unused wsa881x_i2c_resume(struct device *dev) > +{ > + struct wsa881x_priv *wsa881x = dev_get_drvdata(dev); > + int ret; > + > + gpiod_direction_output(wsa881x->sd_n, !wsa881x->sd_n_val); > + > + gpiod_direction_output(wsa881x->mclk_pin, 1); > + ret = clk_prepare_enable(wsa881x->wsa_mclk); > + if (ret) { > + dev_err(wsa881x->dev, "mclk enable failed\n"); > + return ret; > + } > + > + wsa881x_init_common(wsa881x); > + > + return 0; > +} > + > +static const struct dev_pm_ops wsa881x_i2c_pm_ops = { > + SET_RUNTIME_PM_OPS(wsa881x_i2c_suspend, wsa881x_i2c_resume, NULL) > + SET_SYSTEM_SLEEP_PM_OPS(wsa881x_i2c_suspend, wsa881x_i2c_resume) > +}; > + > +static const struct i2c_device_id wsa881x_i2c_id[] = { > + {"qcom,wsa8810"}, > + {"qcom,wsa8815"}, > + {} > +}; > + > +MODULE_DEVICE_TABLE(i2c, wsa881x_i2c_id); > + > +static const struct of_device_id wsa881x_i2c_driver_table[] = { > + {.compatible = "qcom,wsa8810"}, > + {.compatible = "qcom,wsa8815"}, > + {} > +}; > +MODULE_DEVICE_TABLE(of, wsa881x_i2c_driver_table); > + > +static struct i2c_driver wsa881x_i2c_driver = { > + .driver = { > + .name = "wsa881x-i2c-codec", > + .pm = &wsa881x_i2c_pm_ops, > + .of_match_table = wsa881x_i2c_driver_table, > + }, > + .id_table = wsa881x_i2c_id, > + .probe = wsa881x_i2c_probe, > +}; > + > +module_i2c_driver(wsa881x_i2c_driver); > +MODULE_DESCRIPTION("WSA881x Codec driver for Analog mode"); > +MODULE_LICENSE("GPL"); > ^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v3 07/12] arm64: dts: qcom: sm6115: add LPASS devices 2025-05-22 17:40 [PATCH v3 00/12] qrb4210-rb2: add wsa audio playback and capture support Alexey Klimov ` (5 preceding siblings ...) 2025-05-22 17:40 ` [PATCH v3 06/12] ASoC: codecs: add wsa881x-i2c amplifier codec driver Alexey Klimov @ 2025-05-22 17:40 ` Alexey Klimov 2025-05-22 17:52 ` Krzysztof Kozlowski 2025-05-22 17:40 ` [PATCH v3 08/12] arm64: dts: qcom: sm4250: add description of soundwire and dmic pins Alexey Klimov ` (5 subsequent siblings) 12 siblings, 1 reply; 43+ messages in thread From: Alexey Klimov @ 2025-05-22 17:40 UTC (permalink / raw) To: Srinivas Kandagatla, Mark Brown, linux-sound Cc: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio, Konrad Dybcio The rxmacro, txmacro, vamacro, soundwire nodes, lpass clock controllers are required to support audio playback and audio capture on sm6115 and its derivatives. Cc: Konrad Dybcio <konradybcio@kernel.org> Cc: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> Cc: Srinivas Kandagatla <srini@kernel.org> Co-developed-by: Konrad Dybcio <konrad.dybcio@linaro.org> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> --- arch/arm64/boot/dts/qcom/sm6115.dtsi | 132 +++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/sm6115.dtsi b/arch/arm64/boot/dts/qcom/sm6115.dtsi index c8865779173eca65f9e94535b5339f590d4b1410..045887ae215b0965ffc098fd31fd18ac1ad90b7b 100644 --- a/arch/arm64/boot/dts/qcom/sm6115.dtsi +++ b/arch/arm64/boot/dts/qcom/sm6115.dtsi @@ -2689,6 +2689,138 @@ funnel_apss1_in: endpoint { }; }; + rxmacro: codec@a600000 { + compatible = "qcom,sm6115-lpass-rx-macro"; + reg = <0x0 0xa600000 0x0 0x1000>; + + clocks = <&q6afecc LPASS_CLK_ID_RX_CORE_MCLK LPASS_CLK_ATTRIBUTE_COUPLE_NO>, + <&q6afecc LPASS_CLK_ID_RX_CORE_NPL_MCLK LPASS_CLK_ATTRIBUTE_COUPLE_NO>, + <&q6afecc LPASS_HW_DCODEC_VOTE LPASS_CLK_ATTRIBUTE_COUPLE_NO>, + <&vamacro>; + clock-names = "mclk", + "npl", + "dcodec", + "fsgen"; + assigned-clocks = <&q6afecc LPASS_CLK_ID_RX_CORE_MCLK LPASS_CLK_ATTRIBUTE_COUPLE_NO>, + <&q6afecc LPASS_CLK_ID_RX_CORE_NPL_MCLK LPASS_CLK_ATTRIBUTE_COUPLE_NO>; + assigned-clock-rates = <22579200>, + <22579200>; + #clock-cells = <0>; + clock-output-names = "mclk"; + #sound-dai-cells = <1>; + }; + + swr1: soundwire@a610000 { + compatible = "qcom,soundwire-v1.6.0"; + reg = <0x0 0x0a610000 0x0 0x2000>; + interrupts = <GIC_SPI 297 IRQ_TYPE_LEVEL_HIGH>; + + clocks = <&rxmacro>; + clock-names = "iface"; + + resets = <&lpass_audiocc 0>; + reset-names = "swr_audio_cgcr"; + + label = "RX"; + qcom,din-ports = <0>; + qcom,dout-ports = <5>; + + qcom,ports-sinterval-low = /bits/ 8 <0x03 0x1f 0x1f 0x07 0x00>; + qcom,ports-offset1 = /bits/ 8 <0x00 0x00 0x0b 0x01 0x00>; + qcom,ports-offset2 = /bits/ 8 <0x00 0x00 0x0b 0x00 0x00>; + qcom,ports-hstart = /bits/ 8 <0xff 0x03 0xff 0xff 0xff>; + qcom,ports-hstop = /bits/ 8 <0xff 0x06 0xff 0xff 0xff>; + qcom,ports-word-length = /bits/ 8 <0x01 0x07 0x04 0xff 0xff>; + qcom,ports-block-pack-mode = /bits/ 8 <0xff 0x00 0x01 0xff 0xff>; + qcom,ports-block-group-count = /bits/ 8 <0xff 0xff 0xff 0xff 0x00>; + qcom,ports-lane-control = /bits/ 8 <0x01 0x00 0x00 0x00 0x00>; + + #sound-dai-cells = <1>; + #address-cells = <2>; + #size-cells = <0>; + }; + + txmacro: codec@a620000 { + compatible = "qcom,sm6115-lpass-tx-macro"; + reg = <0x0 0x0a620000 0x0 0x1000>; + + clocks = <&q6afecc LPASS_CLK_ID_TX_CORE_MCLK LPASS_CLK_ATTRIBUTE_COUPLE_NO>, + <&q6afecc LPASS_CLK_ID_TX_CORE_NPL_MCLK LPASS_CLK_ATTRIBUTE_COUPLE_NO>, + <&q6afecc LPASS_HW_DCODEC_VOTE LPASS_CLK_ATTRIBUTE_COUPLE_NO>, + <&vamacro>; + clock-names = "mclk", + "npl", + "dcodec", + "fsgen"; + assigned-clocks = <&q6afecc LPASS_CLK_ID_TX_CORE_MCLK LPASS_CLK_ATTRIBUTE_COUPLE_NO>, + <&q6afecc LPASS_CLK_ID_TX_CORE_NPL_MCLK LPASS_CLK_ATTRIBUTE_COUPLE_NO>; + assigned-clock-rates = <19200000>, + <19200000>; + #clock-cells = <0>; + clock-output-names = "mclk"; + #sound-dai-cells = <1>; + }; + + lpass_audiocc: clock-controller@a6a9000 { + compatible = "qcom,sm6115-lpassaudiocc"; + reg = <0x0 0x0a6a9000 0x0 0x1000>; + #reset-cells = <1>; + }; + + vamacro: codec@a730000 { + compatible = "qcom,sm6115-lpass-va-macro", "qcom,sm8450-lpass-va-macro"; + reg = <0x0 0x0a730000 0x0 0x1000>; + clocks = <&q6afecc LPASS_CLK_ID_TX_CORE_MCLK LPASS_CLK_ATTRIBUTE_COUPLE_NO>, + <&q6afecc LPASS_HW_DCODEC_VOTE LPASS_CLK_ATTRIBUTE_COUPLE_NO>, + <&q6afecc LPASS_CLK_ID_TX_CORE_NPL_MCLK LPASS_CLK_ATTRIBUTE_COUPLE_NO>; + clock-names = "mclk", + "dcodec", + "npl"; + assigned-clocks = <&q6afecc LPASS_CLK_ID_TX_CORE_MCLK LPASS_CLK_ATTRIBUTE_COUPLE_NO>, + <&q6afecc LPASS_CLK_ID_TX_CORE_NPL_MCLK LPASS_CLK_ATTRIBUTE_COUPLE_NO>; + assigned-clock-rates = <19200000>, + <19200000>; + #clock-cells = <0>; + clock-output-names = "fsgen"; + #sound-dai-cells = <1>; + }; + + swr0: soundwire@a740000 { + compatible = "qcom,soundwire-v1.6.0"; + reg = <0x0 0x0a740000 0x0 0x2000>; + interrupts = <GIC_SPI 296 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 79 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&txmacro>; + clock-names = "iface"; + + resets = <&lpasscc 0>; + reset-names = "swr_audio_cgcr"; + + label = "VA_TX"; + qcom,din-ports = <3>; + qcom,dout-ports = <0>; + + qcom,ports-sinterval-low = /bits/ 8 <0x03 0x03 0x03>; + qcom,ports-offset1 = /bits/ 8 <0x01 0x02 0x01>; + qcom,ports-offset2 = /bits/ 8 <0x00 0x00 0x00>; + qcom,ports-hstart = /bits/ 8 <0xff 0xff 0xff>; + qcom,ports-hstop = /bits/ 8 <0xff 0xff 0xff>; + qcom,ports-word-length = /bits/ 8 <0xff 0xff 0xff>; + qcom,ports-block-pack-mode = /bits/ 8 <0xff 0xff 0xff>; + qcom,ports-block-group-count = /bits/ 8 <0xff 0xff 0xff>; + qcom,ports-lane-control = /bits/ 8 <0x00 0x00 0x00>; + + #sound-dai-cells = <1>; + #address-cells = <2>; + #size-cells = <0>; + }; + + lpasscc: clock-controller@a7ec000 { + compatible = "qcom,sm6115-lpasscc"; + reg = <0x0 0x0a7ec000 0x0 0x1000>; + #reset-cells = <1>; + }; + remoteproc_adsp: remoteproc@a400000 { compatible = "qcom,sm6115-adsp-pas"; reg = <0x0 0x0a400000 0x0 0x4040>; -- 2.47.2 ^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH v3 07/12] arm64: dts: qcom: sm6115: add LPASS devices 2025-05-22 17:40 ` [PATCH v3 07/12] arm64: dts: qcom: sm6115: add LPASS devices Alexey Klimov @ 2025-05-22 17:52 ` Krzysztof Kozlowski 2025-05-27 16:32 ` Alexey Klimov 0 siblings, 1 reply; 43+ messages in thread From: Krzysztof Kozlowski @ 2025-05-22 17:52 UTC (permalink / raw) To: Alexey Klimov, Srinivas Kandagatla, Mark Brown, linux-sound Cc: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio On 22/05/2025 19:40, Alexey Klimov wrote: > The rxmacro, txmacro, vamacro, soundwire nodes, lpass clock controllers > are required to support audio playback and audio capture on sm6115 and > its derivatives. > > Cc: Konrad Dybcio <konradybcio@kernel.org> > Cc: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> Just keep one CC. > Cc: Srinivas Kandagatla <srini@kernel.org> > Co-developed-by: Konrad Dybcio <konrad.dybcio@linaro.org> Missing SoB. > Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> > --- > arch/arm64/boot/dts/qcom/sm6115.dtsi | 132 +++++++++++++++++++++++++++++++++++ > 1 file changed, 132 insertions(+) > > diff --git a/arch/arm64/boot/dts/qcom/sm6115.dtsi b/arch/arm64/boot/dts/qcom/sm6115.dtsi > index c8865779173eca65f9e94535b5339f590d4b1410..045887ae215b0965ffc098fd31fd18ac1ad90b7b 100644 > --- a/arch/arm64/boot/dts/qcom/sm6115.dtsi > +++ b/arch/arm64/boot/dts/qcom/sm6115.dtsi > @@ -2689,6 +2689,138 @@ funnel_apss1_in: endpoint { > }; > }; ... > + swr0: soundwire@a740000 { > + compatible = "qcom,soundwire-v1.6.0"; > + reg = <0x0 0x0a740000 0x0 0x2000>; > + interrupts = <GIC_SPI 296 IRQ_TYPE_LEVEL_HIGH>, > + <GIC_SPI 79 IRQ_TYPE_LEVEL_HIGH>; > + clocks = <&txmacro>; > + clock-names = "iface"; > + > + resets = <&lpasscc 0>; > + reset-names = "swr_audio_cgcr"; > + > + label = "VA_TX"; > + qcom,din-ports = <3>; > + qcom,dout-ports = <0>; > + > + qcom,ports-sinterval-low = /bits/ 8 <0x03 0x03 0x03>; > + qcom,ports-offset1 = /bits/ 8 <0x01 0x02 0x01>; > + qcom,ports-offset2 = /bits/ 8 <0x00 0x00 0x00>; > + qcom,ports-hstart = /bits/ 8 <0xff 0xff 0xff>; > + qcom,ports-hstop = /bits/ 8 <0xff 0xff 0xff>; > + qcom,ports-word-length = /bits/ 8 <0xff 0xff 0xff>; > + qcom,ports-block-pack-mode = /bits/ 8 <0xff 0xff 0xff>; > + qcom,ports-block-group-count = /bits/ 8 <0xff 0xff 0xff>; > + qcom,ports-lane-control = /bits/ 8 <0x00 0x00 0x00>; > + > + #sound-dai-cells = <1>; > + #address-cells = <2>; > + #size-cells = <0>; Why this not is not disabled? That's a bus. Each bus node makes no sense on its own without the actual devices, thus it is always disabled in the SoC file. Just take a look at other DTSI. > + }; > + > + lpasscc: clock-controller@a7ec000 { > + compatible = "qcom,sm6115-lpasscc"; > + reg = <0x0 0x0a7ec000 0x0 0x1000>; > + #reset-cells = <1>; > + }; > + > remoteproc_adsp: remoteproc@a400000 { Looks like not ordered by unit address. > compatible = "qcom,sm6115-adsp-pas"; > reg = <0x0 0x0a400000 0x0 0x4040>; > Best regards, Krzysztof ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v3 07/12] arm64: dts: qcom: sm6115: add LPASS devices 2025-05-22 17:52 ` Krzysztof Kozlowski @ 2025-05-27 16:32 ` Alexey Klimov 2025-05-27 17:03 ` Konrad Dybcio 2025-05-27 18:33 ` Krzysztof Kozlowski 0 siblings, 2 replies; 43+ messages in thread From: Alexey Klimov @ 2025-05-27 16:32 UTC (permalink / raw) To: Krzysztof Kozlowski, Konrad Dybcio, Konrad Dybcio Cc: Srinivas Kandagatla, Mark Brown, linux-sound, Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio On Thu May 22, 2025 at 6:52 PM BST, Krzysztof Kozlowski wrote: > On 22/05/2025 19:40, Alexey Klimov wrote: >> The rxmacro, txmacro, vamacro, soundwire nodes, lpass clock controllers >> are required to support audio playback and audio capture on sm6115 and >> its derivatives. >> >> Cc: Konrad Dybcio <konradybcio@kernel.org> >> Cc: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> > > Just keep one CC. Question is which one now. Konrad, is it fine to keep your oss.qualcomm.com email here? >> Cc: Srinivas Kandagatla <srini@kernel.org> >> Co-developed-by: Konrad Dybcio <konrad.dybcio@linaro.org> > > Missing SoB. IIRC I took Konrad's changes but at this point I don't remember how much was changed. So I need to switch to Konrad's owned completely or somehow indicate using tags that it is initial Konrad's work. Konrad, what's your preference here? >> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> >> --- >> arch/arm64/boot/dts/qcom/sm6115.dtsi | 132 +++++++++++++++++++++++++++++++++++ >> 1 file changed, 132 insertions(+) >> >> diff --git a/arch/arm64/boot/dts/qcom/sm6115.dtsi b/arch/arm64/boot/dts/qcom/sm6115.dtsi >> index c8865779173eca65f9e94535b5339f590d4b1410..045887ae215b0965ffc098fd31fd18ac1ad90b7b 100644 >> --- a/arch/arm64/boot/dts/qcom/sm6115.dtsi >> +++ b/arch/arm64/boot/dts/qcom/sm6115.dtsi >> @@ -2689,6 +2689,138 @@ funnel_apss1_in: endpoint { >> }; >> }; > > > > ... > >> + swr0: soundwire@a740000 { >> + compatible = "qcom,soundwire-v1.6.0"; >> + reg = <0x0 0x0a740000 0x0 0x2000>; >> + interrupts = <GIC_SPI 296 IRQ_TYPE_LEVEL_HIGH>, >> + <GIC_SPI 79 IRQ_TYPE_LEVEL_HIGH>; >> + clocks = <&txmacro>; >> + clock-names = "iface"; >> + >> + resets = <&lpasscc 0>; >> + reset-names = "swr_audio_cgcr"; >> + >> + label = "VA_TX"; >> + qcom,din-ports = <3>; >> + qcom,dout-ports = <0>; >> + >> + qcom,ports-sinterval-low = /bits/ 8 <0x03 0x03 0x03>; >> + qcom,ports-offset1 = /bits/ 8 <0x01 0x02 0x01>; >> + qcom,ports-offset2 = /bits/ 8 <0x00 0x00 0x00>; >> + qcom,ports-hstart = /bits/ 8 <0xff 0xff 0xff>; >> + qcom,ports-hstop = /bits/ 8 <0xff 0xff 0xff>; >> + qcom,ports-word-length = /bits/ 8 <0xff 0xff 0xff>; >> + qcom,ports-block-pack-mode = /bits/ 8 <0xff 0xff 0xff>; >> + qcom,ports-block-group-count = /bits/ 8 <0xff 0xff 0xff>; >> + qcom,ports-lane-control = /bits/ 8 <0x00 0x00 0x00>; >> + >> + #sound-dai-cells = <1>; >> + #address-cells = <2>; >> + #size-cells = <0>; > > Why this not is not disabled? That's a bus. Each bus node makes no sense > on its own without the actual devices, thus it is always disabled in the > SoC file. Just take a look at other DTSI. Because I didn't know that. Ok, I'll add disable status to these. >> + }; >> + >> + lpasscc: clock-controller@a7ec000 { >> + compatible = "qcom,sm6115-lpasscc"; >> + reg = <0x0 0x0a7ec000 0x0 0x1000>; >> + #reset-cells = <1>; >> + }; >> + >> remoteproc_adsp: remoteproc@a400000 { > > Looks like not ordered by unit address. Ok, I need to sort it then and check other parts to see if they are sorted or not. ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v3 07/12] arm64: dts: qcom: sm6115: add LPASS devices 2025-05-27 16:32 ` Alexey Klimov @ 2025-05-27 17:03 ` Konrad Dybcio 2025-05-27 18:33 ` Krzysztof Kozlowski 1 sibling, 0 replies; 43+ messages in thread From: Konrad Dybcio @ 2025-05-27 17:03 UTC (permalink / raw) To: Alexey Klimov, Krzysztof Kozlowski, Konrad Dybcio, Konrad Dybcio Cc: Srinivas Kandagatla, Mark Brown, linux-sound, Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio On 5/27/25 6:32 PM, Alexey Klimov wrote: > On Thu May 22, 2025 at 6:52 PM BST, Krzysztof Kozlowski wrote: >> On 22/05/2025 19:40, Alexey Klimov wrote: >>> The rxmacro, txmacro, vamacro, soundwire nodes, lpass clock controllers >>> are required to support audio playback and audio capture on sm6115 and >>> its derivatives. >>> >>> Cc: Konrad Dybcio <konradybcio@kernel.org> >>> Cc: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> >> >> Just keep one CC. > > Question is which one now. Konrad, is it fine to keep your oss.qualcomm.com > email here? > >>> Cc: Srinivas Kandagatla <srini@kernel.org> >>> Co-developed-by: Konrad Dybcio <konrad.dybcio@linaro.org> >> >> Missing SoB. > > IIRC I took Konrad's changes but at this point I don't remember how much was changed. > So I need to switch to Konrad's owned completely or somehow indicate using tags > that it is initial Konrad's work. > > Konrad, what's your preference here? just loosely mention it in the commit message Konrad ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v3 07/12] arm64: dts: qcom: sm6115: add LPASS devices 2025-05-27 16:32 ` Alexey Klimov 2025-05-27 17:03 ` Konrad Dybcio @ 2025-05-27 18:33 ` Krzysztof Kozlowski 2025-05-27 20:36 ` Alexey Klimov 1 sibling, 1 reply; 43+ messages in thread From: Krzysztof Kozlowski @ 2025-05-27 18:33 UTC (permalink / raw) To: Alexey Klimov, Konrad Dybcio, Konrad Dybcio Cc: Srinivas Kandagatla, Mark Brown, linux-sound, Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio On 27/05/2025 18:32, Alexey Klimov wrote: > On Thu May 22, 2025 at 6:52 PM BST, Krzysztof Kozlowski wrote: >> On 22/05/2025 19:40, Alexey Klimov wrote: >>> The rxmacro, txmacro, vamacro, soundwire nodes, lpass clock controllers >>> are required to support audio playback and audio capture on sm6115 and >>> its derivatives. >>> >>> Cc: Konrad Dybcio <konradybcio@kernel.org> >>> Cc: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> >> >> Just keep one CC. > > Question is which one now. Konrad, is it fine to keep your oss.qualcomm.com > email here? > >>> Cc: Srinivas Kandagatla <srini@kernel.org> >>> Co-developed-by: Konrad Dybcio <konrad.dybcio@linaro.org> >> >> Missing SoB. > > IIRC I took Konrad's changes but at this point I don't remember how much was changed. And stripped his SoB? > So I need to switch to Konrad's owned completely or somehow indicate using tags > that it is initial Konrad's work. No, you need to add proper SoB. See submitting patches about using co-developed-by. If there was no SoB in the original work (happens), maybe Konrad can provide now publicly. > Best regards, Krzysztof ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v3 07/12] arm64: dts: qcom: sm6115: add LPASS devices 2025-05-27 18:33 ` Krzysztof Kozlowski @ 2025-05-27 20:36 ` Alexey Klimov 2025-05-28 5:59 ` Krzysztof Kozlowski 0 siblings, 1 reply; 43+ messages in thread From: Alexey Klimov @ 2025-05-27 20:36 UTC (permalink / raw) To: Krzysztof Kozlowski, Konrad Dybcio, Konrad Dybcio Cc: Srinivas Kandagatla, Mark Brown, linux-sound, Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio On Tue May 27, 2025 at 7:33 PM BST, Krzysztof Kozlowski wrote: > On 27/05/2025 18:32, Alexey Klimov wrote: >> On Thu May 22, 2025 at 6:52 PM BST, Krzysztof Kozlowski wrote: >>> On 22/05/2025 19:40, Alexey Klimov wrote: >>>> The rxmacro, txmacro, vamacro, soundwire nodes, lpass clock controllers >>>> are required to support audio playback and audio capture on sm6115 and >>>> its derivatives. >>>> >>>> Cc: Konrad Dybcio <konradybcio@kernel.org> >>>> Cc: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> >>> >>> Just keep one CC. >> >> Question is which one now. Konrad, is it fine to keep your oss.qualcomm.com >> email here? >> >>>> Cc: Srinivas Kandagatla <srini@kernel.org> >>>> Co-developed-by: Konrad Dybcio <konrad.dybcio@linaro.org> >>> >>> Missing SoB. >> >> IIRC I took Konrad's changes but at this point I don't remember how much was changed. > > And stripped his SoB? If the memory serves me well there was none. Thanks, Alexey ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v3 07/12] arm64: dts: qcom: sm6115: add LPASS devices 2025-05-27 20:36 ` Alexey Klimov @ 2025-05-28 5:59 ` Krzysztof Kozlowski 0 siblings, 0 replies; 43+ messages in thread From: Krzysztof Kozlowski @ 2025-05-28 5:59 UTC (permalink / raw) To: Alexey Klimov, Krzysztof Kozlowski, Konrad Dybcio, Konrad Dybcio Cc: Srinivas Kandagatla, Mark Brown, linux-sound, Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio On 27/05/2025 22:36, Alexey Klimov wrote: > On Tue May 27, 2025 at 7:33 PM BST, Krzysztof Kozlowski wrote: >> On 27/05/2025 18:32, Alexey Klimov wrote: >>> On Thu May 22, 2025 at 6:52 PM BST, Krzysztof Kozlowski wrote: >>>> On 22/05/2025 19:40, Alexey Klimov wrote: >>>>> The rxmacro, txmacro, vamacro, soundwire nodes, lpass clock controllers >>>>> are required to support audio playback and audio capture on sm6115 and >>>>> its derivatives. >>>>> >>>>> Cc: Konrad Dybcio <konradybcio@kernel.org> >>>>> Cc: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> >>>> >>>> Just keep one CC. >>> >>> Question is which one now. Konrad, is it fine to keep your oss.qualcomm.com >>> email here? >>> >>>>> Cc: Srinivas Kandagatla <srini@kernel.org> >>>>> Co-developed-by: Konrad Dybcio <konrad.dybcio@linaro.org> >>>> >>>> Missing SoB. >>> >>> IIRC I took Konrad's changes but at this point I don't remember how much was changed. >> >> And stripped his SoB? > > If the memory serves me well there was none. Sure, then the last part of my response is applicable (which was below above sentence). Best regards, Krzysztof ^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v3 08/12] arm64: dts: qcom: sm4250: add description of soundwire and dmic pins 2025-05-22 17:40 [PATCH v3 00/12] qrb4210-rb2: add wsa audio playback and capture support Alexey Klimov ` (6 preceding siblings ...) 2025-05-22 17:40 ` [PATCH v3 07/12] arm64: dts: qcom: sm6115: add LPASS devices Alexey Klimov @ 2025-05-22 17:40 ` Alexey Klimov 2025-05-22 18:12 ` Konrad Dybcio 2025-05-22 17:40 ` [PATCH v3 09/12] arm64: dts: qcom: qrb4210-rb2: add wcd937x codec support Alexey Klimov ` (4 subsequent siblings) 12 siblings, 1 reply; 43+ messages in thread From: Alexey Klimov @ 2025-05-22 17:40 UTC (permalink / raw) To: Srinivas Kandagatla, Mark Brown, linux-sound Cc: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio, Srinivas Kandagatla Adds data and clock pins description (their active state) of soundwire masters and onboard DMIC. Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> --- arch/arm64/boot/dts/qcom/sm4250.dtsi | 62 ++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/sm4250.dtsi b/arch/arm64/boot/dts/qcom/sm4250.dtsi index cd8c8e59976e5dc4b48d0e14566cf142895711d5..723391ba9aa21d84ba2dda23932c20bd048fbe80 100644 --- a/arch/arm64/boot/dts/qcom/sm4250.dtsi +++ b/arch/arm64/boot/dts/qcom/sm4250.dtsi @@ -37,10 +37,36 @@ &cpu7 { compatible = "qcom,kryo240"; }; +&swr0 { + pinctrl-0 = <&lpass_tx_swr_active>; + pinctrl-names = "default"; +}; + +&swr1 { + pinctrl-0 = <&lpass_rx_swr_active>; + pinctrl-names = "default"; +}; + &lpass_tlmm { compatible = "qcom,sm4250-lpass-lpi-pinctrl"; gpio-ranges = <&lpass_tlmm 0 0 27>; + lpass_dmic01_active: lpass-dmic01-active-state { + clk-pins { + pins = "gpio6"; + function = "dmic01_clk"; + drive-strength = <8>; + output-high; + }; + + data-pins { + pins = "gpio7"; + function = "dmic01_data"; + drive-strength = <8>; + input-enable; + }; + }; + lpi_i2s2_active: lpi-i2s2-active-state { sck-pins { pins = "gpio10"; @@ -74,4 +100,40 @@ ext-mclk1-pins { output-high; }; }; + + lpass_tx_swr_active: lpass-tx-swr-active-state { + clk-pins { + pins = "gpio0"; + function = "swr_tx_clk"; + drive-strength = <10>; + slew-rate = <3>; + bias-disable; + }; + + data-pins { + pins = "gpio1", "gpio2"; + function = "swr_tx_data"; + drive-strength = <10>; + slew-rate = <3>; + bias-bus-hold; + }; + }; + + lpass_rx_swr_active: lpass-rx-swr-active-state { + clk-pins { + pins = "gpio3"; + function = "swr_rx_clk"; + drive-strength = <10>; + slew-rate = <3>; + bias-disable; + }; + + data-pins { + pins = "gpio4", "gpio5"; + function = "swr_rx_data"; + drive-strength = <10>; + slew-rate = <3>; + bias-bus-hold; + }; + }; }; -- 2.47.2 ^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH v3 08/12] arm64: dts: qcom: sm4250: add description of soundwire and dmic pins 2025-05-22 17:40 ` [PATCH v3 08/12] arm64: dts: qcom: sm4250: add description of soundwire and dmic pins Alexey Klimov @ 2025-05-22 18:12 ` Konrad Dybcio 2025-05-27 15:59 ` Alexey Klimov 0 siblings, 1 reply; 43+ messages in thread From: Konrad Dybcio @ 2025-05-22 18:12 UTC (permalink / raw) To: Alexey Klimov, Srinivas Kandagatla, Mark Brown, linux-sound Cc: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio On 5/22/25 7:40 PM, Alexey Klimov wrote: > Adds data and clock pins description (their active state) of > soundwire masters and onboard DMIC. > > Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> > Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> > --- > arch/arm64/boot/dts/qcom/sm4250.dtsi | 62 ++++++++++++++++++++++++++++++++++++ > 1 file changed, 62 insertions(+) > > diff --git a/arch/arm64/boot/dts/qcom/sm4250.dtsi b/arch/arm64/boot/dts/qcom/sm4250.dtsi > index cd8c8e59976e5dc4b48d0e14566cf142895711d5..723391ba9aa21d84ba2dda23932c20bd048fbe80 100644 > --- a/arch/arm64/boot/dts/qcom/sm4250.dtsi > +++ b/arch/arm64/boot/dts/qcom/sm4250.dtsi > @@ -37,10 +37,36 @@ &cpu7 { > compatible = "qcom,kryo240"; > }; > > +&swr0 { > + pinctrl-0 = <&lpass_tx_swr_active>; > + pinctrl-names = "default"; > +}; > + > +&swr1 { > + pinctrl-0 = <&lpass_rx_swr_active>; > + pinctrl-names = "default"; > +}; > + > &lpass_tlmm { > compatible = "qcom,sm4250-lpass-lpi-pinctrl"; > gpio-ranges = <&lpass_tlmm 0 0 27>; > > + lpass_dmic01_active: lpass-dmic01-active-state { > + clk-pins { > + pins = "gpio6"; > + function = "dmic01_clk"; > + drive-strength = <8>; > + output-high; > + }; > + > + data-pins { > + pins = "gpio7"; > + function = "dmic01_data"; > + drive-strength = <8>; > + input-enable; > + }; Other SoCs put these in the common dtsi Konrad ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v3 08/12] arm64: dts: qcom: sm4250: add description of soundwire and dmic pins 2025-05-22 18:12 ` Konrad Dybcio @ 2025-05-27 15:59 ` Alexey Klimov 0 siblings, 0 replies; 43+ messages in thread From: Alexey Klimov @ 2025-05-27 15:59 UTC (permalink / raw) To: Konrad Dybcio, Srinivas Kandagatla, Mark Brown, linux-sound Cc: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio On Thu May 22, 2025 at 7:12 PM BST, Konrad Dybcio wrote: > On 5/22/25 7:40 PM, Alexey Klimov wrote: >> Adds data and clock pins description (their active state) of >> soundwire masters and onboard DMIC. >> >> Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> >> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> >> --- >> arch/arm64/boot/dts/qcom/sm4250.dtsi | 62 ++++++++++++++++++++++++++++++++++++ >> 1 file changed, 62 insertions(+) >> >> diff --git a/arch/arm64/boot/dts/qcom/sm4250.dtsi b/arch/arm64/boot/dts/qcom/sm4250.dtsi >> index cd8c8e59976e5dc4b48d0e14566cf142895711d5..723391ba9aa21d84ba2dda23932c20bd048fbe80 100644 >> --- a/arch/arm64/boot/dts/qcom/sm4250.dtsi >> +++ b/arch/arm64/boot/dts/qcom/sm4250.dtsi >> @@ -37,10 +37,36 @@ &cpu7 { >> compatible = "qcom,kryo240"; >> }; >> >> +&swr0 { >> + pinctrl-0 = <&lpass_tx_swr_active>; >> + pinctrl-names = "default"; >> +}; >> + >> +&swr1 { >> + pinctrl-0 = <&lpass_rx_swr_active>; >> + pinctrl-names = "default"; >> +}; >> + >> &lpass_tlmm { >> compatible = "qcom,sm4250-lpass-lpi-pinctrl"; >> gpio-ranges = <&lpass_tlmm 0 0 27>; >> >> + lpass_dmic01_active: lpass-dmic01-active-state { >> + clk-pins { >> + pins = "gpio6"; >> + function = "dmic01_clk"; >> + drive-strength = <8>; >> + output-high; >> + }; >> + >> + data-pins { >> + pins = "gpio7"; >> + function = "dmic01_data"; >> + drive-strength = <8>; >> + input-enable; >> + }; > > Other SoCs put these in the common dtsi which seems to be sm4250.dtsi in this case unless I am missing something. Thanks, Alexey ^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v3 09/12] arm64: dts: qcom: qrb4210-rb2: add wcd937x codec support 2025-05-22 17:40 [PATCH v3 00/12] qrb4210-rb2: add wsa audio playback and capture support Alexey Klimov ` (7 preceding siblings ...) 2025-05-22 17:40 ` [PATCH v3 08/12] arm64: dts: qcom: sm4250: add description of soundwire and dmic pins Alexey Klimov @ 2025-05-22 17:40 ` Alexey Klimov 2025-05-22 17:41 ` [PATCH v3 10/12] arm64: dts: qcom: qrb4210-rb2: enable wsa881x amplifier Alexey Klimov ` (3 subsequent siblings) 12 siblings, 0 replies; 43+ messages in thread From: Alexey Klimov @ 2025-05-22 17:40 UTC (permalink / raw) To: Srinivas Kandagatla, Mark Brown, linux-sound Cc: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio wcd937x codec contains soundwire RX and TX slave devices and can convert digital audio to analog audio and vice versa. The codec node also requires description of reset pin/gpio. Cc: Srinivas Kandagatla <srini@kernel.org> Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> --- arch/arm64/boot/dts/qcom/qrb4210-rb2.dts | 47 ++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/qrb4210-rb2.dts b/arch/arm64/boot/dts/qcom/qrb4210-rb2.dts index a37860175d2733214f1b257e84d5cb4821033242..6bce63720cfffd8e0e619937fb1f365cbbbcb283 100644 --- a/arch/arm64/boot/dts/qcom/qrb4210-rb2.dts +++ b/arch/arm64/boot/dts/qcom/qrb4210-rb2.dts @@ -5,6 +5,7 @@ /dts-v1/; +#include <dt-bindings/gpio/gpio.h> #include <dt-bindings/leds/common.h> #include <dt-bindings/sound/qcom,q6afe.h> #include <dt-bindings/sound/qcom,q6asm.h> @@ -152,6 +153,25 @@ codec { }; }; + wcd937x: codec { + compatible = "qcom,wcd9370-codec"; + pinctrl-0 = <&wcd_reset_n>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 82 GPIO_ACTIVE_LOW>; + vdd-buck-supply = <&vreg_l9a_1p8>; + vdd-rxtx-supply = <&vreg_l9a_1p8>; + vdd-px-supply = <&vreg_l9a_1p8>; + vdd-mic-bias-supply = <&vdc_vbat_som>; + qcom,micbias1-microvolt = <1800000>; + qcom,micbias2-microvolt = <1800000>; + qcom,micbias3-microvolt = <1800000>; + qcom,micbias4-microvolt = <1800000>; + qcom,mbhc-buttons-vthreshold-microvolt = <75000 150000 237000 500000 500000 500000 500000 500000>; + qcom,rx-device = <&wcd937x_rx>; + qcom,tx-device = <&wcd937x_tx>; + #sound-dai-cells = <1>; + }; + vreg_hdmi_out_1p2: regulator-hdmi-out-1p2 { compatible = "regulator-fixed"; regulator-name = "VREG_HDMI_OUT_1P2"; @@ -605,6 +625,26 @@ &sleep_clk { clock-frequency = <32764>; }; +&swr1 { + status = "okay"; + + wcd937x_rx: codec@0,4 { + compatible = "sdw20217010a00"; + reg = <0 4>; + qcom,rx-port-mapping = <1 2 3 4 5>; + }; +}; + +&swr0 { + status = "okay"; + + wcd937x_tx: codec@0,3 { + compatible = "sdw20217010a00"; + reg = <0 3>; + qcom,tx-port-mapping = <1 1 2 3>; + }; +}; + &tlmm { gpio-reserved-ranges = <43 2>, <49 1>, <54 1>, <56 3>, <61 2>, <64 1>, @@ -689,6 +729,13 @@ sdc2_card_det_n: sd-card-det-n-state { drive-strength = <2>; bias-pull-up; }; + + wcd_reset_n: wcd-reset-n-state { + pins = "gpio82"; + function = "gpio"; + drive-strength = <16>; + output-high; + }; }; &uart3 { -- 2.47.2 ^ permalink raw reply related [flat|nested] 43+ messages in thread
* [PATCH v3 10/12] arm64: dts: qcom: qrb4210-rb2: enable wsa881x amplifier 2025-05-22 17:40 [PATCH v3 00/12] qrb4210-rb2: add wsa audio playback and capture support Alexey Klimov ` (8 preceding siblings ...) 2025-05-22 17:40 ` [PATCH v3 09/12] arm64: dts: qcom: qrb4210-rb2: add wcd937x codec support Alexey Klimov @ 2025-05-22 17:41 ` Alexey Klimov 2025-05-22 18:13 ` Konrad Dybcio 2025-05-22 17:41 ` [PATCH v3 11/12] arm64: dts: qcom: qrb4210-rb2: add WSA audio playback support Alexey Klimov ` (2 subsequent siblings) 12 siblings, 1 reply; 43+ messages in thread From: Alexey Klimov @ 2025-05-22 17:41 UTC (permalink / raw) To: Srinivas Kandagatla, Mark Brown, linux-sound Cc: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio, Srinivas Kandagatla One WSA881X amplifier is connected on QRB4210 RB2 board hence only mono speaker is supported. This amplifier is set to work in analog mode only. Also add required powerdown pin/gpio. Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> --- arch/arm64/boot/dts/qcom/qrb4210-rb2.dts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/qrb4210-rb2.dts b/arch/arm64/boot/dts/qcom/qrb4210-rb2.dts index 6bce63720cfffd8e0e619937fb1f365cbbbcb283..4b878e585227ee6b3b362108be96aad99acba21d 100644 --- a/arch/arm64/boot/dts/qcom/qrb4210-rb2.dts +++ b/arch/arm64/boot/dts/qcom/qrb4210-rb2.dts @@ -270,6 +270,24 @@ zap-shader { }; }; +&i2c1 { + clock-frequency = <400000>; + status = "okay"; + + wsa881x: amplifier@f { + compatible = "qcom,wsa8815"; + reg = <0x0f>; + pinctrl-0 = <&wsa_en_active>; + pinctrl-names = "default"; + clocks = <&q6afecc LPASS_CLK_ID_MCLK_2 LPASS_CLK_ATTRIBUTE_COUPLE_NO>; + powerdown-gpios = <&lpass_tlmm 16 GPIO_ACTIVE_LOW>; + mclk-gpios = <&lpass_tlmm 18 GPIO_ACTIVE_HIGH>; + sound-name-prefix = "SpkrMono"; + #sound-dai-cells = <0>; + #thermal-sensor-cells = <0>; + }; +}; + &i2c2_gpio { clock-frequency = <400000>; status = "okay"; @@ -736,6 +754,14 @@ wcd_reset_n: wcd-reset-n-state { drive-strength = <16>; output-high; }; + + wsa_en_active: wsa-en-active-state { + pins = "gpio106"; + function = "gpio"; + drive-strength = <16>; + bias-disable; + output-high; + }; }; &uart3 { -- 2.47.2 ^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH v3 10/12] arm64: dts: qcom: qrb4210-rb2: enable wsa881x amplifier 2025-05-22 17:41 ` [PATCH v3 10/12] arm64: dts: qcom: qrb4210-rb2: enable wsa881x amplifier Alexey Klimov @ 2025-05-22 18:13 ` Konrad Dybcio 2025-05-27 15:55 ` Alexey Klimov 0 siblings, 1 reply; 43+ messages in thread From: Konrad Dybcio @ 2025-05-22 18:13 UTC (permalink / raw) To: Alexey Klimov, Srinivas Kandagatla, Mark Brown, linux-sound Cc: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio On 5/22/25 7:41 PM, Alexey Klimov wrote: > One WSA881X amplifier is connected on QRB4210 RB2 board > hence only mono speaker is supported. This amplifier is set > to work in analog mode only. Also add required powerdown > pin/gpio. > > Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> > Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> > --- > arch/arm64/boot/dts/qcom/qrb4210-rb2.dts | 26 ++++++++++++++++++++++++++ > 1 file changed, 26 insertions(+) > > diff --git a/arch/arm64/boot/dts/qcom/qrb4210-rb2.dts b/arch/arm64/boot/dts/qcom/qrb4210-rb2.dts > index 6bce63720cfffd8e0e619937fb1f365cbbbcb283..4b878e585227ee6b3b362108be96aad99acba21d 100644 > --- a/arch/arm64/boot/dts/qcom/qrb4210-rb2.dts > +++ b/arch/arm64/boot/dts/qcom/qrb4210-rb2.dts > @@ -270,6 +270,24 @@ zap-shader { > }; > }; > > +&i2c1 { > + clock-frequency = <400000>; > + status = "okay"; > + > + wsa881x: amplifier@f { > + compatible = "qcom,wsa8815"; > + reg = <0x0f>; > + pinctrl-0 = <&wsa_en_active>; > + pinctrl-names = "default"; > + clocks = <&q6afecc LPASS_CLK_ID_MCLK_2 LPASS_CLK_ATTRIBUTE_COUPLE_NO>; > + powerdown-gpios = <&lpass_tlmm 16 GPIO_ACTIVE_LOW>; > + mclk-gpios = <&lpass_tlmm 18 GPIO_ACTIVE_HIGH>; > + sound-name-prefix = "SpkrMono"; > + #sound-dai-cells = <0>; > + #thermal-sensor-cells = <0>; > + }; > +}; > + > &i2c2_gpio { > clock-frequency = <400000>; > status = "okay"; > @@ -736,6 +754,14 @@ wcd_reset_n: wcd-reset-n-state { > drive-strength = <16>; > output-high; > }; > + > + wsa_en_active: wsa-en-active-state { > + pins = "gpio106"; Are there two separate enable pins? Or is the powerdown-gpio something else? Konrad ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v3 10/12] arm64: dts: qcom: qrb4210-rb2: enable wsa881x amplifier 2025-05-22 18:13 ` Konrad Dybcio @ 2025-05-27 15:55 ` Alexey Klimov 2025-05-27 20:59 ` Konrad Dybcio 0 siblings, 1 reply; 43+ messages in thread From: Alexey Klimov @ 2025-05-27 15:55 UTC (permalink / raw) To: Konrad Dybcio, Srinivas Kandagatla, Mark Brown, linux-sound Cc: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio On Thu May 22, 2025 at 7:13 PM BST, Konrad Dybcio wrote: > On 5/22/25 7:41 PM, Alexey Klimov wrote: >> One WSA881X amplifier is connected on QRB4210 RB2 board >> hence only mono speaker is supported. This amplifier is set >> to work in analog mode only. Also add required powerdown >> pin/gpio. >> >> Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> >> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> >> --- >> arch/arm64/boot/dts/qcom/qrb4210-rb2.dts | 26 ++++++++++++++++++++++++++ >> 1 file changed, 26 insertions(+) >> >> diff --git a/arch/arm64/boot/dts/qcom/qrb4210-rb2.dts b/arch/arm64/boot/dts/qcom/qrb4210-rb2.dts >> index 6bce63720cfffd8e0e619937fb1f365cbbbcb283..4b878e585227ee6b3b362108be96aad99acba21d 100644 >> --- a/arch/arm64/boot/dts/qcom/qrb4210-rb2.dts >> +++ b/arch/arm64/boot/dts/qcom/qrb4210-rb2.dts >> @@ -270,6 +270,24 @@ zap-shader { >> }; >> }; >> >> +&i2c1 { >> + clock-frequency = <400000>; >> + status = "okay"; >> + >> + wsa881x: amplifier@f { >> + compatible = "qcom,wsa8815"; >> + reg = <0x0f>; >> + pinctrl-0 = <&wsa_en_active>; >> + pinctrl-names = "default"; >> + clocks = <&q6afecc LPASS_CLK_ID_MCLK_2 LPASS_CLK_ATTRIBUTE_COUPLE_NO>; >> + powerdown-gpios = <&lpass_tlmm 16 GPIO_ACTIVE_LOW>; >> + mclk-gpios = <&lpass_tlmm 18 GPIO_ACTIVE_HIGH>; >> + sound-name-prefix = "SpkrMono"; >> + #sound-dai-cells = <0>; >> + #thermal-sensor-cells = <0>; >> + }; >> +}; >> + >> &i2c2_gpio { >> clock-frequency = <400000>; >> status = "okay"; >> @@ -736,6 +754,14 @@ wcd_reset_n: wcd-reset-n-state { >> drive-strength = <16>; >> output-high; >> }; >> + >> + wsa_en_active: wsa-en-active-state { >> + pins = "gpio106"; > > Are there two separate enable pins? Or is the powerdown-gpio something > else? No, should be only one. I think 106 on tlmm is wired into 16 on lpass tlmm. We need to assign gpio function to such pins, aren't we? Best regards, Alexey ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v3 10/12] arm64: dts: qcom: qrb4210-rb2: enable wsa881x amplifier 2025-05-27 15:55 ` Alexey Klimov @ 2025-05-27 20:59 ` Konrad Dybcio 0 siblings, 0 replies; 43+ messages in thread From: Konrad Dybcio @ 2025-05-27 20:59 UTC (permalink / raw) To: Alexey Klimov, Konrad Dybcio, Srinivas Kandagatla, Mark Brown, linux-sound Cc: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio On 5/27/25 5:55 PM, Alexey Klimov wrote: > On Thu May 22, 2025 at 7:13 PM BST, Konrad Dybcio wrote: >> On 5/22/25 7:41 PM, Alexey Klimov wrote: >>> One WSA881X amplifier is connected on QRB4210 RB2 board >>> hence only mono speaker is supported. This amplifier is set >>> to work in analog mode only. Also add required powerdown >>> pin/gpio. >>> >>> Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> >>> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> >>> --- >>> arch/arm64/boot/dts/qcom/qrb4210-rb2.dts | 26 ++++++++++++++++++++++++++ >>> 1 file changed, 26 insertions(+) >>> >>> diff --git a/arch/arm64/boot/dts/qcom/qrb4210-rb2.dts b/arch/arm64/boot/dts/qcom/qrb4210-rb2.dts >>> index 6bce63720cfffd8e0e619937fb1f365cbbbcb283..4b878e585227ee6b3b362108be96aad99acba21d 100644 >>> --- a/arch/arm64/boot/dts/qcom/qrb4210-rb2.dts >>> +++ b/arch/arm64/boot/dts/qcom/qrb4210-rb2.dts >>> @@ -270,6 +270,24 @@ zap-shader { >>> }; >>> }; >>> >>> +&i2c1 { >>> + clock-frequency = <400000>; >>> + status = "okay"; >>> + >>> + wsa881x: amplifier@f { >>> + compatible = "qcom,wsa8815"; >>> + reg = <0x0f>; >>> + pinctrl-0 = <&wsa_en_active>; >>> + pinctrl-names = "default"; >>> + clocks = <&q6afecc LPASS_CLK_ID_MCLK_2 LPASS_CLK_ATTRIBUTE_COUPLE_NO>; >>> + powerdown-gpios = <&lpass_tlmm 16 GPIO_ACTIVE_LOW>; >>> + mclk-gpios = <&lpass_tlmm 18 GPIO_ACTIVE_HIGH>; >>> + sound-name-prefix = "SpkrMono"; >>> + #sound-dai-cells = <0>; >>> + #thermal-sensor-cells = <0>; >>> + }; >>> +}; >>> + >>> &i2c2_gpio { >>> clock-frequency = <400000>; >>> status = "okay"; >>> @@ -736,6 +754,14 @@ wcd_reset_n: wcd-reset-n-state { >>> drive-strength = <16>; >>> output-high; >>> }; >>> + >>> + wsa_en_active: wsa-en-active-state { >>> + pins = "gpio106"; >> >> Are there two separate enable pins? Or is the powerdown-gpio something >> else? > > No, should be only one. I think 106 on tlmm is wired into 16 on lpass tlmm. > We need to assign gpio function to such pins, aren't we? Well, we can just poke at them from lpass_tlmm Konrad ^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v3 11/12] arm64: dts: qcom: qrb4210-rb2: add WSA audio playback support 2025-05-22 17:40 [PATCH v3 00/12] qrb4210-rb2: add wsa audio playback and capture support Alexey Klimov ` (9 preceding siblings ...) 2025-05-22 17:41 ` [PATCH v3 10/12] arm64: dts: qcom: qrb4210-rb2: enable wsa881x amplifier Alexey Klimov @ 2025-05-22 17:41 ` Alexey Klimov 2025-05-22 17:41 ` [PATCH v3 12/12] arm64: dts: qcom: qrb4210-rb2: add VA capture support Alexey Klimov 2025-05-22 17:47 ` [PATCH v3 00/12] qrb4210-rb2: add wsa audio playback and " Krzysztof Kozlowski 12 siblings, 0 replies; 43+ messages in thread From: Alexey Klimov @ 2025-05-22 17:41 UTC (permalink / raw) To: Srinivas Kandagatla, Mark Brown, linux-sound Cc: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio Add support for audio playback via WCD937X/WSA881X. From DSP and rxmacro the sound stream goes into AUX port of wcd codec. wcd codec decodes digital audio into analog and outputs it to single wsa amplifier hence only the mono configuration. The audio playback is verified using the following commands: amixer -c0 cset iface=MIXER,name='AUX_RDAC Switch' 1 amixer -c0 cset iface=MIXER,name='RX_RX2 Digital Volume' 80 amixer -c0 cset iface=MIXER,name='RX INT2_1 MIX1 INP0' 'RX2' amixer -c0 cset iface=MIXER,name='RX_CODEC_DMA_RX_1 Audio Mixer MultiMedia1' 1 amixer -c0 cset iface=MIXER,name='RX_MACRO RX2 MUX' 'AIF2_PB' amixer -c0 cset iface=MIXER,name='SpkrMono WSA_RDAC' 1 amixer -c0 cset iface=MIXER,name='LO Switch' 1 amixer -c0 cset iface=MIXER,name='RX HPH Mode' 4 aplay -D hw:0,0 /usr/share/sounds/alsa/Front_Center.wav Cc: Srinivas Kandagatla <srini@kernel.org> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> --- arch/arm64/boot/dts/qcom/qrb4210-rb2.dts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/qrb4210-rb2.dts b/arch/arm64/boot/dts/qcom/qrb4210-rb2.dts index 4b878e585227ee6b3b362108be96aad99acba21d..1e2b9d2516b62e2e80c40ed6c3a0c4548a02630c 100644 --- a/arch/arm64/boot/dts/qcom/qrb4210-rb2.dts +++ b/arch/arm64/boot/dts/qcom/qrb4210-rb2.dts @@ -111,6 +111,8 @@ sound { pinctrl-0 = <&lpi_i2s2_active>; pinctrl-names = "default"; model = "Qualcomm-RB2-WSA8815-Speakers-DMIC0"; + audio-routing = "IN3_AUX", "AUX_OUT", + "SpkrMono WSA_IN", "AUX"; mm1-dai-link { link-name = "MultiMedia1"; @@ -151,6 +153,22 @@ codec { sound-dai = <<9611_codec 0>; }; }; + + wsa-dai-link { + link-name = "WSA Playback"; + + codec { + sound-dai = <&wsa881x>, <&wcd937x 0>, <&swr1 3>, <&rxmacro 1>; + }; + + cpu { + sound-dai = <&q6afedai RX_CODEC_DMA_RX_1>; + }; + + platform { + sound-dai = <&q6routing>; + }; + }; }; wcd937x: codec { -- 2.47.2 ^ permalink raw reply related [flat|nested] 43+ messages in thread
* [PATCH v3 12/12] arm64: dts: qcom: qrb4210-rb2: add VA capture support 2025-05-22 17:40 [PATCH v3 00/12] qrb4210-rb2: add wsa audio playback and capture support Alexey Klimov ` (10 preceding siblings ...) 2025-05-22 17:41 ` [PATCH v3 11/12] arm64: dts: qcom: qrb4210-rb2: add WSA audio playback support Alexey Klimov @ 2025-05-22 17:41 ` Alexey Klimov 2025-05-22 18:16 ` Konrad Dybcio 2025-05-22 17:47 ` [PATCH v3 00/12] qrb4210-rb2: add wsa audio playback and " Krzysztof Kozlowski 12 siblings, 1 reply; 43+ messages in thread From: Alexey Klimov @ 2025-05-22 17:41 UTC (permalink / raw) To: Srinivas Kandagatla, Mark Brown, linux-sound Cc: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio Add support for audio capture using onboard DMIC. It is directly connected to vamacro and txmacro without any soundwire interfaces. The capture was verified using the following commands: amixer -c0 cset iface=MIXER,name='MultiMedia3 Mixer VA_CODEC_DMA_TX_0' 1 amixer -c0 cset iface=MIXER,name='VA_AIF1_CAP Mixer DEC0' 1 amixer -c0 cset iface=MIXER,name='VA_DEC0 Volume' 110 amixer -c0 cset iface=MIXER,name='VA DMIC MUX0' 2 arecord -D hw:0,2 -f S16_LE -c 2 -r 48000 -d 5 record.wav Cc: Srinivas Kandagatla <srini@kernel.org> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> --- arch/arm64/boot/dts/qcom/qrb4210-rb2.dts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/qrb4210-rb2.dts b/arch/arm64/boot/dts/qcom/qrb4210-rb2.dts index 1e2b9d2516b62e2e80c40ed6c3a0c4548a02630c..1c125ae4e2f3eb4f715bd0aac42a60b9132ecfbc 100644 --- a/arch/arm64/boot/dts/qcom/qrb4210-rb2.dts +++ b/arch/arm64/boot/dts/qcom/qrb4210-rb2.dts @@ -169,6 +169,22 @@ platform { sound-dai = <&q6routing>; }; }; + + va-dai-link { + link-name = "VA Capture"; + + codec { + sound-dai = <&vamacro 0>; + }; + + cpu { + sound-dai = <&q6afedai VA_CODEC_DMA_TX_0>; + }; + + platform { + sound-dai = <&q6routing>; + }; + }; }; wcd937x: codec { @@ -833,6 +849,12 @@ &usb_qmpphy_out { remote-endpoint = <&pmi632_ss_in>; }; +&vamacro { + pinctrl-0 = <&lpass_dmic01_active>; + pinctrl-names = "default"; + qcom,dmic-sample-rate = <2400000>; +}; + &wifi { vdd-0.8-cx-mx-supply = <&vreg_l8a_0p664>; vdd-1.8-xo-supply = <&vreg_l16a_1p3>; -- 2.47.2 ^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH v3 12/12] arm64: dts: qcom: qrb4210-rb2: add VA capture support 2025-05-22 17:41 ` [PATCH v3 12/12] arm64: dts: qcom: qrb4210-rb2: add VA capture support Alexey Klimov @ 2025-05-22 18:16 ` Konrad Dybcio 0 siblings, 0 replies; 43+ messages in thread From: Konrad Dybcio @ 2025-05-22 18:16 UTC (permalink / raw) To: Alexey Klimov, Srinivas Kandagatla, Mark Brown, linux-sound Cc: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio On 5/22/25 7:41 PM, Alexey Klimov wrote: > Add support for audio capture using onboard DMIC. It is directly > connected to vamacro and txmacro without any soundwire interfaces. > > The capture was verified using the following commands: > > amixer -c0 cset iface=MIXER,name='MultiMedia3 Mixer VA_CODEC_DMA_TX_0' 1 > amixer -c0 cset iface=MIXER,name='VA_AIF1_CAP Mixer DEC0' 1 > amixer -c0 cset iface=MIXER,name='VA_DEC0 Volume' 110 > amixer -c0 cset iface=MIXER,name='VA DMIC MUX0' 2 > > arecord -D hw:0,2 -f S16_LE -c 2 -r 48000 -d 5 record.wav > > Cc: Srinivas Kandagatla <srini@kernel.org> > Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> > --- Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> Konrad ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v3 00/12] qrb4210-rb2: add wsa audio playback and capture support 2025-05-22 17:40 [PATCH v3 00/12] qrb4210-rb2: add wsa audio playback and capture support Alexey Klimov ` (11 preceding siblings ...) 2025-05-22 17:41 ` [PATCH v3 12/12] arm64: dts: qcom: qrb4210-rb2: add VA capture support Alexey Klimov @ 2025-05-22 17:47 ` Krzysztof Kozlowski 12 siblings, 0 replies; 43+ messages in thread From: Krzysztof Kozlowski @ 2025-05-22 17:47 UTC (permalink / raw) To: Alexey Klimov, Srinivas Kandagatla, Mark Brown, linux-sound Cc: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson, Dmitry Baryshkov, Konrad Dybcio, Konrad Dybcio, Jaroslav Kysela, Takashi Iwai, linux-arm-msm, devicetree, linux-kernel, linux-gpio On 22/05/2025 19:40, Alexey Klimov wrote: > Rebased, updated, re-tested. This implements the playback support via the > following path: RX1 from DSP is connected to rxmacro which communicates > with wcd codec using soundwire. This goes into AUX input of wcd. Wcd codec > outputs analog audio into wsa8815 amplifier. Capturing works through vamacro > using one onboard DMIC which is directly connected to vamacro codec. > > Changes since v2: > -- dropped [PATCH v2 08/14] dt-bindings: arm: qcom-soc: extend pattern matching > to support qcom,wsa881x and replaced with new one; > -- dropped [PATCH v2 14/14] ASoC: qcom: sm8250: force single channel via RX_1 output for qrb4210 > -- reordered as suggested by Krzysztof; > -- updates to wsa881x-common.h registers descriptions and corresponding updates > to wsa881x-common.c (Konrad); > -- sorted subnodes in DT alphabetically as suggested by Konrad; > -- wsa881x bindings updates (as suggested by Krzysztof); What exactly changed? This is way too vague. > -- ASoC: dt-bindings: qcom: Add SM6115 LPASS rxmacro and vamacro codecs > is still present; What does it mean "still present"? You never responded to my comment. I never asked to remove it, so I do not get why you mention it is still present. Best regards, Krzysztof ^ permalink raw reply [flat|nested] 43+ messages in thread
end of thread, other threads:[~2025-05-29 17:12 UTC | newest] Thread overview: 43+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-05-22 17:40 [PATCH v3 00/12] qrb4210-rb2: add wsa audio playback and capture support Alexey Klimov 2025-05-22 17:40 ` [PATCH v3 01/12] ASoC: dt-bindings: qcom: Add SM6115 LPASS rxmacro and vamacro codecs Alexey Klimov 2025-05-22 17:49 ` Krzysztof Kozlowski 2025-05-22 17:40 ` [PATCH v3 02/12] dt-bindings: arm: qcom-soc: ignore "wsa" from being selected as SoC component Alexey Klimov 2025-05-23 8:12 ` Krzysztof Kozlowski 2025-05-28 14:37 ` Alexey Klimov 2025-05-28 16:58 ` Konrad Dybcio 2025-05-29 6:58 ` Krzysztof Kozlowski 2025-05-29 16:34 ` Konrad Dybcio 2025-05-29 16:58 ` Krzysztof Kozlowski 2025-05-29 17:12 ` Konrad Dybcio 2025-05-29 6:38 ` Krzysztof Kozlowski 2025-05-22 17:40 ` [PATCH v3 03/12] ASoC: dt-bindings: qcom,wsa881x: extend description to analog mode Alexey Klimov 2025-05-22 17:45 ` Krzysztof Kozlowski 2025-05-27 20:34 ` Alexey Klimov 2025-05-28 5:58 ` Krzysztof Kozlowski 2025-05-22 17:40 ` [PATCH v3 04/12] ASoC: codecs: lpass-rx-macro: add sm6115 compatible Alexey Klimov 2025-05-22 17:49 ` Krzysztof Kozlowski 2025-05-27 16:42 ` Alexey Klimov 2025-05-22 17:40 ` [PATCH v3 05/12] ASoC: codecs: wsa881x: split into common and soundwire drivers Alexey Klimov 2025-05-29 10:05 ` Srinivas Kandagatla 2025-05-22 17:40 ` [PATCH v3 06/12] ASoC: codecs: add wsa881x-i2c amplifier codec driver Alexey Klimov 2025-05-23 12:59 ` kernel test robot 2025-05-29 10:05 ` Srinivas Kandagatla 2025-05-22 17:40 ` [PATCH v3 07/12] arm64: dts: qcom: sm6115: add LPASS devices Alexey Klimov 2025-05-22 17:52 ` Krzysztof Kozlowski 2025-05-27 16:32 ` Alexey Klimov 2025-05-27 17:03 ` Konrad Dybcio 2025-05-27 18:33 ` Krzysztof Kozlowski 2025-05-27 20:36 ` Alexey Klimov 2025-05-28 5:59 ` Krzysztof Kozlowski 2025-05-22 17:40 ` [PATCH v3 08/12] arm64: dts: qcom: sm4250: add description of soundwire and dmic pins Alexey Klimov 2025-05-22 18:12 ` Konrad Dybcio 2025-05-27 15:59 ` Alexey Klimov 2025-05-22 17:40 ` [PATCH v3 09/12] arm64: dts: qcom: qrb4210-rb2: add wcd937x codec support Alexey Klimov 2025-05-22 17:41 ` [PATCH v3 10/12] arm64: dts: qcom: qrb4210-rb2: enable wsa881x amplifier Alexey Klimov 2025-05-22 18:13 ` Konrad Dybcio 2025-05-27 15:55 ` Alexey Klimov 2025-05-27 20:59 ` Konrad Dybcio 2025-05-22 17:41 ` [PATCH v3 11/12] arm64: dts: qcom: qrb4210-rb2: add WSA audio playback support Alexey Klimov 2025-05-22 17:41 ` [PATCH v3 12/12] arm64: dts: qcom: qrb4210-rb2: add VA capture support Alexey Klimov 2025-05-22 18:16 ` Konrad Dybcio 2025-05-22 17:47 ` [PATCH v3 00/12] qrb4210-rb2: add wsa audio playback and " Krzysztof Kozlowski
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).