* [PATCH 1/5] extcon: arizona: Disable debouce for accessory removal detection
@ 2013-01-23 16:03 Mark Brown
2013-01-23 16:03 ` [PATCH 2/5] extcon: arizona: Retry failed HP measurements Mark Brown
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Mark Brown @ 2013-01-23 16:03 UTC (permalink / raw)
To: MyungJoo Ham, Chanwoo Choi; +Cc: patches, linux-kernel, Mark Brown
Ensure we clamp as quickly as possible after removal by disabling the
debounce while there is an accessory present.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
drivers/extcon/extcon-arizona.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index de141f7..ce95f86 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -773,6 +773,10 @@ static irqreturn_t arizona_jackdet(int irq, void *data)
} else {
arizona_start_hpdet_acc_id(info);
}
+
+ 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");
@@ -792,6 +796,11 @@ static irqreturn_t arizona_jackdet(int irq, void *data)
if (ret != 0)
dev_err(arizona->dev, "Removal report failed: %d\n",
ret);
+
+ regmap_update_bits(arizona->regmap,
+ ARIZONA_JACK_DETECT_DEBOUNCE,
+ ARIZONA_MICD_CLAMP_DB | ARIZONA_JD1_DB,
+ ARIZONA_MICD_CLAMP_DB | ARIZONA_JD1_DB);
}
mutex_unlock(&info->lock);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/5] extcon: arizona: Retry failed HP measurements
2013-01-23 16:03 [PATCH 1/5] extcon: arizona: Disable debouce for accessory removal detection Mark Brown
@ 2013-01-23 16:03 ` Mark Brown
2013-01-23 16:03 ` [PATCH 3/5] extcon: arizona: Remove duplicate rate configuration Mark Brown
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2013-01-23 16:03 UTC (permalink / raw)
To: MyungJoo Ham, Chanwoo Choi; +Cc: patches, linux-kernel, Mark Brown
We now have mechanisms in place to allow retries so let's use them rather
than guessing.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
drivers/extcon/extcon-arizona.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index ce95f86..5283034 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -31,8 +31,6 @@
#include <linux/mfd/arizona/pdata.h>
#include <linux/mfd/arizona/registers.h>
-#define ARIZONA_DEFAULT_HP 32
-
#define ARIZONA_NUM_BUTTONS 6
#define ARIZONA_ACCDET_MODE_MIC 0
@@ -208,7 +206,7 @@ static int arizona_hpdet_read(struct arizona_extcon_info *info)
if (!(val & ARIZONA_HP_DONE)) {
dev_err(arizona->dev, "HPDET did not complete: %x\n",
val);
- val = ARIZONA_DEFAULT_HP;
+ return -EAGAIN;
}
val &= ARIZONA_HP_LVL_MASK;
@@ -218,14 +216,14 @@ static int arizona_hpdet_read(struct arizona_extcon_info *info)
if (!(val & ARIZONA_HP_DONE_B)) {
dev_err(arizona->dev, "HPDET did not complete: %x\n",
val);
- return ARIZONA_DEFAULT_HP;
+ return -EAGAIN;
}
ret = regmap_read(arizona->regmap, ARIZONA_HP_DACVAL, &val);
if (ret != 0) {
dev_err(arizona->dev, "Failed to read HP value: %d\n",
ret);
- return ARIZONA_DEFAULT_HP;
+ return -EAGAIN;
}
regmap_read(arizona->regmap, ARIZONA_HEADPHONE_DETECT_1,
@@ -267,7 +265,7 @@ static int arizona_hpdet_read(struct arizona_extcon_info *info)
if (!(val & ARIZONA_HP_DONE_B)) {
dev_err(arizona->dev, "HPDET did not complete: %x\n",
val);
- return ARIZONA_DEFAULT_HP;
+ return -EAGAIN;
}
val &= ARIZONA_HP_LVL_B_MASK;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/5] extcon: arizona: Remove duplicate rate configuration
2013-01-23 16:03 [PATCH 1/5] extcon: arizona: Disable debouce for accessory removal detection Mark Brown
2013-01-23 16:03 ` [PATCH 2/5] extcon: arizona: Retry failed HP measurements Mark Brown
@ 2013-01-23 16:03 ` Mark Brown
2013-01-23 16:03 ` [PATCH 4/5] extcon: arizona: Support additional configuration of microphone detection Mark Brown
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2013-01-23 16:03 UTC (permalink / raw)
To: MyungJoo Ham, Chanwoo Choi; +Cc: patches, linux-kernel, Mark Brown
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
drivers/extcon/extcon-arizona.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index 5283034..ab8b9c7 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -1003,10 +1003,6 @@ static int arizona_extcon_probe(struct platform_device *pdev)
goto err_micdet;
}
- regmap_update_bits(arizona->regmap, ARIZONA_MIC_DETECT_1,
- ARIZONA_MICD_RATE_MASK,
- 8 << ARIZONA_MICD_RATE_SHIFT);
-
arizona_clk32k_enable(arizona);
regmap_update_bits(arizona->regmap, ARIZONA_JACK_DETECT_DEBOUNCE,
ARIZONA_JD1_DB, ARIZONA_JD1_DB);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/5] extcon: arizona: Support additional configuration of microphone detection
2013-01-23 16:03 [PATCH 1/5] extcon: arizona: Disable debouce for accessory removal detection Mark Brown
2013-01-23 16:03 ` [PATCH 2/5] extcon: arizona: Retry failed HP measurements Mark Brown
2013-01-23 16:03 ` [PATCH 3/5] extcon: arizona: Remove duplicate rate configuration Mark Brown
@ 2013-01-23 16:03 ` Mark Brown
2013-01-23 16:03 ` [PATCH 5/5] extcon: arizona: Use regulated mode for microphone supply when detecting Mark Brown
2013-01-24 1:10 ` [PATCH 1/5] extcon: arizona: Disable debouce for accessory removal detection Chanwoo Choi
4 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2013-01-23 16:03 UTC (permalink / raw)
To: MyungJoo Ham, Chanwoo Choi; +Cc: patches, linux-kernel, Mark Brown
Allow systems to tune detection rate and debounce suitably for their
mechanical parameters.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
drivers/extcon/extcon-arizona.c | 12 ++++++++++++
include/linux/mfd/arizona/pdata.h | 6 ++++++
2 files changed, 18 insertions(+)
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index ab8b9c7..d7e1047 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -907,6 +907,18 @@ static int arizona_extcon_probe(struct platform_device *pdev)
arizona->pdata.micd_bias_start_time
<< ARIZONA_MICD_BIAS_STARTTIME_SHIFT);
+ if (arizona->pdata.micd_rate)
+ regmap_update_bits(arizona->regmap, ARIZONA_MIC_DETECT_1,
+ ARIZONA_MICD_RATE_MASK,
+ arizona->pdata.micd_rate
+ << ARIZONA_MICD_RATE_SHIFT);
+
+ if (arizona->pdata.micd_dbtime)
+ regmap_update_bits(arizona->regmap, ARIZONA_MIC_DETECT_1,
+ ARIZONA_MICD_DBTIME_MASK,
+ arizona->pdata.micd_dbtime
+ << ARIZONA_MICD_DBTIME_SHIFT);
+
/*
* If we have a clamp use it, activating in conjunction with
* GPIO5 if that is connected for jack detect operation.
diff --git a/include/linux/mfd/arizona/pdata.h b/include/linux/mfd/arizona/pdata.h
index bcbe4fd..2f5f08e 100644
--- a/include/linux/mfd/arizona/pdata.h
+++ b/include/linux/mfd/arizona/pdata.h
@@ -111,6 +111,12 @@ struct arizona_pdata {
/** Mic detect ramp rate */
int micd_bias_start_time;
+ /** Mic detect sample rate */
+ int micd_rate;
+
+ /** Mic detect debounce level */
+ int micd_dbtime;
+
/** Headset polarity configurations */
struct arizona_micd_config *micd_configs;
int num_micd_configs;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 5/5] extcon: arizona: Use regulated mode for microphone supply when detecting
2013-01-23 16:03 [PATCH 1/5] extcon: arizona: Disable debouce for accessory removal detection Mark Brown
` (2 preceding siblings ...)
2013-01-23 16:03 ` [PATCH 4/5] extcon: arizona: Support additional configuration of microphone detection Mark Brown
@ 2013-01-23 16:03 ` Mark Brown
2013-01-24 0:59 ` Chanwoo Choi
2013-01-24 1:10 ` [PATCH 1/5] extcon: arizona: Disable debouce for accessory removal detection Chanwoo Choi
4 siblings, 1 reply; 7+ messages in thread
From: Mark Brown @ 2013-01-23 16:03 UTC (permalink / raw)
To: MyungJoo Ham, Chanwoo Choi; +Cc: patches, linux-kernel, Mark Brown
When starting microphone detection some headsets should be exposed to
the fully regulated microphone bias in order to ensure that they behave
in an optimal fashion.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
drivers/extcon/extcon-arizona.c | 62 +++++++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index d7e1047..3aacacc 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -27,6 +27,8 @@
#include <linux/regulator/consumer.h>
#include <linux/extcon.h>
+#include <sound/soc.h>
+
#include <linux/mfd/arizona/core.h>
#include <linux/mfd/arizona/pdata.h>
#include <linux/mfd/arizona/registers.h>
@@ -113,6 +115,40 @@ static void arizona_extcon_set_mode(struct arizona_extcon_info *info, int mode)
dev_dbg(arizona->dev, "Set jack polarity to %d\n", mode);
}
+static void arizona_extcon_pulse_micbias(struct arizona_extcon_info *info)
+{
+ struct arizona *arizona = info->arizona;
+ const char *widget;
+ int ret;
+
+ if (arizona->dapm) {
+ switch (info->micd_modes[0].bias) {
+ case 1:
+ widget = "MICBIAS1";
+ break;
+ case 2:
+ widget = "MICBIAS2";
+ break;
+ case 3:
+ widget = "MICBIAS3";
+ break;
+ default:
+ widget = "MICVDD";
+ break;
+ }
+
+ ret = snd_soc_dapm_force_enable_pin(arizona->dapm, widget);
+ if (ret != 0)
+ dev_warn(arizona->dev, "Failed to enable %s: %d\n",
+ widget, ret);
+
+ ret = snd_soc_dapm_disable_pin(arizona->dapm, widget);
+ if (ret != 0)
+ dev_warn(arizona->dev, "Failed to disable %s: %d\n",
+ widget, ret);
+ }
+}
+
static void arizona_start_mic(struct arizona_extcon_info *info)
{
struct arizona *arizona = info->arizona;
@@ -122,6 +158,15 @@ static void arizona_start_mic(struct arizona_extcon_info *info)
/* Microphone detection can't use idle mode */
pm_runtime_get(info->dev);
+ if (info->detecting) {
+ ret = regulator_allow_bypass(info->micvdd, false);
+ if (ret != 0) {
+ dev_err(arizona->dev,
+ "Failed to regulate MICVDD: %d\n",
+ ret);
+ }
+ }
+
ret = regulator_enable(info->micvdd);
if (ret != 0) {
dev_err(arizona->dev, "Failed to enable MICVDD: %d\n",
@@ -151,6 +196,7 @@ static void arizona_stop_mic(struct arizona_extcon_info *info)
{
struct arizona *arizona = info->arizona;
bool change;
+ int ret;
regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1,
ARIZONA_MICD_ENA, 0,
@@ -162,6 +208,12 @@ static void arizona_stop_mic(struct arizona_extcon_info *info)
regmap_write(arizona->regmap, 0x80, 0x0);
}
+ ret = regulator_allow_bypass(info->micvdd, true);
+ if (ret != 0) {
+ dev_err(arizona->dev, "Failed to bypass MICVDD: %d\n",
+ ret);
+ }
+
if (change) {
regulator_disable(info->micvdd);
pm_runtime_mark_last_busy(info->dev);
@@ -564,6 +616,8 @@ static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info)
info->hpdet_active = true;
+ arizona_extcon_pulse_micbias(info);
+
ret = regmap_update_bits(arizona->regmap, 0x225, 0x4000, 0x4000);
if (ret != 0)
dev_warn(arizona->dev, "Failed to do magic: %d\n", ret);
@@ -649,6 +703,13 @@ static irqreturn_t arizona_micdet(int irq, void *data)
dev_err(arizona->dev, "Headset report failed: %d\n",
ret);
+ /* Don't need to regulate for button detection */
+ ret = regulator_allow_bypass(info->micvdd, false);
+ if (ret != 0) {
+ dev_err(arizona->dev, "Failed to bypass MICVDD: %d\n",
+ ret);
+ }
+
info->mic = true;
info->detecting = false;
goto handled;
@@ -716,6 +777,7 @@ static irqreturn_t arizona_micdet(int irq, void *data)
input_report_key(info->input,
arizona_lvl_to_key[i].report, 0);
input_sync(info->input);
+ arizona_extcon_pulse_micbias(info);
}
handled:
--
1.7.10.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 5/5] extcon: arizona: Use regulated mode for microphone supply when detecting
2013-01-23 16:03 ` [PATCH 5/5] extcon: arizona: Use regulated mode for microphone supply when detecting Mark Brown
@ 2013-01-24 0:59 ` Chanwoo Choi
0 siblings, 0 replies; 7+ messages in thread
From: Chanwoo Choi @ 2013-01-24 0:59 UTC (permalink / raw)
To: Mark Brown; +Cc: MyungJoo Ham, patches, linux-kernel
On 01/24/2013 01:03 AM, Mark Brown wrote:
> When starting microphone detection some headsets should be exposed to
> the fully regulated microphone bias in order to ensure that they behave
> in an optimal fashion.
>
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
> drivers/extcon/extcon-arizona.c | 62 +++++++++++++++++++++++++++++++++++++++
> 1 file changed, 62 insertions(+)
>
> diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
> index d7e1047..3aacacc 100644
> --- a/drivers/extcon/extcon-arizona.c
> +++ b/drivers/extcon/extcon-arizona.c
> @@ -27,6 +27,8 @@
> #include <linux/regulator/consumer.h>
> #include <linux/extcon.h>
>
> +#include <sound/soc.h>
> +
> #include <linux/mfd/arizona/core.h>
> #include <linux/mfd/arizona/pdata.h>
> #include <linux/mfd/arizona/registers.h>
> @@ -113,6 +115,40 @@ static void arizona_extcon_set_mode(struct arizona_extcon_info *info, int mode)
> dev_dbg(arizona->dev, "Set jack polarity to %d\n", mode);
> }
>
> +static void arizona_extcon_pulse_micbias(struct arizona_extcon_info *info)
> +{
> + struct arizona *arizona = info->arizona;
> + const char *widget;
> + int ret;
> +
> + if (arizona->dapm) {
> + switch (info->micd_modes[0].bias) {
> + case 1:
> + widget = "MICBIAS1";
> + break;
> + case 2:
> + widget = "MICBIAS2";
> + break;
> + case 3:
> + widget = "MICBIAS3";
> + break;
> + default:
> + widget = "MICVDD";
> + break;
> + }
> +
> + ret = snd_soc_dapm_force_enable_pin(arizona->dapm, widget);
> + if (ret != 0)
> + dev_warn(arizona->dev, "Failed to enable %s: %d\n",
> + widget, ret);
> +
> + ret = snd_soc_dapm_disable_pin(arizona->dapm, widget);
> + if (ret != 0)
> + dev_warn(arizona->dev, "Failed to disable %s: %d\n",
> + widget, ret);
> + }
> +}
> +
> static void arizona_start_mic(struct arizona_extcon_info *info)
> {
> struct arizona *arizona = info->arizona;
> @@ -122,6 +158,15 @@ static void arizona_start_mic(struct arizona_extcon_info *info)
> /* Microphone detection can't use idle mode */
> pm_runtime_get(info->dev);
>
> + if (info->detecting) {
> + ret = regulator_allow_bypass(info->micvdd, false);
> + if (ret != 0) {
> + dev_err(arizona->dev,
> + "Failed to regulate MICVDD: %d\n",
> + ret);
> + }
> + }
> +
> ret = regulator_enable(info->micvdd);
> if (ret != 0) {
> dev_err(arizona->dev, "Failed to enable MICVDD: %d\n",
> @@ -151,6 +196,7 @@ static void arizona_stop_mic(struct arizona_extcon_info *info)
> {
> struct arizona *arizona = info->arizona;
> bool change;
> + int ret;
>
> regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1,
> ARIZONA_MICD_ENA, 0,
> @@ -162,6 +208,12 @@ static void arizona_stop_mic(struct arizona_extcon_info *info)
> regmap_write(arizona->regmap, 0x80, 0x0);
> }
>
> + ret = regulator_allow_bypass(info->micvdd, true);
> + if (ret != 0) {
> + dev_err(arizona->dev, "Failed to bypass MICVDD: %d\n",
> + ret);
> + }
> +
> if (change) {
> regulator_disable(info->micvdd);
> pm_runtime_mark_last_busy(info->dev);
> @@ -564,6 +616,8 @@ static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info)
>
> info->hpdet_active = true;
>
> + arizona_extcon_pulse_micbias(info);
> +
> ret = regmap_update_bits(arizona->regmap, 0x225, 0x4000, 0x4000);
> if (ret != 0)
> dev_warn(arizona->dev, "Failed to do magic: %d\n", ret);
> @@ -649,6 +703,13 @@ static irqreturn_t arizona_micdet(int irq, void *data)
> dev_err(arizona->dev, "Headset report failed: %d\n",
> ret);
>
> + /* Don't need to regulate for button detection */
> + ret = regulator_allow_bypass(info->micvdd, false);
> + if (ret != 0) {
> + dev_err(arizona->dev, "Failed to bypass MICVDD: %d\n",
> + ret);
> + }
> +
> info->mic = true;
> info->detecting = false;
> goto handled;
> @@ -716,6 +777,7 @@ static irqreturn_t arizona_micdet(int irq, void *data)
> input_report_key(info->input,
> arizona_lvl_to_key[i].report, 0);
> input_sync(info->input);
> + arizona_extcon_pulse_micbias(info);
> }
>
> handled:
This patch happen build error related to soc-dapm. You should add 'CONFIG_SND_SOC'
dependency to drivers/extcon/Kconfig for extcon-arizona driver.
drivers/built-in.o: In function `arizona_extcon_pulse_micbias':
/home/cwchoi00/kernel/git.kernel.org/extcon/drivers/extcon/extcon-arizona.c:140: undefined reference
to `snd_soc_dapm_force_enable_pin'
/home/cwchoi00/kernel/git.kernel.org/extcon/drivers/extcon/extcon-arizona.c:145: undefined reference
to `snd_soc_dapm_disable_pin'
/home/cwchoi00/kernel/git.kernel.org/extcon/drivers/extcon/extcon-arizona.c:145: undefined reference
to `snd_soc_dapm_disable_pin'
Thanks,
Chanwoo Choi
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/5] extcon: arizona: Disable debouce for accessory removal detection
2013-01-23 16:03 [PATCH 1/5] extcon: arizona: Disable debouce for accessory removal detection Mark Brown
` (3 preceding siblings ...)
2013-01-23 16:03 ` [PATCH 5/5] extcon: arizona: Use regulated mode for microphone supply when detecting Mark Brown
@ 2013-01-24 1:10 ` Chanwoo Choi
4 siblings, 0 replies; 7+ messages in thread
From: Chanwoo Choi @ 2013-01-24 1:10 UTC (permalink / raw)
To: Mark Brown; +Cc: MyungJoo Ham, patches, linux-kernel
On 01/24/2013 01:03 AM, Mark Brown wrote:
> Ensure we clamp as quickly as possible after removal by disabling the
> debounce while there is an accessory present.
>
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
> drivers/extcon/extcon-arizona.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
Patches 1-4 applied.
Patch 5 failed to build, so I sent reply related to build error of Patch 5.
Thanks,
Chanwoo Choi
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-01-24 1:10 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-23 16:03 [PATCH 1/5] extcon: arizona: Disable debouce for accessory removal detection Mark Brown
2013-01-23 16:03 ` [PATCH 2/5] extcon: arizona: Retry failed HP measurements Mark Brown
2013-01-23 16:03 ` [PATCH 3/5] extcon: arizona: Remove duplicate rate configuration Mark Brown
2013-01-23 16:03 ` [PATCH 4/5] extcon: arizona: Support additional configuration of microphone detection Mark Brown
2013-01-23 16:03 ` [PATCH 5/5] extcon: arizona: Use regulated mode for microphone supply when detecting Mark Brown
2013-01-24 0:59 ` Chanwoo Choi
2013-01-24 1:10 ` [PATCH 1/5] extcon: arizona: Disable debouce for accessory removal detection Chanwoo Choi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox