From 465d003197328fcf5aa39b7a6b0f36ccf852e232 Mon Sep 17 00:00:00 2001 From: Niranjan H Y Date: Tue, 25 Aug 2026 12:47:46 +0530 Subject: [PATCH 1/4] ASoC: tac5xx2-sdw: add 5272 support --- sound/soc/codecs/tac5xx2-sdw.c | 127 ++++++++++++++++++++++------ sound/soc/sdw_utils/soc_sdw_utils.c | 30 +++++++ 2 files changed, 129 insertions(+), 28 deletions(-) diff --git a/sound/soc/codecs/tac5xx2-sdw.c b/sound/soc/codecs/tac5xx2-sdw.c index a5f654cde69fc4..f9139a64159132 100644 --- a/sound/soc/codecs/tac5xx2-sdw.c +++ b/sound/soc/codecs/tac5xx2-sdw.c @@ -1168,6 +1168,40 @@ static int tac_interrupt_callback(struct sdw_slave *slave, return 0; } +static struct snd_soc_dai_driver tac5272_dai_driver[] = { + { + .name = "tac5xx2-aif3", + .id = TAC5XX2_UAJ, + .playback = { + .stream_name = "DP4 UAJ Speaker Playback", + .channels_min = 1, + .channels_max = 2, + .rates = TAC5XX2_DEVICE_RATES, + .formats = TAC5XX2_DEVICE_FORMATS, + }, + .capture = { + .stream_name = "DP7 UAJ Mic Capture", + .channels_min = 1, + .channels_max = 2, + .rates = TAC5XX2_DEVICE_RATES, + .formats = TAC5XX2_DEVICE_FORMATS, + }, + .ops = &tac_dai_ops, + }, + { + .name = "tac5xx2-aif2", + .id = TAC5XX2_DMIC, + .capture = { + .stream_name = "DP3 Mic Capture", + .channels_min = 1, + .channels_max = 4, + .rates = TAC5XX2_DEVICE_RATES, + .formats = TAC5XX2_DEVICE_FORMATS, + }, + .ops = &tac_dai_ops, + }, +}; + static struct snd_soc_dai_driver tac5572_dai_driver[] = { { .name = "tac5xx2-aif1", @@ -1353,40 +1387,78 @@ static struct snd_soc_dai_driver tas2883_dai_driver[] = { static s32 tac_component_probe(struct snd_soc_component *component) { struct tac5xx2_prv *tac_dev = snd_soc_component_get_drvdata(component); + u32 part_id = tac_dev->part_id; int ret; ret = pm_runtime_resume(component->dev); if (ret < 0 && ret != -EACCES) return ret; - if (!tac_has_uaj_support(tac_dev)) - goto done_comp_probe; + switch (part_id) { + case 0x2883: + case 0x5272: + case 0x5572: + case 0x5672: + case 0x5682: + ret = snd_soc_dapm_new_controls(snd_soc_component_to_dapm(component), + tac5xx2_common_widgets, + ARRAY_SIZE(tac5xx2_common_widgets)); + if (ret) { + dev_err(component->dev, "Failed to add common widgets: %d\n", ret); + break; + } - ret = snd_soc_dapm_new_controls(snd_soc_component_to_dapm(component), - tac_uaj_widgets, - ARRAY_SIZE(tac_uaj_widgets)); - if (ret) { - dev_err(component->dev, "Failed to add UAJ widgets: %d\n", ret); - return ret; - } + ret = snd_soc_dapm_add_routes(snd_soc_component_to_dapm(component), + tac5xx2_common_routes, + ARRAY_SIZE(tac5xx2_common_routes)); + if (ret) { + dev_err(component->dev, "Failed to add common routes: %d\n", ret); + break; + } - ret = snd_soc_dapm_add_routes(snd_soc_component_to_dapm(component), - tac_uaj_routes, ARRAY_SIZE(tac_uaj_routes)); - if (ret) { - dev_err(component->dev, "Failed to add UAJ routes: %d\n", ret); - return ret; - } + ret = snd_soc_add_component_controls(component, tac5xx2_snd_controls, + ARRAY_SIZE(tac5xx2_snd_controls)); + if (ret) { + dev_err(component->dev, "Failed to add common controls: %d\n", ret); + break; + } - ret = snd_soc_add_component_controls(component, tac_uaj_controls, - ARRAY_SIZE(tac_uaj_controls)); - if (ret) { - dev_err(component->dev, "Failed to add UAJ controls: %d\n", ret); - return ret; + if (part_id == 0x2883) + break; + + if (!tac_has_uaj_support(tac_dev)) { + if (part_id == 0x5272) { + dev_err(component->dev, "tac5272 without UAJ support is invalid\n"); + ret = -EINVAL; + } + break; + } + + ret = snd_soc_dapm_new_controls(snd_soc_component_to_dapm(component), + tac_uaj_widgets, + ARRAY_SIZE(tac_uaj_widgets)); + if (ret) { + dev_err(component->dev, "Failed to add UAJ widgets: %d\n", ret); + break; + } + + ret = snd_soc_dapm_add_routes(snd_soc_component_to_dapm(component), + tac_uaj_routes, ARRAY_SIZE(tac_uaj_routes)); + if (ret) { + dev_err(component->dev, "Failed to add UAJ routes: %d\n", ret); + break; + } + + ret = snd_soc_add_component_controls(component, tac_uaj_controls, + ARRAY_SIZE(tac_uaj_controls)); + if (ret) + dev_err(component->dev, "Failed to add UAJ controls: %d\n", ret); + + break; } -done_comp_probe: tac_dev->component = component; - return 0; + return ret; } static void tac_component_remove(struct snd_soc_component *codec) @@ -1399,12 +1471,6 @@ static void tac_component_remove(struct snd_soc_component *codec) static const struct snd_soc_component_driver soc_codec_driver_tacdevice = { .probe = tac_component_probe, .remove = tac_component_remove, - .controls = tac5xx2_snd_controls, - .num_controls = ARRAY_SIZE(tac5xx2_snd_controls), - .dapm_widgets = tac5xx2_common_widgets, - .num_dapm_widgets = ARRAY_SIZE(tac5xx2_common_widgets), - .dapm_routes = tac5xx2_common_routes, - .num_dapm_routes = ARRAY_SIZE(tac5xx2_common_routes), .idle_bias_on = 0, .endianness = 1, }; @@ -1419,6 +1485,10 @@ static s32 tac_init(struct tac5xx2_prv *tac_dev) dev_set_drvdata(tac_dev->dev, tac_dev); switch (tac_dev->part_id) { + case 0x5272: + dai_drv = tac5272_dai_driver; + num_dais = ARRAY_SIZE(tac5272_dai_driver); + break; case 0x5572: dai_drv = tac5572_dai_driver; num_dais = ARRAY_SIZE(tac5572_dai_driver); @@ -2045,6 +2115,7 @@ static void tac_sdw_remove(struct sdw_slave *peripheral) } static const struct sdw_device_id tac_sdw_id[] = { + SDW_SLAVE_ENTRY(0x0102, 0x5272, 0), SDW_SLAVE_ENTRY(0x0102, 0x5572, 0), SDW_SLAVE_ENTRY(0x0102, 0x5672, 0), SDW_SLAVE_ENTRY(0x0102, 0x5682, 0), diff --git a/sound/soc/sdw_utils/soc_sdw_utils.c b/sound/soc/sdw_utils/soc_sdw_utils.c index 7a19de75f32b53..8862a15bdec772 100644 --- a/sound/soc/sdw_utils/soc_sdw_utils.c +++ b/sound/soc/sdw_utils/soc_sdw_utils.c @@ -81,6 +81,36 @@ static const struct snd_kcontrol_new rt700_controls[] = { }; struct asoc_sdw_codec_info codec_info_list[] = { + { + .vendor_id = 0x0102, + .part_id = 0x5272, + .name_prefix = "tac5272", + .dais = { + { + /* UAJ */ + .direction = {true, true}, + .dai_name = "tac5xx2-aif3", + .component_name = "tac5272", + .dai_type = SOC_SDW_DAI_TYPE_JACK, + .dailink = {SOC_SDW_JACK_OUT_DAI_ID, SOC_SDW_JACK_IN_DAI_ID}, + .controls = generic_jack_controls, + .num_controls = ARRAY_SIZE(generic_jack_controls), + .widgets = generic_jack_widgets, + .num_widgets = ARRAY_SIZE(generic_jack_widgets), + .rtd_init = asoc_sdw_ti_sdca_jack_rtd_init, + }, + { + /* mic (DMIC) */ + .direction = {false, true}, + .dai_name = "tac5xx2-aif2", + .component_name = "tac5272", + .dai_type = SOC_SDW_DAI_TYPE_MIC, + .dailink = {SOC_SDW_UNUSED_DAI_ID, SOC_SDW_DMIC_DAI_ID}, + .rtd_init = asoc_sdw_ti_dmic_rtd_init, + }, + }, + .dai_num = 2, + }, { .vendor_id = 0x0102, .part_id = 0x5572, From 2590319e458a86bd7e950526a265f3b1475de0a3 Mon Sep 17 00:00:00 2001 From: Niranjan H Y Date: Sat, 19 Sep 2026 18:45:40 +0530 Subject: [PATCH 2/4] ASoC: tac5xx2-sdw: correct default volume registers The volume doesn't get correctly updated when the volume in the mixer controls are updated to their default values as the regmap cache will not do HW write leading to unexpected behaviour. So correct them with the hardware defaults. Signed-off-by: Niranjan H Y --- sound/soc/codecs/tac5xx2-sdw.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/tac5xx2-sdw.c b/sound/soc/codecs/tac5xx2-sdw.c index f9139a64159132..e4dad288e01087 100644 --- a/sound/soc/codecs/tac5xx2-sdw.c +++ b/sound/soc/codecs/tac5xx2-sdw.c @@ -401,6 +401,8 @@ static const struct reg_default tac_reg_default[] = { {TAC_USAGE_REG(SM, OT113), 0x0}, {TAC_MUTE_REG(SM, FU113, LEFT), 0x1}, {TAC_MUTE_REG(SM, FU113, RIGHT), 0x1}, + {TAC_VOLUME_REG(SM, FU113, LEFT), 0x9c00}, + {TAC_VOLUME_REG(SM, FU113, RIGHT), 0x9c00}, {TAC_GAIN_REG(SM, FU113, LEFT), 0x0}, {TAC_GAIN_REG(SM, FU113, RIGHT), 0x0}, {TAC_MUTE_REG(SM, FU11, LEFT), 0x1}, @@ -417,11 +419,11 @@ static const struct reg_default tac_reg_default[] = { {TAC_USAGE_REG(UAJ, OT45), 0x0}, {TAC_MUTE_REG(UAJ, FU41, LEFT), 0x1}, {TAC_MUTE_REG(UAJ, FU41, RIGHT), 0x1}, - {TAC_VOLUME_REG(UAJ, FU41, LEFT), 0x0}, - {TAC_VOLUME_REG(UAJ, FU41, RIGHT), 0x0}, + {TAC_VOLUME_REG(UAJ, FU41, LEFT), 0x9c00}, + {TAC_VOLUME_REG(UAJ, FU41, RIGHT), 0x9c00}, {TAC_MUTE_REG(UAJ, FU36, RIGHT), 0x1}, {SDW_SDCA_CTL(TAC_FUNCTION_ID_UAJ, TAC_SDCA_ENT_FU36, - TAC_SDCA_CHANNEL_VOLUME, TAC_JACK_MONO_CS), 0x0}, + TAC_SDCA_CHANNEL_VOLUME, TAC_JACK_MONO_CS), 0x9c00}, {TAC_XU_BYPASS_REG(UAJ, XU42), 0x0}, {SDW_SDCA_CTL(TAC_FUNCTION_ID_UAJ, TAC_SDCA_ENT_CS36, TAC_SDCA_CTL_CS_SAMP_RATE_IDX, 0), 0x0}, From 50e94563493f84f98e5479d12d2a06ce8ba0d2f0 Mon Sep 17 00:00:00 2001 From: Niranjan H Y Date: Thu, 19 Nov 2026 14:51:37 +0530 Subject: [PATCH 3/4] ASoC: tac5xx2-sdw: initialize volume registers to 0 dBFS on first probe The SDCA volume registers power on at 0x9c00 (-100 dBFS in Q7.8 format) which is below the mixer control range (-72 dBFS to +6 dBFS). Write 0x0 (0 dBFS) to all volume registers on first probe so the initial HW state is within the valid range and consistent with the regmap cache. SA FU21 is already handled by the existing tac_spk_seq. Add tac_dmic_seq for SM FU113 and tac_uaj_seq for UAJ FU41/FU36. Signed-off-by: Niranjan H Y --- sound/soc/codecs/tac5xx2-sdw.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/sound/soc/codecs/tac5xx2-sdw.c b/sound/soc/codecs/tac5xx2-sdw.c index e4dad288e01087..84876077068e22 100644 --- a/sound/soc/codecs/tac5xx2-sdw.c +++ b/sound/soc/codecs/tac5xx2-sdw.c @@ -438,6 +438,18 @@ static const struct reg_sequence tac_spk_seq[] = { TAC_SDCA_CHANNEL_VOLUME, TAC_CHANNEL_RIGHT), 0), }; +static const struct reg_sequence tac_dmic_seq[] = { + REG_SEQ0(TAC_VOLUME_REG(SM, FU113, LEFT), 0), + REG_SEQ0(TAC_VOLUME_REG(SM, FU113, RIGHT), 0), +}; + +static const struct reg_sequence tac_uaj_seq[] = { + REG_SEQ0(TAC_VOLUME_REG(UAJ, FU41, LEFT), 0), + REG_SEQ0(TAC_VOLUME_REG(UAJ, FU41, RIGHT), 0), + REG_SEQ0(SDW_SDCA_CTL(TAC_FUNCTION_ID_UAJ, TAC_SDCA_ENT_FU36, + TAC_SDCA_CHANNEL_VOLUME, TAC_JACK_MONO_CS), 0), +}; + static bool tac_volatile_reg(struct device *dev, unsigned int reg) { switch (reg) { @@ -1855,6 +1867,15 @@ static int tac_io_init(struct device *dev, struct sdw_slave *slave, bool first) goto io_init_err; } dev_dbg(dev, "smartmic init done\n"); + + if (first) { + ret = regmap_multi_reg_write(tac_dev->regmap, tac_dmic_seq, + ARRAY_SIZE(tac_dmic_seq)); + if (ret) { + dev_err(dev, "dmic vol init failed, err=%d\n", ret); + goto io_init_err; + } + } } if (tac_dev->uaj_func_data) { @@ -1867,6 +1888,13 @@ static int tac_io_init(struct device *dev, struct sdw_slave *slave, bool first) dev_dbg(dev, "uaj init done\n"); if (first) { + ret = regmap_multi_reg_write(tac_dev->regmap, tac_uaj_seq, + ARRAY_SIZE(tac_uaj_seq)); + if (ret) { + dev_err(dev, "uaj vol init failed, err=%d\n", ret); + goto io_init_err; + } + if (tac_dev->hs_jack) { ret = tac5xx2_jack_init(tac_dev); if (ret) { From 78b5912fd6dc7a3ec392107a666e5ef13b23bc63 Mon Sep 17 00:00:00 2001 From: Niranjan H Y Date: Thu, 19 Nov 2026 22:00:52 +0530 Subject: [PATCH 4/4] ASoC: tac5xx2-sdw: drop DSP algo re-enable from port post-prepare The post port prepare callback was re-enabling the DSP algorithm by writing TAC_DSP_ALGO_STATUS_RUNNING if the algo was found not running. This is not needed as the algorithm state is managed independently of the stream prepare sequence. Remove tac_port_prep() and clear the .port_prep ops entry. Signed-off-by: Niranjan H Y --- sound/soc/codecs/tac5xx2-sdw.c | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/sound/soc/codecs/tac5xx2-sdw.c b/sound/soc/codecs/tac5xx2-sdw.c index 84876077068e22..6bca6b4e1a6f2b 100644 --- a/sound/soc/codecs/tac5xx2-sdw.c +++ b/sound/soc/codecs/tac5xx2-sdw.c @@ -1985,44 +1985,10 @@ static int tac5xx2_sdw_read_prop(struct sdw_slave *peripheral) return 0; } -static int tac_port_prep(struct sdw_slave *slave, struct sdw_prepare_ch *prep_ch, - enum sdw_port_prep_ops pre_ops) -{ - struct device *dev = &slave->dev; - struct tac5xx2_prv *tac_dev = dev_get_drvdata(dev); - unsigned int val; - int ret; - - if (pre_ops != SDW_OPS_PORT_POST_PREP) - return 0; - - if (!tac_dev->fw_dl_success) - return 0; - - ret = regmap_read(tac_dev->regmap, TAC_DSP_ALGO_STATUS, &val); - if (ret) { - dev_err(dev, "Failed to read algo status: %d\n", ret); - return ret; - } - - if (val != TAC_DSP_ALGO_STATUS_RUNNING) { - dev_dbg(dev, "Algo not running (0x%02x), re-enabling\n", val); - ret = regmap_write(tac_dev->regmap, TAC_DSP_ALGO_STATUS, - TAC_DSP_ALGO_STATUS_RUNNING); - if (ret) { - dev_err(dev, "Failed to re-enable algo: %d\n", ret); - return ret; - } - } - - return 0; -} - static const struct sdw_slave_ops tac_sdw_ops = { .read_prop = tac5xx2_sdw_read_prop, .update_status = tac_update_status, .interrupt_callback = tac_interrupt_callback, - .port_prep = tac_port_prep, }; static s32 tac_sdw_probe(struct sdw_slave *peripheral,