ASoC: rt5645: Add jd_invert for Broadwell
authorJohn Lin <john.lin@realtek.com>
Mon, 21 Sep 2015 06:12:01 +0000 (14:12 +0800)
committerMark Brown <broonie@kernel.org>
Tue, 22 Sep 2015 16:46:33 +0000 (09:46 -0700)
Broadwell can not triger the IRQ falling and rising simultaneously,
so it can not detect jack-in and jack-out simultaneously.
We add a flag "jd_invert" to platform data. If this flag is set,
codec IRQ will be set to invert that forces IRQ as pulse when jack-in
and jack-out.

Signed-off-by: John Lin <john.lin@realtek.com>
Signed-off-by: Bard Liao <bardliao@realtek.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/rt5645.h
sound/soc/codecs/rt5645.c
sound/soc/codecs/rt5645.h

index 22734bc3ffd4a2e72ec1a1979ec1adf7df8014c6..a5cf6152e778929d572250462b2252a4369b08ca 100644 (file)
@@ -21,6 +21,8 @@ struct rt5645_platform_data {
        /* 0 = IN2P; 1 = GPIO6; 2 = GPIO10; 3 = GPIO12 */
 
        unsigned int jd_mode;
+       /* Invert JD when jack insert */
+       bool jd_invert;
 };
 
 #endif
index e83068886c70e05c5b42f24ae28ecf8a30a10634..b0d96b6d21defde5708f8e45140e0335a3bbbd37 100644 (file)
@@ -2829,6 +2829,9 @@ static int rt5645_jack_detect(struct snd_soc_codec *codec, int jack_insert)
                        snd_soc_dapm_sync(dapm);
                        rt5645->jack_type = SND_JACK_HEADPHONE;
                }
+               if (rt5645->pdata.jd_invert)
+                       regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2,
+                               RT5645_JD_1_1_MASK, RT5645_JD_1_1_INV);
        } else { /* jack out */
                rt5645->jack_type = 0;
 
@@ -2844,6 +2847,9 @@ static int rt5645_jack_detect(struct snd_soc_codec *codec, int jack_insert)
                        snd_soc_dapm_disable_pin(dapm, "LDO2");
                snd_soc_dapm_disable_pin(dapm, "Mic Det Power");
                snd_soc_dapm_sync(dapm);
+               if (rt5645->pdata.jd_invert)
+                       regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2,
+                               RT5645_JD_1_1_MASK, RT5645_JD_1_1_NOR);
        }
 
        return rt5645->jack_type;
@@ -3213,6 +3219,7 @@ static struct rt5645_platform_data buddy_platform_data = {
        .dmic1_data_pin = RT5645_DMIC_DATA_GPIO5,
        .dmic2_data_pin = RT5645_DMIC_DATA_IN2P,
        .jd_mode = 3,
+       .jd_invert = true,
 };
 
 static int buddy_quirk_cb(const struct dmi_system_id *id)
index 0e4cfc6ac64984acb1bd395a7477b7cf21cfc020..90325d9256ff14693f21b6fd83dc9902aae50149 100644 (file)
 #define RT5645_OT_P_NOR                                (0x0 << 10)
 #define RT5645_OT_P_INV                                (0x1 << 10)
 #define RT5645_IRQ_JD_1_1_EN                   (0x1 << 9)
+#define RT5645_JD_1_1_MASK                     (0x1 << 7)
+#define RT5645_JD_1_1_SFT                      7
+#define RT5645_JD_1_1_NOR                      (0x0 << 7)
+#define RT5645_JD_1_1_INV                      (0x1 << 7)
 
 /* IRQ Control 2 (0xbe) */
 #define RT5645_IRQ_MB1_OC_MASK                 (0x1 << 15)