]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
ASoC: tlv320adcx140: Configure PDM sampling edge
authorDan Murphy <dmurphy@ti.com>
Thu, 14 May 2020 12:33:38 +0000 (07:33 -0500)
committerMark Brown <broonie@kernel.org>
Thu, 14 May 2020 17:05:21 +0000 (18:05 +0100)
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>
sound/soc/codecs/tlv320adcx140.c
sound/soc/codecs/tlv320adcx140.h

index 97634e0ca0bad5102000fa536fc41ea71fee6d55..140a5802a9a99ad757dd9b6c73e070e5c372af3e 100644 (file)
@@ -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;
index 6d055e55909e68b828d5b077b5bdf8803f3a3bd5..432eaf25d1a7b9d41142a90672fa0dcecd991398 100644 (file)
 
 #define ADCX140_TX_OFFSET_MASK         GENMASK(4, 0)
 
+#define ADCX140_NUM_PDM_EDGES          4
+#define ADCX140_PDM_EDGE_SHIFT         7
+
 #endif /* _TLV320ADCX140_ */