linux-stable/sound/soc
Benjamin Rood f134a436d7 ASoC: sgtl5000: set DAP_AVC_CTRL register to correct default value on probe
[ Upstream commit f86f58e359 ]

According to the SGTL5000 datasheet [1], the DAP_AVC_CTRL register has
the following bit field definitions:

| BITS  | FIELD       | RW | RESET | DEFINITION                        |
| 15    | RSVD        | RO | 0x0   | Reserved                          |
| 14    | RSVD        | RW | 0x1   | Reserved                          |
| 13:12 | MAX_GAIN    | RW | 0x1   | Max Gain of AVC in expander mode  |
| 11:10 | RSVD        | RO | 0x0   | Reserved                          |
| 9:8   | LBI_RESP    | RW | 0x1   | Integrator Response               |
| 7:6   | RSVD        | RO | 0x0   | Reserved                          |
| 5     | HARD_LMT_EN | RW | 0x0   | Enable hard limiter mode          |
| 4:1   | RSVD        | RO | 0x0   | Reserved                          |
| 0     | EN          | RW | 0x0   | Enable/Disable AVC                |

The original default value written to the DAP_AVC_CTRL register during
sgtl5000_i2c_probe() was 0x0510.  This would incorrectly write values to
bits 4 and 10, which are defined as RESERVED.  It would also not set
bits 12 and 14 to their correct RESET values of 0x1, and instead set
them to 0x0.  While the DAP_AVC module is effectively disabled because
the EN bit is 0, this default value is still writing invalid values to
registers that are marked as read-only and RESERVED as well as not
setting bits 12 and 14 to their correct default values as defined by the
datasheet.

The correct value that should be written to the DAP_AVC_CTRL register is
0x5100, which configures the register bits to the default values defined
by the datasheet, and prevents any writes to bits defined as
'read-only'.  Generally speaking, it is best practice to NOT attempt to
write values to registers/bits defined as RESERVED, as it generally
produces unwanted/undefined behavior, or errors.

Also, all credit for this patch should go to my colleague Dan MacDonald
<dmacdonald@curbellmedical.com> for finding this error in the first
place.

[1] https://www.nxp.com/docs/en/data-sheet/SGTL5000.pdf

Signed-off-by: Benjamin Rood <benjaminjrood@gmail.com>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
Link: https://lore.kernel.org/r/20210219183308.GA2117@ubuntu-dev
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-04-07 15:00:04 +02:00
..
adi
amd ASoC: AMD Renoir - refine DMI entries for some Lenovo products 2021-02-03 23:28:38 +01:00
atmel ASoC: atmel: mchp-spdifrx needs COMMON_CLK 2020-12-30 11:53:36 +01:00
au1x
bcm
cirrus
codecs ASoC: sgtl5000: set DAP_AVC_CTRL register to correct default value on probe 2021-04-07 15:00:04 +02:00
dwc
fsl ASoC: fsl_ssi: Fix TDM slot setup for I2S mode 2021-03-25 09:04:06 +01:00
generic ASoC: simple-card-utils: Do not handle device clock 2021-03-25 09:04:07 +01:00
hisilicon treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
img
intel ASoC: Intel: bytcr_rt5640: Fix HP Pavilion x2 10-p0XX OVCD current threshold 2021-03-25 09:04:06 +01:00
jz4740 ASoC: jz4740-i2s: add missed checks for clk_get() 2020-12-30 11:53:35 +01:00
kirkwood
mediatek ASoC: mediatek: mt8183-mt6358: ignore TDM DAI link by default 2021-02-03 23:28:51 +01:00
meson ASoC: meson: axg-tdmin: fix axg skew offset 2021-01-19 18:27:29 +01:00
mxs
pxa treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
qcom ASoC: qcom: lpass-cpu: Fix lpass dai ids parse 2021-03-25 09:04:07 +01:00
rockchip Linux 5.9-rc5 2020-10-06 16:19:24 +01:00
samsung Linux 5.9-rc5 2020-10-06 16:19:24 +01:00
sh ASoC: siu: Fix build error by a wrong const prefix 2021-03-04 11:38:28 +01:00
sirf
sof ASoC: SOF: intel: fix wrong poll bits in dsp power down 2021-03-25 09:04:06 +01:00
spear
sprd ASoC: various vendors: delete repeated words in comments 2020-08-18 14:52:32 +01:00
sti
stm ASoC: stm32: dfsdm: change rate limits 2020-10-08 20:44:40 +01:00
sunxi ASoC: sun4i-i2s: Fix lrck_period computation for I2S justified mode 2020-12-30 11:53:00 +01:00
tegra ASoC: tegra: trimslice.c: use devm_snd_soc_register_card() 2020-10-01 20:28:17 +01:00
ti ASoC: ti: davinci-mcasp: Use &pdev->dev for early dev_warn 2020-10-08 21:16:52 +01:00
txx9 ASoC: txx9: Replace tasklet with work 2020-09-09 15:42:10 +01:00
uniphier
ux500
xilinx sound: remove duplicate "the the" phrase in Kconfig text 2020-08-18 14:52:43 +01:00
xtensa
zte treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
Kconfig
Makefile
soc-ac97.c
soc-acpi.c
soc-card.c
soc-component.c ASoC: soc-component: add mark for snd_soc_pcm_component_pm_runtime_get/put() 2020-09-28 17:01:44 +01:00
soc-compress.c ASoC: soc-component: add mark for snd_soc_pcm_component_pm_runtime_get/put() 2020-09-28 17:01:44 +01:00
soc-core.c ALSA: fix kernel-doc markups 2020-10-26 15:26:31 +01:00
soc-dai.c ASoC: soc-dai: add mark for snd_soc_dai_startup/shutdown() 2020-09-28 17:01:42 +01:00
soc-dapm.c ASoC: dapm: remove widget from dirty list on free 2021-01-19 18:27:17 +01:00
soc-devres.c
soc-generic-dmaengine-pcm.c ASoC: dmaengine: Document support for TX only or RX only streams 2020-10-09 15:11:20 +01:00
soc-jack.c
soc-link.c ASoC: soc-link: add mark for snd_soc_link_startup/shutdown() 2020-09-28 17:01:43 +01:00
soc-ops.c
soc-pcm.c ASoC: pcm: DRAIN support reactivation 2020-12-30 11:53:02 +01:00
soc-topology.c ASoC: topology: Fix memory corruption in soc_tplg_denum_create_values() 2021-02-03 23:28:51 +01:00
soc-utils.c