diff options
author | Dan Murphy <dmurphy@ti.com> | 2020-05-14 07:33:38 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2020-05-14 18:05:21 +0100 |
commit | 79fc48e41e39d7a98c5f8ae37f613d7ff9953c86 (patch) | |
tree | 694018da0d0eb1e19c579836cbc1c35bcd41a9a7 /sound/soc/codecs | |
parent | 75b0adbb0806a141b0b5f074cd6bd58bb9870c0d (diff) | |
download | linux-79fc48e41e39d7a98c5f8ae37f613d7ff9953c86.tar.bz2 |
ASoC: tlv320adcx140: Configure PDM sampling edge
Configure the PDM sampling edges based on the values from the firmware.
Signed-off-by: Dan Murphy <dmurphy@ti.com>
Link: https://lore.kernel.org/r/20200514123338.20392-3-dmurphy@ti.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/codecs')
-rw-r--r-- | sound/soc/codecs/tlv320adcx140.c | 22 | ||||
-rw-r--r-- | sound/soc/codecs/tlv320adcx140.h | 3 |
2 files changed, 25 insertions, 0 deletions
diff --git a/sound/soc/codecs/tlv320adcx140.c b/sound/soc/codecs/tlv320adcx140.c index 97634e0ca0ba..140a5802a9a9 100644 --- a/sound/soc/codecs/tlv320adcx140.c +++ b/sound/soc/codecs/tlv320adcx140.c @@ -760,6 +760,10 @@ static int adcx140_codec_probe(struct snd_soc_component *component) int sleep_cfg_val = ADCX140_WAKE_DEV; u8 bias_source; u8 vref_source; + int pdm_count; + u32 pdm_edges[ADCX140_NUM_PDM_EDGES]; + u32 pdm_edge_val = 0; + int i; int ret; ret = device_property_read_u8(adcx140->dev, "ti,mic-bias-source", @@ -786,6 +790,24 @@ static int adcx140_codec_probe(struct snd_soc_component *component) bias_source |= vref_source; + pdm_count = device_property_count_u32(adcx140->dev, + "ti,pdm-edge-select"); + if (pdm_count <= ADCX140_NUM_PDM_EDGES && pdm_count > 0) { + ret = device_property_read_u32_array(adcx140->dev, + "ti,pdm-edge-select", + pdm_edges, pdm_count); + if (ret) + return ret; + + for (i = 0; i < pdm_count; i++) + pdm_edge_val |= pdm_edges[i] << (ADCX140_PDM_EDGE_SHIFT - i); + + ret = regmap_write(adcx140->regmap, ADCX140_PDM_CFG, + pdm_edge_val); + if (ret) + return ret; + } + ret = adcx140_reset(adcx140); if (ret) goto out; diff --git a/sound/soc/codecs/tlv320adcx140.h b/sound/soc/codecs/tlv320adcx140.h index 6d055e55909e..432eaf25d1a7 100644 --- a/sound/soc/codecs/tlv320adcx140.h +++ b/sound/soc/codecs/tlv320adcx140.h @@ -128,4 +128,7 @@ #define ADCX140_TX_OFFSET_MASK GENMASK(4, 0) +#define ADCX140_NUM_PDM_EDGES 4 +#define ADCX140_PDM_EDGE_SHIFT 7 + #endif /* _TLV320ADCX140_ */ |