Skip to content

Commit 0e27bd3

Browse files
committed
extcon: arizona: Add some debounce time before starting HPDET identification
The HPDET identification method does not have the same natural debounce built into it that the standard MICDET method does so add some extra on top of what the jack detection does in hardware to make sure we get a robust result. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
1 parent e339af1 commit 0e27bd3

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

‎drivers/extcon/extcon-arizona.c‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ struct arizona_extcon_info {
5353
bool micd_reva;
5454
bool micd_clamp;
5555

56+
struct delayed_work hpdet_work;
57+
5658
bool hpdet_active;
5759

5860
int num_hpdet_res;
@@ -640,7 +642,7 @@ static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info)
640642
dev_dbg(arizona->dev, "Starting identification via HPDET\n");
641643

642644
/* Make sure we keep the device enabled during the measurement */
643-
pm_runtime_get(info->dev);
645+
pm_runtime_get_sync(info->dev);
644646

645647
info->hpdet_active = true;
646648

@@ -813,6 +815,17 @@ static irqreturn_t arizona_micdet(int irq, void *data)
813815
return IRQ_HANDLED;
814816
}
815817

818+
static void arizona_hpdet_work(struct work_struct *work)
819+
{
820+
struct arizona_extcon_info *info = container_of(work,
821+
struct arizona_extcon_info,
822+
hpdet_work.work);
823+
824+
mutex_lock(&info->lock);
825+
arizona_start_hpdet_acc_id(info);
826+
mutex_unlock(&info->lock);
827+
}
828+
816829
static irqreturn_t arizona_jackdet(int irq, void *data)
817830
{
818831
struct arizona_extcon_info *info = data;
@@ -822,6 +835,8 @@ static irqreturn_t arizona_jackdet(int irq, void *data)
822835

823836
pm_runtime_get_sync(info->dev);
824837

838+
cancel_delayed_work_sync(&info->hpdet_work);
839+
825840
mutex_lock(&info->lock);
826841

827842
if (arizona->pdata.jd_gpio5) {
@@ -857,7 +872,8 @@ static irqreturn_t arizona_jackdet(int irq, void *data)
857872

858873
arizona_start_mic(info);
859874
} else {
860-
arizona_start_hpdet_acc_id(info);
875+
schedule_delayed_work(&info->hpdet_work,
876+
msecs_to_jiffies(250));
861877
}
862878

863879
regmap_update_bits(arizona->regmap,
@@ -927,6 +943,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)
927943
mutex_init(&info->lock);
928944
info->arizona = arizona;
929945
info->dev = &pdev->dev;
946+
INIT_DELAYED_WORK(&info->hpdet_work, arizona_hpdet_work);
930947
platform_set_drvdata(pdev, info);
931948

932949
switch (arizona->type) {
@@ -1173,6 +1190,7 @@ static int arizona_extcon_remove(struct platform_device *pdev)
11731190
arizona_free_irq(arizona, ARIZONA_IRQ_MICDET, info);
11741191
arizona_free_irq(arizona, jack_irq_rise, info);
11751192
arizona_free_irq(arizona, jack_irq_fall, info);
1193+
cancel_delayed_work_sync(&info->hpdet_work);
11761194
regmap_update_bits(arizona->regmap, ARIZONA_JACK_DETECT_ANALOGUE,
11771195
ARIZONA_JD1_ENA, 0);
11781196
arizona_clk32k_disable(arizona);

0 commit comments

Comments
 (0)