aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/extcon/extcon-arizona.c19
-rw-r--r--include/linux/mfd/arizona/registers.h9
2 files changed, 23 insertions, 5 deletions
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index a287cece0593..5775f055bd02 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -44,6 +44,15 @@
44#define HPDET_DEBOUNCE 500 44#define HPDET_DEBOUNCE 500
45#define DEFAULT_MICD_TIMEOUT 2000 45#define DEFAULT_MICD_TIMEOUT 2000
46 46
47#define MICD_LVL_1_TO_7 (ARIZONA_MICD_LVL_1 | ARIZONA_MICD_LVL_2 | \
48 ARIZONA_MICD_LVL_3 | ARIZONA_MICD_LVL_4 | \
49 ARIZONA_MICD_LVL_5 | ARIZONA_MICD_LVL_6 | \
50 ARIZONA_MICD_LVL_7)
51
52#define MICD_LVL_0_TO_7 (ARIZONA_MICD_LVL_0 | MICD_LVL_1_TO_7)
53
54#define MICD_LVL_0_TO_8 (MICD_LVL_0_TO_7 | ARIZONA_MICD_LVL_8)
55
47struct arizona_extcon_info { 56struct arizona_extcon_info {
48 struct device *dev; 57 struct device *dev;
49 struct arizona *arizona; 58 struct arizona *arizona;
@@ -765,7 +774,7 @@ static void arizona_micd_detect(struct work_struct *work)
765 774
766 mutex_lock(&info->lock); 775 mutex_lock(&info->lock);
767 776
768 for (i = 0; i < 10 && !(val & 0x7fc); i++) { 777 for (i = 0; i < 10 && !(val & MICD_LVL_0_TO_8); i++) {
769 ret = regmap_read(arizona->regmap, ARIZONA_MIC_DETECT_3, &val); 778 ret = regmap_read(arizona->regmap, ARIZONA_MIC_DETECT_3, &val);
770 if (ret != 0) { 779 if (ret != 0) {
771 dev_err(arizona->dev, 780 dev_err(arizona->dev,
@@ -784,7 +793,7 @@ static void arizona_micd_detect(struct work_struct *work)
784 } 793 }
785 } 794 }
786 795
787 if (i == 10 && !(val & 0x7fc)) { 796 if (i == 10 && !(val & MICD_LVL_0_TO_8)) {
788 dev_err(arizona->dev, "Failed to get valid MICDET value\n"); 797 dev_err(arizona->dev, "Failed to get valid MICDET value\n");
789 mutex_unlock(&info->lock); 798 mutex_unlock(&info->lock);
790 return; 799 return;
@@ -798,7 +807,7 @@ static void arizona_micd_detect(struct work_struct *work)
798 } 807 }
799 808
800 /* If we got a high impedence we should have a headset, report it. */ 809 /* If we got a high impedence we should have a headset, report it. */
801 if (info->detecting && (val & 0x400)) { 810 if (info->detecting && (val & ARIZONA_MICD_LVL_8)) {
802 arizona_identify_headphone(info); 811 arizona_identify_headphone(info);
803 812
804 ret = extcon_update_state(&info->edev, 813 ret = extcon_update_state(&info->edev,
@@ -827,7 +836,7 @@ static void arizona_micd_detect(struct work_struct *work)
827 * plain headphones. If both polarities report a low 836 * plain headphones. If both polarities report a low
828 * impedence then give up and report headphones. 837 * impedence then give up and report headphones.
829 */ 838 */
830 if (info->detecting && (val & 0x3f8)) { 839 if (info->detecting && (val & MICD_LVL_1_TO_7)) {
831 if (info->jack_flips >= info->micd_num_modes * 10) { 840 if (info->jack_flips >= info->micd_num_modes * 10) {
832 dev_dbg(arizona->dev, "Detected HP/line\n"); 841 dev_dbg(arizona->dev, "Detected HP/line\n");
833 arizona_identify_headphone(info); 842 arizona_identify_headphone(info);
@@ -851,7 +860,7 @@ static void arizona_micd_detect(struct work_struct *work)
851 * If we're still detecting and we detect a short then we've 860 * If we're still detecting and we detect a short then we've
852 * got a headphone. Otherwise it's a button press. 861 * got a headphone. Otherwise it's a button press.
853 */ 862 */
854 if (val & 0x3fc) { 863 if (val & MICD_LVL_0_TO_7) {
855 if (info->mic) { 864 if (info->mic) {
856 dev_dbg(arizona->dev, "Mic button detected\n"); 865 dev_dbg(arizona->dev, "Mic button detected\n");
857 866
diff --git a/include/linux/mfd/arizona/registers.h b/include/linux/mfd/arizona/registers.h
index cb49417f8ba9..b31976595eba 100644
--- a/include/linux/mfd/arizona/registers.h
+++ b/include/linux/mfd/arizona/registers.h
@@ -2196,6 +2196,15 @@
2196/* 2196/*
2197 * R677 (0x2A5) - Mic Detect 3 2197 * R677 (0x2A5) - Mic Detect 3
2198 */ 2198 */
2199#define ARIZONA_MICD_LVL_0 0x0004 /* MICD_LVL - [2] */
2200#define ARIZONA_MICD_LVL_1 0x0008 /* MICD_LVL - [3] */
2201#define ARIZONA_MICD_LVL_2 0x0010 /* MICD_LVL - [4] */
2202#define ARIZONA_MICD_LVL_3 0x0020 /* MICD_LVL - [5] */
2203#define ARIZONA_MICD_LVL_4 0x0040 /* MICD_LVL - [6] */
2204#define ARIZONA_MICD_LVL_5 0x0080 /* MICD_LVL - [7] */
2205#define ARIZONA_MICD_LVL_6 0x0100 /* MICD_LVL - [8] */
2206#define ARIZONA_MICD_LVL_7 0x0200 /* MICD_LVL - [9] */
2207#define ARIZONA_MICD_LVL_8 0x0400 /* MICD_LVL - [10] */
2199#define ARIZONA_MICD_LVL_MASK 0x07FC /* MICD_LVL - [10:2] */ 2208#define ARIZONA_MICD_LVL_MASK 0x07FC /* MICD_LVL - [10:2] */
2200#define ARIZONA_MICD_LVL_SHIFT 2 /* MICD_LVL - [10:2] */ 2209#define ARIZONA_MICD_LVL_SHIFT 2 /* MICD_LVL - [10:2] */
2201#define ARIZONA_MICD_LVL_WIDTH 9 /* MICD_LVL - [10:2] */ 2210#define ARIZONA_MICD_LVL_WIDTH 9 /* MICD_LVL - [10:2] */