extcon: arizona: support inverted jack detect switch
authorRichard Fitzgerald <rf@opensource.wolfsonmicro.com>
Fri, 23 May 2014 11:54:57 +0000 (12:54 +0100)
committerChanwoo Choi <cw00.choi@samsung.com>
Mon, 16 Jun 2014 04:33:18 +0000 (13:33 +0900)
Add config option for inverted jack detect switch that
opens when jack is inserted.

Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
[Acked by Lee Jones for MFD part]
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
drivers/extcon/extcon-arizona.c
include/linux/mfd/arizona/pdata.h

index 6c84e3d120435f9ad16d5afd3a030e98140b6f47..cf907430a69854cabe6750a1b1cffd2cc59df3fc 100644 (file)
 #define ARIZONA_ACCDET_MODE_HPL 1
 #define ARIZONA_ACCDET_MODE_HPR 2
 
+#define ARIZONA_MICD_CLAMP_MODE_JDL      0x4
+#define ARIZONA_MICD_CLAMP_MODE_JDH      0x5
+#define ARIZONA_MICD_CLAMP_MODE_JDL_GP5H 0x9
+#define ARIZONA_MICD_CLAMP_MODE_JDH_GP5H 0xb
+
 #define ARIZONA_HPDET_MAX 10000
 
 #define HPDET_DEBOUNCE 500
@@ -962,10 +967,16 @@ static irqreturn_t arizona_jackdet(int irq, void *data)
 
        if (arizona->pdata.jd_gpio5) {
                mask = ARIZONA_MICD_CLAMP_STS;
-               present = 0;
+               if (arizona->pdata.jd_invert)
+                       present = ARIZONA_MICD_CLAMP_STS;
+               else
+                       present = 0;
        } else {
                mask = ARIZONA_JD1_STS;
-               present = ARIZONA_JD1_STS;
+               if (arizona->pdata.jd_invert)
+                       present = 0;
+               else
+                       present = ARIZONA_JD1_STS;
        }
 
        ret = regmap_read(arizona->regmap, ARIZONA_AOD_IRQ_RAW_STATUS, &val);
@@ -1096,6 +1107,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)
        struct arizona_pdata *pdata = &arizona->pdata;
        struct arizona_extcon_info *info;
        unsigned int val;
+       unsigned int clamp_mode;
        int jack_irq_fall, jack_irq_rise;
        int ret, mode, i, j;
 
@@ -1305,15 +1317,21 @@ static int arizona_extcon_probe(struct platform_device *pdev)
                        regmap_write(arizona->regmap, ARIZONA_GPIO5_CTRL,
                                     val);
 
-                       regmap_update_bits(arizona->regmap,
-                                          ARIZONA_MICD_CLAMP_CONTROL,
-                                          ARIZONA_MICD_CLAMP_MODE_MASK, 0x9);
+                       if (arizona->pdata.jd_invert)
+                               clamp_mode = ARIZONA_MICD_CLAMP_MODE_JDH_GP5H;
+                       else
+                               clamp_mode = ARIZONA_MICD_CLAMP_MODE_JDL_GP5H;
                } else {
-                       regmap_update_bits(arizona->regmap,
-                                          ARIZONA_MICD_CLAMP_CONTROL,
-                                          ARIZONA_MICD_CLAMP_MODE_MASK, 0x4);
+                       if (arizona->pdata.jd_invert)
+                               clamp_mode = ARIZONA_MICD_CLAMP_MODE_JDH;
+                       else
+                               clamp_mode = ARIZONA_MICD_CLAMP_MODE_JDL;
                }
 
+               regmap_update_bits(arizona->regmap,
+                                  ARIZONA_MICD_CLAMP_CONTROL,
+                                  ARIZONA_MICD_CLAMP_MODE_MASK, clamp_mode);
+
                regmap_update_bits(arizona->regmap,
                                   ARIZONA_JACK_DETECT_DEBOUNCE,
                                   ARIZONA_MICD_CLAMP_DB,
index 12a5c135c746d9c69be4199a022f4d3519920f08..4578c72c9b86c56d045e85002000ddee2dc81147 100644 (file)
@@ -127,6 +127,9 @@ struct arizona_pdata {
        /** Internal pull on GPIO5 is disabled when used for jack detection */
        bool jd_gpio5_nopull;
 
+       /** set to true if jackdet contact opens on insert */
+       bool jd_invert;
+
        /** Use the headphone detect circuit to identify the accessory */
        bool hpdet_acc_id;