aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--sound/soc/amd/acp-es8336.c4
-rw-r--r--sound/soc/codecs/ak4458.c11
-rw-r--r--sound/soc/codecs/tas2781-i2c.c29
-rw-r--r--sound/soc/codecs/tas5086.c27
-rw-r--r--sound/soc/codecs/wcd939x.c113
-rw-r--r--sound/soc/sof/ipc4-topology.c29
6 files changed, 115 insertions, 98 deletions
diff --git a/sound/soc/amd/acp-es8336.c b/sound/soc/amd/acp-es8336.c
index e079b3218c6f..3756b8bef17b 100644
--- a/sound/soc/amd/acp-es8336.c
+++ b/sound/soc/amd/acp-es8336.c
@@ -203,8 +203,10 @@ static int st_es8336_late_probe(struct snd_soc_card *card)
codec_dev = acpi_get_first_physical_node(adev);
acpi_dev_put(adev);
- if (!codec_dev)
+ if (!codec_dev) {
dev_err(card->dev, "can not find codec dev\n");
+ return -ENODEV;
+ }
ret = devm_acpi_dev_add_driver_gpios(codec_dev, acpi_es8336_gpios);
if (ret)
diff --git a/sound/soc/codecs/ak4458.c b/sound/soc/codecs/ak4458.c
index 32cb802ad635..d472d9952628 100644
--- a/sound/soc/codecs/ak4458.c
+++ b/sound/soc/codecs/ak4458.c
@@ -45,7 +45,6 @@ struct ak4458_priv {
const struct ak4458_drvdata *drvdata;
struct device *dev;
struct regmap *regmap;
- struct gpio_desc *reset_gpiod;
struct reset_control *reset;
struct gpio_desc *mute_gpiod;
int digfil; /* SSLOW, SD, SLOW bits */
@@ -631,10 +630,7 @@ static struct snd_soc_dai_driver ak4497_dai = {
static void ak4458_reset(struct ak4458_priv *ak4458, bool active)
{
- if (ak4458->reset_gpiod) {
- gpiod_set_value_cansleep(ak4458->reset_gpiod, active);
- usleep_range(1000, 2000);
- } else if (!IS_ERR_OR_NULL(ak4458->reset)) {
+ if (!IS_ERR_OR_NULL(ak4458->reset)) {
if (active)
reset_control_assert(ak4458->reset);
else
@@ -758,11 +754,6 @@ static int ak4458_i2c_probe(struct i2c_client *i2c)
if (IS_ERR(ak4458->reset))
return PTR_ERR(ak4458->reset);
- ak4458->reset_gpiod = devm_gpiod_get_optional(ak4458->dev, "reset",
- GPIOD_OUT_LOW);
- if (IS_ERR(ak4458->reset_gpiod))
- return PTR_ERR(ak4458->reset_gpiod);
-
ak4458->mute_gpiod = devm_gpiod_get_optional(ak4458->dev, "mute",
GPIOD_OUT_LOW);
if (IS_ERR(ak4458->mute_gpiod))
diff --git a/sound/soc/codecs/tas2781-i2c.c b/sound/soc/codecs/tas2781-i2c.c
index e0e630f66101..b412f8f2e5d5 100644
--- a/sound/soc/codecs/tas2781-i2c.c
+++ b/sound/soc/codecs/tas2781-i2c.c
@@ -104,7 +104,7 @@ static int tas2781_amp_putvol(struct snd_kcontrol *kcontrol,
return tasdevice_amp_putvol(tas_priv, ucontrol, mc);
}
-static int tas2781_force_fwload_get(struct snd_kcontrol *kcontrol,
+static int tasdev_force_fwload_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *component =
@@ -119,7 +119,7 @@ static int tas2781_force_fwload_get(struct snd_kcontrol *kcontrol,
return 0;
}
-static int tas2781_force_fwload_put(struct snd_kcontrol *kcontrol,
+static int tasdev_force_fwload_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *component =
@@ -140,6 +140,11 @@ static int tas2781_force_fwload_put(struct snd_kcontrol *kcontrol,
return change;
}
+static const struct snd_kcontrol_new tasdevice_snd_controls[] = {
+ SOC_SINGLE_BOOL_EXT("Speaker Force Firmware Load", 0,
+ tasdev_force_fwload_get, tasdev_force_fwload_put),
+};
+
static const struct snd_kcontrol_new tas2781_snd_controls[] = {
SOC_SINGLE_RANGE_EXT_TLV("Speaker Analog Gain", TAS2781_AMP_LEVEL,
1, 0, 20, 0, tas2781_amp_getvol,
@@ -147,8 +152,6 @@ static const struct snd_kcontrol_new tas2781_snd_controls[] = {
SOC_SINGLE_RANGE_EXT_TLV("Speaker Digital Gain", TAS2781_DVC_LVL,
0, 0, 200, 1, tas2781_digital_getvol,
tas2781_digital_putvol, dvc_tlv),
- SOC_SINGLE_BOOL_EXT("Speaker Force Firmware Load", 0,
- tas2781_force_fwload_get, tas2781_force_fwload_put),
};
static int tasdevice_set_profile_id(struct snd_kcontrol *kcontrol,
@@ -590,6 +593,18 @@ static struct snd_soc_dai_driver tasdevice_dai_driver[] = {
static int tasdevice_codec_probe(struct snd_soc_component *codec)
{
struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(codec);
+ int rc;
+
+ if (tas_priv->chip_id == TAS2781) {
+ rc = snd_soc_add_component_controls(codec,
+ tas2781_snd_controls,
+ ARRAY_SIZE(tas2781_snd_controls));
+ if (rc < 0) {
+ dev_err(tas_priv->dev, "%s: Add control err rc = %d",
+ __func__, rc);
+ return rc;
+ }
+ }
tas_priv->name_prefix = codec->name_prefix;
return tascodec_init(tas_priv, codec, THIS_MODULE, tasdevice_fw_ready);
@@ -617,8 +632,8 @@ static const struct snd_soc_component_driver
soc_codec_driver_tasdevice = {
.probe = tasdevice_codec_probe,
.remove = tasdevice_codec_remove,
- .controls = tas2781_snd_controls,
- .num_controls = ARRAY_SIZE(tas2781_snd_controls),
+ .controls = tasdevice_snd_controls,
+ .num_controls = ARRAY_SIZE(tasdevice_snd_controls),
.dapm_widgets = tasdevice_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(tasdevice_dapm_widgets),
.dapm_routes = tasdevice_audio_map,
@@ -759,7 +774,7 @@ MODULE_DEVICE_TABLE(acpi, tasdevice_acpi_match);
static struct i2c_driver tasdevice_i2c_driver = {
.driver = {
- .name = "tas2781-codec",
+ .name = "tasdev-codec",
.of_match_table = of_match_ptr(tasdevice_of_match),
#ifdef CONFIG_ACPI
.acpi_match_table = ACPI_PTR(tasdevice_acpi_match),
diff --git a/sound/soc/codecs/tas5086.c b/sound/soc/codecs/tas5086.c
index 6d45df3b9ba4..4bc1fdd232bb 100644
--- a/sound/soc/codecs/tas5086.c
+++ b/sound/soc/codecs/tas5086.c
@@ -24,14 +24,13 @@
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/delay.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/spi/spi.h>
#include <linux/of.h>
#include <linux/of_device.h>
-#include <linux/of_gpio.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
@@ -246,7 +245,7 @@ struct tas5086_private {
/* Current sample rate for de-emphasis control */
int rate;
/* GPIO driving Reset pin, if any */
- int gpio_nreset;
+ struct gpio_desc *reset;
struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)];
};
@@ -462,11 +461,11 @@ static int tas5086_mute_stream(struct snd_soc_dai *dai, int mute, int stream)
static void tas5086_reset(struct tas5086_private *priv)
{
- if (gpio_is_valid(priv->gpio_nreset)) {
+ if (priv->reset) {
/* Reset codec - minimum assertion time is 400ns */
- gpio_direction_output(priv->gpio_nreset, 0);
+ gpiod_direction_output(priv->reset, 1);
udelay(1);
- gpio_set_value(priv->gpio_nreset, 1);
+ gpiod_set_value(priv->reset, 0);
/* Codec needs ~15ms to wake up */
msleep(15);
@@ -867,9 +866,9 @@ static void tas5086_remove(struct snd_soc_component *component)
{
struct tas5086_private *priv = snd_soc_component_get_drvdata(component);
- if (gpio_is_valid(priv->gpio_nreset))
+ if (priv->reset)
/* Set codec to the reset state */
- gpio_set_value(priv->gpio_nreset, 0);
+ gpiod_set_value(priv->reset, 1);
regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies);
};
@@ -914,7 +913,6 @@ static int tas5086_i2c_probe(struct i2c_client *i2c)
{
struct tas5086_private *priv;
struct device *dev = &i2c->dev;
- int gpio_nreset = -EINVAL;
int i, ret;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
@@ -940,12 +938,11 @@ static int tas5086_i2c_probe(struct i2c_client *i2c)
i2c_set_clientdata(i2c, priv);
- gpio_nreset = of_get_named_gpio(dev->of_node, "reset-gpio", 0);
- if (gpio_is_valid(gpio_nreset))
- if (devm_gpio_request(dev, gpio_nreset, "TAS5086 Reset"))
- gpio_nreset = -EINVAL;
-
- priv->gpio_nreset = gpio_nreset;
+ /* Request line asserted */
+ priv->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
+ if (IS_ERR(priv->reset))
+ return PTR_ERR(priv->reset);
+ gpiod_set_consumer_name(priv->reset, "TAS5086 Reset");
ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies);
if (ret < 0) {
diff --git a/sound/soc/codecs/wcd939x.c b/sound/soc/codecs/wcd939x.c
index 66af035bd0e5..68fc591670dc 100644
--- a/sound/soc/codecs/wcd939x.c
+++ b/sound/soc/codecs/wcd939x.c
@@ -181,8 +181,6 @@ struct wcd939x_priv {
/* typec handling */
bool typec_analog_mux;
#if IS_ENABLED(CONFIG_TYPEC)
- struct typec_mux_dev *typec_mux;
- struct typec_switch_dev *typec_sw;
enum typec_orientation typec_orientation;
unsigned long typec_mode;
struct typec_switch *typec_switch;
@@ -3519,6 +3517,68 @@ static const struct component_master_ops wcd939x_comp_ops = {
.unbind = wcd939x_unbind,
};
+static void __maybe_unused wcd939x_typec_mux_unregister(void *data)
+{
+ struct typec_mux_dev *typec_mux = data;
+
+ typec_mux_unregister(typec_mux);
+}
+
+static void __maybe_unused wcd939x_typec_switch_unregister(void *data)
+{
+ struct typec_switch_dev *typec_sw = data;
+
+ typec_switch_unregister(typec_sw);
+}
+
+static int wcd939x_add_typec(struct wcd939x_priv *wcd939x, struct device *dev)
+{
+#if IS_ENABLED(CONFIG_TYPEC)
+ int ret;
+ struct typec_mux_dev *typec_mux;
+ struct typec_switch_dev *typec_sw;
+ struct typec_mux_desc mux_desc = {
+ .drvdata = wcd939x,
+ .fwnode = dev_fwnode(dev),
+ .set = wcd939x_typec_mux_set,
+ };
+ struct typec_switch_desc sw_desc = {
+ .drvdata = wcd939x,
+ .fwnode = dev_fwnode(dev),
+ .set = wcd939x_typec_switch_set,
+ };
+
+ /*
+ * Is USBSS is used to mux analog lines,
+ * register a typec mux/switch to get typec events
+ */
+ if (!wcd939x->typec_analog_mux)
+ return 0;
+
+ typec_mux = typec_mux_register(dev, &mux_desc);
+ if (IS_ERR(typec_mux))
+ return dev_err_probe(dev, PTR_ERR(typec_mux),
+ "failed to register typec mux\n");
+
+ ret = devm_add_action_or_reset(dev, wcd939x_typec_mux_unregister,
+ typec_mux);
+ if (ret)
+ return ret;
+
+ typec_sw = typec_switch_register(dev, &sw_desc);
+ if (IS_ERR(typec_sw))
+ return dev_err_probe(dev, PTR_ERR(typec_sw),
+ "failed to register typec switch\n");
+
+ ret = devm_add_action_or_reset(dev, wcd939x_typec_switch_unregister,
+ typec_sw);
+ if (ret)
+ return ret;
+#endif
+
+ return 0;
+}
+
static int wcd939x_add_slave_components(struct wcd939x_priv *wcd939x,
struct device *dev,
struct component_match **matchptr)
@@ -3567,42 +3627,13 @@ static int wcd939x_probe(struct platform_device *pdev)
return -EINVAL;
}
-#if IS_ENABLED(CONFIG_TYPEC)
- /*
- * Is USBSS is used to mux analog lines,
- * register a typec mux/switch to get typec events
- */
- if (wcd939x->typec_analog_mux) {
- struct typec_mux_desc mux_desc = {
- .drvdata = wcd939x,
- .fwnode = dev_fwnode(dev),
- .set = wcd939x_typec_mux_set,
- };
- struct typec_switch_desc sw_desc = {
- .drvdata = wcd939x,
- .fwnode = dev_fwnode(dev),
- .set = wcd939x_typec_switch_set,
- };
-
- wcd939x->typec_mux = typec_mux_register(dev, &mux_desc);
- if (IS_ERR(wcd939x->typec_mux)) {
- ret = dev_err_probe(dev, PTR_ERR(wcd939x->typec_mux),
- "failed to register typec mux\n");
- goto err_disable_regulators;
- }
-
- wcd939x->typec_sw = typec_switch_register(dev, &sw_desc);
- if (IS_ERR(wcd939x->typec_sw)) {
- ret = dev_err_probe(dev, PTR_ERR(wcd939x->typec_sw),
- "failed to register typec switch\n");
- goto err_unregister_typec_mux;
- }
- }
-#endif /* CONFIG_TYPEC */
+ ret = wcd939x_add_typec(wcd939x, dev);
+ if (ret)
+ goto err_disable_regulators;
ret = wcd939x_add_slave_components(wcd939x, dev, &match);
if (ret)
- goto err_unregister_typec_switch;
+ goto err_disable_regulators;
wcd939x_reset(wcd939x);
@@ -3619,18 +3650,6 @@ static int wcd939x_probe(struct platform_device *pdev)
return 0;
-#if IS_ENABLED(CONFIG_TYPEC)
-err_unregister_typec_mux:
- if (wcd939x->typec_analog_mux)
- typec_mux_unregister(wcd939x->typec_mux);
-#endif /* CONFIG_TYPEC */
-
-err_unregister_typec_switch:
-#if IS_ENABLED(CONFIG_TYPEC)
- if (wcd939x->typec_analog_mux)
- typec_switch_unregister(wcd939x->typec_sw);
-#endif /* CONFIG_TYPEC */
-
err_disable_regulators:
regulator_bulk_disable(WCD939X_MAX_SUPPLY, wcd939x->supplies);
regulator_bulk_free(WCD939X_MAX_SUPPLY, wcd939x->supplies);
diff --git a/sound/soc/sof/ipc4-topology.c b/sound/soc/sof/ipc4-topology.c
index 7755c01735f5..90f6856ee80c 100644
--- a/sound/soc/sof/ipc4-topology.c
+++ b/sound/soc/sof/ipc4-topology.c
@@ -3307,14 +3307,17 @@ static int sof_ipc4_link_setup(struct snd_sof_dev *sdev, struct snd_soc_dai_link
return 0;
}
-static enum sof_tokens common_copier_token_list[] = {
+/* Tokens needed for different copier variants (aif, dai and buffer) */
+static enum sof_tokens copier_token_list[] = {
SOF_COMP_TOKENS,
+ SOF_COPIER_TOKENS,
SOF_AUDIO_FMT_NUM_TOKENS,
SOF_IN_AUDIO_FORMAT_TOKENS,
SOF_OUT_AUDIO_FORMAT_TOKENS,
- SOF_COPIER_DEEP_BUFFER_TOKENS,
- SOF_COPIER_TOKENS,
SOF_COMP_EXT_TOKENS,
+
+ SOF_COPIER_DEEP_BUFFER_TOKENS, /* for AIF copier */
+ SOF_DAI_TOKENS, /* for DAI copier */
};
static enum sof_tokens pipeline_token_list[] = {
@@ -3322,16 +3325,6 @@ static enum sof_tokens pipeline_token_list[] = {
SOF_PIPELINE_TOKENS,
};
-static enum sof_tokens dai_token_list[] = {
- SOF_COMP_TOKENS,
- SOF_AUDIO_FMT_NUM_TOKENS,
- SOF_IN_AUDIO_FORMAT_TOKENS,
- SOF_OUT_AUDIO_FORMAT_TOKENS,
- SOF_COPIER_TOKENS,
- SOF_DAI_TOKENS,
- SOF_COMP_EXT_TOKENS,
-};
-
static enum sof_tokens pga_token_list[] = {
SOF_COMP_TOKENS,
SOF_GAIN_TOKENS,
@@ -3368,23 +3361,23 @@ static enum sof_tokens process_token_list[] = {
static const struct sof_ipc_tplg_widget_ops tplg_ipc4_widget_ops[SND_SOC_DAPM_TYPE_COUNT] = {
[snd_soc_dapm_aif_in] = {sof_ipc4_widget_setup_pcm, sof_ipc4_widget_free_comp_pcm,
- common_copier_token_list, ARRAY_SIZE(common_copier_token_list),
+ copier_token_list, ARRAY_SIZE(copier_token_list),
NULL, sof_ipc4_prepare_copier_module,
sof_ipc4_unprepare_copier_module},
[snd_soc_dapm_aif_out] = {sof_ipc4_widget_setup_pcm, sof_ipc4_widget_free_comp_pcm,
- common_copier_token_list, ARRAY_SIZE(common_copier_token_list),
+ copier_token_list, ARRAY_SIZE(copier_token_list),
NULL, sof_ipc4_prepare_copier_module,
sof_ipc4_unprepare_copier_module},
[snd_soc_dapm_dai_in] = {sof_ipc4_widget_setup_comp_dai, sof_ipc4_widget_free_comp_dai,
- dai_token_list, ARRAY_SIZE(dai_token_list), NULL,
+ copier_token_list, ARRAY_SIZE(copier_token_list), NULL,
sof_ipc4_prepare_copier_module,
sof_ipc4_unprepare_copier_module},
[snd_soc_dapm_dai_out] = {sof_ipc4_widget_setup_comp_dai, sof_ipc4_widget_free_comp_dai,
- dai_token_list, ARRAY_SIZE(dai_token_list), NULL,
+ copier_token_list, ARRAY_SIZE(copier_token_list), NULL,
sof_ipc4_prepare_copier_module,
sof_ipc4_unprepare_copier_module},
[snd_soc_dapm_buffer] = {sof_ipc4_widget_setup_pcm, sof_ipc4_widget_free_comp_pcm,
- common_copier_token_list, ARRAY_SIZE(common_copier_token_list),
+ copier_token_list, ARRAY_SIZE(copier_token_list),
NULL, sof_ipc4_prepare_copier_module,
sof_ipc4_unprepare_copier_module},
[snd_soc_dapm_scheduler] = {sof_ipc4_widget_setup_comp_pipeline,