public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/9] Arizona Extcon Bug Fixes and Improvements
@ 2015-09-16  9:42 Charles Keepax
  2015-09-16  9:42 ` [PATCH 1/9] mfd: arizona: Add registers for ADC microphone detection Charles Keepax
                   ` (9 more replies)
  0 siblings, 10 replies; 12+ messages in thread
From: Charles Keepax @ 2015-09-16  9:42 UTC (permalink / raw)
  To: cw00.choi, lee.jones; +Cc: myungjoo.ham, sameo, patches, linux-kernel

Hi,

Ok I have split these patches out into 2 chains; this chain
contains no device tree changes so that should let us merge
these now and at least get the benefit of the bug fixes
etc. whilst we work on getting the necessary ACKs for the
DT changes. The DT changes themselves should be simpler to
merge as there are no build dependencies there between the
extcon and MFD patches so they can just each go through
their respective trees. Whereas this chain needs to all go
through one tree.

These patches add support for the ADC mode microphone
detection, and the general purpose switch for pop
suppression. The bug fixes include fixing the headphone
detection accuracy at the top end of the range and some
corrections around the use of the microphone clamps.

Thanks,
Charles

Charles Keepax (8):
  mfd: arizona: Add registers for ADC microphone detection
  mfd: arizona: Add register bits for general purpose switch
  mfd: arizona: Add TST_CAP bits for headphone detection
  extcon: arizona: Add support for new ADC value mic detect
  extcon: arizona: Add support for general purpose switch
  extcon: arizona: Additional settings to improve accuracy of HP detect
  extcon: arizona: Use the micd_clamp for interrupts if it is available
  extcon: arizona: Don't disable debounce for inverted jacks

Nariman Poushin (1):
  extcon: arizona: Ignore jd_invert for MICD_CLAMP_STS

 drivers/extcon/extcon-arizona.c       |  106 +++++++++++++++++++++++++++------
 drivers/mfd/wm5110-tables.c           |    6 ++
 include/dt-bindings/mfd/arizona.h     |    2 +
 include/linux/mfd/arizona/pdata.h     |    6 ++
 include/linux/mfd/arizona/registers.h |   14 ++++-
 5 files changed, 113 insertions(+), 21 deletions(-)

-- 
1.7.2.5


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/9] mfd: arizona: Add registers for ADC microphone detection
  2015-09-16  9:42 [PATCH 0/9] Arizona Extcon Bug Fixes and Improvements Charles Keepax
@ 2015-09-16  9:42 ` Charles Keepax
  2015-09-16  9:42 ` [PATCH 2/9] mfd: arizona: Add register bits for general purpose switch Charles Keepax
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Charles Keepax @ 2015-09-16  9:42 UTC (permalink / raw)
  To: cw00.choi, lee.jones; +Cc: myungjoo.ham, sameo, patches, linux-kernel

The newer devices support using a software comparison to determine
whether a 3/4 pole jack is present. Add the registers necessary for
this.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
---
 drivers/mfd/wm5110-tables.c           |    2 ++
 include/dt-bindings/mfd/arizona.h     |    2 ++
 include/linux/mfd/arizona/pdata.h     |    3 +++
 include/linux/mfd/arizona/registers.h |    6 +++---
 4 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/mfd/wm5110-tables.c b/drivers/mfd/wm5110-tables.c
index c4b9374..5f604e0 100644
--- a/drivers/mfd/wm5110-tables.c
+++ b/drivers/mfd/wm5110-tables.c
@@ -1811,6 +1811,7 @@ static bool wm5110_readable_register(struct device *dev, unsigned int reg)
 	case ARIZONA_MIC_DETECT_1:
 	case ARIZONA_MIC_DETECT_2:
 	case ARIZONA_MIC_DETECT_3:
+	case ARIZONA_MIC_DETECT_4:
 	case ARIZONA_MIC_DETECT_LEVEL_1:
 	case ARIZONA_MIC_DETECT_LEVEL_2:
 	case ARIZONA_MIC_DETECT_LEVEL_3:
@@ -2847,6 +2848,7 @@ static bool wm5110_volatile_register(struct device *dev, unsigned int reg)
 	case ARIZONA_ASYNC_SAMPLE_RATE_1_STATUS:
 	case ARIZONA_ASYNC_SAMPLE_RATE_2_STATUS:
 	case ARIZONA_MIC_DETECT_3:
+	case ARIZONA_MIC_DETECT_4:
 	case ARIZONA_HP_CTRL_1L:
 	case ARIZONA_HP_CTRL_1R:
 	case ARIZONA_HEADPHONE_DETECT_2:
diff --git a/include/dt-bindings/mfd/arizona.h b/include/dt-bindings/mfd/arizona.h
index 7b2000c..c40f665 100644
--- a/include/dt-bindings/mfd/arizona.h
+++ b/include/dt-bindings/mfd/arizona.h
@@ -107,5 +107,7 @@
 #define ARIZONA_ACCDET_MODE_MIC 0
 #define ARIZONA_ACCDET_MODE_HPL 1
 #define ARIZONA_ACCDET_MODE_HPR 2
+#define ARIZONA_ACCDET_MODE_HPM 4
+#define ARIZONA_ACCDET_MODE_ADC 7
 
 #endif
diff --git a/include/linux/mfd/arizona/pdata.h b/include/linux/mfd/arizona/pdata.h
index 1dc3858..92f31ffa 100644
--- a/include/linux/mfd/arizona/pdata.h
+++ b/include/linux/mfd/arizona/pdata.h
@@ -124,6 +124,9 @@ struct arizona_pdata {
 	/** Channel to use for headphone detection */
 	unsigned int hpdet_channel;
 
+	/** Use software comparison to determine mic presence */
+	bool micd_software_compare;
+
 	/** Extra debounce timeout used during initial mic detection (ms) */
 	unsigned int micd_detect_debounce;
 
diff --git a/include/linux/mfd/arizona/registers.h b/include/linux/mfd/arizona/registers.h
index fdd70b3..ab219c9 100644
--- a/include/linux/mfd/arizona/registers.h
+++ b/include/linux/mfd/arizona/registers.h
@@ -2359,9 +2359,9 @@
 #define ARIZONA_ACCDET_SRC_MASK                  0x2000  /* ACCDET_SRC */
 #define ARIZONA_ACCDET_SRC_SHIFT                     13  /* ACCDET_SRC */
 #define ARIZONA_ACCDET_SRC_WIDTH                      1  /* ACCDET_SRC */
-#define ARIZONA_ACCDET_MODE_MASK                 0x0003  /* ACCDET_MODE - [1:0] */
-#define ARIZONA_ACCDET_MODE_SHIFT                     0  /* ACCDET_MODE - [1:0] */
-#define ARIZONA_ACCDET_MODE_WIDTH                     2  /* ACCDET_MODE - [1:0] */
+#define ARIZONA_ACCDET_MODE_MASK                 0x0007  /* ACCDET_MODE - [2:0] */
+#define ARIZONA_ACCDET_MODE_SHIFT                     0  /* ACCDET_MODE - [2:0] */
+#define ARIZONA_ACCDET_MODE_WIDTH                     3  /* ACCDET_MODE - [2:0] */
 
 /*
  * R667 (0x29B) - Headphone Detect 1
-- 
1.7.2.5


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/9] mfd: arizona: Add register bits for general purpose switch
  2015-09-16  9:42 [PATCH 0/9] Arizona Extcon Bug Fixes and Improvements Charles Keepax
  2015-09-16  9:42 ` [PATCH 1/9] mfd: arizona: Add registers for ADC microphone detection Charles Keepax
@ 2015-09-16  9:42 ` Charles Keepax
  2015-09-16  9:42 ` [PATCH 3/9] mfd: arizona: Add TST_CAP bits for headphone detection Charles Keepax
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Charles Keepax @ 2015-09-16  9:42 UTC (permalink / raw)
  To: cw00.choi, lee.jones; +Cc: myungjoo.ham, sameo, patches, linux-kernel

The switch is typically used in conjunction with the MICDET clamp in
order to suppress pops and clicks associated with jack insertion.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
---
 drivers/mfd/wm5110-tables.c       |    2 ++
 include/linux/mfd/arizona/pdata.h |    3 +++
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/mfd/wm5110-tables.c b/drivers/mfd/wm5110-tables.c
index 5f604e0..aae17d6 100644
--- a/drivers/mfd/wm5110-tables.c
+++ b/drivers/mfd/wm5110-tables.c
@@ -1481,6 +1481,7 @@ static const struct reg_default wm5110_reg_default[] = {
 	{ 0x00000C04, 0xA101 },    /* R3076  - GPIO5 CTRL */
 	{ 0x00000C0F, 0x0400 },    /* R3087  - IRQ CTRL 1 */
 	{ 0x00000C10, 0x1000 },    /* R3088  - GPIO Debounce Config */
+	{ 0x00000C18, 0x0000 },    /* R3096  - GP Switch 1 */
 	{ 0x00000C20, 0x8002 },    /* R3104  - Misc Pad Ctrl 1 */
 	{ 0x00000C21, 0x8001 },    /* R3105  - Misc Pad Ctrl 2 */
 	{ 0x00000C22, 0x0000 },    /* R3106  - Misc Pad Ctrl 3 */
@@ -2528,6 +2529,7 @@ static bool wm5110_readable_register(struct device *dev, unsigned int reg)
 	case ARIZONA_GPIO5_CTRL:
 	case ARIZONA_IRQ_CTRL_1:
 	case ARIZONA_GPIO_DEBOUNCE_CONFIG:
+	case ARIZONA_GP_SWITCH_1:
 	case ARIZONA_MISC_PAD_CTRL_1:
 	case ARIZONA_MISC_PAD_CTRL_2:
 	case ARIZONA_MISC_PAD_CTRL_3:
diff --git a/include/linux/mfd/arizona/pdata.h b/include/linux/mfd/arizona/pdata.h
index 92f31ffa..57b45ca 100644
--- a/include/linux/mfd/arizona/pdata.h
+++ b/include/linux/mfd/arizona/pdata.h
@@ -184,6 +184,9 @@ struct arizona_pdata {
 
 	/** GPIO for primary IRQ (used for edge triggered emulation) */
 	int irq_gpio;
+
+	/** General purpose switch control */
+	unsigned int gpsw;
 };
 
 #endif
-- 
1.7.2.5


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/9] mfd: arizona: Add TST_CAP bits for headphone detection
  2015-09-16  9:42 [PATCH 0/9] Arizona Extcon Bug Fixes and Improvements Charles Keepax
  2015-09-16  9:42 ` [PATCH 1/9] mfd: arizona: Add registers for ADC microphone detection Charles Keepax
  2015-09-16  9:42 ` [PATCH 2/9] mfd: arizona: Add register bits for general purpose switch Charles Keepax
@ 2015-09-16  9:42 ` Charles Keepax
  2015-09-20  4:17   ` Lee Jones
  2015-09-16  9:42 ` [PATCH 4/9] extcon: arizona: Add support for new ADC value mic detect Charles Keepax
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 12+ messages in thread
From: Charles Keepax @ 2015-09-16  9:42 UTC (permalink / raw)
  To: cw00.choi, lee.jones; +Cc: myungjoo.ham, sameo, patches, linux-kernel

On wm5110/8280 some additional settings are required to get accurate
measurements at the top end of the headphone detection range. This patch
adds the bits required for this.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 drivers/mfd/wm5110-tables.c           |    2 ++
 include/linux/mfd/arizona/registers.h |    8 ++++++++
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/drivers/mfd/wm5110-tables.c b/drivers/mfd/wm5110-tables.c
index aae17d6..28f2ae3 100644
--- a/drivers/mfd/wm5110-tables.c
+++ b/drivers/mfd/wm5110-tables.c
@@ -1912,6 +1912,7 @@ static bool wm5110_readable_register(struct device *dev, unsigned int reg)
 	case ARIZONA_HP1_SHORT_CIRCUIT_CTRL:
 	case ARIZONA_HP2_SHORT_CIRCUIT_CTRL:
 	case ARIZONA_HP3_SHORT_CIRCUIT_CTRL:
+	case ARIZONA_HP_TEST_CTRL_1:
 	case ARIZONA_AIF1_BCLK_CTRL:
 	case ARIZONA_AIF1_TX_PIN_CTRL:
 	case ARIZONA_AIF1_RX_PIN_CTRL:
@@ -2857,6 +2858,7 @@ static bool wm5110_volatile_register(struct device *dev, unsigned int reg)
 	case ARIZONA_INPUT_ENABLES_STATUS:
 	case ARIZONA_OUTPUT_STATUS_1:
 	case ARIZONA_RAW_OUTPUT_STATUS_1:
+	case ARIZONA_HP_TEST_CTRL_1:
 	case ARIZONA_SLIMBUS_RX_PORT_STATUS:
 	case ARIZONA_SLIMBUS_TX_PORT_STATUS:
 	case ARIZONA_INTERRUPT_STATUS_1:
diff --git a/include/linux/mfd/arizona/registers.h b/include/linux/mfd/arizona/registers.h
index ab219c9..c7c11c9 100644
--- a/include/linux/mfd/arizona/registers.h
+++ b/include/linux/mfd/arizona/registers.h
@@ -242,6 +242,7 @@
 #define ARIZONA_HP1_SHORT_CIRCUIT_CTRL           0x4A0
 #define ARIZONA_HP2_SHORT_CIRCUIT_CTRL           0x4A1
 #define ARIZONA_HP3_SHORT_CIRCUIT_CTRL           0x4A2
+#define ARIZONA_HP_TEST_CTRL_1                   0x4A4
 #define ARIZONA_SPK_CTRL_2                       0x4B5
 #define ARIZONA_SPK_CTRL_3                       0x4B6
 #define ARIZONA_DAC_COMP_1                       0x4DC
@@ -3702,6 +3703,13 @@
 #define ARIZONA_HP3_SC_ENA_WIDTH                      1  /* HP3_SC_ENA */
 
 /*
+ * R1188 (0x4A4) HP Test Ctrl 1
+ */
+#define ARIZONA_HP1_TST_CAP_SEL_MASK             0x0003  /* HP1_TST_CAP_SEL - [1:0] */
+#define ARIZONA_HP1_TST_CAP_SEL_SHIFT                 0  /* HP1_TST_CAP_SEL - [1:0] */
+#define ARIZONA_HP1_TST_CAP_SEL_WIDTH                 2  /* HP1_TST_CAP_SEL - [1:0] */
+
+/*
  * R1244 (0x4DC) - DAC comp 1
  */
 #define ARIZONA_OUT_COMP_COEFF_MASK              0xFFFF  /* OUT_COMP_COEFF - [15:0] */
-- 
1.7.2.5


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/9] extcon: arizona: Add support for new ADC value mic detect
  2015-09-16  9:42 [PATCH 0/9] Arizona Extcon Bug Fixes and Improvements Charles Keepax
                   ` (2 preceding siblings ...)
  2015-09-16  9:42 ` [PATCH 3/9] mfd: arizona: Add TST_CAP bits for headphone detection Charles Keepax
@ 2015-09-16  9:42 ` Charles Keepax
  2015-09-16  9:42 ` [PATCH 5/9] extcon: arizona: Add support for general purpose switch Charles Keepax
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Charles Keepax @ 2015-09-16  9:42 UTC (permalink / raw)
  To: cw00.choi, lee.jones; +Cc: myungjoo.ham, sameo, patches, linux-kernel

Newer devices give users the option to make the 3/4 pole jack
determination using a software comparison rather than a hardware one.
This patch adds support for this functionality.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
---
 drivers/extcon/extcon-arizona.c |   64 +++++++++++++++++++++++++++++++++++----
 1 files changed, 58 insertions(+), 6 deletions(-)

diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index 4b9f09c..f213e14 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -48,6 +48,10 @@
 #define HPDET_DEBOUNCE 500
 #define DEFAULT_MICD_TIMEOUT 2000
 
+#define QUICK_HEADPHONE_MAX_OHM 3
+#define MICROPHONE_MIN_OHM      1257
+#define MICROPHONE_MAX_OHM      30000
+
 #define MICD_DBTIME_TWO_READINGS 2
 #define MICD_DBTIME_FOUR_READINGS 4
 
@@ -117,12 +121,15 @@ static const struct arizona_micd_range micd_default_ranges[] = {
 	{ .max = 430, .key = BTN_5 },
 };
 
+/* The number of levels in arizona_micd_levels valid for button thresholds */
+#define ARIZONA_NUM_MICD_BUTTON_LEVELS 64
+
 static const int arizona_micd_levels[] = {
 	3, 6, 8, 11, 13, 16, 18, 21, 23, 26, 28, 31, 34, 36, 39, 41, 44, 46,
 	49, 52, 54, 57, 60, 62, 65, 67, 70, 73, 75, 78, 81, 83, 89, 94, 100,
 	105, 111, 116, 122, 127, 139, 150, 161, 173, 186, 196, 209, 220, 245,
 	270, 295, 321, 348, 375, 402, 430, 489, 550, 614, 681, 752, 903, 1071,
-	1257,
+	1257, 30000,
 };
 
 static const unsigned int arizona_cable[] = {
@@ -270,6 +277,7 @@ static void arizona_start_mic(struct arizona_extcon_info *info)
 	struct arizona *arizona = info->arizona;
 	bool change;
 	int ret;
+	unsigned int mode;
 
 	/* Microphone detection can't use idle mode */
 	pm_runtime_get(info->dev);
@@ -295,9 +303,14 @@ static void arizona_start_mic(struct arizona_extcon_info *info)
 		regmap_write(arizona->regmap, 0x80, 0x0);
 	}
 
+	if (info->detecting && arizona->pdata.micd_software_compare)
+		mode = ARIZONA_ACCDET_MODE_ADC;
+	else
+		mode = ARIZONA_ACCDET_MODE_MIC;
+
 	regmap_update_bits(arizona->regmap,
 			   ARIZONA_ACCESSORY_DETECT_MODE_1,
-			   ARIZONA_ACCDET_MODE_MASK, ARIZONA_ACCDET_MODE_MIC);
+			   ARIZONA_ACCDET_MODE_MASK, mode);
 
 	arizona_extcon_pulse_micbias(info);
 
@@ -804,6 +817,37 @@ static void arizona_micd_detect(struct work_struct *work)
 		return;
 	}
 
+	if (info->detecting && arizona->pdata.micd_software_compare) {
+		/* Must disable MICD before we read the ADCVAL */
+		regmap_update_bits(arizona->regmap, ARIZONA_MIC_DETECT_1,
+				   ARIZONA_MICD_ENA, 0);
+		ret = regmap_read(arizona->regmap, ARIZONA_MIC_DETECT_4, &val);
+		if (ret != 0) {
+			dev_err(arizona->dev,
+				"Failed to read MICDET_ADCVAL: %d\n",
+				ret);
+			mutex_unlock(&info->lock);
+			return;
+		}
+
+		dev_dbg(arizona->dev, "MICDET_ADCVAL: %x\n", val);
+
+		val &= ARIZONA_MICDET_ADCVAL_MASK;
+		if (val < ARRAY_SIZE(arizona_micd_levels))
+			val = arizona_micd_levels[val];
+		else
+			val = INT_MAX;
+
+		if (val <= QUICK_HEADPHONE_MAX_OHM)
+			val = ARIZONA_MICD_STS | ARIZONA_MICD_LVL_0;
+		else if (val <= MICROPHONE_MIN_OHM)
+			val = ARIZONA_MICD_STS | ARIZONA_MICD_LVL_1;
+		else if (val <= MICROPHONE_MAX_OHM)
+			val = ARIZONA_MICD_STS | ARIZONA_MICD_LVL_8;
+		else
+			val = ARIZONA_MICD_LVL_8;
+	}
+
 	for (i = 0; i < 10 && !(val & MICD_LVL_0_TO_8); i++) {
 		ret = regmap_read(arizona->regmap, ARIZONA_MIC_DETECT_3, &val);
 		if (ret != 0) {
@@ -932,10 +976,17 @@ static void arizona_micd_detect(struct work_struct *work)
 	}
 
 handled:
-	if (info->detecting)
+	if (info->detecting) {
+		if (arizona->pdata.micd_software_compare)
+			regmap_update_bits(arizona->regmap,
+					   ARIZONA_MIC_DETECT_1,
+					   ARIZONA_MICD_ENA,
+					   ARIZONA_MICD_ENA);
+
 		queue_delayed_work(system_power_efficient_wq,
 				   &info->micd_timeout_work,
 				   msecs_to_jiffies(info->micd_timeout));
+	}
 
 	pm_runtime_mark_last_busy(info->dev);
 	mutex_unlock(&info->lock);
@@ -1335,7 +1386,8 @@ static int arizona_extcon_probe(struct platform_device *pdev)
 		break;
 	}
 
-	BUILD_BUG_ON(ARRAY_SIZE(arizona_micd_levels) != 0x40);
+	BUILD_BUG_ON(ARRAY_SIZE(arizona_micd_levels) <
+		     ARIZONA_NUM_MICD_BUTTON_LEVELS);
 
 	if (arizona->pdata.num_micd_ranges) {
 		info->micd_ranges = pdata->micd_ranges;
@@ -1368,11 +1420,11 @@ static int arizona_extcon_probe(struct platform_device *pdev)
 
 	/* Set up all the buttons the user specified */
 	for (i = 0; i < info->num_micd_ranges; i++) {
-		for (j = 0; j < ARRAY_SIZE(arizona_micd_levels); j++)
+		for (j = 0; j < ARIZONA_NUM_MICD_BUTTON_LEVELS; j++)
 			if (arizona_micd_levels[j] >= info->micd_ranges[i].max)
 				break;
 
-		if (j == ARRAY_SIZE(arizona_micd_levels)) {
+		if (j == ARIZONA_NUM_MICD_BUTTON_LEVELS) {
 			dev_err(arizona->dev, "Unsupported MICD level %d\n",
 				info->micd_ranges[i].max);
 			ret = -EINVAL;
-- 
1.7.2.5


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 5/9] extcon: arizona: Add support for general purpose switch
  2015-09-16  9:42 [PATCH 0/9] Arizona Extcon Bug Fixes and Improvements Charles Keepax
                   ` (3 preceding siblings ...)
  2015-09-16  9:42 ` [PATCH 4/9] extcon: arizona: Add support for new ADC value mic detect Charles Keepax
@ 2015-09-16  9:42 ` Charles Keepax
  2015-09-16  9:42 ` [PATCH 6/9] extcon: arizona: Additional settings to improve accuracy of HP detect Charles Keepax
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Charles Keepax @ 2015-09-16  9:42 UTC (permalink / raw)
  To: cw00.choi, lee.jones; +Cc: myungjoo.ham, sameo, patches, linux-kernel

The switch is typically used in conjunction with the MICDET clamp in
order to suppress pops and clicks associated with jack insertion.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
---
 drivers/extcon/extcon-arizona.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index f213e14..d719ee7 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -1310,6 +1310,10 @@ static int arizona_extcon_probe(struct platform_device *pdev)
 		info->micd_num_modes = ARRAY_SIZE(micd_default_modes);
 	}
 
+	if (arizona->pdata.gpsw > 0)
+		regmap_update_bits(arizona->regmap, ARIZONA_GP_SWITCH_1,
+				ARIZONA_SW1_MODE_MASK, arizona->pdata.gpsw);
+
 	if (arizona->pdata.micd_pol_gpio > 0) {
 		if (info->micd_modes[0].gpio)
 			mode = GPIOF_OUT_INIT_HIGH;
-- 
1.7.2.5


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 6/9] extcon: arizona: Additional settings to improve accuracy of HP detect
  2015-09-16  9:42 [PATCH 0/9] Arizona Extcon Bug Fixes and Improvements Charles Keepax
                   ` (4 preceding siblings ...)
  2015-09-16  9:42 ` [PATCH 5/9] extcon: arizona: Add support for general purpose switch Charles Keepax
@ 2015-09-16  9:42 ` Charles Keepax
  2015-09-16  9:42 ` [PATCH 7/9] extcon: arizona: Ignore jd_invert for MICD_CLAMP_STS Charles Keepax
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Charles Keepax @ 2015-09-16  9:42 UTC (permalink / raw)
  To: cw00.choi, lee.jones; +Cc: myungjoo.ham, sameo, patches, linux-kernel

If the TST_CAP_SEL bits aren't set correctly on wm5110/8280 there will
be a 100k load along side the headphones, which will affect the accurary
towards the very top of the detection range. This patch sets those bits.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
---
 drivers/extcon/extcon-arizona.c |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index d719ee7..6d35147b 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -43,6 +43,9 @@
 #define ARIZONA_MICD_CLAMP_MODE_JDL_GP5H 0x9
 #define ARIZONA_MICD_CLAMP_MODE_JDH_GP5H 0xb
 
+#define ARIZONA_TST_CAP_DEFAULT 0x3
+#define ARIZONA_TST_CAP_CLAMP   0x1
+
 #define ARIZONA_HPDET_MAX 10000
 
 #define HPDET_DEBOUNCE 500
@@ -147,6 +150,7 @@ static void arizona_extcon_hp_clamp(struct arizona_extcon_info *info,
 {
 	struct arizona *arizona = info->arizona;
 	unsigned int mask = 0, val = 0;
+	unsigned int cap_sel = 0;
 	int ret;
 
 	switch (arizona->type) {
@@ -154,10 +158,21 @@ static void arizona_extcon_hp_clamp(struct arizona_extcon_info *info,
 	case WM8280:
 		mask = ARIZONA_HP1L_SHRTO | ARIZONA_HP1L_FLWR |
 		       ARIZONA_HP1L_SHRTI;
-		if (clamp)
+		if (clamp) {
 			val = ARIZONA_HP1L_SHRTO;
-		else
+			cap_sel = ARIZONA_TST_CAP_CLAMP;
+		} else {
 			val = ARIZONA_HP1L_FLWR | ARIZONA_HP1L_SHRTI;
+			cap_sel = ARIZONA_TST_CAP_DEFAULT;
+		}
+
+		ret = regmap_update_bits(arizona->regmap,
+					 ARIZONA_HP_TEST_CTRL_1,
+					 ARIZONA_HP1_TST_CAP_SEL_MASK,
+					 cap_sel);
+		if (ret != 0)
+			dev_warn(arizona->dev,
+				 "Failed to set TST_CAP_SEL: %d\n", ret);
 		break;
 	default:
 		mask = ARIZONA_RMV_SHRT_HP1L;
-- 
1.7.2.5


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 7/9] extcon: arizona: Ignore jd_invert for MICD_CLAMP_STS
  2015-09-16  9:42 [PATCH 0/9] Arizona Extcon Bug Fixes and Improvements Charles Keepax
                   ` (5 preceding siblings ...)
  2015-09-16  9:42 ` [PATCH 6/9] extcon: arizona: Additional settings to improve accuracy of HP detect Charles Keepax
@ 2015-09-16  9:42 ` Charles Keepax
  2015-09-16  9:42 ` [PATCH 8/9] extcon: arizona: Use the micd_clamp for interrupts if it is available Charles Keepax
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Charles Keepax @ 2015-09-16  9:42 UTC (permalink / raw)
  To: cw00.choi, lee.jones; +Cc: myungjoo.ham, sameo, patches, linux-kernel

From: Nariman Poushin <nariman@opensource.wolfsonmicro.com>

The polarity of MICD_CLAMP_STS does not change when different clamp
modes are used, this patch corrects this issue.

Signed-off-by: Nariman Poushin <nariman@opensource.wolfsonmicro.com>
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
---
 drivers/extcon/extcon-arizona.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index 6d35147b..ece5892 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -1059,10 +1059,7 @@ static irqreturn_t arizona_jackdet(int irq, void *data)
 
 	if (arizona->pdata.jd_gpio5) {
 		mask = ARIZONA_MICD_CLAMP_STS;
-		if (arizona->pdata.jd_invert)
-			present = ARIZONA_MICD_CLAMP_STS;
-		else
-			present = 0;
+		present = 0;
 	} else {
 		mask = ARIZONA_JD1_STS;
 		if (arizona->pdata.jd_invert)
-- 
1.7.2.5


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 8/9] extcon: arizona: Use the micd_clamp for interrupts if it is available
  2015-09-16  9:42 [PATCH 0/9] Arizona Extcon Bug Fixes and Improvements Charles Keepax
                   ` (6 preceding siblings ...)
  2015-09-16  9:42 ` [PATCH 7/9] extcon: arizona: Ignore jd_invert for MICD_CLAMP_STS Charles Keepax
@ 2015-09-16  9:42 ` Charles Keepax
  2015-09-16  9:42 ` [PATCH 9/9] extcon: arizona: Don't disable debounce for inverted jacks Charles Keepax
  2015-09-25  0:05 ` [PATCH 0/9] Arizona Extcon Bug Fixes and Improvements Chanwoo Choi
  9 siblings, 0 replies; 12+ messages in thread
From: Charles Keepax @ 2015-09-16  9:42 UTC (permalink / raw)
  To: cw00.choi, lee.jones; +Cc: myungjoo.ham, sameo, patches, linux-kernel

Currently we only use the microphone clamp IRQ if GPIO5 is being used as
a second jack detection pin. But we should be using it on any system
where the clamp is available. This patch updates the driver to do so.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 drivers/extcon/extcon-arizona.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index ece5892..9255c1f 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -1057,7 +1057,7 @@ static irqreturn_t arizona_jackdet(int irq, void *data)
 
 	mutex_lock(&info->lock);
 
-	if (arizona->pdata.jd_gpio5) {
+	if (info->micd_clamp) {
 		mask = ARIZONA_MICD_CLAMP_STS;
 		present = 0;
 	} else {
@@ -1504,7 +1504,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)
 	pm_runtime_idle(&pdev->dev);
 	pm_runtime_get_sync(&pdev->dev);
 
-	if (arizona->pdata.jd_gpio5) {
+	if (info->micd_clamp) {
 		jack_irq_rise = ARIZONA_IRQ_MICD_CLAMP_RISE;
 		jack_irq_fall = ARIZONA_IRQ_MICD_CLAMP_FALL;
 	} else {
@@ -1609,7 +1609,7 @@ static int arizona_extcon_remove(struct platform_device *pdev)
 			   ARIZONA_MICD_CLAMP_CONTROL,
 			   ARIZONA_MICD_CLAMP_MODE_MASK, 0);
 
-	if (arizona->pdata.jd_gpio5) {
+	if (info->micd_clamp) {
 		jack_irq_rise = ARIZONA_IRQ_MICD_CLAMP_RISE;
 		jack_irq_fall = ARIZONA_IRQ_MICD_CLAMP_FALL;
 	} else {
-- 
1.7.2.5


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 9/9] extcon: arizona: Don't disable debounce for inverted jacks
  2015-09-16  9:42 [PATCH 0/9] Arizona Extcon Bug Fixes and Improvements Charles Keepax
                   ` (7 preceding siblings ...)
  2015-09-16  9:42 ` [PATCH 8/9] extcon: arizona: Use the micd_clamp for interrupts if it is available Charles Keepax
@ 2015-09-16  9:42 ` Charles Keepax
  2015-09-25  0:05 ` [PATCH 0/9] Arizona Extcon Bug Fixes and Improvements Chanwoo Choi
  9 siblings, 0 replies; 12+ messages in thread
From: Charles Keepax @ 2015-09-16  9:42 UTC (permalink / raw)
  To: cw00.choi, lee.jones; +Cc: myungjoo.ham, sameo, patches, linux-kernel

Whilst the jack is connected we disable the jack detection debounce to
ensure as quick as possible a detection of jack removal. However, it is
only safe to disable the jack debounce whilst the jack is connected if
using the micd clamp or the jack is not inverted. Otherwise spurious
interrupts might be generated when we re-enable the debounce.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 drivers/extcon/extcon-arizona.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index 9255c1f..4479781 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -1118,9 +1118,11 @@ static irqreturn_t arizona_jackdet(int irq, void *data)
 					   msecs_to_jiffies(HPDET_DEBOUNCE));
 		}
 
-		regmap_update_bits(arizona->regmap,
-				   ARIZONA_JACK_DETECT_DEBOUNCE,
-				   ARIZONA_MICD_CLAMP_DB | ARIZONA_JD1_DB, 0);
+		if (info->micd_clamp || !arizona->pdata.jd_invert)
+			regmap_update_bits(arizona->regmap,
+					   ARIZONA_JACK_DETECT_DEBOUNCE,
+					   ARIZONA_MICD_CLAMP_DB |
+					   ARIZONA_JD1_DB, 0);
 	} else {
 		dev_dbg(arizona->dev, "Detected jack removal\n");
 
-- 
1.7.2.5


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/9] mfd: arizona: Add TST_CAP bits for headphone detection
  2015-09-16  9:42 ` [PATCH 3/9] mfd: arizona: Add TST_CAP bits for headphone detection Charles Keepax
@ 2015-09-20  4:17   ` Lee Jones
  0 siblings, 0 replies; 12+ messages in thread
From: Lee Jones @ 2015-09-20  4:17 UTC (permalink / raw)
  To: Charles Keepax; +Cc: cw00.choi, myungjoo.ham, sameo, patches, linux-kernel

On Wed, 16 Sep 2015, Charles Keepax wrote:

> On wm5110/8280 some additional settings are required to get accurate
> measurements at the top end of the headphone detection range. This patch
> adds the bits required for this.
> 
> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> ---
>  drivers/mfd/wm5110-tables.c           |    2 ++
>  include/linux/mfd/arizona/registers.h |    8 ++++++++
>  2 files changed, 10 insertions(+), 0 deletions(-)

Acked-by: Lee Jones <lee.jones@linaro.org>

> diff --git a/drivers/mfd/wm5110-tables.c b/drivers/mfd/wm5110-tables.c
> index aae17d6..28f2ae3 100644
> --- a/drivers/mfd/wm5110-tables.c
> +++ b/drivers/mfd/wm5110-tables.c
> @@ -1912,6 +1912,7 @@ static bool wm5110_readable_register(struct device *dev, unsigned int reg)
>  	case ARIZONA_HP1_SHORT_CIRCUIT_CTRL:
>  	case ARIZONA_HP2_SHORT_CIRCUIT_CTRL:
>  	case ARIZONA_HP3_SHORT_CIRCUIT_CTRL:
> +	case ARIZONA_HP_TEST_CTRL_1:
>  	case ARIZONA_AIF1_BCLK_CTRL:
>  	case ARIZONA_AIF1_TX_PIN_CTRL:
>  	case ARIZONA_AIF1_RX_PIN_CTRL:
> @@ -2857,6 +2858,7 @@ static bool wm5110_volatile_register(struct device *dev, unsigned int reg)
>  	case ARIZONA_INPUT_ENABLES_STATUS:
>  	case ARIZONA_OUTPUT_STATUS_1:
>  	case ARIZONA_RAW_OUTPUT_STATUS_1:
> +	case ARIZONA_HP_TEST_CTRL_1:
>  	case ARIZONA_SLIMBUS_RX_PORT_STATUS:
>  	case ARIZONA_SLIMBUS_TX_PORT_STATUS:
>  	case ARIZONA_INTERRUPT_STATUS_1:
> diff --git a/include/linux/mfd/arizona/registers.h b/include/linux/mfd/arizona/registers.h
> index ab219c9..c7c11c9 100644
> --- a/include/linux/mfd/arizona/registers.h
> +++ b/include/linux/mfd/arizona/registers.h
> @@ -242,6 +242,7 @@
>  #define ARIZONA_HP1_SHORT_CIRCUIT_CTRL           0x4A0
>  #define ARIZONA_HP2_SHORT_CIRCUIT_CTRL           0x4A1
>  #define ARIZONA_HP3_SHORT_CIRCUIT_CTRL           0x4A2
> +#define ARIZONA_HP_TEST_CTRL_1                   0x4A4
>  #define ARIZONA_SPK_CTRL_2                       0x4B5
>  #define ARIZONA_SPK_CTRL_3                       0x4B6
>  #define ARIZONA_DAC_COMP_1                       0x4DC
> @@ -3702,6 +3703,13 @@
>  #define ARIZONA_HP3_SC_ENA_WIDTH                      1  /* HP3_SC_ENA */
>  
>  /*
> + * R1188 (0x4A4) HP Test Ctrl 1
> + */
> +#define ARIZONA_HP1_TST_CAP_SEL_MASK             0x0003  /* HP1_TST_CAP_SEL - [1:0] */
> +#define ARIZONA_HP1_TST_CAP_SEL_SHIFT                 0  /* HP1_TST_CAP_SEL - [1:0] */
> +#define ARIZONA_HP1_TST_CAP_SEL_WIDTH                 2  /* HP1_TST_CAP_SEL - [1:0] */
> +
> +/*
>   * R1244 (0x4DC) - DAC comp 1
>   */
>  #define ARIZONA_OUT_COMP_COEFF_MASK              0xFFFF  /* OUT_COMP_COEFF - [15:0] */

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/9] Arizona Extcon Bug Fixes and Improvements
  2015-09-16  9:42 [PATCH 0/9] Arizona Extcon Bug Fixes and Improvements Charles Keepax
                   ` (8 preceding siblings ...)
  2015-09-16  9:42 ` [PATCH 9/9] extcon: arizona: Don't disable debounce for inverted jacks Charles Keepax
@ 2015-09-25  0:05 ` Chanwoo Choi
  9 siblings, 0 replies; 12+ messages in thread
From: Chanwoo Choi @ 2015-09-25  0:05 UTC (permalink / raw)
  To: Charles Keepax, lee.jones; +Cc: myungjoo.ham, sameo, patches, linux-kernel

Hi Charles and Lee,

I create the immutable branch[1] for this patch-set.
[1] https://git.kernel.org/cgit/linux/kernel/git/chanwoo/extcon.git/ (branch: ib-extcon-mfd-4.4)

I'll send pull request to Lee Jones today.

Best Regards,
Chanwoo Choi

On 2015년 09월 16일 18:42, Charles Keepax wrote:
> Hi,
> 
> Ok I have split these patches out into 2 chains; this chain
> contains no device tree changes so that should let us merge
> these now and at least get the benefit of the bug fixes
> etc. whilst we work on getting the necessary ACKs for the
> DT changes. The DT changes themselves should be simpler to
> merge as there are no build dependencies there between the
> extcon and MFD patches so they can just each go through
> their respective trees. Whereas this chain needs to all go
> through one tree.
> 
> These patches add support for the ADC mode microphone
> detection, and the general purpose switch for pop
> suppression. The bug fixes include fixing the headphone
> detection accuracy at the top end of the range and some
> corrections around the use of the microphone clamps.
> 
> Thanks,
> Charles
> 
> Charles Keepax (8):
>   mfd: arizona: Add registers for ADC microphone detection
>   mfd: arizona: Add register bits for general purpose switch
>   mfd: arizona: Add TST_CAP bits for headphone detection
>   extcon: arizona: Add support for new ADC value mic detect
>   extcon: arizona: Add support for general purpose switch
>   extcon: arizona: Additional settings to improve accuracy of HP detect
>   extcon: arizona: Use the micd_clamp for interrupts if it is available
>   extcon: arizona: Don't disable debounce for inverted jacks
> 
> Nariman Poushin (1):
>   extcon: arizona: Ignore jd_invert for MICD_CLAMP_STS
> 
>  drivers/extcon/extcon-arizona.c       |  106 +++++++++++++++++++++++++++------
>  drivers/mfd/wm5110-tables.c           |    6 ++
>  include/dt-bindings/mfd/arizona.h     |    2 +
>  include/linux/mfd/arizona/pdata.h     |    6 ++
>  include/linux/mfd/arizona/registers.h |   14 ++++-
>  5 files changed, 113 insertions(+), 21 deletions(-)
> 


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2015-09-25  0:05 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-16  9:42 [PATCH 0/9] Arizona Extcon Bug Fixes and Improvements Charles Keepax
2015-09-16  9:42 ` [PATCH 1/9] mfd: arizona: Add registers for ADC microphone detection Charles Keepax
2015-09-16  9:42 ` [PATCH 2/9] mfd: arizona: Add register bits for general purpose switch Charles Keepax
2015-09-16  9:42 ` [PATCH 3/9] mfd: arizona: Add TST_CAP bits for headphone detection Charles Keepax
2015-09-20  4:17   ` Lee Jones
2015-09-16  9:42 ` [PATCH 4/9] extcon: arizona: Add support for new ADC value mic detect Charles Keepax
2015-09-16  9:42 ` [PATCH 5/9] extcon: arizona: Add support for general purpose switch Charles Keepax
2015-09-16  9:42 ` [PATCH 6/9] extcon: arizona: Additional settings to improve accuracy of HP detect Charles Keepax
2015-09-16  9:42 ` [PATCH 7/9] extcon: arizona: Ignore jd_invert for MICD_CLAMP_STS Charles Keepax
2015-09-16  9:42 ` [PATCH 8/9] extcon: arizona: Use the micd_clamp for interrupts if it is available Charles Keepax
2015-09-16  9:42 ` [PATCH 9/9] extcon: arizona: Don't disable debounce for inverted jacks Charles Keepax
2015-09-25  0:05 ` [PATCH 0/9] Arizona Extcon Bug Fixes and Improvements Chanwoo Choi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox