Add support for Halo Core DSPs
Subsystems (5)
Charles Keepax
maintainercover Add support for Halo Core DSPs
This series starts with a couple of small bug fixes but the bulk of the series is refactoring to prepare for, then adding the new Halo Core DSP support.
Halo Core is similar to the older ADSP cores but requires slightly different proceedure to enable/disable the core. We do add a new revision of the WMFW file format to support this core as well. This revision is currently only supported on Halo Core although it is expected this will probably be expanded to include ADSP in the future.
Thanks,
Charles
Charles Keepax (8):
ASoC: wm_adsp: Correct handling of compressed streams that restart
ASoC: wm_adsp: Correct error messages in wm_adsp_buffer_get_error
ASoC: wm_adsp: Add locking to wm_adsp2_bus_error
ASoC: wm_adsp: Shutdown any compressed streams on DSP watchdog timeout
ASoC: wm_adsp: Don't export wm_adsp2_lock
ASoC: wm_adsp: Refactor firmware status reading
ASoC: wm_adsp: Factor out parsing of firmware ID header
ASoC: wm_adsp: Factor out DSP specific operations
Richard Fitzgerald (2):
ASoC: wm_adsp: Move wm_adsp2_set_dspclk to CODEC drivers
ASoC: wm_adsp: Add HALO MPU fault logging
Stuart Henderson (1):
ASoC: wm_adsp: Add WDT expiry IRQ handling support for Halo core
Wen Shi (1):
ASoC: wm_adsp: Add support for new Halo core DSPs
sound/soc/codecs/cs47l24.c | 4 +- sound/soc/codecs/wm5102.c | 4 +- sound/soc/codecs/wm5110.c | 4 +- sound/soc/codecs/wm_adsp.c | 1038 +++++++++++++++++++++++++++++++++----------- sound/soc/codecs/wm_adsp.h | 51 ++- sound/soc/codecs/wmfw.h | 30 ++ 6 files changed, 859 insertions(+), 272 deletions(-)
Signature · 1 line
2.11.0
Charles Keepax
maintainerPATCH 1/12 ASoC: wm_adsp: Correct handling of compressed streams that restart
Previously support was added to allow streams to be stopped and started again without the DSP being power cycled and this was done by clearing the buffer state in trigger start. Another supported use-case is using the DSP for a trigger event then opening the compressed stream later to receive the audio, unfortunately clearing the buffer state in trigger start destroys the data received from such a trigger. Correct this issue by moving the call to wm_adsp_buffer_clear to be in trigger stop instead.
--- sound/soc/codecs/wm_adsp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
sound/soc/codecs/wm_adsp.c +1 -2
@@ -3571,8 +3571,6 @@ int wm_adsp_compr_trigger(struct snd_compr_stream *stream, int cmd)if (ret <0 )break ; -wm_adsp_buffer_clear (compr->buf); -/* Trigger the IRQ at one fragment of data */ ret = wm_adsp_buffer_write(compr->buf, HOST_BUFFER_FIELD(high_water_mark),
@@ -3584,6 +3582,7 @@ int wm_adsp_compr_trigger(struct snd_compr_stream *stream, int cmd) }break ;case SNDRV_PCM_TRIGGER_STOP : +wm_adsp_buffer_clear (compr->buf);break ;default : ret = -EINVAL ;
Signature · 1 line
2.11.0
Mark Brown
maintainerApplied "ASoC: wm_adsp: Correct handling of compressed streams that restart" to the asoc tree
The patch
ASoC: wm_adsp: Correct handling of compressed streams that restart
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
639e5eb3c7d67e407f2a71fccd95323751398f6fMon Sep 17 00:00:00 2001
From: Charles Keepax <[email protected]>
Date: Tue, 19 Mar 2019 11:52:04 +0000
Subject: [PATCH] ASoC: wm_adsp: Correct handling of compressed streams that
restart
Previously support was added to allow streams to be stopped and started again without the DSP being power cycled and this was done by clearing the buffer state in trigger start. Another supported use-case is using the DSP for a trigger event then opening the compressed stream later to receive the audio, unfortunately clearing the buffer state in trigger start destroys the data received from such a trigger. Correct this issue by moving the call to wm_adsp_buffer_clear to be in trigger stop instead.
--- sound/soc/codecs/wm_adsp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
sound/soc/codecs/wm_adsp.c +1 -2
@@ -3571,8 +3571,6 @@ int wm_adsp_compr_trigger(struct snd_compr_stream *stream, int cmd)if (ret <0 )break ; -wm_adsp_buffer_clear (compr->buf); -/* Trigger the IRQ at one fragment of data */ ret = wm_adsp_buffer_write(compr->buf, HOST_BUFFER_FIELD(high_water_mark),
@@ -3584,6 +3582,7 @@ int wm_adsp_compr_trigger(struct snd_compr_stream *stream, int cmd) }break ;case SNDRV_PCM_TRIGGER_STOP : +wm_adsp_buffer_clear (compr->buf);break ;default : ret = -EINVAL ;
Signature · 1 line
2.20.1
Charles Keepax
maintainerPATCH 2/12 ASoC: wm_adsp: Correct error messages in wm_adsp_buffer_get_error
In reply to Charles KeepaxDuring recent logging improvements it seems two error messages lost their updates during patch application/rebasing. Add these back in.
--- sound/soc/codecs/wm_adsp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/wm_adsp.c +2 -2
@@ -3535,11 +3535,11 @@ static int wm_adsp_buffer_get_error(struct wm_adsp_compr_buf *buf) ret =wm_adsp_buffer_read (buf,HOST_BUFFER_FIELD (error), &buf->error);if (ret <0 ) { -adsp_err (buf->dsp,"Failed to check buffer error: %d\n" , ret); +compr_err (buf,"Failed to check buffer error: %d\n" , ret);return ret; }if (buf->error !=0 ) { -adsp_err (buf->dsp,"Buffer error occurred: %d\n" , buf->error); +compr_err (buf,"Buffer error occurred: %d\n" , buf->error);return -EIO ; }
Signature · 1 line
2.11.0
Mark Brown
maintainerApplied "ASoC: wm_adsp: Correct error messages in wm_adsp_buffer_get_error" to the asoc tree
The patch
ASoC: wm_adsp: Correct error messages in wm_adsp_buffer_get_error
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
48ead31ce247dc8c0b01ad99d1a97da35421493bMon Sep 17 00:00:00 2001
From: Charles Keepax <[email protected]>
Date: Tue, 19 Mar 2019 11:52:05 +0000
Subject: [PATCH] ASoC: wm_adsp: Correct error messages in
wm_adsp_buffer_get_error
During recent logging improvements it seems two error messages lost their updates during patch application/rebasing. Add these back in.
--- sound/soc/codecs/wm_adsp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/wm_adsp.c +2 -2
@@ -3535,11 +3535,11 @@ static int wm_adsp_buffer_get_error(struct wm_adsp_compr_buf *buf) ret =wm_adsp_buffer_read (buf,HOST_BUFFER_FIELD (error), &buf->error);if (ret <0 ) { -adsp_err (buf->dsp,"Failed to check buffer error: %d\n" , ret); +compr_err (buf,"Failed to check buffer error: %d\n" , ret);return ret; }if (buf->error !=0 ) { -adsp_err (buf->dsp,"Buffer error occurred: %d\n" , buf->error); +compr_err (buf,"Buffer error occurred: %d\n" , buf->error);return -EIO ; }
Signature · 1 line
2.20.1
Charles Keepax
maintainerPATCH 3/12 ASoC: wm_adsp: Add locking to wm_adsp2_bus_error
In reply to Charles KeepaxBest to lock across handling the bus error to ensure the DSP doesn't change power state as we are reading the status registers.
--- sound/soc/codecs/wm_adsp.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
sound/soc/codecs/wm_adsp.c +8 -3
@@ -3922,11 +3922,13 @@ irqreturn_t wm_adsp2_bus_error(struct wm_adsp *dsp)struct regmap *regmap = dsp->regmap;int ret =0 ; +mutex_lock (&dsp->pwr_lock); + ret =regmap_read (regmap, dsp->base +ADSP2_LOCK_REGION_CTRL , &val);if (ret) {adsp_err (dsp,"Failed to read Region Lock Ctrl register: %d\n" , ret); -return IRQ_HANDLED ; + goto error; }if (val &ADSP2_WDT_TIMEOUT_STS_MASK ) {
@@ -3945,7 +3947,7 @@ irqreturn_t wm_adsp2_bus_error(struct wm_adsp *dsp)adsp_err (dsp,"Failed to read Bus Err Addr register: %d\n" , ret); -return IRQ_HANDLED ; + goto error; } adsp_err(dsp, "bus error address = 0x%x\n",
@@ -3958,7 +3960,7 @@ irqreturn_t wm_adsp2_bus_error(struct wm_adsp *dsp)adsp_err (dsp,"Failed to read Pmem Xmem Err Addr register: %d\n" , ret); -return IRQ_HANDLED ; + goto error; } adsp_err(dsp, "xmem error address = 0x%x\n",
@@ -3971,6 +3973,9 @@ irqreturn_t wm_adsp2_bus_error(struct wm_adsp *dsp)regmap_update_bits (regmap, dsp->base +ADSP2_LOCK_REGION_CTRL ,ADSP2_CTRL_ERR_EINT ,ADSP2_CTRL_ERR_EINT ); +error: +mutex_unlock (&dsp->pwr_lock); +return IRQ_HANDLED ; }EXPORT_SYMBOL_GPL (wm_adsp2_bus_error);
Signature · 1 line
2.11.0
Mark Brown
maintainerApplied "ASoC: wm_adsp: Add locking to wm_adsp2_bus_error" to the asoc tree
The patch
ASoC: wm_adsp: Add locking to wm_adsp2_bus_error
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
a2225a6d155fcb247fe4c6d87f7c91807462966dMon Sep 17 00:00:00 2001
From: Charles Keepax <[email protected]>
Date: Tue, 19 Mar 2019 11:52:06 +0000
Subject: [PATCH] ASoC: wm_adsp: Add locking to wm_adsp2_bus_error
Best to lock across handling the bus error to ensure the DSP doesn't change power state as we are reading the status registers.
--- sound/soc/codecs/wm_adsp.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
sound/soc/codecs/wm_adsp.c +8 -3
@@ -3922,11 +3922,13 @@ irqreturn_t wm_adsp2_bus_error(struct wm_adsp *dsp)struct regmap *regmap = dsp->regmap;int ret =0 ; +mutex_lock (&dsp->pwr_lock); + ret =regmap_read (regmap, dsp->base +ADSP2_LOCK_REGION_CTRL , &val);if (ret) {adsp_err (dsp,"Failed to read Region Lock Ctrl register: %d\n" , ret); -return IRQ_HANDLED ; + goto error; }if (val &ADSP2_WDT_TIMEOUT_STS_MASK ) {
@@ -3945,7 +3947,7 @@ irqreturn_t wm_adsp2_bus_error(struct wm_adsp *dsp)adsp_err (dsp,"Failed to read Bus Err Addr register: %d\n" , ret); -return IRQ_HANDLED ; + goto error; } adsp_err(dsp, "bus error address = 0x%x\n",
@@ -3958,7 +3960,7 @@ irqreturn_t wm_adsp2_bus_error(struct wm_adsp *dsp)adsp_err (dsp,"Failed to read Pmem Xmem Err Addr register: %d\n" , ret); -return IRQ_HANDLED ; + goto error; } adsp_err(dsp, "xmem error address = 0x%x\n",
@@ -3971,6 +3973,9 @@ irqreturn_t wm_adsp2_bus_error(struct wm_adsp *dsp)regmap_update_bits (regmap, dsp->base +ADSP2_LOCK_REGION_CTRL ,ADSP2_CTRL_ERR_EINT ,ADSP2_CTRL_ERR_EINT ); +error: +mutex_unlock (&dsp->pwr_lock); +return IRQ_HANDLED ; }EXPORT_SYMBOL_GPL (wm_adsp2_bus_error);
Signature · 1 line
2.20.1
Charles Keepax
maintainerPATCH 4/12 ASoC: wm_adsp: Shutdown any compressed streams on DSP watchdog timeout
In reply to Charles KeepaxIf a watchdog timeout is received from the DSP it is safe to assume the DSP is not functioning anymore and as such any active compressed streams should be put into an error state.
--- sound/soc/codecs/wm_adsp.c | 21 +++++++++++++++++++++ sound/soc/codecs/wm_adsp.h | 1 + 2 files changed, 22 insertions(+)
sound/soc/codecs/wm_adsp.c +21 -0
@@ -2905,6 +2905,8 @@ int wm_adsp2_event(struct snd_soc_dapm_widget *w,if (wm_adsp_fw[dsp->fw].num_caps !=0 )wm_adsp_buffer_free (dsp); + dsp->fatal_error = false; +mutex_unlock (&dsp->pwr_lock);adsp_dbg (dsp,"Execution stopped\n" );
@@ -3000,6 +3002,9 @@ static int wm_adsp_compr_attach(struct wm_adsp_compr *compr) {struct wm_adsp_compr_buf *buf =NULL , *tmp; +if (compr->dsp->fatal_error) +return -EINVAL ; +list_for_each_entry (tmp, &compr->dsp->buffer_list, list) {if (!tmp->name || !strcmp (compr->name, tmp->name)) { buf = tmp;
@@ -3916,6 +3921,21 @@ int wm_adsp2_lock(struct wm_adsp *dsp, unsigned int lock_regions) }EXPORT_SYMBOL_GPL (wm_adsp2_lock); +static void wm_adsp_fatal_error (struct wm_adsp *dsp) +{ +struct wm_adsp_compr *compr; + + dsp->fatal_error = true; + +list_for_each_entry (compr, &dsp->compr_list, list) { +if (compr->stream) { +snd_compr_stop_error (compr->stream, +SNDRV_PCM_STATE_XRUN ); +snd_compr_fragment_elapsed (compr->stream); + } + } +} +irqreturn_t wm_adsp2_bus_error (struct wm_adsp *dsp) {unsigned int val;
@@ -3934,6 +3954,7 @@ irqreturn_t wm_adsp2_bus_error(struct wm_adsp *dsp)if (val &ADSP2_WDT_TIMEOUT_STS_MASK ) {adsp_err (dsp,"watchdog timeout error\n" );wm_adsp_stop_watchdog (dsp); +wm_adsp_fatal_error (dsp); }if (val & (ADSP2_SLAVE_ERR_MASK |ADSP2_REGION_LOCK_ERR_MASK )) {
sound/soc/codecs/wm_adsp.h +1 -0
@@ -85,6 +85,7 @@ struct wm_adsp {bool preloaded;bool booted;bool running; +bool fatal_error;struct list_head ctl_list;
Signature · 1 line
2.11.0
Mark Brown
maintainerApplied "ASoC: wm_adsp: Shutdown any compressed streams on DSP watchdog timeout" to the asoc tree
The patch
ASoC: wm_adsp: Shutdown any compressed streams on DSP watchdog timeout
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
a2bcbc1b9ac2f982a438081a9f1b5d823332d514Mon Sep 17 00:00:00 2001
From: Charles Keepax <[email protected]>
Date: Tue, 19 Mar 2019 11:52:07 +0000
Subject: [PATCH] ASoC: wm_adsp: Shutdown any compressed streams on DSP
watchdog timeout
If a watchdog timeout is received from the DSP it is safe to assume the DSP is not functioning anymore and as such any active compressed streams should be put into an error state.
--- sound/soc/codecs/wm_adsp.c | 21 +++++++++++++++++++++ sound/soc/codecs/wm_adsp.h | 1 + 2 files changed, 22 insertions(+)
sound/soc/codecs/wm_adsp.c +21 -0
@@ -2905,6 +2905,8 @@ int wm_adsp2_event(struct snd_soc_dapm_widget *w,if (wm_adsp_fw[dsp->fw].num_caps !=0 )wm_adsp_buffer_free (dsp); + dsp->fatal_error = false; +mutex_unlock (&dsp->pwr_lock);adsp_dbg (dsp,"Execution stopped\n" );
@@ -3000,6 +3002,9 @@ static int wm_adsp_compr_attach(struct wm_adsp_compr *compr) {struct wm_adsp_compr_buf *buf =NULL , *tmp; +if (compr->dsp->fatal_error) +return -EINVAL ; +list_for_each_entry (tmp, &compr->dsp->buffer_list, list) {if (!tmp->name || !strcmp (compr->name, tmp->name)) { buf = tmp;
@@ -3916,6 +3921,21 @@ int wm_adsp2_lock(struct wm_adsp *dsp, unsigned int lock_regions) }EXPORT_SYMBOL_GPL (wm_adsp2_lock); +static void wm_adsp_fatal_error (struct wm_adsp *dsp) +{ +struct wm_adsp_compr *compr; + + dsp->fatal_error = true; + +list_for_each_entry (compr, &dsp->compr_list, list) { +if (compr->stream) { +snd_compr_stop_error (compr->stream, +SNDRV_PCM_STATE_XRUN ); +snd_compr_fragment_elapsed (compr->stream); + } + } +} +irqreturn_t wm_adsp2_bus_error (struct wm_adsp *dsp) {unsigned int val;
@@ -3934,6 +3954,7 @@ irqreturn_t wm_adsp2_bus_error(struct wm_adsp *dsp)if (val &ADSP2_WDT_TIMEOUT_STS_MASK ) {adsp_err (dsp,"watchdog timeout error\n" );wm_adsp_stop_watchdog (dsp); +wm_adsp_fatal_error (dsp); }if (val & (ADSP2_SLAVE_ERR_MASK |ADSP2_REGION_LOCK_ERR_MASK )) {
sound/soc/codecs/wm_adsp.h +1 -0
@@ -85,6 +85,7 @@ struct wm_adsp {bool preloaded;bool booted;bool running; +bool fatal_error;struct list_head ctl_list;
Signature · 1 line
2.20.1
Charles Keepax
maintainerPATCH 5/12 ASoC: wm_adsp: Don't export wm_adsp2_lock
In reply to Charles KeepaxThis function is not presently called from outside the adsp code and nor should it be, as such stop exporting it.
--- sound/soc/codecs/wm_adsp.c | 61 +++++++++++++++++++++++----------------------- sound/soc/codecs/wm_adsp.h | 1 - 2 files changed, 30 insertions(+), 32 deletions(-)
sound/soc/codecs/wm_adsp.c +30 -31
@@ -2622,6 +2622,36 @@ static int wm_adsp2_ena(struct wm_adsp *dsp)return 0 ; } +static int wm_adsp2_lock (struct wm_adsp *dsp,unsigned int lock_regions) +{ +struct regmap *regmap = dsp->regmap; +unsigned int code0, code1, lock_reg; + +if (!(lock_regions &WM_ADSP2_REGION_ALL )) +return 0 ; + + lock_regions &=WM_ADSP2_REGION_ALL ; + lock_reg = dsp->base +ADSP2_LOCK_REGION_1_LOCK_REGION_0 ; + +while (lock_regions) { + code0 = code1 =0 ; +if (lock_regions &BIT (0 )) { + code0 =ADSP2_LOCK_CODE_0 ; + code1 =ADSP2_LOCK_CODE_1 ; + } +if (lock_regions &BIT (1 )) { + code0 |=ADSP2_LOCK_CODE_0 <<ADSP2_LOCK_REGION_SHIFT ; + code1 |=ADSP2_LOCK_CODE_1 <<ADSP2_LOCK_REGION_SHIFT ; + } +regmap_write (regmap, lock_reg, code0); +regmap_write (regmap, lock_reg, code1); + lock_regions >>=2 ; + lock_reg +=2 ; + } + +return 0 ; +} +static void wm_adsp2_boot_work (struct work_struct *work) { struct wm_adsp *dsp = container_of(work,
@@ -3890,37 +3920,6 @@ int wm_adsp_compr_copy(struct snd_compr_stream *stream, char __user *buf, }EXPORT_SYMBOL_GPL (wm_adsp_compr_copy); -int wm_adsp2_lock (struct wm_adsp *dsp,unsigned int lock_regions) -{ -struct regmap *regmap = dsp->regmap; -unsigned int code0, code1, lock_reg; - -if (!(lock_regions &WM_ADSP2_REGION_ALL )) -return 0 ; - - lock_regions &=WM_ADSP2_REGION_ALL ; - lock_reg = dsp->base +ADSP2_LOCK_REGION_1_LOCK_REGION_0 ; - -while (lock_regions) { - code0 = code1 =0 ; -if (lock_regions &BIT (0 )) { - code0 =ADSP2_LOCK_CODE_0 ; - code1 =ADSP2_LOCK_CODE_1 ; - } -if (lock_regions &BIT (1 )) { - code0 |=ADSP2_LOCK_CODE_0 <<ADSP2_LOCK_REGION_SHIFT ; - code1 |=ADSP2_LOCK_CODE_1 <<ADSP2_LOCK_REGION_SHIFT ; - } -regmap_write (regmap, lock_reg, code0); -regmap_write (regmap, lock_reg, code1); - lock_regions >>=2 ; - lock_reg +=2 ; - } - -return 0 ; -} -EXPORT_SYMBOL_GPL (wm_adsp2_lock); -static void wm_adsp_fatal_error (struct wm_adsp *dsp) {struct wm_adsp_compr *compr;
sound/soc/codecs/wm_adsp.h +0 -1
@@ -141,7 +141,6 @@ int wm_adsp2_early_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event, unsigned int freq); -int wm_adsp2_lock (struct wm_adsp *adsp,unsigned int regions);irqreturn_t wm_adsp2_bus_error (struct wm_adsp *adsp); int wm_adsp2_event(struct snd_soc_dapm_widget *w,
Signature · 1 line
2.11.0
Mark Brown
maintainerApplied "ASoC: wm_adsp: Don't export wm_adsp2_lock" to the asoc tree
The patch
ASoC: wm_adsp: Don't export wm_adsp2_lock
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
2b0ee49f129cf3e9885f8d83439024e8116b865cMon Sep 17 00:00:00 2001
From: Charles Keepax <[email protected]>
Date: Tue, 19 Mar 2019 11:52:08 +0000
Subject: [PATCH] ASoC: wm_adsp: Don't export wm_adsp2_lock
This function is not presently called from outside the adsp code and nor should it be, as such stop exporting it.
--- sound/soc/codecs/wm_adsp.c | 61 +++++++++++++++++++------------------- sound/soc/codecs/wm_adsp.h | 1 - 2 files changed, 30 insertions(+), 32 deletions(-)
sound/soc/codecs/wm_adsp.c +30 -31
@@ -2622,6 +2622,36 @@ static int wm_adsp2_ena(struct wm_adsp *dsp)return 0 ; } +static int wm_adsp2_lock (struct wm_adsp *dsp,unsigned int lock_regions) +{ +struct regmap *regmap = dsp->regmap; +unsigned int code0, code1, lock_reg; + +if (!(lock_regions &WM_ADSP2_REGION_ALL )) +return 0 ; + + lock_regions &=WM_ADSP2_REGION_ALL ; + lock_reg = dsp->base +ADSP2_LOCK_REGION_1_LOCK_REGION_0 ; + +while (lock_regions) { + code0 = code1 =0 ; +if (lock_regions &BIT (0 )) { + code0 =ADSP2_LOCK_CODE_0 ; + code1 =ADSP2_LOCK_CODE_1 ; + } +if (lock_regions &BIT (1 )) { + code0 |=ADSP2_LOCK_CODE_0 <<ADSP2_LOCK_REGION_SHIFT ; + code1 |=ADSP2_LOCK_CODE_1 <<ADSP2_LOCK_REGION_SHIFT ; + } +regmap_write (regmap, lock_reg, code0); +regmap_write (regmap, lock_reg, code1); + lock_regions >>=2 ; + lock_reg +=2 ; + } + +return 0 ; +} +static void wm_adsp2_boot_work (struct work_struct *work) { struct wm_adsp *dsp = container_of(work,
@@ -3890,37 +3920,6 @@ int wm_adsp_compr_copy(struct snd_compr_stream *stream, char __user *buf, }EXPORT_SYMBOL_GPL (wm_adsp_compr_copy); -int wm_adsp2_lock (struct wm_adsp *dsp,unsigned int lock_regions) -{ -struct regmap *regmap = dsp->regmap; -unsigned int code0, code1, lock_reg; - -if (!(lock_regions &WM_ADSP2_REGION_ALL )) -return 0 ; - - lock_regions &=WM_ADSP2_REGION_ALL ; - lock_reg = dsp->base +ADSP2_LOCK_REGION_1_LOCK_REGION_0 ; - -while (lock_regions) { - code0 = code1 =0 ; -if (lock_regions &BIT (0 )) { - code0 =ADSP2_LOCK_CODE_0 ; - code1 =ADSP2_LOCK_CODE_1 ; - } -if (lock_regions &BIT (1 )) { - code0 |=ADSP2_LOCK_CODE_0 <<ADSP2_LOCK_REGION_SHIFT ; - code1 |=ADSP2_LOCK_CODE_1 <<ADSP2_LOCK_REGION_SHIFT ; - } -regmap_write (regmap, lock_reg, code0); -regmap_write (regmap, lock_reg, code1); - lock_regions >>=2 ; - lock_reg +=2 ; - } - -return 0 ; -} -EXPORT_SYMBOL_GPL (wm_adsp2_lock); -static void wm_adsp_fatal_error (struct wm_adsp *dsp) {struct wm_adsp_compr *compr;
sound/soc/codecs/wm_adsp.h +0 -1
@@ -141,7 +141,6 @@ int wm_adsp2_early_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event, unsigned int freq); -int wm_adsp2_lock (struct wm_adsp *adsp,unsigned int regions);irqreturn_t wm_adsp2_bus_error (struct wm_adsp *adsp); int wm_adsp2_event(struct snd_soc_dapm_widget *w,
Signature · 1 line
2.20.1
Charles Keepax
maintainerPATCH 6/12 ASoC: wm_adsp: Move wm_adsp2_set_dspclk to CODEC drivers
In reply to Charles KeepaxFrom: Richard Fitzgerald <[email protected]>
The original wm_adsp2_early_event took an additional frequency argument for clocking control so could not be used directly as a DAPM callback. But this setup could equally be done by the codec driver function wrapping wm_adsp2_early event. In preparation for adding support for new core types wm_adsp2_set_dspclk has been exported, and the freq argument removed so that it can be used directly as a DAPM callback.
--- sound/soc/codecs/cs47l24.c | 4 +++- sound/soc/codecs/wm5102.c | 4 +++- sound/soc/codecs/wm5110.c | 4 +++- sound/soc/codecs/wm_adsp.c | 32 +++++++++++++------------------- sound/soc/codecs/wm_adsp.h | 6 ++++-- 5 files changed, 26 insertions(+), 24 deletions(-)
sound/soc/codecs/cs47l24.c +3 -1
@@ -75,7 +75,9 @@ static int cs47l24_adsp_power_ev(struct snd_soc_dapm_widget *w, v = (v &ARIZONA_SYSCLK_FREQ_MASK ) >>ARIZONA_SYSCLK_FREQ_SHIFT ; -return wm_adsp2_early_event (w, kcontrol, event, v); +wm_adsp2_set_dspclk (w, v); + +return wm_adsp2_early_event (w, kcontrol, event); } static DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
sound/soc/codecs/wm5102.c +3 -1
@@ -646,6 +646,8 @@ static int wm5102_adsp_power_ev(struct snd_soc_dapm_widget *w,return ret; } } + +wm_adsp2_set_dspclk (w, v);break ;case SND_SOC_DAPM_POST_PMD :
@@ -659,7 +661,7 @@ static int wm5102_adsp_power_ev(struct snd_soc_dapm_widget *w,break ; } -return wm_adsp2_early_event (w, kcontrol, event, v); +return wm_adsp2_early_event (w, kcontrol, event); } static int wm5102_out_comp_coeff_get(struct snd_kcontrol *kcontrol,
sound/soc/codecs/wm5110.c +3 -1
@@ -211,7 +211,9 @@ static int wm5110_adsp_power_ev(struct snd_soc_dapm_widget *w, v = (v &ARIZONA_SYSCLK_FREQ_MASK ) >>ARIZONA_SYSCLK_FREQ_SHIFT ; -return wm_adsp2_early_event (w, kcontrol, event, v); +wm_adsp2_set_dspclk (w, v); + +return wm_adsp2_early_event (w, kcontrol, event); }static const struct reg_sequence wm5110_no_dre_left_enable[] = {
sound/soc/codecs/wm_adsp.c +13 -19
@@ -2715,26 +2715,22 @@ static void wm_adsp2_boot_work(struct work_struct *work)mutex_unlock (&dsp->pwr_lock); } -static void wm_adsp2_set_dspclk (struct wm_adsp *dsp,unsigned int freq) +int wm_adsp2_set_dspclk (struct snd_soc_dapm_widget *w,unsigned int freq) { +struct snd_soc_component *component =snd_soc_dapm_to_component (w->dapm); +struct wm_adsp *dsps =snd_soc_component_get_drvdata (component); +struct wm_adsp *dsp = &dsps[w->shift];int ret; -switch (dsp->rev) { -case 0 : - ret =regmap_update_bits_async (dsp->regmap, - dsp->base +ADSP2_CLOCKING , -ADSP2_CLK_SEL_MASK , - freq <<ADSP2_CLK_SEL_SHIFT ); -if (ret) { -adsp_err (dsp,"Failed to set clock rate: %d\n" , ret); -return ; - } -break ; -default : -/* clock is handled by parent codec driver */ -break ; - } + ret =regmap_update_bits (dsp->regmap, dsp->base +ADSP2_CLOCKING , +ADSP2_CLK_SEL_MASK , + freq <<ADSP2_CLK_SEL_SHIFT ); +if (ret) +adsp_err (dsp,"Failed to set clock rate: %d\n" , ret); + +return ret; } +EXPORT_SYMBOL_GPL (wm_adsp2_set_dspclk);int wm_adsp2_preloader_get (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol)
@@ -2792,8 +2788,7 @@ static void wm_adsp_stop_watchdog(struct wm_adsp *dsp) }int wm_adsp2_early_event (struct snd_soc_dapm_widget *w, -struct snd_kcontrol *kcontrol,int event, -unsigned int freq) +struct snd_kcontrol *kcontrol,int event) {struct snd_soc_component *component =snd_soc_dapm_to_component (w->dapm);struct wm_adsp *dsps =snd_soc_component_get_drvdata (component);
@@ -2802,7 +2797,6 @@ int wm_adsp2_early_event(struct snd_soc_dapm_widget *w,switch (event) {case SND_SOC_DAPM_PRE_PMU : -wm_adsp2_set_dspclk (dsp, freq);queue_work (system_unbound_wq, &dsp->boot_work);break ;case SND_SOC_DAPM_PRE_PMD :
sound/soc/codecs/wm_adsp.h +4 -2
@@ -137,15 +137,17 @@ int wm_adsp2_component_probe(struct wm_adsp *dsp, struct snd_soc_component *compint wm_adsp2_component_remove (struct wm_adsp *dsp,struct snd_soc_component *component);int wm_adsp1_event (struct snd_soc_dapm_widget *w,struct snd_kcontrol *kcontrol,int event); +int wm_adsp2_early_event (struct snd_soc_dapm_widget *w, -struct snd_kcontrol *kcontrol,int event, -unsigned int freq); +struct snd_kcontrol *kcontrol,int event);irqreturn_t wm_adsp2_bus_error (struct wm_adsp *adsp);int wm_adsp2_event (struct snd_soc_dapm_widget *w,struct snd_kcontrol *kcontrol,int event); +int wm_adsp2_set_dspclk (struct snd_soc_dapm_widget *w,unsigned int freq); +int wm_adsp2_preloader_get (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol); int wm_adsp2_preloader_put(struct snd_kcontrol *kcontrol,
Signature · 1 line
2.11.0
Mark Brown
maintainerApplied "ASoC: wm_adsp: Move wm_adsp2_set_dspclk to CODEC drivers" to the asoc tree
The patch
ASoC: wm_adsp: Move wm_adsp2_set_dspclk to CODEC drivers
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
b9070df451668e0c317d420d8331568b4d7ba6dfMon Sep 17 00:00:00 2001
From: Richard Fitzgerald <[email protected]>
Date: Tue, 19 Mar 2019 11:52:09 +0000
Subject: [PATCH] ASoC: wm_adsp: Move wm_adsp2_set_dspclk to CODEC drivers
The original wm_adsp2_early_event took an additional frequency argument for clocking control so could not be used directly as a DAPM callback. But this setup could equally be done by the codec driver function wrapping wm_adsp2_early event. In preparation for adding support for new core types wm_adsp2_set_dspclk has been exported, and the freq argument removed so that it can be used directly as a DAPM callback.
--- sound/soc/codecs/cs47l24.c | 4 +++- sound/soc/codecs/wm5102.c | 4 +++- sound/soc/codecs/wm5110.c | 4 +++- sound/soc/codecs/wm_adsp.c | 32 +++++++++++++------------------- sound/soc/codecs/wm_adsp.h | 6 ++++-- 5 files changed, 26 insertions(+), 24 deletions(-)
sound/soc/codecs/cs47l24.c +3 -1
@@ -75,7 +75,9 @@ static int cs47l24_adsp_power_ev(struct snd_soc_dapm_widget *w, v = (v &ARIZONA_SYSCLK_FREQ_MASK ) >>ARIZONA_SYSCLK_FREQ_SHIFT ; -return wm_adsp2_early_event (w, kcontrol, event, v); +wm_adsp2_set_dspclk (w, v); + +return wm_adsp2_early_event (w, kcontrol, event); } static DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
sound/soc/codecs/wm5102.c +3 -1
@@ -646,6 +646,8 @@ static int wm5102_adsp_power_ev(struct snd_soc_dapm_widget *w,return ret; } } + +wm_adsp2_set_dspclk (w, v);break ;case SND_SOC_DAPM_POST_PMD :
@@ -659,7 +661,7 @@ static int wm5102_adsp_power_ev(struct snd_soc_dapm_widget *w,break ; } -return wm_adsp2_early_event (w, kcontrol, event, v); +return wm_adsp2_early_event (w, kcontrol, event); } static int wm5102_out_comp_coeff_get(struct snd_kcontrol *kcontrol,
sound/soc/codecs/wm5110.c +3 -1
@@ -211,7 +211,9 @@ static int wm5110_adsp_power_ev(struct snd_soc_dapm_widget *w, v = (v &ARIZONA_SYSCLK_FREQ_MASK ) >>ARIZONA_SYSCLK_FREQ_SHIFT ; -return wm_adsp2_early_event (w, kcontrol, event, v); +wm_adsp2_set_dspclk (w, v); + +return wm_adsp2_early_event (w, kcontrol, event); }static const struct reg_sequence wm5110_no_dre_left_enable[] = {
sound/soc/codecs/wm_adsp.c +13 -19
@@ -2715,26 +2715,22 @@ static void wm_adsp2_boot_work(struct work_struct *work)mutex_unlock (&dsp->pwr_lock); } -static void wm_adsp2_set_dspclk (struct wm_adsp *dsp,unsigned int freq) +int wm_adsp2_set_dspclk (struct snd_soc_dapm_widget *w,unsigned int freq) { +struct snd_soc_component *component =snd_soc_dapm_to_component (w->dapm); +struct wm_adsp *dsps =snd_soc_component_get_drvdata (component); +struct wm_adsp *dsp = &dsps[w->shift];int ret; -switch (dsp->rev) { -case 0 : - ret =regmap_update_bits_async (dsp->regmap, - dsp->base +ADSP2_CLOCKING , -ADSP2_CLK_SEL_MASK , - freq <<ADSP2_CLK_SEL_SHIFT ); -if (ret) { -adsp_err (dsp,"Failed to set clock rate: %d\n" , ret); -return ; - } -break ; -default : -/* clock is handled by parent codec driver */ -break ; - } + ret =regmap_update_bits (dsp->regmap, dsp->base +ADSP2_CLOCKING , +ADSP2_CLK_SEL_MASK , + freq <<ADSP2_CLK_SEL_SHIFT ); +if (ret) +adsp_err (dsp,"Failed to set clock rate: %d\n" , ret); + +return ret; } +EXPORT_SYMBOL_GPL (wm_adsp2_set_dspclk);int wm_adsp2_preloader_get (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol)
@@ -2792,8 +2788,7 @@ static void wm_adsp_stop_watchdog(struct wm_adsp *dsp) }int wm_adsp2_early_event (struct snd_soc_dapm_widget *w, -struct snd_kcontrol *kcontrol,int event, -unsigned int freq) +struct snd_kcontrol *kcontrol,int event) {struct snd_soc_component *component =snd_soc_dapm_to_component (w->dapm);struct wm_adsp *dsps =snd_soc_component_get_drvdata (component);
@@ -2802,7 +2797,6 @@ int wm_adsp2_early_event(struct snd_soc_dapm_widget *w,switch (event) {case SND_SOC_DAPM_PRE_PMU : -wm_adsp2_set_dspclk (dsp, freq);queue_work (system_unbound_wq, &dsp->boot_work);break ;case SND_SOC_DAPM_PRE_PMD :
sound/soc/codecs/wm_adsp.h +4 -2
@@ -137,15 +137,17 @@ int wm_adsp2_component_probe(struct wm_adsp *dsp, struct snd_soc_component *compint wm_adsp2_component_remove (struct wm_adsp *dsp,struct snd_soc_component *component);int wm_adsp1_event (struct snd_soc_dapm_widget *w,struct snd_kcontrol *kcontrol,int event); +int wm_adsp2_early_event (struct snd_soc_dapm_widget *w, -struct snd_kcontrol *kcontrol,int event, -unsigned int freq); +struct snd_kcontrol *kcontrol,int event);irqreturn_t wm_adsp2_bus_error (struct wm_adsp *adsp);int wm_adsp2_event (struct snd_soc_dapm_widget *w,struct snd_kcontrol *kcontrol,int event); +int wm_adsp2_set_dspclk (struct snd_soc_dapm_widget *w,unsigned int freq); +int wm_adsp2_preloader_get (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol); int wm_adsp2_preloader_put(struct snd_kcontrol *kcontrol,
Signature · 1 line
2.20.1
Charles Keepax
maintainerPATCH 7/12 ASoC: wm_adsp: Refactor firmware status reading
In reply to Charles KeepaxIn preparation for further additions refactor the reading of the firmware status.
--- sound/soc/codecs/wm_adsp.c | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-)
sound/soc/codecs/wm_adsp.c +18 -25
@@ -788,49 +788,42 @@ static unsigned int wm_adsp_region_to_reg(struct wm_adsp_region const *mem, } } -static void wm_adsp2_show_fw_status (struct wm_adsp *dsp) +static void wm_adsp_read_fw_status (struct wm_adsp *dsp, +int noffs,unsigned int *offs) { -unsigned int scratch[4 ]; -unsigned int addr = dsp->base +ADSP2_SCRATCH0 ;unsigned int i;int ret; -for (i =0 ; i <ARRAY_SIZE (scratch); ++i) { - ret =regmap_read (dsp->regmap, addr + i, &scratch[i]); +for (i =0 ; i < noffs; ++i) { + ret =regmap_read (dsp->regmap, dsp->base + offs[i], &offs[i]);if (ret) {adsp_err (dsp,"Failed to read SCRATCH%u: %d\n" , i, ret);return ; } } +} + +static void wm_adsp2_show_fw_status (struct wm_adsp *dsp) +{ +unsigned int offs[] = { +ADSP2_SCRATCH0 ,ADSP2_SCRATCH1 ,ADSP2_SCRATCH2 ,ADSP2_SCRATCH3 , + }; + +wm_adsp_read_fw_status (dsp,ARRAY_SIZE (offs), offs);adsp_dbg (dsp,"FW SCRATCH 0:0x%x 1:0x%x 2:0x%x 3:0x%x\n" , - scratch[0 ], scratch[1 ], scratch[2 ], scratch[3 ]); + offs[0 ], offs[1 ], offs[2 ], offs[3 ]); }static void wm_adsp2v2_show_fw_status (struct wm_adsp *dsp) { -unsigned int scratch[2 ]; -int ret; +unsigned int offs[] = {ADSP2V2_SCRATCH0_1 ,ADSP2V2_SCRATCH2_3 }; - ret =regmap_read (dsp->regmap, dsp->base +ADSP2V2_SCRATCH0_1 , - &scratch[0 ]); -if (ret) { -adsp_err (dsp,"Failed to read SCRATCH0_1: %d\n" , ret); -return ; - } - - ret =regmap_read (dsp->regmap, dsp->base +ADSP2V2_SCRATCH2_3 , - &scratch[1 ]); -if (ret) { -adsp_err (dsp,"Failed to read SCRATCH2_3: %d\n" , ret); -return ; - } +wm_adsp_read_fw_status (dsp,ARRAY_SIZE (offs), offs);adsp_dbg (dsp,"FW SCRATCH 0:0x%x 1:0x%x 2:0x%x 3:0x%x\n" , - scratch[0 ] &0xFFFF , - scratch[0 ] >>16 , - scratch[1 ] &0xFFFF , - scratch[1 ] >>16 ); + offs[0 ] &0xFFFF , offs[0 ] >>16 , + offs[1 ] &0xFFFF , offs[1 ] >>16 ); }static inline struct wm_coeff_ctl *bytes_ext_to_ctl (struct soc_bytes_ext *ext)
Signature · 1 line
2.11.0
Mark Brown
maintainerApplied "ASoC: wm_adsp: Refactor firmware status reading" to the asoc tree
The patch
ASoC: wm_adsp: Refactor firmware status reading
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
4049ce86fc9b0512d4f624bb8b63c8f513fb66d1Mon Sep 17 00:00:00 2001
From: Charles Keepax <[email protected]>
Date: Tue, 19 Mar 2019 11:52:10 +0000
Subject: [PATCH] ASoC: wm_adsp: Refactor firmware status reading
In preparation for further additions refactor the reading of the firmware status.
--- sound/soc/codecs/wm_adsp.c | 43 ++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 25 deletions(-)
sound/soc/codecs/wm_adsp.c +18 -25
@@ -788,49 +788,42 @@ static unsigned int wm_adsp_region_to_reg(struct wm_adsp_region const *mem, } } -static void wm_adsp2_show_fw_status (struct wm_adsp *dsp) +static void wm_adsp_read_fw_status (struct wm_adsp *dsp, +int noffs,unsigned int *offs) { -unsigned int scratch[4 ]; -unsigned int addr = dsp->base +ADSP2_SCRATCH0 ;unsigned int i;int ret; -for (i =0 ; i <ARRAY_SIZE (scratch); ++i) { - ret =regmap_read (dsp->regmap, addr + i, &scratch[i]); +for (i =0 ; i < noffs; ++i) { + ret =regmap_read (dsp->regmap, dsp->base + offs[i], &offs[i]);if (ret) {adsp_err (dsp,"Failed to read SCRATCH%u: %d\n" , i, ret);return ; } } +} + +static void wm_adsp2_show_fw_status (struct wm_adsp *dsp) +{ +unsigned int offs[] = { +ADSP2_SCRATCH0 ,ADSP2_SCRATCH1 ,ADSP2_SCRATCH2 ,ADSP2_SCRATCH3 , + }; + +wm_adsp_read_fw_status (dsp,ARRAY_SIZE (offs), offs);adsp_dbg (dsp,"FW SCRATCH 0:0x%x 1:0x%x 2:0x%x 3:0x%x\n" , - scratch[0 ], scratch[1 ], scratch[2 ], scratch[3 ]); + offs[0 ], offs[1 ], offs[2 ], offs[3 ]); }static void wm_adsp2v2_show_fw_status (struct wm_adsp *dsp) { -unsigned int scratch[2 ]; -int ret; +unsigned int offs[] = {ADSP2V2_SCRATCH0_1 ,ADSP2V2_SCRATCH2_3 }; - ret =regmap_read (dsp->regmap, dsp->base +ADSP2V2_SCRATCH0_1 , - &scratch[0 ]); -if (ret) { -adsp_err (dsp,"Failed to read SCRATCH0_1: %d\n" , ret); -return ; - } - - ret =regmap_read (dsp->regmap, dsp->base +ADSP2V2_SCRATCH2_3 , - &scratch[1 ]); -if (ret) { -adsp_err (dsp,"Failed to read SCRATCH2_3: %d\n" , ret); -return ; - } +wm_adsp_read_fw_status (dsp,ARRAY_SIZE (offs), offs);adsp_dbg (dsp,"FW SCRATCH 0:0x%x 1:0x%x 2:0x%x 3:0x%x\n" , - scratch[0 ] &0xFFFF , - scratch[0 ] >>16 , - scratch[1 ] &0xFFFF , - scratch[1 ] >>16 ); + offs[0 ] &0xFFFF , offs[0 ] >>16 , + offs[1 ] &0xFFFF , offs[1 ] >>16 ); }static inline struct wm_coeff_ctl *bytes_ext_to_ctl (struct soc_bytes_ext *ext)
Signature · 1 line
2.20.1
Charles Keepax
maintainerPATCH 8/12 ASoC: wm_adsp: Factor out parsing of firmware ID header
In reply to Charles KeepaxThere is no need to duplicate this code for both ADSP1 and 2 as the handling is exactly the same.
--- sound/soc/codecs/wm_adsp.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
sound/soc/codecs/wm_adsp.c +16 -15
@@ -1982,6 +1982,18 @@ static void wm_adsp_free_alg_regions(struct wm_adsp *dsp) } } +static void wmfw_parse_id_header (struct wm_adsp *dsp, +struct wmfw_id_hdr *fw,int nalgs) +{ + dsp->fw_id =be32_to_cpu (fw->id); + dsp->fw_id_version =be32_to_cpu (fw->ver); + +adsp_info (dsp,"Firmware: %x v%d.%d.%d, %zu algorithms\n" , + dsp->fw_id, (dsp->fw_id_version &0xff0000 ) >>16 , + (dsp->fw_id_version &0xff00 ) >>8 , dsp->fw_id_version &0xff , + nalgs); +} +static int wm_adsp1_setup_algs (struct wm_adsp *dsp) {struct wmfw_adsp1_id_hdr adsp1_id;
@@ -2005,13 +2017,8 @@ static int wm_adsp1_setup_algs(struct wm_adsp *dsp) } n_algs =be32_to_cpu (adsp1_id.n_algs); - dsp->fw_id =be32_to_cpu (adsp1_id.fw.id); -adsp_info (dsp,"Firmware: %x v%d.%d.%d, %zu algorithms\n" , - dsp->fw_id, - (be32_to_cpu (adsp1_id.fw.ver) &0xff0000 ) >>16 , - (be32_to_cpu (adsp1_id.fw.ver) &0xff00 ) >>8 , -be32_to_cpu (adsp1_id.fw.ver) &0xff , - n_algs); + +wmfw_parse_id_header (dsp, &adsp1_id.fw, n_algs); alg_region =wm_adsp_create_region (dsp,WMFW_ADSP1_ZM , adsp1_id.fw.id, adsp1_id.zm);
@@ -2111,14 +2118,8 @@ static int wm_adsp2_setup_algs(struct wm_adsp *dsp) } n_algs =be32_to_cpu (adsp2_id.n_algs); - dsp->fw_id =be32_to_cpu (adsp2_id.fw.id); - dsp->fw_id_version =be32_to_cpu (adsp2_id.fw.ver); -adsp_info (dsp,"Firmware: %x v%d.%d.%d, %zu algorithms\n" , - dsp->fw_id, - (dsp->fw_id_version &0xff0000 ) >>16 , - (dsp->fw_id_version &0xff00 ) >>8 , - dsp->fw_id_version &0xff , - n_algs); + +wmfw_parse_id_header (dsp, &adsp2_id.fw, n_algs); alg_region =wm_adsp_create_region (dsp,WMFW_ADSP2_XM , adsp2_id.fw.id, adsp2_id.xm);
Signature · 1 line
2.11.0
Mark Brown
maintainerApplied "ASoC: wm_adsp: Factor out parsing of firmware ID header" to the asoc tree
The patch
ASoC: wm_adsp: Factor out parsing of firmware ID header
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
a5dcb24d70ffbb4ea47b8eefad1158d033b9dec9Mon Sep 17 00:00:00 2001
From: Charles Keepax <[email protected]>
Date: Tue, 19 Mar 2019 11:52:11 +0000
Subject: [PATCH] ASoC: wm_adsp: Factor out parsing of firmware ID header
There is no need to duplicate this code for both ADSP1 and 2 as the handling is exactly the same.
--- sound/soc/codecs/wm_adsp.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
sound/soc/codecs/wm_adsp.c +16 -15
@@ -1982,6 +1982,18 @@ static void wm_adsp_free_alg_regions(struct wm_adsp *dsp) } } +static void wmfw_parse_id_header (struct wm_adsp *dsp, +struct wmfw_id_hdr *fw,int nalgs) +{ + dsp->fw_id =be32_to_cpu (fw->id); + dsp->fw_id_version =be32_to_cpu (fw->ver); + +adsp_info (dsp,"Firmware: %x v%d.%d.%d, %zu algorithms\n" , + dsp->fw_id, (dsp->fw_id_version &0xff0000 ) >>16 , + (dsp->fw_id_version &0xff00 ) >>8 , dsp->fw_id_version &0xff , + nalgs); +} +static int wm_adsp1_setup_algs (struct wm_adsp *dsp) {struct wmfw_adsp1_id_hdr adsp1_id;
@@ -2005,13 +2017,8 @@ static int wm_adsp1_setup_algs(struct wm_adsp *dsp) } n_algs =be32_to_cpu (adsp1_id.n_algs); - dsp->fw_id =be32_to_cpu (adsp1_id.fw.id); -adsp_info (dsp,"Firmware: %x v%d.%d.%d, %zu algorithms\n" , - dsp->fw_id, - (be32_to_cpu (adsp1_id.fw.ver) &0xff0000 ) >>16 , - (be32_to_cpu (adsp1_id.fw.ver) &0xff00 ) >>8 , -be32_to_cpu (adsp1_id.fw.ver) &0xff , - n_algs); + +wmfw_parse_id_header (dsp, &adsp1_id.fw, n_algs); alg_region =wm_adsp_create_region (dsp,WMFW_ADSP1_ZM , adsp1_id.fw.id, adsp1_id.zm);
@@ -2111,14 +2118,8 @@ static int wm_adsp2_setup_algs(struct wm_adsp *dsp) } n_algs =be32_to_cpu (adsp2_id.n_algs); - dsp->fw_id =be32_to_cpu (adsp2_id.fw.id); - dsp->fw_id_version =be32_to_cpu (adsp2_id.fw.ver); -adsp_info (dsp,"Firmware: %x v%d.%d.%d, %zu algorithms\n" , - dsp->fw_id, - (dsp->fw_id_version &0xff0000 ) >>16 , - (dsp->fw_id_version &0xff00 ) >>8 , - dsp->fw_id_version &0xff , - n_algs); + +wmfw_parse_id_header (dsp, &adsp2_id.fw, n_algs); alg_region =wm_adsp_create_region (dsp,WMFW_ADSP2_XM , adsp2_id.fw.id, adsp2_id.xm);
Signature · 1 line
2.20.1
Charles Keepax
maintainerPATCH 9/12 ASoC: wm_adsp: Factor out DSP specific operations
In reply to Charles KeepaxIn preparation for the addition of more types of DSP core refactor the handling of DSP specific operations such as starting the memory or enabling the core into a set of callbacks. This should make it easier to add new core types and allow for more code reuse between them.
--- sound/soc/codecs/cs47l24.c | 2 +- sound/soc/codecs/wm5102.c | 2 +- sound/soc/codecs/wm5110.c | 2 +- sound/soc/codecs/wm_adsp.c | 383 ++++++++++++++++++++++++++++----------------- sound/soc/codecs/wm_adsp.h | 35 ++++- 5 files changed, 271 insertions(+), 153 deletions(-)
sound/soc/codecs/cs47l24.c +1 -1
@@ -77,7 +77,7 @@ static int cs47l24_adsp_power_ev(struct snd_soc_dapm_widget *w,wm_adsp2_set_dspclk (w, v); -return wm_adsp2_early_event (w, kcontrol, event); +return wm_adsp_early_event (w, kcontrol, event); } static DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
sound/soc/codecs/wm5102.c +1 -1
@@ -661,7 +661,7 @@ static int wm5102_adsp_power_ev(struct snd_soc_dapm_widget *w,break ; } -return wm_adsp2_early_event (w, kcontrol, event); +return wm_adsp_early_event (w, kcontrol, event); } static int wm5102_out_comp_coeff_get(struct snd_kcontrol *kcontrol,
sound/soc/codecs/wm5110.c +1 -1
@@ -213,7 +213,7 @@ static int wm5110_adsp_power_ev(struct snd_soc_dapm_widget *w,wm_adsp2_set_dspclk (w, v); -return wm_adsp2_early_event (w, kcontrol, event); +return wm_adsp_early_event (w, kcontrol, event); }static const struct reg_sequence wm5110_no_dre_left_enable[] = {
sound/soc/codecs/wm_adsp.c +238 -145
551 lines not on this page · raw message
sound/soc/codecs/wm_adsp.h +30 -5
@@ -54,6 +54,7 @@ struct wm_adsp_alg_region {struct wm_adsp_compr ;struct wm_adsp_compr_buf ; +struct wm_adsp_ops ;struct wm_adsp {const char *part;
@@ -66,6 +67,8 @@ struct wm_adsp {struct regmap *regmap;struct snd_soc_component *component; +struct wm_adsp_ops *ops; +unsigned int base;unsigned int sysclk_reg;unsigned int sysclk_mask;
@@ -106,6 +109,28 @@ struct wm_adsp { }; +struct wm_adsp_ops { +bool (*validate_version)(struct wm_adsp *dsp,unsigned int version); +unsigned int (*parse_sizes)(struct wm_adsp *dsp, +const char *const file, +unsigned int pos, +const struct firmware *firmware); +int (*setup_algs)(struct wm_adsp *dsp); + +void (*show_fw_status)(struct wm_adsp *dsp); +void (*stop_watchdog)(struct wm_adsp *dsp); + +int (*enable_memory)(struct wm_adsp *dsp); +void (*disable_memory)(struct wm_adsp *dsp); +int (*lock_memory)(struct wm_adsp *dsp,unsigned int lock_regions); + +int (*enable_core)(struct wm_adsp *dsp); +void (*disable_core)(struct wm_adsp *dsp); + +int (*start_core)(struct wm_adsp *dsp); +void (*stop_core)(struct wm_adsp *dsp); +}; +#define WM_ADSP1 (wname, num) \ SND_SOC_DAPM_PGA_E(wname, SND_SOC_NOPM, num, 0, NULL, 0, \ wm_adsp1_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD)
@@ -121,7 +146,7 @@ struct wm_adsp { .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD, \ .subseq = 100, /* Ensure we run after SYSCLK supply widget */ }, \ { .id = snd_soc_dapm_out_drv, .name = wname, \ - .reg = SND_SOC_NOPM, .shift = num, .event = wm_adsp2_event, \ + .reg = SND_SOC_NOPM, .shift = num, .event = wm_adsp_event, \ .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD }#define WM_ADSP_FW_CONTROL (dspname, num) \
@@ -138,13 +163,13 @@ int wm_adsp2_component_remove(struct wm_adsp *dsp, struct snd_soc_component *comint wm_adsp1_event (struct snd_soc_dapm_widget *w,struct snd_kcontrol *kcontrol,int event); -int wm_adsp2_early_event (struct snd_soc_dapm_widget *w, -struct snd_kcontrol *kcontrol,int event); +int wm_adsp_early_event (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *kcontrol,int event);irqreturn_t wm_adsp2_bus_error (struct wm_adsp *adsp); -int wm_adsp2_event (struct snd_soc_dapm_widget *w, -struct snd_kcontrol *kcontrol,int event); +int wm_adsp_event (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *kcontrol,int event);int wm_adsp2_set_dspclk (struct snd_soc_dapm_widget *w,unsigned int freq);
Signature · 1 line
2.11.0
Mark Brown
maintainerApplied "ASoC: wm_adsp: Factor out DSP specific operations" to the asoc tree
The patch
ASoC: wm_adsp: Factor out DSP specific operations
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
4e08d50d1fb6144df4b0b5c75a17edd344bf3d1bMon Sep 17 00:00:00 2001
From: Charles Keepax <[email protected]>
Date: Tue, 19 Mar 2019 11:52:12 +0000
Subject: [PATCH] ASoC: wm_adsp: Factor out DSP specific operations
In preparation for the addition of more types of DSP core refactor the handling of DSP specific operations such as starting the memory or enabling the core into a set of callbacks. This should make it easier to add new core types and allow for more code reuse between them.
--- sound/soc/codecs/cs47l24.c | 2 +- sound/soc/codecs/wm5102.c | 2 +- sound/soc/codecs/wm5110.c | 2 +- sound/soc/codecs/wm_adsp.c | 383 +++++++++++++++++++++++-------------- sound/soc/codecs/wm_adsp.h | 35 +++- 5 files changed, 271 insertions(+), 153 deletions(-)
sound/soc/codecs/cs47l24.c +1 -1
@@ -77,7 +77,7 @@ static int cs47l24_adsp_power_ev(struct snd_soc_dapm_widget *w,wm_adsp2_set_dspclk (w, v); -return wm_adsp2_early_event (w, kcontrol, event); +return wm_adsp_early_event (w, kcontrol, event); } static DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
sound/soc/codecs/wm5102.c +1 -1
@@ -661,7 +661,7 @@ static int wm5102_adsp_power_ev(struct snd_soc_dapm_widget *w,break ; } -return wm_adsp2_early_event (w, kcontrol, event); +return wm_adsp_early_event (w, kcontrol, event); } static int wm5102_out_comp_coeff_get(struct snd_kcontrol *kcontrol,
sound/soc/codecs/wm5110.c +1 -1
@@ -213,7 +213,7 @@ static int wm5110_adsp_power_ev(struct snd_soc_dapm_widget *w,wm_adsp2_set_dspclk (w, v); -return wm_adsp2_early_event (w, kcontrol, event); +return wm_adsp_early_event (w, kcontrol, event); }static const struct reg_sequence wm5110_no_dre_left_enable[] = {
sound/soc/codecs/wm_adsp.c +238 -145
551 lines not on this page · raw message
sound/soc/codecs/wm_adsp.h +30 -5
@@ -54,6 +54,7 @@ struct wm_adsp_alg_region {struct wm_adsp_compr ;struct wm_adsp_compr_buf ; +struct wm_adsp_ops ;struct wm_adsp {const char *part;
@@ -66,6 +67,8 @@ struct wm_adsp {struct regmap *regmap;struct snd_soc_component *component; +struct wm_adsp_ops *ops; +unsigned int base;unsigned int sysclk_reg;unsigned int sysclk_mask;
@@ -106,6 +109,28 @@ struct wm_adsp { }; +struct wm_adsp_ops { +bool (*validate_version)(struct wm_adsp *dsp,unsigned int version); +unsigned int (*parse_sizes)(struct wm_adsp *dsp, +const char *const file, +unsigned int pos, +const struct firmware *firmware); +int (*setup_algs)(struct wm_adsp *dsp); + +void (*show_fw_status)(struct wm_adsp *dsp); +void (*stop_watchdog)(struct wm_adsp *dsp); + +int (*enable_memory)(struct wm_adsp *dsp); +void (*disable_memory)(struct wm_adsp *dsp); +int (*lock_memory)(struct wm_adsp *dsp,unsigned int lock_regions); + +int (*enable_core)(struct wm_adsp *dsp); +void (*disable_core)(struct wm_adsp *dsp); + +int (*start_core)(struct wm_adsp *dsp); +void (*stop_core)(struct wm_adsp *dsp); +}; +#define WM_ADSP1 (wname, num) \ SND_SOC_DAPM_PGA_E(wname, SND_SOC_NOPM, num, 0, NULL, 0, \ wm_adsp1_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD)
@@ -121,7 +146,7 @@ struct wm_adsp { .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD, \ .subseq = 100, /* Ensure we run after SYSCLK supply widget */ }, \ { .id = snd_soc_dapm_out_drv, .name = wname, \ - .reg = SND_SOC_NOPM, .shift = num, .event = wm_adsp2_event, \ + .reg = SND_SOC_NOPM, .shift = num, .event = wm_adsp_event, \ .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD }#define WM_ADSP_FW_CONTROL (dspname, num) \
@@ -138,13 +163,13 @@ int wm_adsp2_component_remove(struct wm_adsp *dsp, struct snd_soc_component *comint wm_adsp1_event (struct snd_soc_dapm_widget *w,struct snd_kcontrol *kcontrol,int event); -int wm_adsp2_early_event (struct snd_soc_dapm_widget *w, -struct snd_kcontrol *kcontrol,int event); +int wm_adsp_early_event (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *kcontrol,int event);irqreturn_t wm_adsp2_bus_error (struct wm_adsp *adsp); -int wm_adsp2_event (struct snd_soc_dapm_widget *w, -struct snd_kcontrol *kcontrol,int event); +int wm_adsp_event (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *kcontrol,int event);int wm_adsp2_set_dspclk (struct snd_soc_dapm_widget *w,unsigned int freq);
Signature · 1 line
2.20.1
Charles Keepax
maintainerPATCH 10/12 ASoC: wm_adsp: Add support for new Halo core DSPs
In reply to Charles KeepaxFrom: Wen Shi <[email protected]>
The Halo core is a new generation of audio DSP architecture from Cirrus Logic. A new iteration of the WMFW file format (v3) is also added, for this new architecture. Currently this format is not supported on the old ADSP2 architecture however support may be added for it in the future.
--- sound/soc/codecs/wm_adsp.c | 354 +++++++++++++++++++++++++++++++++++++++++---- sound/soc/codecs/wm_adsp.h | 8 + sound/soc/codecs/wmfw.h | 30 ++++ 3 files changed, 363 insertions(+), 29 deletions(-)
sound/soc/codecs/wm_adsp.c +325 -29
@@ -227,8 +227,54 @@*/ #define WM_ADSP_FW_EVENT_SHUTDOWN 0x000001 +/* +* HALO core +*/ +#define HALO_SCRATCH1 0x005c0 +#define HALO_SCRATCH2 0x005c8 +#define HALO_SCRATCH3 0x005d0 +#define HALO_SCRATCH4 0x005d8 +#define HALO_CCM_CORE_CONTROL 0x41000 +#define HALO_CORE_SOFT_RESET 0x00010 + +/* +* HALO MPU banks +*/ +#define HALO_MPU_XMEM_ACCESS_0 0x43000 +#define HALO_MPU_YMEM_ACCESS_0 0x43004 +#define HALO_MPU_WINDOW_ACCESS_0 0x43008 +#define HALO_MPU_XREG_ACCESS_0 0x4300C +#define HALO_MPU_YREG_ACCESS_0 0x43014 +#define HALO_MPU_XMEM_ACCESS_1 0x43018 +#define HALO_MPU_YMEM_ACCESS_1 0x4301C +#define HALO_MPU_WINDOW_ACCESS_1 0x43020 +#define HALO_MPU_XREG_ACCESS_1 0x43024 +#define HALO_MPU_YREG_ACCESS_1 0x4302C +#define HALO_MPU_XMEM_ACCESS_2 0x43030 +#define HALO_MPU_YMEM_ACCESS_2 0x43034 +#define HALO_MPU_WINDOW_ACCESS_2 0x43038 +#define HALO_MPU_XREG_ACCESS_2 0x4303C +#define HALO_MPU_YREG_ACCESS_2 0x43044 +#define HALO_MPU_XMEM_ACCESS_3 0x43048 +#define HALO_MPU_YMEM_ACCESS_3 0x4304C +#define HALO_MPU_WINDOW_ACCESS_3 0x43050 +#define HALO_MPU_XREG_ACCESS_3 0x43054 +#define HALO_MPU_YREG_ACCESS_3 0x4305C +#define HALO_MPU_LOCK_CONFIG 0x43140 + +/* +* HALO_CCM_CORE_CONTROL +*/ +#define HALO_CORE_EN 0x00000001 + +/* +* HALO_CORE_SOFT_RESET +*/ +#define HALO_CORE_SOFT_RESET_MASK 0x00000001 +struct wm_adsp_ops wm_adsp1_ops;struct wm_adsp_ops wm_adsp2_ops[]; +struct wm_adsp_ops wm_halo_ops;struct wm_adsp_buf {struct list_head list;
@@ -309,6 +355,12 @@ struct wm_adsp_system_config_xm_hdr {__be32 build_job_number; }; +struct wm_halo_system_config_xm_hdr { +__be32 halo_heartbeat; +__be32 build_job_name[3 ]; +__be32 build_job_number; +}; +struct wm_adsp_alg_xm_struct {__be32 magic;__be32 smoothing;
@@ -535,12 +587,18 @@ static const char *wm_adsp_mem_region_name(unsigned int type)switch (type) {case WMFW_ADSP1_PM :return "PM" ; +case WMFW_HALO_PM_PACKED : +return "PM_PACKED" ;case WMFW_ADSP1_DM :return "DM" ;case WMFW_ADSP2_XM :return "XM" ; +case WMFW_HALO_XM_PACKED : +return "XM_PACKED" ;case WMFW_ADSP2_YM :return "YM" ; +case WMFW_HALO_YM_PACKED : +return "YM_PACKED" ;case WMFW_ADSP1_ZM :return "ZM" ;default :
@@ -772,17 +830,12 @@ static struct wm_adsp_region const *wm_adsp_find_region(struct wm_adsp *dsp,static unsigned int wm_adsp_region_to_reg (struct wm_adsp_region const *mem,unsigned int offset) { -if (WARN_ON (!mem)) -return offset;switch (mem->type) {case WMFW_ADSP1_PM :return mem->base + (offset *3 );case WMFW_ADSP1_DM : -return mem->base + (offset *2 );case WMFW_ADSP2_XM : -return mem->base + (offset *2 );case WMFW_ADSP2_YM : -return mem->base + (offset *2 );case WMFW_ADSP1_ZM :return mem->base + (offset *2 );default :
@@ -791,6 +844,24 @@ static unsigned int wm_adsp_region_to_reg(struct wm_adsp_region const *mem, } } +static unsigned int wm_halo_region_to_reg (struct wm_adsp_region const *mem, +unsigned int offset) +{ +switch (mem->type) { +case WMFW_ADSP2_XM : +case WMFW_ADSP2_YM : +return mem->base + (offset *4 ); +case WMFW_HALO_XM_PACKED : +case WMFW_HALO_YM_PACKED : +return (mem->base + (offset *3 )) & ~0x3 ; +case WMFW_HALO_PM_PACKED : +return mem->base + (offset *5 ); +default : +WARN (1 ,"Unknown memory region type" ); +return offset; + } +} +static void wm_adsp_read_fw_status (struct wm_adsp *dsp,int noffs,unsigned int *offs) {
@@ -829,6 +900,18 @@ static void wm_adsp2v2_show_fw_status(struct wm_adsp *dsp) offs[1] & 0xFFFF, offs[1] >> 16); } +static void wm_halo_show_fw_status (struct wm_adsp *dsp) +{ +unsigned int offs[] = { +HALO_SCRATCH1 ,HALO_SCRATCH2 ,HALO_SCRATCH3 ,HALO_SCRATCH4 , + }; + +wm_adsp_read_fw_status (dsp,ARRAY_SIZE (offs), offs); + +adsp_dbg (dsp,"FW SCRATCH 0:0x%x 1:0x%x 2:0x%x 3:0x%x\n" , + offs[0 ], offs[1 ], offs[2 ], offs[3 ]); +} +static inline struct wm_coeff_ctl *bytes_ext_to_ctl (struct soc_bytes_ext *ext) { return container_of(ext, struct wm_coeff_ctl, bytes_ext);
@@ -847,7 +930,7 @@ static int wm_coeff_base_reg(struct wm_coeff_ctl *ctl, unsigned int *reg)return -EINVAL ; } - *reg =wm_adsp_region_to_reg (mem, ctl->alg_region.base + ctl->offset); + *reg = dsp->ops->region_to_reg (mem, ctl->alg_region.base + ctl->offset);return 0 ; }
@@ -1335,28 +1418,33 @@ static int wm_adsp_create_control(struct wm_adsp *dsp,case 1 :snprintf (name,SNDRV_CTL_ELEM_ID_NAME_MAXLEN ,"%s %s %x" , dsp->name, region_name, alg_region->alg); + subname =NULL ;/* don't append subname */ break ; -default : +case 2 : ret =snprintf (name,SNDRV_CTL_ELEM_ID_NAME_MAXLEN ,"%s%c %.12s %x" , dsp->name, *region_name, wm_adsp_fw_text[dsp->fw], alg_region->alg); +break ; +default : + ret =snprintf (name,SNDRV_CTL_ELEM_ID_NAME_MAXLEN , +"%s %.12s %x" , dsp->name, + wm_adsp_fw_text[dsp->fw], alg_region->alg); +break ; + } -/* Truncate the subname from the start if it is too long */ -if (subname) { -int avail =SNDRV_CTL_ELEM_ID_NAME_MAXLEN - ret -2 ; -int skip =0 ; +if (subname) { +int avail =SNDRV_CTL_ELEM_ID_NAME_MAXLEN - ret -2 ; +int skip =0 ; -if (dsp->component->name_prefix) - avail -=strlen (dsp->component->name_prefix) +1 ; +if (dsp->component->name_prefix) + avail -=strlen (dsp->component->name_prefix) +1 ; -if (subname_len > avail) - skip = subname_len - avail; +/* Truncate the subname from the start if it is too long */ +if (subname_len > avail) + skip = subname_len - avail; -snprintf (name + ret, -SNDRV_CTL_ELEM_ID_NAME_MAXLEN - ret," %.*s" , - subname_len - skip, subname + skip); - } -break ; +snprintf (name + ret,SNDRV_CTL_ELEM_ID_NAME_MAXLEN - ret, +" %.*s" , subname_len - skip, subname + skip); }list_for_each_entry (ctl, &dsp->ctl_list, list) {
@@ -1689,6 +1777,16 @@ static bool wm_adsp_validate_version(struct wm_adsp *dsp, unsigned int version) } } +static bool wm_halo_validate_version (struct wm_adsp *dsp,unsigned int version) +{ +switch (version) { +case 3 : +return true; +default : +return false; + } +} +static int wm_adsp_load (struct wm_adsp *dsp) {LIST_HEAD (buf_list);
@@ -1774,7 +1872,6 @@ static int wm_adsp_load(struct wm_adsp *dsp) text =NULL ; offset =le32_to_cpu (region->offset) &0xffffff ; type =be32_to_cpu (region->type) &0xff ; - mem =wm_adsp_find_region (dsp, type);switch (type) {case WMFW_NAME_TEXT :
@@ -1802,8 +1899,17 @@ static int wm_adsp_load(struct wm_adsp *dsp)case WMFW_ADSP2_XM :case WMFW_ADSP2_YM :case WMFW_ADSP1_ZM : +case WMFW_HALO_PM_PACKED : +case WMFW_HALO_XM_PACKED : +case WMFW_HALO_YM_PACKED : + mem =wm_adsp_find_region (dsp, type); +if (!mem) { +adsp_err (dsp,"No region of type: %x\n" , type); + goto out_fw; + } + region_name =wm_adsp_mem_region_name (type); - reg =wm_adsp_region_to_reg (mem, offset); + reg = dsp->ops->region_to_reg (mem, offset);break ;default : adsp_warn(dsp,
@@ -1916,7 +2022,7 @@ static void *wm_adsp_read_algs(struct wm_adsp *dsp, size_t n_algs, }/* Read the terminator first to validate the length */ - reg =wm_adsp_region_to_reg (mem, pos + len); + reg = dsp->ops->region_to_reg (mem, pos + len); ret =regmap_raw_read (dsp->regmap, reg, &val,sizeof (val));if (ret !=0 ) {
@@ -1936,7 +2042,7 @@ static void *wm_adsp_read_algs(struct wm_adsp *dsp, size_t n_algs,if (!alg)return ERR_PTR (-ENOMEM ); - reg =wm_adsp_region_to_reg (mem, pos); + reg = dsp->ops->region_to_reg (mem, pos); ret =regmap_raw_read (dsp->regmap, reg, alg, len);if (ret !=0 ) {
@@ -2008,6 +2114,35 @@ static void wmfw_parse_id_header(struct wm_adsp *dsp, nalgs); } +static void wmfw_v3_parse_id_header (struct wm_adsp *dsp, +struct wmfw_v3_id_hdr *fw,int nalgs) +{ + dsp->fw_id =be32_to_cpu (fw->id); + dsp->fw_id_version =be32_to_cpu (fw->ver); + dsp->fw_vendor_id =be32_to_cpu (fw->vendor_id); + +adsp_info (dsp,"Firmware: %x vendor: 0x%x v%d.%d.%d, %zu algorithms\n" , + dsp->fw_id, dsp->fw_vendor_id, + (dsp->fw_id_version &0xff0000 ) >>16 , + (dsp->fw_id_version &0xff00 ) >>8 , dsp->fw_id_version &0xff , + nalgs); +} + +static int wm_adsp_create_regions (struct wm_adsp *dsp,__be32 id,int nregions, +int *type,__be32 *base) +{ +struct wm_adsp_alg_region *alg_region; +int i; + +for (i =0 ; i < nregions; i++) { + alg_region =wm_adsp_create_region (dsp, type[i], id, base[i]); +if (IS_ERR (alg_region)) +return PTR_ERR (alg_region); + } + +return 0 ; +} +static int wm_adsp1_setup_algs (struct wm_adsp *dsp) {struct wmfw_adsp1_id_hdr adsp1_id;
@@ -2238,6 +2373,78 @@ static int wm_adsp2_setup_algs(struct wm_adsp *dsp)return ret; } +static int wm_halo_create_regions (struct wm_adsp *dsp,__be32 id, +__be32 xm_base,__be32 ym_base) +{ +int types[] = { +WMFW_ADSP2_XM ,WMFW_HALO_XM_PACKED , +WMFW_ADSP2_YM ,WMFW_HALO_YM_PACKED + }; +__be32 bases[] = { xm_base, xm_base, ym_base, ym_base }; + +return wm_adsp_create_regions (dsp, id,ARRAY_SIZE (types), types, bases); +} + +static int wm_halo_setup_algs (struct wm_adsp *dsp) +{ +struct wmfw_halo_id_hdr halo_id; +struct wmfw_halo_alg_hdr *halo_alg; +const struct wm_adsp_region *mem; +unsigned int pos, len; +size_t n_algs; +int i, ret; + + mem =wm_adsp_find_region (dsp,WMFW_ADSP2_XM ); +if (WARN_ON (!mem)) +return -EINVAL ; + + ret =regmap_raw_read (dsp->regmap, mem->base, &halo_id, +sizeof (halo_id)); +if (ret !=0 ) { +adsp_err (dsp,"Failed to read algorithm info: %d\n" , + ret); +return ret; + } + + n_algs =be32_to_cpu (halo_id.n_algs); + +wmfw_v3_parse_id_header (dsp, &halo_id.fw, n_algs); + + ret =wm_halo_create_regions (dsp, halo_id.fw.id, + halo_id.ym_base, halo_id.ym_base); +if (ret) +return ret; + +/* Calculate offset and length in DSP words */ + pos =sizeof (halo_id) /sizeof (u32); + len = (sizeof (*halo_alg) * n_algs) /sizeof (u32); + + halo_alg =wm_adsp_read_algs (dsp, n_algs, mem, pos, len); +if (IS_ERR (halo_alg)) +return PTR_ERR (halo_alg); + +for (i =0 ; i < n_algs; i++) { +adsp_info (dsp, +"%d: ID %x v%d.%d.%d XM@%x YM@%x\n" , + i,be32_to_cpu (halo_alg[i].alg.id), + (be32_to_cpu (halo_alg[i].alg.ver) &0xff0000 ) >>16 , + (be32_to_cpu (halo_alg[i].alg.ver) &0xff00 ) >>8 , +be32_to_cpu (halo_alg[i].alg.ver) &0xff , +be32_to_cpu (halo_alg[i].xm_base), +be32_to_cpu (halo_alg[i].ym_base)); + + ret =wm_halo_create_regions (dsp, halo_alg[i].alg.id, + halo_alg[i].xm_base, + halo_alg[i].ym_base); +if (ret) + goto out; + } + +out: +kfree (halo_alg); +return ret; +} +static int wm_adsp_load_coeff (struct wm_adsp *dsp) {LIST_HEAD (buf_list);
@@ -2332,7 +2539,7 @@ static int wm_adsp_load_coeff(struct wm_adsp *dsp)adsp_err (dsp,"No ZM\n" );break ; } - reg =wm_adsp_region_to_reg (mem,0 ); + reg = dsp->ops->region_to_reg (mem,0 ); }else { region_name ="register" ;
@@ -2344,6 +2551,9 @@ static int wm_adsp_load_coeff(struct wm_adsp *dsp)case WMFW_ADSP1_ZM :case WMFW_ADSP2_XM :case WMFW_ADSP2_YM : +case WMFW_HALO_XM_PACKED : +case WMFW_HALO_YM_PACKED : +case WMFW_HALO_PM_PACKED :adsp_dbg (dsp,"%s.%d: %d bytes in %x for %x\n" , file, blocks,le32_to_cpu (blk->len), type,le32_to_cpu (blk->id));
@@ -2358,7 +2568,7 @@ static int wm_adsp_load_coeff(struct wm_adsp *dsp) le32_to_cpu(blk->id));if (alg_region) { reg = alg_region->base; - reg =wm_adsp_region_to_reg (mem, reg); + reg = dsp->ops->region_to_reg (mem, reg); reg += offset; }else { adsp_err(dsp, "No %x for algorithm %x\n",
@@ -2748,6 +2958,37 @@ static void wm_adsp_boot_work(struct work_struct *work)mutex_unlock (&dsp->pwr_lock); } +static int wm_halo_configure_mpu (struct wm_adsp *dsp,unsigned int lock_regions) +{ +struct reg_sequence config[] = { + { dsp->base +HALO_MPU_LOCK_CONFIG ,0x5555 }, + { dsp->base +HALO_MPU_LOCK_CONFIG ,0xAAAA }, + { dsp->base +HALO_MPU_XMEM_ACCESS_0 ,0xFFFFFFFF }, + { dsp->base +HALO_MPU_YMEM_ACCESS_0 ,0xFFFFFFFF }, + { dsp->base +HALO_MPU_WINDOW_ACCESS_0 , lock_regions }, + { dsp->base +HALO_MPU_XREG_ACCESS_0 , lock_regions }, + { dsp->base +HALO_MPU_YREG_ACCESS_0 , lock_regions }, + { dsp->base +HALO_MPU_XMEM_ACCESS_1 ,0xFFFFFFFF }, + { dsp->base +HALO_MPU_YMEM_ACCESS_1 ,0xFFFFFFFF }, + { dsp->base +HALO_MPU_WINDOW_ACCESS_1 , lock_regions }, + { dsp->base +HALO_MPU_XREG_ACCESS_1 , lock_regions }, + { dsp->base +HALO_MPU_YREG_ACCESS_1 , lock_regions }, + { dsp->base +HALO_MPU_XMEM_ACCESS_2 ,0xFFFFFFFF }, + { dsp->base +HALO_MPU_YMEM_ACCESS_2 ,0xFFFFFFFF }, + { dsp->base +HALO_MPU_WINDOW_ACCESS_2 , lock_regions }, + { dsp->base +HALO_MPU_XREG_ACCESS_2 , lock_regions }, + { dsp->base +HALO_MPU_YREG_ACCESS_2 , lock_regions }, + { dsp->base +HALO_MPU_XMEM_ACCESS_3 ,0xFFFFFFFF }, + { dsp->base +HALO_MPU_YMEM_ACCESS_3 ,0xFFFFFFFF }, + { dsp->base +HALO_MPU_WINDOW_ACCESS_3 , lock_regions }, + { dsp->base +HALO_MPU_XREG_ACCESS_3 , lock_regions }, + { dsp->base +HALO_MPU_YREG_ACCESS_3 , lock_regions }, + { dsp->base +HALO_MPU_LOCK_CONFIG ,0 }, + }; + +return regmap_multi_reg_write (dsp->regmap, config,ARRAY_SIZE (config)); +} +int wm_adsp2_set_dspclk (struct snd_soc_dapm_widget *w,unsigned int freq) {struct snd_soc_component *component =snd_soc_dapm_to_component (w->dapm);
@@ -2970,6 +3211,23 @@ int wm_adsp_event(struct snd_soc_dapm_widget *w, }EXPORT_SYMBOL_GPL (wm_adsp_event); +static int wm_halo_start_core (struct wm_adsp *dsp) +{ +return regmap_update_bits (dsp->regmap, + dsp->base +HALO_CCM_CORE_CONTROL , +HALO_CORE_EN ,HALO_CORE_EN ); +} + +static void wm_halo_stop_core (struct wm_adsp *dsp) +{ +regmap_update_bits (dsp->regmap, dsp->base +HALO_CCM_CORE_CONTROL , +HALO_CORE_EN ,0 ); + +/* reset halo core with CORE_SOFT_REEST */ +regmap_update_bits (dsp->regmap, dsp->base +HALO_CORE_SOFT_RESET , +HALO_CORE_SOFT_RESET_MASK ,1 ); +} +int wm_adsp2_component_probe (struct wm_adsp *dsp,struct snd_soc_component *component) {char preload[32 ];
@@ -3031,6 +3289,22 @@ int wm_adsp2_init(struct wm_adsp *dsp) }EXPORT_SYMBOL_GPL (wm_adsp2_init); +int wm_halo_init (struct wm_adsp *dsp) +{ +int ret; + + ret =wm_adsp_common_init (dsp); +if (ret) +return ret; + + dsp->ops = &wm_halo_ops; + +INIT_WORK (&dsp->boot_work, wm_adsp_boot_work); + +return 0 ; +} +EXPORT_SYMBOL_GPL (wm_halo_init); +void wm_adsp2_remove (struct wm_adsp *dsp) {struct wm_coeff_ctl *ctl;
@@ -3275,7 +3549,7 @@ static int wm_adsp_read_data_block(struct wm_adsp *dsp, int mem_type,if (!mem)return -EINVAL ; - reg =wm_adsp_region_to_reg (mem, mem_addr); + reg = dsp->ops->region_to_reg (mem, mem_addr); ret =regmap_raw_read (dsp->regmap, reg, data,sizeof (*data) * num_words);
@@ -3303,7 +3577,7 @@ static int wm_adsp_write_data_word(struct wm_adsp *dsp, int mem_type,if (!mem)return -EINVAL ; - reg =wm_adsp_region_to_reg (mem, mem_addr); + reg = dsp->ops->region_to_reg (mem, mem_addr); data =cpu_to_be32 (data &0x00ffffffu );
@@ -3414,7 +3688,7 @@ static int wm_adsp_buffer_parse_legacy(struct wm_adsp *dsp)return -ENOMEM ; alg_region =wm_adsp_find_alg_region (dsp,WMFW_ADSP2_XM , dsp->fw_id); - xmalg =sizeof (struct wm_adsp_system_config_xm_hdr ) /sizeof (__be32); + xmalg = dsp->ops->sys_config_size /sizeof (__be32); addr = alg_region->base + xmalg +ALG_XM_FIELD (magic); ret =wm_adsp_read_data_word (dsp,WMFW_ADSP2_XM , addr, &magic);
@@ -4024,13 +4298,16 @@ EXPORT_SYMBOL_GPL(wm_adsp2_bus_error);struct wm_adsp_ops wm_adsp1_ops = { .validate_version = wm_adsp_validate_version, .parse_sizes = wm_adsp1_parse_sizes, + .region_to_reg = wm_adsp_region_to_reg, };struct wm_adsp_ops wm_adsp2_ops[] = { { + .sys_config_size =sizeof (struct wm_adsp_system_config_xm_hdr ), .parse_sizes = wm_adsp2_parse_sizes, .validate_version = wm_adsp_validate_version, .setup_algs = wm_adsp2_setup_algs, + .region_to_reg = wm_adsp_region_to_reg, .show_fw_status = wm_adsp2_show_fw_status,
@@ -4045,9 +4322,11 @@ struct wm_adsp_ops wm_adsp2_ops[] = { }, { + .sys_config_size = sizeof(struct wm_adsp_system_config_xm_hdr), .parse_sizes = wm_adsp2_parse_sizes, .validate_version = wm_adsp_validate_version, .setup_algs = wm_adsp2_setup_algs, + .region_to_reg = wm_adsp_region_to_reg, .show_fw_status = wm_adsp2v2_show_fw_status,
@@ -4062,9 +4341,11 @@ struct wm_adsp_ops wm_adsp2_ops[] = { .stop_core = wm_adsp2_stop_core, }, { + .sys_config_size = sizeof(struct wm_adsp_system_config_xm_hdr), .parse_sizes = wm_adsp2_parse_sizes, .validate_version = wm_adsp_validate_version, .setup_algs = wm_adsp2_setup_algs, + .region_to_reg = wm_adsp_region_to_reg, .show_fw_status = wm_adsp2v2_show_fw_status, .stop_watchdog = wm_adsp_stop_watchdog,
@@ -4081,4 +4362,19 @@ struct wm_adsp_ops wm_adsp2_ops[] = { }, }; +struct wm_adsp_ops wm_halo_ops = { + .sys_config_size =sizeof (struct wm_halo_system_config_xm_hdr ), + .parse_sizes = wm_adsp2_parse_sizes, + .validate_version = wm_halo_validate_version, + .setup_algs = wm_halo_setup_algs, + .region_to_reg = wm_halo_region_to_reg, + + .show_fw_status = wm_halo_show_fw_status, + + .lock_memory = wm_halo_configure_mpu, + + .start_core = wm_halo_start_core, + .stop_core = wm_halo_stop_core, +}; +MODULE_LICENSE ("GPL v2" );
sound/soc/codecs/wm_adsp.h +8 -0
@@ -70,6 +70,7 @@ struct wm_adsp {struct wm_adsp_ops *ops;unsigned int base; +unsigned int base_sysinfo;unsigned int sysclk_reg;unsigned int sysclk_mask;unsigned int sysclk_shift;
@@ -78,6 +79,7 @@ struct wm_adsp {unsigned int fw_id;unsigned int fw_id_version; +unsigned int fw_vendor_id;const struct wm_adsp_region *mem;int num_mems;
@@ -110,12 +112,16 @@ struct wm_adsp { };struct wm_adsp_ops { +unsigned int sys_config_size; +bool (*validate_version)(struct wm_adsp *dsp,unsigned int version);unsigned int (*parse_sizes)(struct wm_adsp *dsp,const char *const file,unsigned int pos,const struct firmware *firmware);int (*setup_algs)(struct wm_adsp *dsp); +unsigned int (*region_to_reg)(struct wm_adsp_region const *mem, +unsigned int offset);void (*show_fw_status)(struct wm_adsp *dsp);void (*stop_watchdog)(struct wm_adsp *dsp);
@@ -160,6 +166,8 @@ int wm_adsp2_init(struct wm_adsp *dsp);void wm_adsp2_remove (struct wm_adsp *dsp);int wm_adsp2_component_probe (struct wm_adsp *dsp,struct snd_soc_component *component);int wm_adsp2_component_remove (struct wm_adsp *dsp,struct snd_soc_component *component); +int wm_halo_init (struct wm_adsp *dsp); +int wm_adsp1_event (struct snd_soc_dapm_widget *w,struct snd_kcontrol *kcontrol,int event);
sound/soc/codecs/wmfw.h +30 -0
@@ -73,6 +73,14 @@ struct wmfw_id_hdr {__be32 ver; } __packed; +struct wmfw_v3_id_hdr { +__be32 core_id; +__be32 block_rev; +__be32 vendor_id; +__be32 id; +__be32 ver; +} __packed; +struct wmfw_adsp1_id_hdr {struct wmfw_id_hdr fw;__be32 zm;
@@ -88,6 +96,15 @@ struct wmfw_adsp2_id_hdr {__be32 n_algs; } __packed; +struct wmfw_halo_id_hdr { +struct wmfw_v3_id_hdr fw; +__be32 xm_base; +__be32 xm_size; +__be32 ym_base; +__be32 ym_size; +__be32 n_algs; +} __packed; +struct wmfw_alg_hdr {__be32 id;__be32 ver;
@@ -106,6 +123,14 @@ struct wmfw_adsp2_alg_hdr {__be32 ym; } __packed; +struct wmfw_halo_alg_hdr { +struct wmfw_alg_hdr alg; +__be32 xm_base; +__be32 xm_size; +__be32 ym_base; +__be32 ym_size; +} __packed; +struct wmfw_adsp_alg_data {__le32 id;u8 name[WMFW_MAX_ALG_NAME ];
@@ -154,6 +179,7 @@ struct wmfw_coeff_item {#define WMFW_ADSP1 1#define WMFW_ADSP2 2 +#define WMFW_HALO 4#define WMFW_ABSOLUTE 0xf0#define WMFW_ALGORITHM_DATA 0xf2
@@ -169,4 +195,8 @@ struct wmfw_coeff_item {#define WMFW_ADSP2_XM 5#define WMFW_ADSP2_YM 6 +#define WMFW_HALO_PM_PACKED 0x10 +#define WMFW_HALO_XM_PACKED 0x11 +#define WMFW_HALO_YM_PACKED 0x12 +#endif
Signature · 1 line
2.11.0
Mark Brown
maintainerApplied "ASoC: wm_adsp: Add support for new Halo core DSPs" to the asoc tree
The patch
ASoC: wm_adsp: Add support for new Halo core DSPs
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
170b1e123f385e7d60e992bc7fb1cc2897520769Mon Sep 17 00:00:00 2001
From: Wen Shi <[email protected]>
Date: Tue, 19 Mar 2019 11:52:13 +0000
Subject: [PATCH] ASoC: wm_adsp: Add support for new Halo core DSPs
The Halo core is a new generation of audio DSP architecture from Cirrus Logic. A new iteration of the WMFW file format (v3) is also added, for this new architecture. Currently this format is not supported on the old ADSP2 architecture however support may be added for it in the future.
--- sound/soc/codecs/wm_adsp.c | 354 ++++++++++++++++++++++++++++++++++--- sound/soc/codecs/wm_adsp.h | 8 + sound/soc/codecs/wmfw.h | 30 ++++ 3 files changed, 363 insertions(+), 29 deletions(-)
sound/soc/codecs/wm_adsp.c +325 -29
@@ -227,8 +227,54 @@*/ #define WM_ADSP_FW_EVENT_SHUTDOWN 0x000001 +/* +* HALO core +*/ +#define HALO_SCRATCH1 0x005c0 +#define HALO_SCRATCH2 0x005c8 +#define HALO_SCRATCH3 0x005d0 +#define HALO_SCRATCH4 0x005d8 +#define HALO_CCM_CORE_CONTROL 0x41000 +#define HALO_CORE_SOFT_RESET 0x00010 + +/* +* HALO MPU banks +*/ +#define HALO_MPU_XMEM_ACCESS_0 0x43000 +#define HALO_MPU_YMEM_ACCESS_0 0x43004 +#define HALO_MPU_WINDOW_ACCESS_0 0x43008 +#define HALO_MPU_XREG_ACCESS_0 0x4300C +#define HALO_MPU_YREG_ACCESS_0 0x43014 +#define HALO_MPU_XMEM_ACCESS_1 0x43018 +#define HALO_MPU_YMEM_ACCESS_1 0x4301C +#define HALO_MPU_WINDOW_ACCESS_1 0x43020 +#define HALO_MPU_XREG_ACCESS_1 0x43024 +#define HALO_MPU_YREG_ACCESS_1 0x4302C +#define HALO_MPU_XMEM_ACCESS_2 0x43030 +#define HALO_MPU_YMEM_ACCESS_2 0x43034 +#define HALO_MPU_WINDOW_ACCESS_2 0x43038 +#define HALO_MPU_XREG_ACCESS_2 0x4303C +#define HALO_MPU_YREG_ACCESS_2 0x43044 +#define HALO_MPU_XMEM_ACCESS_3 0x43048 +#define HALO_MPU_YMEM_ACCESS_3 0x4304C +#define HALO_MPU_WINDOW_ACCESS_3 0x43050 +#define HALO_MPU_XREG_ACCESS_3 0x43054 +#define HALO_MPU_YREG_ACCESS_3 0x4305C +#define HALO_MPU_LOCK_CONFIG 0x43140 + +/* +* HALO_CCM_CORE_CONTROL +*/ +#define HALO_CORE_EN 0x00000001 + +/* +* HALO_CORE_SOFT_RESET +*/ +#define HALO_CORE_SOFT_RESET_MASK 0x00000001 +struct wm_adsp_ops wm_adsp1_ops;struct wm_adsp_ops wm_adsp2_ops[]; +struct wm_adsp_ops wm_halo_ops;struct wm_adsp_buf {struct list_head list;
@@ -309,6 +355,12 @@ struct wm_adsp_system_config_xm_hdr {__be32 build_job_number; }; +struct wm_halo_system_config_xm_hdr { +__be32 halo_heartbeat; +__be32 build_job_name[3 ]; +__be32 build_job_number; +}; +struct wm_adsp_alg_xm_struct {__be32 magic;__be32 smoothing;
@@ -535,12 +587,18 @@ static const char *wm_adsp_mem_region_name(unsigned int type)switch (type) {case WMFW_ADSP1_PM :return "PM" ; +case WMFW_HALO_PM_PACKED : +return "PM_PACKED" ;case WMFW_ADSP1_DM :return "DM" ;case WMFW_ADSP2_XM :return "XM" ; +case WMFW_HALO_XM_PACKED : +return "XM_PACKED" ;case WMFW_ADSP2_YM :return "YM" ; +case WMFW_HALO_YM_PACKED : +return "YM_PACKED" ;case WMFW_ADSP1_ZM :return "ZM" ;default :
@@ -772,17 +830,12 @@ static struct wm_adsp_region const *wm_adsp_find_region(struct wm_adsp *dsp,static unsigned int wm_adsp_region_to_reg (struct wm_adsp_region const *mem,unsigned int offset) { -if (WARN_ON (!mem)) -return offset;switch (mem->type) {case WMFW_ADSP1_PM :return mem->base + (offset *3 );case WMFW_ADSP1_DM : -return mem->base + (offset *2 );case WMFW_ADSP2_XM : -return mem->base + (offset *2 );case WMFW_ADSP2_YM : -return mem->base + (offset *2 );case WMFW_ADSP1_ZM :return mem->base + (offset *2 );default :
@@ -791,6 +844,24 @@ static unsigned int wm_adsp_region_to_reg(struct wm_adsp_region const *mem, } } +static unsigned int wm_halo_region_to_reg (struct wm_adsp_region const *mem, +unsigned int offset) +{ +switch (mem->type) { +case WMFW_ADSP2_XM : +case WMFW_ADSP2_YM : +return mem->base + (offset *4 ); +case WMFW_HALO_XM_PACKED : +case WMFW_HALO_YM_PACKED : +return (mem->base + (offset *3 )) & ~0x3 ; +case WMFW_HALO_PM_PACKED : +return mem->base + (offset *5 ); +default : +WARN (1 ,"Unknown memory region type" ); +return offset; + } +} +static void wm_adsp_read_fw_status (struct wm_adsp *dsp,int noffs,unsigned int *offs) {
@@ -829,6 +900,18 @@ static void wm_adsp2v2_show_fw_status(struct wm_adsp *dsp) offs[1] & 0xFFFF, offs[1] >> 16); } +static void wm_halo_show_fw_status (struct wm_adsp *dsp) +{ +unsigned int offs[] = { +HALO_SCRATCH1 ,HALO_SCRATCH2 ,HALO_SCRATCH3 ,HALO_SCRATCH4 , + }; + +wm_adsp_read_fw_status (dsp,ARRAY_SIZE (offs), offs); + +adsp_dbg (dsp,"FW SCRATCH 0:0x%x 1:0x%x 2:0x%x 3:0x%x\n" , + offs[0 ], offs[1 ], offs[2 ], offs[3 ]); +} +static inline struct wm_coeff_ctl *bytes_ext_to_ctl (struct soc_bytes_ext *ext) { return container_of(ext, struct wm_coeff_ctl, bytes_ext);
@@ -847,7 +930,7 @@ static int wm_coeff_base_reg(struct wm_coeff_ctl *ctl, unsigned int *reg)return -EINVAL ; } - *reg =wm_adsp_region_to_reg (mem, ctl->alg_region.base + ctl->offset); + *reg = dsp->ops->region_to_reg (mem, ctl->alg_region.base + ctl->offset);return 0 ; }
@@ -1335,28 +1418,33 @@ static int wm_adsp_create_control(struct wm_adsp *dsp,case 1 :snprintf (name,SNDRV_CTL_ELEM_ID_NAME_MAXLEN ,"%s %s %x" , dsp->name, region_name, alg_region->alg); + subname =NULL ;/* don't append subname */ break ; -default : +case 2 : ret =snprintf (name,SNDRV_CTL_ELEM_ID_NAME_MAXLEN ,"%s%c %.12s %x" , dsp->name, *region_name, wm_adsp_fw_text[dsp->fw], alg_region->alg); +break ; +default : + ret =snprintf (name,SNDRV_CTL_ELEM_ID_NAME_MAXLEN , +"%s %.12s %x" , dsp->name, + wm_adsp_fw_text[dsp->fw], alg_region->alg); +break ; + } -/* Truncate the subname from the start if it is too long */ -if (subname) { -int avail =SNDRV_CTL_ELEM_ID_NAME_MAXLEN - ret -2 ; -int skip =0 ; +if (subname) { +int avail =SNDRV_CTL_ELEM_ID_NAME_MAXLEN - ret -2 ; +int skip =0 ; -if (dsp->component->name_prefix) - avail -=strlen (dsp->component->name_prefix) +1 ; +if (dsp->component->name_prefix) + avail -=strlen (dsp->component->name_prefix) +1 ; -if (subname_len > avail) - skip = subname_len - avail; +/* Truncate the subname from the start if it is too long */ +if (subname_len > avail) + skip = subname_len - avail; -snprintf (name + ret, -SNDRV_CTL_ELEM_ID_NAME_MAXLEN - ret," %.*s" , - subname_len - skip, subname + skip); - } -break ; +snprintf (name + ret,SNDRV_CTL_ELEM_ID_NAME_MAXLEN - ret, +" %.*s" , subname_len - skip, subname + skip); }list_for_each_entry (ctl, &dsp->ctl_list, list) {
@@ -1689,6 +1777,16 @@ static bool wm_adsp_validate_version(struct wm_adsp *dsp, unsigned int version) } } +static bool wm_halo_validate_version (struct wm_adsp *dsp,unsigned int version) +{ +switch (version) { +case 3 : +return true; +default : +return false; + } +} +static int wm_adsp_load (struct wm_adsp *dsp) {LIST_HEAD (buf_list);
@@ -1774,7 +1872,6 @@ static int wm_adsp_load(struct wm_adsp *dsp) text =NULL ; offset =le32_to_cpu (region->offset) &0xffffff ; type =be32_to_cpu (region->type) &0xff ; - mem =wm_adsp_find_region (dsp, type);switch (type) {case WMFW_NAME_TEXT :
@@ -1802,8 +1899,17 @@ static int wm_adsp_load(struct wm_adsp *dsp)case WMFW_ADSP2_XM :case WMFW_ADSP2_YM :case WMFW_ADSP1_ZM : +case WMFW_HALO_PM_PACKED : +case WMFW_HALO_XM_PACKED : +case WMFW_HALO_YM_PACKED : + mem =wm_adsp_find_region (dsp, type); +if (!mem) { +adsp_err (dsp,"No region of type: %x\n" , type); + goto out_fw; + } + region_name =wm_adsp_mem_region_name (type); - reg =wm_adsp_region_to_reg (mem, offset); + reg = dsp->ops->region_to_reg (mem, offset);break ;default : adsp_warn(dsp,
@@ -1916,7 +2022,7 @@ static void *wm_adsp_read_algs(struct wm_adsp *dsp, size_t n_algs, }/* Read the terminator first to validate the length */ - reg =wm_adsp_region_to_reg (mem, pos + len); + reg = dsp->ops->region_to_reg (mem, pos + len); ret =regmap_raw_read (dsp->regmap, reg, &val,sizeof (val));if (ret !=0 ) {
@@ -1936,7 +2042,7 @@ static void *wm_adsp_read_algs(struct wm_adsp *dsp, size_t n_algs,if (!alg)return ERR_PTR (-ENOMEM ); - reg =wm_adsp_region_to_reg (mem, pos); + reg = dsp->ops->region_to_reg (mem, pos); ret =regmap_raw_read (dsp->regmap, reg, alg, len);if (ret !=0 ) {
@@ -2008,6 +2114,35 @@ static void wmfw_parse_id_header(struct wm_adsp *dsp, nalgs); } +static void wmfw_v3_parse_id_header (struct wm_adsp *dsp, +struct wmfw_v3_id_hdr *fw,int nalgs) +{ + dsp->fw_id =be32_to_cpu (fw->id); + dsp->fw_id_version =be32_to_cpu (fw->ver); + dsp->fw_vendor_id =be32_to_cpu (fw->vendor_id); + +adsp_info (dsp,"Firmware: %x vendor: 0x%x v%d.%d.%d, %zu algorithms\n" , + dsp->fw_id, dsp->fw_vendor_id, + (dsp->fw_id_version &0xff0000 ) >>16 , + (dsp->fw_id_version &0xff00 ) >>8 , dsp->fw_id_version &0xff , + nalgs); +} + +static int wm_adsp_create_regions (struct wm_adsp *dsp,__be32 id,int nregions, +int *type,__be32 *base) +{ +struct wm_adsp_alg_region *alg_region; +int i; + +for (i =0 ; i < nregions; i++) { + alg_region =wm_adsp_create_region (dsp, type[i], id, base[i]); +if (IS_ERR (alg_region)) +return PTR_ERR (alg_region); + } + +return 0 ; +} +static int wm_adsp1_setup_algs (struct wm_adsp *dsp) {struct wmfw_adsp1_id_hdr adsp1_id;
@@ -2238,6 +2373,78 @@ static int wm_adsp2_setup_algs(struct wm_adsp *dsp)return ret; } +static int wm_halo_create_regions (struct wm_adsp *dsp,__be32 id, +__be32 xm_base,__be32 ym_base) +{ +int types[] = { +WMFW_ADSP2_XM ,WMFW_HALO_XM_PACKED , +WMFW_ADSP2_YM ,WMFW_HALO_YM_PACKED + }; +__be32 bases[] = { xm_base, xm_base, ym_base, ym_base }; + +return wm_adsp_create_regions (dsp, id,ARRAY_SIZE (types), types, bases); +} + +static int wm_halo_setup_algs (struct wm_adsp *dsp) +{ +struct wmfw_halo_id_hdr halo_id; +struct wmfw_halo_alg_hdr *halo_alg; +const struct wm_adsp_region *mem; +unsigned int pos, len; +size_t n_algs; +int i, ret; + + mem =wm_adsp_find_region (dsp,WMFW_ADSP2_XM ); +if (WARN_ON (!mem)) +return -EINVAL ; + + ret =regmap_raw_read (dsp->regmap, mem->base, &halo_id, +sizeof (halo_id)); +if (ret !=0 ) { +adsp_err (dsp,"Failed to read algorithm info: %d\n" , + ret); +return ret; + } + + n_algs =be32_to_cpu (halo_id.n_algs); + +wmfw_v3_parse_id_header (dsp, &halo_id.fw, n_algs); + + ret =wm_halo_create_regions (dsp, halo_id.fw.id, + halo_id.ym_base, halo_id.ym_base); +if (ret) +return ret; + +/* Calculate offset and length in DSP words */ + pos =sizeof (halo_id) /sizeof (u32); + len = (sizeof (*halo_alg) * n_algs) /sizeof (u32); + + halo_alg =wm_adsp_read_algs (dsp, n_algs, mem, pos, len); +if (IS_ERR (halo_alg)) +return PTR_ERR (halo_alg); + +for (i =0 ; i < n_algs; i++) { +adsp_info (dsp, +"%d: ID %x v%d.%d.%d XM@%x YM@%x\n" , + i,be32_to_cpu (halo_alg[i].alg.id), + (be32_to_cpu (halo_alg[i].alg.ver) &0xff0000 ) >>16 , + (be32_to_cpu (halo_alg[i].alg.ver) &0xff00 ) >>8 , +be32_to_cpu (halo_alg[i].alg.ver) &0xff , +be32_to_cpu (halo_alg[i].xm_base), +be32_to_cpu (halo_alg[i].ym_base)); + + ret =wm_halo_create_regions (dsp, halo_alg[i].alg.id, + halo_alg[i].xm_base, + halo_alg[i].ym_base); +if (ret) + goto out; + } + +out: +kfree (halo_alg); +return ret; +} +static int wm_adsp_load_coeff (struct wm_adsp *dsp) {LIST_HEAD (buf_list);
@@ -2332,7 +2539,7 @@ static int wm_adsp_load_coeff(struct wm_adsp *dsp)adsp_err (dsp,"No ZM\n" );break ; } - reg =wm_adsp_region_to_reg (mem,0 ); + reg = dsp->ops->region_to_reg (mem,0 ); }else { region_name ="register" ;
@@ -2344,6 +2551,9 @@ static int wm_adsp_load_coeff(struct wm_adsp *dsp)case WMFW_ADSP1_ZM :case WMFW_ADSP2_XM :case WMFW_ADSP2_YM : +case WMFW_HALO_XM_PACKED : +case WMFW_HALO_YM_PACKED : +case WMFW_HALO_PM_PACKED :adsp_dbg (dsp,"%s.%d: %d bytes in %x for %x\n" , file, blocks,le32_to_cpu (blk->len), type,le32_to_cpu (blk->id));
@@ -2358,7 +2568,7 @@ static int wm_adsp_load_coeff(struct wm_adsp *dsp) le32_to_cpu(blk->id));if (alg_region) { reg = alg_region->base; - reg =wm_adsp_region_to_reg (mem, reg); + reg = dsp->ops->region_to_reg (mem, reg); reg += offset; }else { adsp_err(dsp, "No %x for algorithm %x\n",
@@ -2748,6 +2958,37 @@ static void wm_adsp_boot_work(struct work_struct *work)mutex_unlock (&dsp->pwr_lock); } +static int wm_halo_configure_mpu (struct wm_adsp *dsp,unsigned int lock_regions) +{ +struct reg_sequence config[] = { + { dsp->base +HALO_MPU_LOCK_CONFIG ,0x5555 }, + { dsp->base +HALO_MPU_LOCK_CONFIG ,0xAAAA }, + { dsp->base +HALO_MPU_XMEM_ACCESS_0 ,0xFFFFFFFF }, + { dsp->base +HALO_MPU_YMEM_ACCESS_0 ,0xFFFFFFFF }, + { dsp->base +HALO_MPU_WINDOW_ACCESS_0 , lock_regions }, + { dsp->base +HALO_MPU_XREG_ACCESS_0 , lock_regions }, + { dsp->base +HALO_MPU_YREG_ACCESS_0 , lock_regions }, + { dsp->base +HALO_MPU_XMEM_ACCESS_1 ,0xFFFFFFFF }, + { dsp->base +HALO_MPU_YMEM_ACCESS_1 ,0xFFFFFFFF }, + { dsp->base +HALO_MPU_WINDOW_ACCESS_1 , lock_regions }, + { dsp->base +HALO_MPU_XREG_ACCESS_1 , lock_regions }, + { dsp->base +HALO_MPU_YREG_ACCESS_1 , lock_regions }, + { dsp->base +HALO_MPU_XMEM_ACCESS_2 ,0xFFFFFFFF }, + { dsp->base +HALO_MPU_YMEM_ACCESS_2 ,0xFFFFFFFF }, + { dsp->base +HALO_MPU_WINDOW_ACCESS_2 , lock_regions }, + { dsp->base +HALO_MPU_XREG_ACCESS_2 , lock_regions }, + { dsp->base +HALO_MPU_YREG_ACCESS_2 , lock_regions }, + { dsp->base +HALO_MPU_XMEM_ACCESS_3 ,0xFFFFFFFF }, + { dsp->base +HALO_MPU_YMEM_ACCESS_3 ,0xFFFFFFFF }, + { dsp->base +HALO_MPU_WINDOW_ACCESS_3 , lock_regions }, + { dsp->base +HALO_MPU_XREG_ACCESS_3 , lock_regions }, + { dsp->base +HALO_MPU_YREG_ACCESS_3 , lock_regions }, + { dsp->base +HALO_MPU_LOCK_CONFIG ,0 }, + }; + +return regmap_multi_reg_write (dsp->regmap, config,ARRAY_SIZE (config)); +} +int wm_adsp2_set_dspclk (struct snd_soc_dapm_widget *w,unsigned int freq) {struct snd_soc_component *component =snd_soc_dapm_to_component (w->dapm);
@@ -2970,6 +3211,23 @@ int wm_adsp_event(struct snd_soc_dapm_widget *w, }EXPORT_SYMBOL_GPL (wm_adsp_event); +static int wm_halo_start_core (struct wm_adsp *dsp) +{ +return regmap_update_bits (dsp->regmap, + dsp->base +HALO_CCM_CORE_CONTROL , +HALO_CORE_EN ,HALO_CORE_EN ); +} + +static void wm_halo_stop_core (struct wm_adsp *dsp) +{ +regmap_update_bits (dsp->regmap, dsp->base +HALO_CCM_CORE_CONTROL , +HALO_CORE_EN ,0 ); + +/* reset halo core with CORE_SOFT_REEST */ +regmap_update_bits (dsp->regmap, dsp->base +HALO_CORE_SOFT_RESET , +HALO_CORE_SOFT_RESET_MASK ,1 ); +} +int wm_adsp2_component_probe (struct wm_adsp *dsp,struct snd_soc_component *component) {char preload[32 ];
@@ -3031,6 +3289,22 @@ int wm_adsp2_init(struct wm_adsp *dsp) }EXPORT_SYMBOL_GPL (wm_adsp2_init); +int wm_halo_init (struct wm_adsp *dsp) +{ +int ret; + + ret =wm_adsp_common_init (dsp); +if (ret) +return ret; + + dsp->ops = &wm_halo_ops; + +INIT_WORK (&dsp->boot_work, wm_adsp_boot_work); + +return 0 ; +} +EXPORT_SYMBOL_GPL (wm_halo_init); +void wm_adsp2_remove (struct wm_adsp *dsp) {struct wm_coeff_ctl *ctl;
@@ -3275,7 +3549,7 @@ static int wm_adsp_read_data_block(struct wm_adsp *dsp, int mem_type,if (!mem)return -EINVAL ; - reg =wm_adsp_region_to_reg (mem, mem_addr); + reg = dsp->ops->region_to_reg (mem, mem_addr); ret =regmap_raw_read (dsp->regmap, reg, data,sizeof (*data) * num_words);
@@ -3303,7 +3577,7 @@ static int wm_adsp_write_data_word(struct wm_adsp *dsp, int mem_type,if (!mem)return -EINVAL ; - reg =wm_adsp_region_to_reg (mem, mem_addr); + reg = dsp->ops->region_to_reg (mem, mem_addr); data =cpu_to_be32 (data &0x00ffffffu );
@@ -3414,7 +3688,7 @@ static int wm_adsp_buffer_parse_legacy(struct wm_adsp *dsp)return -ENOMEM ; alg_region =wm_adsp_find_alg_region (dsp,WMFW_ADSP2_XM , dsp->fw_id); - xmalg =sizeof (struct wm_adsp_system_config_xm_hdr ) /sizeof (__be32); + xmalg = dsp->ops->sys_config_size /sizeof (__be32); addr = alg_region->base + xmalg +ALG_XM_FIELD (magic); ret =wm_adsp_read_data_word (dsp,WMFW_ADSP2_XM , addr, &magic);
@@ -4024,13 +4298,16 @@ EXPORT_SYMBOL_GPL(wm_adsp2_bus_error);struct wm_adsp_ops wm_adsp1_ops = { .validate_version = wm_adsp_validate_version, .parse_sizes = wm_adsp1_parse_sizes, + .region_to_reg = wm_adsp_region_to_reg, };struct wm_adsp_ops wm_adsp2_ops[] = { { + .sys_config_size =sizeof (struct wm_adsp_system_config_xm_hdr ), .parse_sizes = wm_adsp2_parse_sizes, .validate_version = wm_adsp_validate_version, .setup_algs = wm_adsp2_setup_algs, + .region_to_reg = wm_adsp_region_to_reg, .show_fw_status = wm_adsp2_show_fw_status,
@@ -4045,9 +4322,11 @@ struct wm_adsp_ops wm_adsp2_ops[] = { }, { + .sys_config_size = sizeof(struct wm_adsp_system_config_xm_hdr), .parse_sizes = wm_adsp2_parse_sizes, .validate_version = wm_adsp_validate_version, .setup_algs = wm_adsp2_setup_algs, + .region_to_reg = wm_adsp_region_to_reg, .show_fw_status = wm_adsp2v2_show_fw_status,
@@ -4062,9 +4341,11 @@ struct wm_adsp_ops wm_adsp2_ops[] = { .stop_core = wm_adsp2_stop_core, }, { + .sys_config_size = sizeof(struct wm_adsp_system_config_xm_hdr), .parse_sizes = wm_adsp2_parse_sizes, .validate_version = wm_adsp_validate_version, .setup_algs = wm_adsp2_setup_algs, + .region_to_reg = wm_adsp_region_to_reg, .show_fw_status = wm_adsp2v2_show_fw_status, .stop_watchdog = wm_adsp_stop_watchdog,
@@ -4081,4 +4362,19 @@ struct wm_adsp_ops wm_adsp2_ops[] = { }, }; +struct wm_adsp_ops wm_halo_ops = { + .sys_config_size =sizeof (struct wm_halo_system_config_xm_hdr ), + .parse_sizes = wm_adsp2_parse_sizes, + .validate_version = wm_halo_validate_version, + .setup_algs = wm_halo_setup_algs, + .region_to_reg = wm_halo_region_to_reg, + + .show_fw_status = wm_halo_show_fw_status, + + .lock_memory = wm_halo_configure_mpu, + + .start_core = wm_halo_start_core, + .stop_core = wm_halo_stop_core, +}; +MODULE_LICENSE ("GPL v2" );
sound/soc/codecs/wm_adsp.h +8 -0
@@ -70,6 +70,7 @@ struct wm_adsp {struct wm_adsp_ops *ops;unsigned int base; +unsigned int base_sysinfo;unsigned int sysclk_reg;unsigned int sysclk_mask;unsigned int sysclk_shift;
@@ -78,6 +79,7 @@ struct wm_adsp {unsigned int fw_id;unsigned int fw_id_version; +unsigned int fw_vendor_id;const struct wm_adsp_region *mem;int num_mems;
@@ -110,12 +112,16 @@ struct wm_adsp { };struct wm_adsp_ops { +unsigned int sys_config_size; +bool (*validate_version)(struct wm_adsp *dsp,unsigned int version);unsigned int (*parse_sizes)(struct wm_adsp *dsp,const char *const file,unsigned int pos,const struct firmware *firmware);int (*setup_algs)(struct wm_adsp *dsp); +unsigned int (*region_to_reg)(struct wm_adsp_region const *mem, +unsigned int offset);void (*show_fw_status)(struct wm_adsp *dsp);void (*stop_watchdog)(struct wm_adsp *dsp);
@@ -160,6 +166,8 @@ int wm_adsp2_init(struct wm_adsp *dsp);void wm_adsp2_remove (struct wm_adsp *dsp);int wm_adsp2_component_probe (struct wm_adsp *dsp,struct snd_soc_component *component);int wm_adsp2_component_remove (struct wm_adsp *dsp,struct snd_soc_component *component); +int wm_halo_init (struct wm_adsp *dsp); +int wm_adsp1_event (struct snd_soc_dapm_widget *w,struct snd_kcontrol *kcontrol,int event);
sound/soc/codecs/wmfw.h +30 -0
@@ -73,6 +73,14 @@ struct wmfw_id_hdr {__be32 ver; } __packed; +struct wmfw_v3_id_hdr { +__be32 core_id; +__be32 block_rev; +__be32 vendor_id; +__be32 id; +__be32 ver; +} __packed; +struct wmfw_adsp1_id_hdr {struct wmfw_id_hdr fw;__be32 zm;
@@ -88,6 +96,15 @@ struct wmfw_adsp2_id_hdr {__be32 n_algs; } __packed; +struct wmfw_halo_id_hdr { +struct wmfw_v3_id_hdr fw; +__be32 xm_base; +__be32 xm_size; +__be32 ym_base; +__be32 ym_size; +__be32 n_algs; +} __packed; +struct wmfw_alg_hdr {__be32 id;__be32 ver;
@@ -106,6 +123,14 @@ struct wmfw_adsp2_alg_hdr {__be32 ym; } __packed; +struct wmfw_halo_alg_hdr { +struct wmfw_alg_hdr alg; +__be32 xm_base; +__be32 xm_size; +__be32 ym_base; +__be32 ym_size; +} __packed; +struct wmfw_adsp_alg_data {__le32 id;u8 name[WMFW_MAX_ALG_NAME ];
@@ -154,6 +179,7 @@ struct wmfw_coeff_item {#define WMFW_ADSP1 1#define WMFW_ADSP2 2 +#define WMFW_HALO 4#define WMFW_ABSOLUTE 0xf0#define WMFW_ALGORITHM_DATA 0xf2
@@ -169,4 +195,8 @@ struct wmfw_coeff_item {#define WMFW_ADSP2_XM 5#define WMFW_ADSP2_YM 6 +#define WMFW_HALO_PM_PACKED 0x10 +#define WMFW_HALO_XM_PACKED 0x11 +#define WMFW_HALO_YM_PACKED 0x12 +#endif
Signature · 1 line
2.20.1
Charles Keepax
maintainerPATCH 11/12 ASoC: wm_adsp: Add HALO MPU fault logging
In reply to Charles KeepaxFrom: Richard Fitzgerald <[email protected]>
A Halo Core DSP has a memory protection unit that can trap and signal memory access faults. This patch adds a function that dumps the fault information.
The interrupt reaches the host via the parent codec interrupt controller so this fault function is exported to be called by the codec driver.
--- sound/soc/codecs/wm_adsp.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/wm_adsp.h | 1 + 2 files changed, 85 insertions(+)
sound/soc/codecs/wm_adsp.c +84 -0
@@ -228,6 +228,12 @@#define WM_ADSP_FW_EVENT_SHUTDOWN 0x000001/* +* HALO system info +*/ +#define HALO_AHBM_WINDOW_DEBUG_0 0x02040 +#define HALO_AHBM_WINDOW_DEBUG_1 0x02044 + +/* * HALO core */ #define HALO_SCRATCH1 0x005c0
@@ -260,9 +266,22 @@#define HALO_MPU_WINDOW_ACCESS_3 0x43050#define HALO_MPU_XREG_ACCESS_3 0x43054#define HALO_MPU_YREG_ACCESS_3 0x4305C +#define HALO_MPU_XM_VIO_ADDR 0x43100 +#define HALO_MPU_XM_VIO_STATUS 0x43104 +#define HALO_MPU_YM_VIO_ADDR 0x43108 +#define HALO_MPU_YM_VIO_STATUS 0x4310C +#define HALO_MPU_PM_VIO_ADDR 0x43110 +#define HALO_MPU_PM_VIO_STATUS 0x43114#define HALO_MPU_LOCK_CONFIG 0x43140/* +* HALO_AHBM_WINDOW_DEBUG_1 +*/ +#define HALO_AHBM_CORE_ERR_ADDR_MASK 0x0fffff00 +#define HALO_AHBM_CORE_ERR_ADDR_SHIFT 8 +#define HALO_AHBM_FLAGS_ERR_MASK 0x000000ff + +/* * HALO_CCM_CORE_CONTROL */ #define HALO_CORE_EN 0x00000001
@@ -272,6 +291,15 @@*/ #define HALO_CORE_SOFT_RESET_MASK 0x00000001 +/* +* HALO_MPU_?M_VIO_STATUS +*/ +#define HALO_MPU_VIO_STS_MASK 0x007e0000 +#define HALO_MPU_VIO_STS_SHIFT 17 +#define HALO_MPU_VIO_ERR_WR_MASK 0x00008000 +#define HALO_MPU_VIO_ERR_SRC_MASK 0x00007fff +#define HALO_MPU_VIO_ERR_SRC_SHIFT 0 +struct wm_adsp_ops wm_adsp1_ops;struct wm_adsp_ops wm_adsp2_ops[];struct wm_adsp_ops wm_halo_ops;
@@ -4295,6 +4323,62 @@ irqreturn_t wm_adsp2_bus_error(struct wm_adsp *dsp) }EXPORT_SYMBOL_GPL (wm_adsp2_bus_error); +irqreturn_t wm_halo_bus_error (struct wm_adsp *dsp) +{ +struct regmap *regmap = dsp->regmap; +unsigned int fault[6 ]; +struct reg_sequence clear[] = { + { dsp->base +HALO_MPU_XM_VIO_STATUS ,0x0 }, + { dsp->base +HALO_MPU_YM_VIO_STATUS ,0x0 }, + { dsp->base +HALO_MPU_PM_VIO_STATUS ,0x0 }, + }; +int ret; + +mutex_lock (&dsp->pwr_lock); + + ret =regmap_read (regmap, dsp->base_sysinfo +HALO_AHBM_WINDOW_DEBUG_1 , + fault); +if (ret) { +adsp_warn (dsp,"Failed to read AHB DEBUG_1: %d\n" , ret); + goto exit_unlock; + } + +adsp_warn (dsp,"AHB: STATUS: 0x%x ADDR: 0x%x\n" , + *fault &HALO_AHBM_FLAGS_ERR_MASK , + (*fault &HALO_AHBM_CORE_ERR_ADDR_MASK ) >> +HALO_AHBM_CORE_ERR_ADDR_SHIFT ); + + ret =regmap_read (regmap, dsp->base_sysinfo +HALO_AHBM_WINDOW_DEBUG_0 , + fault); +if (ret) { +adsp_warn (dsp,"Failed to read AHB DEBUG_0: %d\n" , ret); + goto exit_unlock; + } + +adsp_warn (dsp,"AHB: SYS_ADDR: 0x%x\n" , *fault); + + ret =regmap_bulk_read (regmap, dsp->base +HALO_MPU_XM_VIO_ADDR , + fault,ARRAY_SIZE (fault)); +if (ret) { +adsp_warn (dsp,"Failed to read MPU fault info: %d\n" , ret); + goto exit_unlock; + } + +adsp_warn (dsp,"XM: STATUS:0x%x ADDR:0x%x\n" , fault[1 ], fault[0 ]); +adsp_warn (dsp,"YM: STATUS:0x%x ADDR:0x%x\n" , fault[3 ], fault[2 ]); +adsp_warn (dsp,"PM: STATUS:0x%x ADDR:0x%x\n" , fault[5 ], fault[4 ]); + + ret =regmap_multi_reg_write (dsp->regmap, clear,ARRAY_SIZE (clear)); +if (ret) +adsp_warn (dsp,"Failed to clear MPU status: %d\n" , ret); + +exit_unlock: +mutex_unlock (&dsp->pwr_lock); + +return IRQ_HANDLED ; +} +EXPORT_SYMBOL_GPL (wm_halo_bus_error); +struct wm_adsp_ops wm_adsp1_ops = { .validate_version = wm_adsp_validate_version, .parse_sizes = wm_adsp1_parse_sizes,
sound/soc/codecs/wm_adsp.h +1 -0
@@ -175,6 +175,7 @@ int wm_adsp_early_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event);irqreturn_t wm_adsp2_bus_error (struct wm_adsp *adsp); +irqreturn_t wm_halo_bus_error (struct wm_adsp *dsp);int wm_adsp_event (struct snd_soc_dapm_widget *w,struct snd_kcontrol *kcontrol,int event);
Signature · 1 line
2.11.0
Charles Keepax
maintainerPATCH 12/12 ASoC: wm_adsp: Add WDT expiry IRQ handling support for Halo core
In reply to Charles KeepaxFrom: Stuart Henderson <[email protected]>
--- sound/soc/codecs/wm_adsp.c | 29 +++++++++++++++++++++++++++++ sound/soc/codecs/wm_adsp.h | 1 + 2 files changed, 30 insertions(+)
sound/soc/codecs/wm_adsp.c +29 -0
@@ -242,6 +242,7 @@#define HALO_SCRATCH4 0x005d8#define HALO_CCM_CORE_CONTROL 0x41000#define HALO_CORE_SOFT_RESET 0x00010 +#define HALO_WDT_CONTROL 0x47000/* * HALO MPU banks
@@ -292,6 +293,11 @@#define HALO_CORE_SOFT_RESET_MASK 0x00000001/* +* HALO_WDT_CONTROL +*/ +#define HALO_WDT_EN_MASK 0x00000001 + +/* * HALO_MPU_?M_VIO_STATUS */ #define HALO_MPU_VIO_STS_MASK 0x007e0000
@@ -3083,6 +3089,12 @@ static void wm_adsp_stop_watchdog(struct wm_adsp *dsp) ADSP2_WDT_ENA_MASK, 0); } +static void wm_halo_stop_watchdog (struct wm_adsp *dsp) +{ +regmap_update_bits (dsp->regmap, dsp->base +HALO_WDT_CONTROL , +HALO_WDT_EN_MASK ,0 ); +} +int wm_adsp_early_event (struct snd_soc_dapm_widget *w,struct snd_kcontrol *kcontrol,int event) {
@@ -4379,6 +4391,22 @@ irqreturn_t wm_halo_bus_error(struct wm_adsp *dsp) }EXPORT_SYMBOL_GPL (wm_halo_bus_error); +irqreturn_t wm_halo_wdt_expire (int irq,void *data) +{ +struct wm_adsp *dsp = data; + +mutex_lock (&dsp->pwr_lock); + +adsp_warn (dsp,"WDT Expiry Fault\n" ); +wm_halo_stop_watchdog (dsp); +wm_adsp_fatal_error (dsp); + +mutex_unlock (&dsp->pwr_lock); + +return IRQ_HANDLED ; +} +EXPORT_SYMBOL_GPL (wm_halo_wdt_expire); +struct wm_adsp_ops wm_adsp1_ops = { .validate_version = wm_adsp_validate_version, .parse_sizes = wm_adsp1_parse_sizes,
@@ -4454,6 +4482,7 @@ struct wm_adsp_ops wm_halo_ops = { .region_to_reg = wm_halo_region_to_reg, .show_fw_status = wm_halo_show_fw_status, + .stop_watchdog = wm_halo_stop_watchdog, .lock_memory = wm_halo_configure_mpu,
sound/soc/codecs/wm_adsp.h +1 -0
@@ -176,6 +176,7 @@ int wm_adsp_early_event(struct snd_soc_dapm_widget *w,irqreturn_t wm_adsp2_bus_error (struct wm_adsp *adsp);irqreturn_t wm_halo_bus_error (struct wm_adsp *dsp); +irqreturn_t wm_halo_wdt_expire (int irq,void *data);int wm_adsp_event (struct snd_soc_dapm_widget *w,struct snd_kcontrol *kcontrol,int event);
Signature · 1 line
2.11.0