2020-09-08 08:37:40

by Camel Guo

[permalink] [raw]
Subject: [PATCH 2/2] ASoC: tlv320adcx140: Wake up codec before accessing register

From: Camel Guo <[email protected]>

According to its datasheet, after reset this codec goes into sleep
mode. In this mode, any register accessing should be avoided except for
exiting sleep mode. Hence this commit moves SLEEP_CFG access before any
register accessing.

Signed-off-by: Camel Guo <[email protected]>
---
sound/soc/codecs/tlv320adcx140.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/sound/soc/codecs/tlv320adcx140.c b/sound/soc/codecs/tlv320adcx140.c
index 597dd1062943..6d456aa269ad 100644
--- a/sound/soc/codecs/tlv320adcx140.c
+++ b/sound/soc/codecs/tlv320adcx140.c
@@ -842,6 +842,18 @@ static int adcx140_codec_probe(struct snd_soc_component *component)
if (ret)
goto out;

+ if (adcx140->supply_areg == NULL)
+ sleep_cfg_val |= ADCX140_AREG_INTERNAL;
+
+ ret = regmap_write(adcx140->regmap, ADCX140_SLEEP_CFG, sleep_cfg_val);
+ if (ret) {
+ dev_err(adcx140->dev, "setting sleep config failed %d\n", ret);
+ goto out;
+ }
+
+ /* 8.4.3: Wait >= 1ms after entering active mode. */
+ usleep_range(1000, 100000);
+
pdm_count = device_property_count_u32(adcx140->dev,
"ti,pdm-edge-select");
if (pdm_count <= ADCX140_NUM_PDM_EDGES && pdm_count > 0) {
@@ -889,18 +901,6 @@ static int adcx140_codec_probe(struct snd_soc_component *component)
if (ret)
goto out;

- if (adcx140->supply_areg == NULL)
- sleep_cfg_val |= ADCX140_AREG_INTERNAL;
-
- ret = regmap_write(adcx140->regmap, ADCX140_SLEEP_CFG, sleep_cfg_val);
- if (ret) {
- dev_err(adcx140->dev, "setting sleep config failed %d\n", ret);
- goto out;
- }
-
- /* 8.4.3: Wait >= 1ms after entering active mode. */
- usleep_range(1000, 100000);
-
ret = regmap_update_bits(adcx140->regmap, ADCX140_BIAS_CFG,
ADCX140_MIC_BIAS_VAL_MSK |
ADCX140_MIC_BIAS_VREF_MSK, bias_cfg);
--
2.20.1


2020-09-08 16:37:19

by Dan Murphy

[permalink] [raw]
Subject: Re: [PATCH 2/2] ASoC: tlv320adcx140: Wake up codec before accessing register

Camel

On 9/8/20 6:49 AM, Dan Murphy wrote:
> Camel
>
> On 9/8/20 3:35 AM, Camel Guo wrote:
>> From: Camel Guo <[email protected]>
>>
>> According to its datasheet, after reset this codec goes into sleep
>> mode. In this mode, any register accessing should be avoided except for
>> exiting sleep mode. Hence this commit moves SLEEP_CFG access before any
>> register accessing.
>
> This is interesting because our HW team suggested putting the device
> into sleep mode when doing register writes/reads because they were
> finding abnormalities in the register settings when the device is active.
>
> I have a local patch that changes this as well that the HW team
> requested.


OK I have clarification on this now.  Their original request was
incorrect they indicate the BIAS, ADC and PLLs be powered down during
writes and reads.


>
> Mark
>
> Let me run this by the HW team first before applying this patch.

Mark

Acked-by: Dan Murphy <[email protected]>


>
> Dan
>

2020-09-08 20:04:58

by Dan Murphy

[permalink] [raw]
Subject: Re: [PATCH 2/2] ASoC: tlv320adcx140: Wake up codec before accessing register

Camel

On 9/8/20 3:35 AM, Camel Guo wrote:
> From: Camel Guo <[email protected]>
>
> According to its datasheet, after reset this codec goes into sleep
> mode. In this mode, any register accessing should be avoided except for
> exiting sleep mode. Hence this commit moves SLEEP_CFG access before any
> register accessing.

This is interesting because our HW team suggested putting the device
into sleep mode when doing register writes/reads because they were
finding abnormalities in the register settings when the device is active.

I have a local patch that changes this as well that the HW team requested.

Mark

Let me run this by the HW team first before applying this patch.

Dan