]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/extcon/extcon-arizona.c
Merge remote-tracking branch 'char-misc/char-misc-next'
[karo-tx-linux.git] / drivers / extcon / extcon-arizona.c
index 4479781ee941bd12e470313f3dcf1eaed517dfd7..e4890dd4fefd6ee52ca5a411b7b3aa4dc0905175 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * extcon-arizona.c - Extcon driver Wolfson Arizona devices
  *
- *  Copyright (C) 2012 Wolfson Microelectronics plc
+ *  Copyright (C) 2012-2014 Wolfson Microelectronics plc
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -137,9 +137,9 @@ static const int arizona_micd_levels[] = {
 
 static const unsigned int arizona_cable[] = {
        EXTCON_MECHANICAL,
-       EXTCON_MICROPHONE,
-       EXTCON_HEADPHONE,
-       EXTCON_LINE_OUT,
+       EXTCON_JACK_MICROPHONE,
+       EXTCON_JACK_HEADPHONE,
+       EXTCON_JACK_LINE_OUT,
        EXTCON_NONE,
 };
 
@@ -154,6 +154,10 @@ static void arizona_extcon_hp_clamp(struct arizona_extcon_info *info,
        int ret;
 
        switch (arizona->type) {
+       case WM8998:
+       case WM1814:
+               mask = 0;
+               break;
        case WM5110:
        case WM8280:
                mask = ARIZONA_HP1L_SHRTO | ARIZONA_HP1L_FLWR |
@@ -197,17 +201,19 @@ static void arizona_extcon_hp_clamp(struct arizona_extcon_info *info,
                                 ret);
        }
 
-       ret = regmap_update_bits(arizona->regmap, ARIZONA_HP_CTRL_1L,
-                                mask, val);
-       if (ret != 0)
-               dev_warn(arizona->dev, "Failed to do clamp: %d\n",
+       if (mask) {
+               ret = regmap_update_bits(arizona->regmap, ARIZONA_HP_CTRL_1L,
+                                        mask, val);
+               if (ret != 0)
+                       dev_warn(arizona->dev, "Failed to do clamp: %d\n",
                                 ret);
 
-       ret = regmap_update_bits(arizona->regmap, ARIZONA_HP_CTRL_1R,
-                                mask, val);
-       if (ret != 0)
-               dev_warn(arizona->dev, "Failed to do clamp: %d\n",
-                        ret);
+               ret = regmap_update_bits(arizona->regmap, ARIZONA_HP_CTRL_1R,
+                                        mask, val);
+               if (ret != 0)
+                       dev_warn(arizona->dev, "Failed to do clamp: %d\n",
+                                ret);
+       }
 
        /* Restore the desired state while not doing the clamp */
        if (!clamp) {
@@ -471,9 +477,6 @@ static int arizona_hpdet_read(struct arizona_extcon_info *info)
                           arizona_hpdet_b_ranges[range].factor_a);
                break;
 
-       default:
-               dev_warn(arizona->dev, "Unknown HPDET IP revision %d\n",
-                        info->hpdet_ip_version);
        case 2:
                if (!(val & ARIZONA_HP_DONE_B)) {
                        dev_err(arizona->dev, "HPDET did not complete: %x\n",
@@ -510,6 +513,12 @@ static int arizona_hpdet_read(struct arizona_extcon_info *info)
                                arizona_hpdet_c_ranges[range].min);
                        val = arizona_hpdet_c_ranges[range].min;
                }
+               break;
+
+       default:
+               dev_warn(arizona->dev, "Unknown HPDET IP revision %d\n",
+                        info->hpdet_ip_version);
+               return -EINVAL;
        }
 
        dev_dbg(arizona->dev, "HP impedance %d ohms\n", val);
@@ -591,7 +600,7 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data)
        struct arizona_extcon_info *info = data;
        struct arizona *arizona = info->arizona;
        int id_gpio = arizona->pdata.hpdet_id_gpio;
-       unsigned int report = EXTCON_HEADPHONE;
+       unsigned int report = EXTCON_JACK_HEADPHONE;
        int ret, reading;
        bool mic = false;
 
@@ -636,9 +645,9 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data)
 
        /* Report high impedence cables as line outputs */
        if (reading >= 5000)
-               report = EXTCON_LINE_OUT;
+               report = EXTCON_JACK_LINE_OUT;
        else
-               report = EXTCON_HEADPHONE;
+               report = EXTCON_JACK_HEADPHONE;
 
        ret = extcon_set_cable_state_(info->edev, report, true);
        if (ret != 0)
@@ -723,7 +732,7 @@ err:
                           ARIZONA_ACCDET_MODE_MASK, ARIZONA_ACCDET_MODE_MIC);
 
        /* Just report headphone */
-       ret = extcon_set_cable_state_(info->edev, EXTCON_HEADPHONE, true);
+       ret = extcon_set_cable_state_(info->edev, EXTCON_JACK_HEADPHONE, true);
        if (ret != 0)
                dev_err(arizona->dev, "Failed to report headphone: %d\n", ret);
 
@@ -780,7 +789,7 @@ err:
                           ARIZONA_ACCDET_MODE_MASK, ARIZONA_ACCDET_MODE_MIC);
 
        /* Just report headphone */
-       ret = extcon_set_cable_state_(info->edev, EXTCON_HEADPHONE, true);
+       ret = extcon_set_cable_state_(info->edev, EXTCON_JACK_HEADPHONE, true);
        if (ret != 0)
                dev_err(arizona->dev, "Failed to report headphone: %d\n", ret);
 
@@ -906,7 +915,7 @@ static void arizona_micd_detect(struct work_struct *work)
                arizona_identify_headphone(info);
 
                ret = extcon_set_cable_state_(info->edev,
-                                             EXTCON_MICROPHONE, true);
+                                             EXTCON_JACK_MICROPHONE, true);
                if (ret != 0)
                        dev_err(arizona->dev, "Headset report failed: %d\n",
                                ret);
@@ -1289,6 +1298,11 @@ static int arizona_extcon_probe(struct platform_device *pdev)
                        break;
                }
                break;
+       case WM8998:
+       case WM1814:
+               info->micd_clamp = true;
+               info->hpdet_ip_version = 2;
+               break;
        default:
                break;
        }