[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ld3s5vbjjigkbesnyccyxohnekgbwkbae7zwmjd7u23km3f5fq@awxsaee7yj6m>
Date: Fri, 22 Aug 2025 14:32:48 +0300
From: Dmitry Baryshkov <dmitry.baryshkov@....qualcomm.com>
To: Srinivas Kandagatla <srinivas.kandagatla@....qualcomm.com>
Cc: broonie@...nel.org, perex@...ex.cz, tiwai@...e.com, srini@...nel.org,
lgirdwood@...il.com, linux-sound@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-arm-msm@...r.kernel.org,
krzysztof.kozlowski@...aro.org, neil.armstrong@...aro.org
Subject: Re: [PATCH v2 6/8] ASoC: codecs: wcd-common: move status_update
callback to common
On Fri, Aug 22, 2025 at 11:49:25AM +0100, Srinivas Kandagatla wrote:
> Soundwire update_status, bus_config and interrupt callbacks for wcd937x,
> wcd938x, wcd939x soundwire codecs are exactly identlical, move them to
> common driver to remove this duplicate code.
>
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@....qualcomm.com>
> ---
> sound/soc/codecs/wcd-common.c | 46 ++++++++++++++++++++++++++++++++++
> sound/soc/codecs/wcd-common.h | 10 ++++++++
> sound/soc/codecs/wcd937x-sdw.c | 28 +++------------------
> sound/soc/codecs/wcd938x-sdw.c | 41 +++---------------------------
> sound/soc/codecs/wcd939x-sdw.c | 42 +++----------------------------
> 5 files changed, 67 insertions(+), 100 deletions(-)
>
> diff --git a/sound/soc/codecs/wcd-common.c b/sound/soc/codecs/wcd-common.c
> index 0c1ffa015403..2592e8ed2d13 100644
> --- a/sound/soc/codecs/wcd-common.c
> +++ b/sound/soc/codecs/wcd-common.c
> @@ -9,9 +9,14 @@
> #include <linux/printk.h>
> #include <linux/component.h>
> #include <linux/pm_runtime.h>
> +#include <linux/soundwire/sdw.h>
> +#include <linux/soundwire/sdw_type.h>
> +#include <linux/regmap.h>
>
> #include "wcd-common.h"
>
> +#define SWRS_SCP_HOST_CLK_DIV2_CTL_BANK(m) (0xE0 + 0x10 * (m))
> +
> int wcd_get_micb_vout_ctl_val(struct device *dev, u32 micb_mv)
> {
> /* min micbias voltage is 1V and maximum is 2.85V */
> @@ -89,5 +94,46 @@ const struct component_ops wcd_sdw_component_ops = {
> };
> EXPORT_SYMBOL_GPL(wcd_sdw_component_ops);
>
> +int wcd_update_status(struct sdw_slave *slave, enum sdw_slave_status status)
> +{
> + struct regmap *regmap = dev_get_regmap(&slave->dev, NULL);
> +
> + if (regmap && status == SDW_SLAVE_ATTACHED) {
> + /* Write out any cached changes that happened between probe and attach */
> + regcache_cache_only(regmap, false);
> + return regcache_sync(regmap);
> + }
> +
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(wcd_update_status);
> +
> +int wcd_bus_config(struct sdw_slave *slave, struct sdw_bus_params *params)
> +{
> + sdw_write(slave, SWRS_SCP_HOST_CLK_DIV2_CTL_BANK(params->next_bank), 0x01);
> +
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(wcd_bus_config);
> +
> +int wcd_interrupt_callback(struct sdw_slave *slave, struct irq_domain *slave_irq,
> + unsigned int wcd_intr_status0, unsigned int wcd_intr_status1,
> + unsigned int wcd_intr_status2)
> +{
> + struct regmap *regmap = dev_get_regmap(&slave->dev, NULL);
> + u32 sts1, sts2, sts3;
> +
> + do {
> + handle_nested_irq(irq_find_mapping(slave_irq, 0));
> + regmap_read(regmap, wcd_intr_status0, &sts1);
> + regmap_read(regmap, wcd_intr_status1, &sts2);
> + regmap_read(regmap, wcd_intr_status2, &sts3);
> +
> + } while (sts1 || sts2 || sts3);
> +
> + return IRQ_HANDLED;
> +}
> +EXPORT_SYMBOL_GPL(wcd_interrupt_callback);
> +
> MODULE_DESCRIPTION("Common Qualcomm WCD Codec helpers driver");
> MODULE_LICENSE("GPL");
> diff --git a/sound/soc/codecs/wcd-common.h b/sound/soc/codecs/wcd-common.h
> index deb78241236b..0cb6365bea4b 100644
> --- a/sound/soc/codecs/wcd-common.h
> +++ b/sound/soc/codecs/wcd-common.h
> @@ -6,11 +6,16 @@
> #ifndef __WCD_COMMON_H__
> #define __WCD_COMMON_H___
>
> +#include <linux/device.h>
> +#include <linux/soundwire/sdw.h>
Just forward-declare structures, there is no need for includes.
> +
> #define WCD_MIN_MICBIAS_MV 1000
> #define WCD_DEF_MICBIAS_MV 1800
> #define WCD_MAX_MICBIAS_MV 2850
> #define WCD_MAX_MICBIAS 4
>
> +
> +
Extra empty lines.
> struct wcd_sdw_ch_info {
> int port_num;
> unsigned int ch_mask;
> @@ -32,5 +37,10 @@ struct wcd_common {
> extern const struct component_ops wcd_sdw_component_ops;
> int wcd_get_micb_vout_ctl_val(struct device *dev, u32 micb_mv);
> int wcd_dt_parse_micbias_info(struct wcd_common *common);
> +int wcd_update_status(struct sdw_slave *slave, enum sdw_slave_status status);
> +int wcd_bus_config(struct sdw_slave *slave, struct sdw_bus_params *params);
> +int wcd_interrupt_callback(struct sdw_slave *slave, struct irq_domain *slave_irq,
> + unsigned int wcd_intr_status0, unsigned int wcd_intr_status1,
> + unsigned int wcd_intr_status2);
>
> #endif /* __WCD_COMMON_H___ */
--
With best wishes
Dmitry
Powered by blists - more mailing lists