rt5645: Importing rt5645-specific jack detect code
This enables a whole bunch of power and routing configs for getting
microphone input off of the headphone jack and fixes a devicetree bool
read problem.
Change-Id: Ice278fcf0efc8e132a68b0c664b9d99983ae4860
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
index 9e2cb71..189dc46 100644
--- a/sound/soc/codecs/rt5645.c
+++ b/sound/soc/codecs/rt5645.c
@@ -3122,9 +3122,14 @@
if (jack_insert) {
regmap_write(rt5645->regmap, RT5645_CHARGE_PUMP, 0x0e06);
+ /* If the DT says we need low voltage, we need to raise
+ the HP amp detection threshold for the headphone
+ charge pump to prevent misdetects because the GPIO
+ used for the interrupt is most-likely wired directly
+ off of HPO_L. Failing to do this causes the HPO_L
+ line to hover at 2V, which is enough to cause
+ mis-reads of the GPIO value. */
if (rt5645->pdata.jd_low_volt_enable) {
- /* Enable the headphone output voltage bias on the HPO_L
- line to improve jack detection */
regmap_update_bits(rt5645->regmap, RT5645_CHARGE_PUMP,
3 << 11, 3 << 11);
}
@@ -3227,6 +3232,23 @@
RT5645_GP1_PIN_IRQ, RT5645_GP1_PIN_IRQ);
regmap_update_bits(rt5645->regmap, RT5645_GEN_CTRL1,
RT5645_DIG_GATE_CTRL, RT5645_DIG_GATE_CTRL);
+ } else if (rt5645->codec_type == CODEC_TYPE_RT5645) {
+ regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL2,
+ RT5645_CBJ_DET_MODE, RT5645_CBJ_DET_MODE);
+ regmap_update_bits(rt5645->regmap, RT5645_GEN_CTRL2,
+ 0x1 << 4, 0x1 << 4);
+
+ /* Turn on combo jack input buffer power */
+ regmap_update_bits(rt5645->regmap, RT5645_GEN_CTRL3,
+ 0x1 << 8, 0x1 << 8);
+
+ /* Turn on MIC input from RING2 */
+ regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL1,
+ RT5645_CBJ_MIC_SEL_L, RT5645_CBJ_MIC_SEL_L);
+
+ /* De-ground the RING2 MIC input */
+ regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL3,
+ 0x1 << 15, 0);
}
rt5645_irq(0, rt5645);
@@ -3247,8 +3269,6 @@
case 0: /* Not using rt5645 JD */
if (rt5645->gpiod_hp_det) {
gpio_state = gpiod_get_value(rt5645->gpiod_hp_det);
- dev_dbg(rt5645->codec->dev, "gpio_state = %d\n",
- gpio_state);
report = rt5645_jack_detect(rt5645->codec, gpio_state);
}
snd_soc_jack_report(rt5645->hp_jack,
@@ -3699,9 +3719,12 @@
"realtek,dmic2-data-pin", &rt5645->pdata.dmic2_data_pin);
device_property_read_u32(dev,
"realtek,jd-mode", &rt5645->pdata.jd_mode);
- device_property_read_u32(dev,
- "realtek,jd-low-volt-enable",
- &rt5645->pdata.jd_low_volt_enable);
+ rt5645->pdata.jd_low_volt_enable =
+ device_property_read_bool(dev, "realtek,jd-low-volt-enable");
+
+ if (rt5645->pdata.jd_low_volt_enable) {
+ printk("rt5645: Raising HP amp charge pump to prevent jack presence mis-detects.\n");
+ }
return 0;
}