From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
To: Alexey Klimov <alexey.klimov@linaro.org>,
broonie@kernel.org, konradybcio@kernel.org,
konrad.dybcio@oss.qualcomm.com, andersson@kernel.org,
srinivas.kandagatla@linaro.org
Cc: tiwai@suse.com, lgirdwood@gmail.com, perex@perex.cz,
robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
dmitry.baryshkov@linaro.org, linux-sound@vger.kernel.org,
linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 07/14] ASoC: codecs: wsa881x: split into common and soundwire drivers
Date: Thu, 12 Dec 2024 18:20:32 +0100 [thread overview]
Message-ID: <70647a37-6196-4179-803d-35add798fa0b@oss.qualcomm.com> (raw)
In-Reply-To: <20241212004727.2903846-8-alexey.klimov@linaro.org>
On 12.12.2024 1:47 AM, 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().
>
> Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org>
> ---
[...]
> +
> +int wsa881x_digital_mute(struct snd_soc_dai *dai, int mute, int stream)
> +{
> + struct snd_soc_component *component = dai->component;
> +
> + if (mute)
> + snd_soc_component_update_bits(component,
> + WSA881X_SPKR_DRV_EN, 0x80, 0x00);
> + else
> + snd_soc_component_update_bits(component,
> + WSA881X_SPKR_DRV_EN, 0x80, 0x80);
mute ? 0x00 : BIT(7)
you can even return it for good measure
> +
> + return 0;
> +}
> +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, 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);
All these could use some #defines..
> +
> + regmap_read(rm, WSA881X_OTP_REG_0, &val);
> + if (val)
> + regmap_update_bits(rm, WSA881X_BOOST_PRESET_OUT1, 0xF0, 0x70);
And this, a comment..
> +
> + 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);
> +}
> +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.");
> +
> + dev_set_drvdata(dev, wsa);
> + gpiod_direction_output(wsa->sd_n, !wsa->sd_n_val);
> +
> + *wsa881x = wsa;
> +
> + return 0;
There's no usage of wsa881x, so you can drop this dance
Konrad
next prev parent reply other threads:[~2024-12-12 17:20 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-12 0:47 [PATCH v2 00/14] qrb4210-rb2: add wsa audio playback and capture support Alexey Klimov
2024-12-12 0:47 ` [PATCH v2 01/14] ASoC: dt-bindings: qcom: Add SM6115 LPASS rxmacro and vamacro codecs Alexey Klimov
2024-12-12 2:25 ` Rob Herring (Arm)
2024-12-12 7:39 ` Krzysztof Kozlowski
2024-12-12 16:36 ` Konrad Dybcio
2024-12-12 0:47 ` [PATCH v2 02/14] ASoC: codecs: va-macro: add sm6115 compatible Alexey Klimov
2024-12-12 7:40 ` Krzysztof Kozlowski
2024-12-12 0:47 ` [PATCH v2 03/14] ASoC: codecs: lpass-rx-macro: " Alexey Klimov
2024-12-12 0:47 ` [PATCH v2 04/14] arm64: dts: qcom: sm6115: add LPASS devices Alexey Klimov
2024-12-12 7:42 ` Krzysztof Kozlowski
2024-12-12 0:47 ` [PATCH v2 05/14] arm64: dts: qcom: sm4250: add description of soundwire and dmic pins Alexey Klimov
2024-12-12 0:47 ` [PATCH v2 06/14] arm64: dts: qcom: qrb4210-rb2: add wcd937x codec support Alexey Klimov
2024-12-12 7:43 ` Krzysztof Kozlowski
2024-12-12 17:17 ` Konrad Dybcio
2024-12-12 0:47 ` [PATCH v2 07/14] ASoC: codecs: wsa881x: split into common and soundwire drivers Alexey Klimov
2024-12-12 17:20 ` Konrad Dybcio [this message]
2024-12-12 0:47 ` [PATCH v2 08/14] dt-bindings: arm: qcom-soc: extend pattern matching to support qcom,wsa881x Alexey Klimov
2024-12-12 7:46 ` Krzysztof Kozlowski
2024-12-12 8:02 ` Krzysztof Kozlowski
2024-12-12 0:47 ` [PATCH v2 09/14] ASoC: dt-bindings: qcom,wsa881x: extend description to analog mode Alexey Klimov
2024-12-12 2:25 ` Rob Herring (Arm)
2024-12-12 7:49 ` Krzysztof Kozlowski
2024-12-12 16:39 ` Konrad Dybcio
2024-12-12 0:47 ` [PATCH v2 10/14] arm64: dts: qcom: qrb4210-rb2: enable wsa881x amplifier Alexey Klimov
2024-12-12 0:47 ` [PATCH v2 11/14] ASoC: codecs: add wsa881x-i2c amplifier codec driver Alexey Klimov
2024-12-12 0:47 ` [PATCH v2 12/14] arm64: dts: qcom: qrb4210-rb2: add WSA audio playback support Alexey Klimov
2024-12-13 12:41 ` Konrad Dybcio
2024-12-12 0:47 ` [PATCH v2 13/14] arm64: dts: qcom: qrb4210-rb2: add VA capture support Alexey Klimov
2024-12-12 0:47 ` [PATCH v2 14/14] ASoC: qcom: sm8250: force single channel via RX_1 output for qrb4210 Alexey Klimov
2024-12-12 17:22 ` Konrad Dybcio
2024-12-13 11:54 ` Alexey Klimov
2024-12-13 11:57 ` Konrad Dybcio
2024-12-12 7:37 ` [PATCH v2 00/14] qrb4210-rb2: add wsa audio playback and capture support Krzysztof Kozlowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=70647a37-6196-4179-803d-35add798fa0b@oss.qualcomm.com \
--to=konrad.dybcio@oss.qualcomm.com \
--cc=alexey.klimov@linaro.org \
--cc=andersson@kernel.org \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.baryshkov@linaro.org \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=robh@kernel.org \
--cc=srinivas.kandagatla@linaro.org \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®