* [PATCH v2] ASoC: tas2783-sdw: add firmware download status check
@ 2026-08-13 2:14 Baojun Xu
2026-08-13 22:19 ` Mark Brown
0 siblings, 1 reply; 5+ messages in thread
From: Baojun Xu @ 2026-08-13 2:14 UTC (permalink / raw)
To: broonie
Cc: tiwai, andriy.shevchenko, 13916275206, alsa-devel, shenghao-ding,
baojun.xu, linux-sound, linux-kernel, k-yi, henry.lo, robinchen,
niranjan.hy, pin-hao.huang, Syed.SabaKareem
Currently, the firmware download is unnecessarily triggered on every
system resume from suspend, causing significant wake-up latency. However,
this step is redundant if the AMP remains powered on. Furthermore, certain
memory pages (addresses > 0xc60000) are skipped even after an AMP reset.
Signed-off-by: Baojun Xu <baojun.xu@ti.com>
---
v2:
- Update register address from 0x07 to 7 and keep the line within the
80-character limit.
- Remove stray/unnecessary changes.
- Change variable type to unsigned int to comply with API requirements.
- Replace usleep_range() with fsleep().
- Set idle_bias_on to 0 to enable low-power mode.
- Reactivate the AMP after resume.
---
sound/soc/codecs/tas2783-sdw.c | 55 ++++++++++++++++++++--------------
1 file changed, 33 insertions(+), 22 deletions(-)
diff --git a/sound/soc/codecs/tas2783-sdw.c b/sound/soc/codecs/tas2783-sdw.c
index c217da5fccdf..8fc679d460d9 100644
--- a/sound/soc/codecs/tas2783-sdw.c
+++ b/sound/soc/codecs/tas2783-sdw.c
@@ -97,6 +97,7 @@ struct tas2783_prv {
u8 rca_binaryname[64];
u8 dev_name[32];
bool hw_init;
+ bool first_hw_init;
/* wq for firmware download */
wait_queue_head_t fw_wait;
bool fw_dl_task_done;
@@ -783,14 +784,16 @@ static void tas2783_fw_ready(const struct firmware *fmw, void *context)
file->version, file->length,
file->dest_addr, file->fw_data);
- ret = sdw_nwrite_no_pm(tas_dev->sdw_peripheral,
- file->dest_addr,
- file->length,
- file->fw_data);
- if (ret < 0) {
- dev_err(tas_dev->dev,
- "FW download failed: %d", ret);
- break;
+ if (!tas_dev->first_hw_init || file->dest_addr < 0xc60000) {
+ ret = sdw_nwrite_no_pm(tas_dev->sdw_peripheral,
+ file->dest_addr,
+ file->length,
+ file->fw_data);
+ if (ret < 0) {
+ dev_err(tas_dev->dev,
+ "FW download failed: %d", ret);
+ break;
+ }
}
cur_file++;
}
@@ -801,6 +804,8 @@ static void tas2783_fw_ready(const struct firmware *fmw, void *context)
ret = -EINVAL;
} else {
tas2783_update_calibdata(tas_dev);
+ regmap_write(tas_dev->regmap, TASDEV_REG_SDW(0, 0, 7), 0x22);
+ tas_dev->first_hw_init = true;
}
out:
@@ -940,7 +945,7 @@ static s32 tas_sdw_hw_params(struct snd_pcm_substream *substream,
TAS2783_SDCA_POW_STATE_ON);
if (!ret)
break;
- usleep_range(2000, 2200);
+ fsleep(2200);
} while (retry--);
}
@@ -1038,7 +1043,7 @@ static const struct snd_soc_component_driver soc_codec_driver_tasdevice = {
.num_dapm_widgets = ARRAY_SIZE(tas_dapm_widgets),
.dapm_routes = tas_audio_map,
.num_dapm_routes = ARRAY_SIZE(tas_audio_map),
- .idle_bias_on = 1,
+ .idle_bias_on = 0,
.endianness = 1,
};
@@ -1171,25 +1176,29 @@ static s32 tas_fw_load(struct tas2783_prv *tas_dev, struct sdw_slave *slave)
static s32 tas_io_init(struct device *dev, struct sdw_slave *slave)
{
struct tas2783_prv *tas_dev = dev_get_drvdata(dev);
+ unsigned int val;
s32 ret;
if (tas_dev->hw_init)
return 0;
- tas_dev->fw_dl_success = false;
+ regmap_read(tas_dev->regmap, TASDEV_REG_SDW(0, 0, 7), &val);
+ /* Check if the AMP is in reset status. */
+ if (val == 0x20) {
+ tas_dev->fw_dl_success = false;
- ret = regmap_write(tas_dev->regmap, TAS2783_SW_RESET, 0x1);
- if (ret) {
- dev_err(dev, "sw reset failed, err=%d", ret);
- return ret;
- }
- usleep_range(2000, 2200);
+ ret = regmap_write(tas_dev->regmap, TAS2783_SW_RESET, 0x1);
+ if (ret) {
+ dev_err(dev, "sw reset failed, err=%d", ret);
+ return ret;
+ }
+ fsleep(2200);
- tas_dev->fw_use_fallback = false;
- ret = tas_fw_load(tas_dev, slave);
- if (!ret && tas_dev->fw_use_fallback)
+ tas_dev->fw_use_fallback = false;
ret = tas_fw_load(tas_dev, slave);
-
+ if (!ret && tas_dev->fw_use_fallback)
+ ret = tas_fw_load(tas_dev, slave);
+ }
if (!ret) {
if (tas_dev->sa_func_data)
ret = sdca_regmap_write_init(dev, tas_dev->regmap,
@@ -1197,7 +1206,8 @@ static s32 tas_io_init(struct device *dev, struct sdw_slave *slave)
else
ret = regmap_multi_reg_write(tas_dev->regmap, tas2783_init_seq,
ARRAY_SIZE(tas2783_init_seq));
-
+ /* Re-active AMP after resume. */
+ regmap_write(tas_dev->regmap, TASDEV_REG_SDW(0, 0, 2), 0);
if (ret)
dev_err(tas_dev->dev,
"init writes failed, err=%d", ret);
@@ -1357,6 +1367,7 @@ static s32 tas_sdw_probe(struct sdw_slave *peripheral,
tas_dev->dev = dev;
tas_dev->sdw_peripheral = peripheral;
tas_dev->hw_init = false;
+ tas_dev->first_hw_init = false;
mutex_init(&tas_dev->calib_lock);
mutex_init(&tas_dev->pde_lock);
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] ASoC: tas2783-sdw: add firmware download status check
2026-08-13 2:14 [PATCH v2] ASoC: tas2783-sdw: add firmware download status check Baojun Xu
@ 2026-08-13 22:19 ` Mark Brown
2026-08-14 3:45 ` Xu, Baojun
2026-08-14 3:51 ` Xu, Baojun
0 siblings, 2 replies; 5+ messages in thread
From: Mark Brown @ 2026-08-13 22:19 UTC (permalink / raw)
To: Baojun Xu
Cc: tiwai, andriy.shevchenko, 13916275206, alsa-devel, shenghao-ding,
linux-sound, linux-kernel, k-yi, henry.lo, robinchen, niranjan.hy,
pin-hao.huang, Syed.SabaKareem
[-- Attachment #1: Type: text/plain, Size: 730 bytes --]
On Thu, Aug 13, 2026 at 10:14:50AM +0800, Baojun Xu wrote:
> Currently, the firmware download is unnecessarily triggered on every
> system resume from suspend, causing significant wake-up latency. However,
> this step is redundant if the AMP remains powered on. Furthermore, certain
> memory pages (addresses > 0xc60000) are skipped even after an AMP reset.
> + if (!tas_dev->first_hw_init || file->dest_addr < 0xc60000) {
> + ret = sdw_nwrite_no_pm(tas_dev->sdw_peripheral,
> + file->dest_addr,
> + file->length,
> + file->fw_data);
What happens if the amplifier uses power (eg, over a system suspend)?
Though since nothing clears first_hw_init I guess there might be issues
there anyway...
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Re: [PATCH v2] ASoC: tas2783-sdw: add firmware download status check
2026-08-13 22:19 ` Mark Brown
@ 2026-08-14 3:45 ` Xu, Baojun
2026-08-14 11:23 ` Mark Brown
2026-08-14 3:51 ` Xu, Baojun
1 sibling, 1 reply; 5+ messages in thread
From: Xu, Baojun @ 2026-08-14 3:45 UTC (permalink / raw)
To: Mark Brown
Cc: tiwai@suse.de, andriy.shevchenko@linux.intel.com,
13916275206@139.com, alsa-devel@alsa-project.org, Ding, Shenghao,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
Yi, Ken, Lo, Henry, Chen, Robin, Holalu Yogendra, Niranjan,
pin-hao.huang@hp.com, Syed.SabaKareem@amd.com
> On Thu, Aug 13, 2026 at 10:14:50AM +0800, Baojun Xu wrote:
> > Currently, the firmware download is unnecessarily triggered on every
> > system resume from suspend, causing significant wake-up latency. However,
> > this step is redundant if the AMP remains powered on. Furthermore, certain
> > memory pages (addresses > 0xc60000) are skipped even after an AMP reset.
>
> > + if (!tas_dev->first_hw_init || file->dest_addr < 0xc60000) {
> > + ret = sdw_nwrite_no_pm(tas_dev->sdw_peripheral,
> > + file->dest_addr,
> > + file->length,
> + file->fw_data);
>
> What happens if the amplifier uses power (eg, over a system suspend)?
> Though since nothing clears first_hw_init I guess there might be issues
> there anyway...
Hi Mark,
Yes, that is the purpose of this patch. It prevents the re-downloading of
pages above 0xC60000 after resuming from suspend, as the data in this region
persists across an AMP reset. Therefore, these pages should only be downloaded
during the initial power-up (when first_hw_init is false).
Best Regards
Jim
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Re: [PATCH v2] ASoC: tas2783-sdw: add firmware download status check
2026-08-13 22:19 ` Mark Brown
2026-08-14 3:45 ` Xu, Baojun
@ 2026-08-14 3:51 ` Xu, Baojun
1 sibling, 0 replies; 5+ messages in thread
From: Xu, Baojun @ 2026-08-14 3:51 UTC (permalink / raw)
To: Mark Brown
Cc: tiwai@suse.de, andriy.shevchenko@linux.intel.com,
13916275206@139.com, alsa-devel@alsa-project.org, Ding, Shenghao,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
Yi, Ken, Lo, Henry, Chen, Robin, Holalu Yogendra, Niranjan,
pin-hao.huang@hp.com, Syed.SabaKareem@amd.com
> On Thu, Aug 13, 2026 at 10:14:50AM +0800, Baojun Xu wrote:
> > Currently, the firmware download is unnecessarily triggered on every
> > system resume from suspend, causing significant wake-up latency. However,
> > this step is redundant if the AMP remains powered on. Furthermore, certain
> > memory pages (addresses > 0xc60000) are skipped even after an AMP reset.
>
> > + if (!tas_dev->first_hw_init || file->dest_addr < 0xc60000) {
> > + ret = sdw_nwrite_no_pm(tas_dev->sdw_peripheral,
> > + file->dest_addr,
> > + file->length,
> + file->fw_data);
>
> What happens if the amplifier uses power (eg, over a system suspend)?
> Though since nothing clears first_hw_init I guess there might be issues
> there anyway...
Hi Mark,
Yes, that is the purpose of this patch. It prevents the re-downloading of
pages above 0xC60000 after resuming from suspend, as the data in this region
persists across an AMP reset. Therefore, these pages should only be downloaded
during the initial power-up (when first_hw_init is false).
Best Regards
Jim
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Re: [PATCH v2] ASoC: tas2783-sdw: add firmware download status check
2026-08-14 3:45 ` Xu, Baojun
@ 2026-08-14 11:23 ` Mark Brown
0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2026-08-14 11:23 UTC (permalink / raw)
To: Xu, Baojun
Cc: tiwai@suse.de, andriy.shevchenko@linux.intel.com,
13916275206@139.com, alsa-devel@alsa-project.org, Ding, Shenghao,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
Yi, Ken, Lo, Henry, Chen, Robin, Holalu Yogendra, Niranjan,
pin-hao.huang@hp.com, Syed.SabaKareem@amd.com
[-- Attachment #1: Type: text/plain, Size: 742 bytes --]
On Fri, Aug 14, 2026 at 03:45:20AM +0000, Xu, Baojun wrote:
> > What happens if the amplifier uses power (eg, over a system suspend)?
> > Though since nothing clears first_hw_init I guess there might be issues
> > there anyway...
> Yes, that is the purpose of this patch. It prevents the re-downloading of
> pages above 0xC60000 after resuming from suspend, as the data in this region
> persists across an AMP reset. Therefore, these pages should only be downloaded
> during the initial power-up (when first_hw_init is false).
That's only going to be the case if the suspend is a retention one that
maintains power to the device. If the suspend is a deep one that cuts
power to the device then I can't see how it'll keep memory contents.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-08-17 16:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-13 2:14 [PATCH v2] ASoC: tas2783-sdw: add firmware download status check Baojun Xu
2026-08-13 22:19 ` Mark Brown
2026-08-14 3:45 ` Xu, Baojun
2026-08-14 11:23 ` Mark Brown
2026-08-14 3:51 ` Xu, Baojun
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.