diff options
author | Hans de Goede <hdegoede@redhat.com> | 2018-03-04 15:35:53 +0100 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2018-03-07 13:49:21 +0100 |
commit | e6eb0207597afa1cdd4914a17a727b101cc859ff (patch) | |
tree | 183dae6ce9083cbdc88b5015f5f0a78d7e4bf2ea /sound/soc/codecs/rt5651.c | |
parent | ASoC: rt5651: Allow specifying over-current threshold through a device-property (diff) | |
download | linux-e6eb0207597afa1cdd4914a17a727b101cc859ff.tar.xz linux-e6eb0207597afa1cdd4914a17a727b101cc859ff.zip |
ASoC: rt5651: Allow specifying the OVCD scale-factor through a device-property
OVer-Current-Detection (OVCD) for the micbias current is used to detect if
an inserted jack is a headset or headphones (mic shorted to ground).
The threshold for at which current the OVCD triggers on the rt5651 is not
only controlled by setting the absolute current limit, but also by setting
a scale factor which applies to the limit. Testing has shown that we need
to set both (depending on the board).
This commit adds support for the sofar unused OVCD scale-factor register
and adds support for specifying non-default values for it through the
"realtek,over-current-scale-factor" device-property.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/codecs/rt5651.c')
-rw-r--r-- | sound/soc/codecs/rt5651.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 7ff1bc892cfd..486817809b7b 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1632,6 +1632,10 @@ static int rt5651_set_jack(struct snd_soc_component *component, snd_soc_component_update_bits(component, RT5651_PWR_ANLG2, RT5651_PWR_JD_M, RT5651_PWR_JD_M); + /* Set OVCD threshold current and scale-factor */ + snd_soc_component_write(component, RT5651_PR_BASE + RT5651_BIAS_CUR4, + 0xa800 | rt5651->ovcd_sf); + snd_soc_component_update_bits(component, RT5651_MICBIAS, RT5651_MIC1_OVCD_MASK | RT5651_MIC1_OVTH_MASK | @@ -1685,7 +1689,13 @@ static void rt5651_apply_properties(struct snd_soc_component *component) "realtek,jack-detect-source", &val) == 0) rt5651->jd_src = val; + /* + * Testing on various boards has shown that good defaults for the OVCD + * threshold and scale-factor are 2000µA and 0.75. For an effective + * limit of 1500µA, this seems to be more reliable then 1500µA and 1.0. + */ rt5651->ovcd_th = RT5651_MIC1_OVTH_2000UA; + rt5651->ovcd_sf = RT5651_MIC_OVCD_SF_0P75; if (device_property_read_u32(component->dev, "realtek,over-current-threshold-microamp", &val) == 0) { @@ -1704,6 +1714,15 @@ static void rt5651_apply_properties(struct snd_soc_component *component) val); } } + + if (device_property_read_u32(component->dev, + "realtek,over-current-scale-factor", &val) == 0) { + if (val <= RT5651_OVCD_SF_1P5) + rt5651->ovcd_sf = val << RT5651_MIC_OVCD_SF_SFT; + else + dev_warn(component->dev, "Warning: Invalid over-current-scale-factor value: %d, defaulting to 0.75\n", + val); + } } static int rt5651_probe(struct snd_soc_component *component) |